0% found this document useful (0 votes)
59 views11 pages

Nmap Port Scanning Experiment Guide

The document provides an introduction to cyber security focusing on port scanning using Nmap, explaining what ports are, their significance, and ethical considerations. It details various Nmap commands and techniques for scanning, detecting services, and identifying vulnerabilities, along with real-world legal and illegal scenarios. The conclusion emphasizes the importance of responsible use of port scanning tools and offers next steps for further learning in cybersecurity.

Uploaded by

3221v6r
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views11 pages

Nmap Port Scanning Experiment Guide

The document provides an introduction to cyber security focusing on port scanning using Nmap, explaining what ports are, their significance, and ethical considerations. It details various Nmap commands and techniques for scanning, detecting services, and identifying vulnerabilities, along with real-world legal and illegal scenarios. The conclusion emphasizes the importance of responsible use of port scanning tools and offers next steps for further learning in cybersecurity.

Uploaded by

3221v6r
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Introduction To Cyber Security & Lab Tools

Ex1. Perform an Experiment for port scanning with nmap

Aim of the Experiment:

-To understand what a network port is, how to use Nmap to scan for open ports on a machine,
and to distinguish between ethical and unethical uses of port scanning with real-world
examples.

What is a Port?

Imagine a Computer as a Hotel:

• A hotel has many rooms.

• Each room serves a different purpose (e.g., dining, sleeping, storage).

• A computer is like a hotel, and ports are its rooms.

Definition:

-A port is a communication endpoint on a computer where data is received and sent. Each
port is associated with a specific service or application.

Vijay babu K [Link] [Link] 1/11


Introduction To Cyber Security & Lab Tools

Port Numbers:

• Ports are numbered from 0 to 65535.

• Common Port Numbers:

Port Number Protocol Use

20, 21 FTP File transfer

22 SSH Secure remote login

23 Telnet Unsecure remote login

25 SMTP Sending email

53 DNS Resolving domain names

80 HTTP Web browsing

443 HTTPS Secure web browsing

3306 MySQL Database

Example:

• When you open [Link] your browser connects to port 443 on


Google’s servers because it’s using HTTPS.

What is Port Scanning?

-Port scanning is like checking which doors (ports) are open on a building (computer) to see
which services are active. It helps in:

• Identifying vulnerabilities

• Auditing networks

• Ethical hacking

Vijay babu K [Link] [Link] 2/11


Introduction To Cyber Security & Lab Tools

What is Nmap?

o Nmap = Network Mapper

o It's a powerful command-line tool used to:

• Discover live hosts on a network

• Identify open ports and services

• Detect the operating system

• Perform security audits

Tools Required:

Tool Description

Nmap Port scanner

Target Machine Localhost / VM (Ubuntu, Windows, etc.)

OS Kali Linux / Ubuntu / Windows

Network Setup LAN or Virtual Network (do not scan public IPs
without permission)

Types of Port States (Nmap output):

Port State Meaning

Open Service is listening (can connect)

Closed No service is listening (but port exists)

Filtered Port blocked by firewall

Unfiltered Port accessible, but no info

**Open Filtered**

**Closed Filtered**

Vijay babu K [Link] [Link] 3/11


Introduction To Cyber Security & Lab Tools

Step-by-Step Procedure:

A. Beginner – Basic Scan:

nmap <target_ip>

Example:

nmap [Link]

B. Intermediate – Detect Service Versions:

nmap -sV [Link] `

• Shows version of services (e.g., Apache 2.4.41)

C. Expert – Aggressive Scan:

nmap -A [Link]

• Performs: OS Detection, Version detection, Script scanning, Traceroute

Sample/Expected Output:

Vijay babu K [Link] [Link] 4/11


Introduction To Cyber Security & Lab Tools

Complete Nmap Commands, Subcommands, Uses & Use Cases

1. Basic Scanning Commands

Command Use Example Use Case

Discover open
nmap <IP> Basic scan nmap [Link]
ports

nmap <domain> Scan domain nmap [Link] Scan web server

2. Port Scanning Options

Command Use Example Use Case

Check if SSH
-p <port> Scan specific port nmap -p 22 [Link]
is open

Full port
-p- Scan all 65535 ports nmap -p- [Link]
sweep

Quick check
-F Fast scan (top 100 ports) nmap -F [Link] for common
services

Ordered port
-r Scan ports in order nmap -r [Link]
scan

Fast scan on
--top-ports <n> Scan top N ports nmap --top-ports 20 [Link] most used
ports

3. Scan Techniques

Command Technique Use Case

-sS TCP SYN scan (stealth) Default and fast scan

-sT TCP connect scan When SYN scan fails (no root)

-sU UDP scan Scan services like DNS, SNMP

-sN Null scan Firewall evasion (advanced)

Vijay babu K [Link] [Link] 5/11


Introduction To Cyber Security & Lab Tools

Command Technique Use Case

-sX Xmas scan IDS evasion

-sF FIN scan Stealth scan with FIN flags

4. Service & Version Detection

Command Use Example Use Case

Detect service Check app versions


-sV nmap -sV [Link]
versions (Apache, SSH)

Control version Faster vs more


--version-intensity <0-9> nmap --version-intensity 5
detection accurate scans

5. OS Detection

Command Use Example Use Case

Find target OS type


-O Detect OS nmap -O [Link]
(Windows, Linux)

Guess OS
--osscan-guess nmap -O --osscan-guess Useful if detection is unclear
aggressively

6. Aggressive Scan

Command Use Example Use Case

Aggressive scan (OS + version + script + Full audit


-A nmap -A [Link]
traceroute) of target

Vijay babu K [Link] [Link] 6/11


Introduction To Cyber Security & Lab Tools

7. Script Scanning (Nmap Scripting Engine - NSE)

Command Use Example Use Case

Check for common


-sC Run default scripts nmap -sC [Link]
vulnerabilities

--script <script> Run specific script nmap --script http-title Show webpage title

Run vulnerability Check for CVEs, weak


--script vuln nmap --script vuln
scan scripts services

8. Timing & Performance

Command Use Example Use Case

Faster scans (T4/T5) or


-T0 to -T5 Timing templates nmap -T4 [Link]
stealthier (T0)

Set minimum
--min-rate nmap --min-rate 1000 Fast scans
packets/sec

--max-retries Limit retries nmap --max-retries 2 Avoid long scan times

9. Output Options

Command Use Example Use Case

-oN Normal output nmap -oN [Link] Easy-to-read output

-oX XML output nmap -oX [Link] Parse in scripts

For
-oG Grepable output nmap -oG [Link]
scripting/automation

Get .nmap, .xml,


-oA All formats nmap -oA fullscan
.grep files

Vijay babu K [Link] [Link] 7/11


Introduction To Cyber Security & Lab Tools

10. Host Discovery

Command Use Example Use Case

-sn Ping scan only nmap -sn [Link]/24 Find live hosts

Scan hidden hosts (ICMP


-Pn Disable ping nmap -Pn [Link]
blocked)

-PS, -PA, - TCP SYN, TCP ACK, UDP


nmap -PS80,443 Custom host discovery
PU ping

11. Firewall/IDS Evasion

Command Use Example Use Case

Fragment
-f nmap -f [Link] Bypass simple firewalls
packets

--source-port Fake DNS to bypass


Set source port nmap --source-port 53
<port> filters

nmap -D RND:10
-D RND:10 Decoy scanning Hide real source IP
[Link]

--data-length <n> Add payload nmap --data-length 50 Obfuscate scan packets

12. Scanning Multiple Targets

Command Use Example Use Case

nmap [Link]-
Scan range of IPs nmap [Link]-254 Scan full subnet
10

nmap -iL [Link] Input from file nmap -iL [Link] Batch scan

Scan 5 random Random host


nmap -iR 5 nmap -iR 10
hosts scanning

nmap --exclude
nmap --exclude <ip> Exclude IP Skip specific systems
[Link]

Vijay babu K [Link] [Link] 8/11


Introduction To Cyber Security & Lab Tools

13. Real-World Use Cases

Use Case Nmap Feature Used

Network Inventory nmap -sP [Link]/24

Find Open Web Servers nmap -p 80,443 -sV [Link]/24

Detect Vulnerabilities nmap --script vuln

Audit SSH Security nmap --script ssh* -p 22

Check Database Exposure nmap -p 3306 --script mysql*

Identify IoT Devices nmap -O -sV

Bypass Firewalls (Lab use only) nmap -f or nmap -D RND:10

Next Steps After Mastering Nmap

1. Learn Wireshark for packet analysis

2. Master Nmap Scripting Engine (NSE) scripting (Lua-based)

3. Move into Vulnerability Scanning with tools like Nessus, OpenVAS

4. Practice on labs like TryHackMe, Hack The Box

5. Get certified: CEH, OSCP, or CompTIA Security+

6. Combine Nmap with Metasploit Framework

7. Scan and secure cloud systems (AWS, Azure, GCP)

Observations:

Command/Tool Purpose/Observation

Vijay babu K [Link] [Link] 9/11


Introduction To Cyber Security & Lab Tools

Real-Time Scenarios (Examples):

Legal Scenario:

-A security team scans their company’s internal servers to find open ports for maintenance
— with permission.

Illegal Scenario:

-A hacker scans a bank’s website without permission and uses open ports to exploit a server
— without permission, violates the IT Act 66C/66D in India.

Legal vs Illegal Use of Port Scanning:

Action Legal Illegal Example

Scan your own PC/server Test open services on


localhost

Scan a public IP without Scanning [Link]


asking

Scan a friend’s PC with Lab practice


permission

Scan government servers Against the law

Additional Tips for Better Understanding:

o Use nmap localhost to safely test on your own machine.

o Use nmap -F for a fast scan (top 100 ports).

o Use nmap -O to detect the OS of the target (in aggressive mode).

o Always log your scans with on [Link].

Vijay babu K [Link] [Link] 10/11


Introduction To Cyber Security & Lab Tools

Precautions and Ethics:

o Never scan unknown IPs without written permission.

o Respect cyber laws and digital ethics.

o Use tools only in labs, sandboxes, or for certified penetration testing.

o Educate others on legal/illegal boundaries of scanning.

What Can I Do If I Know Port Scanning Well?

o - Learn vulnerability assessment and penetration testing (VAPT)

o - Practice ethical hacking using platforms like Hack The Box, TryHackMe

o - Get certified (e.g., CEH, CompTIA Security+, OSCP)

o - Learn advanced tools like Wireshark, Nessus, Metasploit

o - Join bug bounty programs (HackerOne, Bugcrowd)

Conclusion/Result:

This experiment taught:

o The concept of ports and services

o Nmap usage at various levels (basic to advanced)

o The importance of ethical hacking

o Differences between safe/unsafe, legal/illegal scanning

Port scanning is a powerful tool — but with great power comes great responsibility!

Viva / Interview Questions:

1. What is a network port?


2. How does Nmap work?
3. What is the difference between TCP and UDP scanning?
4. What do you mean by "filtered" port?
5. What are ethical issues in port scanning?
6. What Indian law punishes illegal hacking or scanning?
7. Why do attackers use Nmap?
8. How can organizations protect their open ports?

Vijay babu K [Link] [Link] 11/11

Common questions

Powered by AI

Aggressive scanning techniques in network security, such as those performed with the Nmap -A option, offer comprehensive data due to layered analysis, including OS detection, version detection, script scanning, and traceroute. The primary advantage is a thorough understanding of the security posture by detecting a wide array of vulnerabilities and network misconfigurations in a single scan . However, the risks include increased chances of detection by Intrusion Detection Systems (IDS), potentially triggering alarms and defensive responses. It can also consume significant bandwidth and resources, leading to network disruption .

Timing and performance adjustments in Nmap can significantly influence both the accuracy and stealth of scans. Using timing templates (e.g., -T0 for stealth or -T5 for speed) allows users to control the rate of packet sending, impacting scan detectability and completeness. Faster settings increase the chance of missing details due to network congestion or resource limitations, while slower settings reduce the risk of discovery by IDS but extend scan duration. Adjustments such as --min-rate or --max-retries refine these aspects by setting minimum packet rates or limiting retries, balancing thoroughness against vulnerability to detection .

Nmap's version detection capabilities, enabled with the -sV option, allow security professionals to accurately identify specific software and service versions running on target systems. This is crucial for vulnerability assessment since discovered versions can be cross-referenced with vulnerability databases to identify known exploits and vulnerabilities. Accurate version detection helps prioritize security patches and mitigation efforts and enables targeted vulnerability testing. However, it can also make scans more detectable, as it requires a more in-depth interaction with the target .

Effective strategies to protect a network from unauthorized port scanning include implementing firewalls to block unsolicited traffic, using Intrusion Detection Systems (IDS) to monitor and alert upon suspicious patterns, and applying rate limiting to hinder scan progress. Network segmentation can minimize exposure by isolating sensitive systems. Honeypot deployment can distract and gather intelligence on attackers. While these methods effectively deter casual intruders and raise the complexity of scans, they require careful configuration and maintenance to ensure they do not introduce bottlenecks or vulnerabilities themselves .

Legal frameworks differentiate ethical and unethical uses of Nmap based on consent, purpose, and the outcome of scanning activities. Ethical uses include network auditing within an organization, educational purposes, and penetration testing with explicit consent. Unethical uses involve scanning third-party systems without permission, attempting to exploit discovered weaknesses, and violating privacy and security laws. Legal implications vary by jurisdiction; for example, the IT Act in India punitively addresses unauthorized scanning and hacking activities, marking them as criminal offenses .

Real-world scenarios differentiate legal and illegal port scanning based on consent and intent. Legal port scanning is executed with permission as part of security audits or testing by certified professionals, while illegal scanning is performed without authorization, often with malicious intent to exploit vulnerabilities. Engaging in unauthorized scanning can lead to significant legal repercussions, including fines, reputational damage, and potential imprisonment under laws like the IT Act 66C/66D in India. Unauthorized scanning is considered an initial step in many cybercrimes, increasing the severity of its consequences .

Nmap's scripting capabilities, through the Nmap Scripting Engine (NSE), allow users to write and use scripts to automate complex network reconnaissance and vulnerability detection tasks. These scripts can detect vulnerabilities by checking for known CVEs, misconfigurations, or weak services. Practical examples include checking web servers with http-vuln-cve2017-5638 for Apache Struts vulnerabilities or using scripts such as smb-vuln-ms17-010 for detecting the presence of the SMBv1 protocol that was exploited by WannaCry ransomware .

The ethical considerations in port scanning revolve around respecting privacy, obtaining permission, and adhering to legal regulations. Port scanning, when used without consent, can be considered invasive and potentially harmful. Ethical use involves activities such as auditing your own networks, performing security assessments with explicit permission, or participating in controlled testing environments like labs or cyber ranges. Unethical use includes scanning public or private networks without authorization, exploiting vulnerabilities discovered through scans for malicious purposes, and violating legal frameworks such as the IT Act 66C/66D in India .

TCP SYN scan, also known as stealth scanning, sends SYN packets to initiate a TCP handshake but does not complete it, thus avoiding full session establishment. It's faster, consumes fewer resources, and usually requires root access . In contrast, TCP connect scan completes the full TCP handshake using the operating system’s network stack. It does not require special privileges, making it suitable if SYN scanning is not an option. The TCP connect scan is less stealthy as it logs full connections on the system being scanned .

In Nmap output, port states play a critical role in interpreting network security posture. Open ports indicate active services that could be susceptible to exploitation or connection, requiring immediate security evaluation. Closed ports suggest no active services but imply the port is reachable for connection attempts, possibly facilitating network mapping. Filtered ports are blocked by firewalls, indicating defensive measures but also suggesting potential evasion needs assessment. Additionally, Unfiltered ports, not blocked but with no indicative service, can signal obfuscation or signify potential attack vectors .

You might also like