forked from maxnoodles/wechat_app_spider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mitm_mumu.py
34 lines (27 loc) · 983 Bytes
/
mitm_mumu.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
import re
import mitmproxy.http
from mitmproxy import ctx
import redis
class Counter:
def __init__(self):
self.redis_cli = redis.StrictRedis(decode_responses=True)
self.biz_queue = 'wechat_biz'
self.url_queue = 'article_url'
def inspect_redis_queue(self, name):
queue_len = self.redis_cli.llen(name)
if queue_len != 0:
self.redis_cli.delete(name)
def request(self, flow: mitmproxy.http.HTTPFlow):
biz = re.search(r'https://mp.weixin.qq.com/mp/geticon\?__biz=(.*?)&', flow.request.url)
if biz:
referer = flow.request.headers['referer']
print(referer)
biz = biz.group(1)
self.inspect_redis_queue(self.biz_queue)
self.inspect_redis_queue(self.url_queue)
self.redis_cli.lpush(self.biz_queue, biz)
self.redis_cli.lpush(self.url_queue, referer)
ctx.log.info(f"the biz is: {biz}")
addons = [
Counter()
]