Slashdot Mirror


Detecting Rootkits In GNU/Linux

An anonymous reader sends note of a blog post on rootkit detection in GNU/Linux. The article mentions only two utilities for ferreting out rootkits — the first comment to the blog post lists three additional ones — but it could be useful for those who haven't thought about the problem much. From the article: "A rootkit... is a collection of tools that a cracker installs on a victim's computer after gaining initial access. It generally consists of log cleaning scripts and trojaned replacements of core system utilities such as ps, top, ifconfig and so on."

38 of 142 comments (clear)

  1. ifl by stoolpigeon · · Score: 3, Informative

    I think that there is room to mention the well known tools such as AIDA and TripWire and LogCheck.

    --
    It's hard to believe that's how Micronians are made. Why don't we see it right now by having you both kiss one another?
    1. Re:ifl by Moby+Cock · · Score: 4, Informative

      Most modern rootkits are kernel level and Trip Wire can not readily detect them. Nevertheless it is still useful to have at hand.

    2. Re:ifl by stoolpigeon · · Score: 4, Funny

      i have no idea. i've never used any of them. this is a joke gone completely wrong. i just copied and pasted the comment from over at tfa. hence my subject: ifl (it's funny laugh). i figured it'd end up troll, over-rated, but i got such a laugh out of doing it (sorry i'm easily amused) that i figured it was worth it. in what is a horrid twist of fate, i now feel bad for getting modded up.

      --
      It's hard to believe that's how Micronians are made. Why don't we see it right now by having you both kiss one another?
    3. Re:ifl by computational+super · · Score: 3, Insightful

      You know, one of the things I'd like to do if I had more time and knew how to do it would be to create a bootable "system scan" disk. A rootkit could hide itself from tripwire et al, but it couldn't hide from a bootable CD. I guess you can sort of achieve the same effect with Knoppix with a bit of work, but it would be nice to have something that I could use to scan a machine for vulnerabilities without using the hard drive to boot at all.

      --
      Proud neuron in the Slashdot hivemind since 2002.
    4. Re:ifl by Anonymous Coward · · Score: 3, Informative

      Something like this?

    5. Re:ifl by Jackmn · · Score: 2, Informative
      . The system could be almost completely restored on an orderly shutdown, leaving nothing detectable but a single hook (hide everything else in swap or unused sectors in filesystem)
      The only way to leave a 'hook' on any common setup is to modify the storage medium of the OS or modify the firmware of a piece of hardware. Both can be detected, and there's no way to prevent that.

      MD5 hashes can be subverted, which means the above mentioned initial hook could hide (I believe this is only really useful if the hook was in the original package and you are turning it on by changing a single bit)
      There is no known computationally viable way any decent hash can be 'subverted' in the manner you are implying. Changing a single bit will completely change the hash of a binary with any decent hashing algorithm. You're not going to be able to find a hash collision that provides you with a binary that is the same size as the one you are replacing and does everything you want.
  2. This is... by Creepy+Crawler · · Score: 2, Informative

    For starters, why you do NOT keep any sort of compiler on your machine.

    It's rather difficult to load kernel obfuscation modules (like hiding processes and files) without header files and no compiler.

    It'd be even better if you could make every program execute only (no reading) and hide /proc through something like NSASecurity setup. What they dont know, they cant do much with. Obfuscation, THEN security. Keep em guessing.

    --
    1. Re:This is... by Rosco+P.+Coltrane · · Score: 5, Informative

      It's rather difficult to load kernel obfuscation modules (like hiding processes and files) without header files and no compiler.

      I'll tell you a little secret: if you know the kernel version number and target architecture, you can build a module on another, totally different machine. Wow! 2007 technology man!

      --
      "A door is what a dog is perpetually on the wrong side of" - Ogden Nash
    2. Re:This is... by psycho8me · · Score: 5, Interesting

      That may have been true 30 years ago when a compiler license cost thousands. If a person has write access to your system, they can just copy a compiler binary over.

    3. Re:This is... by seifried · · Score: 4, Interesting

      Does root have access to /proc/kcore? If yes then an attacker with root access can modify the kernel in memory as needed. Heck there's even projects to bring this into the mainstream for carrier grade Linux (no need for those pesky reboots after a kernel upgrade): http://pannus.sourceforge.net/

    4. Re:This is... by diegocgteleline.es · · Score: 3, Funny

      Real men and real hackers write their programs in binary code, not in stupid and bloated assembler.

    5. Re:This is... by gmack · · Score: 2, Insightful

      Point well taken, but I do wonder how often these kind of exploits actually happen in the wild on linux or on commercial unixen.

      Often enough. Exploits will be written for any OS that has a decent return on investment time wise. These days that means both Windows and Linux. You could actually see this in when the better architected OpenSSH became the standard for most Linux distros the move to Linux brought a bunch of new eyes to go over the code and a bunch of exploits got discovered in a really short time.

      Linux isn't the only one of course a couple of years back I left a new FreeBSD install over night without locking it down and discovered a root kit waiting for me in the morning.

      I used to get more calls than I get now though. The Linux vendors have improved a lot and removed crap like WuFTPd, sendmail and moved to the rewritten bind9. Those moves a have cut the attack vector and instead of system daemons being the main focus it's badly written web apps being used to gain a shell and then a local root exploit used to gain root.

      The really fascinating thing is that I've seen custom PHP scripts get scanned for common programming mistakes and exploited

      So all that to say basically Linux gets hit too it is better than Windows by a long shot but it's not perfect. Keep your distro patched.

  3. Ah! No need for rootkit detector... by Rosco+P.+Coltrane · · Score: 4, Funny

    ... with the Internet Freedom Disk!

    --
    "A door is what a dog is perpetually on the wrong side of" - Ogden Nash
    1. Re:Ah! No need for rootkit detector... by Anonymous Coward · · Score: 2, Funny
      ... with the Internet Freedom Disk!
      First it was "freedom fries," and now they've gone and corrupted what was once a perfectly fine Internet French Disk with their misplaced patriotism.
  4. OSSEC HIDS by magmf · · Score: 2, Informative

    I PREFFER OSSEC HIDS to do this. look www.ossec.net i think this is the most powerfull agent ever :)

    --
    Marcus Maciel(ScOrP|On) System/Network Administrator/Security Officer www.underlinux.com.br
  5. Pish Posh by eno2001 · · Score: 5, Funny

    It's GNU/Linux. Any hacker worth his salt doesn't want to bother with archaic OSes based on Unix. He wants the 1337 stylings of Windows Vista. No sense in rootkitting a *nix box. You can't do anything with a *nix box. But an army of zombie Vista PCs, now THAT is ULTIMATE POWER!

    --
    -"...bad old ideas look confusingly fresh when they are packaged as technology" - Jaron Lanier (Digital Maoism on Edge.o
  6. Compiler is Irrelevant by brunes69 · · Score: 3, Informative

    It's pretty trivial to just deduce what kernel the machine is running and build working binaries wherever you want. In fact it would be preferred, since a sysadmin is far more likely to notice a rogue gcc process sucking up CPU than a file transfer while the rootkit is being loaded.

    Anyway - if the person has root on the box (which they need to install the rootkit anyway), then they can just ship up THEIR OWN COMPILER if they want to regardless.

    1. Re:Compiler is Irrelevant by profplump · · Score: 4, Insightful

      First, let me introduce you to the file command, which can tell me all about your arch. Or failing that, less, or any other program than can read any binary on your system. Your binary executables necessarily include information about their format, including their architecture.

      spaceheater ~ 0$ file /bin/bash
      /bin/bash: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.0.0, dynamically linked (uses shared libs), not stripped

      Second, why are you worried about compilers and version numbers if you're so sure people can't load modules anyway? What exactly are you trying to protect? There's something to be said for a minimalistic system, but you've yet to explain how having a compiler installed poses any sort of realistic security threat.

      Finally, what's to keep someone from simply replacing your entire hand-complied, monolithic kernel? Even if you disable all the ways to do this without rebooting -- kexec() and /proc/kcore, probably among others -- they could always reboot the machine. Sure, you'd notice the reboot, but would you be able to detect their change after the reboot?

      I'd also like to mention that OS-enforced append-only files are a poor substitute to logging to a hardware-enforced WORM drive, particularly if we're talking about rootkits. You're still fundamentally relaying on the OS to provide protection, which isn't reasonable when a rootkit has been installed.

  7. Yes, but... by Darlantan · · Score: 5, Funny

    You have your l33t ninja with his army of zombie Windows boxes... ...but how do they stack up to the *nix pirates, and their FTPs on the seven seas of the intarwebs? It's the classic clashes, modernized. Who has the REAL Ultimate Power?

    --
    Fill in your four or five-letter word of wisdom here _ _ _ _ _.
  8. Read Only Drives by DigitalRaptor · · Score: 5, Interesting

    I run Gentoo Linux servers for hosting email and websites, and have wanted a way to really secure the boxes.

    Many hard drives have jumpers that make them read only.

    I thought it would be great to have all of the rarely changed portions of the operating system on a separate drive set to read only.

    The only time you would move the jumper to read-write would be when you were installing updates.

    Things like: /tmp /var/log
    etc

    Would have to always be on a read-write drive.

    But having things like /usr/bin on a read-only drive seems like an effective way to protect against many, many different root-kits, worms, etc.

    What do you think? Feasible or impractical?

    --
    Lose Weight and Feel Great with Isagenix
    1. Re:Read Only Drives by Darlantan · · Score: 2, Informative

      You'd want to be able to flip it on the fly for OS updates. Otherwise, you're looking at pretty routine downtime -- which may or may not be an issue for you.

      --
      Fill in your four or five-letter word of wisdom here _ _ _ _ _.
    2. Re:Read Only Drives by computational+super · · Score: 2, Funny

      Yeah, there's a program you can run to flip them whenever you need to. I had to install it SUID root though.

      --
      Proud neuron in the Slashdot hivemind since 2002.
    3. Re:Read Only Drives by chill · · Score: 4, Informative

      Impractical, because it requires you to dedicate a drive to the stuff that can be mounted RO. Just mount the PARTITION read-only, instead.

      If you have more than one machine, get a dedicated syslog server and send the logs from the other machines over to it. This way logs aren't on the main machines and it is much harder to compromise the audit trail.

      For businesses, get something like a Trigeo appliance and keep an eye on the behavior of everything.

      Make sure all your permissions/rules are based off the concept of "default deny, explicit allow".

      You could also built a monolithic kernel and not allow modules at all. Kind of hard to insert a corrupt module if the kernel isn't modular!

        Charles

      --
      Learning HOW to think is more important than learning WHAT to think.
    4. Re:Read Only Drives by throx · · Score: 2, Insightful

      I'm not assuming anything is on a read-write disk. If the attacker is able to load arbitrary code into the kernel then it doesn't matter where /etc/fstab is - they can just rewrite the kernel at runtime to mount a disk without worrying about /etc/fstab.

      Yes - your machine will be "clean" after a reboot, but because you've made it read only it will be vulnerable to whatever attack gave them root in the first place.

      Any system - read/write or read only root drive can be reset to a known configuration with little effort (it's usually called "restoring from a backup"), but the point of the rootkit is to give you no reason to do this. Your system looks like it's running just fine and your security theater of making the root drive read-only is giving you a warm fuzzy feeling about how safe you are, but in reality an attacker owns your box and you have no idea.

      The answer is to spend less time thinking about what if an attacker gets root and more time preventing them. Once they have root it's pretty simple: nothing is trustworthy on the box any more because you have hard empirical evidence that it's weak to an attack.

      --

      Fear: When you see B8 00 4C CD 21 and know what it means

    5. Re:Read Only Drives by djh101010 · · Score: 4, Interesting

      Right, but now if you want to install a program or security update you have to power off, change jumper, power on, install, power off, reset jumper, power back on. This may or may not be worth it, particularily in the case of a security update.

      Amazingly enough, I can draw on 25 year old experience on this one, sort of. Back in the early 1980s, I ran a BBS on a dialup TRS-80. The floppy drives, I put toggle switches on the front of so the read-only setting could be changed on the fly. So worst case, it'd be something you might be able to put an external switch for that jumper, outside the drive case. Maybe. Might blow up but at the time it worked great.

    6. Re:Read Only Drives by noahm · · Score: 4, Insightful
      Impractical, because it requires you to dedicate a drive to the stuff that can be mounted RO. Just mount the PARTITION read-only, instead.

      # mount -o remount,rw /readonly/partition

      So that won't help you...

      You could also built a monolithic kernel and not allow modules at all. Kind of hard to insert a corrupt module if the kernel isn't modular!

      That won't help either: http://doc.bughunter.net/rootkit-backdoor/kmem-pat ching.html Most modern kernel-level rootkits do not depend on the ability to dynamically load modules.

      noah

    7. Re:Read Only Drives by FlyingGuy · · Score: 2, Interesting

      This is where about $5.00 worth of parts and a soldering iron will help you out.

      Most all chassis have at least ONE empty slot. Buy a simple miniature SPST toggle switch and some thin wire. Take a jumper and split it electricaly, then solder a wire to each jumper socket. Solder each end of the two wires to the pins on the toggle switch. Drill an approprate hole in the slot dust cover and mount the switch, or just feed the wires out and mount the switch on something close to the box. You now have on the fly flipping from r/w to r/o, provided the SCSI or SATA or SAS or whatever drive interface you are using doesn't freak out when its flipped.

      Not only is this simple but its also hacker proof unless they have physical access to your server, and even then they have to know what that little toggle switch does!

      --
      Hey KID! Yeah you, get the fuck off my lawn!
  9. I like to leave this up to the FBI by Timesprout · · Score: 4, Funny

    When the dark suits turn up on my doorstep with an arrest warrant on charges of attempting to crack confidential government sites I can be pretty sure my machine has been rooted.

    --
    Do not try to read the dupe, thats impossible. Instead, only try to realize the truth
    What truth?
    There is no dupe
  10. trojan the detector by tkw954 · · Score: 2, Interesting

    Wouldn't the first step for a rootkit developer be to add rkhunter and chkrootkit to their list of trojaned programs so that they give a "no rootkit" output? Maybe there's some protection from this, but I don't see it in the article.

  11. I've always wondered... by sootman · · Score: 3, Interesting

    How hard is it to build a basic but worthwhile rootkit detection tool with common tools? Like run `md5 /bin/*` and then ship the output of that to another machine every day for comparison to yesterday's output of that command? (Looking at other directories as well, of course.) My understanding is that many rootkits come with hacked versions of tools like 'ps' to hide themselves.

    On the one hand, yeah, let's not reinvent the wheel, but on the other hand, there are advantages to building your own tools:
    - you know exactly what they're doing--more complicated pre-existing tools might do more, but if you don't understand their output, they're no good.
    - you don't have to trust*/audit someone else's code
    - they don't do more than you need
    - they don't have features that you don't know about or might misuse
    - at the very least, it's a great way to learn

    * yes, I know about this. but there are reasonable limits--I do trust that my distro came with a clean copy of gcc. OTOH, I'd rather write my own 20-line script that download someone else's that says it does the same thing as what I would write myself but that I'd have to audit for even the smallest things, like sneaking in an
    if ($rooted="no")
    instead of
    if ($rooted=="no")

    --
    Dear Slashdot: next time you want to mess with the site, add a rich-text editor for comments.
  12. Meh, I don't trust those tools by straponego · · Score: 4, Funny

    I just eyeball /proc/kcore for anything suspicious every day or so.

  13. chkrootkit by joe+155 · · Score: 2, Informative

    chkrootkit is good, I like it anyway, you can get it in Fedora Core 6 through yum (although you don't seem to be able to get rkhunter through yum any more). you have to run it as root, maybe its something about what it needs to access... anywho, you can get issues with false possitives, I just ran it and got;

    Searching for OBSD rk v1... /usr/lib/security
    /usr/lib/security/classpath.security
    ....
    Searching for suspicious files and dirs, it may take a while...
    /usr/lib/perl5/5.8.8/i386-linux-thread-multi/.pack list

    so I wouldn't worry too much if you see something that looks iffy before you check it out (I'd have been annoyed if I just reinstalled my OS just to find the same thing happening again). It will also show your ethnet port as being in "sniffer". Anywho, best practices can minimize the risk to pretty much 0... oh, but for God's sake PLEASE switch off remote root access on ssh over default ports, ideally switch it off altogether (If you need it please learn how to use it). Ssh coupled with an easily broken root password is the single biggest cause of rootkits... and a huge /var/log/secure!

    --
    *''I can't believe it's not a hyperlink.''
  14. Re:trojan the detector by sfjoe · · Score: 3, Insightful


    They can do that but, if you're like me, chkrootkit runs from a mounted CD-ROM. It's a little harder for them to trojan it that way.

    --
    It's simple: I demand prosecution for torture.
  15. This would have been more appropriate: by Anonymous Coward · · Score: 2, Insightful

    52 65 61 6C 20 6D 65 6E 20 61 6E 64 20 72 65 61 6C 20 68 61 63 6B 65 72 73 20 77 72 69 74 65 20 74 68 65 69 72 20 70 72 6F 67 72 61 6D 73 20 69 6E 20 62 69 6E 61 72 79 20 63 6F 64 65 2C 20 6E 6F 74 20 69 6E 20 73 74 75 70 69 64 20 61 6E 64 20 62 6C 6F 61 74 65 64 20 61 73 73 65 6D 62 6C 65 72 2E

    1. Re:This would have been more appropriate: by Linker3000 · · Score: 2, Funny

      Hey, AC, There's a guy on the phone for you - says he's from SCO and he'd like a quick word.

      --
      AT&ROFLMAO
  16. The tables have turned, Mr. Bond... by RealGrouchy · · Score: 2, Funny

    Joke's on you, Linux boys (and girls?)!

    I don't have to worry about this. I use Windows!

    Oh wait...

    - RG>

    --
    Hey pal, this isn't a pleasantforest, so don't waste my time with pleasantries!
  17. Besides the point! by TrueKonrads · · Score: 2, Informative

    Kind of bypasses the point of detection, in a way.

    One cane safely ass-u-me that if the storage is disconnected, then , if You look very very close, then You could detect a rootkit. Though IF,

    1. If the kit is in-mem only and subverts no system binaries and stores its support files somewhere under /home/maryjanesmith/ or somewhere on /var/www, in other words - locations with thouesand of changing files (TripWire won't work even with SHA1 or other non md5 sums)
    2. Uses an unpatched hole or security lapse to activate itself (say, attacker checks if the rootkit is there, by sending some fancy ping and expecting a fancy pong, e.g.)

    Then even an offline inspection can be bypassed.

    Besides, I'm sure a lot of businesses will take the risk of running potentially compromised server, than incur downtime.

    Now, the Challenge is: What to do, to lock down system so that it is possible to verify the kernel and some userspace against a known good state and the system always gives veritable results? I think that SELinux already does a lot of that - limits root's access. You can setup its policy so, that it will only allow executing binaries and load modules from from read-only partition. The point, is to lock down the box to such state, where only physical access allows security sensitive part modification. I know this is inconvenient,but if some Good Practices [tm] are followed, then a machine once-setup can run with config unchanged for a Year or so. Have some sort of Patch Tuesday or rely on trusted and secured binaries that allow package updated only if their strong crypto signatures validate.

    On an end note, securing and maintaining a system like this with existing tools (that I am aware of) is timeconsuming and hence - expensive. So, the cost-benefit ratio might be nearing the "Let's just re-roll the system on suspected cracks" scenraio. For SMB at least.

    --
    Lone Gunmen crew.
  18. I was rooted by ftp once by trigggl · · Score: 2, Interesting

    That was a couple of days after openning a port in my router for ftp. I thought it was cool to be able to transfer files to and from work. I set it up so that only users could sign in and the user would be locked into their home folder. I saw a couple of attempts to get in in the log. I was watching the monitor of my internet traffic when someone got in and instantly data was going both ways. That's when I turned the DSL router off, closed all ports on the router behind it and disabled ftp on the box. I won't be openning up ports again. When I turned the DSL router back on, I made sure that it got a new address. I need to learn a lot more before I try to run a server again. I also changed the permissions on the other partitions because they had different UID's making them available to the distro I'm currently running. Bad habits will bite you. If you leave a port open, you will get rooted.

    --
    Ops, I shuld have usd the prevuwe but in.