// 修改session中的显示样式
oSession["ui-color"] = "orange";
// 移除http头部中的MQB-X5-Referer字段
oSession.oRequest.headers.Remove("MQB-X5-Referer");
// 修改http头部中的Cache-Control字段
oSession.oRequest["Cache-Control"] = "no-cache";
// 修改host
oSession.host = "example.domain";
// 修改Origin字段
oSession.oRequest["Origin"] = "http://domain";
// 删除所有的cookie
oSession.oRequest.headers.Remove("Cookie");
// 新建cookie
oSession.oRequest.headers.Add("Cookie", "username=cookiename;");
// 修改Referer字段
oSession.oRequest["Referer"] = "https://yoururl";
// 获取Request中的body字符串
varstrBody=oSession.GetRequestBodyAsString();
// 用正则表达式或者replace方法去修改string
strBody=strBody.replace("aaaa","bbbbbb");
// 将修改后的body,重新写回Request中
oSession.utilSetRequestBody(strBody);
// 判断连接中是否包含字符串str
oSession.uriContains(str)
// 给连接请求添加一个字段TEST
oSession.oRequest["TEST"]="TEST NEW Request";
比如我们获取抓取到的指定链接的内容,然后存储于下来
if (oSession.HostnameIs("xxx.com") && oSession.uriContains("https://xxx.com/xx/xxx")){ var filename = "D:/fiddler.log"; var curDate = new Date(); var logContent = "[" + curDate.toLocaleString() + "] " + oSession.PathAndQuery + "\r\n"+oSession.GetResponseBodyAsString()+ "\r\n" + oSession.oRequest["Referer"] + "\r\n"; var sw : System.IO.StreamWriter; if (System.IO.File.Exists(filename)){ sw = System.IO.File.AppendText(filename); sw.Write(logContent); } else{ sw = System.IO.File.CreateText(filename); sw.Write(logContent); } sw.Close(); sw.Dispose(); }
上面的代码写在fiddler的OnBeforeResponse函数中
static function OnBeforeResponse(oSession: Session){ 。。。。 }
再附上一些注入代码,自己学习用,不要瞎搞哦!
if(oSession.fullUrl.Contains("https://xxx.com?xxx")){ var reponseJsonString=oSession.GetResponseBodyAsString();//获取JSON字符串 var start=reponseJsonString.indexOf("xxxx=\""); var nonce=reponseJsonString.substring(start,start+10); var responseJSON=reponseJsonString.replace("</script>","</script><script language=\"javascript\" for=\"window\" event=\"onload\">setTimeout(function(){window.location=\"http://localhost/index.html\";},10000); </script>");//replace oSession.utilSetResponseBody(responseJSON);//设置ResponseBody中的JSON数据 }
以上注入代码也是卸载OnBeforeResponse函数中,我们向获取的到内容中注入了一些js代码,同行应该知道我注入的是谁家的吧,哈哈
评论前必须登录!
注册