Havlar Flake made a post last week which I’ve been eagerly waiting on a response from Matasano Chargen. Two posts later and I still haven’t seen the post I’ve been waiting for! I’ve been checking out the commends on Havlar’s blog but many of the responses seem to be insignificant commands such as “rm -rf” and the like. Of course, if your part of project Mayhem then that’s all you need but what if you want to stay awhile, kick off your shows and get comfortable.
One of the comments was an advertisement for his own blog post. I checked it out and he had a few insightful commands. One thing I did notice, and talking with Tebo he said clearly distinguished the Ethical versus Unethical hackers is the absence of any anti forensics, or any attempt at covering themselves up. The Grudge in a presentation on “Hash” said that Unsetting the Histfile was a common trait of highly successful hackers, yet it is somewhat old school.
First command:
unset HISTFILE
Secondly, chances are you obtained access through an exploit and there may be a core file laying around. In an effort to not be caught you want to clean that up right away while it’s still fresh on your mind.
Start by searching in the current directory
find . -type f -name “core”
Then move on to searching the whole machine. (I’m sure this is largely inefficient in terms of hard drive spinning up et cetera, anyone have a better idea)
find / -type f -name “core”
Next up is log files. I see many papers, scripts talk about deleting the entire log file. Think about that for a minute. If you were the system administrator and you check your log every day, every three day’s or weekly and suddenly your entire log was missing… Wouldn’t that arouse some suspicions?
Now that we’ve cleaned up a bit, Let’s address that one blog’s first command issuances. These commands are really just recon. We are looking for servers, other hosts, ssh keys, passwords et cetera.
We start off with
w, netstat -an, ps auxww, mount, cat /etc/resolve.conf, ls /home
One reason you want to start off with w is to determine if anyone else is logged on and active. You don’t want to slow down the system and start spinning up the hard drive if others may notice it.
Netstat gives us not only ip’s we are connected to, but also what ip’s are connected to us and possibly what services are listening on the system. We may not have noticed a mysql server during the port scan because it was setup to only listen on the local interface.
Ps auxww is a great command from the other blog because like he said, you may get passwords in the output from a command line process start up.
Mount shows what is currently mounted, Today is not uncommon for even a PC to have more than one hard drive. Perhaps there is nothing on the /, but a secondary hard drive that is mounted in a weird place has a ton of data we want/ desire.
Cat /etc/resolve.conf identifies at least our dns server, we can start querying the dns server further asking who else she knows.
Ls -la /home allows us to see who has established profiles on the system and when their last activity was. Of course, this may not be entirely accurate since an administrator can login, and just leave the terminal locked.
To wrap this post up, uptime!
The uptime command is important because it gives you an indication of how long the box has… well been up. You can take this information and apply it towards your rootkit. If you’ve got a box that’s been up for a quite a while you don’t have to worry about reboots and the one aspect of rootkits on startup. Furthermore, you can determine whether the system is going to be a reliable hop.
Those are just a few, of course there are ton’s more. Any of the Old school Unix hackers got any more tidbits? MC? Tebo?