• fiddlercore 抓包获取cookie的方法


      public partial class form1 : Form
        {
            public form1()
            {
                string cookies = "";
                InitializeComponent();
    
                #region AttachEventListeners
    
                Fiddler.FiddlerApplication.OnNotification += delegate (object sender, NotificationEventArgs oNEA) { Console.WriteLine("** NotifyUser: " + oNEA.NotifyString); };
                Fiddler.FiddlerApplication.Log.OnLogString += delegate (object sender, LogEventArgs oLEA) { Console.WriteLine("** LogString: " + oLEA.LogString); };
                Fiddler.FiddlerApplication.BeforeRequest += delegate (Fiddler.Session oS) {
                    //Console.WriteLine("Before request for:	" + oS.fullUrl);
    
                };
                Fiddler.FiddlerApplication.BeforeResponse += delegate (Fiddler.Session oS) {
                    if (oS.fullUrl.Contains("survey/upload.do")&& !oS.fullUrl.Contains("?key=AvImageUpload"))
                    {
                        cookies = oS.RequestHeaders["Cookie"];
    
                        if (InvokeRequired)
                        {
                            this.Invoke(new MethodInvoker(delegate {
                                textBox1.Text = cookies;
                            }));
                            return;
                        }
                        // Console.WriteLine(oS.fullUrl);
                        //oS.utilDecodeResponse();
                        //oS.SaveResponseBody(Environment.CurrentDirectory + "\Captcha.jpg");
                    }
                };
                Fiddler.FiddlerApplication.AfterSessionComplete += delegate (Fiddler.Session oS) {
                    //Console.WriteLine("Finished session:	" + oS.fullUrl);
                };
                Console.CancelKeyPress += new ConsoleCancelEventHandler(btn_Close_Click);
                #endregion AttachEventListeners
               // Console.WriteLine("Starting FiddlerCore...");
                Fiddler.FiddlerApplication.Startup(8877, true, true);
                //Console.WriteLine("Hit CTRL+C to end session.");
                Object forever = new Object();
            }
    
            private void btn_Copy_Click(object sender, EventArgs e)
            {
                textBox1.Focus();
                textBox1.SelectAll();
                if (textBox1.SelectedText != "")
                    Clipboard.SetDataObject(textBox1.SelectedText);
                MessageBox.Show("复制成功!");
            }
    
            private void btn_Close_Click(object sender, EventArgs e)
            {
                Fiddler.FiddlerApplication.Shutdown();
                System.Threading.Thread.Sleep(750);
                this.Close();
            }
        }
    

      需要添加fiddlercore  的dll引用

  • 相关阅读:
    SpringMVC工作原理
    Centosyum方式安装nginx
    centos7通过yum安装JDK1.8
    经典SQL语句
    Jquery选择器
    JS获取当前日期并定时刷新
    MyEclipse快捷键大全
    强大的Layui前端框架地址
    MFC 实现来回滚动效果的进度条
    CImageList* 转 LPDISPATCH 在控件中显示图片
  • 原文地址:https://www.cnblogs.com/muxueyuan/p/6229706.html
Copyright © 2020-2023  润新知