Skip to content

Instantly share code, notes, and snippets.

@caiguanhao
Created January 24, 2017 10:01
Show Gist options
  • Save caiguanhao/e16b93b2cc504b0ce8ee42323cf255ba to your computer and use it in GitHub Desktop.
Save caiguanhao/e16b93b2cc504b0ce8ee42323cf255ba to your computer and use it in GitHub Desktop.
偷步进入确认出借页面
# 1. Start the container:

docker run -d -p 6666:8080 --name proxy -v="$PWD:/host" -v="$PWD/m:/home/mitmproxy/.mitmproxy" mitmproxy/mitmproxy mitmdump -qs /host/hyr.py

# 2. Set HTTP proxy (SERVER_IP:6666)
# 3. Visit http://mitm.it and install certificate
import subprocess
import json
class Injector:
KEY = '623739666634326663396430343561656433383332343361'
IV = '3234736464657873'
def __init__(self):
return
def encrypt(self, string):
cmd = ['openssl', 'des-ede3-cbc', '-e', '-a', '-A', '-nopad', '-K', self.KEY, '-iv', self.IV]
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
if isinstance(string, str):
string = string.encode('utf-8')
out, err = p.communicate(string)
return out.decode('utf-8')
def decrypt(self, string):
cmd = ['openssl', 'des-ede3-cbc', '-d', '-a', '-A', '-nopad', '-K', self.KEY, '-iv', self.IV]
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
if isinstance(string, str):
string = string.encode('utf-8')
out, err = p.communicate(string)
return out.decode('utf-8')
def modify_list(self, string):
resp = json.loads(string)
resp['data']['yn_info']['btn_lend_text'] = '偷步抢'
resp['data']['yn_info']['yn_flag'] = 6
del resp['data']['new_blist'][1:len(resp['data']['new_blist'])]
modified = json.dumps(resp)
while len(modified) % 8 != 0:
modified += ' '
return modified
def modify_info(self, string):
resp = json.loads(string)
resp['data']['status'] = 6
resp['data']['diff_money'] = 9999999.99
modified = json.dumps(resp)
while len(modified) % 8 != 0:
modified += ' '
return modified
def response(self, flow):
if flow.request.path == '/2-0-0/index.php?r=dlbpay/borrowbaglist':
modified = self.encrypt(self.modify_list(self.decrypt(flow.response.content)))
flow.response.text = modified
if flow.request.path == '/2-0-0/index.php?r=dlbpay/dtpayinfo/':
modified = self.encrypt(self.modify_info(self.decrypt(flow.response.content)))
flow.response.text = modified
return
def start():
return Injector()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment