Capture Android app packets with fiddler

Source: Internet
Author: User

Objective

Android development friends often need to do network data acquisition and submission of form data, and so on, but for the debugger, it is difficult to know how our data is sent in exactly what form, whether the delivery is successful, if the sending failed for what causes. The Fiddler tool gives us a handy grab-and-hold operation that allows you to easily grab data from your browser, whether it's a mobile app or a Web browser.

What is fiddler

Baidu Encyclopedia is said: Fiddler is an HTTP protocol debugging Agent tool, it can record and check all your computer and the Internet between the HTTP communication, set breakpoints, see all the "in and out" Fiddler data
Fiddler Download: Http://www.telerik.com/fiddler
The installation of Fiddler not much to say, the Fool is installed.

How the Fiddler works

Fiddler is based on the agent to implement crawling network packets, when we turn on fiddler, Fiddler will change the proxy of our browser to 127.0.0.1 port is 8888, then the default port of fiddler, This means that every request we send and every response we receive will go through fiddler, which will enable us to crawl the packet.
Path: Options –> Advanced Settings –> change proxy settings –> LAN Settings –> advanced

Fiddler common functions

Open the Fiddler main interface as follows:

Let's explain once from left to right:
1. The first icon of a small bubble similar to speech: Add comment to a session reply, that is, add a comment function. We can select a reply and add a comment to the reply, and the added note will be displayed on the comment option for that session.
2.replay:
This button is used to replay a session, for example, I need to re-request a reply, you can select the answer, and then click the button, or click on the keyboard R key.
3. Filter the request:
If I only want to filter requests from 360 browsers, you can use the left mouse button to long press the button and drag to any of the 360 browser's viewable areas:

You can see that a package that only filters 360 browsers is displayed at this time.
4. Filtering Session Sessions

As can be seen, here I filtered the "Baidu" this keyword.
5.textWizard
The purpose of this tab is to encode or decode a given string, such as:

6. Breakpoint Debugging

As you can see, there is a button at the bottom that changes the direction of the arrows when you click the button. When the arrow is up, any requests from our browser will be blocked and will be executed only if the Go button is clicked.
7. Use of the console
At the bottom of the fiddler is a black rectangular box, which is the Fiddler command line. We can enter "help" at the command line to jump to the official website, which has detailed command-line instruction.
The common commands are:
1.cls Empty All Sessions
2.?.png filtering requests for all pictures
8. Control whether the fiddler is working
At the bottom left of the Fiddler is a button that controls whether the fiddler acts as a proxy server to crawl packets sent and received by the browser. When I click on the button, if the button is displayed it indicates that fiddler is working, and if the button is hidden, the Fiddler is not acting as a proxy server.

9. The Answer panel description:

Analysis of Session Sessions

Here I randomly choose a conversation for a simple analysis.

Replace the data returned by the server side

With "Autoresponser" can replace the server-side returned files, when debugging needs to replace the server-side returned data, such as an already on-line project, can not be a real replacement of a file, we could do this

From the picture, it can be clearly seen that when I load the session again, the previous set of 404 agents will be displayed.

This is also possible if you need to set up a different file agent. For example, for this session, the original server-side returned content such as:

Because the session returned is a picture type, so I choose ImageView this tab, you can see the picture returned at this time, then if you need to use the local file proxy that returned content, and the previous steps are the same, just select the agent when the local file can be Such as:

This time, I chose a local file as the proxy, and when I re-requested the session again, I returned the local file:

It can be seen that the content returned by this session is already my local agent.

Fiddler network speed limit

Fiddler also provide us with a very convenient network speed limit function, through the network speed limit function, you can simulate some of the user's real environment. Fiddler provides the network speed limit plug-in, which we can download on his website: http://www.telerik.com/fiddler/add-ons

Click "Download", after the download is complete, click Install, you need to restart the fiddler, after restarting Fiddler, you can see the Fiddler Toolbar tab, a more fiddlerscript option.

For example, I need to delay a period of time before the request can be done:

Add such a piece of code "osession[" Request-trickle-delay "] =" 3000 "in the Onbeforerequest method and" osession["if you need to delay the service-side response Request-trickle-delay "] =" 3000 ";" Replace the request in the response.

Capture Android app packets with fiddler

Finally to the theme of today, how to use Fiddler crawl Android app data package, in fact, is very simple, just a little configuration can be. Since fiddler is the default crawl of the HTTP protocol packet, we need to be able to crawl encrypted packets such as HTTPS, crawling Android app packets, need to do the following configuration:
1. Configure Fiddler
Click the toolbar option "Tools–>fiddleroptions"
To configure https:

To configure a remote connection:

After these configurations are complete, be sure to restart Fiddler.
Can see the default port of Fiddler is 8888, we can now enter "http://127.0.0.1:8888" on the browser

Our fiddler has been configured so far, then we need to configure the wireless network on the phone.
2. Mobile Wireless Network configuration
Note: If you need fiddler to crawl the packets on the Android app, the two must be in the same wireless network. (also, turn off your computer's firewall if necessary)
Before you configure your phone's wireless network, you must first know the IP address of the host where the Fiddler resides:

Can see my fiddler host, which is my computer in the wireless network IP address is 192.168.1.109
Open the wireless network interface in your phone's settings and do the following four steps:
Select a connected network, click Modify Network

Click Advanced Options

Agent--Manual

Enter the IP of the proxy server, that is, the IP address of the host where we fiddler, and the port, fiddler the default port is 8888,ip option set to "DHCP"

Click Save, at this time the mobile phone is configured successfully, open fiddler, use open NetEase News client.

At this point you can see the fiddler crawl of the NetEase app sent and received relevant data packets.

OK, on the left is all of our sessions, I randomly selected a session, the session is the image type, view the content of the session, is our NetEase news headlines on the picture.

Summarize

Fiddler is a handy tool for crawling network packets, and is implemented in an agent-based manner.
Attention:
1. Turn off your computer's firewall
2. If you need to crawl the mobile app's packet, you need the phone and computer to connect to the same wireless network
3. After the package will be fiddler shut down (increase the speed of access to the network) at the same time the agent on the phone shut down (if you do not shut down the agent, when the fiddler is closed, or the two are not connected to the same wireless network, the hand will not be able to access the network properly)

OK, today's basic learning about fiddler, and the network packet that uses the Fiddler crawl app, is here. I hope we can enjoy it. Break the sleep.

Capture Android app packets with fiddler

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.