-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinterceptor.py
67 lines (55 loc) · 2.42 KB
/
interceptor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import mitmproxy.http
import json
from mitmproxy import ctx
from mitmproxy import flowfilter
class InterceptorUserProfile:
token = ''
def __init__(self):
# 拦截用户信息
self.filter = flowfilter.parse("~u https://cat-match.easygame2021.com/sheep/v1/game/personal_info")
def request(self, flow: mitmproxy.http.HTTPFlow):
if flowfilter.match(self.filter, flow):
print("已拦截到羊了个羊的用户数据:")
self.token = flow.request.headers['t']
def response(self, flow: mitmproxy.http.HTTPFlow):
if flowfilter.match(self.filter, flow):
user_info = json.loads(flow.response.text)
print('用户名:' + user_info['data']['nick_name'])
print('UID:' + str(user_info['data']['uid']))
print('token:'+self.token)
print('')
user_info['data']['nick_name'] = 'Crack By MoLeft & 呆瓜'
flow.response.text = json.dumps(user_info)
# 旧版
class InterceptorStartGame():
def __init__(self):
# 拦截闯关
self.filter = flowfilter.parse("~u https://cat-match.easygame2021.com/sheep/v1/game/map_info\?")
def request(self, flow: mitmproxy.http.HTTPFlow):
if flowfilter.match(self.filter, flow):
map_id = flow.request.query['map_id']
if map_id != '80001':
flow.request.query['map_id'] = '80001'
print('已将关卡[%s]修改为[80001]难度降低' % (map_id))
print('')
# 新版
class InterceptorStartNewGame():
def __init__(self):
# 拦截新闯关
self.filter = flowfilter.parse("~u https://cat-match.easygame2021.com/sheep/v1/game/map_info_ex\?")
def request(self, flow: mitmproxy.http.HTTPFlow):
if flowfilter.match(self.filter, flow):
pass
def response(self, flow: mitmproxy.http.HTTPFlow):
if flowfilter.match(self.filter, flow):
game_data = json.loads(flow.response.text)
if game_data['err_code'] == 0:
print("已将关卡[%s]修改为[%s]难度降低" % (game_data['data']['map_md5'][1], game_data['data']['map_md5'][0]))
game_data['data']['map_md5'][1] = game_data['data']['map_md5'][0]
flow.response.text = json.dumps(game_data)
print()
addons = [
InterceptorUserProfile(),
InterceptorStartGame(),
InterceptorStartNewGame()
]