Box: Intermediate Nmap · Platform: TryHackMe · Category: Networking / Recon · Difficulty: Easy
1. Introduction / TL;DR
Some challenges hide flags behind layers of obfuscation. This one hides them behind a sysadmin who, by their own admission, is forgetful.
Intermediate Nmap is a TryHackMe room that dares you to go beyond nmap -p 22,80 and actually scan the full port range of a target. The twist? A service running on port 31337 — yes, leet port — is broadcasting SSH credentials in plaintext to anyone who bothers to knock. Pair that with an SSH login and a quick cat, and the flag is yours.
This writeup is for anyone who wants to understand why each command works, not just copy-paste their way to a flag.
TL;DR:
- Full-range nmap scan reveals port 31337 broadcasting credentials.
- SSH into the box with those credentials.
- Read the flag from
/home/user/flag.txt.
2. Initial Recon
The challenge description gives us a deliberate nudge:
“This VM is listening on a high port, and if you connect to it it may give you some information you can use to connect to a lower port commonly used for remote access!”
“High port” and “remote access” are the two keywords here. Remote access almost certainly means SSH (port 22). A “high port” means something above 1024 — possibly well above. The only way to find it reliably is to scan all 65,535 TCP ports.
Why scan all ports?
By default, nmap only scans its top 1,000 most common ports. That’s a reasonable shortcut for broad assessments, but it means anything running on an uncommon port stays invisible. In CTFs and real-world pentests alike, operators often run services on non-standard ports deliberately — either for obscurity or because convention doesn’t apply to them.
The flags we need:
| Flag | Purpose |
|---|---|
-p- | Scan all 65,535 TCP ports (shorthand for -p 1-65535) |
-sV | Probe open ports to determine the service and version running |
--min-rate 5000 | Send at least 5,000 packets per second — dramatically speeds up a full scan |
| |
Results
| |
Three open ports:
- 22/tcp — Standard SSH. The intended login target.
- 2222/tcp — A second SSH instance (a red herring, as it turns out).
- 31337/tcp — Unknown service, labelled
Elite?by nmap.
Port 31337 deserves its own section.
3. Analysis — What Is Port 31337?
Port 31337 is not arbitrary. In hacker lore, 31337 is “leet” (leetspeak for “elite”), and it has been used by everything from Back Orifice malware to deliberate CTF jokes for decades. Seeing it in a challenge named Intermediate Nmap is a wink from the challenge author.
Nmap couldn’t identify the service by protocol alone, so it fell back to version detection probing — sending a series of payloads (NULL, GET /, generic lines, etc.) and capturing whatever the service responded with. That response was embedded directly in the scan output under the SF-Port31337-TCP fingerprint block:
| |
Decoding the escaped bytes (\x20 = space, \n = newline):
| |
Someone left a sticky note as a network service. The “forget-me-not” port is handing out credentials to anyone who runs -sV.
You can also see this directly by connecting with netcat:
| |
| |
The service sends its message and closes the connection — no handshake, no auth, no fanfare.
4. Vulnerability Identification
This challenge demonstrates two real-world issues that appear in actual penetration tests:
4a. Incomplete Port Coverage
Scanning only the top 1,000 ports (the nmap default) would have completely missed port 31337. In production environments, developers routinely run administrative services, debug endpoints, or legacy applications on non-standard ports believing obscurity offers protection. It does not — but it does defeat lazy scanners.
Lesson: Always run a full -p- scan before concluding there’s nothing interesting on a host.
4b. Credentials Transmitted / Stored in Plaintext
The service on port 31337 is, in effect, a plaintext credential store that announces itself over the network. This is an egregious example of a pattern that shows up in more subtle forms all the time:
- Debug endpoints that expose environment variables (including
DATABASE_URL,SECRET_KEY). - Banner messages that include version strings attackers can cross-reference with CVE databases.
- Configuration files served over HTTP with no authentication.
The credentials here are: username ubuntu, password Dafdas!!/str0ng. These will be used to authenticate over SSH.
5. Exploitation Strategy
The Core Technique: Service Version Detection (-sV)
nmap -sV does something most people don’t think about: when it encounters a port it can’t identify from the SYN/ACK alone, it actively probes it. It sends payloads from its probe database (nmap-service-probes) — things like an empty byte sequence (NULL), an HTTP GET /, and protocol-specific openers — and records what comes back.
Those responses are used to match against known service fingerprints. When no match is found, nmap logs the raw response in the output (the SF-Port... block). That raw response is exactly what the service is sending — and in this case, it’s credentials.
This means -sV is not just a passive label-applier. It’s an active interrogation tool, and its output can contain actual data the service returned during the probe exchange.
Why This Applies Here
The challenge was designed to teach precisely this: a service running on an unusual port will be invisible without a full scan, and its nature won’t be clear without version detection. The two flags -p- and -sV together are the complete solution to the recon phase.
Once credentials are obtained, SSH is the “lower port commonly used for remote access” the challenge description references. Standard password authentication completes the login.
6. Building the Exploit — Step by Step
Step 1: Full Port Scan with Service Detection
| |
Why: -p- ensures we don’t miss port 31337 by stopping at the default 1,000. -sV causes nmap to probe port 31337 and capture its credential banner. --min-rate 5000 keeps the scan from taking 20+ minutes on a full port range.
Output (relevant section):
| |
Step 2: Confirm the Credential Banner
| |
Why: Reading directly from the port confirms what nmap captured and rules out any fingerprint parsing artefact. The service responds immediately and closes.
Output:
| |
Credentials extracted:
- Username:
ubuntu - Password:
Dafdas!!/str0ng
Step 3: SSH Login
| |
Enter the password Dafdas!!/str0ng when prompted.
Why port 22, not 2222? Both are SSH. Port 22 is the standard. The challenge description says “lower port” — and the flag lives in /home/user/, a path not owned by ubuntu. Both ports likely accept the same credentials, but we try the canonical port first.
Shell obtained:
| |
Step 4: Locate and Read the Flag
| |
| |
| |
| |
Complete Solve Script
The script below automates the entire process — from scan to flag — and can be run directly on any machine with Python 3, python-nmap, and paramiko installed.
| |
Sample run:
| |
7. Conclusion / Flag
| |
This room teaches a habit that separates thorough pentesters from lazy ones: scan everything. Nmap’s default 1,000-port scan is a convenience shortcut, not a guarantee of completeness. Port 31337 — right there in the name, screaming “elite” to anyone who recognises it — was invisible until we added -p-.
The second lesson is subtler: -sV is an active interrogation. It doesn’t just label services; it sends probes and captures responses. Those responses can contain banner messages, version strings, or — as demonstrated here — credentials left in plaintext by a forgetful sysadmin.
Key takeaways:
- Always run
-p-before concluding a host has nothing interesting. -sVcaptures raw service responses; read the full output, not just the port/service columns.- Port numbers are not security controls. Obscurity is not defence.
- Port 31337 will always be suspicious. Always check port 31337.
Written as part of a TryHackMe room walkthrough. Target was a dedicated lab VM with no real users or data.