Ejemplo n.º 1
0
        private void FreeHttpWindow_Load(object sender, EventArgs e)
        {
            try
            {
                LoadFiddlerModificHttpRuleCollection(fiddlerModificHttpRuleCollection);
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("{0}\r\n{1}", ex.Message, ex.InnerException == null? "":ex.InnerException.Message), "load user rule fail");
                if (File.Exists("RuleData.xml"))
                {
                    File.Copy("RuleData.xml", "RuleData.lastErrorFile", true);
                }
            }
            if (StaticDataCollection == null)
            {
                StaticDataCollection = new ActuatorStaticDataCollection(true);
            }
            if (ModificSettingInfo == null)
            {
                ModificSettingInfo = new FiddlerModificSettingInfo(false, true, true);
            }
            if (ModificSettingInfo.IsDefaultEnableRule)
            {
                pb_requestRuleSwitch_Click(null, null);
                pb_responseRuleSwitch_Click(null, null);
            }

            FreeHttp.MyHelper.MyGlobalHelper.OnGetGlobalMessage += ((obj, arg) => { PutWarn(arg.Message); });

            tbe_RequestBodyModific.Visible          = false;
            tbe_ResponseBodyModific.Visible         = false;
            tbe_urlFilter.Visible                   = false;
            tbe_RequestBodyModific.OnCloseEditBox  += tbe_BodyModific_OnCloseEditBox;
            tbe_ResponseBodyModific.OnCloseEditBox += tbe_BodyModific_OnCloseEditBox;
            tbe_urlFilter.OnCloseEditBox           += tbe_BodyModific_OnCloseEditBox;


            cb_macthMode.SelectedIndex       = 0;
            tabControl_Modific.SelectedIndex = 0;
            IsSetResponseLatencyEable        = false;

            //rtb_MesInfo.AllowDrop = true;
            //rtb_MesInfo.DragEnter += rtb_MesInfo_DragEnter;
            //rtb_MesInfo.DragDrop += rtb_MesInfo_DragDrop;

            splitContainer_httpEditInfo.AllowDrop  = true;
            splitContainer_httpEditInfo.DragEnter += rtb_MesInfo_DragEnter;
            splitContainer_httpEditInfo.DragDrop  += rtb_MesInfo_DragDrop;

            panel_modific_Contorl.AllowDrop  = true;
            panel_modific_Contorl.DragEnter += rtb_MesInfo_DragEnter;
            panel_modific_Contorl.DragDrop  += rtb_MesInfo_DragDrop;

            MyControlHelper.SetRichTextBoxDropString(rtb_requsetReplace_body);
            MyControlHelper.SetRichTextBoxDropString(rtb_requestRaw);
        }
Ejemplo n.º 2
0
 private void RawResponseEdit_Load(object sender, EventArgs e)
 {
     initializeResponseLineDc(out responseLineDc);
     foreach (var tempKey in responseLineDc)
     {
         cb_responseLine.Items.Add(tempKey.Key);
     }
     cb_responseLine.SelectedIndex = 0;
     MyControlHelper.SetRichTextBoxDropString(rtb_rawResponse);
     //rtb_rawResponse.AllowDrop = true;
     //rtb_rawResponse.DragEnter += rtb_rawResponse_DragEnter;
     //rtb_rawResponse.DragDrop += rtb_rawResponse_DragDrop;
 }
Ejemplo n.º 3
0
        private void LoadRuleInfo(IFiddlerHttpTamper ruleInfo)
        {
            Action <FiddlerRequestChange> GetFiddlerRequestChangeAddition = (nowFiddlerRequestChange) =>
            {
                if ((nowFiddlerRequestChange.ParameterPickList != null && nowFiddlerRequestChange.ParameterPickList.Count > 0) || nowFiddlerRequestChange.IsHasParameter)
                {
                    rtb_ruleInfo.AddRtbStr("Addition ", Color.Red, true, new Font(FontFamily.GenericMonospace, 14));
                    if (nowFiddlerRequestChange.IsHasParameter)
                    {
                        rtb_ruleInfo.AddRtbStr("Has Parameter: ", Color.Blue, false);
                        rtb_ruleInfo.AppendText("true");
                        rtb_ruleInfo.AppendText("\r\n");
                    }
                    if (nowFiddlerRequestChange.ParameterPickList != null && nowFiddlerRequestChange.ParameterPickList.Count > 0)
                    {
                        foreach (var tempRequest in nowFiddlerRequestChange.ParameterPickList)
                        {
                            rtb_ruleInfo.AddRtbStr("Request Parameter Pick: ", Color.Blue, false);
                            rtb_ruleInfo.AppendText(tempRequest.ToString());
                            rtb_ruleInfo.AppendText("\r\n");
                        }
                    }
                }
            };
            Action <FiddlerResponseChange> GetFiddlerResponseChangeAddition = (nowFiddlerResponseChange) =>
            {
                if ((nowFiddlerResponseChange.ParameterPickList != null && nowFiddlerResponseChange.ParameterPickList.Count > 0) || nowFiddlerResponseChange.IsHasParameter || nowFiddlerResponseChange.ResponseLatency > 0)
                {
                    rtb_ruleInfo.AddRtbStr("Addition ", Color.Red, true, new Font(FontFamily.GenericMonospace, 14));
                    if (nowFiddlerResponseChange.IsHasParameter)
                    {
                        rtb_ruleInfo.AddRtbStr("Has Parameter: ", Color.Blue, false);
                        rtb_ruleInfo.AppendText("true");
                        rtb_ruleInfo.AppendText("\r\n");
                    }
                    if (nowFiddlerResponseChange.ResponseLatency > 0)
                    {
                        rtb_ruleInfo.AddRtbStr("ResponseLatency: ", Color.Blue, false);
                        rtb_ruleInfo.AppendText(nowFiddlerResponseChange.ResponseLatency + "ms");
                        rtb_ruleInfo.AppendText("\r\n");
                    }
                    if (nowFiddlerResponseChange.ParameterPickList != null && nowFiddlerResponseChange.ParameterPickList.Count > 0)
                    {
                        foreach (var tempResponse in nowFiddlerResponseChange.ParameterPickList)
                        {
                            rtb_ruleInfo.AddRtbStr("Response Parameter Pick: ", Color.Blue, false);
                            rtb_ruleInfo.AppendText(tempResponse.ToString());
                            rtb_ruleInfo.AppendText("\r\n");
                        }
                    }
                }
            };

            isLoadRuleComplete = false;
            MyControlHelper.SetControlFreeze(rtb_ruleInfo);
            MyControlHelper.SetControlFreeze(this);
            pb_ruleIcon.Image = InnerListViewItem.ImageList.Images[InnerListViewItem.ImageIndex];
            rtb_ruleInfo.Clear();
            rtb_ruleInfo.AddRtbStr("Filter ", Color.Red, true, new Font(FontFamily.GenericMonospace, 14));
            if (ruleInfo.HttpFilter.UriMatch != null)
            {
                rtb_ruleInfo.AddRtbStr("Uri: ", Color.Blue, false);
                rtb_ruleInfo.AppendText(ruleInfo.HttpFilter.UriMatch.ToString());
                rtb_ruleInfo.AppendText("\r\n");
            }
            if (ruleInfo.HttpFilter.HeadMatch != null && ruleInfo.HttpFilter.HeadMatch.HeadsFilter.Count > 0)
            {
                foreach (var tempHeaderFilter in ruleInfo.HttpFilter.HeadMatch.HeadsFilter)
                {
                    rtb_ruleInfo.AddRtbStr("Header: ", Color.Blue, false);
                    rtb_ruleInfo.AppendText(string.Format("{0} [contain] {1}", tempHeaderFilter.Key, tempHeaderFilter.Value));
                    rtb_ruleInfo.AppendText("\r\n");
                }
            }
            if (ruleInfo.HttpFilter.BodyMatch != null)
            {
                rtb_ruleInfo.AddRtbStr("Entity: ", Color.Blue, false);
                rtb_ruleInfo.AppendText(ruleInfo.HttpFilter.BodyMatch.ToString());
                rtb_ruleInfo.AppendText("\r\n");
            }
            rtb_ruleInfo.AddRtbStr("Action ", Color.Red, true, new Font(FontFamily.GenericMonospace, 14));

            switch (ruleInfo.TamperProtocol)
            {
            case TamperProtocalType.Http:
                if (ruleInfo is FiddlerRequestChange)
                {
                    lb_ruleId.Text = string.Format("Http Request Tamper Rule {0}", InnerListViewItem.SubItems[0].Text);

                    FiddlerRequestChange nowFiddlerRequestChange = ruleInfo as FiddlerRequestChange;
                    if (nowFiddlerRequestChange.IsRawReplace)
                    {
                        rtb_ruleInfo.AddRtbStr("Request Replace", Color.Blue, true);
                        rtb_ruleInfo.AppendText(nowFiddlerRequestChange.HttpRawRequest.OriginSting);
                        rtb_ruleInfo.AppendText("\r\n");
                    }
                    else
                    {
                        if (nowFiddlerRequestChange.UriModific != null && nowFiddlerRequestChange.UriModific.ModificMode != HttpHelper.ContentModificMode.NoChange)
                        {
                            rtb_ruleInfo.AddRtbStr("Request Uri Modific: ", Color.Blue, false);
                            rtb_ruleInfo.AppendText(nowFiddlerRequestChange.UriModific.ToString());
                            rtb_ruleInfo.AppendText("\r\n");
                        }
                        if (nowFiddlerRequestChange.HeadDelList != null && nowFiddlerRequestChange.HeadDelList.Count > 0)
                        {
                            foreach (var tempHeaderDel in nowFiddlerRequestChange.HeadDelList)
                            {
                                rtb_ruleInfo.AddRtbStr("Request Head Delete: ", Color.Blue, false);
                                rtb_ruleInfo.AppendText(tempHeaderDel);
                            }
                        }
                        if (nowFiddlerRequestChange.HeadAddList != null && nowFiddlerRequestChange.HeadAddList.Count > 0)
                        {
                            foreach (var tempHeaderAdd in nowFiddlerRequestChange.HeadAddList)
                            {
                                rtb_ruleInfo.AddRtbStr("Request Head Add: ", Color.Blue, false);
                                rtb_ruleInfo.AppendText(tempHeaderAdd);
                                rtb_ruleInfo.AppendText("\r\n");
                            }
                        }
                        if (nowFiddlerRequestChange.BodyModific != null && nowFiddlerRequestChange.BodyModific.ModificMode != HttpHelper.ContentModificMode.NoChange)
                        {
                            rtb_ruleInfo.AddRtbStr("Request Entity Modific: ", Color.Blue, false);
                            rtb_ruleInfo.AppendText(nowFiddlerRequestChange.BodyModific.ToString());
                            rtb_ruleInfo.AppendText("\r\n");
                        }
                    }
                    GetFiddlerRequestChangeAddition(nowFiddlerRequestChange);
                }
                else if (ruleInfo is FiddlerResponseChange)
                {
                    lb_ruleId.Text = string.Format("Http Response Tamper Rule {0}", InnerListViewItem.SubItems[0].Text);

                    FiddlerResponseChange nowFiddlerResponseChange = ruleInfo as FiddlerResponseChange;
                    if (nowFiddlerResponseChange.IsRawReplace)
                    {
                        rtb_ruleInfo.AddRtbStr("Request Replace", Color.Blue, true);
                        rtb_ruleInfo.AppendText(nowFiddlerResponseChange.HttpRawResponse.OriginSting);
                        rtb_ruleInfo.AppendText("\r\n");
                    }
                    else
                    {
                        if (nowFiddlerResponseChange.HeadDelList != null && nowFiddlerResponseChange.HeadDelList.Count > 0)
                        {
                            foreach (var tempHeaderDel in nowFiddlerResponseChange.HeadDelList)
                            {
                                rtb_ruleInfo.AddRtbStr("Response Head Delete: ", Color.Blue, false);
                                rtb_ruleInfo.AppendText(tempHeaderDel);
                                rtb_ruleInfo.AppendText("\r\n");
                            }
                        }
                        if (nowFiddlerResponseChange.HeadAddList != null && nowFiddlerResponseChange.HeadAddList.Count > 0)
                        {
                            foreach (var tempHeaderAdd in nowFiddlerResponseChange.HeadAddList)
                            {
                                rtb_ruleInfo.AddRtbStr("Response Head Add: ", Color.Blue, false);
                                rtb_ruleInfo.AppendText(tempHeaderAdd);
                                rtb_ruleInfo.AppendText("\r\n");
                            }
                        }
                        if (nowFiddlerResponseChange.BodyModific != null && nowFiddlerResponseChange.BodyModific.ModificMode != HttpHelper.ContentModificMode.NoChange)
                        {
                            rtb_ruleInfo.AddRtbStr("Response Entity Modific: ", Color.Blue, false);
                            rtb_ruleInfo.AppendText(nowFiddlerResponseChange.BodyModific.ToString());
                            rtb_ruleInfo.AppendText("\r\n");
                        }
                    }

                    GetFiddlerResponseChangeAddition(nowFiddlerResponseChange);
                }
                break;

            case TamperProtocalType.WebSocket:
                if (ruleInfo is FiddlerRequestChange)
                {
                    lb_ruleId.Text = string.Format("Websocket Send Tamper Rule {0}", InnerListViewItem.SubItems[0].Text);

                    FiddlerRequestChange nowFiddlerWebSocketRequestChange = ruleInfo as FiddlerRequestChange;
                    if (nowFiddlerWebSocketRequestChange.BodyModific != null && nowFiddlerWebSocketRequestChange.BodyModific.ModificMode != HttpHelper.ContentModificMode.NoChange)
                    {
                        rtb_ruleInfo.AddRtbStr("Socket Payload Modific: ", Color.Blue, false);
                        rtb_ruleInfo.AppendText(nowFiddlerWebSocketRequestChange.BodyModific.ToString());
                        rtb_ruleInfo.AppendText("\r\n");
                    }
                    GetFiddlerRequestChangeAddition(nowFiddlerWebSocketRequestChange);
                }
                else if (ruleInfo is FiddlerResponseChange)
                {
                    lb_ruleId.Text = string.Format("Websocket Receive Tamper Rule {0}", InnerListViewItem.SubItems[0].Text);

                    FiddlerResponseChange nowFiddlerWebSocketResponseChange = ruleInfo as FiddlerResponseChange;
                    if (nowFiddlerWebSocketResponseChange.BodyModific != null && nowFiddlerWebSocketResponseChange.BodyModific.ModificMode != HttpHelper.ContentModificMode.NoChange)
                    {
                        rtb_ruleInfo.AddRtbStr("Socket Payload Modific: ", Color.Blue, false);
                        rtb_ruleInfo.AppendText(nowFiddlerWebSocketResponseChange.BodyModific.ToString());
                        rtb_ruleInfo.AppendText("\r\n");
                    }
                    GetFiddlerResponseChangeAddition(nowFiddlerWebSocketResponseChange);
                }

                break;

            default:
                break;
            }
            if (!string.IsNullOrEmpty(ruleInfo.HttpFilter.Name))
            {
                lb_ruleId.Text += string.Format(" ({0})", ruleInfo.HttpFilter.Name);
            }
            isLoadRuleComplete = true;
            MyControlHelper.SetControlUnfreeze(rtb_ruleInfo);
            MyControlHelper.SetControlUnfreeze(this);
            if (rtb_ruleInfo.Rtf.EndsWith("\r\n"))
            {
                rtb_ruleInfo.Rtf = rtb_ruleInfo.Rtf.Remove(rtb_ruleInfo.Rtf.Length - 2, 2);
            }
        }
Ejemplo n.º 4
0
        public void UpdatalistView_CaseParameter(bool isNew)
        {
            if (isNew)
            {
                MyControlHelper.SetControlFreeze(listView_CaseParameter);
                listView_CaseParameter.BeginUpdate();
                listView_CaseParameter.Items.Clear();
                try
                {
                    //Dictionary<string, IRunTimeStaticData> tempUpdateStaticDataDictionary = null;
                    //Dictionary<string, IRunTimeDataSource> tempUpdateDataSourceDictionary = null;
                    dynamic tempUpdateDictionary = null;
                    switch (nowShowType)
                    {
                    case ShowRunTimeParameterType.KeyValue:
                        tempUpdateDictionary = actuatorStaticDataCollection.RunActuatorStaticDataKeyList;
                        break;

                    case ShowRunTimeParameterType.Parameter:
                        tempUpdateDictionary = actuatorStaticDataCollection.RunActuatorStaticDataParameterList;
                        break;

                    case ShowRunTimeParameterType.DataSouce:
                        tempUpdateDictionary = actuatorStaticDataCollection.RunActuatorStaticDataSouceList;
                        break;

                    default:
                        MessageBox.Show("nonsupport static data type");
                        break;
                    }
                    if (tempUpdateDictionary != null && tempUpdateDictionary.Count > 0)
                    {
                        foreach (var tempKvp in tempUpdateDictionary)
                        {
                            ListViewItem tempItem = new ListViewItem(new string[] { tempKvp.Key, CaseRunTimeDataTypeEngine.dictionaryStaticDataAnnotation[tempKvp.Value.RunTimeStaticDataType][0], tempKvp.Value.DataCurrent() });
                            tempItem.Tag = tempKvp.Value;
                            listView_CaseParameter.Items.Add(tempItem);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                listView_CaseParameter.EndUpdate();
                MyControlHelper.SetControlUnfreeze(listView_CaseParameter);
            }
            else
            {
                foreach (ListViewItem tempItem in listView_CaseParameter.Items)
                {
                    if (actuatorStaticDataCollection.IsHaveSameKey(tempItem.SubItems[0].Text))
                    {
                        IRunTimeStaticData tempStaticData = tempItem.Tag as IRunTimeStaticData;
                        if (tempStaticData != null)
                        {
                            tempItem.SubItems[2].Text = tempStaticData.DataCurrent();
                        }
                        else
                        {
                            UpdatalistView_CaseParameter(true);
                            return;
                        }
                    }
                    else
                    {
                        UpdatalistView_CaseParameter(true);
                        return;
                    }
                }
            }
        }