Skip to content

Instantly share code, notes, and snippets.

@mengskysama
Created June 26, 2017 13:24
Show Gist options
  • Save mengskysama/ee4aa0042a6dedc9f3babd4501367de3 to your computer and use it in GitHub Desktop.
Save mengskysama/ee4aa0042a6dedc9f3babd4501367de3 to your computer and use it in GitHub Desktop.
trackerhack
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
import tornado.httpclient
import re
from tornado.options import define, options
from tornado import gen
@gen.coroutine
def handle_request(request):
uri = request.uri
print uri
uri = re.sub('uploaded=(\d+)', lambda m: 'uploaded=' + str(int(int(m.group(1)) * 4)), uri)
http_client = tornado.httpclient.AsyncHTTPClient()
req = tornado.httpclient.HTTPRequest(uri,
headers = {'User-Agent': request.headers['User-Agent'],
'Accept-Encoding': 'gzip',
'Connection': 'close'},
use_gzip=True,
follow_redirects=True)
try:
res = yield http_client.fetch(req)
request.write('HTTP/1.1 200 OK\r\nContent-Length: %d\r\n\r\n%s' % (
len(res.body), res.body)
)
except tornado.httpclient.HTTPError, code:
print 'HTTPError except Code' + str(code)
msg = 'NexusPHP Return a Error Code :' + str(code)
ret = 'd14:failure reason' + str(len(msg)) + ':' + msg + 'e'
request.write('HTTP/1.1 200 OK\r\nContent-Length: %d\r\n\r\n%s' % (
len(ret), ret)
)
finally:
request.finish()
def main():
http_server = tornado.httpserver.HTTPServer(handle_request)
http_server.listen(listen_port, '127.0.0.1')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment