文章目录

  • 本文目标
  • 下载安装最新版本fiddler
  • 配置工程
    • 新建一个工程并引入类库
    • 新建一个页面控件
      • 在AssemblyInfo.cs中声明fiddler的版本
      • 设计页面
      • 使用fiddler提供的接口,把页面加入到fiddler中
      • 生成并测试
  • 完成目标功能
    • 修改页面控件内容
    • 补充页面控件的代码
    • 对应项目的代码如下(Class1.cs)
    • 生成并测试
      • 开始捕获
      • 保存到文件中
      • 以上说明功能完成
  • 示例代码下载
  • 参考的链接

本文目标

为fiddler做一个插件,按要求截获所感兴趣的关键字url,保存到文件中

下载安装最新版本fiddler

https://www.telerik.com/fiddler

选择安装路径到d盘中(非必须)

关于接口的描述,请参考:https://www.cnblogs.com/weekend001/archive/2013/12/13/3473632.html

配置工程

新建一个工程并引入类库

新建一个C#,Windows类库

添加前面安装的fiddler.exe作为引用


因为要加入一个带窗体的应用程序,因此还需要引入System.Windows.Forms

新建一个页面控件

在AssemblyInfo.cs中声明fiddler的版本

一般嘛使用4.5.1.2即可解决大多数版本问题

[assembly: Fiddler.RequiredVersion("4.5.1.2")]

设计页面

使用fiddler提供的接口,把页面加入到fiddler中

using Fiddler;
using System.Windows.Forms;namespace FiddlerExtension
{public class Class1: IAutoTamper{private TabPage tabPage; //创建插件的选项卡页private UserControl1 myCtrl; //MyControl自定义控件public Class1(){//构造函数中实例化对象this.tabPage = new TabPage("MyFiddlerExtension");//选项卡的名字为Testthis.myCtrl = new UserControl1();}public void OnLoad(){//将用户控件添加到选项卡中this.tabPage.Controls.Add(this.myCtrl);//为选项卡添加icon图标,这里使用Fiddler 自带的this.tabPage.ImageIndex = (int)Fiddler.SessionIcons.Timeline;//将tabTage选项卡添加到Fidder UI的Tab 页集合中FiddlerApplication.UI.tabsViews.TabPages.Add(this.tabPage);}public void OnBeforeUnload(){}// Called before the user can edit a request using the Fiddler Inspectorspublic void AutoTamperRequestBefore(Session oSession){}// Called after the user has had the chance to edit the request using the Fiddler Inspectors, but before the request is sentpublic void AutoTamperRequestAfter(Session oSession) { }// Called before the user can edit a response using the Fiddler Inspectors, unless streaming.public void AutoTamperResponseBefore(Session oSession) { }// Called after the user edited a response using the Fiddler Inspectors.  Not called when streaming.public void AutoTamperResponseAfter(Session oSession) { }// Called Fiddler returns a self-generated HTTP error (for instance DNS lookup failed, etc)public void OnBeforeReturningError(Session oSession) { }}
}

为按钮加入一个响应事件

using System;
using System.Windows.Forms;namespace FiddlerExtension
{public partial class UserControl1 : UserControl{public UserControl1(){InitializeComponent();}private void button1_Click(object sender, EventArgs e){MessageBox.Show("you clicked me");}}
}

生成并测试

把生成后得到的FiddlerExtension.dll,拷贝到fiddler目录下的Scripts文件夹中

=================================================

可以通过修改生成事件,让其自动复制到指定文件夹中

copy "$(TargetPath)" "D:\Fiddler\Scripts$(TargetFilename)"

=================================================

运行fiddler,点击页面中的按钮,可以看到弹出提示,证明代码已经正确

完成目标功能

修改页面控件内容

补充页面控件的代码

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Threading;namespace FiddlerExtension
{public partial class UserControl1 : UserControl{public string filter = "";private bool isBeginFilter = false;public UserControl1(){InitializeComponent();}private void button1_Click_1(object sender, EventArgs e){if (!isBeginFilter) // beginFilter{isBeginFilter = !isBeginFilter;filter = this.textBox2.Text;this.button1.Text = "停止捕获";}else{isBeginFilter = !isBeginFilter;filter = "";this.button1.Text = "开始捕获";}}private void button2_Click(object sender, EventArgs e){// 把当前listview中的数据保存到output.txt中if (this.listView1.Items.Count == 0){MessageBox.Show("列表为空!");}else{List<string> list = new List<string>();foreach (ListViewItem item in this.listView1.Items){string temp = item.SubItems[2].Text; // 取出url的数据进行保存list.Add(temp);}Thread thexp = new Thread(() => export(list)) { IsBackground = true };thexp.Start();}}private void export(List<string> list){string path = AppDomain.CurrentDomain.BaseDirectory + "url_" + Guid.NewGuid().ToString() + ".txt";StringBuilder sb = new StringBuilder();foreach (string urlString in list){sb.AppendLine(urlString);}System.IO.File.WriteAllText(path, sb.ToString(), Encoding.UTF8);MessageBox.Show("已保存完毕,路径:" + path);}}
}

对应项目的代码如下(Class1.cs)

using Fiddler;
using System.Windows.Forms;namespace FiddlerExtension
{public class Class1 : IAutoTamper{private TabPage tabPage; //创建插件的选项卡页private UserControl1 myCtrl; //MyControl自定义控件public Class1(){//构造函数中实例化对象this.tabPage = new TabPage("MyFiddlerExtension");//选项卡的名字为Testthis.myCtrl = new UserControl1();}public void OnLoad(){//将用户控件添加到选项卡中this.tabPage.Controls.Add(this.myCtrl);//为选项卡添加icon图标,这里使用Fiddler 自带的this.tabPage.ImageIndex = (int)Fiddler.SessionIcons.Timeline;//将tabTage选项卡添加到Fidder UI的Tab 页集合中FiddlerApplication.UI.tabsViews.TabPages.Add(this.tabPage);}public void OnBeforeUnload(){}// Called before the user can edit a request using the Fiddler Inspectorspublic void AutoTamperRequestBefore(Session oSession){//   this.myCtrl.textBox1.Text += oSession.fullUrl + "\r\n";// 过滤满足条件的hostif (this.myCtrl.filter != ""){string url = oSession.fullUrl;if (url.Contains(this.myCtrl.filter)){ListViewItem item = new ListViewItem(this.myCtrl.listView1.Items.Count + "");item.SubItems.Add(oSession.host); // 加入hostitem.SubItems.Add(oSession.fullUrl); // 加入fullUrl//item.SubItems.Add(""); // 加入request参数//item.SubItems.Add(""); // 加入response参数this.myCtrl.listView1.Items.Add(item);}}}// Called after the user has had the chance to edit the request using the Fiddler Inspectors, but before the request is sentpublic void AutoTamperRequestAfter(Session oSession) { }// Called before the user can edit a response using the Fiddler Inspectors, unless streaming.public void AutoTamperResponseBefore(Session oSession) { }// Called after the user edited a response using the Fiddler Inspectors.  Not called when streaming.public void AutoTamperResponseAfter(Session oSession) { }// Called Fiddler returns a self-generated HTTP error (for instance DNS lookup failed, etc)public void OnBeforeReturningError(Session oSession) { }}
}

生成并测试

开始捕获

保存到文件中

点击后如下

打开查看内容如下

以上说明功能完成

示例代码下载

https://download.csdn.net/download/zengraoli/12120294

已在demo上做了修改,url写出到固定文件中,只需要替换本文相应代码即可

参考的链接

  • https://www.cnblogs.com/weekend001/archive/2013/12/13/3473632.html
  • https://www.cnblogs.com/rufus-hua/p/5275980.html
  • https://www.qxqzx.com/contents/623.html
  • https://www.sohu.com/a/190260237_741445
  • https://blog.csdn.net/qqaiqqaiww/article/details/92800318
  • https://www.cnblogs.com/weekend001/p/3472912.html
  • https://blog.csdn.net/x333vxhl/article/details/55188371
  • https://www.qxqzx.com/contents/623.html

fiddler4写插件总结相关推荐

  1. 为jQuery写插件

    很多场合,我们都会调用jQuery的插件去完成某个功能,比如slider. 如下图,做一个div,通过"$( "#slider" ).slider();"的方式 ...

  2. 自制vue组件通信插件:教你如何用mixin写插件

    "vue-unicom"的作者:szpoppy,如果觉得对你有用,请一定点个star 这个项目虽然是szpoppy的个人项目,但是在szpoppy公司内是在大面积使用的,一直由sz ...

  3. 从0带你写插件之微信防撤回,保姆级教学代码一行一行解读

    前几天逛看雪的时候,发现fickle大佬的这个思路很是不错,正好我也挺感兴趣的,就去学了一下inlinehook,嗯,不太难,所以就有了这篇文章,我从0开始讲这个代码框架,我很尽量的把这篇博客写的详细 ...

  4. nagios自写插件—check_file

    借助插件进行的每一次有效的Nagios检查(Nagios check)都会生成一个数字表示的退出状态.可能的状态有: 0--各方面都正常,检查成功完成. 1--资源处于警告状态. 2--资源处于临界状 ...

  5. 【Unity UGUI】简单的美术字体的制作(教你写插件)

    在 unity UGUI 使用中我们常常用到美术字体,然而有时却没有那么复杂那么多,再此介绍下生成美术字体的原理 选中预先制作好的图片 点击Go 就可以生成一个简单的字体了 使用也很简单 要注意设置( ...

  6. 插件制作教程 php,typecho插件编写教程(二):写一个新插件

    第一节我们了解了一个插件的基本构成,下面我们需要一个实例练习巩固. 真赶巧,老高最近正在改版百度sitemap提交插件for typecho,下面和老高一起改版吧! 准备 不知道大家用过WP版的百度结 ...

  7. 如何用python写html的插件,使用python开发vim插件及心得分享

    如何使vim下开发python调试更方便 如何用 Python 给 Vim 写插件 如何使 Vim 下开发 Python 调试更方便 怎么用python调用matlab? 打算用vim写Python ...

  8. 使用FireBreath写浏览器插件(三)

    三. FireBreath Helloworld 首先需要创建一个自己插件的工程,首先要安装Python,然后进入命令行后,在Firebreath的源代码目录下执行:python fbgen.py,这 ...

  9. 使用FireBreath写浏览器插件(二)

    二. Firebreath的实际应用 去年我在给公司开发PC上Widget引擎,这个Widget引擎上面运行WebApp应用,界面和应用逻辑使用HTML+CSS+Javascript实现,而网页无法实 ...

  10. 一起写atom插件(1)——写个简单的插件

    前言 atom是个非常不错的编辑器,当然前提是你要会自己写插件,至少是可以fork一下别人的插件改成自己的,这是用atom的必备技能. 因为atom的开源性质,插件也参差不齐,很难找到完全符合自己的插 ...

最新文章

  1. Linux文件系统中的inode节点详细介绍
  2. IE6下fixed失效的解决方法
  3. LeetCode动态规划 最大子序和
  4. burst什么意思_为什么Windows/iOS操作很流畅而Linux/Android却很卡顿呢?
  5. SpringCloud feign、hystrix、zuul超时配置
  6. Android平台SQLite快速入门“.NET研究”实践
  7. Python+OpenCV:理解k近邻(kNN)算法(k-Nearest Neighbour (kNN) algorithm)
  8. idea一键导包快捷键_十三肝了2晚的《IDEA操作手册-终极秘籍》终于来了...
  9. [Linux] 解决Ubuntu12.10 64位google chrome安装Flash后出现couldn‘t load plug-in的问题;
  10. HDU1716 排列2【全排列+输出格式】
  11. Python 类的几个内置装饰器—— Staticmethod Classmethod Property
  12. 数据挖掘——数据预处理
  13. PLC如何读取模拟量
  14. Unity中不同平台快速切换
  15. 《创造成功本能》 博客思听 2011年2月
  16. apicloud mysql_apiCloud中的API对象
  17. 海兰一体计算机配置,新一代办公神器!海兰一体机G40 plus为何受职场人士追捧?...
  18. 学籍(学生)信息管理系统
  19. “微软烦了我一年,还告诉我要笑着忍受”
  20. ABP vnext 控制器知识整理

热门文章

  1. 《Android 应用案例开发大全(第3版)》——第1.2节掀起Android的盖头来
  2. c程序设计语言 azw,Go语言程序设计[azw3+epub+mobi][18.06MB]
  3. 在真机上 模拟GPS
  4. Fiddler 教程
  5. Python代码缩进
  6. 使用 Ajax 上传文件
  7. 中国自由软件推广先锋的自述,心潮澎湃的一往无前,一定要看!作者:洪峰
  8. 关于ping是用的TCP还是UDP的争论
  9. 火山PC画板打造UI
  10. synopsys软件介绍