Advertisement
berzerk0

nmap and arpscan

Apr 26th, 2018
415
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.65 KB | None | 0 0
  1. --- OBTAIN IP FROM DOMAIN NAME ---
  2.  
  3. Using "host"
  4.  
  5. host -t a DOMAIN
  6. host -t aaaa DOMAIN
  7.  
  8.  
  9. Using "traceroute" (sends pings)
  10.  
  11. traceroute example.com
  12.  
  13. Using --traceroute with "nmap" (-PN does not send pings, assumes host is up)
  14.  
  15. sudo nmap -sn --traceroute DOMAIN
  16. sudo nmap -PN -sn --traceroute DOMAIN
  17.  
  18. Using OSINT
  19. dns.google.com
  20. https://toolbar.netcraft.com/site_report?url=http://example.com
  21. Maltego or recon-ng
  22.  
  23.  
  24. Using nmap to get netblocks
  25.  
  26. nmap -sn DOMAIN/24 | grep DOMAIN
  27.  
  28.  
  29.  
  30. -- DISCOVER/VERIFY A HOST WITHOUT ICMP PING --
  31.  
  32. Using nmap
  33.  
  34. nmap TCP SYN pinging: -PS (port 80 default)
  35.  
  36. sudo nmap -sn -PS some_ports DOMAIN
  37.  
  38.  
  39. nmap TCP ACK ping: -PA (port 80 default)
  40.  
  41. sudo nmap -sn -PA some_ports DOMAIN
  42.  
  43.  
  44. nmap UDP ping: -PU (ports 31,338 default)
  45. data length of 32 simulates Windows, data length 56 simulates Linux
  46.  
  47. sudo -sn -PU some_ports --data-length 32 DOMAIN
  48.  
  49.  
  50. nmap SCTP INIT ping (port 80 default)
  51.  
  52. sudo nmap -sn -PY some_ports DOMAIN
  53.  
  54.  
  55. nmap non-standard pings (not echo, PP = timestamp, PM = address mask)
  56.  
  57. sudo nmap -sn -PP DOMAIN
  58. sudo nmap -sn -PM DOMAIN
  59.  
  60.  
  61.  
  62. Using telnet to try and connect via TCP via a likely port
  63.  
  64. telnet DOMAIN some_port
  65.  
  66.  
  67. Using nc to try and connect via TCP via a likely port
  68.  
  69. nc DOMAIN some_port
  70.  
  71.  
  72. --- ARP-SCAN USAGE ----
  73.  
  74. Discover hosts on a local network via ARP
  75.  
  76. arp-scan -I nic_name 192.168.1.1-192.168.1.255
  77. arp-scan -I nic_name -l
  78.  
  79.  
  80.  
  81. Or, do the same with nmap (slower, but better at OUI)
  82.  
  83. nmap -e nic_name -sn hosts
  84.  
  85.  
  86.  
  87. ARP Scan hosts from file "ip_list.txt" and save to "scan.pcap"
  88.  
  89. arp-scan -I nic_name -W path/to/pcapfile -f path/to/hostsfile
  90.  
  91. Quickly read the pcap with "tcpdump -r path/to/file"
  92.  
  93.  
  94. Include padding after packet data, for "short" files only
  95.  
  96. arp-scan -I nic_name -A HEXVALUE hosts
  97. arp-scan -I nic_name -A $(xxd FILE | cut -d ' ' -f 2-8 | tr -d ' \n')
  98.  
  99.  
  100. Discover hosts on local network via ARP, but spoof IP and MAC
  101. (ARP header shows real MAC address)
  102.  
  103. arp-scan -I nic_name -s 12.34.56.78 -S 01:02:03:04:05:06 hosts
  104.  
  105.  
  106. Determine which host has a given MAC address
  107.  
  108. arp-scan -I nic_name -T mac_address hosts
  109.  
  110.  
  111. Determine which hosts are listening to multicast
  112.  
  113. arp-scan -I nic_name -T 01:00:5E:00:00:00 hosts
  114.  
  115. Determine which hosts are in promiscuous mode
  116.  
  117. arp-scan -I nic_name -T 01:00:01:02:03:04 hosts
  118.  
  119.  
  120. --- nmap firewall bypass attempts --
  121.  
  122. Null, FIN and XMAS scans may bypass Unix-based firewalls. (-sN -sF -sX)
  123. (-sN != -sn)
  124. sudo nmap -sN HOSTS
  125. sudo nmap -sF HOSTS
  126. sudo nmap -sX HOSTS
  127.  
  128.  
  129. If host is behind a firewall, scanning it may produce a response "Not Shown: ALL_SCANNED filtered ports"
  130.  
  131. ACK Scan may show if ports are filtered or unfiltered.
  132.  
  133. sudo nmap -sA -PN HOST
  134.  
  135. Some firewalls may trust traffic based solely on the port number.
  136.  
  137. Using a non-standard port may bypass this check.
  138.  
  139. sudo nmap -PN -g port_number host
  140.  
  141. If this scan shows a single port, scanning from that port may take advantage of a misconfiguration and bypass the firewall
  142.  
  143.  
  144. Some firewalls, primarily Unix-based systems have trouble dealing with IP packet fragments. The '-f' flag breaks packets into fragments of 8 bytes or less after the header. '--mtu multiple_of_8' breaks packets into fragments o
  145.  
  146. sudo nmap -PN -f host
  147.  
  148.  
  149. Since some firewalls protect only from outside IPs, it may be possible to bypass a firewall by routing through another machine on its network. Loose options will attempt to find a route through a certain group of hosts. Strict routing requires manual setting of hops
  150.  
  151. nmap -PN --ip-options "L 192.168.1.1 192.168.1.32" host
  152. nmap -PN --ip-options "S hop1 hop2 hop3..." host
  153.  
  154.  
  155.  
  156.  
  157.  
  158. -- Memorable nmap commands--
  159.  
  160.  
  161. Just show what hosts are to be scanned, but don't scan anything.
  162.  
  163. nmap -sL (complicated host definition)
  164.  
  165. Just traceroute
  166.  
  167. nmap -sn -Pn --traceroute HOST
  168.  
  169.  
  170. Resume a scan interrupted but output to a file (xml works best)
  171.  
  172. sudo nmap --resume FILENAME
  173.  
  174.  
  175.  
  176. Convert nmap .xml to html
  177.  
  178. xsltproc nmap.xml -o nmap.html
  179.  
  180.  
  181.  
  182.  
  183. Scan multiple hosts for a certain for a certain open port, only show hosts with that port open, save to greppaple format
  184.  
  185. nmap -Pn -p port_number --open -oG port_numberscan_%D HOSTS
  186.  
  187.  
  188.  
  189. Scan some TCP and UDP ports
  190.  
  191. sudo nmap -sS -sU -pT:21,23,U:53,111 HOST
  192.  
  193.  
  194.  
  195. Run all safe scripts on top 100 ports save to all formats
  196.  
  197. sudo nmap -sS -F -Pn --script safe -oA outfile_%D HOSTS
  198.  
  199.  
  200.  
  201. Fyodor's Discoverer Supreme:
  202.  
  203. sudo nmap -sn -PE -PP -PS21,22,23,25,25,80,113,31339, -PA80,113,443,10042 -PU53,51234 --source-port 53 --data-length 32 HOSTS
  204.  
  205.  
  206.  
  207. Scan all TCP ports as fast as possible, identify versions, OS and traceroute, run default, safe and vulnerable scripts, save to all formats (good for CTFs)
  208.  
  209.  
  210. nmap -e nic_name -sS -A -p0- --scripts "default or vuln" -oA seriousscan_%D HOSTS
  211.  
  212.  
  213.  
  214.  
  215. Ghostscan: Decoy IPs, using slow timing, append random data to packets, randomize host scan order, scan from random port above 51000, don't ping, use SYN scan, output to all formats
  216.  
  217.  
  218. sudo nmap -sS -Pn -T0 -g $(shuf -i 50000-65535 -n 1) --randomize-hosts --data-length $(($RANDOM%32+224)) -D decoy-ip1,decoy-ip2,decoy-ip3,decoy-ip4,decoy-ip4,decoy-ip5,decoy-ip6 -oA ghostscan_%D HOSTS
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement