"Speaking Tools" series of bag capture artifact - Fiddler

 

Fiddler

" If a worker wants to do his work well, he must first sharpen his tools. "  - The Master said.
In the next period of time, I will introduce some tools that I usually use, mainly tools in daily program development. Interested students can pay attention to my WeChat subscription account,  Uncle Neng , for the feeling.

Network packet capture is an essential skill for exploring the truth of the mysterious Internet world. There are many tools, and the most famous one is wireshark¹. This tool is really powerful, but the learning cost is relatively high. If you are interested, you can buy this book "Wireshark" Network analysis is as simple as that." Study slowly by yourself. Of course, there are also simple ones, such as Smsniff², which is strongly recommended for friends who have little foundation and do not want to invest time.

I will not introduce the above two softwares. Here I mainly want to talk about Fiddler³, which is between the previous two, and the taste is just right.

Fiddler allows you to monitor, set breakpoints, and even modify input and output data. The more you use it, the more you will get closer to the truth of the online world. The more you understand it, the more you will fall in love with it. It can be described as a development engineer, test engineer, network engineer at home A must-have tool for travel.

In fact, a lot of content is described in detail on the Fiddler Doc on the official website   . Maybe some people are not good at English (me too). I will briefly mention a few important points from a practical point of view. In addition, if you really don't know you in English, download the  Fiddler2 Chinese manual  !


1. Principle introduction

Fiddler works as a proxy web server, it uses proxy address: 127.0.0.1, default port: 8888.

Fiddler-1

For example, visit www.qq.com

Fiddler-2

Of course, you are uncomfortable looking at port 8888 (obsessive-compulsive disorder), and you can change it if you want.

Fiddler-3

2. Basic interface

I won't list the UI functions of Fiddler2 one by one. You will know when you open it yourself. Here is the overall picture, just have a perceptual understanding!
Fiddler-0

3. Capture browser session

能支持HTTP代理的任意程序的数据包都能被Fiddler嗅探到,Fiddler的运行机制其实就是本机上监听8888端口的HTTP代理。 Fiddler2启动的时候默认IE的代理设为了127.0.0.1:8888,而其他浏览器是需要手动设置的。

  • chrome设置
    建议下载个proxy SwitchySharp的插件,代理设置、过滤、切换都非常的方便!
  • firefox设置
    点击: 「工具」 -> 「选项」, 在「选项」对话框上点击 「高级」 tab -> 「网络」 tab -> 「设置」.

这些设置都很简单,就不上图占用大家流量了(毕竟运营商喊了半天的“提速降费”,但流量还是挺贵的),其它什么360安全浏览器,什么XX浏览器,我就不一一讲了,大同小异。

4、捕获JAVA应用

这里不管你是Eclipse开发也好, intellij idea也罢,甚至有人还在使用Jbuilder我也忍了,设置都是一样,有两种方式:

1、启动配置应用的JVM环境

jre -DproxySet=true -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=8888
或者
jre -DproxySet=true -DproxyHost=127.0.0.1 -DproxyPort=8888 MyApp

2、代码设置JVM代理设置

System.setProperty("http.proxyHost", "127.0.0.1");
System.setProperty("https.proxyHost", "127.0.0.1");
System.setProperty("http.proxyPort", "8888");
System.setProperty("https.proxyPort", "8888");

但是如果你程序中使用 Apache HttpClient 来发送请求的话,我不得不遗憾的告诉你,上述两种方式都没用,你必须在HttpClient上做代理设置,形如:

RequestConfig.custom().setProxy("127.0.0.1","8888").build();

5、捕获HTTPS

真的很简单,打开工具栏->Tools->Fiddler Options->HTTPS
Fiddler-4

如果你想知道原理,可参考 浅谈HTTPS以及Fiddler抓取HTTPS协议 ,反正我是不求甚解。

6、手机上抓包

要在手机上抓包的前提是: 要抓包的手机和安装Fiddler的电脑在同一个局域网上。 接下来就简单了,三步走:

  1. 配置Fiddler, 允许"远程连接" 
    Tools-> Fiddler Options 。(配置完后记得要重启Fiddler)。 
    选中"Allow remote computers to connect",是允许别的机器把HTTP/HTTPS请求发送到Fiddler上来 。
    Fiddler-8

  2. 给手机安装Fiddler证书
    使用手机浏览器访问http://【电脑IP地址】:【fiddler设置的端口号】,既可以下载fiddler的证书并安装。啥?电脑IP怎么看?把电脑反过来,底部右下角就能看到,如果还是看不到,请用橡皮擦一下。

  3. 给手机设置代理
    打开HTTP代理, 输入Fiddler所在机器的IP地址(比如:192.168.1.104) 以及Fiddler的端口号8888。

7、操作会话

  • 查找会话
    有些时候,会话列表中一堆的会话,眼睛都要看瞎了的时候,它就派上用场了,用快捷键Ctrl+F打开Find Sessions对话框,输入关键字查询会话,查询到的会话会用黄色显示(当然你也可以配置换个颜色)。
  • 过滤会话 这个其实和查找会话类似,就是个加强版的“查找会话”,只不过可以选项更多。在任务面板的Filters tab中,里面有很多选项, 可以自己研究下,大概就知道怎么了。
  • 比较会话
    有些时候,我们想比较下两个会话的区别,选中2个会话,右键然后点击Compare,就可以用WinDiff来比较两个会话的不同了(当然需要你安装WinDiff)。
  • Save the session
    Sometimes, we need to save the session to send it to others or to analyze it later. Then select the session you want to save, then click File->Save->Selected Sessions, and you're done.

8. Breakpoints modify request and response

This is an advanced skill, which is omitted in this issue and will be continued when there is time.

9. Quick Command Line QuickExec

This is an advanced skill, which is omitted in this issue and will be continued when there is time.

10. Other small cookies

  • The useful "cross" frame
    is an absolute fool operation. For example, if you want to capture the package of the specified program, for example, if you only want to capture "Evernote", then click and hold the "cross" frame, and then drag it to the Evernote window to place it. Just open it. It can specify the process to capture packets, and point to which to play, to eliminate unnecessary interference.
    Fiddler-7

  • Encoding Widget
    Click TextWizard on the toolbar of Fiddler2, this tool can Encode and Decode string, mother no longer have to worry about my encoding.
    Fiddler-5

  • Composer
    is the same thing as Postman⁴, you can simulate your http request, you can build a beautiful song yourself.
    Fiddler-6


appendix


Welcome to my personal WeChat public account: Uncle Neng

Uncle Neng

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326859621&siteId=291194637