CTFroom: Basic Pentesting — Brute Force, Hash Cracking & Sudo Escalation
A structured assessment covering SMB share enumeration, brute forcing SSH credentials with Hydra, harvesting shadow password hashes, and cracking hashes with Hashcat to achieve root access.
Challenge Overview
Basic Pentesting is designed to reinforce fundamental ethical hacking workflows: port enumeration, SMB share inspection, brute forcing network credentials, and exploiting shadow hash leakage to achieve root privilege escalation.
Phase 1: Port Scanning & SMB Enumeration
Discovered services:
We run enum4linux to enumerate users and accessible SMB shares:
The enumeration discloses two valid local usernames:
jankayPhase 2: SSH Brute Forcing with Hydra
With verified usernames, we perform a dictionary attack against SSH using the rockyou.txt wordlist:
Within minutes, Hydra discovers the password for jan:
We connect via SSH:
Phase 3: Lateral Movement to User 'kay'
Checking /home, we notice kay's directory. Exploring /home/kay/.ssh:
The private key is protected with a passphrase. We copy the private key to our local machine and extract the hash using ssh2john:
John successfully cracks the passphrase:
We can now log in as kay:
Phase 4: Root Privilege Escalation
Checking kay's permissions or checking /etc/shadow:
Shows that user kay can run all commands as root:
We recover the root flag from /root/root.txt.
Defense Remediation
jan used a simple dictionary password (armando) easily cracked via automated dictionary attacks. Enforce complexity requirements and rate-limiting via fail2ban.chmod 600) and are not readable by other non-root accounts on the system./etc/ssh/sshd_config.