TryHackMe : Nmap Room

Nmap Room writeup

  • Name: Nmap
  • Description: An in depth look at scanning with Nmap, a powerful network scanning tool.
  • Room: tryhackme.com

Task 2: Introduction

What networking constructs are used to direct traffic to the right application on a server?

Ports

How many of these are available on any network-enabled computer?

65535

[Research] How many of these are considered “well-known”? (These are the “standard” numbers mentioned in the task)

1024

Task 3: Nmap Switches

What is the first switch listed in the help menu for a ‘Syn Scan’ (more on this later!)?

-sS

Which switch would you use for a “UDP scan”?

-sU

If you wanted to detect which operating system the target is running on, which switch would you use?

-O

Nmap provides a switch to detect the version of the services running on the target. What is this switch?

-sV

The default output provided by nmap often does not provide enough information for a pentester. How would you increase the verbosity?

-v

Verbosity level one is good, but verbosity level two is better! How would you set the verbosity level to two?
(Note: it’s highly advisable to always use at least this option)

-vv

We should always save the output of our scans — this means that we only need to run the scan once (reducing network traffic and thus chance of detection), and gives us a reference to use when writing reports for clients.

What switch would you use to save the nmap results in three major formats?

-oA

What switch would you use to save the nmap results in a “normal” format?

-oN

A very useful output format: how would you save results in a “grepable” format?

-oG

Sometimes the results we’re getting just aren’t enough. If we don’t care about how loud we are, we can enable “aggressive” mode. This is a shorthand switch that activates service detection, operating system detection, a traceroute and common script scanning.

How would you activate this setting?

-A

Nmap offers five levels of “timing” template. These are essentially used to increase the speed your scan runs at. Be careful though: higher speeds are noisier, and can incur errors!

How would you set the timing template to level 5?

-T5

We can also choose which port(s) to scan.

How would you tell nmap to only scan port 80?

-p 80

How would you tell nmap to scan ports 1000–1500?

-p 1000–1500

A very useful option that should not be ignored:

How would you tell nmap to scan all ports?

-p-

How would you activate a script from the nmap scripting library (lots more on this later!)?

— script

How would you activate all of the scripts in the “vuln” category?

— script=vuln

“Scan Types”

Task 5: TCP Connect Scans

Which RFC defines the appropriate behaviour for the TCP protocol?

RFC 793

If a port is closed, which flag should the server send back to indicate this?

RST (In other words, if Nmap sends a TCP request with the SYN flag set to a closed port, “the target server will respond with a TCP packet with the RST (Reset) flag set. By this response, Nmap can establish that the port is closed”)

Task 6: SYN Scans

There are two other names for a SYN scan, what are they?

Half-Open, Stealth (SYN scans are sometimes referred to as “Half-openscans, or Stealth scans)

Can Nmap use a SYN scan without Sudo permissions (Y/N)?

N (“This is because SYN scans require the ability to create raw packets (as opposed to the full TCP handshake), which is a privilege only the root user has by default”)

Task 7: UDP Scans

If a UDP port doesn’t respond to an Nmap scan, what will it be marked as?

open|filtered (“When a packet is sent to an open UDP port, there should be no response. When this happens, Nmap refers to the port as being open|filtered”)

When a UDP port is closed, by convention the target should send back a “port unreachable” message. Which protocol would it use to do so?

ICMP (“When a packet is sent to a closed UDP port, the target should respond with an ICMP (ping) packet containing a message that the port is unreachable. This clearly identifies closed ports, which Nmap marks as such and moves on”)

Task 8: NULL, FIN and Xmas

Which of the three shown scan types uses the URG flag?

xmas (“It’s referred to as an xmas scan as the flags that it sets (PSH, URG and FIN)”)

Why are NULL, FIN and Xmas scans generally used?

Firewall Evasion (“That said, the goal here is, of course, firewall evasion”)

Which common OS may respond to a NULL, FIN or Xmas scan with a RST for every port?

Microsoft Windows (“In particular Microsoft Windows (and a lot of Cisco network devices) are known to respond with a RST”)

Task 9: ICMP Network Scanning

How would you perform a ping sweep on the 172.16.x.x network (Netmask: 255.255.0.0) using Nmap? (CIDR notation)

nmap -sn 172.16.0.0/16 (“Classless Inter-Domain Routing is a method for allocating IP addresses and for IP routing”)

“NSE Scripts”

Task 10: Overview

What language are NSE scripts written in?

Lua (“NSE Scripts are written in the Lua programming language)

Which category of scripts would be a very bad idea to run in a production environment?

intrusive (“intrusive:- Not safe: likely to affect the target”)

Task 11: Working with the NSE

What optional argument can the ftp-anon.nse script take?

https://nmap.org/nsedoc/scripts/ftp-anon.html

maxlist

Task 12: Searching for Scripts

Search for “smb” scripts in the /usr/share/nmap/scripts/ directory using either of the demonstrated methods.
What is the filename of the script which determines the underlying OS of the SMB server?

smb-os-discovery.nse

Read through this script. What does it depend on?

cat /usr/share/nmap/scripts/smb-os-discovery.nse

smb-brute

Firewall Evasion

Which simple (and frequently relied upon) protocol is often blocked, requiring the use of the -Pn switch?

ICMP (“ This means that Nmap will always treat the target host(s) as being alive, effectively bypassing the ICMP block”)

[Research] Which Nmap switch allows you to append an arbitrary length of random data to the end of packets?

https://nmap.org/book/man-bypass-firewalls-ids.html

— data-length

Task 14: Practical

Does the target (MACHINE_IP)respond to ICMP (ping) requests (Y/N)?

sudo nmap -PE 10.10.191.36

N

Perform an Xmas scan on the first 999 ports of the target — how many ports are shown to be open or filtered?

sudo nmap -p 1–999 -sX 10.10.191.36 -Pn -vv

999

Perform a TCP SYN scan on the first 5000 ports of the target — how many ports are shown to be open?

sudo nmap -p1–5000 -sS 10.10.191.36 -Pn -vv

5

Deploy the ftp-anon script against the box. Can Nmap login successfully to the FTP server on port 21? (Y/N)

Y

thank you 🌏🔥

--

--

--

Computer student and interested in programming and security

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

VPN App: How We Fixed Other’s Mistakes and Launched the Project

Transaction & Transaction Processing : A brief description

Animations and the Anatomy of Keyframes

bouncing arrow animation from example code

Getting started with APIs in Python to Gather Data

Cover image for Using Python and APIs to Gather Data.

How to Create PostgreSQL Database on AWS

Product Owner’s Checklist for Product Backlog Refinement

The Go Pointer Magic

Batch Processing using MaxCompute

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Hassan Mohammadi

Hassan Mohammadi

Computer student and interested in programming and security

More from Medium

[EN] TryHackMe 25 Days of Cyber Security: Day 6 Walkthrough

XXE - TryHackMe Walkthrough

Kenobi TryHackMe Write-Up

TryHackMe: Internal