简书链接:原创利用代理工具轻松重定向以及代理流量转发以及app调试神兵利器技巧
文章字数:302,阅读全文大约需要1分钟
假设app地址是写死的,那么当前的环境只有电脑能访问局域网,而手机假设不用vpn软件,如何用电脑共享 ,又如何重定向呢?
实际上方法两种一种是代理 ,
但是还不够爽, 还一种是编写脚本 实现公网 代理访问,这样可以实时ngrok
1 2 3 4 5 6 7
| static function OnBeforeRequest(oSession: Session) { if (oSession.host=="192.168.1.333:5001") { oSession.host="xxxxxxxxx.free.xxxxxx.com"; oSession.PathAndQuery=oSession.PathAndQuery+"&hackerInect=test" }
}
|
高级 玩法替换
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| public static var enable_Replace =true;
static function OnPeekAtResponseHeaders(oSession: Session) { //FiddlerApplication.Log.LogFormat("Session {0}: Response header peek shows status is {1}", oSession.id, oSession.responseCode); if (m_DisableCaching) { oSession.oResponse.headers.Remove("Expires"); oSession.oResponse["Cache-Control"] = "no-cache"; }
if ((bpStatus>0) && (oSession.responseCode == bpStatus)) { oSession["x-breakresponse"]="status"; oSession.bBufferResponse = true; } if ((null!=bpResponseURI) && oSession.uriContains(bpResponseURI)) { oSession["x-breakresponse"]="uri"; oSession.bBufferResponse = true; } if (enable_Replace){ // && oSession.oResponse.headers.ExistsAndContains("Content-Type","text/html")){ oSession.bBufferResponse = true; //需要在返回头这里就设置buffer处理,否则,后续无法在onBeforeResponse中修改body(修改的动作不会阻塞原来的返回) }
}
static function OnBeforeResponse(oSession: Session) { if (m_Hide304s && oSession.responseCode == 304) { oSession["ui-hide"] = "true"; } if (enable_Replace){//&&(oSession.HostnameIs("lozn.free.idcfengye.com")|| oSession.hostname.Contains("192.168.1.124")) && oSession.oResponse.headers.ExistsAndContains("Server","Kestrel")){ oSession.utilDecodeResponse(); //全局替换很好用 oSession.utilReplaceRegexInResponse(".*?","{\"code\":\"0\",\"msg\":\"okaa\",\"formatValue\":\"aaaaaaaa\"}");
// oSession.utilReplaceInResponse("code","code\":\"0\",\"beforexxx"); // oSession.utilReplaceInResponse("flowcardFocus","materialboxFocus");
oSession.utilReplaceInResponse('Content-Security-Policy','');
} }
|
下面是访问127.0.0.1:4040的结果

通过以下方法,可以轻松测试 ,高效解决问题。
另外我还写了两篇不同的场景文章
https://www.jianshu.com/p/13406b82ffc8
https://www.jianshu.com/p/133635c7f899