Tag Archives: Mitmproxy

mitmproxy抓https出现502Bad Gateway. unable to get local issuer certificate的解决方法

502 Bad Gateway. Certificate Verification Error for www.xxxx.com: unable to get local issuer certificate (errno: 20, depth: 0) 想到可能是当前证书不支持,网上找一个最新的cacert.pem替换certifi包(xx\python36\Lib\site-packages\certifi)目录的证书,再次使用可以抓到包了。 参考资料 https://github.com/mitmproxy/mitmproxy/issues/1608 https://curl.haxx.se/docs/caextract.html

使用MitmProxy绕过Content Security Policy (CSP)

这几天测试用Selenium 和 Chrome插件都无法在 谷歌插件商店https://chrome.google.com/webstore/category/extensions?hl=en 实现JS注入 检查发现响应头里面有一个 ‘content-security-policy’,错误提示: "Refused to execute inline script because it violates the following Content Security Policy directive: "script-src ‘report-sample’ ‘nonce-wNKF1pjNhZent+g6jyFL9g’ ‘unsafe-inline’ ‘unsafe-eval’". Note that ‘unsafe-inline’ is ignored if either a hash or nonce value is present in the source list." CSP全称Content Security Policy ,可以直接翻译为内容安全策略,说白了,就是为了页面内容安全而制定的一系列防护策略. 通过CSP所约束的的规责指定可信的内容来源(这里的内容可以指脚本、图片、iframe、fton、style等等可能的远程的资源)。通过CSP协定,让WEB处于一个安全的运行环境中. 我这里使用MitmProxy绕过CSP执行JS注入 脚本如下 from bs4 import BeautifulSoup… Read More »

Mitmproxy + Python安装和使用的一些问题

安装: pip3 install mitmproxy 国内: pip install mitmproxy -i http://pypi.douban.com/simple –trusted-host pypi.douban.com 如果’Microsoft Visual C++ Build Tools’错误,可以在https://visualstudio.microsoft.com/zh-hans/downloads/ 直接下载安装即可 如果’Dll load error…..’ 错误,安装VC https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads 检查是否安装成功: mitmdump –version 版本升级: pip install –upgrade mitmproxy 安装证书 访问 http://mitm.it/ 自动安装 手动: 命令 certutil -addstore root mitmproxy-ca-cert.cer 自定义脚本 : 脚本内容是实时修改生效 mitmdump -s xxx.py 指定代理 –mode upstream:http://192.168.0.1:8800 忽略HOST / 忽略多个host –ignore-hosts ^google\.com:443$… Read More »