首页 > 其他 > 详细

fiddler扩展开发笔记

时间:2019-08-01 18:47:32      阅读:225      评论:0      收藏:0      [点我收藏+]

在cshare中命名空间名称FiddlerUtility,然后写静态变量OnBeforeRequest,OnBeforeResponse

 using System;
using Fiddler;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using System.Collections.Generic;

namespace Fiddler
{
    public static class Handlers
    {
    
        public static void OnBeforeRequest(Session oSession)
        {
            var getDataDomain = "www.baidu.com";

            if (!oSession.HostnameIs(getDataDomain))
            {
                //FiddlerObject.alert("true");
                //oSession["ui-hide"] = "false";
            }

            //获取提交返回的授权信息
            if(oSession.uriContains(getDataDomain))
            {            
                var Authorization = oSession.RequestHeaders["Authorization"];
    
                if (!String.IsNullOrWhiteSpace(Authorization))
                {        
                    var authSession = "Authorization: " + Authorization;
                    FiddlerApplication.UI.SetStatusText(authSession);
                    System.IO.File.WriteAllText(@"D:\Users\Desktop\httpdata\test2.txt", authSession , Encoding.UTF8);   
                }                    
            }

            
        }
                
        public static void OnBeforeResponse(Session oSession)
        {
            //获取提交返回的授权信息
            if(oSession.uriContains("www.baidu.com"))
            {            
                var strResponseBody = oSession.GetResponseBodyAsString();
                FiddlerObject.alert(strResponseBody);
                if (!String.IsNullOrWhiteSpace(strResponseBody))
                {        
                    // var strResponseBody = "Authorization: " + Authorization;
                    // FiddlerApplication.UI.SetStatusText(authSession);
                    FiddlerObject.alert(strResponseBody);
                    System.IO.File.WriteAllText(@"D:\Users\Desktop\httpdata\test3.txt", strResponseBody , Encoding.UTF8);   
                }                    
            }
        }
        
        public static void Main(){}
    }
}

 

编译:

csc /target:library /out:D:\Users\Desktop\FiddlerExt\FiddlerHandle.dll D:\Users\Desktop\FiddlerExt\FiddlerHandle.cs /reference:"C:\Users\Administrator\AppData\local\Programs\Fiddler\Fiddler.exe"

在fiddler界面的js.net添加

import FiddlerUtility;

在OnBeforeRequest函数中添加。
FiddlerHandle.OnBeforeRequest(oSession,"D:\\Users\\Desktop\\httpdata");
在OnBeforeResponse函数中添加。
FiddlerHandle.OnBeforeResponse(oSession,"D:\\Users\\Desktop\\httpdata");

fiddler扩展开发笔记

原文:https://www.cnblogs.com/partman/p/11284511.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!