Created
February 16, 2016 19:21
-
-
Save GreeeenApple/65b8f65c678ce381263b to your computer and use it in GitHub Desktop.
already fixed(?) yo yo
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
import os | |
from libmproxy import controller, proxy | |
from libmproxy.proxy.server import ProxyServer | |
import commands | |
def themerequest(flow): | |
target_host = "dl.shop.line.naver.jp" | |
target_path = "theme.zip" | |
replace_path = "/themeshop/v1/products/5b/8f/d2/5b8fd2d0-03ba-45d2-9c81-c5ad9b1abfe0/2/ANDROID/theme.zip" | |
p = flow.request.path | |
if target_host in flow.request.host: | |
if target_host in flow.request.headers["Host"]: | |
if p.find(target_path) != -1: | |
print flow | |
flow.request.path = replace_path | |
def stamprequest(flow): | |
edit_host = "edit.net" | |
target_host = "dl.stickershop.line.naver.jp" | |
target_path1 = "stickers.zip" | |
target_path2 = "stickerpack.zip" | |
replace_path1 = "/products/0/0/1/" #/stickershop/v1/product/ | |
replace_path2 = "/android/stickers.zip" #/android/stickers.zip | |
p = flow.request.path | |
if target_host in flow.request.host: | |
if target_host in flow.request.headers["Host"]: | |
if p.find(target_path1) != -1 or p.find(target_path2) != -1: | |
#print flow | |
flow.request.path = replace_path1 + commands.getoutput("cat stamp") + replace_path2 | |
elif edit_host in flow.request.host: | |
num = p.split("/")[1] | |
try: | |
int(num, 10) | |
commands.getoutput("echo " + num + " > stamp") | |
except: | |
pass | |
class StickyMaster(controller.Master): | |
def __init__(self, server): | |
controller.Master.__init__(self, server) | |
def run(self): | |
try: | |
return controller.Master.run(self) | |
except KeyboardInterrupt: | |
self.shutdown() | |
def handle_request(self, flow): | |
stamprequest(flow) | |
themerequest(flow) | |
flow.reply() | |
def handle_response(self, flow): | |
print "------------------response--------------------" | |
print flow | |
flow.reply() | |
config = proxy.ProxyConfig(port=8080) | |
server = ProxyServer(config) | |
m = StickyMaster(server) | |
m.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment