Fiddler based tutorial Comments

Fiddler is the best one of the most powerful Web debugging tool, it can record all http and https requests the client and server, allowing you to monitor, set breakpoints, and even modify the input and output data using Fiddler both for development or testing speaking, they are of great help.

                Read catalog

  1. Basic introduction of Fiddler
  2. Fiddler works
  3. Other similar tools
  4. How Fiddler session to capture Firefox
  5. Firefox plug-in to use Fiddler
  6. How Fiddler capture HTTPS sessions
  7. Fiddler's basic interface
  8. Fiddler's statistical view
  9. Use the command line QuickExec
  10. Fiddler modified set breakpoints Request
  11. Fiddler set breakpoints modify Response
  12. Fiddler AutoResponder create rules
  13. How to filter Fiddler session
  14. Fiddler session in comparison function
  15. Fiddler provided encoding gadgets
  16. Fiddler query session
  17. Fiddler saved session
  18. Fiddler's script system
  19. How to use Fiddler on the site when debugging VS
  20. Response is garbled   

 

Basic introduction of Fiddler

Fiddler's official website: www.fiddler2.com

Fiddler official website provides a lot of help documentation and video tutorials, this is the best material to learn Fiddler's.

Fiddler is the best one of the most powerful Web debugging tool, it can record all http and https requests the client and server, allowing you to monitor, set breakpoints, and even modify the input and output data, Fiddler includes a powerful web-based event scripting subsystem, and can be extended using .net languages

The more you know about the HTTP protocol, the more you will be able to master the use of Fiddler's. The more you use Fiddler, the more they can help you understand the HTTP protocol.

Fiddler both for developers or testers, is a very useful tool

Fiddler works

Fiddler is a proxy server in the form of web work, it uses the proxy address: 127.0.0.1, port: 8888 and it will automatically log off when Fiddler proxy will automatically set the proxy, the time to exit, so it will not affect other programs. But if non-normal exit Fiddler, Fiddler at this time because there is no automatic cancellation will cause the pages are not accessible. The solution is to reboot Fiddler.

 

Other similar tools

Similar tools: httpwatch, firebug, wireshark

How Fiddler session to capture Firefox

HTTP proxy support any program of packets can be sniffed Fiddler, Fiddler operating mechanism is actually HTTP proxy listens on port 8888 of the machine. Fiddler2 activated when the default IE proxy to the 127.0.0.1:8888, but other browsers are set manually, so the Firefox proxy instead 127.0.0.1:8888 can monitor the data.

The agent provided by the following steps Firefox

Click: Tools -> Options, click the Advanced tab in the Options dialog box -> network tab -> setting.

 

Firefox plug-in installation Fiddler

Modify Firefox proxy is too much trouble, you do not have to be removed when the fiddler proxy. trouble

Recommend that you use fiddler hook firefox plug-in, so you are very easy to use Fiddler get firefox the request and response

When you install fiddler, has installed a Fiddler hook plugin, you need to go to activate this plugin firefox
open firefox tools-> Add ons -> Extensions start FiddlerHook

 

 

How Fiddler capture HTTPS sessions

默认下,Fiddler不会捕获HTTPS会话,需要你设置下, 打开Fiddler  Tool->Fiddler Options->HTTPS tab

选中checkbox, 弹出如下的对话框,点击"YES"

点击"Yes" 后,就设置好了

Fiddler的基本界面

看看Fiddler的基本界面

 

Inspectors tab下有很多查看Request或者Response的消息。 其中Raw Tab可以查看完整的消息,Headers tab 只查看消息中的header. 如下图

 

Fiddler的HTTP统计视图

通过陈列出所有的HTTP通信量,Fiddler可以很容易的向您展示哪些文件生成了您当前请求的页面。使用Statistics页签,用户可以通过选择多个会话来得来这几个会话的总的信息统计,比如多个请求和传输的字节数。

选择第一个请求和最后一个请求,可获得整个页面加载所消耗的总体时间。从条形图表中还可以分别出哪些请求耗时最多,从而对页面的访问进行访问速度优化

QuickExec命令行的使用

Fiddler的左下角有一个命令行工具叫做QuickExec,允许你直接输入命令。

常见得命令有

help  打开官方的使用页面介绍,所有的命令都会列出来

cls    清屏  (Ctrl+x 也可以清屏)

select  选择会话的命令

?.png  用来选择png后缀的图片

bpu  截获request

Fiddler中设置断点修改Request

Fiddler最强大的功能莫过于设置断点了,设置好断点后,你可以修改httpRequest 的任何信息包括host, cookie或者表单中的数据。设置断点有两种方法

第一种:打开Fiddler 点击Rules-> Automatic Breakpoint  ->Before Requests(这种方法会中断所有的会话)

如何消除命令呢?  点击Rules-> Automatic Breakpoint  ->Disabled

第二种:  在命令行中输入命令:  bpu www.baidu.com   (这种方法只会中断www.baidu.com)

如何消除命令呢?  在命令行中输入命令 bpu

 

看个实例,模拟博客园的登录, 在IE中打开博客园的登录页面,输入错误的用户名和密码,用Fiddler中断会话,修改成正确的用户名密码。这样就能成功登录

1. 用IE 打开博客园的登录界面  http://passport.cnblogs.com/login.aspx
2. 打开Fiddler,  在命令行中输入bpu http://passport.cnblogs.com/login.aspx
3. 输入错误的用户名和密码 点击登录
4. Fiddler 能中断这次会话,选择被中断的会话,点击Inspectors tab下的WebForms tab 修改用户名密码,然后点击Run to Completion 如下图所示。
5. 结果是正确地登录了博客园

 

Fiddler中设置断点修改Response

当然Fiddler中也能修改Response

第一种:打开Fiddler 点击Rules-> Automatic Breakpoint  ->After Response  (这种方法会中断所有的会话)

如何消除命令呢?  点击Rules-> Automatic Breakpoint  ->Disabled

第二种:  在命令行中输入命令:  bpafter www.baidu.com   (这种方法只会中断www.baidu.com)

如何消除命令呢?  在命令行中输入命令 bpafter,

具体用法和上节差不多,就不多说了。

Fiddler中创建AutoResponder规则

Fiddler 的AutoResponder tab允许你从本地返回文件,而不用将http request 发送到服务器上。

看个实例. 1. 打开博客园首页,把博客园的logo图片保存到本地,并且对图片做些修改。

2. 打开Fiddler 找到logo图片的会话, http://static.cnblogs.com/images/logo_2012_lantern_festival.gif,  把这个会话拖到AutoResponer Tab下

3. 选择Enable automatic reaponses 和Unmatched requests passthrough

4. 在下面的Rule Editor 下面选择 Find a file... 选择本地保存的图片.  最后点击Save 保存下。

5.  再用IE博客园首页, 你会看到首页的图片用的是本地的。

 



Fiddler中如何过滤会话

每次使用Fiddler, 打开一个网站,都能在Fiddler中看到几十个会话,看得眼花缭乱。最好的办法是过滤掉一些会话,比如过滤掉图片的会话. Fiddler中有过滤的功能, 在右边的Filters tab中,里面有很多选项, 稍微研究下,就知道怎么用。

 

Fiddler中会话比较功能

选中2个会话,右键然后点击Compare,就可以用WinDiff来比较两个会话的不同了 (当然需要你安装WinDiff)

 

Fiddler中提供的编码小工具

点击Fiddler 工具栏上的TextWizard,  这个工具可以Encode和Decode string.

Fiddler中查询会话

用快捷键Ctrl+F 打开 Find Sessions的对话框,输入关键字查询你要的会话。 查询到的会话会用黄色显示

Fiddler中保存会话

有些时候我们需要把会话保存下来,以便发给别人或者以后去分析。  保存会话的步骤如下:

选择你想保存的会话,然后点击File->Save->Selected Sessions

Fiddler的script系统

Fiddler最复杂的莫过于script系统了 官方的帮助文档: http://www.fiddler2.com/Fiddler/dev/ScriptSamples.asp

首先先安装SyntaxView插件,Inspectors tab->Get SyntaxView tab->Download and Install SyntaxView Now... 如下图

 

安装成功后Fiddler 就会多了一个Fiddler Script tab, 如下图

在里面我们就可以编写脚本了, 看个实例 让所有cnblogs的会话都显示红色。

把这段脚本放在OnBeforeRequest(oSession: Session) 方法下,并且点击"Save script"

     if (oSession.HostnameIs("www.cnblogs.com")) {
oSession["ui-color"] = "red";
}

这样所有的cnblogs的会话都会显示红色

 

如何在VS调试网站的时候使用Fiddler

我们在用visual stuido 开发ASP.NET网站的时候也需要用Fiddler来分析HTTP, 默认的时候Fiddler是不能嗅探到localhost的网站。不过只要在localhost后面加个点号,Fiddler就能嗅探到。

例如:原本ASP.NET的地址是 http://localhost:2391/Default.aspx,  加个点号后,变成 http://localhost.:2391/Default.aspx 就可以了

 

第二个办法就是在hosts文件中加入  127.0.0.1  localsite

如何你访问http://localsite:端口号   。  这样Fiddler也能截取到了。

 

Response 是乱码的

有时候我们看到Response中的HTML是乱码的, 这是因为HTML被压缩了, 我们可以通过两种方法去解压缩。

1. 点击Response Raw上方的"Response is encoded any may need to be decoded before inspection. click here to transform"

2. 选中工具栏中的"Decode"。  这样会自动解压缩。

 

【博客摘自大神《小坦克》,感谢博主,如有侵权,请联系删除】

Guess you like

Origin www.cnblogs.com/show2008/p/10981315.html