Mobile terminal environment configuration and packet capture basics
To crawl App data, the first step is to see clearly what is transmitted between the App and the server. This is inseparable from a stable and easy-to-use debugging environment and packet capture tool chain.
This article will take you step by step to build your own App packet capture environment from the four dimensions of environment selection→core commands→packet capture configuration→anti-capture breakthrough.
1. Mobile debugging environment: simulator or real device?
There is no need to worry about choosing an environment. Each of the two options has clear usage scenarios:
Suggestion: Use the simulator directly for daily development and learning. It has low cost, full authority and the highest efficiency.
1.1 Quickly connect ADB to mainstream simulators
After selecting the simulator, the first step is to use ADB to "bind" the PC and the simulator together:
After the connection is successful, executeadb devicesYou will see the device status:
2. Commonly used ADB commands: ten commands for daily development
ADB is a communication bridge between PC and Android devices. The following commands cover 99% of daily needs. There is no need to memorize them by rote. Just check back when you need them.
Connection and status
Application management
File transfer
Common debugging techniques
3. Mainstream packet capture tools: choose one of the three
The core principles of all packet capture tools are similar: Set the Wi-Fi proxy on the mobile phone to PC → The tool intercepts traffic → The tool uses its own CA certificate to "pretend" to the server to communicate with the App, thereby enabling clear text viewing of requests and responses.
Depending on the operating system and requirements, you can choose:
3.1 Mitmproxy: The most suitable tool for Python packet capture
Mitmproxy has three startup methods. When you first start, you can play with the Web interface (mitmweb) first, and then use script mode to automate processing after you are familiar with it.
Step one: Installation and startup
Step 2: Simulator configuration agent (taking Thunderbolt as an example)
- Open the emulator
设置 → WLAN → 长按已连接的 WiFi → 修改网络 - Agent selection
手动, the server fills in the LAN IP of the PC (for WindowsipconfigView, for Mac/Linuxifconfig) - Fill in the port
8080, save and open the browser to accessmitm.it - Follow the prompts to download and install the certificate (Android 7.0+ must install the certificate in the system area, see Section 4 for details)
Step 3: Write a script to automatically save the JSON response
Many App APIs return JSON, which we can automatically intercept and save with a few lines of code:
Start script mode:
4. Counter packet capture: certificate locking and bypass techniques
HTTPS encryption will bring two thresholds for packet capture. Fortunately, there are ready-made solutions for each.
4.1 Install the certificate to the system area
Starting from Android 7.0 (API 24), the App only trusts the CA certificate pre-installed by the system by default, and the certificate installed by the user will be ignored, so the Mitmproxy certificate must be flashed into the system area (ROOT permissions are required).
If the emulator has been ROOT, the whole process will be particularly smooth, which is one of the reasons why the emulator was recommended above.
4.2 Bypass SSL Pinning
If you still cannot catch the package after installing the system certificate, it means that the App has enabled SSL Pinning (certificate pinning). It will actively verify whether the certificate returned by the server is consistent with its own built-in certificate. If it is inconsistent, it will directly disconnect.
The quickest bypass is Frida + JustTrustMe:
In this way, the verification logic of SSL Pinning will be bypassed, and the packet capture tool can decrypt HTTPS traffic normally.
5. A complete actual combat process
Take grabbing the API of a reading app as an example and stringing together the previous knowledge (only for learning, no illegal use):
- Open the lightning simulator and confirm that it is ROOT
- Install Mitmproxy system certificate
- Start
mitmweb -p 8080 - Set up the emulator Wi-Fi proxy
- Launch the reading app with Frida + JustTrustMe
- Flip through some books and open the browser
http://127.0.0.1:8081You can see real-time API data
The entire process, from environment-setup to seeing the clear text interface, can be completed within ten minutes.
Summarize
There are four core points in this article:
- Prioritize the use of simulators: ROOT permissions directly minimize obstacles
- 10 ADB commands are enough: covering application management, file transfer and simple debugging
- Choose one of three packet capture tools: Python developers prefer Mitmproxy for easy scripting
- Two steps to break through and counterattack: System area certificate + Frida+JustTrustMe to bypass SSL Pinning
Mastering these, you will have a master key to "see through App data flow", laying a solid foundation for subsequent protocol analysis and crawler development.

