DEV Community

Victor
Victor

Posted on

Intermediate Nmap: Network Enumeration, Credential Discovery and SSH Access

1. Introduction

In this write-up, I will document my experience completing the Intermediate Nmap room on TryHackMe, focusing on network enumeration, service discovery, credential identification, and SSH access.

Unlike web application challenges, where I usually start by inspecting HTTP requests, identifying application technologies, or searching for web vulnerabilities, this challenge required a more traditional penetration-testing approach.

I started by scanning the target machine to identify exposed services and understand what information could be retrieved from them.

During the enumeration process, I discovered an unusual service running on port 31337/tcp. Although Nmap could not identify the service automatically, its fingerprint response contained an interesting message that eventually helped me identify credentials for accessing the target through SSH.

My approach involved the following steps:

  • Network reconnaissance using Nmap.
  • Identifying open ports and running services.
  • Investigating an unidentified service on port 31337.
  • Extracting useful information from service fingerprint data.
  • Testing SSH authentication on different ports.
  • Gaining access to the target machine.
  • Locating and reading the flag file.

The interesting part of this challenge was that a seemingly unusual service response contained information that could be used to progress further.


2. Initial Reconnaissance – Network Scanning

After starting the target machine on TryHackMe, I launched the AttackBox and began with a basic service enumeration scan.

I used the following command:

nmap -sV -sC 10.49.179.100
Enter fullscreen mode Exit fullscreen mode

Explanation:

  • -sV: Detect service versions running on open ports.
  • -sC: Execute Nmap's default NSE scripts.
  • 10.49.179.100: Target machine IP address.

The scan identified three open TCP ports:

Port State Service Version
22/tcp Open SSH OpenSSH 8.2p1
2222/tcp Open SSH OpenSSH 8.2p1
31337/tcp Open Unknown Unrecognized

The first two ports were running SSH services, while port 31337 returned data that Nmap could not associate with a recognized service.

This immediately caught my attention.

Rather than focusing only on the SSH services, I decided to investigate the unidentified service because it might contain additional information.


3. Investigating the Unusual Service – Port 31337

The most interesting finding from the initial scan was:

31337/tcp open  Elite?
Enter fullscreen mode Exit fullscreen mode

Nmap also displayed a section called fingerprint-strings.

This section contained several protocol probes and responses collected during service detection.

Among the returned data, I noticed an unusual message:

In case I forget - user:pass
Enter fullscreen mode Exit fullscreen mode

This was an important clue.

It suggested that the service response contained a username and password reminder.

Instead of treating port 31337 as an ordinary unknown service, I examined the returned fingerprint data more carefully.

The exposed message indicated that credentials might be available within the service response.

I noted the information for the next step and decided to investigate the SSH services.

  • 31337/tcp open
  • fingerprint-strings
  • In case I forget - user:pass
  • The credential area (keep the actual credentials redacted).

This screenshot is important because it demonstrates how service enumeration can reveal information beyond standard service names and version numbers.


4. SSH Authentication Testing

After identifying the credential clue, I moved on to testing the SSH services.

Since the Nmap scan identified two SSH ports, I initially decided to test port 2222.

4.1 Testing SSH on Port 2222

I executed:

ssh -p 2222 ubuntu@10.49.179.100
Enter fullscreen mode Exit fullscreen mode

The connection reached the SSH service, but authentication failed.

The terminal returned:

ubuntu@10.49.179.100: Permission denied (publickey).
Enter fullscreen mode Exit fullscreen mode

This indicated that the SSH service on port 2222 was configured to require public-key authentication for this login attempt.

The credentials discovered earlier were not accepted through this authentication method.

I decided to test the other SSH service instead.

4.2 Connecting Through the Default SSH Port

Next, I attempted to connect through the default SSH port, 22.

I used:

ssh ubuntu@10.49.179.100
Enter fullscreen mode Exit fullscreen mode

This time, the server requested a password.

After providing the credentials identified during the previous enumeration step, I successfully authenticated.

The terminal displayed the Ubuntu login banner:

Welcome to Ubuntu 20.04.3 LTS
Enter fullscreen mode Exit fullscreen mode

I now had an authenticated SSH session on the target machine.

This was an important step in the challenge because I had moved from external network enumeration to gaining access to the target environment.


5. Post-Exploitation – Exploring the Target System

After obtaining SSH access, I started with a few basic commands to understand my current environment.

First, I checked the available files and directories:

ls
Enter fullscreen mode Exit fullscreen mode

Then I verified my current working directory:

pwd
Enter fullscreen mode Exit fullscreen mode

The output showed:

/home/ubuntu
Enter fullscreen mode Exit fullscreen mode

This confirmed that I was currently operating from the Ubuntu user's home directory.

At this stage, I wanted to locate the flag file.

Instead of manually checking directories one by one, I used the find command to search the filesystem.

find / -name "flag.txt" 2>/dev/null
Enter fullscreen mode Exit fullscreen mode

Explanation:

  • /: Start searching from the filesystem root.
  • -name "flag.txt": Search for files with the specified name.
  • 2>/dev/null: Suppress permission-denied and other error messages.

The command returned:

/home/user/flag.txt
Enter fullscreen mode Exit fullscreen mode

This revealed the location of the flag file.

An interesting detail was that the flag was located inside /home/user/, rather than the current /home/ubuntu/ directory.


6. Reading the Flag File

After identifying the file location, I used the cat command to read its contents.

Since my current directory was /home/ubuntu, I used a relative path:

cat ../user/flag.txt
Enter fullscreen mode Exit fullscreen mode

The command successfully displayed the contents of the flag file.

I have intentionally redacted the flag value in this write-up.

This completed the main objective of the challenge.


7. Technical Analysis – What Did I Learn?

Looking back at this challenge, the most important part was the information gathered during service enumeration.

7.1 Service Enumeration Is More Than Version Detection

When performing an Nmap scan, I usually pay attention to open ports, service names, and software versions.

However, this challenge demonstrated that service fingerprint responses can contain additional information.

Even when Nmap cannot identify a service, the returned data may provide useful clues for further investigation.

7.2 Multiple SSH Ports Can Have Different Configurations

Both ports 22 and 2222 were running OpenSSH, but they did not behave identically during authentication.

Port 2222 returned:

Permission denied (publickey).
Enter fullscreen mode Exit fullscreen mode

The default SSH port allowed password-based authentication for the account I tested.

This reminded me that different services running on the same host can have different authentication configurations.

7.3 Credential Discovery Can Be More Important Than Exploiting a Vulnerability

Not every penetration-testing challenge requires exploiting a software vulnerability or executing a complex payload.

Sometimes, useful information is exposed through service responses, configuration mistakes, or operational notes.

In this challenge, the credential clue provided a path to authenticated access.

7.4 Basic Linux Enumeration Still Matters

Once I gained access, basic Linux commands were sufficient to identify the target file.

The commands I used were:

Command Purpose
ls List files and directories
pwd Display current working directory
find Search for files and directories
cat Read file contents
ssh Establish a remote connection

Understanding these basic commands is essential during post-exploitation activities.


8. Key Takeaways

Intermediate Nmap was a useful exercise in practicing a structured penetration-testing methodology.

The challenge reinforced several important concepts:

  • Always enumerate all open ports instead of focusing only on common services.
  • Investigate unidentified services and their fingerprint responses.
  • Pay attention to unusual messages and potentially exposed information.
  • Test different exposed services when the initial authentication attempt fails.
  • Understand the authentication configuration of SSH services.
  • Use Linux enumeration commands to locate important files after gaining access.

My biggest takeaway from this room is that small pieces of information discovered during reconnaissance can become the key to gaining access to a target system.

A good penetration tester should not immediately jump into exploitation without first understanding the information already exposed by the target.


Write-up Information

Field Details
Author Victor Hoang
Platform TryHackMe
Room Intermediate Nmap
Category Network Enumeration / Linux
Target OS Ubuntu 20.04.3 LTS
Tools Used Nmap, SSH, Linux CLI
Initial Access SSH Authentication
Exploit Reference Service Enumeration / Credential Discovery / SSH Access
Post-Exploitation Linux File Enumeration

Disclaimer: This write-up documents activities performed in the authorized TryHackMe lab environment. Credentials and flag values have been intentionally redacted.

Top comments (0)