コード例 #1
0
 public void AutoTamperResponseAfter(Session oSession)
 {
     if (!isOnLoad)
     {
         return;
     }
     if (myFreeHttpWindow.IsResponseRuleEnable)
     {
         if (isSkipUiHide && oSession["ui-hide"] == "true")
         {
             return;
         }
         if (myFreeHttpWindow.ModificSettingInfo.IsSkipConnectTunnels && oSession.RequestMethod == "CONNECT")
         {
             return;
         }
         List <IFiddlerHttpTamper> matchItems = FiddlerSessionHelper.FindMatchTanperRule(oSession, myFreeHttpWindow.FiddlerResponseChangeList, false);
         if (matchItems != null && matchItems.Count > 0)
         {
             foreach (var matchItem in matchItems)
             {
                 FiddlerResponseChange nowFiddlerResponseChange = ((FiddlerResponseChange)matchItem);
                 ListViewItem          tempListViewItem         = myFreeHttpWindow.FindListViewItemFromRule(matchItem);
                 if (!(nowFiddlerResponseChange.IsRawReplace && nowFiddlerResponseChange.IsIsDirectRespons))
                 {
                     FreeHttpWindow.MarkMatchRule(tempListViewItem);
                     MarkSession(oSession);
                     ShowMes(string.Format("macth the [reponse rule {0}] with {1}", tempListViewItem.SubItems[0].Text, oSession.fullUrl));
                     FiddlerSessionTamper.ModificSessionResponse(oSession, nowFiddlerResponseChange, ShowError, ShowMes);
                 }
                 if (nowFiddlerResponseChange.LesponseLatency > 0)
                 {
                     ShowMes(string.Format("[reponse rule {0}] is modified , now delay {1} ms", tempListViewItem.SubItems[0].Text, nowFiddlerResponseChange.LesponseLatency));
                     System.Threading.Thread.Sleep(nowFiddlerResponseChange.LesponseLatency);
                 }
                 if (myFreeHttpWindow.ModificSettingInfo.IsOnlyMatchFistTamperRule)
                 {
                     break;
                 }
             }
         }
     }
 }
コード例 #2
0
        private void FiddlerApplication_OnWebSocketMessage(object sender, WebSocketMessageEventArgs e)
        {
            //((Bitmap)((Fiddler.Session)sender).ViewItem.ImageList.Images[34]).Save(@"D:\A1.ico", System.Drawing.Imaging.ImageFormat.Icon);
            Session          oSession         = (Session)sender;
            WebSocketMessage webSocketMessage = e.oWSM;

            if (!isOnLoad)
            {
                return;
            }
            if (webSocketMessage == null)
            {
                AddFiddlerObjectLog("get null WebSocketMessage");
                return;
            }
            if (webSocketMessage.FrameType == WebSocketFrameTypes.Close ||
                webSocketMessage.FrameType == WebSocketFrameTypes.Ping ||
                webSocketMessage.FrameType == WebSocketFrameTypes.Pong ||
                webSocketMessage.FrameType == WebSocketFrameTypes.Reservedx3 ||
                webSocketMessage.FrameType == WebSocketFrameTypes.Reservedx4 ||
                webSocketMessage.FrameType == WebSocketFrameTypes.Reservedx5 ||
                webSocketMessage.FrameType == WebSocketFrameTypes.Reservedx6 ||
                webSocketMessage.FrameType == WebSocketFrameTypes.Reservedx7 ||
                webSocketMessage.FrameType == WebSocketFrameTypes.ReservedxB ||
                webSocketMessage.FrameType == WebSocketFrameTypes.ReservedxC ||
                webSocketMessage.FrameType == WebSocketFrameTypes.ReservedxD ||
                webSocketMessage.FrameType == WebSocketFrameTypes.ReservedxE ||
                webSocketMessage.FrameType == WebSocketFrameTypes.ReservedxF)
            {
                return;
            }
            if ((myFreeHttpWindow.IsRequestRuleEnable && webSocketMessage.IsOutbound) || (myFreeHttpWindow.IsResponseRuleEnable && !webSocketMessage.IsOutbound))
            {
                if (isSkipUiHide && oSession["ui-hide"] == "true")
                {
                    return;
                }
                if (myFreeHttpWindow.ModificSettingInfo.IsSkipConnectTunnels && oSession.RequestMethod == "CONNECT")
                {
                    return;
                }
                bool isRequest = webSocketMessage.IsOutbound;
                List <IFiddlerHttpTamper> matchItems = null;
                if (isRequest)
                {
                    matchItems = FiddlerSessionHelper.FindMatchTanperRule(oSession, myFreeHttpWindow.FiddlerRequestChangeList, isRequest, webSocketMessage);
                }
                else
                {
                    //oSession.WriteResponseToStream(new MemoryStream(new Byte[] { 0x81,0x81,0x01,0x41 }), false);
                    //WebSocket ws = oSession.__oTunnel as WebSocket;
                    //ws.listMessages.Add(webSocketMessage);
                    matchItems = FiddlerSessionHelper.FindMatchTanperRule(oSession, myFreeHttpWindow.FiddlerResponseChangeList, isRequest, webSocketMessage);
                }
                if (matchItems != null && matchItems.Count > 0)
                {
                    foreach (var matchItem in matchItems)
                    {
                        ListViewItem tempListViewItem = myFreeHttpWindow.FindListViewItemFromRule(matchItem);
                        FreeHttpWindow.MarkMatchRule(tempListViewItem);
                        MarkSession(oSession);
                        ShowMes(string.Format("macth the [requst rule {0}] with {1}", tempListViewItem.SubItems[0].Text, oSession.fullUrl));
                        FiddlerSessionTamper.ModificWebSocketMessage(oSession, webSocketMessage, matchItem, isRequest, ShowError, ShowMes);
                        if (!isRequest)
                        {
                            FiddlerResponseChange nowFiddlerResponseChange = ((FiddlerResponseChange)matchItem);
                            if (nowFiddlerResponseChange.LesponseLatency > 0)
                            {
                                ShowMes(string.Format("[reponse rule {0}] is modified , now delay {1} ms", tempListViewItem.SubItems[0].Text, nowFiddlerResponseChange.LesponseLatency));
                                System.Threading.Thread.Sleep(nowFiddlerResponseChange.LesponseLatency);
                            }
                            if (myFreeHttpWindow.ModificSettingInfo.IsOnlyMatchFistTamperRule)
                            {
                                break;
                            }
                        }
                    }
                }
            }
        }
コード例 #3
0
        public void AutoTamperRequestBefore(Session oSession)
        {
            //if (oSession.HTTPMethodIs("CONNECT") && oSession.HostnameIs("api.map.baidu.com"))
            //{
            //    oSession["x-OverrideSslProtocols"] = "ssl3.0";
            //}
            //oSession.oRequest["AddOrigin"] = "from lijie PC";
            if (!isOnLoad)
            {
                return;
            }
            if (myFreeHttpWindow.IsRequestRuleEnable)
            {
                //IsRequestRuleEnable is more efficient then string comparison (so if not IsRequestRuleEnable the string comparison will not execute)
                if (isSkipUiHide && oSession["ui-hide"] == "true")
                {
                    return;
                }
                if (myFreeHttpWindow.ModificSettingInfo.IsSkipConnectTunnels && oSession.RequestMethod == "CONNECT")
                {
                    return;
                }
                List <IFiddlerHttpTamper> matchItems = FiddlerSessionHelper.FindMatchTanperRule(oSession, myFreeHttpWindow.FiddlerRequestChangeList, true);
                if (matchItems != null && matchItems.Count > 0)
                {
                    foreach (var matchItem in matchItems)
                    {
                        FiddlerRequestChange nowFiddlerRequsetChange = ((FiddlerRequestChange)matchItem);
                        ListViewItem         tempListViewItem        = myFreeHttpWindow.FindListViewItemFromRule(matchItem);
                        FreeHttpWindow.MarkMatchRule(tempListViewItem);
                        MarkSession(oSession);
                        ShowMes(string.Format("macth the [requst rule {0}] with {1}", tempListViewItem.SubItems[0].Text, oSession.fullUrl));
                        FiddlerSessionTamper.ModificSessionRequest(oSession, nowFiddlerRequsetChange, ShowError, ShowMes);
                        if (myFreeHttpWindow.ModificSettingInfo.IsOnlyMatchFistTamperRule)
                        {
                            break;
                        }
                    }
                }
            }

            if (myFreeHttpWindow.IsResponseRuleEnable)
            {
                if (myFreeHttpWindow.ModificSettingInfo.IsSkipConnectTunnels && oSession.RequestMethod == "CONNECT")
                {
                    return;
                }
                List <IFiddlerHttpTamper> matchItems = FiddlerSessionHelper.FindMatchTanperRule(oSession, myFreeHttpWindow.FiddlerResponseChangeList, false);
                if (matchItems != null && matchItems.Count > 0)
                {
                    oSession.bBufferResponse = true;//  if any response rule may match the Session, we should set bBufferResponse true (When streaming is enabled for a response, each block of data read from the server is immediately passed to the client application. )
                    foreach (var matchItem in matchItems)
                    {
                        FiddlerResponseChange nowFiddlerResponseChange = ((FiddlerResponseChange)matchItem);
                        ListViewItem          tempListViewItem         = myFreeHttpWindow.FindListViewItemFromRule(matchItem);
                        if (nowFiddlerResponseChange.IsIsDirectRespons)
                        {
                            FreeHttpWindow.MarkMatchRule(tempListViewItem);
                            MarkSession(oSession);
                            ShowMes(string.Format("macth the [reponse rule {0}] with {1}", tempListViewItem.SubItems[0].Text, oSession.fullUrl));
                            FiddlerSessionTamper.ReplaceSessionResponse(oSession, nowFiddlerResponseChange, ShowError, ShowMes);
                            //oSession.state = SessionStates.Done;
                            if (myFreeHttpWindow.ModificSettingInfo.IsOnlyMatchFistTamperRule)
                            {
                                break;
                            }
                        }
                    }
                }
            }
        }
コード例 #4
0
ファイル: FiddlerFreeHttp.cs プロジェクト: yesnomore/FreeHttp
        public void AutoTamperRequestBefore(Session oSession)
        {
            //if (oSession.HTTPMethodIs("CONNECT") && oSession.HostnameIs("api.map.baidu.com"))
            //{
            //    oSession["x-OverrideSslProtocols"] = "ssl3.0";
            //}
            //oSession.oRequest["AddOrigin"] = "from lijie PC";
            if (!isOnLoad)
            {
                return;
            }
            if (myFreeHttpWindow.IsRequestRuleEnable)
            {
                //IsRequestRuleEnable is more efficient then string comparison (so if not IsRequestRuleEnable the string comparison will not execute)
                if (isSkipUiHide && oSession["ui-hide"] == "true")
                {
                    return;
                }
                if (myFreeHttpWindow.ModificSettingInfo.IsSkipTlsHandshake && oSession.RequestMethod == "CONNECT")
                {
                    return;
                }
                List <ListViewItem> matchItems = FiddlerSessionHelper.FindMatchTanperRule(oSession, myFreeHttpWindow.RequestRuleListView, true);
                if (matchItems != null && matchItems.Count > 0)
                {
                    foreach (var matchItem in matchItems)
                    {
                        FiddlerRequsetChange nowFiddlerRequsetChange = ((FiddlerRequsetChange)matchItem.Tag);
                        FreeHttpWindow.MarkMatchRule(matchItem);
                        MarkSession(oSession);
                        ShowMes(string.Format("macth the [requst rule {0}] with {1}", matchItem.SubItems[0].Text, oSession.fullUrl));
                        FiddlerSessionTamper.ModificSessionRequest(oSession, nowFiddlerRequsetChange, ShowError, ShowMes);
                        if (myFreeHttpWindow.ModificSettingInfo.IsOnlyMatchFistTamperRule)
                        {
                            break;
                        }
                    }
                }
            }

            if (myFreeHttpWindow.IsResponseRuleEnable)
            {
                if (myFreeHttpWindow.ModificSettingInfo.IsSkipTlsHandshake && oSession.RequestMethod == "CONNECT")
                {
                    return;
                }
                List <ListViewItem> matchItems = FiddlerSessionHelper.FindMatchTanperRule(oSession, myFreeHttpWindow.ResponseRuleListView, false);
                if (matchItems != null && matchItems.Count > 0)
                {
                    foreach (var matchItem in matchItems)
                    {
                        FiddlerResponseChange nowFiddlerResponseChange = ((FiddlerResponseChange)matchItem.Tag);
                        if (nowFiddlerResponseChange.IsIsDirectRespons)
                        {
                            FreeHttpWindow.MarkMatchRule(matchItem);
                            MarkSession(oSession);
                            ShowMes(string.Format("macth the [reponse rule {0}] with {1}", matchItem.SubItems[0].Text, oSession.fullUrl));
                            FiddlerSessionTamper.ReplaceSessionResponse(oSession, nowFiddlerResponseChange, ShowError, ShowMes);
                            //oSession.state = SessionStates.Done;
                            if (myFreeHttpWindow.ModificSettingInfo.IsOnlyMatchFistTamperRule)
                            {
                                break;
                            }
                        }
                    }
                }
            }
        }