Xiaopei's DokuWiki

These are the good times in your life,
so put on a smile and it'll be alright

User Tools

Site Tools


it:anyproxy

anyproxy

使用源码运行

可以访问 http://127.0.0.1:8002/ 看抓到的请求,手机可以在此扫码安装证书实现 HTTPS 代理。

$ git clone git@github.com:alibaba/anyproxy.git && cd anyproxy && cnpm i
 
# help
$ node bin.js --help
 
# 普通启动,监听 8001
$ node bin.js
 
# 拦截 http
$ http --proxy=http:localhost:8001 --proxy=https:localhost:8001 http://www.baidu.com/s?wd=韩红
# received request to : www.baidu.com/s?wd=%E9%9F%A9%E7%BA%A2
# ==>will forward to real server by proxy
 
# 但 https 不抓
$ http --proxy=http:localhost:8001 --proxy=https:localhost:8001 https://www.baidu.com/s?wd=韩红
# received https CONNECT request www.baidu.com
# ==>will bypass the man-in-the-middle proxy
 
# 生成 root CA
$ node bin.js -g
 
# 按拦截 https 方式启动
$ node bin.js -i
 
# 拦截 http 仍然 OK
$ http --proxy=http:localhost:8001 --proxy=https:localhost:8001 http://www.baidu.com/s?wd=韩红
# received request to : www.baidu.com/s?wd=%E9%9F%A9%E7%BA%A2
# ==>will forward to real server by proxy
 
# https 默认会 certificate verify failed
$ http --proxy=http:localhost:8001 --proxy=https:localhost:8001 https://www.baidu.com/s?wd=韩红
# http: error: SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed
 
# 用证书会 OK
$ http --verify ~/.anyproxy_certs/rootCA.crt --proxy=http:localhost:8001 --proxy=https:localhost:8001 https://www.baidu.com/s?wd=韩红
# received https CONNECT request www.baidu.com
# ==>will forward to local https server
# [internal https]proxy server for www.baidu.com established
# received request to : www.baidu.com/s?wd=%E9%9F%A9%E7%BA%A2
# ==>will forward to real server by proxy
 
 
# 不验证也可以 OK
$ http --verify no --proxy=http:localhost:8001 --proxy=https:localhost:8001 https://www.baidu.com/s?wd=韩红
# received https CONNECT request www.baidu.com
# ==>will forward to local https server
# [internal https]proxy server for www.baidu.com established
# received request to : www.baidu.com/s?wd=%E9%9F%A9%E7%BA%A2
# ==>will forward to real server by proxy
it/anyproxy.txt · Last modified: 2017/05/11 18:58 by admin