|
|
To print: Select File and then Print from your browser's menu
-------------------------------------------------------------- This story was printed from ZDNet Australia. --------------------------------------------------------------
|
UNIX tools track down hackers By Laura Taylor, TechRepublic July 01, 2002 URL: http://www.zdnet.com.au/news/software/soa/UNIX-tools-track-down-hackers/0,130061733,120266324,00.htm
Catching malicious hackers isn't impossible. With the right tools, you can gather important information to help stop hack attacks. How can you use common UNIX tools to hunt down network attackers?
You have determined that your network has been breached. There are two standard approaches on what to do next:
Most organisations decide to close the holes as quickly as possible because the probability of actually catching an intruder is very low. But if you can identify the hacker and opt to prosecute, you must gather as much information about the attack as possible. Data such as the hacker's location, the domain and IP address from which the hacking took place, the name of the hacker, and what specific damage the hacker inflicted are all necessary for prosecution. One method of gaining this information is by using tried-and-true UNIX networking tools usually employed in incident-response forensics. UNIX forensic tools In forensic analysis, you cannot use any tools that are currently installed on the hacked system, because it is possible that those tools could have been replaced with Trojan programs. For example, the ps program that displays the process table could have been replaced with a Trojan ps program that displays everything except the process of a running hacker daemon. Whatever tools you decide to use for analysing evidence should all be freshly installed. Key items you'll want to look at and retain for analysis are:
Various software tools and UNIX commands can help you gather this information. Some of the UNIX tools that come bundled with most UNIX operating systems or that are freely available on the Internet and are worth familiarising yourself with include:
Use netstat to determine open ports and services
Netstat is the tool to use to determine what ports and services are currently open. When you execute the command netstat -an, you'll see a listing of all the connections along with their listening ports and the network addresses associated with these ports. The output will look something like this: Look for patterns such as similar source ports used to connect to different sockets. (A socket is an IP address and port together e.g., 206.208.163.15:80.) In the above example, three connections (now closed) were used to connect to the Web server port, all from different source ports. If you discover a server on a particular port that is not normally in use, it's possible that a hacker (with root level access) installed it for malicious purposes. Use tcpdump to look for aberrant packet behaviour
Use the tcpdump tool to trace packets and print out packet header information. When you execute the command tcpdump > outputfile on a shared network that is not switched and dumping to an output file, you'll see a timestamp, a source socket, a destination socket, a TCP flag, a sequence number and offset, and a maximum segment size. The output will look something like Listing A. Use dig to uncover suspicious IP addresses
The dig utility, a replacement for the older nslookup, is a good tool to use to look up suspicious IP addresses discovered through netstat, tcpdump, or other commands. To use this command, insert the IP address or hostname after the dig command, like so: dig 140.216.41.2. Use traceroute to find geographic physical locations
The traceroute tool can help you figure out the route a packet follows to get from one place to another. Most administrators use traceroute to find out the physical geographic location of a system. You run traceroute by listing the hostname, preferably the fully qualified domain name, after the command, like this: traceroute company.com.
The output will list the name and IP address of the destination, and will list all hops along the way, similar to the output shown in Listing B. The output is in the form hostname |IP address | probe1 | probe2 | probe3. Each probe is a timed attempt to get the proper response. Each probe also returns the time it took to get that response. Find
There are many ways in which you can use find in incident-response forensics. For example, if you suspect that an intruder broke in by exploiting SUID or SGID files, you can use find to locate all these files (as shown in Listing C) by looking for any log file that references the SUID (2000) or SGID (4000) permission bits.
Typically, the SUID and SGID file list shouldn’t change. If you see new additions, examine any new files from the SUID and SGID list and determine whether or not they should be there. You can also use find to look for world-writeable files, because these files are also often exploited. To look for all the world-writeable files, run find as shown in Listing D. Use dd to preserve the evidence
The dd utility, a UNIX command for dumping data, has been a part of almost every UNIX-based operating system for as long as I can remember. Use the dd utility when you want to preserve evidence and create a forensic disk image, without changing timestamps or anything else. First, figure out where you're going to dump the image; a writeable CD or another disk are the most likely places. Grep, egrep, awk find 0 UID and GID accounts other than root
You'll want to look for root accounts that might not look like root accounts. Often, intruders set up new accounts with root access that aren't associated with the root name. To find these accounts, use the command shown in Listing G. What next?
Figuring out who cracked your network is only part of the battle. After you have gathered all the information you can find, you must report the activity to the right institution, such as the FedCIRC, a government-run organisation dedicated to computer security-related issues affecting the civilian agencies and departments of the federal government. Other groups include the Department of Energy’s Computer Incident Advisory Capability (CIAC) and the Federal Bureau Of Investigation National Computer Crime Squad. Editorial disclaimer: The authors and editors have taken care in preparation of the content contained herein but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for any damages. Always have a verified backup before making any changes.
TechRepublic is the online community and
information resource for all IT professionals, from support staff to executives. We offer in-depth technical articles written
for IT professionals by IT professionals. In addition to articles on everything from Windows to e-mail to fire walls, we
offer IT industry analysis, downloads, management tips, discussion forums, and e-newsletters.
Copyright © 2009 CBS Interactive, a CBS Company. All Rights Reserved. |