美文网首页
fiddlerScript oSession 方法等收集(发送请

fiddlerScript oSession 方法等收集(发送请

作者: 码农私房菜 | 来源:发表于2023-11-06 12:44 被阅读0次

    判断请求 响应的网络状态码

    oSession.responseCode === 200Script

    判断请求 uri 是否包含某些字符

    oSession.uriContains("xieboke.net")

    oSession.fullUrl.Contains("xieboke.net")

    获取返回结果并转成 字符串

    oSession.GetResponseBodyAsString();

    获取 json 返回结果中的中某个字段

    var response_string = oSession.GetResponseBodyAsString();

    // 字符串 转成可以操作的 json 格式
    var response_json = Fiddler.WebFormats.JSON.JsonDecode(response_string);
    var is_double = response_json.JSONObject["isDouble"]

    修改 Session 的样式等

    oSession["ui-backcolor"] = "yellow"; // 背景色 - yellow 黄色,red 红色,green 绿色,Lavender 淡紫色

    oSession["ui-color"] = "red"; // 字体颜色

    oSession["ui-hide"] = "true"; // 不显示

    oSession["ui-bold"]="true"; // 字体加粗

    oSession["ui-italic"] = "yup"; //设置字体斜体,字符串无所谓

    oSession["ui-customcolumn"] = '高佣api'; //设置Custom一列显示文案

    FiddlerObject.playSound("C:\windows\media\tada.wav"); //设置请求时播放的声音

    获取请求的参数

    oSession.oRequest.headers; // 获取整个请求头

    oSession.oRequest.headers["token"]; // 获取 请求头 token 的值

    oSession.oRequest.headers.Exists("Authorization"); // 判断请求头 Authorization 是否存在

    oSession.Hostname; // 获取请求的域名

    oSession.port; // 获取请求的端口

    修改请求头的参数

    oSession.RequestHeaders.Remove("User-Agent"); // 删除 User-Agent 传参

    oSession.RequestHeaders["uid"] = "0"; //修改请求头

    修改返回的参数

    oSession.oResponse["Cache-Control"] = "no-cache";

    打印日志

    FiddlerApplication.Log.LogString("xieboke_net_log: " + "test");

    弹个对话框

    FiddlerObject.alert("弹个对话框");

    MessageBox.Show("弹个框");

    修改请求的域名

    if (oSession.HostnameIs('baidu.com')){
            oSession.hostname = '=xieboke.net';
    }
    

    Copy

    发起网络请求

    if(oSession.hostname.Contains("xieboke.net") || oSession.hostname.Contains("zhuoqun.info") ){
    
            var key="";
            var request_body = oSession.GetRequestBodyAsString().replace(/"/g,"'");
            var response_body = oSession.GetResponseBodyAsString().replace(/"/g,"'");
            var content = "[" + oSession.responseCode + "] " + oSession.oRequest.headers + "\r\nRequests:\r\n" + request_body + "\r\nResponse:\r\n" + response_body;
            //MessageBox.Show(content)
            //var content="test"
            var dingding_hook = "https://oapi.dingtalk.com/robot/send?access_token=xxx"
            var user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36"
            var body = '{"msgtype": "text","text": {"content": "' + content + '"}}'
            var body_length =  body.toString().length;
    
            var method = "POST";
            var myUrl = dingding_hook;
            var url = myUrl;
            var protocol = "HTTP/1.1";
            var raw="";
    
            raw += method + " " + url + " " + protocol + "\r\n";
            raw += "User-Agent:" + user_agent + "\r\n";
            raw += "Content-Length:" + body_length + "\r\n";
            raw += "Content-Type:application/json; charset=utf-8" + "\r\n\r\n";
            raw += body + "\r\n\\r\n";
            //MessageBox.Show(raw)
    
            try{ 
                // Make a recursive HTTP request for the next item.
                FiddlerObject.utilIssueRequest(raw); 
            } 
            catch(e){ 
                MessageBox.Show(e.ToString()); 
            } 
        }   
    

    Copy

    保存到文件

    //文件保存路径,可自定义
    file = fso.OpenTextFile("E:\\zhuoyuebiji\\fiddler_session\\convert.log",8 ,true, true);
    file.writeLine("Response code: " + oSession.responseCode + " [" + curDate.toLocaleString() + "]");
    //file.writeLine("Response body: " + oSession.GetResponseBodyAsString());
    //file.writeLine("Test: " + typeof(resultToJson));
    file.writeLine("tbkConvertURL:[" + tbkConvertURL + "]");
    file.writeLine("\n");
    file.close();
    

    Copy

    时间格式化

    var now = new Date();
    var ts = now.getFullYear()+now.getMonth()+now.getDate()+now.getDay()+now.getHours()+now.getMinutes()+now.getSeconds()+now.getMilliseconds();
    var timeString = now.getFullYear() + now.getMonth()+ now.getDate() + now.getDay();
    

    相关文章

      网友评论

          本文标题:fiddlerScript oSession 方法等收集(发送请

          本文链接:https://www.haomeiwen.com/subject/fyatwdtx.html