Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node抓包工具AnyProxy #26

Open
Wscats opened this issue Jan 22, 2018 · 0 comments
Open

node抓包工具AnyProxy #26

Wscats opened this issue Jan 22, 2018 · 0 comments

Comments

@Wscats
Copy link
Owner

Wscats commented Jan 22, 2018

安装AnyProxy

全局安装AnyProxy模块

npm i -g anyproxy

image

配置

生成证书

anyproxy-ca

image

以代理https的方式启动

anyproxy -i

image

在浏览器打开链接

http://localhost:8002/

image

安装证书

配置代理

用的是Charles,具体可以参考网上其他文章,当然这个我后来也没配置,直接在手机的代理设置好PC的IP和默认的8001端口就可以了

PC端

本地双击直接安装rootCA.crt

C:\Users\Administrator\.anyproxy\certificates\rootCA.crt

手机端

扫描http://localhost:8002/界面下的RootCA二维码下载到手机

  • 在手机直接安装证书(但有可能提示:无法安装该证书 因为无法读取)
  • 打开设置->更多设置->系统安全->从存储设备(SD卡)安装->选择文件(有可能会提示警告,或者要你设置密码才能安装)

这里有一点要注意,如果是IOS10+,安装完证书之后要在设置->通用->关于本机->证书信任设置,打开对应的针对根证书启用完全信任,才可以抓包成功

定义规则

新建rule.js文件

module.exports = {
    summary: 'a rule to hack response',
    * beforeSendResponse(requestDetail, responseDetail) {
        if (requestDetail.url === 'http://httpbin.org/user-agent') {
            const newResponse = responseDetail.response;
            newResponse.body += '- AnyProxy Hacked! Wscats Test~';
            return new Promise((resolve, reject) => {
                setTimeout(() => { // delay
                    resolve({
                        response: newResponse
                    });
                }, 5000);
            });
        }
    },
};

在终端执行一下命令,在手机端打开http://httpbin.org/user-agent链接测试,代理https请求记得加上--intercept参数

anyproxy --intercept --rule rule.js

image

然后在浏览器打开链接http://localhost:8002/可以看到页面会有一下内容,证明配置规则成功

{
  "user-agent": "Mozilla/5.0 (Linux; U; Android 6.0.1; zh-cn; Redmi 4A Build/MMB29M) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/53.0.2785.146 Mobile Safari/537.36 XiaoMi/MiuiBrowser/9.3.10"
}
- AnyProxy Hacked! Wscats Test~

参考文档

AnyProxy

@Wscats Wscats changed the title node抓包工具 node抓包工具AnyProxy Jan 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant