<tt><font size=2>kwlug-disc-bounces@kwlug.org wrote on 05/14/2009 09:24:05
AM:<br>
> Have you ever heard of a rootkit which installs a modified rpm that
<br>
> would return a false positive verification of packages it had changed?
<br>
> I think that some viruses on Windows will hamstring antivirus software
<br>
> if they can get around it in the first place, making detection much
more <br>
> difficult.  It seems like a logical move to try something similar
with <br>
> package verification.<br>
</font></tt>
<br><tt><font size=2>So far "they" haven't caught up to that,
but it is a concern. Rootkits to date haven't been to smart. I can see
how someone might suspect that they do. </font></tt>
<br>
<br><tt><font size=2>Smarter rootkits verify the root kit installation
when running each binary. RPM packages may have pre-scripts and post-scripts
that are run before of after installing files. If a script uses an infected
binary re-installing a package may result in re-infection. </font></tt>
<br>
<br><tt><font size=2>Another trick is to set ext2 immutable attributes
on the rootkit binaries (man lsattr to learn about ext2 attributes). RPM
can't replace these files but also doesn't produce an error. In either
of these cases re-installing an RPM may not result in removing the root
kit. This can certainly give someone the impression RPM has been hacked
too.</font></tt>
<br><tt><font size=2><br>
The fix is to check for and reset immutable bits (lsattr, chattr), use
the --noscripts option when re-installing RPMs and avoid the use of hacked
tools. Use "echo *" as a simple replacement for ls. Look in /proc
instead of using ps. Use "cat /proc/net/sockstat" instead of
netstat (and learn to read hex.)</font></tt>
<br>
<br><tt><font size=2>Here is a quick way to see if a system has a root
kit. It will be quite accurate on positives, and reasonably accurate on
negatives for a quick check:</font></tt>
<br>
<br><tt><font size=2>lsattr /bin/* /usr/bin/* | egrep -v -- -{15}  
             # find
all files that have ext extended attributes</font></tt>
<br><tt><font size=2>rpm -V coreutils net-tools procps util-linux util-linux-ng
       # ls, netstat, ps, top, etc.</font></tt>
<br><tt><font size=2>rpm -V openssh-server openssh-clients    
            # commonly hacked
for ssh vulnerabilities.</font></tt>
<br>
<br><tt><font size=2>Once you've verified that the tools are good we can
use them for other checks. Some hacks don't use root kits, they just install
a daemon like an IRC bot or a back door and try to hide it using a normal
name like "init", "cron" or "httpd".</font></tt>
<br>
<br><tt><font size=2>netstat -a          
               
             # look
for odd connections and listening ports</font></tt>
<br><tt><font size=2>find /dev -type f        
               
       # find all normal files in /dev, Hacks
often put files here</font></tt>
<br><tt><font size=2>ps -ef | grep init        
               
       # There should be only one</font></tt>
<br><tt><font size=2>ps -ef | grep cron        
               
       # again only one</font></tt>
<br><tt><font size=2>ps -ef | grep httpd        
               #
There may be lots, but only one with PPID of 1</font></tt>
<br><tt><font size=2>ls -l /tmp /var/tmp        
               #
Look for odd files owned by apache user.</font></tt>