AnyProxy is an open HTTP proxy server that can also be used to capture packets like Charles.
I first saw this project in this WeChat mini game plug-in project. The idea of the plug-in is to change the content of the HTTP/HTTPS/WebSocket request/response, so that the answer can be quickly distinguished in the game. Taking this as an example, AnyProxy can manipulate HTTP requests and responses, directly in the response data, add a tick in front of the correct option, players can easily identify, because the correct answer itself can be captured by HTTP the requested data.
This article mainly explains how to use AnyProxy to capture HTTP/HTTPS/WebSocket request data from iPhone and Mac computers. (AnyProxy in the project is used as an npm module. The packet capture in this article is based on the fact that AnyProxy is a global command line module)
Install
The first is installation, which is very simple:
npm install -g anyproxy
Startup: (Proxy HTTP/HTTPS/WebSocket)
anyproxy --intercept --ws-intercept
At this time, the browser is opened localhost:8002
, and all requests will be displayed on it.
iOS
To proxy HTTPS, a certificate needs to be installed. Refer to iOS system trust CA certificate
iOS >= 10.3 One more step, trust certificate. Refer to iOS >= 10.3 Trust CA Certificate
Then open the settings on the mobile phone, find the connected wifi (a network segment is required for the PC), set the HTTP PROXY, select Manual, Server is the LAN IP of the PC, and Port is 8001
Mac
To proxy HTTPS, a certificate needs to be installed. Refer to OSX system trust CA certificate
Then you need to configure the proxy. Reference Configuring OSX System Agents
When configuring the proxy, if you want to capture HTTPS requests, you need to hook the HTTPS option at the same time