예제 #1
0
        internal static void AfterSessionComplete(Fiddler.Session Sess)
        {
            if (Sess.HTTPMethodIs("Connect")) return;
            if (Sess.isFlagSet(Fiddler.SessionFlags.RequestGeneratedByFiddler))
            {
                Session IrSe;
                try
                {
                    IrSe = new Session(Sess);
                }
                catch(Exception Exp)
                {
                    IronException.Report("Error handling Response", Exp.Message, Exp.StackTrace);
                    return;
                }
                if (IrSe == null)
                {
                    IronException.Report("Error handling Response", "", "");
                    return;
                }
                if (IrSe.FiddlerSession == null)
                {
                    IronException.Report("Error handling Response", "", "");
                    return;
                }
                if (IrSe.Response == null)
                {
                    IronException.Report("Error handling Response", "", "");
                    return;
                }

                if (Sess.oFlags["IronFlag-BuiltBy"] == "ManualTestingSection")
                {
                    try
                    {
                        ManualTesting.HandleResponse(IrSe);
                    }
                    catch(Exception Exp)
                    {
                        IronException.Report("Error handling 'Manual Testing' Response", Exp.Message, Exp.StackTrace);
                    }
                }
                else if (Sess.oFlags["IronFlag-BuiltBy"].Equals("Shell") || Sess.oFlags["IronFlag-BuiltBy"].Equals("Scan") || Sess.oFlags["IronFlag-BuiltBy"].Equals("Probe") || Sess.oFlags["IronFlag-BuiltBy"].Equals("Stealth") || Config.IsSourcePresent(Sess.oFlags["IronFlag-BuiltBy"]))
                {
                    try
                    {
                        string DictID = "";
                        if (Sess.oFlags["IronFlag-BuiltBy"].Equals("Shell"))
                        {
                            try
                            {
                                IronUpdater.AddShellResponse(IrSe.Response);
                                DictID = Sess.oFlags["IronFlag-ID"] + "-Shell";
                            }
                            catch (Exception Exp)
                            {
                                IronException.Report("Error handling 'Scripting Shell' Response", Exp.Message, Exp.StackTrace);
                            }
                        }
                        else if (Sess.oFlags["IronFlag-BuiltBy"].Equals("Probe"))
                        {
                            try
                            {
                                IronUpdater.AddProbeResponse(IrSe.Response);
                                DictID = Sess.oFlags["IronFlag-ID"] + "-Probe";
                            }
                            catch (Exception Exp)
                            {
                                IronException.Report("Error handling 'Probe' Response", Exp.Message, Exp.StackTrace);
                            }
                        }
                        else if (Sess.oFlags["IronFlag-BuiltBy"].Equals("Stealth"))
                        {
                            try
                            {
                                DictID = Sess.oFlags["IronFlag-ID"] + "-Stealth";
                            }
                            catch (Exception Exp)
                            {
                                IronException.Report("Error handling 'Stealth' Response", Exp.Message, Exp.StackTrace);
                            }
                        }
                        else if (Sess.oFlags["IronFlag-BuiltBy"].Equals("Scan"))
                        {
                            try
                            {
                                IronUpdater.AddScanResponse(IrSe.Response);
                                DictID = Sess.oFlags["IronFlag-ID"] + "-Scan";
                            }
                            catch (Exception Exp)
                            {
                                IronException.Report("Error handling 'Automated Scanning' Response", Exp.Message, Exp.StackTrace);
                            }
                        }
                        else
                        {
                            try
                            {
                                IronUpdater.AddOtherSourceResponse(IrSe.Response);
                                DictID = string.Format("{0}-{1}", Sess.oFlags["IronFlag-ID"], Sess.oFlags["IronFlag-BuiltBy"]);
                            }
                            catch (Exception Exp)
                            {
                                IronException.Report(string.Format("Error handling '{0}' Response", Sess.oFlags["IronFlag-BuiltBy"]), Exp.Message, Exp.StackTrace);
                            }
                        }
                        Config.APIResponseDict[DictID].SetResponse(IrSe.Response);
                        Config.APIResponseDict[DictID].MSR.Set();
                    }
                    catch (Exception MainExp)
                    {
                        IronException.Report("Error handling 'Scripting Shell/Automated Scanning/Probe' Response", MainExp.Message, MainExp.StackTrace);
                    }
                }
            }
        }
예제 #2
0
파일: Main.cs 프로젝트: nayutin/NayuColle
        void FiddlerApplication_AfterSessionComplete(Fiddler.Session oSession)
        {
            //ignoreフラグが立っていればリターン
            if (oSession.isFlagSet(Fiddler.SessionFlags.Ignored))
                return;

            string url = oSession.fullUrl;
            try
            {

                Invoke(new UpdateUI(() =>
                   {
                       if (checkBox1.Checked)
                       {
                           if (url.IndexOf("/kcs/") > 0)
                           {
                               listBox1.Items.Add(url);
                               listBox1.TopIndex = listBox1.Items.Count - listBox1.Height / listBox1.ItemHeight;
                           }

                           if (url.IndexOf("/kcsapi/") > 0)
                           {
                               if (checkBox2.Checked)
                                   sw5.Start();

                               listBox1.Items.Add(url);
                               listBox1.TopIndex = listBox1.Items.Count - listBox1.Height / listBox1.ItemHeight;

                               if (checkBox4.Checked)
                               {
                                   string str = oSession.GetResponseBodyAsString();
                                   str = str.Substring(str.IndexOf("=") + 1);
                                   var json = DynamicJson.Parse(str);
                                   string filepath = @"result.txt";
                                   string text = url + Environment.NewLine + str + Environment.NewLine + json + Environment.NewLine + Environment.NewLine;
                                   File.AppendAllText(filepath, text);
                               }

                               if (checkBox3.Checked)
                               {
                                   string str = oSession.GetResponseBodyAsString();
                                   str = str.Substring(str.IndexOf("=") + 1);
                                   var json = DynamicJson.Parse(str);
                                   textBox1.AppendText(url + Environment.NewLine + str + Environment.NewLine + Environment.NewLine);
                                   textBox2.AppendText(url + Environment.NewLine + json + Environment.NewLine + Environment.NewLine);
                               }
                           }

                       }

                   }));
                if (url.IndexOf("/kcsapi/") > 0)
                {

                    string str = oSession.GetResponseBodyAsString();
                    str = str.Substring(str.IndexOf("=") + 1);
                    var json = DynamicJson.Parse(str);
                    var Member = new Edit_Ship { Ships = Member_Ship };

                    if (url.IndexOf("/api_get_member/basic") > 0)
                        MakeBasic(json);

                    if (url.IndexOf("/api_get_member/deck_port") > 0)
                        ParseMission(json);

                    if (url.IndexOf("/api_get_member/ndock") > 0)
                        ParseDock(json);

                    if (url.IndexOf("/api_get_member/material") > 0)
                        MakeMaterial(json);

                    if (url.IndexOf("api_get_member/deck") > 0 && url.IndexOf("api_get_member/deck_port") < 0)
                    {
                        var json_deck = json.api_data;
                        ParseMission(json);
                        Invoke(new UpdateUI_JSON(UpdateDeck), json_deck);
                    }

                    if (url.IndexOf("/api_get_member/ship2") > 0)
                    {

                        var deck_data = json.api_data_deck;
                        var ship_data = json.api_data;
                        var loop = ((member_ship[])ship_data).Count();

                        KanmusuCurrent.Invoke(new UpdateUI(() =>
                        {
                            KanmusuCurrent.Text = loop.ToString();
                        }));

                        Member.Make_Member_ShipTable(ship_data);
                       // Make_Member_ShipTable(ship_data);
                        Invoke(new UpdateUI_JSON(UpdateDeck), deck_data);
                    }

                    if (url.IndexOf("/api_get_member/ship3") > 0)
                    {
                        var deck_data = json.api_data.api_deck_data;
                        var ship_data = json.api_data.api_ship_data;
                        var loop = ((member_ship[])ship_data).Count();

                        KanmusuCurrent.Invoke(new UpdateUI(() =>
                        {
                            KanmusuCurrent.Text = loop.ToString();
                        }));
                        Member.Make_Member_ShipTable(ship_data);
                       // Make_Member_ShipTable(ship_data);
                        Invoke(new UpdateUI_JSON(UpdateDeck), deck_data);
                    }

                    sw5.Stop();
                    if (checkBox2.Checked)
                    {
                        textBox3.Invoke(new UpdateUI(() =>
                        {
                            textBox3.AppendText("\"" + url + "\"" + Environment.NewLine + "Session Complete = " + sw5.Elapsed + Environment.NewLine);
                        }));
                    }
                    sw5.Reset();
                }
            }
            catch
            {
                textBox3.Invoke(new UpdateUI(() =>
                {
                    textBox3.AppendText(url + "にて例外エラー" + Environment.NewLine);
                }));
            }
        }