11.4. Sniffing Tools¶
11.4.1. Nmap¶
nmap [Scan Type(s)] [Options] {target specification}
11.4.1.1. Specifying Targets¶
CIDR style
192.168.1.0/24comma separated
www.baidu.com,www.zhihu.comDividing line
10.22-25.43.32from file
-iL <inputfile>Exclude unwanted host
--exclude <host1 [, host2] [, host3] ... >--excludefile <excludefile>
11.4.1.2. Host Discovery¶
-sLList Scan - simply list targets to scan-sn/-sPPing Scan - disable port scan-PnTreat all hosts as online – skip host discovery-sS/sT/sA/sW/sMTCP SYN/Connect()/ACK/Window/Maimon scans-sUUDP Scan-sN/sF/sXTCP Null, FIN, and Xmas scans
Name |
Package tag |
Port OPEN |
Port CLOSE |
Features |
|---|---|---|---|---|
TCP SYN scan |
SYN |
Reply ACK+SYN |
Reply to RST |
The application has no logs, but is easy to find |
Full connection scan |
SYN |
Reply ACK+SYN |
Reply to RST |
easy to spot |
ACK scan |
ACK |
Reply to RST |
packet is dropped |
. |
FIN scan |
FIN |
packet is dropped |
Reply to RST |
Need to wait for timeout, low efficiency |
TCP Xmas scan |
FIN+URG+PSH |
packet is dropped |
Reply to RST |
Need to wait for timeout, low efficiency; not applicable to all operating systems |
TCP NULL scan |
NULL |
packet is dropped |
Reply to RST |
Need to wait for timeout, low efficiency; not applicable to all operating systems |
11.4.1.3. Port Scanning¶
--scanflagsCustomized TCP scan-P0no pingPS [port list](TCP SYN ping) // need root on UnixPA [port list](TCP ACK ping)PU [port list](UDP ping)PR (Arp ping)p <port message>FQuick scanrDo not scan in random order
11.4.1.4. Service and version detection¶
-sVversion detection--allportsDo not exclude any ports for version detection--version-intensity <intensity>Set version scan strength--version-lightTurn on lightweight mode // level 2--version-alltry each probe // level 9--version-traceTrack version scan activity-sR RPCscan
11.4.1.5. Operating System Scan¶
-OEnable OS detection--osscan-limitOS detection for specified targets--osscan-guess--fuzzyInferring OS detection results
11.4.1.6. Time and performance¶
- Resize parallel scan groups
--min-hostgroup<milliseconds>--max-hostgroup<milliseconds>
- Adjust the parallelism of probe packets
--min-parallelism<milliseconds>--max-parallelism<milliseconds>
- Adjusting the Probe Packet Timeout
--min_rtt_timeout <milliseconds>--max-rtt-timeout <milliseconds>--initial-rtt-timeout <milliseconds>
- Abandon slow target host
--host-timeout<milliseconds>
- Adjust the time interval of probe packets
--scan-delay<milliseconds>--max_scan-delay<milliseconds>
- Set time template
-T <Paranoid|Sneaky|Polite|Normal|Aggressive|Insane>-T<0-5>(bigger is faster)
11.4.1.8. Output¶
-oN<filespec>stdout-oX<filespec>XML output-oS<filespec>ScRipTKIdd|3oUTpuT-oG<filespec>Grep output-oA<basename>Export to all formats--openOnly output port information that may be open
11.4.1.9. Details and debugging¶
-vdetial output-d [level]debug level--packet-traceTrack sent and received messages--iflistList Interfaces and Routes
11.4.2. Masscan¶
11.4.2.1. Compiling¶
sudo apt-get install git gcc make libpcap-dev
git clone https://github.com/robertdavidgraham/masscan
cd masscan
make -j
11.4.2.2. Command Line Options¶
--portsSpecify the port range--ratespecified rate--source-ipSpecify the source IP