Continuing with another box on TryHackMe, as the name suggests this time it is Nmap. In my last writeup ( Vulnversity), there was a part where nmap was used but it had a brief role over there. With this room ( Nmap) on THM we can develop our nmap skill further.
What is nmap?
As per Wikipedia ( https://en.wikipedia.org/wiki/Nmap), it a free open-source network scanner which can be used to discover hosts and services on a computer network by sending packets and analyzing responses. But once we start using nmap to it’s fullest, we can see that it can be used for many more things like OS detection, encryptions being used, testing scripts and many more things. Basically, it is one of the most used tools to perfrom reconnaissance on any given target/s.
So, let’s begin with the room now!
[Task 1] Deploy
We need to deploy the machine in order to gain access to it and nothing more is required in this task.
[Task 2] Quiz
In this task, there are a number of questions that arranged in a way that we can get a better grip on the mostly used nmap switches. Remember for any help
man nmap is always there.
As this room is pretty straightforward and there is not much to discuss, we can look into each switch's meaning at a somewhat detailed level.
- Accessing the Help Menu:
nmap -h, we can see all the various switches and their brief description. This can come in handy when we don’t feel like going through the manual and just want to check the switch that we want.
2. Stealth Scan:
nmap -sS <target_ip>
- It is the default and most popular type of scan. As the name suggests it can perform the scan in a stealth mode as it never opens a full TCP connection.
3. UDP Scan:
nmap -sU <target_ip>
- With this switch, we can perform a scan on the target machine’s UDP ports. This scan works by simply sending a UDP packet to every port on the target machine and analyzing the response.
4. Operating System Detection:
nmap -O <target_ip>
- With this switch, we can directly detect the OS that the target machine is running. Sometimes, nmap is not able to detect the exact OS but it might provide some suspected OSs that might be running on the target.
5. Service Version Detection:
nmap -sV <target_ip>
- With this switch, we can detect the version of the service running on the open ports. Also, with the help of this information, we can differentiate between truly open ports and filtered ports.
6. Being Talky (Verbose):
nmap -v <target_ip>
- Sometimes we want to know what is going on in the background of the running scan and in such cases, the verbose switch turns out to be really helpful.
7. Very Verbose:
nmap -vv <target_ip>
- This switch provides even greater verbosity and much more detailed insights into the processes running in the background of a scan.
8. Saving Output in XML File:
nmap -oX <target_ip>
- When performing the scan it can be handy to save the output of the scan so that it can be used in the future to check some major or minor details of the scan.
9. Aggressive Scan:
nmap -A <target_ip>
- When want in-depth details of a scan we can use this switch as it is capable of performing OS detection, version detection, script scanning and traceroute all together.
10. Max Scan Speed:
nmap -T<0–5> <target_ip>
- We can adjust the speed of the scan using the speed template. These range from 0 to 5 with 0 T4 being the slowest and T5 being the fastest. One thing to keep in mind here is that faster the scan, more are the chances that we can miss on some details in the scan.
11. Specific Port:
nmap -p<single port number or range> <target_ip>
- With this switch, we can perform scan on a single port like
-p80or over a range of ports like
12. Scanning All Ports:
nmap -p- <target_ip>
- While running a scan to detect all the open ports, we need to perform a check on all the ports. And in such a case we can use the switch `-p-` to run the scan over all the ports.
13. Script Scan:
nmap --script <scrip_name> <target_ip>
- Nmap has a large variety of scripts that can check for various vulnerabilities and perform various detections.
14. Running Vulnerability Scripts:
nmap --script vuln <target_ip>
- There are many categories of scripts in nmap that are segregated in various categories like auth, broadcast, exploit, fuzzer, vuln and many others.
15. Scan Without Ping:
nmap -Pn <target_ip>
- With this switch, nmap skips the discovery stage which is used to determine active machines for heavier scanning. When this switch is specified, nmap is forced to perform a scan against every target IP address specified.
[Task 3] Nmap Scanning
This section consists of various tasks that are needed to be performed on the actual deployed machine. I’ve explained the switches that are used for each task:
Output for questions 1, 2 and 3. As it seems that the results for all these three questions can be obtained from only one search
tester@kali:~$ sudo nmap -sS 10.10.103.104 I've provided it before answering them.
tester@kali:~$ sudo nmap -sS 10.10.103.104
Nmap scan report for 10.10.103.104
Host is up (0.17s latency).
Not shown: 997 closed ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
8090/tcp filtered opsmessagingNmap done: 1 IP address (1 host up) scanned in 1128.53 seconds
- Syn Scan
- As explained above Syn Scan can be performed with
2. Open Ports
- On running the previous scan, we get a list of ports from which we can determine the number of open ports.
3. Communication Protocol
- From the previous scan result itself, we can determine the protocol as it is provided right beside the port number.
For the next 3 questions 4, 5 and 6 as well, only one search would also work and the output of that search is provided below:
tester@kali:~$ sudo nmap -A --script vuln 10.10.103.104
[sudo] password for tester:
Starting Nmap 7.80 ( https://nmap.org ) at 2020-07-14 01:14 IST
Nmap scan report for 10.10.103.104
Host is up (0.16s latency).
Not shown: 998 closed ports
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 6.6.1p1 Ubuntu 2ubuntu2.10 (Ubuntu Linux; protocol 2.0)
|_clamav-exec: ERROR: Script execution failed (use -d to debug)
80/tcp open http Apache httpd 2.4.7 ((Ubuntu))
|_clamav-exec: ERROR: Script execution failed (use -d to debug)
| httponly flag not set
|_ httponly flag not set
|_http-csrf: Couldn't find any CSRF vulnerabilities.
|_http-dombased-xss: Couldn't find any DOM based XSS.
| /login.php: Possible admin folder
| /robots.txt: Robots file
| /config/: Potentially interesting directory w/ listing on 'apache/2.4.7 (ubuntu)'
| /docs/: Potentially interesting directory w/ listing on 'apache/2.4.7 (ubuntu)'
|_ /external/: Potentially interesting directory w/ listing on 'apache/2.4.7 (ubuntu)'
|_http-server-header: Apache/2.4.7 (Ubuntu)
| Slowloris DOS attack
| State: LIKELY VULNERABLE
| IDs: CVE:CVE-2007-6750
| Slowloris tries to keep many connections to the target web server open and hold
| them open as long as possible. It accomplishes this by opening connections to
| the target web server and sending a partial request. By doing so, it starves
| the http server's resources causing Denial Of Service.
| Disclosure date: 2009-09-17
|_http-stored-xss: Couldn't find any stored XSS vulnerabilities.
| CVE-2017-7679 7.5 https://vulners.com/cve/CVE-2017-7679
| CVE-2018-1312 6.8 https://vulners.com/cve/CVE-2018-1312
| CVE-2017-15715 6.8 https://vulners.com/cve/CVE-2017-15715
| CVE-2014-0226 6.8 https://vulners.com/cve/CVE-2014-0226
| CVE-2017-9788 6.4 https://vulners.com/cve/CVE-2017-9788
| CVE-2019-0217 6.0 https://vulners.com/cve/CVE-2019-0217
| CVE-2020-1927 5.8 https://vulners.com/cve/CVE-2020-1927
| CVE-2019-10098 5.8 https://vulners.com/cve/CVE-2019-10098
| CVE-2020-1934 5.0 https://vulners.com/cve/CVE-2020-1934
| CVE-2019-0220 5.0 https://vulners.com/cve/CVE-2019-0220
| CVE-2018-17199 5.0 https://vulners.com/cve/CVE-2018-17199
| CVE-2017-9798 5.0 https://vulners.com/cve/CVE-2017-9798
| CVE-2017-15710 5.0 https://vulners.com/cve/CVE-2017-15710
| CVE-2016-8743 5.0 https://vulners.com/cve/CVE-2016-8743
| CVE-2016-2161 5.0 https://vulners.com/cve/CVE-2016-2161
| CVE-2016-0736 5.0 https://vulners.com/cve/CVE-2016-0736
| CVE-2014-3523 5.0 https://vulners.com/cve/CVE-2014-3523
| CVE-2014-0231 5.0 https://vulners.com/cve/CVE-2014-0231
| CVE-2019-10092 4.3 https://vulners.com/cve/CVE-2019-10092
| CVE-2016-4975 4.3 https://vulners.com/cve/CVE-2016-4975
| CVE-2015-3185 4.3 https://vulners.com/cve/CVE-2015-3185
| CVE-2014-8109 4.3 https://vulners.com/cve/CVE-2014-8109
| CVE-2014-0118 4.3 https://vulners.com/cve/CVE-2014-0118
| CVE-2014-0117 4.3 https://vulners.com/cve/CVE-2014-0117
| CVE-2018-1283 3.5 https://vulners.com/cve/CVE-2018-1283
|_ CVE-2016-8612 3.3 https://vulners.com/cve/CVE-2016-8612
No exact OS matches for host (If you know what OS is running on it, see https://nmap.org/submit/ ).
OS:=S)Network Distance: 2 hops
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernelTRACEROUTE (using port 80/tcp)
HOP RTT ADDRESS
1 161.35 ms 10.8.0.1
2 161.12 ms 10.10.103.104OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 379.87 seconds
4. Service Version Detection
- Service detection can be performed using the
-sVswitch but we also know that
-Asearch can perform multiple detections including service version detection and the output to that is provided above. From the details related to services running on various ports at the beginning of the output, we can see the version of service running on port 22.
5. Find the Flag Not Set
- The output provided above contains the results of an aggressive
-Ascan and from that, we can easily see under the details for port 80 that there is the only flag that is not set.
6. Susceptible DoS Attack
- Under the details for port 80 itself, we can see that nmap has performed some script tests and from that, we can determine the DoS attack to which the machine is susceptible.
With this, we can conclude the Nmap room. This room introduced us with several different switches that we can use with nmap to tweak our scans.
This was just my second writeup based on TryHackMe room. I am uploading all my writeups on GitHub which can be accessed at