安云网 - 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  //copyright AnYun.ORG

使用示例: 

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监听端口。 

//ANYUN.ORG


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

Step 3. Hack the planet :)

//安云网咨询系统

//本文来自安云网

1#MeirLin | 2014-08-11 17:22 //内容来自安云网

前排mank

//安云网咨询系统

 

//ANYUN.ORG

2#Knight | 2014-08-11 17:27

//内容来自安云网

goagent比较好用。

//内容来自AnYun.ORG

  //内容来自AnYun.ORG

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

//内容来自安云网

mark //内容来自AnYun.ORG

  //copyright AnYun.ORG

4#西顾 | 2014-08-11 18:40 //安云网,anyun.org

@Knight goagent怎样利用webshell搭代理? //ANYUN.ORG

  //安云网,anyun.org

5#Mujj | 2014-08-11 18:54 //安云网咨询系统

@西顾  //本文来自安云网

python版:

//本文来自安云网

#!/usr/bin/env python //安云网咨询系统

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

# Contributor: //安云网咨询系统

#      Phus Lu        <[email protected]>

//copyright AnYun.ORG


//内容来自AnYun.ORG

__version__ = '3.0.7' //内容来自AnYun.ORG

__password__ = ''

//ANYUN.ORG

__hostsdeny__ = ()  # __hostsdeny__ = ('.youtube.com', '.youku.com') //内容来自安云网


//内容来自安云网

import sys

//内容来自安云网

import os

//ANYUN.ORG

import re //安云网咨询系统

import time //本文来自安云网

import struct //安云网,anyun.org

import zlib //内容来自安云网

import base64 //copyright AnYun.ORG

import logging //本文来自安云网

import httplib //ANYUN.ORG

import urlparse //安云网咨询系统

import errno

//内容来自安云网

import string //copyright AnYun.ORG

try:

//安云网咨询系统

    from io import BytesIO //copyright AnYun.ORG

except ImportError: //内容来自安云网

    from cStringIO import StringIO as BytesIO //内容来自AnYun.ORG

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

//ANYUN.ORG

except ImportError: //本文来自安云网

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

try:

//内容来自安云网

    import bae.core.wsgi

//安云网咨询系统

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

    bae = None

//内容来自AnYun.ORG

try:

//内容来自安云网

    import socket //安云网,anyun.org

    import select

//copyright AnYun.ORG

except ImportError:

//copyright AnYun.ORG

    socket = None //本文来自安云网

try:

//内容来自AnYun.ORG

    import OpenSSL //ANYUN.ORG

except ImportError:

//安云网咨询系统

    OpenSSL = None //copyright AnYun.ORG


//本文来自安云网

URLFETCH_MAX | 2 //内容来自AnYun.ORG

URLFETCH_MAXSIZE = 4*1024*1024 //安云网,anyun.org

URLFETCH_DEFLATE_MAXSIZE = 4*1024*1024

//安云网,anyun.org

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


//copyright AnYun.ORG

def message_html(title, banner, detail=''): //安云网咨询系统

    MESSAGE_TEMPLATE = '''

//内容来自AnYun.ORG

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

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

    <title>$title</title> //copyright AnYun.ORG

    <style><!-- //内容来自AnYun.ORG

    body {font-family: arial,sans-serif}

//安云网,anyun.org

    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}

//ANYUN.ORG

    div.nav A,span.big {font-size: 12pt; color: #0000cc} //安云网咨询系统

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

//本文来自安云网

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

//内容来自安云网

    A.u:link {color: green}

//内容来自安云网

    //--></style>

//内容来自安云网

    </head>

//内容来自AnYun.ORG

    <body text=#000000 bgcolor=#ffffff>

//copyright AnYun.ORG

    <table border=0 cellpadding=2 cellspacing=0 width=100%> //内容来自安云网

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

//内容来自AnYun.ORG

    <tr><td> </td></tr></table> //安云网咨询系统

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

    <H1>$banner</H1>

//copyright AnYun.ORG

    $detail

//内容来自AnYun.ORG

    <p> //内容来自AnYun.ORG

    </blockquote> //内容来自AnYun.ORG

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

//安云网,anyun.org

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

    '''

//安云网,anyun.org

    return string.Template(MESSAGE_TEMPLATE).substitute(title=title, banner=banner, detail=detail)

//本文来自安云网


//安云网咨询系统


//内容来自AnYun.ORG

try:

//安云网咨询系统

    from Crypto.Cipher.ARC4 import new as _Crypto_Cipher_ARC4_new //安云网咨询系统

except ImportError: //内容来自安云网

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

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

        def __init__(self, key):

//安云网,anyun.org

            x = 0

//安云网,anyun.org

            box = range(256)

//安云网咨询系统

            for i, y in enumerate(box):

//ANYUN.ORG

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

//内容来自AnYun.ORG

                box[i], box[x] = box[x], y //安云网咨询系统

            self.__box = box //内容来自安云网

            self.__x = 0 //ANYUN.ORG

            self.__y = 0

//copyright AnYun.ORG

        def encrypt(self, data): //copyright AnYun.ORG

            out = [] //安云网,anyun.org

            out_append = out.append

//内容来自安云网

            x = self.__x

//copyright AnYun.ORG

            y = self.__y

//copyright AnYun.ORG

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

            for char in data: //本文来自安云网

                x = (x + 1) & 0xff

//本文来自安云网

                y = (y + box[x]) & 0xff

//copyright AnYun.ORG

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

//内容来自AnYun.ORG

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

//copyright AnYun.ORG

            self.__x = x

//本文来自安云网

            self.__y = y

//本文来自安云网

            return ''.join(out) //copyright AnYun.ORG


//安云网,anyun.org


//copyright AnYun.ORG

def rc4crypt(data, key):

//本文来自安云网

    return _Crypto_Cipher_ARC4_new(key).encrypt(data) if key else data

//本文来自安云网


//copyright AnYun.ORG


//内容来自安云网

class RC4FileObject(object): //ANYUN.ORG

    """fileobj for rc4""" //内容来自AnYun.ORG

    def __init__(self, stream, key): //copyright AnYun.ORG

        self.__stream = stream //内容来自安云网

        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): //内容来自AnYun.ORG

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

//内容来自安云网


//安云网,anyun.org


//内容来自AnYun.ORG

def gae_application(environ, start_response): //ANYUN.ORG

    cookie = environ.get('HTTP_COOKIE', '')

//ANYUN.ORG

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

//内容来自安云网

    if environ['REQUEST_METHOD'] == 'GET' and not cookie: //安云网,anyun.org

        if '204' in environ['QUERY_STRING']: //内容来自AnYun.ORG

            start_response('204 No Content', [])

//安云网,anyun.org

            yield ''

//内容来自AnYun.ORG

        else: //内容来自AnYun.ORG

            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)

//copyright AnYun.ORG

            start_response('200 OK', [('Content-Type', 'text/plain; charset=utf-8')]) //本文来自安云网

            yield html.encode('utf8') //copyright AnYun.ORG

        raise StopIteration //ANYUN.ORG


//安云网,anyun.org

    # inflate = lambda x:zlib.decompress(x, -zlib.MAX_WBITS) //安云网咨询系统

    wsgi_input = environ['wsgi.input'] //ANYUN.ORG

    input_data = wsgi_input.read() //内容来自AnYun.ORG


//安云网咨询系统

    try:

//内容来自AnYun.ORG

        if cookie: //内容来自安云网

            if 'rc4' not in options:

//安云网,anyun.org

                metadata = zlib.decompress(base64.b64decode(cookie), -zlib.MAX_WBITS) //copyright AnYun.ORG

                payload = input_data or ''

//安云网咨询系统

            else:

//ANYUN.ORG

                metadata = zlib.decompress(rc4crypt(base64.b64decode(cookie), __password__), -zlib.MAX_WBITS) //ANYUN.ORG

                payload = rc4crypt(input_data, __password__) if input_data else '' //安云网咨询系统

        else: //copyright AnYun.ORG

            if 'rc4' in options: //安云网,anyun.org

                input_data = rc4crypt(input_data, __password__) //copyright AnYun.ORG

            metadata_length, = struct.unpack('!h', input_data[:2]) //内容来自AnYun.ORG

            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) //内容来自安云网

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

//内容来自安云网

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

//内容来自安云网

    except (zlib.error, KeyError, ValueError): //ANYUN.ORG

        import traceback //本文来自安云网

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

//安云网咨询系统

        yield message_html('500 Internal Server Error', 'Bad Request (metadata) - Possible Wrong Password', '<pre>%s</pre>' % traceback.format_exc()) //安云网咨询系统

        raise StopIteration

//本文来自安云网


//安云网,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 'Content-Encoding' in headers:

//ANYUN.ORG

        if headers['Content-Encoding'] == 'deflate': //安云网咨询系统

            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) //copyright AnYun.ORG


//copyright AnYun.ORG

    if __password__ and __password__ != kwargs.get('password', ''): //内容来自安云网

        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


//本文来自安云网

    netloc = urlparse.urlparse(url).netloc

//本文来自安云网


//copyright AnYun.ORG

    if __hostsdeny__ and netloc.endswith(__hostsdeny__):

//本文来自安云网

        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


//copyright AnYun.ORG

    if netloc.startswith(('127.0.0.', '::1', 'localhost')): //内容来自AnYun.ORG

        start_response('400 Bad Request', [('Content-Type', 'text/html')]) //安云网,anyun.org

        html = ''.join('<a href="https://%s/">%s</a><br/>' % (x, x) for x in ('google.com', 'mail.google.com')) //内容来自安云网

        yield message_html('GoAgent %s is Running' % __version__, 'Now you can visit some websites', html) //内容来自安云网

        raise StopIteration

//copyright AnYun.ORG


//安云网咨询系统

    fetchmethod = getattr(urlfetch, method, None) //安云网,anyun.org

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

        start_response('405 Method Not Allowed', [('Content-Type', 'text/html')]) //内容来自安云网

        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 //ANYUN.ORG

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

//本文来自安云网

    accept_encoding = headers.get('Accept-Encoding', '')

//安云网,anyun.org

    errors = [] //ANYUN.ORG

    for i in xrange(int(kwargs.get('fetchmax', URLFETCH_MAX))): //安云网咨询系统

        try: //安云网,anyun.org

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

            break

//内容来自AnYun.ORG

        except apiproxy_errors.OverQuotaError as e:

//内容来自AnYun.ORG

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

        except urlfetch.DeadlineExceededError as e: //ANYUN.ORG

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

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

//内容来自安云网

            time.sleep(1)

//内容来自安云网

 | 2 //本文来自安云网

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

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

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

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

 | 2 //ANYUN.ORG

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

            errors.append('%r, deadline=%s' % (e, deadline)) //安云网咨询系统

            response = e.response //copyright 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)) //本文来自安云网

            else: //安云网,anyun.org

                headers.pop('Range', '') //内容来自AnYun.ORG

                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)))

//copyright AnYun.ORG

 | 2 //安云网咨询系统

        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))

//安云网,anyun.org

            if i == 0 and method == 'GET': //ANYUN.ORG

 | 2

//ANYUN.ORG

    else: //copyright 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'] //本文来自安云网

            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 //内容来自AnYun.ORG

        yield message_html('502 Urlfetch Error', 'Python Urlfetch Error: %r' % method,  error_string) //安云网咨询系统

        raise StopIteration //安云网,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])

//内容来自安云网


//内容来自安云网

    data = response.content

//copyright 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:

//本文来自安云网

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

//ANYUN.ORG

            compressobj = zlib.compressobj(zlib.Z_DEFAULT_COMPRESSION, zlib.DEFLATED, -zlib.MAX_WBITS, zlib.DEF_MEM_LEVEL, 0)

//copyright AnYun.ORG

            dataio = BytesIO() //ANYUN.ORG

            dataio.write('\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\xff') //ANYUN.ORG

            dataio.write(compressobj.compress(data)) //内容来自AnYun.ORG

            dataio.write(compressobj.flush())

//copyright AnYun.ORG

            dataio.write(struct.pack('<LL', zlib.crc32(data) & 0xFFFFFFFFL, len(data) & 0xFFFFFFFFL))

//本文来自安云网

            data = dataio.getvalue() //copyright AnYun.ORG

        elif 'deflate' in accept_encoding: //本文来自安云网

            response_headers['Content-Encoding'] = 'deflate' //本文来自安云网

            data = zlib.compress(data)[2:-4] //安云网,anyun.org

    if data:

//ANYUN.ORG

         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]

//安云网,anyun.org

    if 'rc4' not in options: //内容来自安云网

        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: //ANYUN.ORG

        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__) //copyright AnYun.ORG

        yield rc4crypt(data, __password__)

//安云网咨询系统


//安云网,anyun.org


//安云网,anyun.org

class LegacyHandler(object):

//本文来自安云网

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

//内容来自AnYun.ORG

    @classmethod

//本文来自安云网

    def application(cls, environ, start_response):

//安云网咨询系统

        return cls()(environ, start_response) //本文来自安云网


//本文来自安云网

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

        self.environ = environ

//ANYUN.ORG

        self.start_response = start_response //本文来自安云网

        return self.process_request()

//安云网咨询系统


//本文来自安云网

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

//本文来自安云网

        headers['Content-Length'] = str(len(content)) //安云网,anyun.org

        strheaders = '&'.join('%s=%s' % (k, v.encode('hex')) for k, v in headers.iteritems() if v) //安云网咨询系统

        #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')): //安云网咨询系统

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

//安云网咨询系统

        else:

//copyright AnYun.ORG

            data = '0%s%s%s' % (struct.pack('>3I', status, len(strheaders), len(content)), strheaders, content)

//安云网,anyun.org

        self.start_response('200 OK', [('Content-type', content_type)])

//安云网咨询系统

        return [data] //ANYUN.ORG


//内容来自安云网

    def send_notify(self, method, url, status, content): //安云网,anyun.org

        logging.warning('%r Failed: url=%r, status=%r', method, url, status) //安云网咨询系统

        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


//copyright AnYun.ORG

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

        environ = self.environ

//本文来自安云网

        if environ['REQUEST_METHOD'] == 'GET': //copyright AnYun.ORG

            redirect_url = 'https://%s/2' % environ['HTTP_HOST'] //安云网咨询系统

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

//本文来自安云网

            return [redirect_url] //copyright AnYun.ORG


//内容来自安云网

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

//安云网,anyun.org

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

//内容来自AnYun.ORG


//本文来自安云网

        method = request['method']

//ANYUN.ORG

        url = request['url'] //内容来自AnYun.ORG

        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


//安云网咨询系统

        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

        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())) //ANYUN.ORG

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


//内容来自AnYun.ORG

        errors = [] //本文来自安云网

        for i in xrange(URLFETCH_MAX if 'fetchmax' not in request else int(request['fetchmax'])): //本文来自安云网

            try: //内容来自安云网

                response = urlfetch.fetch(url, payload, fetchmethod, headers, False, False, deadline, False) //安云网,anyun.org

                break //本文来自安云网

            except apiproxy_errors.OverQuotaError as e:

//本文来自安云网

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

            except urlfetch.DeadlineExceededError as e: //安云网,anyun.org

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

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

//本文来自安云网

                time.sleep(1)

//copyright AnYun.ORG

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

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

//ANYUN.ORG

                logging.error('DownloadError(deadline=%s, url=%r)', deadline, url) //安云网,anyun.org

                time.sleep(1) //安云网,anyun.org

            except urlfetch.InvalidURLError as e: //安云网咨询系统

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

            except urlfetch.ResponseTooLargeError as e:

//copyright AnYun.ORG

                response = e.response //本文来自安云网

                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 '') //安云网,anyun.org

                if m is None:

//内容来自AnYun.ORG

                    headers['Range'] = 'bytes=0-%d' % URLFETCH_MAXSIZE

//copyright AnYun.ORG

                else: //安云网咨询系统

                    headers.pop('Range', '')

//ANYUN.ORG

                    headers.pop('range', '') //内容来自AnYun.ORG

                    start = int(m.group(1))

//本文来自安云网

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

//安云网,anyun.org

 | 2

//ANYUN.ORG

            except Exception as e:

//copyright AnYun.ORG

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

//内容来自安云网

        else: //本文来自安云网

            return self.send_notify(method, url, 500, 'Python Server: Urlfetch error: %s' % errors) //安云网咨询系统


//内容来自安云网

        headers = response.headers //安云网,anyun.org

        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)

//内容来自安云网


//copyright AnYun.ORG


//安云网咨询系统

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

    try: //安云网咨询系统

        timecount = timeout //安云网咨询系统

        while 1: //安云网咨询系统

            timecount -= tick

//copyright AnYun.ORG

            if timecount <= 0:

//内容来自安云网

                break

//内容来自AnYun.ORG

            (ins, _, errors) = select.select([local, remote], [], [local, remote], tick) //本文来自安云网

            if errors:

//安云网咨询系统

                break //内容来自安云网

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

                for sock in ins:

//内容来自AnYun.ORG

                    data = sock.recv(bufsize)

//安云网,anyun.org

                    if trans: //copyright AnYun.ORG

                        data = data.translate(trans) //安云网咨询系统

                    if data:

//ANYUN.ORG

                        if sock is remote:

//内容来自AnYun.ORG

                            local.sendall(data)

//copyright AnYun.ORG

                            timecount = maxpong or timeout

//内容来自安云网

                            if pongcallback: //copyright AnYun.ORG

                                try: //内容来自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)

//ANYUN.ORG

                                finally: //安云网,anyun.org

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

                        else:

//安云网,anyun.org

                            remote.sendall(data)

//本文来自安云网

                            timecount = maxping or timeout

//内容来自安云网

                    else: //本文来自安云网

                        return //安云网咨询系统

    except socket.error as e: //ANYUN.ORG

        if e[0] not in (10053, 10054, 10057, errno.EPIPE): //copyright AnYun.ORG

            raise

//本文来自安云网

    finally: //内容来自安云网

        if local:

//内容来自安云网

            local.close() //安云网,anyun.org

        if remote:

//本文来自安云网

            remote.close() //内容来自安云网


//内容来自AnYun.ORG


//内容来自AnYun.ORG

def paas_application(environ, start_response):

//安云网,anyun.org

    if environ['REQUEST_METHOD'] == 'GET': //copyright AnYun.ORG

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

//内容来自安云网

        raise StopIteration

//安云网咨询系统


//安云网咨询系统

    wsgi_input = environ['wsgi.input']

//内容来自AnYun.ORG

    data = wsgi_input.read(2) //安云网,anyun.org

    metadata_length, = struct.unpack('!h', data) //内容来自AnYun.ORG

    metadata = wsgi_input.read(metadata_length) //本文来自安云网


//内容来自安云网

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

    headers = {} //copyright AnYun.ORG

    for line in metadata.splitlines(): //本文来自安云网

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

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

//安云网咨询系统

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

//内容来自AnYun.ORG

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

    url = headers.pop('G-Url') //内容来自安云网

    timeout = URLFETCH_TIMEOUT

//copyright AnYun.ORG


//内容来自安云网

    kwargs = {}

//安云网咨询系统

    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'): //安云网,anyun.org

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

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

//copyright AnYun.ORG

        conn.request('GET', '/') //内容来自安云网

        response = conn.getresponse(True)

//安云网,anyun.org

        status_line = '%s %s' % (response.status, httplib.responses.get(response.status, 'OK')) //安云网,anyun.org

        start_response(status_line, response.getheaders())

//安云网,anyun.org

        yield response.read() //安云网咨询系统

        raise StopIteration //copyright AnYun.ORG


//copyright AnYun.ORG

    if __hostsdeny__ and urlparse.urlparse(url).netloc.endswith(__hostsdeny__): //ANYUN.ORG

        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

//安云网,anyun.org


//本文来自安云网

    headers['Connection'] = 'close' //ANYUN.ORG

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

    if 'Content-Encoding' in headers:

//内容来自AnYun.ORG

        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

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


//安云网,anyun.org

    if method == 'CONNECT': //ANYUN.ORG

        if not socket: //内容来自AnYun.ORG

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

//copyright AnYun.ORG

            yield message_html('403 Forbidden CONNECT', 'socket not available', detail='`import socket` raised ImportError') //内容来自安云网

            raise StopIteration

//本文来自安云网

        rfile = wsgi_input.rfile

//ANYUN.ORG

        sock = rfile._sock //安云网,anyun.org

        host, _, port = url.rpartition(':') //ANYUN.ORG

        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: //安云网咨询系统

        try:

//安云网,anyun.org

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

//本文来自安云网

            HTTPConnection = httplib.HTTPSConnection if scheme == 'https' else httplib.HTTPConnection

//本文来自安云网

            if params:

//内容来自安云网

                path += ';' + params //本文来自安云网

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

                path += '?' + query //内容来自AnYun.ORG

            conn = HTTPConnection(netloc, timeout=timeout)

//copyright AnYun.ORG

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

//本文来自安云网

            response = conn.getresponse()

//ANYUN.ORG


//安云网,anyun.org

            headers_data = zlib.compress('\n'.join('%s:%s' % (k.title(), v) for k, v in response.getheaders()))[2:-4] //内容来自AnYun.ORG

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

//本文来自安云网

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

            while 1:

//安云网,anyun.org

                data = response.read(8192)

//copyright AnYun.ORG

                if not data:

//安云网,anyun.org

                    response.close()

//安云网,anyun.org

                    break //内容来自安云网

                yield data

//内容来自AnYun.ORG

        except httplib.HTTPException:

//安云网咨询系统

            raise //本文来自安云网


//本文来自安云网


//本文来自安云网

app = gae_application if urlfetch else paas_application

//安云网咨询系统

if bae:

//ANYUN.ORG

    application = bae.core.wsgi.WSGIApplication(app) //内容来自安云网

elif sae:

//ANYUN.ORG

    application = sae.create_wsgi_app(app)

//内容来自AnYun.ORG

else: //安云网咨询系统

    application = app //内容来自安云网


//安云网,anyun.org

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

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

    import gevent //ANYUN.ORG

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

    import gevent.wsgi

//copyright AnYun.ORG

    import gevent.monkey //内容来自安云网

    gevent.monkey.patch_all(dns=gevent.version_info[0] >= 1)

//本文来自安云网


//copyright AnYun.ORG

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

//安云网咨询系统

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

//内容来自安云网

    server.serve_forever() //内容来自AnYun.ORG


//本文来自安云网


//ANYUN.ORG

PHP版: //安云网,anyun.org

<?php //安云网,anyun.org


//copyright AnYun.ORG

// Note:

//内容来自安云网

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

//安云网咨询系统

//     Otherwise, dont forgot set [paas]passowrd in proxy.ini //内容来自AnYun.ORG

// Contributor:

//安云网,anyun.org

//     Phus Lu        <[email protected]> //内容来自安云网


//内容来自AnYun.ORG

$__version__  = '3.0.5'; //安云网,anyun.org

$__password__ = '123';

//安云网咨询系统

$__timeout__ | 20;

//安云网咨询系统


//ANYUN.ORG

class URLFetch {

//内容来自AnYun.ORG

    protected $body_maxsize = 4194304;

//内容来自安云网

    protected $headers = array(); //安云网,anyun.org

    protected $body = '';

//内容来自安云网

    protected $body_size = 0; //copyright AnYun.ORG


//本文来自安云网

    function __construct() {

//安云网,anyun.org

    }

//copyright AnYun.ORG


//内容来自AnYun.ORG

    function urlfetch_readheader($ch, $header) {

//内容来自安云网

 | 2)); //copyright AnYun.ORG

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

//本文来自安云网

            $key = join('-', array_map('ucfirst', explode('-', $kv[0]))); //内容来自AnYun.ORG

            $value = $kv[1];

//ANYUN.ORG

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

//内容来自安云网

                if (!array_key_exists('Set-Cookie', $this->headers)) {

//ANYUN.ORG

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

                } else {

//内容来自AnYun.ORG

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

//内容来自AnYun.ORG

                } //内容来自AnYun.ORG

            } else { //内容来自AnYun.ORG

                $this->headers[$key] = $kv[1]; //内容来自安云网

            }

//安云网,anyun.org

        } //内容来自AnYun.ORG

        return strlen($header);

//ANYUN.ORG

    } //本文来自安云网


//安云网,anyun.org

    function urlfetch_readbody($ch, $data) { //copyright AnYun.ORG

        $bytes = strlen($data);

//内容来自安云网

        if ($this->body_size + $bytes > $this->body_maxsize) {

//安云网,anyun.org

            return -1; //内容来自安云网

        }

//内容来自AnYun.ORG

        $this->body_size += $bytes;

//内容来自安云网

        $this->body .= $data; //ANYUN.ORG

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

    } //内容来自AnYun.ORG


//ANYUN.ORG

    function urlfetch($url, $payload, $method, $headers, $follow_redirects, $deadline, $validate_certificate) { //安云网,anyun.org


//安云网,anyun.org

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

        $this->body = ''; //内容来自AnYun.ORG

        $this->body_size = 0; //安云网,anyun.org


//copyright AnYun.ORG

        if ($payload) { //安云网,anyun.org

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

//ANYUN.ORG

        }

//内容来自AnYun.ORG

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


//copyright AnYun.ORG

        $curl_opt = array();

//ANYUN.ORG


//内容来自AnYun.ORG

        $curl_opt[CURLOPT_TIMEOUT]        = $deadline; //内容来自安云网

        $curl_opt[CURLOPT_CONNECTTIMEOUT] = $deadline; //本文来自安云网

        $curl_opt[CURLOPT_RETURNTRANSFER] = true; //安云网咨询系统

        $curl_opt[CURLOPT_BINARYTRANSFER] = true; //内容来自AnYun.ORG

        $curl_opt[CURLOPT_FAILONERROR]    = true; //内容来自AnYun.ORG


//安云网,anyun.org

        if (!$follow_redirects) {

//copyright AnYun.ORG

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

        }

//ANYUN.ORG


//内容来自AnYun.ORG

        if ($deadline) { //ANYUN.ORG

            $curl_opt[CURLOPT_CONNECTTIMEOUT] = $deadline;

//安云网,anyun.org

            $curl_opt[CURLOPT_TIMEOUT] = $deadline;

//安云网,anyun.org

        }

//内容来自AnYun.ORG


//内容来自AnYun.ORG

        if (!$validate_certificate) { //安云网咨询系统

            $curl_opt[CURLOPT_SSL_VERIFYPEER] = false; //内容来自AnYun.ORG

            $curl_opt[CURLOPT_SSL_VERIFYHOST] = false; //本文来自安云网

        }

//安云网,anyun.org


//安云网,anyun.org

        switch (strtoupper($method)) {

//ANYUN.ORG

            case 'HEAD':

//内容来自安云网

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

                break;

//内容来自AnYun.ORG

            case 'GET':

//本文来自安云网

                break; //本文来自安云网

            case 'POST':

//本文来自安云网

                $curl_opt[CURLOPT_POST] = true;

//内容来自安云网

                $curl_opt[CURLOPT_POSTFIELDS] = $payload;

//copyright AnYun.ORG

                break;

//本文来自安云网

            case 'PUT': //ANYUN.ORG

            case 'DELETE':

//ANYUN.ORG

                $curl_opt[CURLOPT_CUSTOMREQUEST] = $method;

//copyright AnYun.ORG

                $curl_opt[CURLOPT_POSTFIELDS] = $payload;

//内容来自AnYun.ORG

                break;

//安云网咨询系统

            default:

//内容来自安云网

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

                exit(-1); //内容来自AnYun.ORG

        } //内容来自AnYun.ORG


//安云网,anyun.org

        $header_array = array(); //安云网咨询系统

        foreach ($headers as $key => $value) { //安云网咨询系统

            if ($key) { //内容来自安云网

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

//内容来自AnYun.ORG

            } //内容来自安云网

        }

//ANYUN.ORG

        $curl_opt[CURLOPT_HTTPHEADER] = $header_array; //内容来自安云网


//copyright AnYun.ORG

        $curl_opt[CURLOPT_HEADER]         = false;

//安云网,anyun.org

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

        $curl_opt[CURLOPT_WRITEFUNCTION]  = array(&$this, 'urlfetch_readbody'); //内容来自AnYun.ORG


//内容来自安云网

        $ch = curl_init($url); //copyright AnYun.ORG

        curl_setopt_array($ch, $curl_opt);

//内容来自安云网

        $ret = curl_exec($ch);

//安云网咨询系统

        $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);

//内容来自AnYun.ORG

        $errno = curl_errno($ch); //安云网,anyun.org

        if ($errno)

//安云网咨询系统

        { //copyright AnYun.ORG

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

//ANYUN.ORG

        } else {

//安云网咨询系统

            $error = '';

//安云网,anyun.org

        } //内容来自安云网

        curl_close($ch);

//ANYUN.ORG


//安云网,anyun.org

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

//本文来自安云网

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

//copyright AnYun.ORG


//安云网,anyun.org

 | 200 && $errno == 23 && $content_length && $this->body_size < $content_length) { //安云网咨询系统

 | 206;

//安云网咨询系统

            $range_end = $this->body_size - 1;

//copyright AnYun.ORG

            $this->headers['Content-Range'] = "bytes 0-$range_end/$content_length"; //本文来自安云网

            $this->headers['Accept-Ranges'] = 'bytes'; //内容来自AnYun.ORG

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

//ANYUN.ORG

        } //copyright AnYun.ORG


//ANYUN.ORG

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

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

    }

//copyright AnYun.ORG

} //安云网,anyun.org


//安云网咨询系统


//安云网咨询系统

function message_html($title, $banner, $detail) { //copyright AnYun.ORG

    $error = <<<ERROR_STRING //安云网,anyun.org

<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}

//copyright AnYun.ORG

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

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

//内容来自AnYun.ORG

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

A.u:link {color: green}

//安云网咨询系统

//--></style> //安云网咨询系统


//内容来自AnYun.ORG

</head>

//本文来自安云网

<body text=#000000 bgcolor=#ffffff> //本文来自安云网

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

//安云网咨询系统

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

//ANYUN.ORG

<tr><td>&nbsp;</td></tr></table>

//内容来自安云网

<blockquote>

//安云网咨询系统

<H1>${banner}</H1>

//ANYUN.ORG

${detail} //ANYUN.ORG


//内容来自安云网

<p> //内容来自AnYun.ORG

</blockquote>

//ANYUN.ORG

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

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

ERROR_STRING; //ANYUN.ORG

    return $error;

//安云网咨询系统

} //ANYUN.ORG


//本文来自安云网


//copyright AnYun.ORG

function decode_request($data) {

//本文来自安云网

 | 2))); //内容来自AnYun.ORG

 | 2, $headers_length)); //内容来自AnYun.ORG

 | 2+intval($headers_length)); //本文来自安云网


//安云网咨询系统

    $method  = '';

//内容来自安云网

    $url     = ''; //ANYUN.ORG

    $headers = array(); //ANYUN.ORG

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


//安云网咨询系统

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

//内容来自AnYun.ORG

 | 2);

//ANYUN.ORG

        $key  = $pair[0]; //ANYUN.ORG

        $value = trim($pair[1]); //copyright AnYun.ORG

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

//本文来自安云网

            $method = $value; //本文来自安云网

        } else if ($key == 'G-Url') { //本文来自安云网

            $url = $value; //内容来自安云网

 | 2) == 'G-') {

//内容来自安云网

 | 2))] = $value;

//内容来自AnYun.ORG

        } else if ($key) {

//安云网,anyun.org

            $key = join('-', array_map('ucfirst', explode('-', $key))); //内容来自AnYun.ORG

            $headers[$key] = $value;

//内容来自AnYun.ORG

        } //安云网咨询系统

    } //内容来自安云网

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

//内容来自安云网

        if ($headers['Content-Encoding'] == 'deflate') { //内容来自AnYun.ORG

            $body = gzinflate($body); //安云网,anyun.org

            $headers['Content-Length'] = strval(strlen($body)); //copyright AnYun.ORG

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

//安云网,anyun.org

        } //安云网,anyun.org

    } //内容来自AnYun.ORG

    return array($method, $url, $headers, $kwargs, $body); //copyright AnYun.ORG

}

//copyright AnYun.ORG


//copyright AnYun.ORG

function print_response($status, $headers, $content, $support_gzip=true) { //内容来自安云网

    $headers['Content-Length'] = strval(strlen($content)); //内容来自AnYun.ORG

    $strheaders = '';

//本文来自安云网

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

//本文来自安云网

        $strheaders .= $key. ':' . $value . "\n";

//本文来自安云网

    }

//copyright AnYun.ORG

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

//copyright AnYun.ORG

 | 22) == 'application/javascript')) {

//copyright AnYun.ORG

        $strheaders .= 'Content-Encoding:gzip';

//ANYUN.ORG

        $content = gzcompress($content); //内容来自AnYun.ORG

    } //内容来自AnYun.ORG

    $response_headers_data = gzdeflate(rtrim($strheaders)); //本文来自安云网

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

    print(pack('nn', $status, strlen($response_headers_data)) . $response_headers_data); //安云网咨询系统

    print($content); //本文来自安云网

}

//安云网咨询系统


//copyright AnYun.ORG


//内容来自AnYun.ORG

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

{

//ANYUN.ORG

    list($method, $url, $headers, $kwargs, $body) = @decode_request(@file_get_contents('php://input'));

//内容来自安云网


//安云网咨询系统

    if ($GLOBALS['__password__']) { //ANYUN.ORG

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

//内容来自安云网

            header("HTTP/1.0 403 Forbidden");

//本文来自安云网

            echo '403 Forbidden'; //ANYUN.ORG

            exit(-1);

//本文来自安云网

        } //内容来自安云网

    } //本文来自安云网


//安云网咨询系统

    if (isset($kwargs['hostip']) && isset($headers['Host'])) { //内容来自AnYun.ORG

        $ip = $kwargs['hostip'];

//安云网,anyun.org

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

//ANYUN.ORG

    } //本文来自安云网


//内容来自AnYun.ORG

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

//安云网,anyun.org


//内容来自AnYun.ORG

    $urlfetch = new URLFetch();

//安云网咨询系统

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

//内容来自安云网

    $status = $response['status']; //ANYUN.ORG

    if (200 <= $status && $status < 400) {

//内容来自安云网

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

//安云网咨询系统

    } else {

//内容来自安云网

        header('HTTP/1.0 502'); //ANYUN.ORG

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

//安云网咨询系统

    } //安云网,anyun.org

} //内容来自安云网


//安云网,anyun.org

function get() { //安云网咨询系统

    $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']; //本文来自安云网

    $domain = preg_replace('/.*\\.(.+\\..+)$/', '$1', $host);

//安云网咨询系统

    if ($host && $host != $domain && $host != 'www'.$domain) { //本文来自安云网

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

    } else {

//ANYUN.ORG

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

//安云网咨询系统

    } //本文来自安云网

}

//安云网,anyun.org


//安云网,anyun.org

function main() {

//copyright AnYun.ORG

    if ($_SERVER['REQUEST_METHOD'] == 'POST') {

//本文来自安云网

        post(); //copyright AnYun.ORG

    } else {

//内容来自AnYun.ORG

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

    } //copyright AnYun.ORG

} //内容来自AnYun.ORG


//copyright AnYun.ORG

main(); //安云网,anyun.org


//安云网咨询系统

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

//安云网,anyun.org

 

//内容来自安云网

6#西顾 | 2014-08-11 21:45

//本文来自安云网

@Mujj 万分感谢   我去琢磨一下 //ANYUN.ORG

 

//内容来自AnYun.ORG

7#随随意意 | 2014-08-11 21:48

//安云网,anyun.org

这个代理不会卡么

//内容来自AnYun.ORG

 

//ANYUN.ORG

8#Knight | 2014-08-11 21:53 //内容来自AnYun.ORG

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

//安云网咨询系统

  //内容来自安云网

9#黑色的屌丝 | 2014-08-11 22:05 //安云网咨询系统

请教下这是怎么回事啊? //安云网,anyun.org

qq.png

//内容来自AnYun.ORG

  //本文来自安云网

10#伟大娃娃 | 2014-08-11 22:09 //内容来自AnYun.ORG

@mujj  你他么配老子的滚轮

//ANYUN.ORG

  //本文来自安云网

11#疯子 | 2014-08-11 22:12 //ANYUN.ORG

@伟大娃娃 我这滚轮很好使,一下子滑到底! //内容来自安云网

 

//本文来自安云网

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

//安云网,anyun.org

@疯子 你那是坏了 //copyright AnYun.ORG

  //本文来自安云网

13#Mujj | 2014-08-12 08:33 //内容来自AnYun.ORG

@伟大娃娃 没有代码缩放真的很蛋疼。 //安云网咨询系统

 

//内容来自安云网

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

//内容来自AnYun.ORG

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

//copyright AnYun.ORG

  //内容来自AnYun.ORG

15#saber | 2014-08-12 09:34

//内容来自安云网

弱弱的问一句,这算是全局代理么?

//本文来自安云网

 

//内容来自安云网

16#Jumbo | 2014-08-12 09:37 //本文来自安云网

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

//本文来自安云网

 

//内容来自AnYun.ORG

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

//本文来自安云网

这会不稳定的

//ANYUN.ORG

 

//内容来自安云网

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

//copyright AnYun.ORG

收藏 //copyright AnYun.ORG

 

//安云网咨询系统

19#疯子 | 2014-08-12 11:00 //内容来自安云网

@[email protected] +1

//安云网咨询系统

  //本文来自安云网

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

//copyright AnYun.ORG

成功代理,再也不怕防火墙了,回帖感谢

//内容来自AnYun.ORG

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

//安云网,anyun.org

  //安云网,anyun.org

21#tombook | 2014-08-12 17:19

//copyright AnYun.ORG

C:\py27>python reGeorgSocksProxy.py -p 8080 -u http://xxxxxx:8080/ //本文来自安云网

tunnel.php //ANYUN.ORG

Traceback (most recent call last):

//内容来自安云网

  File "reGeorgSocksProxy.py", line 10, in <module>

//内容来自AnYun.ORG

    import urllib3

//copyright AnYun.ORG

ImportError: No module named urllib3

//本文来自安云网

 

//copyright AnYun.ORG

22#园长 | 2014-08-12 17:30 //ANYUN.ORG

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

//内容来自AnYun.ORG

  //copyright AnYun.ORG

23#tombook | 2014-08-12 18:28 //安云网咨询系统

@动后河 怎么成功的

//ANYUN.ORG

 

//内容来自AnYun.ORG

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

//内容来自AnYun.ORG

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

  //内容来自AnYun.ORG

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

//安云网,anyun.org

@tombook 安装python urllib3模块 https://pypi.python.org/pypi/urllib3

//ANYUN.ORG

  //ANYUN.ORG

26#isno | 2014-08-13 19:09 //ANYUN.ORG

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

//内容来自安云网

 

//安云网咨询系统

27#gniq | 2014-08-13 21:58

//copyright AnYun.ORG

mark下

//内容来自AnYun.ORG

  //安云网咨询系统

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

//内容来自安云网

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

 

//安云网咨询系统

29#xiaolan | 2014-08-14 03:09 //ANYUN.ORG

@tombook  //ANYUN.ORG

urllib3要到https://pypi.python.org/pypi/urllib3下载并安装........... //本文来自安云网

python setup.py install

//安云网咨询系统


//copyright AnYun.ORG


//安云网,anyun.org


//copyright AnYun.ORG

@瞌睡龙 //内容来自AnYun.ORG

在tomcat 5.x版本及以下中,tunnel.jsp会报错,原因是 //copyright 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

trimDirectiveWhitespaces="true" 在较低版本中不支持

//安云网咨询系统

去掉后客户端会提示Georg is not ready,不过在客户端中注释掉

//ANYUN.ORG


//安云网咨询系统

    if not askGeorg(args.url):

//本文来自安云网

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

//内容来自安云网

        exit()

//内容来自AnYun.ORG


//内容来自AnYun.ORG

后是可以用的.....(笨方法,不懂python) //内容来自AnYun.ORG


//安云网咨询系统

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

求懂python的小伙伴解决此问题.............. //copyright AnYun.ORG

 

//copyright AnYun.ORG

30#mango | 2014-08-14 18:53

//本文来自安云网

3O~18%C474[QSOD1Y~8UR42.jpg怎么用!!!! //本文来自安云网

 

//ANYUN.ORG

31#顺子 | 2014-08-14 19:17

//安云网,anyun.org

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

 

//本文来自安云网

32#Sct7p | 2014-08-26 22:09

//内容来自AnYun.ORG

Traceback (most recent call last):

//内容来自安云网

  File "reGeorgSocksProxy.py", line 10, in <module>

//本文来自安云网

    import urllib3 //本文来自安云网

ImportError: No module named urllib3 //copyright 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 //内容来自安云网

 //安云网,anyun.org

           _____ //copyright AnYun.ORG

  _____   ______  __|___  |__  ______  _____  _____   ______ //内容来自AnYun.ORG

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

//内容来自AnYun.ORG

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

//copyright AnYun.ORG

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

//copyright AnYun.ORG

                    |_____|

//内容来自安云网

                    ... every office needs a tool like Georg

//本文来自安云网


//copyright AnYun.ORG

  [email protected] / @_w_m__

//本文来自安云网

  [email protected] / @trowalts //内容来自安云网

  [email protected] / @kamp_staaldraad

//copyright AnYun.ORG

   //内容来自AnYun.ORG


//copyright AnYun.ORG

[INFO   ]  Log Level set to [INFO]

//本文来自安云网

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

[http://10.1.1.88/socks.php] //本文来自安云网

[INFO   ]  Checking if Georg is ready //安云网咨询系统

[INFO   ]  Georg says, 'All seems fine' //安云网,anyun.org

 

//本文来自安云网

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

//copyright AnYun.ORG

不是全局代理? //内容来自安云网

  //本文来自安云网

35#Sct7p | 2014-08-26 22:42 //安云网,anyun.org

[INFO   ]  Checking if Georg is ready //copyright AnYun.ORG

[INFO   ]  Georg says, 'All seems fine' //安云网咨询系统

[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

//内容来自安云网

[ERROR  ]  timed out

//安云网,anyun.org

[ERROR  ]  timed out //安云网,anyun.org

[ERROR  ]  timed out //安云网,anyun.org

[ERROR  ]  timed out

//ANYUN.ORG

[ERROR  ]  timed out

//ANYUN.ORG

[ERROR  ]  timed out //本文来自安云网

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


//安云网咨询系统


//内容来自安云网


//内容来自AnYun.ORG


//安云网咨询系统

连接被重置 //本文来自安云网



//内容来自安云网

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