Nmap
Nmap
Nmap
Commands
Introducing the power of Nmap
Disclaimer
Dear readers,
This document is provided by VIEH Group for educational purposes
only. While we strive for accuracy and reliability, we make no
warranties or representations regarding the completeness, accuracy, or
usefulness of the information presented herein. Any reliance you place
on this document is at your own risk. VIEH Group shall not be liable
for any damages arising from the use of or reliance on this document.
We acknowledge and appreciate the contribution of the source person.
also,
This document is not created by a professional content writer so any
mistake and error is a part of great design
Scan QR:
Functionality
Nmap commands provide a wide range of functionality for network scanning and security assessment. Some of the
key features include:
•Port Scanning: Nmap can scan for open ports on a target host, helping to identify potential vulnerabilities.
•OS Detection: Nmap can determine the operating system running on a target host by analyzing network packets.
•Version Detection: Nmap can identify the versions of services running on a target host, helping to identify outdated
or vulnerable software.
•Scripting: Nmap provides a scripting engine that allows users to write custom scripts for advanced scanning and
automation.
In the following sections, we will explore some of the most commonly used Nmap commands and their functionalities.
Nmap Brute Force Attacks
Best Practices
1. Use Nmap's built-in brute force options, such as -b and -t, to avoid manual input and reduce the risk of errors.
2. Avoid using brute force attacks on systems that are not authorized to access, as it can be illegal and unethical.
3. Use a strong password and enable two-factor authentication to prevent unauthorized access to systems.
4. Keep your software and systems up-to-date with the latest security patches and updates.
Command
Usage
•Use the-sn flag to specify a ping scan.
•Replace [target] with the IP address or hostname of the target host.
Example
This will perform a ping scan on the host with the IP address 192.168.0.1 to check if it is online.
Detecting malware infections on remote hosts using Nmap
Nmap is able to detect malware and backdoors by running extensive tests on a few popular OS services like on Identd,
Proftpd, Vsftpd, IRC, SMB, and SMTP. It also has a module to check for popular malware signs inside remote servers
and integrates Google’s Safe Browsing and VirusTotal databases as well.
A common malware scan can be performed by using:
Output example:
80/tcp open http|_http-google-malware.nse: Host is known for distributing malware.
Nmap for OS and Service Detection
Best Practices
1. Use the -A option to scan for all available ports and services.
2. Use the -sS option to scan for services only, and avoid scanning for OS detection.
3. Use the -p option to specify the port number, and avoid using the default port number (1-65535).
4. Use the -T option to scan for open ports, and avoid using the -t option to scan for closed ports.
5. Use the -D option to detect the operating system and service, but be aware that false positives can occur.
6. Use the -v option to display the scan results in a detailed format.
7. Use the -o option to save the scan results to a file, and avoid using the -o option to save the scan results to a file with
a .nmap extension.
8. Use the -i option to specify the input file, and avoid using the -i option to specify the output file.
Example
To scan for open ports and services on a target machine, use the following command:
•nmap -sS -p 80 -o output.nmap
This command will scan for open ports on port 80, and save the scan results to a file named output.nmap.
TCP Connect Scan
Overview
TCP connect scan is used to determine if a specific port is open on a target host.
How it Works
•The scan sends a TCP SYN packet to the target host's specified port.
•If the target host responds with a SYN/ACK packet, it means the port is open.
•If the target host responds with a RST packet, it means the port is closed.
•If the target host does not respond, it means the port is filtered or blocked by a firewall.
Usage
•Use the -sT flag with the Nmap command to perform a TCP connect scan.
•Specify the target host and port number to scan.
Example
nmap -sT <target_host> -p <port_number>
SYN Scan
What isSYN Scan?
SYN scan is a type of port scanning technique used to determine if a specific port is open on a target host. It works by
sending SYN packets to the target host and analyzing the response.
Limitations
•SYN scan requires raw socket access, which may not be available on all systems.
•Some firewalls and intrusion detection systems (IDS) may detect and block SYN scan attempts.
UDP Scan
UDP scan is atype of network scanning technique that is used to determine if a specific port is open on a target host
using UDP packets. Unlike TCP scanning, which relies on a three-way handshake, UDP scanning does not establish
a connection with the target host. Instead, it sends UDP packets to the target port and analyzes the response to
determine if the port is open, closed, or filtered.
ACK Scan
The ACKscanisused to determine if a specific port is filtered or unfiltered on a target host.
How it Works
The ACK scan sends TCP ACK packets to a target host with a specific port number. The response received from the
target host can provide valuable information about the state of the port.
•If the target host responds with an RST packet, it means the port is unfiltered.
•If the target host responds with no packet or an ICMP unreachable message, it means the port is filtered.
Usage
The ACK scan can be used for various purposes, such as network troubleshooting, firewall testing, and vulnerability
assessment.
Example Command
$ nmap -sA <target>
Limitations
It's important to note that the ACK scan does not provide information about open or closed ports. It only determines
if a specific port is filtered or unfiltered.
Window Scan
Description
Window scan is used to determine if a specific port is open on a target host by analyzing the TCP window size.
How it works
•Sends a TCP SYN packet to the target port.
•If the port is open, the target will respond with a TCP SYN/ACK packet.
•If the port is closed, the target will respond with a TCP RST packet.
•If the port is filtered, the target will not respond.
Command
nmap -sW <target>
Example
nmap -sW 192.168.0.1
Maimon Scan
Description
Maimon scan is used to determine if a specific port is open on a target host by sending malformed packets.
Syntax
nmap -sM <target> -p <port>
Example
nmap -sM 192.168.0.1 -p 80
Xmas Scan
The Xmasscanisused to determine if a specific port is open on a target host by sending a combination of flags.
How it Works
During an Xmas scan, the Nmap tool sends TCP packets to the target host with the FIN, URG, and PUSH flags set. If
the target port is open, the host's response will differ depending on how it handles these packets. If the port is closed,
the host will typically respond with a TCP RST packet.
Usage
To perform an Xmas scan using Nmap, you can use the following command:
nmap -sX [target]
Replace [target] with the IP address or hostname of the target host.
Example
Here is an example of an Xmas scan command:
nmap -sX 192.168.0.1
This command will perform an Xmas scan on the host with the IP address 192.168.0.1.
Considerations
It's important to note that some firewalls and security systems may detect and block Xmas scans, so it's recommended
to use this scan method with caution and ensure that you have proper authorization before scanning any target hosts.
FIN Scan
Description
A FIN scan is used to determine if a specific port is open on a target host by sending FIN packets. FIN packets are
typically used to gracefully close a TCP connection. If a target port is closed, it should respond with a TCP RST packet.
However, if the port is open, it should ignore the FIN packet and not respond.
Description
A null scan is used to determine if a specific port is open on a target host by sending packets with no flags set.
How it works
A null scan takes advantage of the fact that some systems respond differently to different types of packets. When a null
packet is sent, a system that has a closed port will respond with an RST (reset) packet, indicating that the port is
closed. However, if the port is open, the system will not respond at all, indicating that the port is open.
Usage
To perform a null scan, use the following command:
Nmap Command
To perform an SNMP scan, use the following Nmap command:
nmap -sU -p 161 --script snmp-sysdescr,snmp-netstat,snmp-processes <target>
This command will scan for SNMP services on the target host and gather information such as system
description, network statistics, and running processes.
SMTP Scan
Nmap Command
Description
This command is used to scan for secure web servers on a target host. It checks for the supported SSL/TLS ciphers
and protocols and provides information about the server's certificate.
Usage
Replace <target> with the IP address or hostname of the target host.
Example
Output
The command will output a list of supported ciphers and protocols, as well as information about the server's
certificate.
Telnet Scan
Telnet scan is atype of network scan used to determine information about Telnet services and remote login on a
target host. It allows you to check if Telnet is enabled on a specific IP address or range of IP addresses, and gather
information about the Telnet service running on those hosts.
Usage
To perform an RPC scan, use the following command:
nmap -p 111 --script rpcinfo <target>
This command will scan port 111, which is the default port for RPC services, and use the 'rpcinfo' script to gather
information about the RPC services running on the target host.
Output
The output of an RPC scan will provide details about the RPC services found on the target host, including the program
ID, version, and protocol used.
Example
Starting Nmap 7.80 ( https://nmap.org ) at 2021-07-01 10:00 EDT
Nmap scan report for target.example.com (192.168.0.1)
Host is up (0.001s latency).
Jai Hind!