Service Hijacking
# Check user's permissions
$ sudo -l
User x7331 may run the following commands on kali:
(ALL) NOPASSWD: /bin/systemctl restart backup.service
(ALL) NOPASSWD: /bin/systemctl daemon-reload
(ALL) !/bin/bash, !/bin/sh, !/bin/su, !/usr/bin/sudo
# Check the service's status and the service file path
$ systemctl status backup.service
○ backup.service - Backup Service
Loaded: loaded (/etc/systemd/system/backup.service; enabled; preset: enabled)
Active: inactive (dead)
# Check the service file's permissions
$ ls -la /etc/systemd/system/backup.service
-rw-rw-r-- 1 x7331 x7331 193 Apr 14 17:53 /etc/systemd/system/backup.service
# Review the contents of the file
$ cat /etc/systemd/system/backup.service
[Unit]
Description=Backup Service
<SNIP>
[Service]
Type=simple
ExecStart=/usr/local/bin/backup.sh # This is not writable
User=root
Group=root
<SNIP>Last updated