Selasa, 29 Agustus 2006

Review of Penetration Testing and Network Defense Posted

Amazon.com just posted my three star review of Penetration Testing and Network Defense. This was another disappointment that duped me into trying to read it. From the review:

Penetration testing is becoming a hot topic again, but the available books on the subject continue to underwhelm. Penetration Testing and Network Defense (PTAND), published in the fall of 2005, would be a four star book if it had been published two years earlier. Stephen Northcutt, unlike all other reviewers, noticed this fact as well. When you combine this problem with PTAND with several other deficiencies, the result is a book you can unfortunately skip.

On a brighter pen testing note, I read that work is progressing on version 3.0 of Pete Herzog's Open Source Security Testing Methodology Manual (OSSTMM). Maybe we'll see a new version in a few weeks?

Also, the Active Filter Detection tool implements a cool function needed by OSSTM.

Senin, 28 Agustus 2006

Non-Review: Practical VoIP Security

Here's a first for the TaoSecurity Blog. As mentioned in a pre-review, I planned to read Practical VoIP Security and then write a Amazon.com review. I'd had a bad experience reading VoIP Security, so I hoped this new book would be better. Wrong.

My policy for writing Amazon.com reviews is that I read either the whole book, or the vast majority of it. With Practical VoIP Security, I couldn't make it past the first chapter. In fact, by page 4 -- the third page of text -- I was frustrated. In three pages the author (who was the lead author and technical editor) had mentioned terms like PBX, SS7, H.323, SIP, SNMP, VoIP, and SIGTRAN (which never appears again in this book!) without explaining any of them. I am familiar with all except the last, but I should not have to rely on past knowledge when reading the introductory pages of a "practical" book. The first chapter, overall, is a rambling collection of ideas that do nothing to prepare the reader for what follows.

If you want more details, I found Rob Slade's review to be good.

On a note related to Intruders Selling Security Software, I found this interview with the lead author of Practical VoIP Security to be a sign of foolish boasting or outright deception:

CSOonline: What is your background, and why are you called a hacker?

-name omitted-: I’m a hacker in the more traditional sense. Old-school hackers want to learn how things work and try to take it apart or gain access out of curiosity. Getting into networks and systems is good or bad based on your vantage point. Most traditional hackers do it just to see if they can, but they’re not there to steal information or destroy the integrity of a system.
(emphasis added)

I'm setting you up for material to follow. You might guess the "vantage point" comment doesn't sit well with me. The interview continues.

Can you mention some of your notorious hacks?

Nothing that I’ve done has made public news, and there are some things I’d rather not mention. I did raise the interest of the Defense Department once, but I’ve never been involved in any criminal activity. At one point in my career, I was interested in finding proof of alien life, so I did access the network at China Lake, also known as Area 51 in Roswell, New Mexico.
(emphasis added)

Oh, you mean the super-secret Naval Air Weapons Station China Lake, home of the MAJIC Morale, Welfare and Recreation office? I think this hax0r was trying to find Groom Lake, and if that were the case we wouldn't be hearing from him.

The interview continues:

How does a hacker disclose his or her credentials?

There are two kinds of hackers. Those who do it to impress their friends or become famous, and those that you don’t know about. The really good, and smart, hackers won’t tell you that they are hackers. Many of them are also not very sociable--they keep what they do on the QT, and if they have real credentials or experience, they don’t say anything about it.
(emphasis added)

Now you see why I added emphasis to the first paragraph. Sigh. Why are people like this getting attention from the media?

I guess I'm going to have to wait for Hacking Exposed: VoIP in December. For general books on VoIP, Switching to VoIP and VoIP Hacks by Ted Wallingford look good.

Security Engineering Book in Digital Form

I just read at Light Blue Touchpaper that one of my top ten books of the past ten years is now available online. Now you have no excuse not to read this incredible book (reviewed here).

It seems funny that the blog commenters asking about making a single .pdf have not heard of Pdftk.

Thanks to jimmythegeek for getting this news to me faster than my Bloglines feed.

More Snort and Sguil Tuning

Let's assume you built a new Sguil sensor and have tuned Snort using advice in my Tuning Snort article. What I like to do next is wait a day or so and then run the following query to look for problematic alert types.

mysql> select count(*) as total, event.signature from event where
event.status=0 group by event.signature order by total desc;
+-------+------------------------------------------------------------------------+
| total | signature |
+-------+------------------------------------------------------------------------+
| 43416 | SHELLCODE x86 NOOP |
| 4145 | POLICY SMTP relaying denied |
| 3394 | WEB-MISC PCT Client_Hello overflow attempt |
| 2148 | WEB-CGI calendar access |
| 1645 | tag: Tagged Packet |
| 1267 | SHELLCODE x86 stealth NOOP |
| 1031 | WEB-MISC weblogic/tomcat .jsp view source attempt |
| 817 | http_inspect: OVERSIZE REQUEST-URI DIRECTORY |
| 683 | INFO web bug 0x0 gif attempt |
| 491 | SHELLCODE x86 0x90 unicode NOOP |
| 175 | ftp_pp: Invalid FTP command |
| 128 | WEB-IIS view source via translate header |
| 126 | WEB-MISC robots.txt access |
| 88 | Snort Alert [1:5856:0] |
| 74 | SHELLCODE x86 inc ebx NOOP |
| 71 | portscan: Open Port |
| 47 | WEB-MISC intranet access |
| 28 | MISC MS Terminal server request |
| 28 | WEB-FRONTPAGE /_vti_bin/ access |
| 27 | portscan: TCP Portsweep |
| 21 | WEB-MISC SSLv2 Client_Hello with pad Challenge Length overflow attempt |
| 19 | ATTACK-RESPONSES 403 Forbidden |
| 16 | http_inspect: BARE BYTE UNICODE ENCODING |
| 13 | Snort Alert [1:6031:0] |
| 12 | ATTACK-RESPONSES directory listing |
| 12 | SHELLCODE x86 0xEB0C NOOP |
| 5 | Snort Alert [1:6033:0] |
| 4 | portscan: TCP Portscan |
| 4 | Snort Alert [1:5718:0] |
| 3 | EXPLOIT gobbles SSH exploit attempt |
| 3 | MISC MS Terminal server request RDP |
| 2 | MS-SQL sp_start_job - program execution |
| 2 | WEB-IIS WebDAV file lock attempt |
| 1 | WEB-FRONTPAGE posting |
| 1 | ATTACK-RESPONSES Invalid URL |
| 1 | WEB-MISC Chunked-Encoding transfer attempt |
| 1 | MS-SQL xp_reg* - registry access |
| 1 | WEB-FRONTPAGE rad fp30reg.dll access |
| 1 | WEB-MISC WebDAV search access |
| 1 | NEW POLICY RDP attempted Administrator connection request |
+-------+------------------------------------------------------------------------+
40 rows in set (2.40 sec)

Wow, that first line is popular. Let's break these out by source IP. (Thanks to VictorJ for catching a dumb error in my original syntax.)

mysql> select count(*) as total, event.signature, INET_NTOA(event.src_ip)
from event where event.status=0 and event.signature='SHELLCODE x86 NOOP'
group by event.signature, event.src_ip order by total desc;
+-------+--------------------+-------------------------+
| total | signature | INET_NTOA(event.src_ip) |
+-------+--------------------+-------------------------+
| 43002 | SHELLCODE x86 NOOP | 10.20.30.14 |
| 334 | SHELLCODE x86 NOOP | 6.16.237.132 |
| 46 | SHELLCODE x86 NOOP | 6.16.237.140 |
| 18 | SHELLCODE x86 NOOP | 192.168.0.14 |
| 11 | SHELLCODE x86 NOOP | 3.87.180.190 |
| 3 | SHELLCODE x86 NOOP | 6.16.237.138 |
| 2 | SHELLCODE x86 NOOP | 192.168.1.197 |
+-------+--------------------+-------------------------+
7 rows in set (0.64 sec)

10.20.30.14 is the big offending source IP. Let's see the destination IPs.

mysql> select count(*) as total, event.signature, INET_NTOA(event.src_ip),
INET_NTOA(event.dst_ip) from event where event.status=0 and
event.signature='SHELLCODE x86 NOOP' and event.src_ip=INET_ATON('10.20.30.14')
group by event.signature, event.src_ip, event.dst_ip order by total desc;
+-------+--------------------+-------------------------+-------------------------+
| total | signature | INET_NTOA(event.src_ip) | INET_NTOA(event.dst_ip) |
+-------+--------------------+-------------------------+-------------------------+
| 43002 | SHELLCODE x86 NOOP | 10.20.30.14 | 6.16.237.137 |
+-------+--------------------+-------------------------+-------------------------+
1 row in set (0.94 sec)

It looks like there are 43002 SHELLCODE x86 NOOP from 10.20.30.14 to 6.16.237.137. Is that really true though? We can validate these findings by looking for alerts where 6.16.237.137 is not the destination IP.

mysql> select count(*) as total, event.signature, INET_NTOA(event.src_ip),
INET_NTOA(event.dst_ip) from event where event.status=0 and
event.signature='SHELLCODE x86 NOOP' and event.src_ip=INET_ATON('10.20.30.14') and
event.dst_ip!=INET_ATON('6.16.237.137') group by event.signature, event.src_ip,
event.dst_ip order by total desc;
Empty set (1.20 sec)

With an empty response, we confirm there are 43002 SHELLCODE x86 NOOP from 10.20.30.14 to 6.16.237.137.

I have two options here. First, I could simply delete all of these items from the database. I doubt 43002 SHELLCODE alerts from an internal IP address are malicious. On the other hand, I might want to look at them.

The problem with inspecting them is that they are currently in Sguil's inspection queue. If I fire up Sguil it's going to load 43002 alerts into the client. While they will be aggregated, it will take a long time for that to happen.

In cases like these I prefer to mark the events as "NA" and then inspect a sample later.

Before running the following, kill sguild. You should never update the database while Sguil is trying to make sense of it.

mysql> UPDATE event SET status=1, last_modified='2006-08-28 15:45:00', last_uid='sguil'
where event.status=0 and event.signature='SHELLCODE x86 NOOP' and
event.src_ip=INET_ATON('10.20.30.14');
Query OK, 43002 rows affected, 43002 warnings (5.91 sec)
Rows matched: 43002 Changed: 43002 Warnings: 43002

You can repeat this process for the other large event count alerts, or just restart sguild and fire up the Sguil client to deal with them manually.

How can we prevent such a huge number of alerts from occurring again?

My original article mentioned "Thresholding and Suppression." The SHELLCODE x86 NOOP alert might be a good candidate for thresholding.

A look in sid-msg map shows two sids:

$ grep "SHELLCODE x86 NOOP" sid-msg.map
648 || SHELLCODE x86 NOOP || arachnids,181
1394 || SHELLCODE x86 NOOP

A look in the .rules files shows two rules.

grep "SHELLCODE x86 NOOP" *.rules
shellcode.rules:alert ip $EXTERNAL_NET $SHELLCODE_PORTS -> $HOME_NET any
(msg:"SHELLCODE x86 NOOP"; content:"|90 90 90 90 90 90 90 90 90 90 90 90 90 90|";
reference:arachnids,181; classtype:shellcode-detect; sid:648; rev:8;)
shellcode.rules:alert ip $EXTERNAL_NET $SHELLCODE_PORTS -> $HOME_NET any
(msg:"SHELLCODE x86 NOOP"; content:"aaaaaaaaaaaaaaaaaaaaa";
classtype:shellcode-detect; sid:1394; rev:5;)

I add the following to threshold.conf to limit Snort to generate one alert per 60 seconds for each source IP causing SHELLCODE x86 NOOP alerts.

threshold gen_id 1, sig_id 648, type limit, track by_src, count 1, seconds 60
threshold gen_id 1, sig_id 1394, type limit, track by_src, count 1, seconds 60

Remember to enable your local threshold.conf in snort.conf:

include /usr/local/etc/nsm/threshold.conf

After restarting Snort, I can expect a lower number of alerts should SHELLCODE x86 NOOP get out of hand again. When Snort starts you'll see the sig-id of your new threshold rule applied.

| gen-id=1 sig-id=648 type=Limit tracking=src count=1 seconds=60
...edited...
| gen-id=1 sig-id=1394 type=Limit tracking=src count=1 seconds=60

That's one item for tuning... expect others in the future.

NoVA Sec First Meeting Pictures at novasec.org

Paul Zedeck was kind enough to send pictures from the first NoVA Sec meeting last week. Please visit the NoVA Sec Blog for details.

I try to avoid cross-posting, so keep an eye on that blog for word on the next NoVA Sec meeting.

Network Forensics with NetWitness

Ten days ago I had the privilege of attending a day of product training for NetWitness. NetWitness is a real network forensics tool produced by a company of the same name. Anyone who's read my books or attended my training knows I am a big fan of open source tools. NetWitness, however, is built to facilitate investigating network traffic.

It's important to differentiate between packet collectors, protocol analyzers, and network forensics tools. Dumpcap is the prototypical packet collector. Simpler than Tcpdump and much simpler than Tshark, all Dumpcap does is record packets. It's especially suited for this role, however, because it offers native trace rotation capabilities.

Tcpdump, Tshark, and Wireshark are all protocol analyzers. Yes, Tcpdump is a protocol analyzer, although it is not as robust as Tshark or Wireshark. Protocol analyzers are suited for packet-centric inspection. For example, I used Wireshark extensively while learning about 802.11 traffic. Protocol analyzers are also helpful for network troubleshooting, with varying degrees of automated analysis. Commercial protocol analyzers are especially robust in this regard. Protocol analyzers often feature tools for rebuilding TCP sessions, but that is usually the extent of those features. Protocol analyzers also permit searching traffic, but the analyst generally must have a good grasp of what he is looking for and how to get that idea across to the protocol analyzer.

Network forensics tools are not packet-centric; they are data centric. NetWitness, for example, cares less about the underlying packets and more about the data they contain. The partial screen capture (original here) hints at NetWitness' depiction of files, accounts, and email addresses recognized in a network trace.

Investigators don't (necessarily) look at packets when they use NetWitness for network forensics. Rather, they look for useful data. One investigation might require finding all information related to a specific username. That username (or a portion of it) would be searchable in email, instant messaging, Web logins, documents, and so forth. While you could do some manual searching with tools like Ngrep or Flowgrep, NetWitness is built around discovering information and is well-suited for this process of discovery.

When you find results, they are presented within the context of the session in which they were contained. NetWitness rebuilds the session and presents it in human-friendly format. If they subject viewed an email, you will see the email. If he visited a Web page, you will see the Web page. There are limitations to this model, such as a browser displaying cache graphics instead of requesting them on the wire. However, this sort of model works very well for forensic analysts.

This second partial screen capture (original here) demonstrates two other powerful NetWitness features. First, NetWitness represents traffic using a noun-verb-adjective-like language. When you see the mention of "GET", for example, it's not necessarily an HTTP get. GET actions include FTP retrievals and other actions where a subject acquires data. This meta-language simplifies investigations by letting the analyst look for actions and not for specific protocol activities.

Second, NetWitness performs port-agnostic protocol identification. When you see "HTTP" it doesn't just mean port 80. HTTP is identified by inspecting traffic and looking for the HTTP protocol. This is an important mechanism for finding back doors and covert channels. Obviously encryption will hamper this feature, but port-agnostic protocol identification is a must-have for forensics tools.

I could say quite a bit about NetWitness, but I hope you've gotten the idea that it's a powerful tool. In case you are wondering, I am not being compensated for this review. I did get to attend the training class for free. I am also not selling NetWitness to anyone. The purpose of this review is to share insights on this tool, and to keep those of us with ties to the open source world aware of applications outside of it.

I am open to hearing from NetWitness' main competitors, Niksun and Sandstorm, if they'd like to comment. Sandstorm's NetIntercept holds a special place in my heart, since it runs on FreeBSD. NetWitness is a Windows-based product. (In production I recommend capturing traffic with a program like Dumpcap or Tcpdump, and then analyzing it in NetWitness.)

Review of 802.11 Wireless Networks Posted

Amazon.com just posted my five star review of 802.11 Wireless Networks: The Definitive Guide, 2nd Ed by Matthew Gast. Wow, what an excellent book. From the review:

I tend not to read and review books on as broad a subject as "wireless networking." I've read and reviewed wireless security books like Real 802.11 Security and Wi-Foo, but 802.11 Wireless Networks: The Definitive Guide, 2nd Ed (8WN2E) was a departure for me. Thankfully, 8WN2E is an incredible book. It exceeded my expectations and definitely earned its "Definitive Guide" status.

In addition to the book, I recommend Matthew's blog posts Top Ten 802.11 Myths of 2005 and When Is 54 Not Equal to 54? A Look at 802.11a, b, and g Throughput.

One of the marks of a great book is authoritatively answering a question I've pondered for a while. For example, I've heard that the introduction of 802.11b stations into an 802.11g network means all stations run at 802.11b speeds. This is absolutely false.

On p 303 he says:

Only the protection frames are required to be transmitted at the 802.11b-compatible data rates. Protection does not require 802.11g stations to use a slower data rate for the payload data, as is commonly asserted.

Brilliant. I even added tabs to this book -- I hardly ever do that.