{"id":26,"date":"2011-01-14T15:04:09","date_gmt":"2011-01-14T15:04:09","guid":{"rendered":"http:\/\/www.haxrbyte.org\/?p=26"},"modified":"2011-01-14T15:04:09","modified_gmt":"2011-01-14T15:04:09","slug":"nmap-is-you-friend","status":"publish","type":"post","link":"https:\/\/haxrbyte.org\/?p=26","title":{"rendered":"nmap is you FRIEND&#8230;. :)"},"content":{"rendered":"<p>nmap is the tool any Penetration Tester\/ Ethical Hacker can&#8217;t do without.<\/p>\n<p>The tool can be downloaded from &#8211; <a title=\"http:\/\/nmarp.org\" href=\"http:\/\/nmap.org\/download.html\" target=\"_blank\">http:\/\/nmap.org<\/a><\/p>\n<p>I will use scanme.nmap.org as the target system for the demonstration:<\/p>\n<pre><span style=\"color: #888888;\">[root@byte ~]# ping -c 3 scanme.nmap.org\nPING scanme.nmap.org (64.13.134.52): 56 data bytes\n64 bytes from 64.13.134.52: icmp_seq=0 ttl=54 time=162.937 ms\n64 bytes from 64.13.134.52: icmp_seq=1 ttl=54 time=158.487 ms\n64 bytes from 64.13.134.52: icmp_seq=2 ttl=54 time=154.497 ms\n\n--- scanme.nmap.org ping statistics ---\n3 packets transmitted, 3 packets received, 0.0% packet loss\nround-trip min\/avg\/max\/stddev = 154.497\/158.640\/162.937\/3.447 ms\n\n<\/span><\/pre>\n<p>When we run the nmap command against scanme.nmap.org<\/p>\n<pre><span style=\"color: #888888;\">[root@byte ~]# nmap scanme.nmap.org\n\nStarting Nmap 5.00 ( http:\/\/nmap.org ) at 2011-01-14 06:13 CST\nInteresting ports on scanme.nmap.org (64.13.134.52):\nNot shown: 993 filtered ports\nPORT      STATE  SERVICE\n22\/tcp    open   ssh\n25\/tcp    closed smtp\n53\/tcp    open   domain\n70\/tcp    closed gopher\n80\/tcp    open   http\n113\/tcp   closed auth\n31337\/tcp closed Elite\n\nNmap done: 1 IP address (1 host up) scanned in 34.15 seconds\n[root@byte ~]#\n\n<\/span><\/pre>\n<p>The scan it runs by default is the TCP SYN Scan, also known as the Stealth of Half Scan. As you can see it give you a list of interesting ports, with a state and a service that might be running on that port.<\/p>\n<p>I normally start with a host discovery with a ping scan, this goes no further than to determine if the host is online.<\/p>\n<pre><span style=\"color: #888888;\">[root@byte ~]# nmap -sP scanme.nmap.org\n\nStarting Nmap 5.00 ( http:\/\/nmap.org ) at 2011-01-14 06:28 CST\nHost scanme.nmap.org (64.13.134.52) is up (0.16s latency).\nNmap done: 1 IP address (1 host up) scanned in 0.62 seconds\n[root@byte ~]#\n\n<\/span><\/pre>\n<p>You can run a list scan, but this only gives you a list of targets to scan<\/p>\n<pre><span style=\"color: #888888;\">[root@byte ~]# nmap -sL scanme.nmap.org\n\nStarting Nmap 5.00 ( http:\/\/nmap.org ) at 2011-01-14 06:28 CST\nHost scanme.nmap.org (64.13.134.52) not scanned\nNmap done: 1 IP address (0 hosts up) scanned in 0.24 seconds\n[root@byte ~]#\n\n<\/span><\/pre>\n<p>This scan will, probably only be used, to determine if what the network range that you want scan involves&#8230;something like&#8230;<\/p>\n<pre><span style=\"color: #888888;\">[root@byte ~]# nmap -sL 64.13.134.48\/28\n\nStarting Nmap 5.00 ( http:\/\/nmap.org ) at 2011-01-14 06:35 CST\nHost nmap.org (64.13.134.48) not scanned\nHost insecure.org (64.13.134.49) not scanned\nHost seclists.org (64.13.134.50) not scanned\nHost sectools.org (64.13.134.51) not scanned\nHost scanme.nmap.org (64.13.134.52) not scanned\nHost research.nmap.org (64.13.134.53) not scanned\nHost cust-134-54.titan.net (64.13.134.54) not scanned\nHost cust-134-55.titan.net (64.13.134.55) not scanned\nHost cust-134-56.titan.net (64.13.134.56) not scanned\nHost cust-134-57.titan.net (64.13.134.57) not scanned\nHost ns1.titan.net (64.13.134.58) not scanned\nHost ns2.titan.net (64.13.134.59) not scanned\nHost wwwr.titan.net (64.13.134.60) not scanned\nHost nswc1.titan.net (64.13.134.61) not scanned\nHost nswc2.titan.net (64.13.134.62) not scanned\nHost 64.13.134.63 not scanned\nNmap done: 16 IP addresses (0 hosts up) scanned in 0.21 seconds\n[root@byte ~]#\n\n<\/span><\/pre>\n<p>as you can see no scanning, just listing.<\/p>\n<p>I upgraded my nmap version to nmap-5.36.t4 , there are other interresting things that comes with this like <a href=\"http:\/\/nmap.org\/nping\/\">NPING<\/a> and <a href=\"http:\/\/nmap.org\/ncat\/\">NCAT<\/a> (Ncat was written for the Nmap Project as a much-improved reimplementation of the venerable <a href=\"http:\/\/sectools.org\/#netcat\">Netcat<\/a>)<\/p>\n<p>But I will blog about that a bit later&#8230;.<\/p>\n<p>I decided, rather than going through the <a href=\"http:\/\/nmap.org\/book\/man.html\">NMAP reference guide<\/a>, I wanted to show you some nicer things to do with NMAP&#8230;well at least I think it&#8217;s nicer \ud83d\ude42<\/p>\n<p>TCP connect scan (-sT)<\/p>\n<p>This is you tipical 3-way handshake (SYN&#8211;>SYN-ACK&#8211;>ACK). The host sends out a SYN packet, the target responds wit h a SYN-ACK packet, the host then responds with a ACK packet. Then the communications channel is established and traffic can flow.<\/p>\n<pre><span style=\"color: #888888;\">[root@byte ~]# nmap -sT scanme.nmap.com\n\nStarting Nmap 5.36TEST4 ( http:\/\/nmap.org ) at 2011-01-28 05:02 CST\nNmap scan report for scanme.nmap.com (64.13.134.52)\nHost is up (0.045s latency).\nrDNS record for 64.13.134.52: scanme.nmap.org\nNot shown: 993 filtered ports\nPORT      STATE  SERVICE\n22\/tcp    open   ssh\n25\/tcp    closed smtp\n53\/tcp    open   domain\n70\/tcp    closed gopher\n80\/tcp    open   http\n113\/tcp   closed auth\n31337\/tcp closed Elite\n\nNmap done: 1 IP address (1 host up) scanned in 41.77 seconds\n[root@byte ~]#\n\n\n<\/span><\/pre>\n<p>Ok, you see a couple of ports open.<\/p>\n<p>A interesting thing to use is &#8211;packet-trace. The &#8211;packet-trace option causes Nmap to print a summary of every packet it sends and receives. This is helpful when trying to understand how Nmap works, and for debugging.<\/p>\n<p>Lets take ssh for a example:<\/p>\n<pre><span style=\"color: #888888;\">[root@byte ~]# nmap --packet-trace -p 22 -sT scanme.nmap.org\n\nStarting Nmap 5.36TEST4 ( http:\/\/nmap.org ) at 2011-01-28 05:26 CST\nSENT (0.0550s) ICMP 72.200.200.200 > 64.13.134.52 Echo request (type=8\/code=0) ttl=58 id=45864 iplen=28\nSENT (0.0550s) TCP 72.200.200.200:47740 > 64.13.134.52:443 S ttl=59 id=2266 iplen=44  seq=768689839 win=4096 <mss 1460>\nSENT (0.0550s) TCP 72.200.200.200:47740 > 64.13.134.52:80 A ttl=51 id=50330 iplen=40  seq=0 win=4096\nSENT (0.0550s) ICMP 72.200.200.200 > 64.13.134.52 Timestamp request (type=13\/code=0) ttl=45 id=35095 iplen=40\nRCVD (0.0990s) ICMP 64.13.134.52 > 72.200.200.200 Echo reply (type=0\/code=0) ttl=52 id=17449 iplen=28\nNSOCK (0.2550s) UDP connection requested to 72.232.192.2:53 (IOD #1) EID 8\nNSOCK (0.2550s) Read request from IOD #1 [72.232.192.2:53] (timeout: -1ms) EID 18\nNSOCK (0.2550s) Write request for 43 bytes to IOD #1 EID 27 [72.232.192.2:53]: .............52.134.13.64.in-addr.arpa.....\nNSOCK (0.2550s) Callback: CONNECT SUCCESS for EID 8 [72.232.192.2:53]\nNSOCK (0.2550s) Callback: WRITE SUCCESS for EID 27 [72.232.192.2:53]\nNSOCK (0.2560s) Callback: READ SUCCESS for EID 18 [72.232.192.2:53] (184 bytes)\nNSOCK (0.2560s) Read request from IOD #1 [72.232.192.2:53] (timeout: -1ms) EID 34\nCONN (0.2560s) TCP localhost > 64.13.134.52:22 => Operation now in progress\nNmap scan report for scanme.nmap.org (64.13.134.52)\nHost is up (0.044s latency).\nPORT   STATE SERVICE\n22\/tcp open  ssh\n\nNmap done: 1 IP address (1 host up) scanned in 0.30 seconds\n[root@byte ~]#\n\n<\/span><\/pre>\n<p><strong>NOTE:<\/strong> I used fake ip&#8217;s .. just in case \ud83d\ude42<\/p>\n<p>TCP stealth (half) scan (-sS)<\/p>\n<p>This scan only sends out packets like this (SYN&#8211;>SYN-ACK). The host send a SYN packet, and the target reponds with a SYN-ACK packet, but the host never sends a ACK packet back to the target.<\/p>\n<pre><span style=\"color: #888888;\">[root@byte ~]# nmap -sS scanme.nmap.org\n\nStarting Nmap 5.36TEST4 ( http:\/\/nmap.org ) at 2011-01-28 05:18 CST\nNmap scan report for scanme.nmap.org (64.13.134.52)\nHost is up (0.045s latency).\nNot shown: 993 filtered ports\nPORT      STATE  SERVICE\n22\/tcp    open   ssh\n25\/tcp    closed smtp\n53\/tcp    open   domain\n70\/tcp    closed gopher\n80\/tcp    open   http\n113\/tcp   closed auth\n31337\/tcp closed Elite\n\nNmap done: 1 IP address (1 host up) scanned in 14.75 seconds\n[root@byte ~]#\n\n<\/span><\/pre>\n<p>now lets try this with the &#8211;packet-trace option<\/p>\n<pre><span style=\"color: #888888;\">[root@byte ~]# nmap --packet-trace -p 22 -sS scanme.nmap.org\n\nStarting Nmap 5.36TEST4 ( http:\/\/nmap.org ) at 2011-01-28 05:27 CST\nSENT (0.0550s) ICMP 72.200.200.200 > 64.13.134.52 Echo request (type=8\/code=0) ttl=58 id=64459 iplen=28\nSENT (0.0550s) TCP 72.200.200.200:35214 > 64.13.134.52:443 S ttl=48 id=3099 iplen=44  seq=3743350257 win=1024 <mss 1460>\nSENT (0.0550s) TCP 72.200.200.200:35214 > 64.13.134.52:80 A ttl=40 id=33163 iplen=40  seq=0 win=1024\nSENT (0.0550s) ICMP 72.200.200.200 > 64.13.134.52 Timestamp request (type=13\/code=0) ttl=52 id=22089 iplen=40\nRCVD (0.0990s) ICMP 64.13.134.52 > 72.200.200.200 Echo reply (type=0\/code=0) ttl=52 id=17450 iplen=28\nNSOCK (0.2550s) UDP connection requested to 72.232.192.2:53 (IOD #1) EID 8\nNSOCK (0.2550s) Read request from IOD #1 [72.232.192.2:53] (timeout: -1ms) EID 18\nNSOCK (0.2550s) Write request for 43 bytes to IOD #1 EID 27 [72.232.192.2:53]: <!...........52.134.13.64.in-addr.arpa.....\nNSOCK (0.2550s) Callback: CONNECT SUCCESS for EID 8 [72.232.192.2:53]\nNSOCK (0.2550s) Callback: WRITE SUCCESS for EID 27 [72.232.192.2:53]\nNSOCK (0.2570s) Callback: READ SUCCESS for EID 18 [72.232.192.2:53] (152 bytes)\nNSOCK (0.2570s) Read request from IOD #1 [72.232.192.2:53] (timeout: -1ms) EID 34\nSENT (0.2570s) TCP 72.200.200.200:35214 > 64.13.134.52:22 S ttl=56 id=9289 iplen=44  seq=1621599360 win=1024 <mss 1460>\nRCVD (0.3020s) TCP 64.13.134.52:22 > 72.200.200.200:35214 SA ttl=52 id=0 iplen=44  seq=2276068255 win=5840 <mss 1460>\nNmap scan report for scanme.nmap.org (64.13.134.52)\nHost is up (0.044s latency).\nPORT   STATE SERVICE\n22\/tcp open  ssh\n\nNmap done: 1 IP address (1 host up) scanned in 0.46 seconds\n[root@byte ~]#\n\n<\/span><\/pre>\n<p><strong>to be continued&#8230;..<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>nmap is the tool any Penetration Tester\/ Ethical Hacker can&#8217;t do without. The tool can be downloaded from &#8211; http:\/\/nmap.org I will use scanme.nmap.org as the target system for the demonstration: [root@byte ~]# ping -c 3 scanme.nmap.org PING scanme.nmap.org (64.13.134.52): 56 data bytes 64 bytes from 64.13.134.52: icmp_seq=0 ttl=54 time=162.937 ms 64 bytes from 64.13.134.52: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4],"tags":[],"_links":{"self":[{"href":"https:\/\/haxrbyte.org\/index.php?rest_route=\/wp\/v2\/posts\/26"}],"collection":[{"href":"https:\/\/haxrbyte.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/haxrbyte.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/haxrbyte.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/haxrbyte.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=26"}],"version-history":[{"count":0,"href":"https:\/\/haxrbyte.org\/index.php?rest_route=\/wp\/v2\/posts\/26\/revisions"}],"wp:attachment":[{"href":"https:\/\/haxrbyte.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=26"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/haxrbyte.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=26"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/haxrbyte.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=26"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}