Scanning using Nmap
Some of the Nmap example scans we’ll cover in this Module are run using
sudo
. This is because quite a few Nmap scanning options require access to raw sockets ,254 which in turn require root privileges. Raw sockets allow for surgical manipulation of TCP and UDP packets. Without access to raw sockets, Nmap is limited as it falls back to crafting packets by using the standard Berkeley socket API.Default Nmap TCP will scan
1000 most popular ports
Tesing how much traffic sent by default nmap scan
Monitoring amount of traffic using iptables
sudo iptables -I INPUT -I INPUT 1 -s 192.168.1.5 -j ACCEPT
sudo iptables -I OUTPUT 1 -d 192.168.1.5 -j ACCEPT
sudo iptables -Z
Where
Where
I
- Insert a new rule
INPUT
- Inbound traffic
OUTPUT
- Outbond Traffic
s
- source IP address
d
- destination IP address
j
- Accept the traffic
Z
- Zero the packet and byte counters in all chains
Scanning with nmap
nmap 192.168.1.5
Monitoring Traffice
sudo iptables -vn -L
v
- Verbose
-n
- Numeric Output
-L
- list the rules present in all chaing
Resulting Output
There is 121k
of traffice in default nmap scan
Other Tools
1. MASSCAN
2. RustScan
They are faster than nmap, generate a substaintial amout of concurrent traffic. Nmap impose some traffic rate limiting that results in less bandwidth congestion and more covert behavior
SYN scanning is a TCP port scanning method that involves sending SYN packets to various ports on a target machine without completing a TCP handshake. If a TCP port is open, a SYN-ACK should be sent back from the target machine, informing us that the port is open. At this point, the port scanner does not bother to send the final ACK to complete the three-way handshake.
Nmap Steath Scan (-sS)
sudo nmap -sS 192.168.1.5
Because the three-way handshake is never completed, the information is not passed to the application layer and as a result, will not appear in any application logs
Please note that term “stealth” refers to the fact that, in the past, firewalls would fail to log incomplete TCP connections. This is no longer the case with modern firewalls and although the stealth moniker has stuck around, it could be misleading
Various Scanning Technique using nmap
namp -sT $IP
>> TCP Connect Scan
nmap -sU $IP
>> UDP Scan
UDP Scan use two different methods to determine if a port is open or closed.
Use Standard
ICPM port unreachable
Method >>> for Most portsend protocol specific packet >>> Common port
eg. for port 161 which is used by SNMP - send protocol specific SNMP packet
The UDP scan sU
can also be used in conjuction with a TCP SYN Scan (-sS) to build a more complete picture of our target
sU
can also be used in conjuction with a TCP SYN Scan (-sS) to build a more complete picture of our targetNetwork Sweeping Technique
Attempt to probe large volume of target
Broad host scan
print more greppable output or more manageable format can be done by using `-oG` in nmap command and the command like:
Sweep specific TCP or UDP port
Top port scanning with OS version, script, traceroute using `-A` option
Top 20 port are determined using the /usr/share/nmap/nmap-services
OS scan and Guess OS scan to get rough idea of the target system
Banner Grabbing
Banner Garbbing significantly impacts amount of traffic used as well as speed or our scan
Banners can be modified by system administrators and intentionally set to fake service names to mislead potential attackers.
Nmap Scripting Engine (NSE)
NSE Scripts are located in the
/usr/share/nmap/scripts
To view mor information we can used
--script-help script_name
Eg. http-headers script
http-header scirpt attempt to cnnect HTTP Service on a target system and determine the supported header
Change Nmap xml output to html file for better readability
Last updated