安云网 - AnYun.ORG | 专注于网络信息收集、网络数据分享、网络安全研究、网络各种猎奇八卦。
当前位置: 安云网 > 知识学堂 > 利用webshell搭建socks代理

利用webshell搭建socks代理

时间:2014-08-27来源:WOOYUN 作者:瞌睡龙点击:
老外的开源应用 https://github.com/sensepost/reGeorg 使用示例: python reGeorgSocksProxy.py -p 8080 -u http://upload.sensepost.net:8080/tunnel/tunnel.jsp Step 1. 上传一个脚本(aspx|ashx|jsp|php) 到web服务器上。 Step 2. 执行reGeorgSocksProxy.py脚本,连接shell监听端口。

老外的开源应用 

https://github.com/sensepost/reGeorg 

//本文来自安云网



使用示例: 

python reGeorgSocksProxy.py -p 8080 -u http://upload.sensepost.net:8080/tunnel/tunnel.jsp //内容来自安云网

Step 1. 上传一个脚本(aspx|ashx|jsp|php) 到web服务器上。 

Step 2. 执行reGeorgSocksProxy.py脚本,连接shell监听端口。 

//copyright AnYun.ORG



** 如果你使用nmap等工具需要用到 proxychains。 

Step 3. Hack the planet :)
//安云网咨询系统

//本文来自安云网

1#MeirLin | 2014-08-11 17:22 //安云网,anyun.org

前排mank

//内容来自AnYun.ORG

 

//本文来自安云网

2#Knight | 2014-08-11 17:27 //本文来自安云网

goagent比较好用。 //copyright AnYun.ORG

 

//内容来自安云网

3#骚动侠 | 2014-08-11 18:24

//copyright AnYun.ORG

mark //安云网,anyun.org

 

//本文来自安云网

4#西顾 | 2014-08-11 18:40

//内容来自安云网

@Knight goagent怎样利用webshell搭代理?

//安云网咨询系统

 

//本文来自安云网

5#Mujj | 2014-08-11 18:54

//安云网,anyun.org

@西顾  //copyright AnYun.ORG

python版:

//内容来自AnYun.ORG

#!/usr/bin/env python //ANYUN.ORG

# coding=utf-8 //copyright AnYun.ORG

# Contributor:

//内容来自AnYun.ORG

#      Phus Lu        <[email protected]>

//安云网咨询系统


//安云网,anyun.org

__version__ = '3.0.7' //安云网咨询系统

__password__ = ''

//内容来自安云网

__hostsdeny__ = ()  # __hostsdeny__ = ('.youtube.com', '.youku.com')

//内容来自AnYun.ORG


//ANYUN.ORG

import sys //内容来自AnYun.ORG

import os //ANYUN.ORG

import re

//安云网咨询系统

import time //内容来自安云网

import struct //本文来自安云网

import zlib

//内容来自AnYun.ORG

import base64

//内容来自AnYun.ORG

import logging //本文来自安云网

import httplib //安云网咨询系统

import urlparse //内容来自安云网

import errno //本文来自安云网

import string

//ANYUN.ORG

try:

//本文来自安云网

    from io import BytesIO

//本文来自安云网

except ImportError:

//内容来自安云网

    from cStringIO import StringIO as BytesIO //安云网咨询系统

try: //ANYUN.ORG

    from google.appengine.api import urlfetch //内容来自AnYun.ORG

    from google.appengine.runtime import apiproxy_errors //本文来自安云网

except ImportError:

//安云网,anyun.org

    urlfetch = None //安云网咨询系统

try: //本文来自安云网

    import sae

//安云网咨询系统

except ImportError: //安云网咨询系统

    sae = None //内容来自安云网

try:

//copyright AnYun.ORG

    import bae.core.wsgi

//内容来自AnYun.ORG

except ImportError:

//copyright AnYun.ORG

    bae = None //安云网,anyun.org

try:

//ANYUN.ORG

    import socket

//ANYUN.ORG

    import select

//内容来自安云网

except ImportError: //ANYUN.ORG

    socket = None

//ANYUN.ORG

try: //ANYUN.ORG

    import OpenSSL

//copyright AnYun.ORG

except ImportError:

//本文来自安云网

    OpenSSL = None //copyright AnYun.ORG


//内容来自安云网

URLFETCH_MAX | 2

//内容来自安云网

URLFETCH_MAXSIZE = 4*1024*1024

//内容来自安云网

URLFETCH_DEFLATE_MAXSIZE = 4*1024*1024 //copyright AnYun.ORG

URLFETCH_TIMEOUT = 60

//内容来自安云网


//内容来自AnYun.ORG

def message_html(title, banner, detail=''):

//内容来自安云网

    MESSAGE_TEMPLATE = ''' //ANYUN.ORG

    <html><head> //copyright AnYun.ORG

    <meta http-equiv="content-type" content="text/html;charset=utf-8"> //安云网,anyun.org

    <title>$title</title>

//内容来自AnYun.ORG

    <style><!--

//copyright AnYun.ORG

    body {font-family: arial,sans-serif} //安云网咨询系统

    div.nav {margin-top: 1ex} //安云网,anyun.org

    div.nav A {font-size: 10pt; font-family: arial,sans-serif} //内容来自安云网

    span.nav {font-size: 10pt; font-family: arial,sans-serif; font-weight: bold} //本文来自安云网

    div.nav A,span.big {font-size: 12pt; color: #0000cc} //本文来自安云网

    div.nav A {font-size: 10pt; color: black}

//copyright AnYun.ORG

    A.l:link {color: #6f6f6f} //copyright AnYun.ORG

    A.u:link {color: green} //安云网咨询系统

    //--></style>

//本文来自安云网

    </head> //内容来自安云网

    <body text=#000000 bgcolor=#ffffff> //copyright AnYun.ORG

    <table border=0 cellpadding=2 cellspacing=0 width=100%>

//安云网,anyun.org

    <tr><td bgcolor=#3366cc><font face=arial,sans-serif color=#ffffff><b>Message</b></td></tr>

//ANYUN.ORG

    <tr><td> </td></tr></table> //安云网,anyun.org

    <blockquote> //copyright AnYun.ORG

    <H1>$banner</H1>

//ANYUN.ORG

    $detail

//ANYUN.ORG

    <p>

//安云网,anyun.org

    </blockquote> //本文来自安云网

    <table width=100% cellpadding=0 cellspacing=0><tr><td bgcolor=#3366cc><img alt="" width=1 height=4></td></tr></table>

//安云网咨询系统

    </body></html>

//ANYUN.ORG

    ''' //安云网,anyun.org

    return string.Template(MESSAGE_TEMPLATE).substitute(title=title, banner=banner, detail=detail) //安云网,anyun.org


//安云网咨询系统


//内容来自AnYun.ORG

try:

//内容来自AnYun.ORG

    from Crypto.Cipher.ARC4 import new as _Crypto_Cipher_ARC4_new //安云网,anyun.org

except ImportError:

//copyright AnYun.ORG

    logging.warn('Load Crypto.Cipher.ARC4 Failed, Use Pure Python Instead.') //内容来自AnYun.ORG

    class _Crypto_Cipher_ARC4_new(object): //本文来自安云网

        def __init__(self, key):

//本文来自安云网

            x = 0 //内容来自安云网

            box = range(256)

//内容来自安云网

            for i, y in enumerate(box):

//内容来自安云网

                x = (x + y + ord(key[i % len(key)])) & 0xff

//内容来自安云网

                box[i], box[x] = box[x], y

//ANYUN.ORG

            self.__box = box //安云网咨询系统

            self.__x = 0 //本文来自安云网

            self.__y = 0 //本文来自安云网

        def encrypt(self, data):

//内容来自AnYun.ORG

            out = []

//ANYUN.ORG

            out_append = out.append

//安云网咨询系统

            x = self.__x //本文来自安云网

            y = self.__y

//ANYUN.ORG

            box = self.__box

//本文来自安云网

            for char in data:

//本文来自安云网

                x = (x + 1) & 0xff

//本文来自安云网

                y = (y + box[x]) & 0xff //内容来自安云网

                box[x], box[y] = box[y], box[x]

//copyright AnYun.ORG

                out_append(chr(ord(char) ^ box[(box[x] + box[y]) & 0xff])) //ANYUN.ORG

            self.__x = x

//本文来自安云网

            self.__y = y //安云网咨询系统

            return ''.join(out) //安云网,anyun.org


//内容来自AnYun.ORG


//内容来自AnYun.ORG

def rc4crypt(data, key): //本文来自安云网

    return _Crypto_Cipher_ARC4_new(key).encrypt(data) if key else data //内容来自AnYun.ORG


//内容来自AnYun.ORG


//安云网咨询系统

class RC4FileObject(object):

//内容来自AnYun.ORG

    """fileobj for rc4"""

//本文来自安云网

    def __init__(self, stream, key):

//安云网,anyun.org

        self.__stream = stream //内容来自AnYun.ORG

        self.__cipher = _Crypto_Cipher_ARC4_new(key) if key else lambda x:x //安云网咨询系统

    def __getattr__(self, attr):

//本文来自安云网

        if attr not in ('__stream', '__cipher'): //安云网咨询系统

            return getattr(self.__stream, attr) //安云网,anyun.org

    def read(self, size=-1): //copyright AnYun.ORG

        return self.__cipher.encrypt(self.__stream.read(size))

//本文来自安云网


//copyright AnYun.ORG


//copyright AnYun.ORG

def gae_application(environ, start_response):

//内容来自安云网

    cookie = environ.get('HTTP_COOKIE', '') //本文来自安云网

    options = environ.get('HTTP_X_GOA_OPTIONS', '')

//copyright AnYun.ORG

    if environ['REQUEST_METHOD'] == 'GET' and not cookie:

//内容来自AnYun.ORG

        if '204' in environ['QUERY_STRING']: //内容来自安云网

            start_response('204 No Content', []) //安云网,anyun.org

            yield ''

//copyright AnYun.ORG

        else: //本文来自安云网

            timestamp = long(os.environ['CURRENT_VERSION_ID'].split('.')[1])/2**28

//本文来自安云网

            ctime = time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime(timestamp+8*3600)) //本文来自安云网

            html = u'GoAgent Python Server %s \u5df2\u7ecf\u5728\u5de5\u4f5c\u4e86\uff0c\u90e8\u7f72\u65f6\u95f4 %s\n' % (__version__, ctime) //本文来自安云网

            start_response('200 OK', [('Content-Type', 'text/plain; charset=utf-8')]) //copyright AnYun.ORG

            yield html.encode('utf8')

//内容来自安云网

        raise StopIteration //安云网咨询系统


//ANYUN.ORG

    # inflate = lambda x:zlib.decompress(x, -zlib.MAX_WBITS)

//ANYUN.ORG

    wsgi_input = environ['wsgi.input'] //安云网,anyun.org

    input_data = wsgi_input.read() //安云网咨询系统


//安云网咨询系统

    try:

//内容来自安云网

        if cookie: //安云网,anyun.org

            if 'rc4' not in options:

//安云网,anyun.org

                metadata = zlib.decompress(base64.b64decode(cookie), -zlib.MAX_WBITS)

//ANYUN.ORG

                payload = input_data or ''

//本文来自安云网

            else:

//ANYUN.ORG

                metadata = zlib.decompress(rc4crypt(base64.b64decode(cookie), __password__), -zlib.MAX_WBITS) //安云网咨询系统

                payload = rc4crypt(input_data, __password__) if input_data else '' //内容来自安云网

        else:

//安云网,anyun.org

            if 'rc4' in options:

//安云网咨询系统

                input_data = rc4crypt(input_data, __password__)

//内容来自安云网

            metadata_length, = struct.unpack('!h', input_data[:2]) //安云网咨询系统

            metadata = zlib.decompress(input_data[2:2+metadata_length], -zlib.MAX_WBITS) //安云网,anyun.org

            payload = input_data[2+metadata_length:]

//内容来自安云网

        headers = dict(x.split(':', 1) for x in metadata.splitlines() if x) //ANYUN.ORG

        method = headers.pop('G-Method') //内容来自AnYun.ORG

        url = headers.pop('G-Url')

//copyright AnYun.ORG

    except (zlib.error, KeyError, ValueError):

//ANYUN.ORG

        import traceback

//ANYUN.ORG

        start_response('500 Internal Server Error', [('Content-Type', 'text/html')])

//copyright AnYun.ORG

        yield message_html('500 Internal Server Error', 'Bad Request (metadata) - Possible Wrong Password', '<pre>%s</pre>' % traceback.format_exc()) //copyright AnYun.ORG

        raise StopIteration

//本文来自安云网


//内容来自AnYun.ORG

    kwargs = {}

//本文来自安云网

    any(kwargs.__setitem__(x[2:].lower(), headers.pop(x)) for x in headers.keys() if x.startswith('G-'))

//本文来自安云网


//内容来自AnYun.ORG

    if 'Content-Encoding' in headers:

//内容来自安云网

        if headers['Content-Encoding'] == 'deflate':

//内容来自AnYun.ORG

            payload = zlib.decompress(payload, -zlib.MAX_WBITS) //安云网咨询系统

            headers['Content-Length'] = str(len(payload)) //ANYUN.ORG

            del headers['Content-Encoding'] //ANYUN.ORG


//安云网咨询系统

    logging.info('%s "%s %s %s" - -', environ['REMOTE_ADDR'], method, url, 'HTTP/1.1')

//本文来自安云网

    #logging.info('request headers=%s', headers) //安云网,anyun.org


//本文来自安云网

    if __password__ and __password__ != kwargs.get('password', ''):

//ANYUN.ORG

        start_response('403 Forbidden', [('Content-Type', 'text/html')]) //内容来自安云网

        yield message_html('403 Wrong password', 'Wrong password(%r)' % kwargs.get('password', ''), 'GoAgent proxy.ini password is wrong!')

//内容来自安云网

        raise StopIteration //内容来自AnYun.ORG


//内容来自AnYun.ORG

    netloc = urlparse.urlparse(url).netloc //安云网咨询系统


//ANYUN.ORG

    if __hostsdeny__ and netloc.endswith(__hostsdeny__):

//内容来自AnYun.ORG

        start_response('403 Forbidden', [('Content-Type', 'text/html')])

//内容来自AnYun.ORG

        yield message_html('403 Hosts Deny', 'Hosts Deny(%r)' % netloc, detail='url=%r' % url) //安云网咨询系统

        raise StopIteration

//内容来自AnYun.ORG


//内容来自AnYun.ORG

    if netloc.startswith(('127.0.0.', '::1', 'localhost')):

//安云网咨询系统

        start_response('400 Bad Request', [('Content-Type', 'text/html')])

//安云网咨询系统

        html = ''.join('<a href="https://%s/">%s</a><br/>' % (x, x) for x in ('google.com', 'mail.google.com')) //ANYUN.ORG

        yield message_html('GoAgent %s is Running' % __version__, 'Now you can visit some websites', html) //copyright AnYun.ORG

        raise StopIteration

//copyright AnYun.ORG


//copyright AnYun.ORG

    fetchmethod = getattr(urlfetch, method, None)

//本文来自安云网

    if not fetchmethod:

//安云网咨询系统

        start_response('405 Method Not Allowed', [('Content-Type', 'text/html')]) //安云网,anyun.org

        yield message_html('405 Method Not Allowed', 'Method Not Allowed: %r' % method, detail='Method Not Allowed URL=%r' % url) //ANYUN.ORG

        raise StopIteration

//内容来自安云网


//内容来自AnYun.ORG

    deadline = URLFETCH_TIMEOUT //内容来自安云网

    validate_certificate = bool(int(kwargs.get('validate', 0))) //ANYUN.ORG

    accept_encoding = headers.get('Accept-Encoding', '') //内容来自安云网

    errors = []

//ANYUN.ORG

    for i in xrange(int(kwargs.get('fetchmax', URLFETCH_MAX))): //内容来自AnYun.ORG

        try: //ANYUN.ORG

            response = urlfetch.fetch(url, payload, fetchmethod, headers, allow_truncated=False, follow_redirects=False, deadline=deadline, validate_certificate=validate_certificate) //内容来自安云网

            break

//安云网,anyun.org

        except apiproxy_errors.OverQuotaError as e: //内容来自AnYun.ORG

            time.sleep(5) //本文来自安云网

        except urlfetch.DeadlineExceededError as e:

//安云网咨询系统

            errors.append('%r, deadline=%s' % (e, deadline)) //copyright AnYun.ORG

            logging.error('DeadlineExceededError(deadline=%s, url=%r)', deadline, url) //安云网咨询系统

            time.sleep(1)

//ANYUN.ORG

 | 2 //本文来自安云网

        except urlfetch.DownloadError as e:

//内容来自安云网

            errors.append('%r, deadline=%s' % (e, deadline))

//本文来自安云网

            logging.error('DownloadError(deadline=%s, url=%r)', deadline, url) //安云网咨询系统

            time.sleep(1)

//copyright AnYun.ORG

 | 2

//ANYUN.ORG

        except urlfetch.ResponseTooLargeError as e:

//内容来自AnYun.ORG

            errors.append('%r, deadline=%s' % (e, deadline)) //内容来自安云网

            response = e.response //内容来自AnYun.ORG

            logging.error('ResponseTooLargeError(deadline=%s, url=%r) response(%r)', deadline, url, response)

//安云网咨询系统

            m = re.search(r'=\s*(\d+)-', headers.get('Range') or headers.get('range') or '')

//本文来自安云网

            if m is None:

//安云网咨询系统

                headers['Range'] = 'bytes=0-%d' % int(kwargs.get('fetchmaxsize', URLFETCH_MAXSIZE)) //ANYUN.ORG

            else: //安云网,anyun.org

                headers.pop('Range', '')

//内容来自安云网

                headers.pop('range', '')

//copyright AnYun.ORG

                start = int(m.group(1))

//ANYUN.ORG

                headers['Range'] = 'bytes=%s-%d' % (start, start+int(kwargs.get('fetchmaxsize', URLFETCH_MAXSIZE)))

//ANYUN.ORG

 | 2

//内容来自AnYun.ORG

        except urlfetch.SSLCertificateError as e: //copyright AnYun.ORG

            errors.append('%r, should validate=0 ?' % e) //内容来自AnYun.ORG

            logging.error('%r, deadline=%s', e, deadline) //内容来自AnYun.ORG

        except Exception as e:

//安云网咨询系统

            errors.append(str(e))

//安云网咨询系统

            if i == 0 and method == 'GET':

//安云网咨询系统

 | 2 //安云网,anyun.org

    else: //安云网,anyun.org

        start_response('500 Internal Server Error', [('Content-Type', 'text/html')])

//内容来自AnYun.ORG

        error_string = '<br />\n'.join(errors)

//安云网,anyun.org

        if not error_string:

//内容来自安云网

            logurl = 'https://appengine.google.com/logs?&app_id=%s' % os.environ['APPLICATION_ID'] //安云网,anyun.org

            error_string = 'Internal Server Error. <p/>try <a href="javascript:window.location.reload(true);">refresh</a> or goto <a href="%s" target="_blank">appengine.google.com</a> for details' % logurl

//内容来自安云网

        yield message_html('502 Urlfetch Error', 'Python Urlfetch Error: %r' % method,  error_string)

//内容来自AnYun.ORG

        raise StopIteration //copyright AnYun.ORG


//ANYUN.ORG

    #logging.debug('url=%r response.status_code=%r response.headers=%r response.content[:1024]=%r', url, response.status_code, dict(response.headers), response.content[:1024])

//内容来自AnYun.ORG


//copyright AnYun.ORG

    data = response.content //ANYUN.ORG

    response_headers = response.headers

//安云网,anyun.org

    if 'content-encoding' not in response_headers and len(response.content) < URLFETCH_DEFLATE_MAXSIZE and response_headers.get('content-type', '').startswith(('text/', 'application/json', 'application/javascript')): //内容来自AnYun.ORG

        if 'gzip' in accept_encoding:

//内容来自AnYun.ORG

            response_headers['Content-Encoding'] = 'gzip'

//内容来自AnYun.ORG

            compressobj = zlib.compressobj(zlib.Z_DEFAULT_COMPRESSION, zlib.DEFLATED, -zlib.MAX_WBITS, zlib.DEF_MEM_LEVEL, 0) //内容来自安云网

            dataio = BytesIO()

//copyright AnYun.ORG

            dataio.write('\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\xff') //内容来自AnYun.ORG

            dataio.write(compressobj.compress(data))

//安云网咨询系统

            dataio.write(compressobj.flush())

//本文来自安云网

            dataio.write(struct.pack('<LL', zlib.crc32(data) & 0xFFFFFFFFL, len(data) & 0xFFFFFFFFL)) //本文来自安云网

            data = dataio.getvalue() //安云网,anyun.org

        elif 'deflate' in accept_encoding: //copyright AnYun.ORG

            response_headers['Content-Encoding'] = 'deflate'

//ANYUN.ORG

            data = zlib.compress(data)[2:-4] //ANYUN.ORG

    if data: //本文来自安云网

         response_headers['Content-Length'] = str(len(data))

//ANYUN.ORG

    response_headers_data = zlib.compress('\n'.join('%s:%s' % (k.title(), v) for k, v in response_headers.items() if not k.startswith('x-google-')))[2:-4]

//内容来自安云网

    if 'rc4' not in options: //内容来自AnYun.ORG

        start_response('200 OK', [('Content-Type', 'image/gif')])

//ANYUN.ORG

        yield struct.pack('!hh', int(response.status_code), len(response_headers_data))+response_headers_data

//内容来自安云网

        yield data

//本文来自安云网

    else:

//本文来自安云网

        start_response('200 OK', [('Content-Type', 'image/gif'), ('X-GOA-Options', 'rc4')])

//内容来自AnYun.ORG

        yield struct.pack('!hh', int(response.status_code), len(response_headers_data)) //内容来自安云网

        yield rc4crypt(response_headers_data, __password__) //本文来自安云网

        yield rc4crypt(data, __password__) //copyright AnYun.ORG


//ANYUN.ORG


//ANYUN.ORG

class LegacyHandler(object):

//ANYUN.ORG

    """GoAgent 1.x GAE Fetch Server"""

//ANYUN.ORG

    @classmethod

//内容来自AnYun.ORG

    def application(cls, environ, start_response): //内容来自安云网

        return cls()(environ, start_response)

//安云网,anyun.org


//内容来自安云网

    def __call__(self, environ, start_response): //copyright AnYun.ORG

        self.environ = environ

//安云网,anyun.org

        self.start_response = start_response

//内容来自安云网

        return self.process_request()

//ANYUN.ORG


//内容来自AnYun.ORG

    def send_response(self, status, headers, content, content_type='image/gif'):

//内容来自AnYun.ORG

        headers['Content-Length'] = str(len(content)) //内容来自AnYun.ORG

        strheaders = '&'.join('%s=%s' % (k, v.encode('hex')) for k, v in headers.iteritems() if v)

//安云网,anyun.org

        #logging.debug('response status=%s, headers=%s, content length=%d', status, headers, len(content)) //内容来自AnYun.ORG

        if headers.get('content-type', '').startswith(('text/', 'application/json', 'application/javascript')): //安云网,anyun.org

            data = '1' + zlib.compress('%s%s%s' % (struct.pack('>3I', status, len(strheaders), len(content)), strheaders, content))

//copyright AnYun.ORG

        else: //内容来自AnYun.ORG

            data = '0%s%s%s' % (struct.pack('>3I', status, len(strheaders), len(content)), strheaders, content) //安云网咨询系统

        self.start_response('200 OK', [('Content-type', content_type)]) //本文来自安云网

        return [data] //ANYUN.ORG


//安云网咨询系统

    def send_notify(self, method, url, status, content): //copyright AnYun.ORG

        logging.warning('%r Failed: url=%r, status=%r', method, url, status) //安云网,anyun.org

        content = '<h2>Python Server Fetch Info</h2><hr noshade="noshade"><p>%s %r</p><p>Return Code: %d</p><p>Message: %s</p>' % (method, url, status, content)

//本文来自安云网

        return self.send_response(status, {'content-type': 'text/html'}, content) //内容来自AnYun.ORG


//内容来自AnYun.ORG

    def process_request(self): //本文来自安云网

        environ = self.environ //安云网咨询系统

        if environ['REQUEST_METHOD'] == 'GET':

//本文来自安云网

            redirect_url = 'https://%s/2' % environ['HTTP_HOST'] //安云网,anyun.org

            self.start_response('302 Redirect', [('Location', redirect_url)])

//安云网咨询系统

            return [redirect_url] //ANYUN.ORG


//内容来自安云网

        data = zlib.decompress(environ['wsgi.input'].read(int(environ['CONTENT_LENGTH'])))

//内容来自安云网

        request = dict((k, v.decode('hex')) for k, _, v in (x.partition('=') for x in data.split('&')))

//本文来自安云网


//本文来自安云网

        method = request['method'] //copyright AnYun.ORG

        url = request['url']

//内容来自安云网

        payload = request['payload'] //内容来自安云网


//ANYUN.ORG

        if __password__ and __password__ != request.get('password', ''): //ANYUN.ORG

            return self.send_notify(method, url, 403, 'Wrong password.') //内容来自AnYun.ORG


//安云网,anyun.org

        if __hostsdeny__ and urlparse.urlparse(url).netloc.endswith(__hostsdeny__):

//安云网,anyun.org

            return self.send_notify(method, url, 403, 'Hosts Deny: url=%r' % url) //copyright AnYun.ORG


//copyright AnYun.ORG

        fetchmethod = getattr(urlfetch, method, '') //内容来自安云网

        if not fetchmethod: //安云网咨询系统

            return self.send_notify(method, url, 501, 'Invalid Method')

//内容来自安云网


//安云网咨询系统

        deadline = URLFETCH_TIMEOUT //内容来自AnYun.ORG


//内容来自安云网

        headers = dict((k.title(), v.lstrip()) for k, _, v in (line.partition(':') for line in request['headers'].splitlines()))

//安云网咨询系统

        headers['Connection'] = 'close'

//内容来自安云网


//安云网咨询系统

        errors = []

//安云网,anyun.org

        for i in xrange(URLFETCH_MAX if 'fetchmax' not in request else int(request['fetchmax'])): //copyright AnYun.ORG

            try:

//copyright AnYun.ORG

                response = urlfetch.fetch(url, payload, fetchmethod, headers, False, False, deadline, False)

//本文来自安云网

                break

//本文来自安云网

            except apiproxy_errors.OverQuotaError as e:

//安云网,anyun.org

                time.sleep(4) //内容来自AnYun.ORG

            except urlfetch.DeadlineExceededError as e: //内容来自安云网

                errors.append('DeadlineExceededError %s(deadline=%s)' % (e, deadline)) //copyright AnYun.ORG

                logging.error('DeadlineExceededError(deadline=%s, url=%r)', deadline, url) //安云网咨询系统

                time.sleep(1) //本文来自安云网

            except urlfetch.DownloadError as e:

//安云网,anyun.org

                errors.append('DownloadError %s(deadline=%s)' % (e, deadline)) //内容来自安云网

                logging.error('DownloadError(deadline=%s, url=%r)', deadline, url) //copyright AnYun.ORG

                time.sleep(1) //安云网咨询系统

            except urlfetch.InvalidURLError as e: //本文来自安云网

                return self.send_notify(method, url, 501, 'Invalid URL: %s' % e)

//安云网,anyun.org

            except urlfetch.ResponseTooLargeError as e:

//内容来自安云网

                response = e.response //copyright AnYun.ORG

                logging.error('ResponseTooLargeError(deadline=%s, url=%r) response(%r)', deadline, url, response) //内容来自AnYun.ORG

                m = re.search(r'=\s*(\d+)-', headers.get('Range') or headers.get('range') or '') //ANYUN.ORG

                if m is None: //本文来自安云网

                    headers['Range'] = 'bytes=0-%d' % URLFETCH_MAXSIZE //内容来自AnYun.ORG

                else: //安云网咨询系统

                    headers.pop('Range', '') //安云网,anyun.org

                    headers.pop('range', '')

//本文来自安云网

                    start = int(m.group(1))

//内容来自安云网

                    headers['Range'] = 'bytes=%s-%d' % (start, start+URLFETCH_MAXSIZE)

//copyright AnYun.ORG

 | 2 //copyright AnYun.ORG

            except Exception as e: //内容来自AnYun.ORG

                errors.append('Exception %s(deadline=%s)' % (e, deadline))

//安云网咨询系统

        else:

//本文来自安云网

            return self.send_notify(method, url, 500, 'Python Server: Urlfetch error: %s' % errors)

//ANYUN.ORG


//copyright AnYun.ORG

        headers = response.headers

//内容来自安云网

        if 'content-length' not in headers:

//ANYUN.ORG

            headers['content-length'] = str(len(response.content)) //内容来自AnYun.ORG

        headers['connection'] = 'close'

//安云网,anyun.org

        return self.send_response(response.status_code, headers, response.content)

//本文来自安云网


//内容来自AnYun.ORG


//copyright AnYun.ORG

def forward_socket(local, remote, timeout=60, tick=2, bufsize=8192, maxping=None, maxpong=None, pongcallback=None, trans=None): //copyright AnYun.ORG

    try:

//ANYUN.ORG

        timecount = timeout //ANYUN.ORG

        while 1:

//本文来自安云网

            timecount -= tick

//ANYUN.ORG

            if timecount <= 0: //内容来自安云网

                break

//内容来自AnYun.ORG

            (ins, _, errors) = select.select([local, remote], [], [local, remote], tick)

//安云网,anyun.org

            if errors: //内容来自AnYun.ORG

                break

//ANYUN.ORG

            if ins: //安云网咨询系统

                for sock in ins: //安云网咨询系统

                    data = sock.recv(bufsize) //内容来自安云网

                    if trans: //ANYUN.ORG

                        data = data.translate(trans)

//copyright AnYun.ORG

                    if data: //内容来自AnYun.ORG

                        if sock is remote:

//内容来自安云网

                            local.sendall(data) //内容来自AnYun.ORG

                            timecount = maxpong or timeout

//安云网,anyun.org

                            if pongcallback:

//本文来自安云网

                                try: //copyright AnYun.ORG

                                    #remote_addr = '%s:%s'%remote.getpeername()[:2]

//内容来自AnYun.ORG

                                    #logging.debug('call remote=%s pongcallback=%s', remote_addr, pongcallback)

//ANYUN.ORG

                                    pongcallback()

//本文来自安云网

                                except Exception as e: //本文来自安云网

                                    logging.warning('remote=%s pongcallback=%s failed: %s', remote, pongcallback, e) //本文来自安云网

                                finally:

//内容来自AnYun.ORG

                                    pongcallback = None //安云网,anyun.org

                        else: //内容来自AnYun.ORG

                            remote.sendall(data) //安云网咨询系统

                            timecount = maxping or timeout

//本文来自安云网

                    else: //安云网,anyun.org

                        return

//内容来自安云网

    except socket.error as e: //内容来自安云网

        if e[0] not in (10053, 10054, 10057, errno.EPIPE): //内容来自安云网

            raise

//安云网咨询系统

    finally:

//安云网,anyun.org

        if local: //本文来自安云网

            local.close() //本文来自安云网

        if remote:

//本文来自安云网

            remote.close() //copyright AnYun.ORG


//ANYUN.ORG


//本文来自安云网

def paas_application(environ, start_response): //内容来自AnYun.ORG

    if environ['REQUEST_METHOD'] == 'GET': //安云网咨询系统

        start_response('302 Found', [('Location', 'https://www.google.com')])

//内容来自安云网

        raise StopIteration //内容来自AnYun.ORG


//安云网,anyun.org

    wsgi_input = environ['wsgi.input'] //本文来自安云网

    data = wsgi_input.read(2)

//ANYUN.ORG

    metadata_length, = struct.unpack('!h', data) //安云网咨询系统

    metadata = wsgi_input.read(metadata_length) //安云网,anyun.org


//安云网,anyun.org

    metadata = zlib.decompress(metadata, -zlib.MAX_WBITS)

//ANYUN.ORG

    headers = {}

//安云网,anyun.org

    for line in metadata.splitlines():

//安云网咨询系统

        if line: //内容来自AnYun.ORG

            keyword, value = line.split(':', 1)

//copyright AnYun.ORG

            headers[keyword.title()] = value.strip()

//内容来自安云网

    method = headers.pop('G-Method')

//内容来自AnYun.ORG

    url = headers.pop('G-Url') //copyright AnYun.ORG

    timeout = URLFETCH_TIMEOUT

//内容来自安云网


//安云网,anyun.org

    kwargs = {} //安云网,anyun.org

    any(kwargs.__setitem__(x[2:].lower(), headers.pop(x)) for x in headers.keys() if x.startswith('G-')) //内容来自AnYun.ORG


//安云网咨询系统

    if __password__ and __password__ != kwargs.get('password'):

//安云网咨询系统

        random_host = 'g%d%s' % (int(time.time()*100), environ['HTTP_HOST']) //copyright AnYun.ORG

        conn = httplib.HTTPConnection(random_host, timeout=timeout)

//内容来自安云网

        conn.request('GET', '/')

//copyright AnYun.ORG

        response = conn.getresponse(True)

//安云网咨询系统

        status_line = '%s %s' % (response.status, httplib.responses.get(response.status, 'OK'))

//本文来自安云网

        start_response(status_line, response.getheaders())

//内容来自安云网

        yield response.read() //本文来自安云网

        raise StopIteration

//内容来自安云网


//ANYUN.ORG

    if __hostsdeny__ and urlparse.urlparse(url).netloc.endswith(__hostsdeny__): //内容来自安云网

        start_response('403 Forbidden', [('Content-Type', 'text/html')])

//ANYUN.ORG

        yield message_html('403 Forbidden Host', 'Hosts Deny(%s)' % url, detail='url=%r' % url)

//安云网咨询系统

        raise StopIteration //copyright AnYun.ORG


//本文来自安云网

    headers['Connection'] = 'close' //安云网咨询系统

    payload = environ['wsgi.input'].read() if 'Content-Length' in headers else None //ANYUN.ORG

    if 'Content-Encoding' in headers: //安云网咨询系统

        if headers['Content-Encoding'] == 'deflate': //内容来自AnYun.ORG

            payload = zlib.decompress(payload, -zlib.MAX_WBITS)

//内容来自安云网

            headers['Content-Length'] = str(len(payload)) //内容来自安云网

            del headers['Content-Encoding']

//ANYUN.ORG


//安云网,anyun.org

    logging.info('%s "%s %s %s" - -', environ['REMOTE_ADDR'], method, url, 'HTTP/1.1') //本文来自安云网


//内容来自安云网

    if method == 'CONNECT': //安云网,anyun.org

        if not socket:

//安云网,anyun.org

            start_response('403 Forbidden', [('Content-Type', 'text/html')])

//安云网,anyun.org

            yield message_html('403 Forbidden CONNECT', 'socket not available', detail='`import socket` raised ImportError')

//本文来自安云网

            raise StopIteration

//本文来自安云网

        rfile = wsgi_input.rfile //本文来自安云网

        sock = rfile._sock //ANYUN.ORG

        host, _, port = url.rpartition(':') //内容来自安云网

        port = int(port)

//安云网咨询系统

        remote_sock = socket.create_connection((host, port), timeout=timeout)

//内容来自安云网

        start_response('200 OK', [])

//安云网咨询系统

        forward_socket(sock, remote_sock)

//ANYUN.ORG

        yield 'out'

//内容来自AnYun.ORG

    else:

//copyright AnYun.ORG

        try:

//copyright AnYun.ORG

            scheme, netloc, path, params, query, fragment = urlparse.urlparse(url)

//本文来自安云网

            HTTPConnection = httplib.HTTPSConnection if scheme == 'https' else httplib.HTTPConnection //本文来自安云网

            if params:

//内容来自安云网

                path += ';' + params //安云网,anyun.org

            if query: //安云网咨询系统

                path += '?' + query

//本文来自安云网

            conn = HTTPConnection(netloc, timeout=timeout) //ANYUN.ORG

            conn.request(method, path, body=payload, headers=headers)

//ANYUN.ORG

            response = conn.getresponse() //ANYUN.ORG


//内容来自安云网

            headers_data = zlib.compress('\n'.join('%s:%s' % (k.title(), v) for k, v in response.getheaders()))[2:-4]

//安云网咨询系统

            start_response('200 OK', [('Content-Type', 'image/gif')])

//本文来自安云网

            yield struct.pack('!hh', int(response.status), len(headers_data))+headers_data

//copyright AnYun.ORG

            while 1:

//安云网咨询系统

                data = response.read(8192) //ANYUN.ORG

                if not data:

//ANYUN.ORG

                    response.close()

//本文来自安云网

                    break //内容来自AnYun.ORG

                yield data //ANYUN.ORG

        except httplib.HTTPException:

//copyright AnYun.ORG

            raise //安云网咨询系统


//内容来自安云网


//安云网咨询系统

app = gae_application if urlfetch else paas_application

//copyright AnYun.ORG

if bae: //ANYUN.ORG

    application = bae.core.wsgi.WSGIApplication(app)

//安云网咨询系统

elif sae: //内容来自安云网

    application = sae.create_wsgi_app(app) //ANYUN.ORG

else: //ANYUN.ORG

    application = app //安云网咨询系统


//本文来自安云网

if __name__ == '__main__': //本文来自安云网

    logging.basicConfig(level=logging.INFO, format='%(levelname)s - - %(asctime)s %(message)s', datefmt='[%b %d %H:%M:%S]') //安云网,anyun.org

    import gevent

//安云网咨询系统

    import gevent.server //内容来自AnYun.ORG

    import gevent.wsgi

//ANYUN.ORG

    import gevent.monkey //安云网,anyun.org

    gevent.monkey.patch_all(dns=gevent.version_info[0] >= 1) //内容来自安云网


//安云网咨询系统

    server = gevent.wsgi.WSGIServer(('', int(sys.argv[1])), application) //ANYUN.ORG

    logging.info('local paas_application serving at %s:%s', server.address[0], server.address[1])

//本文来自安云网

    server.serve_forever() //ANYUN.ORG


//ANYUN.ORG


//内容来自AnYun.ORG

PHP版: //copyright AnYun.ORG

<?php

//copyright AnYun.ORG


//本文来自安云网

// Note: //安云网,anyun.org

//     Please try to use the https url to bypass keyword filtering. //copyright AnYun.ORG

//     Otherwise, dont forgot set [paas]passowrd in proxy.ini

//内容来自安云网

// Contributor: //内容来自AnYun.ORG

//     Phus Lu        <[email protected]> //ANYUN.ORG


//本文来自安云网

$__version__  = '3.0.5';

//安云网咨询系统

$__password__ = '123'; //ANYUN.ORG

$__timeout__ | 20; //内容来自安云网


//安云网咨询系统

class URLFetch {

//copyright AnYun.ORG

    protected $body_maxsize = 4194304; //安云网咨询系统

    protected $headers = array(); //copyright AnYun.ORG

    protected $body = '';

//安云网,anyun.org

    protected $body_size = 0; //安云网,anyun.org


//安云网,anyun.org

    function __construct() { //本文来自安云网

    } //安云网,anyun.org


//copyright AnYun.ORG

    function urlfetch_readheader($ch, $header) {

//ANYUN.ORG

 | 2));

//内容来自AnYun.ORG

        if (isset($kv[1])) {

//本文来自安云网

            $key = join('-', array_map('ucfirst', explode('-', $kv[0])));

//内容来自安云网

            $value = $kv[1]; //内容来自安云网

            if ($key == 'Set-Cookie') {

//ANYUN.ORG

                if (!array_key_exists('Set-Cookie', $this->headers)) { //内容来自AnYun.ORG

                    $this->headers['Set-Cookie'] = $value; //内容来自安云网

                } else {

//安云网咨询系统

                    $this->headers['Set-Cookie'] .= "\r\nSet-Cookie: " . $value; //ANYUN.ORG

                } //本文来自安云网

            } else {

//ANYUN.ORG

                $this->headers[$key] = $kv[1]; //ANYUN.ORG

            } //安云网咨询系统

        }

//安云网咨询系统

        return strlen($header); //copyright AnYun.ORG

    }

//内容来自安云网


//内容来自安云网

    function urlfetch_readbody($ch, $data) {

//安云网,anyun.org

        $bytes = strlen($data);

//安云网,anyun.org

        if ($this->body_size + $bytes > $this->body_maxsize) { //本文来自安云网

            return -1;

//安云网,anyun.org

        } //内容来自安云网

        $this->body_size += $bytes; //本文来自安云网

        $this->body .= $data; //copyright AnYun.ORG

        return $bytes;

//本文来自安云网

    } //copyright AnYun.ORG


//内容来自安云网

    function urlfetch($url, $payload, $method, $headers, $follow_redirects, $deadline, $validate_certificate) {

//ANYUN.ORG


//copyright AnYun.ORG

        $this->headers = array(); //内容来自安云网

        $this->body = '';

//ANYUN.ORG

        $this->body_size = 0; //copyright AnYun.ORG


//内容来自安云网

        if ($payload) {

//本文来自安云网

            $headers['Content-Length'] = strval(strlen($payload));

//copyright AnYun.ORG

        } //内容来自安云网

        $headers['Connection'] = 'close';

//ANYUN.ORG


//本文来自安云网

        $curl_opt = array();

//安云网咨询系统


//安云网咨询系统

        $curl_opt[CURLOPT_TIMEOUT]        = $deadline; //安云网咨询系统

        $curl_opt[CURLOPT_CONNECTTIMEOUT] = $deadline;

//本文来自安云网

        $curl_opt[CURLOPT_RETURNTRANSFER] = true;

//安云网,anyun.org

        $curl_opt[CURLOPT_BINARYTRANSFER] = true;

//ANYUN.ORG

        $curl_opt[CURLOPT_FAILONERROR]    = true; //本文来自安云网


//ANYUN.ORG

        if (!$follow_redirects) {

//ANYUN.ORG

            $curl_opt[CURLOPT_FOLLOWLOCATION] = false; //copyright AnYun.ORG

        }

//本文来自安云网


//安云网咨询系统

        if ($deadline) { //ANYUN.ORG

            $curl_opt[CURLOPT_CONNECTTIMEOUT] = $deadline;

//安云网,anyun.org

            $curl_opt[CURLOPT_TIMEOUT] = $deadline;

//安云网,anyun.org

        } //本文来自安云网


//内容来自安云网

        if (!$validate_certificate) { //copyright AnYun.ORG

            $curl_opt[CURLOPT_SSL_VERIFYPEER] = false;

//内容来自AnYun.ORG

            $curl_opt[CURLOPT_SSL_VERIFYHOST] = false;

//内容来自AnYun.ORG

        }

//安云网咨询系统


//内容来自安云网

        switch (strtoupper($method)) { //内容来自AnYun.ORG

            case 'HEAD':

//copyright AnYun.ORG

                $curl_opt[CURLOPT_NOBODY] = true; //本文来自安云网

                break; //安云网咨询系统

            case 'GET':

//内容来自AnYun.ORG

                break;

//本文来自安云网

            case 'POST':

//ANYUN.ORG

                $curl_opt[CURLOPT_POST] = true; //ANYUN.ORG

                $curl_opt[CURLOPT_POSTFIELDS] = $payload;

//内容来自安云网

                break;

//本文来自安云网

            case 'PUT':

//本文来自安云网

            case 'DELETE': //ANYUN.ORG

                $curl_opt[CURLOPT_CUSTOMREQUEST] = $method; //copyright AnYun.ORG

                $curl_opt[CURLOPT_POSTFIELDS] = $payload;

//copyright AnYun.ORG

                break; //安云网咨询系统

            default: //copyright AnYun.ORG

                print(message_html('502 Urlfetch Error', 'Invalid Method: ' . $method,  $url));

//安云网,anyun.org

                exit(-1); //安云网咨询系统

        } //内容来自安云网


//ANYUN.ORG

        $header_array = array(); //内容来自安云网

        foreach ($headers as $key => $value) {

//安云网咨询系统

            if ($key) {

//内容来自安云网

                $header_array[] = join('-', array_map('ucfirst', explode('-', $key))).': '.$value;

//安云网咨询系统

            }

//安云网,anyun.org

        }

//内容来自安云网

        $curl_opt[CURLOPT_HTTPHEADER] = $header_array; //ANYUN.ORG


//ANYUN.ORG

        $curl_opt[CURLOPT_HEADER]         = false; //内容来自安云网

        $curl_opt[CURLOPT_HEADERFUNCTION] = array(&$this, 'urlfetch_readheader');

//内容来自安云网

        $curl_opt[CURLOPT_WRITEFUNCTION]  = array(&$this, 'urlfetch_readbody'); //ANYUN.ORG


//安云网,anyun.org

        $ch = curl_init($url); //ANYUN.ORG

        curl_setopt_array($ch, $curl_opt); //copyright AnYun.ORG

        $ret = curl_exec($ch);

//安云网,anyun.org

        $status = curl_getinfo($ch, CURLINFO_HTTP_CODE); //安云网,anyun.org

        $errno = curl_errno($ch);

//ANYUN.ORG

        if ($errno) //内容来自AnYun.ORG

        { //内容来自安云网

            $error =  $errno . ': ' .curl_error($ch);

//ANYUN.ORG

        } else { //安云网,anyun.org

            $error = '';

//ANYUN.ORG

        }

//本文来自安云网

        curl_close($ch);

//安云网,anyun.org


//内容来自安云网

        $this->headers['Connection'] = 'close';

//安云网咨询系统

        $content_length = isset($this->headers['Content-Length']) ? 1*$this->headers['Content-Length'] : 0;

//内容来自安云网


//本文来自安云网

 | 200 && $errno == 23 && $content_length && $this->body_size < $content_length) { //copyright AnYun.ORG

 | 206; //ANYUN.ORG

            $range_end = $this->body_size - 1; //ANYUN.ORG

            $this->headers['Content-Range'] = "bytes 0-$range_end/$content_length"; //copyright AnYun.ORG

            $this->headers['Accept-Ranges'] = 'bytes'; //安云网,anyun.org

            $this->headers['Content-Length'] = $this->body_size;

//copyright AnYun.ORG

        } //内容来自AnYun.ORG


//安云网,anyun.org

        $response = array('status' => $status, 'headers' => $this->headers, 'content' => $this->body, 'error' => $error); //copyright AnYun.ORG

        return $response;

//本文来自安云网

    } //安云网咨询系统

} //内容来自AnYun.ORG


//内容来自AnYun.ORG


//安云网咨询系统

function message_html($title, $banner, $detail) { //安云网咨询系统

    $error = <<<ERROR_STRING //本文来自安云网

<html><head>

//本文来自安云网

<meta http-equiv="content-type" content="text/html;charset=utf-8">

//内容来自AnYun.ORG

<title>${title}</title> //内容来自安云网

<style><!--

//内容来自AnYun.ORG

body {font-family: arial,sans-serif} //本文来自安云网

div.nav {margin-top: 1ex} //安云网咨询系统

div.nav A {font-size: 10pt; font-family: arial,sans-serif} //内容来自AnYun.ORG

span.nav {font-size: 10pt; font-family: arial,sans-serif; font-weight: bold} //安云网咨询系统

div.nav A,span.big {font-size: 12pt; color: #0000cc}

//ANYUN.ORG

div.nav A {font-size: 10pt; color: black} //copyright AnYun.ORG

A.l:link {color: #6f6f6f}

//copyright AnYun.ORG

A.u:link {color: green}

//安云网,anyun.org

//--></style>

//内容来自安云网


//内容来自AnYun.ORG

</head>

//内容来自安云网

<body text=#000000 bgcolor=#ffffff> //安云网咨询系统

<table border=0 cellpadding=2 cellspacing=0 width=100%> //copyright AnYun.ORG

<tr><td bgcolor=#3366cc><font face=arial,sans-serif color=#ffffff><b>Error</b></td></tr>

//内容来自安云网

<tr><td>&nbsp;</td></tr></table> //copyright AnYun.ORG

<blockquote> //安云网咨询系统

<H1>${banner}</H1> //内容来自AnYun.ORG

${detail} //copyright AnYun.ORG


//内容来自AnYun.ORG

<p>

//本文来自安云网

</blockquote>

//内容来自安云网

<table width=100% cellpadding=0 cellspacing=0><tr><td bgcolor=#3366cc><img alt="" width=1 height=4></td></tr></table> //内容来自AnYun.ORG

</body></html> //安云网,anyun.org

ERROR_STRING;

//安云网,anyun.org

    return $error; //内容来自AnYun.ORG

}

//ANYUN.ORG


//copyright AnYun.ORG


//安云网咨询系统

function decode_request($data) { //内容来自安云网

 | 2)));

//内容来自安云网

 | 2, $headers_length));

//copyright AnYun.ORG

 | 2+intval($headers_length)); //copyright AnYun.ORG


//安云网咨询系统

    $method  = ''; //安云网咨询系统

    $url     = '';

//ANYUN.ORG

    $headers = array(); //copyright AnYun.ORG

    $kwargs  = array(); //内容来自安云网


//copyright AnYun.ORG

    foreach (explode("\n", $headers_data) as $kv) {

//ANYUN.ORG

 | 2);

//安云网咨询系统

        $key  = $pair[0]; //内容来自安云网

        $value = trim($pair[1]); //本文来自安云网

        if ($key == 'G-Method') {

//内容来自安云网

            $method = $value;

//copyright AnYun.ORG

        } else if ($key == 'G-Url') { //内容来自AnYun.ORG

            $url = $value; //安云网,anyun.org

 | 2) == 'G-') {

//copyright AnYun.ORG

 | 2))] = $value;

//ANYUN.ORG

        } else if ($key) {

//内容来自安云网

            $key = join('-', array_map('ucfirst', explode('-', $key)));

//本文来自安云网

            $headers[$key] = $value; //ANYUN.ORG

        } //本文来自安云网

    } //安云网咨询系统

    if (isset($headers['Content-Encoding'])) {

//安云网咨询系统

        if ($headers['Content-Encoding'] == 'deflate') { //本文来自安云网

            $body = gzinflate($body);

//copyright AnYun.ORG

            $headers['Content-Length'] = strval(strlen($body));

//安云网,anyun.org

            unset($headers['Content-Encoding']);

//安云网,anyun.org

        } //安云网,anyun.org

    } //内容来自安云网

    return array($method, $url, $headers, $kwargs, $body); //安云网,anyun.org

}

//安云网咨询系统


//copyright AnYun.ORG

function print_response($status, $headers, $content, $support_gzip=true) {

//copyright AnYun.ORG

    $headers['Content-Length'] = strval(strlen($content));

//安云网,anyun.org

    $strheaders = '';

//本文来自安云网

    foreach ($headers as $key => $value) {

//本文来自安云网

        $strheaders .= $key. ':' . $value . "\n"; //安云网,anyun.org

    }

//内容来自安云网

    $content_type = isset($headers['Content-Type']) ? $headers['Content-Type'] : '';

//安云网咨询系统

 | 22) == 'application/javascript')) { //ANYUN.ORG

        $strheaders .= 'Content-Encoding:gzip'; //ANYUN.ORG

        $content = gzcompress($content);

//安云网咨询系统

    }

//内容来自安云网

    $response_headers_data = gzdeflate(rtrim($strheaders));

//安云网,anyun.org

    header('Content-Type: image/gif'); //copyright AnYun.ORG

    print(pack('nn', $status, strlen($response_headers_data)) . $response_headers_data); //内容来自安云网

    print($content); //copyright AnYun.ORG

}

//ANYUN.ORG


//内容来自安云网


//内容来自安云网

function post() //copyright AnYun.ORG

{

//本文来自安云网

    list($method, $url, $headers, $kwargs, $body) = @decode_request(@file_get_contents('php://input')); //本文来自安云网


//copyright AnYun.ORG

    if ($GLOBALS['__password__']) { //安云网咨询系统

        if (!isset($kwargs['password']) || $GLOBALS['__password__'] != $kwargs['password']) { //ANYUN.ORG

            header("HTTP/1.0 403 Forbidden"); //安云网,anyun.org

            echo '403 Forbidden'; //安云网,anyun.org

            exit(-1); //安云网咨询系统

        } //安云网咨询系统

    } //安云网咨询系统


//安云网,anyun.org

    if (isset($kwargs['hostip']) && isset($headers['Host'])) {

//内容来自AnYun.ORG

        $ip = $kwargs['hostip']; //安云网咨询系统

        $url = preg_replace('#(.+://)([\w\.\-]+)#', '${1}'.$ip, $url);

//本文来自安云网

    }

//ANYUN.ORG


//本文来自安云网

    $headers['Connection'] = 'close'; //内容来自AnYun.ORG


//ANYUN.ORG

    $urlfetch = new URLFetch();

//本文来自安云网

    $response = $urlfetch->urlfetch($url, $body, $method, $headers, False, $deadline, False);

//copyright AnYun.ORG

    $status = $response['status'];

//ANYUN.ORG

    if (200 <= $status && $status < 400) { //安云网,anyun.org

        print_response($status, $response['headers'], $response['content'], isset($headers['Accept-Encoding']) && strpos($headers['Accept-Encoding'], 'gzip'));

//本文来自安云网

    } else { //本文来自安云网

        header('HTTP/1.0 502');

//本文来自安云网

        echo message_html('502 Urlfetch Error', 'PHP Curl Urlfetch Error: ' . $status,  $response['error']); //ANYUN.ORG

    }

//本文来自安云网

}

//安云网咨询系统


//内容来自AnYun.ORG

function get() { //安云网,anyun.org

    $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']; //安云网,anyun.org

    $domain = preg_replace('/.*\\.(.+\\..+)$/', '$1', $host); //内容来自安云网

    if ($host && $host != $domain && $host != 'www'.$domain) {

//copyright AnYun.ORG

        header('Location: http://www.' . $domain);

//ANYUN.ORG

    } else {

//内容来自AnYun.ORG

        header('Location: https://www.google.com');

//copyright AnYun.ORG

    }

//内容来自AnYun.ORG

}

//本文来自安云网


//安云网咨询系统

function main() { //内容来自安云网

    if ($_SERVER['REQUEST_METHOD'] == 'POST') { //ANYUN.ORG

        post(); //本文来自安云网

    } else { //内容来自安云网

        get(); //内容来自安云网

    } //内容来自AnYun.ORG

} //本文来自安云网


//ANYUN.ORG

main(); //本文来自安云网


//ANYUN.ORG

上传到web目录配置goagent的ini即可。

//内容来自安云网

  //内容来自AnYun.ORG

6#西顾 | 2014-08-11 21:45 //安云网,anyun.org

@Mujj 万分感谢   我去琢磨一下 //安云网,anyun.org

 

//本文来自安云网

7#随随意意 | 2014-08-11 21:48 //ANYUN.ORG

这个代理不会卡么 //copyright AnYun.ORG

 

//本文来自安云网

8#Knight | 2014-08-11 21:53 //本文来自安云网

@Mujj 你把代码都贴出来了我还怎么装B。

//安云网,anyun.org

 

//本文来自安云网

9#黑色的屌丝 | 2014-08-11 22:05 //本文来自安云网

请教下这是怎么回事啊? //内容来自安云网

qq.png

//安云网咨询系统

  //内容来自安云网

10#伟大娃娃 | 2014-08-11 22:09 //ANYUN.ORG

@mujj  你他么配老子的滚轮

//ANYUN.ORG

  //安云网咨询系统

11#疯子 | 2014-08-11 22:12 //安云网咨询系统

@伟大娃娃 我这滚轮很好使,一下子滑到底! //copyright AnYun.ORG

 

//安云网,anyun.org

12#Mujj | 2014-08-12 08:33 //安云网,anyun.org

@疯子 你那是坏了 //安云网,anyun.org

  //安云网,anyun.org

13#Mujj | 2014-08-12 08:33

//安云网咨询系统

@伟大娃娃 没有代码缩放真的很蛋疼。

//安云网咨询系统

 

//安云网咨询系统

[email protected] | 2014-08-12 08:48

//安云网,anyun.org

看到滚轮坏的笑尿了 , 推荐 罗技G502 ,滚轮模式自由切换,一滑到底再也不是梦。 //ANYUN.ORG

 

//ANYUN.ORG

15#saber | 2014-08-12 09:34 //内容来自AnYun.ORG

弱弱的问一句,这算是全局代理么? //内容来自AnYun.ORG

  //安云网咨询系统

16#Jumbo | 2014-08-12 09:37

//copyright AnYun.ORG

这个咋玩。是不是跟lcx差不多

//安云网咨询系统

  //内容来自安云网

17#clzzy | 2014-08-12 09:54

//安云网,anyun.org

这会不稳定的 //ANYUN.ORG

 

//内容来自AnYun.ORG

18#动后河 | 2014-08-12 10:29

//安云网咨询系统

收藏 //内容来自AnYun.ORG

 

//内容来自AnYun.ORG

19#疯子 | 2014-08-12 11:00 //内容来自AnYun.ORG

@[email protected] +1

//copyright AnYun.ORG

 

//安云网,anyun.org

20#动后河 | 2014-08-12 11:01

//本文来自安云网

成功代理,再也不怕防火墙了,回帖感谢 //copyright AnYun.ORG

屏幕快照 2014-08-12 上午11.00.24.png //ANYUN.ORG

  //安云网,anyun.org

21#tombook | 2014-08-12 17:19 //本文来自安云网

C:\py27>python reGeorgSocksProxy.py -p 8080 -u http://xxxxxx:8080/ //copyright AnYun.ORG

tunnel.php //安云网咨询系统

Traceback (most recent call last): //本文来自安云网

  File "reGeorgSocksProxy.py", line 10, in <module> //安云网,anyun.org

    import urllib3 //copyright AnYun.ORG

ImportError: No module named urllib3

//本文来自安云网

 

//内容来自安云网

22#园长 | 2014-08-12 17:30 //安云网咨询系统

这个和我写的功能一样了嘛...

//ANYUN.ORG

  //copyright AnYun.ORG

23#tombook | 2014-08-12 18:28 //copyright AnYun.ORG

@动后河 怎么成功的 //安云网咨询系统

 

//本文来自安云网

24#Sct7p | 2014-08-12 18:56

//内容来自AnYun.ORG

用国外webshell的做翻墙稳定吗?  关键是管理员会看到流量异常吗?  如果是某些敏感关键字经过GFW的流量关键字监控的话会被墙吗?

//内容来自AnYun.ORG

 

//本文来自安云网

25#徽弘 | 2014-08-12 21:21

//copyright AnYun.ORG

@tombook 安装python urllib3模块 https://pypi.python.org/pypi/urllib3 //安云网咨询系统

  //安云网咨询系统

26#isno | 2014-08-13 19:09 //安云网咨询系统

我再做一个ISAPI的,效率更高点

//ANYUN.ORG

  //安云网,anyun.org

27#gniq | 2014-08-13 21:58 //内容来自安云网

mark下

//内容来自安云网

 

//本文来自安云网

28#laterain | 2014-08-13 23:10

//内容来自安云网

解决了在不能执行命令的情况下进入内部网络的问题,十分有用,感谢!

//copyright AnYun.ORG

  //内容来自安云网

29#xiaolan | 2014-08-14 03:09 //安云网咨询系统

@tombook  //ANYUN.ORG

urllib3要到https://pypi.python.org/pypi/urllib3下载并安装........... //ANYUN.ORG

python setup.py install

//安云网咨询系统


//安云网,anyun.org


//ANYUN.ORG


//内容来自安云网

@瞌睡龙 //本文来自安云网

在tomcat 5.x版本及以下中,tunnel.jsp会报错,原因是 //安云网,anyun.org


//安云网,anyun.org

<[email protected] import="java.nio.ByteBuffer, java.net.InetSocketAddress, java.nio.channels.SocketChannel, java.util.Arrays, java.io.IOException, java.net.UnknownHostException, java.net.Socket" trimDirectiveWhitespaces="true"%>

//ANYUN.ORG


//安云网,anyun.org

trimDirectiveWhitespaces="true" 在较低版本中不支持 //安云网咨询系统

去掉后客户端会提示Georg is not ready,不过在客户端中注释掉 //内容来自安云网


//安云网,anyun.org

    if not askGeorg(args.url):

//安云网,anyun.org

        log.info("Georg is not ready, please check url")

//ANYUN.ORG

        exit() //copyright AnYun.ORG


//安云网,anyun.org

后是可以用的.....(笨方法,不懂python) //安云网,anyun.org


//copyright AnYun.ORG

不过这样搞的话虽然可以用,但是超不稳定的(流量大点就断了)...........

//本文来自安云网

求懂python的小伙伴解决此问题..............

//内容来自安云网

  //内容来自安云网

30#mango | 2014-08-14 18:53 //安云网,anyun.org

3O~18%C474[QSOD1Y~8UR42.jpg怎么用!!!!

//安云网,anyun.org

  //安云网咨询系统

31#顺子 | 2014-08-14 19:17 //内容来自AnYun.ORG

@Knight 这个帖子的作用是在拿socks来渗内网的时候怎么方便一些。翻墙意义不大 //安云网咨询系统

  //内容来自安云网

32#Sct7p | 2014-08-26 22:09 //内容来自安云网

Traceback (most recent call last): //安云网,anyun.org

  File "reGeorgSocksProxy.py", line 10, in <module> //安云网,anyun.org

    import urllib3

//ANYUN.ORG

ImportError: No module named urllib3 //copyright AnYun.ORG

  //ANYUN.ORG

33#Sct7p | 2014-08-26 22:16 //ANYUN.ORG

C:\Users\SA\Desktop\socks 内网>python reGeorgSocksProxy.py -p 8099 -u http://10. //安云网咨询系统

1.1.88/np/socks.php //copyright AnYun.ORG

 //安云网,anyun.org

           _____ //安云网咨询系统

  _____   ______  __|___  |__  ______  _____  _____   ______ //安云网咨询系统

|     | |   ___||   ___|    ||   ___|/     \|     | |   ___|

//本文来自安云网

|     \ |   ___||   |  |    ||   ___||     ||     \ |   |  |

//ANYUN.ORG

|__|\__\|______||______|  __||______|\_____/|__|\__\|______|

//内容来自安云网

                    |_____|

//内容来自安云网

                    ... every office needs a tool like Georg

//安云网咨询系统


//内容来自安云网

  [email protected] / @_w_m__ //本文来自安云网

  [email protected] / @trowalts //本文来自安云网

  [email protected] / @kamp_staaldraad //copyright AnYun.ORG

  

//内容来自AnYun.ORG


//内容来自AnYun.ORG

[INFO   ]  Log Level set to [INFO] //内容来自AnYun.ORG

[INFO   ]  Starting socks server [127.0.0.1:8099], tunnel at //内容来自安云网

[http://10.1.1.88/socks.php]

//ANYUN.ORG

[INFO   ]  Checking if Georg is ready

//内容来自AnYun.ORG

[INFO   ]  Georg says, 'All seems fine'

//安云网,anyun.org

 

//copyright AnYun.ORG

34#Sct7p | 2014-08-26 22:16

//copyright AnYun.ORG

不是全局代理?

//copyright AnYun.ORG

  //本文来自安云网

35#Sct7p | 2014-08-26 22:42

//安云网,anyun.org

[INFO   ]  Checking if Georg is ready

//ANYUN.ORG

[INFO   ]  Georg says, 'All seems fine' //内容来自AnYun.ORG

[ERROR  ]  timed out //内容来自安云网

[ERROR  ]  timed out

//内容来自安云网

[ERROR  ]  timed out //安云网咨询系统

[ERROR  ]  timed out

//内容来自AnYun.ORG

[ERROR  ]  timed out

//copyright AnYun.ORG

[ERROR  ]  timed out //内容来自AnYun.ORG

[ERROR  ]  timed out //内容来自安云网

[ERROR  ]  timed out

//copyright AnYun.ORG

[ERROR  ]  timed out

//内容来自安云网

[ERROR  ]  timed out

//copyright AnYun.ORG

[ERROR  ]  timed out //安云网咨询系统

[ERROR  ]  timed out

//内容来自安云网

[ERROR  ]  timed out //内容来自安云网


//安云网,anyun.org


//copyright AnYun.ORG


//内容来自安云网


//内容来自AnYun.ORG

连接被重置 //ANYUN.ORG



//安云网,anyun.org

顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
验证码: 点击我更换图片
相关内容
推荐内容