LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 11-21-2003, 06:10 AM   #1
mule
Member
 
Registered: Aug 2003
Posts: 81

Rep: Reputation: 15
zk rootkit detected


i runned chkrootkit at my server. i got the message 'possible zk rootkit detectet'.

how can i find out, wheater i really have it or not??
 
Old 11-21-2003, 08:44 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
First of all, Chkrootkit is known to show what is known as "false positives", which can make using it a liability for your blood pressure levels :-] This however does not mean this will be one, be prepared to see odds switching both ways...


I'm running (a modified) Chkrootkit 0.42b(+u0.0.2, with way better interface promiscuous mode detection on Linux kernels 2.4.x but that's besides the point), if you "grep chkrootkit -e ZK" you should see that as a part of detection (and next to looking for suspicious files like sbin/init.zk), around lines 540 (expert mode) and 960 it looks for existence of any of two files: /usr/bin/run and /etc/sysconfig/console/load.zk. Rerunning Chkrootkit in debug and expert mode with only that test (chkrootkit -d -x aliens) should show which files show up to investigate.
I. Next you should verify these files are part of your distribution, and if they are, if their contents check out (run "file" or "strings" on them, visually inspect text files) and md5/sha1sums check out comparing it with "trusted" copies from say cdrom or one of your distro's ftp mirrors.

II. Else if the files are not part of your distribution, and since this is a rootkit, assert someone has got root. This means the box is no longer under your sole control and is not to be trusted for whatever it's task is, and you should be prepared to turn off the box for investigation.
From now on, regard this system as UNTRUSTED. DO NOT USE IT, AND DO NOT ALLOW OTHERS TO USE IT.
...and forget about getting that one last minute thing done or making changes to the filesystem like making backups etc etc.

OK. What to do in case of suspected compromise?
Precaution 0: read Steps for Recovering from a UNIX or NT System Compromise before doing anything else.

Precaution 1: For any operations on the disks, boot your distro's rescue cd, any cd-based distro (Trinux, Knoppix, Finnix, FIRE, PSK) or a one-floppy distro like tomsrtbt, LOAF. DO NOT BOOT the kernel from the harddisk or let it automatically mount the disks. If you need to mount the disks, mount them readonly.

2. Stay calm.

3. While this also means extracting memory, process and network (connection and interface) details of the running system may be tampered with on the fly, you should still do so. For details on running ps, netstat and lsof I'll hook you up with this post a little down. The find command is wrong, you should run "find /proc/[0-9]* -name exe -printf "%p\n" | xargs -iX cp -aL --parents 'X' /tmp2>&1|tee /tmp/procs.log" to save copies of running binaries. Try running "ifconfig -a" or better "ip link show".
Make sure you don't choose VFS partitions a lot happens on like /, /tmp, /var for output of files. If unsure, don't. If you took process and network snapshots, bring it down to runlevel 1 first, then take another snapshot. Now power down the box. (If you've got magic sysreq keys (see printscreen key) the ALT+SYSRQ+{S then U then B} would sync disks, remount readonly and reboot at which you can power off). This will render the system useless to the cracker and protect you from doing stuff on the box.

4. Boot your systems rescue floppy/cdr, Knoppix, FIRE or PSK. Mount partitions read-only. Check "chkrootkit" again and have your package manager check the files again. Inspect auth files (passwd, shadow, group) and system logs. Please report back any anomalies.

5. In the situation you think the box could be compromised, and if you want to know what the intruder did, proceed by making a full backup of the paritions using "dd". We'll use it to try and track down what the intruder did. If you have to, take out the disks and add to another machine. Make sure you have enough free diskspace. For all partitions do "dd if=/dev/<partition> of=/mnt/disk/file_name_disk_partition_number" and don't forget the swap. Make sure these "dd" images never get mounted in read-write mode. To preserve data.



Good luck.
 
Old 11-21-2003, 08:59 AM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
For the above, some notes:

- If this is a remote box, you obviously can't bring it down and proceed. Ask your colo people to do it for you. If it costs too much money, then make 'em save /etc and /var/(log) in a tarball and use the 3 R's: reformat, repartition and reinstall your box. Note restoration is not feasable, unless you have external means to verify the backup was sane.

- If you have a huge amount of logs and system logs you want me to check out, or can't make head or tail out of it, make a bzipped tarball of it and upload it, mail me the URI and I'll help you check it. Use "split" for archives over 10MB. (This rootkit ain't in my personal collection, so yeah, I'm interested.)

- Make sure to be verbose when you post a follow up, it will speed up the process. Also, I invest time writing these posts, and the last thing I want to see is a follow up which sez "I did X but I found nothing": if unsure, posting as much as you can will be valuable. It will enable us to help you.
 
Old 11-21-2003, 03:15 PM   #4
mule
Member
 
Registered: Aug 2003
Posts: 81

Original Poster
Rep: Reputation: 15
zk rootkit

thx, unspawn.

first, unfortunately the grep chkrootkik -e ZK didn't work on my version of chkrootkit... (v 0.42b)

afterwards, i was looking for .zk files with locate....none showed up...just the /usr/bin/run is there, thats all...even a netstat -an shows no strange connection...

what do you think? should the init.zk be visible?
 
Old 11-22-2003, 07:55 AM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Re: zk rootkit

first, unfortunately the grep chkrootkik -e ZK didn't work on my version of
chkrootkit... (v 0.42b)
That was only part of my example, to make clear,
how Chkrootkit tries to find evidence of the ZK rootkit. I told you to run
Chkrootkit in expert mode. And what to check afterwards.


afterwards, i was looking for .zk files with locate....none showed up...just
the /usr/bin/run is there, thats all...even a netstat -an shows no strange
connection... what do you think? should the init.zk be visible?

For some reason however, you managed to read just the first few lines of my
reply, neglect the rest, didn't perform any test I suggested and started doing
your own thing. Besides that, you answered terse, something I explicitly asked
you not to do. If something I said in my first or second reply wasn't clear:
ask. If it is: answer it. If you won't: then I've got nothing more to say.
 
Old 11-24-2003, 02:11 AM   #6
mule
Member
 
Registered: Aug 2003
Posts: 81

Original Poster
Rep: Reputation: 15
hi unspawn,

as i am some kind of rookie, first of all my excuses not to follow your instructions. so i try to follow step-by-step.

Have to say, that first of all, i immediatly unmounted my data-disks and reinstalled again fedora core 1. The first application i installed afterwards was chkrootkit. so i did the following:
[root@morpheus etc]# chkrootkit -x | grep ZK
[root@morpheus etc]# chkrootkit -x | grep zk
### Output of: /bin/ls /usr/lib/pt07 /usr/bin/atm /tmp/.cheese /dev/ptyzx /dev/ptyzg /usr/bin/sourcemask /dev/ida /dev/xdf* /usr/lib/libx?otps /sbin/init.zk
/bin/ls: /sbin/init.zk: Datei oder Verzeichnis nicht gefunden (means init.zk not found...)
...
and then 'chkrootkit -x > chkrootkit.txt' and then 'more chkrootkit.txt | grep zk' and more chkrootkit.txt | grep ZK with the following results:

###
### Output of: /bin/ls /usr/lib/pt07 /usr/bin/atm /tmp/.cheese /dev/ptyzx /dev/ptyzg /usr/bin/sourcemask /dev/ida /dev/xdf* /usr/lib/libx?otps /sbin/init.z
k
###
/bin/ls: /usr/lib/pt07: Datei oder Verzeichnis nicht gefunden
/bin/ls: /usr/bin/atm: Datei oder Verzeichnis nicht gefunden
/bin/ls: /tmp/.cheese: Datei oder Verzeichnis nicht gefunden
/bin/ls: /dev/ptyzx: Datei oder Verzeichnis nicht gefunden
/bin/ls: /dev/ptyzg: Datei oder Verzeichnis nicht gefunden
/bin/ls: /usr/bin/sourcemask: Datei oder Verzeichnis nicht gefunden
/bin/ls: /dev/xdf*: Datei oder Verzeichnis nicht gefunden
/bin/ls: /usr/lib/libx?otps: Datei oder Verzeichnis nicht gefunden
/bin/ls: /sbin/init.zk: Datei oder Verzeichnis nicht gefunden
/dev/ida:
c0d0
c0d0p1
c0d0p10
c0d0p11
c0d0p12
c0d0p13
c0d0p14
c0d0p15
c0d0p2
c0d0p3
c0d0p4
c0d0p5
c0d0p6
c0d0p7
c0d0p8
c0d0p9
c0d1
c0d10
c0d10p1
c0d10p10
c0d10p11
c0d10p12
c0d10p13
c0d10p14
c0d10p15
c0d10p2
c0d10p3
c0d10p4
c0d10p5
c0d10p6
c0d10p7
c0d10p8
c0d10p9
c0d11
c0d11p1
c0d11p10
c0d11p11
c0d11p12
c0d11p13
c0d11p14
c0d11p15
c0d11p2
....
and so on....

so, i got a list with about 2'000 lines.... with chkconfig -d -x aliens and i more'd with 'zk' getting the same lines as above. do i assume right, that i have to verify, if those files should exist now in my distro?

thx
 
Old 11-24-2003, 08:28 AM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
as i am some kind of rookie, first of all my excuses not to follow your instructions. so i try to follow step-by-step.
Well, it's not that it's mandatory to follow instructions if you know what you're doing, it's only that it saves time when you don't, which I think is critical in such situations.


so, i got a list with about 2'000 lines.... with chkconfig -d -x aliens and i more'd with 'zk' getting the same lines as above.
I'm sorry. I keep forgetting most people don't troubleshoot Bash scripts like I do.
If you run it and redirect output like "chkconfig -d -x aliens 2> /tmp/aliens.err 1>/tmp/aliens.log", the /tmp/aliens.log will hold the files you need to check, and you get the whole "conversation" in /tmp/aliens.err, which means you have a way to verify chkrootkit is running right.


do i assume right, that i have to verify, if those files should exist now in my distro?
No, not "if", it's the other way around: files chkrootkit [u]finds[/i] should be inspected.
About false positives, I know of two packages that include a file called "/usr/bin/run".
If your distro has a package manager that allows you to query files for the package they're in, and provided you have a "sane" copy of your package managers database of installed apps, it should be easy to find the name of that package. For that package, verify the contents of what is on your filesystem with the package from your install cdroms or distro mirror, or remote site where it is made available.
 
Old 11-25-2003, 08:26 AM   #8
mule
Member
 
Registered: Aug 2003
Posts: 81

Original Poster
Rep: Reputation: 15
yes everybody how he wants....i tried this and hot huge files in /tmp. so i seems the most interesting is aliens.log. as this was huge, i was filtering all with zk. there he found no files:
### Output of: /bin/ls /usr/lib/pt07 /usr/bin/atm /tmp/.cheese /dev/ptyzx /dev/ptyzg /usr/bin/sourcemask /dev/ida /dev/xdf* /usr/lib/libx?otps /sbin/init.z
k
###
/bin/ls: /usr/lib/pt07: Datei oder Verzeichnis nicht gefunden
/bin/ls: /usr/bin/atm: Datei oder Verzeichnis nicht gefunden
/bin/ls: /tmp/.cheese: Datei oder Verzeichnis nicht gefunden
/bin/ls: /dev/ptyzx: Datei oder Verzeichnis nicht gefunden
/bin/ls: /dev/ptyzg: Datei oder Verzeichnis nicht gefunden
/bin/ls: /usr/bin/sourcemask: Datei oder Verzeichnis nicht gefunden
/bin/ls: /dev/xdf*: Datei oder Verzeichnis nicht gefunden
/bin/ls: /usr/lib/libx?otps: Datei oder Verzeichnis nicht gefunden
/bin/ls: /sbin/init.zk: Datei oder Verzeichnis nicht gefunden

but a huge list of devices...(i do not paste full if it isn't needed..
/dev/ida:
c0d0
c0d0p1
c0d0p10
c0d0p11
c0d0p12
c0d0p13
c0d0p14
c0d0p15
c0d0p2
c0d0p3
c0d0p4
c0d0p5
c0d0p6
c0d0p7
c0d0p8
c0d0p9
c0d1
c0d10
c0d10p1
c0d10p10

he even doesn't check for /usr/bin/run....or did i miscomprehend? for me, it looks like making specified tests by rootkit, so all for the zk-rootkit should be together....

i was remarking not only in this a little bit strange behaviour of the Fedora Core 1, even if i find it excellent...the antivir-kit from antivir.de even seems to dislike the prelink-crontab (no ELF-support), so it dies...but this is another story...

thanks for your patience...
 
Old 11-25-2003, 08:27 AM   #9
mule
Member
 
Registered: Aug 2003
Posts: 81

Original Poster
Rep: Reputation: 15
ah...btw 'Datei oder Verzeichnis nicht gefunden' means 'File or Directory not found'
 
Old 11-25-2003, 11:01 AM   #10
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
ah...btw 'Datei oder Verzeichnis nicht gefunden' means 'File or Directory not found'
Ja ist das, was translate.google.com sagte.
//Of course translate.google doesnt care eight bits for syntactically correct sentences :-]


he even doesn't check for /usr/bin/run....or did i miscomprehend?
Yes, it does. See the lines at:
Code:
### Output of: /bin/ls /usr/bin/run /etc/sysconfig/console/load*

for me, it looks like making specified tests by rootkit, so all for the zk-rootkit should be together....
Hmm. I didn't get that ligne.


i was remarking not only in this a little bit strange behaviour of the Fedora Core 1, even if i find it excellent...
Wow. OK. Stupid me. I should have asked you your distro/release right away.
Since I installed FC1 as well to do some dev on, I ran Chkrootkit-0.42b (new patched version should be out in December) and I got this
Code:
###
### Output of: /bin/ls /usr/bin/run /etc/sysconfig/console/load*
###
/bin/ls: /etc/sysconfig/console/load*: No such file or directory
/usr/bin/run
Well well. Since it doesn't detect the "/etc/sysconfig/console/load*", the *.zk files, nor a trojaned /sbin/init, let's see (note I'm using my own aliases, but the output matters):
Code:
# Show some file statistics
]# stat /usr/bin/run
  File: `/usr/bin/run'
  Size: 28380           Blocks: 58         IO Block: 4096   regular file
Device: 1/2     Inode: 123456789      Links: 1    
Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
# OK, regular file, owned by root, executable.

# Whats the filetype?
]# file /usr/bin/run
/usr/bin/run: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), stripped
# OK, so it's a binary

# what libs does it need?
]# ldd /usr/bin/run
    libc.so.6 => /lib/i686/libc.so.6 (0x40010000)
    /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x001a2000)
# Nothing weird here

# Is it part of an rpm?
]# rpm-prov /usr/bin/run
run-2.0-3
# Kewl. Let's check out the rpm.

# What does the rpm contain?
#]rpm-contentsof run
/usr/bin/run
/usr/share/doc/run-2.0
/usr/share/doc/run-2.0/README
/usr/share/man/man1/run.1.gz

# What is the rpm about?
]# rpm-list-descr run|grep "^[NVRS]"
Name        : run
Version     : 2.0
Release     : 3
Signature   : DSA/SHA1, Wed 29 Oct 2003 01:10:21 AM CET, Key ID b44269d04f2a6fd2
Packager    : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
Summary     : Multiprocessor CPU set control system
Description : The "run" utility enables you to start applications with various changes in context. (etc etc)

# Can we verify MD5sums?
]# rpm-list-md5 run|sepSpace 1,4-
/usr/bin/run 2bb3d8c6c7f916b85e540d309145ca91 0100755 root root 0 0 51715 X
/usr/share/doc/run-2.0 00000000000000000000000000000000 040755 root root 0 0 4357 X
/usr/share/doc/run-2.0/README bedcc5a27f0d18df77585707bba6f905 0100644 root root 0 1 0 X
/usr/share/man/man1/run.1.gz a89847443b024ffd33371a8b8b215d5e 0100644 root root 0 1 0 X

]# trisum /usr/bin/run
4029842437 28380 /usr/bin/run
356b029d36d95687ae810c20ef899b3a  /usr/bin/run
b0e13de62f3031063f99bd2bdc4eb75b93fda3c1  /usr/bin/run
# Fsck, MD5sum failed.

# Let's see what verify thinks
]# rpm-vfy run
prelink: /usr/bin/run: at least one of file's dependencies has changed since prelinking
S.?.....   /usr/bin/run
# Size failed too.
At this point we haven't established anything except that:
1. Chkrootkit didn't detect all files that are part of the ZK rootkit (which means they are either hidden or not there),
2. there is a file "usr/bin/run" in the "run" package, the filetype, access permissions and ownership match, but the size and MD5sum dont.
This is the point where you would:
1. Use your filesystem integrity checker (Aide, Samhain, tripwire, md5sum database) to verify the files' attributes in the database match (database on read-only media)
2. Download a copy of the rpm from FTP to compare contents with.



the antivir-kit from antivir.de even seems to dislike the prelink-crontab (no ELF-support), so it dies...but this is another story...
Yes, set up another thread for that, or better, email Antivir.de and let them fix it.


thanks for your patience...
You're welcome.


Concluding notes.
It would be easy to say the system is safe. However this is a way of deceiving yourself. Having a copy of the rpm database on read-only media and checking the filesystem with that is one way, but running a filesystem integrity scanner should be mandatory when you install your linux OS.

Chkrootkit has been known to cause FP's (false positives) under a variety of circumstances ranging from finding dotfiles to relying on names or port numbers and from probs with threading apps to detecting short-lived processes or network connections or the state of network interfaces (see http://www.rootshell.be/~unspawn/pac...hkrootkit.html or the Chkrootkit mailinglist archives). For more than one reason it should be clear no system should rely on using just one application to provide you with filesystem "health" signs.
Chkrootkit also is an OSS effort to help people, so this FP should be reported and a patch should be submitted, to help Chkrootkit evolve.

Filesystem integrity checking is something a lot of people don't know about, but (when configured and used properly) can provide invaluable info on the state of the system. Please spread the word and check out/link to the LQ FAQ: Security references, post #3 "Intrusion detection, integrity checks: IDS, NIDS, HIDS, Antivirus, software.".

In the same post you'll find info about Linux and viruses. When newbies ask about viruses, be sure to warn them about the things that are really important instead of just posting a link to someone's rant on AV or AV software.


HF
 
Old 11-26-2003, 02:19 AM   #11
mule
Member
 
Registered: Aug 2003
Posts: 81

Original Poster
Rep: Reputation: 15
have the same results, hard to check...is this because of ELF?? I am not a dev at all, but as i read in manpages, there runs one a day a prog called prelink, that optimizes apps for startup...
 
Old 11-26-2003, 10:07 AM   #12
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Yes, it's because of the prelink stuff.
The error message itself is no cause for alarm.
 
Old 11-26-2003, 02:09 PM   #13
mule
Member
 
Registered: Aug 2003
Posts: 81

Original Poster
Rep: Reputation: 15
thanks a lot...makes me more convenient again...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
where can I get rootkit ?? iamthewind Linux - Security 21 05-04-2008 01:57 PM
rootkit? basilogics Linux - Software 2 08-19-2005 08:16 AM
Possible rootkit? bleunuit Linux - Security 4 05-18-2005 03:21 PM
rootkit: infected??? help synaptical Linux - Security 4 05-16-2005 07:11 PM
rootkit? linuxtesting2 Linux - Security 3 12-06-2004 08:43 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 10:17 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration