Nmap Port Scan
Version Enumeration with Nmap:
Always start with a full nmap
scan to check it returns version information.
We can also use the nmap
script scans to look for vulnerable services:
Introduction
Also see [[(3) Study Notes/(1) Red Team/Pentest/(2) Network/(99) Testing Tools/(1) Enumeration Tools/Nmap|Nmap]].
Example Payload:
Trick for faster scanning:
First, do a full port scan without -A
:
Then, perform -A
on all open ports.
SYN Scan
Example Syntax:
Benefits:
Faster (as less packets were sent)
May be stealthier (if the firewall does not log incomplete connections. The application may also not record the connection as it never reached the application)
UDP Scan
Example Syntax:
Both SYN and UDP scans can also be combined into one scan:
Network Sweeping
Example Syntax:
Use the
-sn
option to perform no port scan.
We can use grep
for a larger network:
Then:
Web Sweep:
This sweep for port 80 across the whole 192.168.50.0/24 network. Then:
General Sweep:
--top-ports
for enumerating common services.
OS Detection
Example Syntax:
Use
--osscan-guess
for aggressive OS guess.
Windows LOLBAS
Test-NetConnection
in PowerShell
Example Syntax:
This basically equals to testing the port with Telnet.
Basic Port Scan in PowerShell:
This loops through 1 to 1024 and attempt to build TCP connections with each of the ports of 192.168.50.151.
Bonus: Monitoring Traffics
iptables
Use
iptables
to monitor traffics of scanning.
-I
for inserting a new rule (to inbound traffic withINPUT
)The number following
INPUT
indicates where to insert the rule (Rule Order), with1
being at the top of all rules.
-s
for the source of traffic-j
for specifying what this rule does. HereACCEPT
means to let the packet go through.
-I
for inserting a new rule (to outbound traffic withOUTPUT
)-d
for the destination of traffic
-Z
for zeroing the packet and the byte counter. This is to reset the counters in iptables to obtain a fresh set of data.
After Scanning, use this to show the traffic generated:
Nessus
Not much useful stuff.
Nmap
NSE Scripts:
How to use customized NSE Scripts:
1. Google the relevant NSE script:
Download the
.nse
file to out machine.
2. Copy the script into the nmap scripts folder:
3. Update script.db
:
4. Use the script:
Last updated