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引用
时间: 2024-09-29 15:29:55