Network scanning with Nmap for Noobs and Ninjas - This slide was presented at Null Delhi monthly security meet by Nikhil and Jayvardhan.
https://www.facebook.com/nullOwaspDelhi/
2. Who we are?
Jayvardhan Singh @Silent_Screamr
- Web and Mobile Security researcher
- Bugbounty and Hall of Fame
- Microsoft | Apple | Nokia | Barracuda |
Blackberry | Olark | Heroku |
Nikhil Raj @0xn1k5
- Web, Network and Wireless pentesting
- RHCSA, RHCE & CEH
- Dump my tools at github.com/0xn1k5
4. Enterprise Network
Firewall Router Switch
Hosts
Private IP
Class A : 10.0.0.0 – 10.255.255.255
Class B : 172.16.0.0 – 172.31.255.255
Class C : 192.168.0.0 – 192.168.255.255
Public IP
Internet
NAT/PAT
5. Find your own IP
Public IP
Just Google What is my
ip address
Or, visit
http://whatismyip
address.com
Private IP
Open the cmd/terminal
and type:
# ipconfig (windows)
# ifconfig (Unix/Linux)
9. What Services are available?
- Each hosts needs to perform multiple
networking operations as web, instant
messenger, file transfer, video streaming and
remote management using RDP or SSH
- Can either be TCP or UDP based service
associated with unique port number
10. Port Numbers
● Port no exists at Transport Layer
● Size: 16 bits unsigned integer
● Range: 0 – 65535 (Both TCP & UDP)
– Well known port ( 0 – 1023 )
– Reserved port ( 1024 – 49151 )
– Dynamic or Private port ( 49152 – 65535 )
11. Common Services & Ports
● Web Services – tcp/80, tcp/8080, tcp/443
● FTP – tcp/20 & 21
● SSH – tcp/22
● Mail – tcp/25
● Database – Mysql (tcp/3306), Oracle
(tcp/1521)
● DNS - udp/53
● SNMP –udp/161
12. TCP vs UDP
• Transmission Control
Protocol
• Reliable
• Connection-oriented
(3-way handshake)
• Flow control,
sequencing and
acknowledgement
• User Datagram
Protocol
• Unreliable
• Connection less
• No retransmission
and
acknowledgement
13. TCP 3 Way Handshake
SYN
SYN + ACK
ACK
Service is listening (Open )
DATA
14. TCP 3 Way Handshake
SYN
RST
Service is listening (Closed)
16. Demo with Netcat
Start Netcat Listener (Server)
# nc -l -p <port>
Use Netcat as client
# nc <ip> <port>
& Inspect traffic in Wireshark
17. Nmap
● Open Source
● Fast and efficient
● Supports multiple platforms
● Active community support
● Popular...Featured in Movies as well :-)
● Can be extended by using its Nmap Scripting
Engine
19. Specifying port range
# nmap -p 80 192.168.0.1
# nmap –p 21,22,80 192.168.0.1/24
# nmap –p 1-65535 192.168.0.1/24
# nmap --top-ports 200 192.168.0.1/24
# nmap –top-ports 10 192.168.0.1 --reason
PS: By default nmap scans only top 1000 most widely
used ports which can be changed using –top-ports
24. Nmap Scripting Engine
- Script ends with .nse extension
- Located at “/usr/share/nmap/scripts” in kali
- Invoked using –sC (default) or –-script
switch
- Categorised as auth, broadcast, brute,
default. discovery, dos, exploit, external,
fuzzer, intrusive, malware, safe, version, and
vuln
- Can be used for enumeration, vulnerability
detection, exploitation and more.
30. Nmap Scan Types II
- Not all systems are RFC compliant
- Responds differently on receiving certain TCP flags
- Mostly used in *nix based system
- FIN Scan (-sF)
- Sets the TCP FIN bit.
- XMAS (-sX)
- Sets the FIN, PSH, and URG flags
- Null Scan (-sN)
- Does not set any flags
31. Firewalls
- Modify source port
# nmap –g 80 <ip>
- Fragment the packet
# nmap –f <ip>
-Send packet with bad checksum
# nmap –-badsum <ip>
In a typical home network, all the devices are either connecter by WiFi or Lan to a central router/access point. And a unique IP is assigned to each device.
While enterprise network is a bit complex, and can have many network devices sitting before your traffic leaves the company’s network. Inside the organization it uses Private IP addressing scheme and is converted into public IP at Gateway device (usually a firewall).
Ask the audience to find their own public ip?
Ask the audience to find their own public ip?
The easiest way to check who else is on the network is to ping the ip(s) sequentially, if they respond it is up else it may down or simply isn’t responding
When connected on the network, Users may browse the web, stream video, download/upload files with the help of different services. These services are can run on TCP (reliable) , UDP (unreliable) protocol or both on different port numbers.
TCP – a stable connection must be established before data transfer is initiated via a process known as three-way handshake. UDP is connection less protocol communications are sent without any expectation of a timely confirmation of receipt from the remote end Thus, one has to allow for a longer timeout before it can be assumed that a remote port is closed
On an network pentest engagement, you will receive a list of ip(s) or network subnet. You have to first identify the alive hosts and confirm the same with the client.
On an network pentest engagement, you will receive a list of ip(s) or network subnet. You have to first identify the alive hosts and confirm the same with the client.