Your SlideShare is downloading. ×
0
Dynamic Port Scanning
Dynamic Port Scanning
Dynamic Port Scanning
Dynamic Port Scanning
Dynamic Port Scanning
Dynamic Port Scanning
Dynamic Port Scanning
Dynamic Port Scanning
Dynamic Port Scanning
Dynamic Port Scanning
Dynamic Port Scanning
Dynamic Port Scanning
Dynamic Port Scanning
Dynamic Port Scanning
Dynamic Port Scanning
Dynamic Port Scanning
Dynamic Port Scanning
Dynamic Port Scanning
Dynamic Port Scanning
Dynamic Port Scanning
Dynamic Port Scanning
Dynamic Port Scanning
Dynamic Port Scanning
Dynamic Port Scanning
Dynamic Port Scanning
Dynamic Port Scanning
Dynamic Port Scanning
Dynamic Port Scanning
Dynamic Port Scanning
Dynamic Port Scanning
Dynamic Port Scanning
Dynamic Port Scanning
Dynamic Port Scanning
Dynamic Port Scanning
Dynamic Port Scanning
Dynamic Port Scanning
Dynamic Port Scanning
Dynamic Port Scanning
Dynamic Port Scanning
Dynamic Port Scanning
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Dynamic Port Scanning

4,062

Published on

Dynamic Port Scanning - AR, HK

Dynamic Port Scanning - AR, HK

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,062
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Dynamic Port Scanning An integration of ARP poisoning into port scanning to dynamically spoof source IP Copyright © 2006 AR < [email_address] > ( http://www.securebits.org )
  • 2. Who am I ? <ul><li>IT Security Engineer at CCC Company, Athens, Greece. </li></ul><ul><li>Independent Security Researcher, leader of SECUREBITS Security Group (www.securebits.org) </li></ul>
  • 3. AGENDA 0x10 Introduction to the Idea of DPS 0x20 Overview of Current Spoofing Techniques 0x30 Integrating ARP Poisoning into Port Scanning 0x40 1-Packet-Based TCP Stealth Scans and Their Uses. 0x50 Putting It into Practice [The Tool of Trade] 0x60 DEMO 0x70 Preventing DPS in Private LANs 0x80 Conclusion 0x90 References 0xa0 Thanks & Greetings – Questions & Answers
  • 4. 0x10 Introduction to the Idea of DPS 0x11 Definition: Dynamic Port Scanner [DPS] integrates ARP-Poisoning and Spoofing into Port Scanning to dynamically spoof the source IP of TCP or UDP scan packets. The &quot;dynamic spoofing&quot; means that for each TCP or UDP scan packet, there is a dynamically and randomly generated IP used as the source IP address for the scan packet. DPS can be considered as &quot; Virtual &quot; Distributed Scan, where the scan appears as coming from many scanning machines. DPS is best suited for &quot; inside &quot; penetration-testing or attack.
  • 5. 0x20 Overview of Current Spoofing Techniques 1] Normal Source-IP Spoofing # nmap –sS –S 10.1.11.200 –p 1-100 20.2.22.300 2] The Use of Decoys # nmap –sS –D10.1.11.200,10.1.11.210 –p 1-90 20.2.22.300 3] Distributed Port Scanning
  • 6. 1] Normal Source-IP Spoofing (1) # nmap –sS –S 10.1.11.200 –p 1-100 20.2.22.300 0x20 Overview of Current Spoofing Techniques This is the simplest among all other technique. All the attacker needs to do is to spoof the source IP of the scanning machine to any other IP without worrying about anything else. That spoofed IP is used for all scan packets. Also, that spoofed IP can by any valid IP address and does not have to be within the subnet IP range of the scanning machine .
  • 7. Advantages: 1- Freedom of Spoofing 2- No wasted initiated packets 3- No tracing of the original scanner Disadvantages: 1- No replies !! 2- No results !! 0x20 Overview of Current Spoofing Techniques 1] Normal Source-IP Spoofing (2) # nmap –sS –S 10.1.11.200 –p 1-100 20.2.22.300
  • 8. 2] The Use of Decoys (1) # nmap –sS –D10.1.11.200,10.1.11.210 –p 1-90 20.2.22.300 0x20 Overview of Current Spoofing Techniques Decoy scan works by sending more than one packet per port. All of these packets carry spoofed source IPs except one packet, which carries the original scanner IP address. By doing so, the attacker guarantees at least one reply packet which is the reply to the scan packet carrying the correct IP address. All other replies will not reach the scanning machine.
  • 9. 2] The Use of Decoys (2) # nmap –sS –D10.1.11.200,10.1.11.210 –p 1-90 20.2.22.300 Advantages: 1- Results are guaranteed 2- Freedom of spoofing Disadvantages: 1- Lots of wasted traffic 2- Original scanner is logged (Detection is not impossible) 0x20 Overview of Current Spoofing Techniques
  • 10. 3] Distributed Port Scanning (1) 0x20 Overview of Current Spoofing Techniques Distributed scan works by dividing the scanning scope among multiple attack platforms. In such case, each attack platform performs a normal scan for a small range of port numbers. Although this is not 100% spoofing mechanism, it increases the overhead of the system administrator on the other side to trace back the attacker [e.g. there could be hundreds of originating IPs.] Furthermore, those originating IPs could be compromised hosts of innocent people
  • 11. 3] Distributed Port Scanning (2) Advantages: 1- No useless traffic 2- Results are guaranteed 3- minimized scan time Disadvantages: 1- All scanners are logged/traced 2- Scanners must be under control 0x20 Overview of Current Spoofing Techniques
  • 12. 0x30 Integrating ARP Poisoning into Port Scanning 0x31 The Basic Idea 0x32 ARP-Cache Poisoning 0x33 ARP-Poisoning with Scanning 0x34 Advantages 0x35 Limitations
  • 13. 0x31 The Basic Idea <ul><li>The basic idea behind Dynamic Port Scanning is the integration of ARP-Poisoning into the scanning process. </li></ul><ul><li>The aim is to poison the ARP-Cache of the remote scanned host or the gateway so that scan replies are delivered to the scanning machine regardless of the (spoofed) destination IP address. </li></ul>0x30 Integrating ARP Poisoning into Port Scanning
  • 14. 0x32 ARP-Cache Poisoning (Quick Lesson) <ul><li>In the old days, one Fake ARP-REPLY would poison the cache. </li></ul><ul><li>It works perfectly on WIN95/98/ME AND Cisco Routers </li></ul><ul><li>Nowadays, a normal fake packet needs to be sent before the fake ARP-REPLY. That packet can be ICMP ECHO Request or even an ARP-REQUEST. </li></ul><ul><li>It works on WINNT/2K/XP, LINUX. </li></ul>2.2.2.2 AA:AA:AA:AA:AA:AA 5.5.5.5 BB:BB:BB:BB:BB:BB ARP Cache: 10.10.10.10 is at AA:AA:AA:AA:AA:AA ARPOP_REQUEST Src 10.10.10.10 (AA:AA:AA:AA:AA:AA) Dst 5.5.5.5 (BB:BB:BB:BB:BB:BB) ARPOP_REPLY Src 10.10.10.10 (AA:AA:AA:AA:AA:AA) Dst 5.5.5.5 (BB:BB:BB:BB:BB:BB) 0x30 Integrating ARP Poisoning into Port Scanning
  • 15. 0x33 ARP-Poisoning with Scanning 10.1.0.74 10.1.11.5 10.1.11.10 10.1.11.15 10.1.11.20 10.1.11.1 1] 10.1.0.74 is NOT within the local net 2] Get the gateway IP and ARP for its MAC 3] Generate random IP (10.1.11.15) 4] Poison the gateway (2 fake ARP packets) 5] Send the scan packet 6] Wait for the response AA:AA:AA:AA:AA:AA BB:BB:BB:BB:BB:BB ARPOP_REPLY src: 10.1.11.15 (AA:AA:AA:AA:AA:AA) dst: 10.1.11.1 (BB:BB:BB:BB:BB:BB) ARPOP_REQUEST src: 10.1.11.15 (AA:AA:AA:AA:AA:AA) dst: 10.1.11.1 (BB:BB:BB:BB:BB:BB) 10.1.11.15:5678  10.1.0.74:80 [SYN] 10.1.0.74:80  10.1.11.15:5678 [SYN/ACK] Target is outside local net 0x30 Integrating ARP Poisoning into Port Scanning
  • 16. 0x33 ARP-Poisoning with Scanning 10.1.11.5 10.1.11.10 10.1.11.15 10.1.11.20 10.1.11.30 1] 10.1.11.30 is within the local net 3] Generate random IP (10.1.11.15) 4] Poison the host (2 fake ARP packets) 5] Send the scan packet 6] Wait for the response ARPOP_REQUEST src: 10.1.11.15 (AA:AA:AA:AA:AA:AA) dst: 10.1.11.30 (BB:BB:BB:BB:BB:BB) ARPOP_REPLY src: 10.1.11.15 (AA:AA:AA:AA:AA:AA) dst: 10.1.11.30 (BB:BB:BB:BB:BB:BB) 10.1.11.15:5678  10.1.11.30:80 [SYN] 10.1.11.30:80  10.1.11.15:5678 [SYN/ACK] Target is within local net 0x30 Integrating ARP Poisoning into Port Scanning
  • 17. 0x33 ARP-Poisoning with Scanning (Mechanism Flowchart) 0x30 Integrating ARP Poisoning into Port Scanning Generate random source IP “ randomly-generated fake IP ” “ Gateway IP ” = “ ARP-Poisoning IP ” “ Target IP ” = “ ARP-Poisoning IP ” NO YES Prepare “ ARP REQ ” and “ ARP REP ” with following data: S_IP: “ randomly-generated fake IP ” D_IP: “ ARP-Poisoning IP ” S_MAC: MAC of “ Attack IP ” D_MAC: MAC of “ ARP-Poisoning IP ” Send the two ARP packets to “ ARP-Poisoning IP ” Send the TCP/UDP Scan packet with following data: S_PORT: random port number D_PORT: scanned port S_IP: “ randomly-generated fake IP ” D_IP: “ target IP ” S_MAC: MAC of “ Attack IP ” D_MAC: MAC of “ ARP-Poisoning IP ” Wait for the reply Is the “ Target IP ” within the local subnet?
  • 18. 0x33 ARP-Poisoning with Scanning ( Graphical Representation ) 0x30 Integrating ARP Poisoning into Port Scanning
  • 19. 0x34 Advantages <ul><li>No wasted TCP/UDP packets </li></ul><ul><li>All replies are delivered to the scanning machine </li></ul><ul><li>Original scanner IP address is never logged (even at the ARP level) </li></ul><ul><li>Detection is IMPOSIBLE at the IP layer. </li></ul>0x30 Integrating ARP Poisoning into Port Scanning
  • 20. 0x35 Limitations <ul><li>Spoofed IP must fall within the local net. </li></ul><ul><li>Number of spoofed IPs is bounded by the subnet range </li></ul><ul><li>(i.e. Class B Subnet has higher number of spoofed IPs than Class C subnet) </li></ul><ul><li>Detection can happen on the MAC layer </li></ul>0x30 Integrating ARP Poisoning into Port Scanning
  • 21. 0x40 1-Packet Based Stealth Scanning Techniques <ul><li>SYN Scan </li></ul><ul><li>ACK Scan </li></ul><ul><li>NULL Scan </li></ul><ul><li>FIN Scan </li></ul><ul><li>PSH Scan </li></ul><ul><li>URG Scan </li></ul><ul><li>XMAS Scan </li></ul><ul><li>XMAS1 Scan </li></ul><ul><li>XMAS2 Scan </li></ul><ul><li>XMAS3 Scan </li></ul>NMAP DPS Group #1: SYN Group #2: ACK Group #2: NULL FIN PSH URG XMAS XMAS1 XMAS2 XMAS3
  • 22. 3.3.3.3 [____ S _] 3.3.3.5 3.3.3.3 [____ S _] 3.3.3.5 3.3.3.3 [_ A __ S _] 3.3.3.5 3.3.3.3 [_ A __ S _] 3.3.3.5 Linux Windows Group #1: TCP SYN Scan (0X02) 3.3.3.3 3.3.3.3 3.3.3.5 3.3.3.5 OPEN PORT OPEN OPEN 0x40 1-Packet Based Stealth Scanning Techniques
  • 23. 3.3.3.3 [____ S _] 3.3.3.5 3.3.3.3 [____ S _] 3.3.3.5 3.3.3.3 [_ A _ R __] 3.3.3.5 3.3.3.3 [_ A _ R __] 3.3.3.5 Linux Windows 3.3.3.3 3.3.3.3 3.3.3.5 3.3.3.5 CLOSED PORT CLOSED CLOSED 0x40 1-Packet Based Stealth Scanning Techniques Group #1: TCP SYN Scan (0X02)
  • 24. 3.3.3.3 [_ A ____] 3.3.3.5 3.3.3.3 [_ A ____] 3.3.3.5 3.3.3.3 [___ R __] 3.3.3.5 3.3.3.3 [___ R __] 3.3.3.5 Linux Windows Group #2 TCP ACK Scan (0X10) 3.3.3.3 3.3.3.3 3.3.3.5 3.3.3.5 OPEN/ CLOSED PORT UNFILTERED UNFILTERED 0x40 1-Packet Based Stealth Scanning Techniques
  • 25. 3.3.3.3 [_ A ____] 3.3.3.5 3.3.3.3 [_ A ____] 3.3.3.5 Linux Windows 3.3.3.3 3.3.3.3 3.3.3.5 3.3.3.5 OPEN/ CLOSED PORT FILTERED FILTERED 0x40 1-Packet Based Stealth Scanning Techniques Group #2 TCP ACK Scan (0X10)
  • 26. 3.3.3.3 [______] 3.3.3.5 3.3.3.3 [______] 3.3.3.5 3.3.3.3 [_ A _ R __] 3.3.3.5 Linux Windows 3.3.3.3 3.3.3.3 3.3.3.5 3.3.3.5 OPEN PORT OPEN | FILTERED OPEN | CLOSED 0x40 1-Packet Based Stealth Scanning Techniques NULL [______] FIN [_____ F ] URG [ U _____] PSH [__ P ___] XMAS [ U _ P __ F ] XMAS1 [__ P __ F ] XMAS2 [ U ____ F ] XMAS3 [ U _ P ___] Group #3: NULL FIN URG PSH XMAS XMAS1 XMAS2 XMAS3
  • 27. 3.3.3.3 [______] 3.3.3.5 3.3.3.3 [______] 3.3.3.5 3.3.3.3 [_ A _ R __] 3.3.3.5 3.3.3.3 [_ A _ R __] 3.3.3.5 Linux Windows 3.3.3.3 3.3.3.3 3.3.3.5 3.3.3.5 CLOSED PORT OPEN | CLOSED CLOSED 0x40 1-Packet Based Stealth Scanning Techniques Group #3: NULL FIN URG PSH XMAS XMAS1 XMAS2 XMAS3 NULL [______] FIN [_____ F ] URG [ U _____] PSH [__ P ___] XMAS [ U _ P __ F ] XMAS1 [__ P __ F ] XMAS2 [ U ____ F ] XMAS3 [ U _ P ___]
  • 28. 0x40 1-Packet Based Stealth Scanning Techniques Example #1: ACK Scan: ACK NULL Scan: No Reply Example #3: ACK Scan: ACK URG Scan: RST_ACK SYN: RST_ACK Example #2: ACK Scan: ACK PSH Scan: RST_ACK SYN Scan: SYN_ACK Operating System: Linux Port Status: Open Operating System: Windows Port Status: Open Operating System: ------ Port Status: Closed Example #4: ACK Scan: No Reply XMAS Scan: No Reply Operating System: ------ Port Status: Filtered
  • 29. 0x50 Putting it into Practice [The Tool of Trade] <ul><li>Dynamic Port Scanner [DPS v1.0] is basic port scanner that integrates ARP-Poisoning to dynamically spoof source IP while scanning. It has the following features: </li></ul><ul><li>Source IP is randomly generated. It is not necessary that the IP exists in the network. </li></ul><ul><li>DPS Tool distinguishes between targets within local net and those beyond the local net. Thus, Poisoned host could be the scan target or the gateway. </li></ul><ul><li>It supports 10 one-packet TCP scanning techniques. Which are: </li></ul><ul><li>SYN, ACK, PSH, URG, FIN, NULL, XMAS, XMAS1, XMAS2, XMAS3 </li></ul><ul><li>Open Source [GPL’d] </li></ul>
  • 30. Tool Usage 0x50 Putting it into Practice [The Tool of Trade]
  • 31. Simple Network… Scanning Machine: OS : Linux IP : 10.1.11.20 MAC: 00:03:FF:A1:A0:89 Target Machine: OS : Linux IP : 10.1.11.81 Open Port: 80 0x50 Putting it into Practice [The Tool of Trade]
  • 32. Scanning… 0x50 Putting it into Practice [The Tool of Trade]
  • 33. The Victim… 0x50 Putting it into Practice [The Tool of Trade]
  • 34. TODO List… <ul><li>Make the program multi-threaded to speed up the scanning process. Current implementation scans each port at a time, which is a time-consuming process for long list of ports. </li></ul><ul><li>Make the ARP poisoning more reliable. Sometimes, when scanning huge number of ports, the program cannot effectively poison the host/gateway which will cause loss in replies. </li></ul><ul><li>Did someone say an “Nmap Patch” ?!!! </li></ul>0x50 Putting it into Practice [The Tool of Trade]
  • 35. 0x60 DEMO DEMO
  • 36. 0x70 Preventing DPS in Private LANs Recent switches come with “Port-Disabling” option in case of detecting any malicious activities on that port. Among those activities is the change of IP Address of the machine attached to that port. Since DPS requires that packets are sent with “fake” IP addresses, a switch can detect this behavior and disable the switch port immediately. The only way to bypass such measure is to increase time-gap between packets sent with different IP addresses. If the time-gap is long enough so that the switch cache is timed-out, it could lead to a situation where that attacker can still use DPS, but, it will take longer time. 0x71 The deployment of Port-Disabling feature on switches
  • 37. 0x70 Preventing DPS in Private LANs “ arpwatch” is a software package that monitors MAC/IP pairs in the network and reports any suspicious behavior. It is always recommended that the sys admin installs it on different subnets to monitor MAC/IP pair changes on the network. 0x72 Installing ARPWatch package on the server(s)
  • 38. 0x70 Preventing DPS in Private LANs Static ARP entries can be the best measure to protect against ARP-Poisoning. However, it can be a nightmare. However, if the network is almost stable (i.e. changes of IPs and machines are minimal), the sys admin can maintain a small perl or shell script that runs once a day and probe the IP/MAC combination of live systems and add static entries for them on the servers, located on that subnet, as well as on the gateway [i.e. router]. Although DPS can use unallocated IPs in subnet, “arpwatch” should take care of reporting them in such case. 0x73 Configuring static ARP entries on the machines
  • 39. 0x08 References 0x01 Nmap Port Scanner tool, by Fyodor http://www.insecure.org/map 0x02 Libnet Packet Creation/Injection Platform, by Mike Schiffman http://www.packetfactory.net/projects/libnet/ 0x03 Building Open Source Network Security Tools , by Mike Schiffman . 0x04 The Art of Scanning, by Fyodor Phrack Magazine - Volume 7, Issue 51 September 01, 1997 - article 11 0x05 libpcap: the packet capturing library http://www.tcpdump.org/ 0x06 arpwatch tool http://ee.lbl.gov/ 0x07 EtherApe: a graphical network monitor http:// etherape.sourceforge.net /
  • 40. THANKS & GREETINGS <ul><li>SECUREBITS Group: HK , NASSER , HUS , NTUFAR </li></ul><ul><li>CCC InfoSec Group: NAFEZ , GHASSAN , SALEM , WAFA </li></ul><ul><li>RUXCON Organizers </li></ul><ul><li>All of the attendees </li></ul>

×