Created
August 7, 2013 12:26
-
-
Save jamslater/6173615 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import SocketServer | |
import SimpleHTTPServer | |
import urllib | |
import urllib2 | |
import urlparse | |
import re | |
class EliProxy(SimpleHTTPServer.SimpleHTTPRequestHandler): | |
def do_POST(self): | |
headers = dict(self.headers) | |
post_data = self.rfile.read(int(headers["content-length"])) | |
# Forward POST data to remote server | |
req = urllib2.Request(self.path, post_data, headers) | |
rfile = urllib2.urlopen(req) | |
# Modify responses for one specific domain (lightly obfuscated) and path | |
split_url = urlparse.urlsplit(self.path) | |
if split_url.netloc[::-1] == 'ten.setisbeweruza.emaghsalf' and split_url.path == '/Level.aspx': | |
response = rfile.read() | |
response = re.sub("Human(Run|Aim)Speed='[\d\.]+'", "Human\g<1>Speed='1'", response) | |
self.wfile.write(response) | |
else: | |
self.copyfile(rfile, self.wfile) | |
# Forward GET requests to remote server, unaltered | |
def do_GET(self): | |
self.copyfile(urllib.urlopen(self.path), self.wfile) | |
httpd = SocketServer.ForkingTCPServer(('', 8080), EliProxy) | |
httpd.serve_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment