首页 > 代码库 > fiddlercore 抓包获取cookie的方法
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:\t" + 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:\t" + 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引用
fiddlercore 抓包获取cookie的方法
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。