THM – NMAP Documentation and Commands – Part 13

Last Updated on January 25, 2022 by aghanim

This is my notes from the Junior Pentesting course at TryHackMe. This course takes you through the basics and some advanced topics regarding penetration testing.


NMAP Live Host Discovery

Scan TypeExample Command
ARP Scansudo nmap -PR -sn MACHINE_IP/24
ICMP Echo Scansudo nmap -PE -sn MACHINE_IP/24
ICMP Timestamp Scansudo nmap -PP -sn MACHINE_IP/24
ICMP Address Mask Scansudo nmap -PM -sn MACHINE_IP/24
TCP SYN Ping Scansudo nmap -PS22,80,443 -sn MACHINE_IP/30
TCP ACK Ping Scansudo nmap -PA22,80,443 -sn MACHINE_IP/30
UDP Ping Scansudo nmap -PU53,161,162 -sn MACHINE_IP/30

Remember to add -sn if you are only interested in host discovery without port-scanning. Omitting -sn will let Nmap default to port-scanning the live hosts.

OptionPurpose
-nno DNS lookup
-Rreverse-DNS lookup for all hosts
-snhost discovery only

NMAP Basic Port Scans

  1. Open: indicates that a service is listening on the specified port.
  2. Closed: indicates that no service is listening on the specified port, although the port is accessible. By accessible, we mean that it is reachable and is not blocked by a firewall or other security appliances/programs.
  3. Filtered: means that Nmap cannot determine if the port is open or closed because the port is not accessible. This state is usually due to a firewall preventing Nmap from reaching that port. Nmap’s packets may be blocked from reaching the port; alternatively, the responses are blocked from reaching Nmap’s host.
  4. Unfiltered: means that Nmap cannot determine if the port is open or closed, although the port is accessible. This state is encountered when using an ACK scan -sA.
  5. Open|Filtered: This means that Nmap cannot determine whether the port is open or filtered.
  6. Closed|Filtered: This means that Nmap cannot decide whether a port is closed or filtered.

TCP Flags

  1. URG: Urgent flag indicates that the urgent pointer filed is significant. The urgent pointer indicates that the incoming data is urgent, and that a TCP segment with the URG flag set is processed immediately without consideration of having to wait on previously sent TCP segments.
  2. ACK: Acknowledgement flag indicates that the acknowledgement number is significant. It is used to acknowledge the receipt of a TCP segment.
  3. PSH: Push flag asking TCP to pass the data to the application promptly.
  4. RST: Reset flag is used to reset the connection. Another device, such as a firewall, might send it to tear a TCP connection. This flag is also used when data is sent to a host and there is no service on the receiving end to answer.
  5. SYN: Synchronize flag is used to initiate a TCP 3-way handshake and synchronize sequence numbers with the other host. The sequence number should be set randomly during TCP connection establishment.
  6. FIN: The sender has no more data to send.

Timings

TimingsDescription
T0paranoid (0)
T1sneaky (1)
T2polite (2)
T3normal (3)
T4aggressive (4)
T5insane (5)

Summary

Port Scan TypeExample Command
TCP Connect Scannmap -sT MACHINE_IP
TCP SYN Scansudo nmap -sS MACHINE_IP
UDP Scansudo nmap -sU MACHINE_IP

These scan types should get you started discovering running TCP and UDP services on a target host.

OptionPurpose
-p-all ports
-p1-1023scan ports 1 to 1023
-F100 most common ports
-rscan ports in consecutive order
-T<0-5>-T0 being the slowest and T5 the fastest
–max-rate 50rate <= 50 packets/sec
–min-rate 15rate >= 15 packets/sec
–min-parallelism 100at least 100 probes in parallel

NMAP Advanced Port Scans

Port Scan TypeExample Command
TCP Null Scansudo nmap -sN MACHINE_IP
TCP FIN Scansudo nmap -sF MACHINE_IP
TCP Xmas Scansudo nmap -sX MACHINE_IP
TCP Maimon Scansudo nmap -sM MACHINE_IP
TCP ACK Scansudo nmap -sA MACHINE_IP
TCP Window Scansudo nmap -sW MACHINE_IP
Custom TCP Scansudo nmap --scanflags URGACKPSHRSTSYNFIN MACHINE_IP
Spoofed Source IPsudo nmap -S SPOOFED_IP MACHINE_IP
Spoofed MAC Address--spoof-mac SPOOFED_MAC
Decoy Scannmap -D DECOY_IP,ME MACHINE_IP
Idle (Zombie) Scansudo nmap -sI ZOMBIE_IP MACHINE_IP
Fragment IP data into 8 bytes-f
Fragment IP data into 16 bytes-ff
OptionPurpose
--source-port PORT_NUMspecify source port number
--data-length NUMappend random data to reach given length

These scan types rely on setting TCP flags in unexpected ways to prompt ports for a reply. Null, FIN, and Xmas scan provoke a response from closed ports, while Maimon, ACK, and Window scans provoke a response from open and closed ports.

OptionPurpose
–reasonexplains how Nmap made its conclusion
-vverbose
-vvvery verbose
-ddebugging
-ddmore details for debugging

NMAP Post Port Scans

OptionMeaning
-sVdetermine service/version info on open ports
-sV –version-lighttry the most likely probes (2)
-sV –version-alltry all available probes (9)
-Odetect OS
–tracerouterun traceroute to target
–script=SCRIPTSNmap scripts to run
-sC or –script=defaultrun default scripts
-Aequivalent to -sV -O -sC --traceroute
-oNsave output in normal format
-oGsave output in grepable format
-oXsave output in XML format
-oAsave output in normal, XML and Grepable formats

Similar Posts

  • THM – Content Discovery – Part 4

    Last Updated on January 25, 2022 by aghanim This is my notes from the Junior Pentesting course at TryHackMe. This course takes you through the basics and some advanced topics regarding penetration testing. Table Of ContentsWhat is content Discovery?Manual Discovery – Robots.txtRobots.txtManual Discovery – FaviconFaviconManual Discovery – Sitemap.xmlSitemap.xmlManual Discovery – HTTP HeadersHTTP HeadersManual Discovery –…

  • THM – Intro to pentesting – Fundamentals – Part 1

    Last Updated on January 25, 2022 by aghanim This is my notes from the Junior Pentesting course at TryHackMe. This course takes you through the basics and some advanced topics regarding penetration testing. Table Of ContentsPenetration testing ethicsRules of Engagement (ROE)Penetration Testing MethodoligiesOSSTMMOWASPNIST Cybersecurity Framework 1.1NCSC CAFBlack box, White box, Grey box penetration testingBlack-Box testingGrey-box…

  • THM – John The Ripper – Part 15

    Last Updated on January 25, 2022 by aghanim This is a continued series where I document my path through different tryhackme courses. I recommend everyone that wants to learn cyber security to subscribe to tryhackme.com and take the courses there. Table Of ContentsCracking Basic HashesCracking Windows authentication HashesCracking /etc/shadow HashesSingle Cracking ModeCustom RulesCracking Password Protected…

  • Handbook V – Maldev

    Last Updated on October 16, 2025 by aghanim Work in Progress Table Of ContentsCoursesSourcesx86 & x64 Assembler and DisassemblerCallback function listExample: Using  ​CertEnumSystemStore​ Convert raw shellcode to raw binary formatEDR TelematryEDR Telematry v2Entropy reductionHijackLibsJoesandbox – Malware AnalysisMalapi.ioNo-defenderNtDoc – The native NT API online documentationParasite-invokeReverse engineering of everything MicrosoftVergilius projectUnprotect.itEvasion techniquesWindows Icons Courses SEKTOR7 Institute https://maldevacademy.com/ EvasionEDR…

  • THM – Web Fundamentals – Part 10

    Last Updated on January 25, 2022 by aghanim Table Of ContentsHow Do We Load Websites?  More HTTPS – Verbs and request formats Cookies  How Do We Load Websites?   Finding the server  A DNS request is made initially. DNS is like a giant phone book that takes a URL and turns it into an IP. You dont have to remember the IP of websites.   The IP address uniquely identifies each internet connected devices, like a web servere or your computer. They are formed of 4 groups of number,…

  • THM – OWASP Top 10 – Part 12

    Last Updated on January 25, 2022 by aghanim Table Of ContentsIntro [Severity 1] Injection[Severity 1] OS Command Injection[Severity 1] Command Injection Practical [Severity 2] Broken Authentication[Severity 2] Broken Authentication Practical [Severity 3] Sensitive Data exposure (Introduction) [Severity 3] Sensitive Data exposure (Supporting material 1)  [Severity 3] Sensitive Data exposure (Supporting material 2) [Severity 3] Sensitive Data exposure (Challenge)[Severity 4] XML External…