Though is wasn't blatently obvious I was running a Apache Webserver on port 80, the guy from China decided to Amap the port to make sure a webserver was present !
Gone are the days of the "Security Through Obscurity" approach with Amap . There is nothing wrong with trying to run services on non-default ports and changing/modifying banners on services. But I think to solely rely on this to defend against attackers is a recipe for disaster.
THC-Amap, was developed by The Hackers Choice (www.thc.org) and was released under GPL 2002. Now in version 5.2 , it identifies services not only by grabbing banners, but also simulates, application handshakes against the target service. When combined against fast scanning tools like Nmap or Paketto Keiretsu's Scanrand. an attacker can quickly scan an entire network and positively identify when they are running on non standard ports or the banners what been changed or obfuscated. (My wish list for list for Amap would be to add funcionality to identify web application firewall/proxies i.e Tero )
From Amap's THC webpage .....
"THC-Amap
Amap is a next-generation tool for assistingnetwork penetration testing.
It performs fast and reliable application protocol detection, independant
on the TCP/UDP port they are being bound to.
[0x01] Introduction
Welcome to the mini website of the THC Amap project.
Amap is a next-generation scanning tool for pentesters.
It attempts to identify applications even if they are running on a
different port than normal.
It also identifies non-ascii based applications. This is achieved
by sending trigger packets, and looking up the responses in a list
of response strings. "
While I leave a putty console logged into my mail server (OpenBSD4.0 Stable i386) for monitoring logs, ome entries stoff out like dogs balls! See bellow:
219.xx.xx.xx.xx - - [18/Dec/2006:03:03:37 +1100] "\x80\x80\x01\x03\x01" 501 -
219.xx.xx.xx.xx - - [18/Dec/2006:03:03:37 +1100] "USER AMAP" 400 -
219.xx.xx.xx.xx - - [18/Dec/2006:03:03:37 +1100] "HELO AMAP" 400 -
219.xx.xx.xx.xx - - [18/Dec/2006:03:03:37 +1100] "GET / HTTP/1.0" 200 23
219.xx.xx.xx.xx - - [18/Dec/2006:03:03:37 +1100] "" 501 -
219.xx.xx.xx.xx - - [18/Dec/2006:03:03:39 +1100] "GET / HTTP/1.0" 200 23
219.xx.xx.xx.xx - - [18/Dec/2006:03:03:43 +1100] "0\x0c\x02\x01\x01`\x07\x02\x01\x02\x04" 400 -
219.xx.xx.xx.xx - - [18/Dec/2006:03:03:43 +1100] "" 501 -
219.xx.xx.xx.xx - - [18/Dec/2006:03:03:43 +1100] "l" 501 -
219.xx.xx.xx.xx - - [18/Dec/2006:03:03:43 +1100] "\x12\x01" 501 -
219.xx.xx.xx.xx - - [18/Dec/2006:03:03:43 +1100] "JRMI" 501 -
219.xx.xx.xx.xx - - [18/Dec/2006:03:03:43 +1100] "" 501 -
219.xx.xx.xx.xx - - [18/Dec/2006:03:03:43 +1100] "\x02\x03" 501 -
219.xx.xx.xx.xx - - [18/Dec/2006:03:03:43 +1100] "" 501 -
219.xx.xx.xx.xx - - [18/Dec/2006:03:03:43 +1100] "\x11" 501 -
219.xx.xx.xx.xx - - [18/Dec/2006:03:03:43 +1100] "\x03" 501 -
219.xx.xx.xx.xx - - [18/Dec/2006:03:03:43 +1100] "y\b" 501 -
219.xx.xx.xx.xx - - [18/Dec/2006:03:03:43 +1100] "\x81" 501 -
219.xx.xx.xx.xx - - [18/Dec/2006:03:03:43 +1100] "" 501 -
219.xx.xx.xx.xx - - [18/Dec/2006:03:03:43 +1100] "\x80" 501 -
219.xx.xx.xx.xx - - [18/Dec/2006:03:03:43 +1100] "" 501 -
219.xx.xx.xx.xx - - [18/Dec/2006:03:03:43 +1100] "" 501 -
I didn't notice it as being an Amap scan as first I was trying to figure out what the hex values were. Then I came across "user amap" etc etc and it was a give away.
One of the impressive feature of Amap is it has the ability to identify protocols wrpped in SSL. This type of service identification is significant because the SSL service doesn't send a "banner". It expects to perform a full binary handshake with the client. There are three steps to an SSL Handshake:
- CLIENT_HELLO
- SERVER_HELLO
- Server-to-Client certificate transfer
I won’t get into too much details about SSL handshake as we will be getting sidetracked from Amap itself.
Amap stores its trigger packets in a file called “appdefs.trig” it stores a collection of possible known responses in a file called “appdefs.resp”. These file can be edited to include other triggers or responses in the following colon ( : ) separated format )hopefully I can add the triggers and responses from web application proxies/firewalls to these files when discovered) :
NAME : [COMMON_PORT, [COMMON_PORT,…]] : [IP_PROTOCOL] : 0|1 : TRIGGER_STRING
Here is a example of a DNS trigger packet sent by amap:
dns : 53 : udp : 1 : 0x00 00 11 00 00 00 00 00 00 00 00 00
And the response signature:
NAME: [TRIGGER, [TRIGGER,…]] : [IP_PROTOCOL] : {MIN_LENGTH, MAX_LENGTH] : RESPONSE_REGEX
Here is a Microsoft DNS signature (from my lab)
dns-ms : dns : udp : : ^\x00\x00\x90\x04
For protocols that are not identified, amap includes another application called “amapcrap”. This tool is used to send random “junk” to a port that isn’t responding to any of the normal triggers. If the service responds, amapcrap outputs the response in appdefs.resp format, as well as the “junk-string” which triggered the response in appdefs.trig format, so they can be added to amap’s database of service signatures and triggers for future recognition.
sist3m@syn:/home #> amapcrap 172.16.1.3 80
# Starting AmapCrap on 172.16.1.3 port 80
# Writing a "+" for every 10 connect attempts
#
# Put this line into appdefs.trig:
PROTOCOL_NAME::tcp:0:0x)+,-08)(*+6d26.*5c-()%2f6f/'+)+0480+4e/#5763+,.+++4e65580(57-+)$15.#0c+04132)**-0+10--6a0'761b3f716a22-)---.+$791d09."1661*-**7670+'27,!.*,"4f.%-"1c40,**"5b0*04-%1c--*#/+710d097a./20.,7c,*53/,627a*.3c2c/-12//0a52+)*,+.+$*073-!6d07+,
# Put this line into appdefs.resp:
PROTOCOL_NAME::tcp::"HTTP/1.1 400 Bad Request\r\nContent-Type: text/html\r\nDate: Wed, 20 Dec 2006 09:00:20 GMT\r\nConnection: close\r\nContent-Length: 35\r\n\r\nBad Request (Invalid Verb)
"
Using Amap with Nmap for the Scanning & Enumeration phase of a Penetration Test
Amap is a good tool for pen-testing which can be used hand in hand with Nmap.
Here are some examples:
When the – l switch is used, amap will take input from a list in a standard nmap format:
nmap –oG
This allow the pen-tester to to conduct a regular scan with nmap and then run amap on the results. The next example shows how nmap and amap can work together.
The following line uses nmap ro scan a typical class C network for common ports and record the results in a grepable format in the nmap_out.txt:
sist3m@syn:/home #> nmap –oG nmap_out.txt 192.168.1.*
Here, amap is used to parse the output file generated by the preceding nmap command and send the default set of trigger packets on the target/port combinations found by nmap.
sist3m@syn:/home #> amap –i nmap_out.txt
Noth nmap and amap operations could be incorporated into a script. Amap can also output for reporting/archival with the –o switch, or for use with other tools in a colon separated format by adding the –m switch.
The following is an example of amap taking input from nmap’s output and outputting to a colon-delimited file:
sist3m@syn:/home #> nmap_out.txt –o amap_out.txt –m
Downsides…..
Obviously there is a huge downside to amap. The noise it generates is like using a jackhammer in a library !
There is absolutely no stealth with this tool. By default is open 12 parallel TCP connections to the target before any trigger packets are even sent and can even open up to a massive 256 with the –c switch. So yes, the NIDS will pick up an amap scan, that’s for sure ! More importantly are the actual logs (see above) kept by the services that amap attempts to identify.
The best defense against amap scan is detection. Good luck configuring an IIS server with SSL enabled to log the SSL handshake amap triggers! : )
I ran a sniffer while running amap against my own servers and noticed a very very unique signature which can be incorporated into a IDS signature to detect an amap scan in progress. When amap is complied from the original source code, is the machine name it uses in the trigger packet it sends for connecting to the service. The machine name is kpmg-pt is a string that can be looked for NIDS to detect an amap scan in progress. WOW! So I wonder who wrote amap and why the KPMG morons did that ?! : ) so if your NIDS triggers because it has detected an amap scan in progress, perhaps KPMG are conducting a Pen-Test on your company LOL!
The information I have used for this blog can be found all over the internet. Have fun with amap