See personal blog
Why WRITE this article:
Although in the past there have been a number of capture package experience, but for a long time not to do, some pits or difficult to avoid, a waste of time. So precipitate a small white guide paste, save time.
To capture and parse Android HTTPS packets, you need to set up the proxy service and configure the mobile terminal.
1. Proxy service
This article takes AnyProxy as an example. AnyProxy is a proxy server that can be flexibly configured. It supports HTTPS plaintext proxy, and provides a Web interface to facilitate the observation of requests, while supporting secondary development, you can use JavaScript to control the whole process of proxy, build front-end personalized debugging environment.
(1) Install Anyproxy
Online articles are very much, this article reference: proxy server AnyProxy
(2) Configure HTTPS
Principle: AnyProxy parses Https through the self-made root certificate rootCA. After the terminal trusts the certificate, it issues the secondary certificate of each domain name. In this case, the secondary certificate can parse each page again.
A. to generate rootCA
#Latest version generation method
$ anyproxy-ca
Copy the code
You can also scan the AnyProxy Web page for download
B. Open and trust rootca.crt
After the generation command is executed, the certificate directory is displayed, or you can find the directory as prompted and double-click it.
Trust Certificate:
(3) Start AnyProxy in HTTPS mode
$ anyproxy --intercept
#shorthand
$ anyproxy -i
Copy the code
2. Mobile
(1) Install the. CRT certificate
There are two correct installation methods:
A. Settings — WiFi — Advanced Settings — Install the certificate
B. Setup – More setup – System Security – from SD card setup
(2) Mobile phone set agent
A. Wi-fi Settings
B. Adb Settings (test valid)
#Set global commandsAdb shell Settings put Global http_proxy Proxy IP address: port number
#Removing proxy information
adb shell settings delete global http_proxy
adb shell settings delete global global_http_proxy_host
adb shell settings delete global global_http_proxy_port
adb reboot
Copy the code
C. Set the proxy through the third-party app (it is not recommended for the time being, because it fails to test the configuration on the android physical machine)
After downloading apK, install it on your phone to set up the agent:
#Set the proxy by running the following command
adb shell am start -n tk.elevenk.proxysetter/.MainActivity
#Parameters that
-e host <host> # The host ip or address for the proxy
-e port <port> # The port for the proxy
-e ssid <ssid> # The SSID of the wifi network to set proxy on(optional, will apply on the first one if empty)
-e key <shared key> # The password/key for the wifi network
-e bypass <bypass string> # The bypass string to use for proxy settings
-e reset-wifi <boolean> # Whether or not to reset the wifi settings. This flag will tell
# the tool to forget all connected networks, make a new
# network config with the SSID and key given, and then
# attempt to connect to the wifi network. If no key is given,
# the wifi network is assumed to be unprotected/open
-e clear <boolean> # A flag that will clear the proxy settings for the given SSID
Copy the code
Common commands:
#Set up agents on open wifi networks to reset wifi (reset-wifi)true)
adb shell am start -n tk.elevenk.proxysetter/.MainActivity -e host <Proxy IP> -e port <Proxy Port> -e ssid <Wifi Name> -e reset-wifi true
#Set up wifi network agent with password
adb shell am start -n tk.elevenk.proxysetter/.MainActivity -e host <Proxy IP> -e port <Proxy Port> -e ssid <Wifi Name> -e key <Wifi pwd>
#Clear the SSID of the proxy server
adb shell am start -n tk.elevenk.proxysetter/.MainActivity -e ssid <ssid> -e clear true
Copy the code