nmap_cheet_sheet_v7.pdf

(563 KB) Pobierz
Nmap Cheat Sheet
Target Specification
Switch
Example
nmap 192.168.1.1
nmap 192.168.1.1 192.168.2.1
nmap 192.168.1.1-254
nmap scanme.nmap.org
nmap 192.168.1.0/24
nmap -iL targets.txt
nmap -iR 100
nmap --exclude 192.168.1.1
Description
Scan a single IP
Scan specific IPs
Scan a range
Scan a domain
Scan using CIDR notation
Scan targets from a file
Scan 100 random hosts
Exclude listed hosts
Switch
Scan Techniques
-sS
-sT
Example
nmap 192.168.1.1 -sS
nmap 192.168.1.1 -sT
nmap 192.168.1.1 -sU
nmap 192.168.1.1 -sA
nmap 192.168.1.1 -sW
nmap 192.168.1.1 -sM
Description
-iL
-iR
--exclude
-sU
-sA
-sW
-sM
TCP SYN port scan (Default)
TCP connect port scan
(Default without root privilege)
UDP port scan
TCP ACK port scan
TCP Window port scan
TCP Maimon port scan
Host Discovery
Switch
-sL
-sn
-Pn
-PS
-PA
-PU
-PR
-n
Example
nmap 192.168.1.1-3 -sL
nmap 192.168.1.1/24 -sn
nmap 192.168.1.1-5 -Pn
nmap 192.168.1.1-5 -PS22-25,80
nmap 192.168.1.1-5 -PA22-25,80
nmap 192.168.1.1-5 -PU53
nmap 192.168.1.1-1/24 -PR
nmap 192.168.1.1 -n
Description
No Scan. List targets only
Disable port scanning
Disable host discovery
. Port scan only
TCP SYN discovery on port x. Port 80 by default
TCP ACK discovery on port x. Port 80 by default
UDP discovery on port x. Port 40125 by default
ARP discovery on local network
Never do DNS resolution
Port Specification
Switch
-p
-p
-p
-p-
-p
-F
--top-ports
-p-65535
-p0-
Example
nmap 192.168.1.1 -p 21
nmap 192.168.1.1 -p 21-100
nmap 192.168.1.1 -p U:53,T:21-25,80
nmap 192.168.1.1 -p-
nmap 192.168.1.1 -p http,https
nmap 192.168.1.1 -F
nmap 192.168.1.1 --top-ports 2000
nmap 192.168.1.1 -p-65535
nmap 192.168.1.1 -p0-
Description
Port scan for port x
Port range
Port scan multiple TCP and UDP ports
Port scan all ports
Port scan from service name
Fast port scan (100 ports)
Port scan the top x ports
Leaving off initial port in range makes the scan start at port 1
Leaving off end port in range makes the scan go through to port 65535
www.stationx.net/nmap-cheat-sheet/
1
Service and Version Detection
Switch
-sV
-sV --version-intensity
-sV --version-light
-sV --version-all
-A
Example
nmap 192.168.1.1 -sV
nmap 192.168.1.1 -sV --version-intensity 8
nmap 192.168.1.1 -sV --version-light
nmap 192.168.1.1 -sV --version-all
nmap 192.168.1.1 -A
Description
Attempts to determine the version of the service running on port
Intensity level 0 to 9. Higher number increases possibility of correctness
Enable light mode. Lower possibility of correctness. Faster
Enable intensity level 9. Higher possibility of correctness. Slower
Enables OS detection, version detection, script scanning, and traceroute
OS Detection
Switch
-O
-O --osscan-limit
-O --osscan-guess
-O --max-os-tries
-A
Example
nmap 192.168.1.1 -O
nmap 192.168.1.1 -O --osscan-limit
nmap 192.168.1.1 -O --osscan-guess
nmap 192.168.1.1 -O --max-os-tries 1
nmap 192.168.1.1 -A
Description
Remote OS detection using TCP/IP stack fingerprinting
If at least one open and one closed TCP port are not found it will not try
OS detection against host
Makes Nmap guess more aggressively
Set the maximum number x of OS detection tries against a target
Enables OS detection, version detection, script scanning, and traceroute
Timing and Performance
Switch
-T0
-T1
-T2
-T3
-T4
-T5
Example
nmap 192.168.1.1 -T0
nmap 192.168.1.1 -T1
nmap 192.168.1.1 -T2
nmap 192.168.1.1 -T3
nmap 192.168.1.1 -T4
nmap 192.168.1.1 -T5
Description
Paranoid (0) Intrusion Detection System evasion
Sneaky (1) Intrusion Detection System evasion
Polite (2) slows down the scan to use less bandwidth and use less target machine resources
Normal (3) which is default speed
Aggressive (4) speeds scans; assumes you are on a reasonably fast and reliable network
Insane (5) speeds scan; assumes you are on an extraordinarily fast network
Example input
Switch
--host-timeout <time>
--min-rtt-timeout/max-rtt-timeout/initial-rtt-timeout <time>
--min-hostgroup/max-hostgroup <size>
--min-parallelism/max-parallelism <numprobes>
--scan-delay/--max-scan-delay <time>
--max-retries <tries>
--min-rate <number>
--max-rate <number>
1s; 4m; 2h
1s; 4m; 2h
50; 1024
10; 1
20ms; 2s; 4m; 5h
3
100
100
Description
Give up on target a er this long
Specifies probe round trip time
Parallel host scan group sizes
Probe parallelization
Adjust delay between probes
Specify the maximum number of port scan probe retransmissions
Send packets no slower than <number> per second
Send packets no faster than <number> per second
www.stationx.net/nmap-cheat-sheet/
2
NSE Scripts
Switch
-sC
--script default
--script
--script
--script
--script
--script-args
Example
nmap 192.168.1.1 -sC
Scan with default NSE scripts. Considered useful for discovery and safe
nmap 192.168.1.1 --script default
Scan with default NSE scripts. Considered useful for discovery and safe
nmap 192.168.1.1 --script=banner
Scan with a single script. Example banner
nmap 192.168.1.1 --script=http*
Scan with a wildcard. Example http
nmap 192.168.1.1 --script=http,banner
Scan with two scripts. Example http and banner
nmap 192.168.1.1 --script "not intrusive" Scan default, but remove intrusive scripts
nmap --script snmp-sysdescr --script-args snmpcommunity=admin 192.168.1.1
NSE script with arguments
Description
Useful NSE Script Examples
Command
Description
nmap -Pn --script=http-sitemap-generator scanme.nmap.org
http site map generator
nmap -n -Pn -p 80 --open -sV -vvv --script banner,http-title -iR 1000
Fast search for random web servers
nmap -Pn --script=dns-brute domain.com
Brute forces DNS hostnames guessing subdomains
nmap -n -Pn -vv -O -sV --script smb-enum*,smb-ls,smb-mbenum,smb-os-discovery,smb-s*,smb-vuln*,smbv2* -vv 192.168.1.1
nmap --script whois* domain.com
Whois query
nmap -p80 --script http-unsafe-output-escaping scanme.nmap.org
Detect cross site scripting vulnerabilities.
nmap -p80 --script http-sql-injection scanme.nmap.org
Check for SQL injections
Safe SMB scripts to run
Firewall / IDS Evasion and Spoofing
Switch
Requested scan (including ping scans) use tiny fragmented
IP packets. Harder for packet filters
--mtu
nmap 192.168.1.1 --mtu 32
Set your own offset size
-D
nmap -D 192.168.1.101,192.168.1.102,192.168.1.103,192.168.1.23 192.168.1.1 Send scans from spoofed IPs
-D
nmap -D decoy-ip1,decoy-ip2,your-own-ip,decoy-ip3,decoy-ip4 remote-host-ip Above example explained
-S
nmap -S www.microso .com www.facebook.com
Scan Facebook from Microso (-e eth0 -Pn may be required)
-g
nmap -g 53 192.168.1.1
Use given source port number
--proxies
nmap --proxies http://192.168.1.1:8080, http://192.168.1.2:8080 192.168.1.1
Relay connections through HTTP/SOCKS4 proxies
--data-length nmap --data-length 200 192.168.1.1
Appends random data to sent packets
Example IDS Evasion command
nmap -f -t 0 -n -Pn --data-length 200 -D 192.168.1.101,192.168.1.102,192.168.1.103,192.168.1.23 192.168.1.1
-f
Example
nmap 192.168.1.1 -f
Description
www.stationx.net/nmap-cheat-sheet/
3
Output
Switch
-oN
-oX
-oG
-oA
-oG -
--append-output
-v
-d
--reason
--open
--packet-trace
--iflist
--resume
Example
nmap 192.168.1.1 -oN normal.file
nmap 192.168.1.1 -oX xml.file
nmap 192.168.1.1 -oG grep.file
nmap 192.168.1.1 -oA results
nmap 192.168.1.1 -oG -
nmap 192.168.1.1 -oN file.file --append-output
nmap 192.168.1.1 -v
nmap 192.168.1.1 -d
nmap 192.168.1.1 --reason
nmap 192.168.1.1 --open
nmap 192.168.1.1 -T4 --packet-trace
nmap --iflist
nmap --resume results.file
Description
Normal output to the file normal.file
XML output to the file xml.file
Grepable output to the file grep.file
Output in the three major formats at once
Grepable output to screen. -oN -, -oX - also usable
Append a scan to a previous scan file
Increase the verbosity level (use -vv or more for greater effect)
Increase debugging level (use -dd or more for greater effect)
Display the reason a port is in a particular state, same output as -vv
Only show open (or possibly open) ports
Show all packets sent and received
Shows the host interfaces and routes
Resume a scan
Description
Scan for web servers and grep to show which IPs are running web servers
Generate a list of the IPs of live hosts
Append IP to the list of live hosts
Compare output from nmap using the ndiff
Convert nmap xml files to html files
Reverse sorted list of how o en ports turn up
Helpful Nmap Output examples
Command
nmap -p80 -sV -oG - --open 192.168.1.1/24 | grep open
nmap -iR 10 -n -oX out.xml | grep "Nmap" | cut -d " " -f5 > live-hosts.txt
nmap -iR 10 -n -oX out2.xml | grep "Nmap" | cut -d " " -f5 >> live-hosts.txt
ndiff scanl.xml scan2.xml
xsltproc nmap.xml -o nmap.html
grep " open " results.nmap | sed -r 's/ +/ /g' | sort | uniq -c | sort -rn | less
Miscellaneous Options
Switch
-6
-h
Example
nmap -6 2607:f0d0:1002:51::4
nmap -h
Other Useful Nmap Commands
Description
Enable IPv6 scanning
nmap help screen
Command
nmap -iR 10 -PS22-25,80,113,1050,35000 -v -sn
nmap 192.168.1.1-1/24 -PR -sn -vv
nmap -iR 10 -sn -traceroute
nmap 192.168.1.1-50 -sL --dns-server 192.168.1.1
Description
Discovery only on ports x, no port scan
Arp discovery only on local network, no port scan
Traceroute to random targets, no port scan
Query the Internal DNS for hosts, list targets only
www.stationx.net/nmap-cheat-sheet/
4
Identifying Open Ports with Nmap
TCP SYN SCAN (-sS)
TCP connect() SCAN (-sT)
TCP FIN SCAN (-sF)
TCP XMAS TREE SCAN (-sX)
TCP NULL SCAN (-sN)
TCP PING SCAN (-sP)
VERSION DETECTION SCAN (-sV)
Version scan identifies open pots with a TCP SYN scan…
UDP SCAN (-sU)
IP PROTOCOL SCAN (-sO)
…and then queries the port with a customized signature.
TCP ACK SCAN (-sA)
TCP WINDOW SCAN (-sW)
www.stationx.net/nmap-cheat-sheet/
5
Zgłoś jeśli naruszono regulamin