Home nmap Port Port Scans
Post
Cancel

nmap Port Port Scans

How to leverage Nmap for service and OS detection, use Nmap Scripting Engine (NSE), and save the results.

https://tryhackme.com/room/nmap04


Task 1 - Introduction

We will cover the following:

  • Detect versions of the running services (on all open ports)
  • Detect the OS based on any signs revealed by the target
  • Run Nmap’s traceroute
  • Run select Nmap scripts
  • Save the scan results in various formats

Task 2 - Service Detection

  • -sV to your Nmap command will collect and determine service and version information for the open ports.

Answer the questions below

Start the target machine for this task and launch the AttackBox. Run nmap -sV –version-light 10.10.101.238 via the AttackBox. What is the detected version for port 143? dovecot imapd

Which service did not have a version detected with –version-light? rpcbind


Task 3 - OS Detection and Traceroute

  • -O - Exampe nmap -sS -O 10.10.101.238 Nmap can decept the Operating System, based on behaviour and responses.
  • --traceroute If you want Nmap to find the routers betwen you and the target. For example nmap -sS --traceroute 10.10.101.238

Answer the questions below

Run nmap with -O option against 10.10.101.238. What OS did Nmap detect? linux


Task 4 - Nmap Scripting Engine (NSE)

Nmap default installation can easily contain close to 600 scripts. On my Kali Linux this is /usr/share/nmap/scripts we can run the default scripts with -sC which is equal to --script=default. We can choose different categories from the table below with this flag. Or even specific scripts with --script "SCRIPT-NAME"

Script CategoryDescription
authAuthentication related scripts
broadcastDiscover hosts by sending broadcast messages
brutePerforms brute-force password auditing against logins
defaultDefault scripts, same as -sC
discoveryRetrieve accessible information, such as database tables and DNS names
dosDetects servers vulnerable to Denial of Service (DoS)
exploitAttempts to exploit various vulnerable services
externalChecks using a third-party service, such as Geoplugin and Virustotal
fuzzerLaunch fuzzing attacks
intrusiveIntrusive scripts such as brute-force attacks and exploitation
malwareScans for backdoors
safeSafe scripts that won’t crash the target
versionRetrieve service versions
vulnChecks for vulnerabilities or exploit vulnerable services

Answer the questions below

Knowing that Nmap scripts are saved in /usr/share/nmap/scripts on the AttackBox. What does the script http-robots.txt check for? disallowed entries

Can you figure out the name for the script that checks for the remote code execution vulnerability MS15-034 (CVE2015-2015-1635)? http-vuln-cve2015-1635

Launch the AttackBox if you haven’t already. After you ensure you have terminated the VM from Task 2, start the target machine for this task. On the AttackBox, run Nmap with the default scripts -sC against 10.10.101.238. You will notice that there is a service listening on port 53. What is its full version value? 9.9.5-9+deb8u19-Debian

Based on its description, the script ssh2-enum-algos “reports the number of algorithms (for encryption, compression, etc.) that the target SSH2 server offers.” What is the name of the key exchange algorithms (kex_algorithms) that relies upon “sha1” and is supported by 10.10.101.238? diffie-hellman-group14-sha1


Task 5 - Saving the Output

The three main formats are:

  • Normal -oN FILENAME
  • Grepable (grepable) -oG FILENAME
  • XML -oX FILENAME

Answer the questions below

Terminate the target machine of the previous task and start the target machine for this task. On the AttackBox terminal, issue the command scp pentester@MACHINE_IP:/home/pentester/* . to download the Nmap reports in normal and grepable formats from the target virtual machine.

Note that the username pentester has the password THM17577

Check the attached Nmap logs. How many systems are listening on the HTTPS port? cat scan_172_17_network.gnmap | grep https there are 3

What is the IP address of the system listening on port 8089? cat scan_172_17_network.gnmap | grep 8089 172.17.20.147


Task 6 - Summary

Familiarized ourselves with Nmap. Here is a list of options/flags we learned to use.

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

This post is licensed under CC BY 4.0 by the author.