580 likes | 993 Views
CL25. Become a Web Debugging Virtuoso with Fiddler. Eric Lawrence Program Manager Microsoft Corporation. Note: Session includes demos and code samples. For optimal viewing, please sit near the front!. Fiddler: Origins. Once upon a time…. Oh no! What happened?!?.
E N D
CL25 Become a Web Debugging Virtuoso with Fiddler Eric Lawrence Program Manager Microsoft Corporation Note: Session includes demos and code samples. For optimal viewing, please sit near the front!
Fiddler: version 1 • The first Fiddler build was released in October 2003.
Fiddler: Evolution Six years, ~17k lines of C#, 51+ release builds, and 700+ cans of Diet Mountain Dew later…
Understanding Extensibility Fiddler 2 Inspector2 ExecAction.exe Inspector2 IFiddlerExtension Your Automation IFiddlerExtension Fiddler ScriptEngine Your FiddlerScript Fiddler Proxy Xceed*.dll Makecert.exe
Getting to know Fiddler Demo A quick tour of the Fiddler UI
Scenario Traffic Monitoring Browsers, applications, and devices
Debug Across Machines PC Mac Fiddler Internet Linux PocketPC
Tips & Tricks • YourApp.exe.config<configuration> <system.net> <defaultProxy> <proxy bypassonlocal="false" usesystemdefault="true" /> </defaultProxy> </system.net></configuration> • or, use http://ipv4.fiddler
HTTPS Traffic Decryption • Fiddler dynamically generates interception certificates chained to a self-signed root.
Scenario Traffic Archiving Store Requests and Responses
Fiddler has many output options • Copy sessions to the clipboard • Store as a plaintext file • Extract binary response bodies • Archive to a database • Export a Visual Studio .WebTest file • Write your own…
The SAZ file format Session Archive Zip files contain: • Request and response bytes • Timing and other metadata • HTML index file For security, SAZ files may be encrypted
FiddlerCap – Lightweight capture tool http://www.fiddlercap.com
Scenario Traffic Analysis Examine Requests and Responses
Filtering Traffic • Ignore Images & CONNECTs • Application Type Filter • Process Filter • Using QuickExec • Using Find
Traffic Comparison • Use WinDiff to compare HTTP requests and responses.
Automated (Passive) Analysis http://websecuritytool.codeplex.com/
Scenario Traffic Manipulation Change the bytes
Automated Rewrites • Simple Built-in Rules • The HOSTS extension
Breakpoint Debugging • Use Fiddler inspectors to modify requests and responses….
Simple Filters • Flag, modify or remove headers from all requests and responses.
Request Builder • Create hand-built HTTP requests, or modify and reissue a request previously captured.
AutoResponder • Replay previously captured or generated traffic.
FiddlerScript – Request Modification staticfunctionOnBeforeRequest(oS:Session){if(oS.uriContains(".aspx")){oS["ui-color"]="red";} if(m_DisableCaching){oS.oRequest.headers.Remove("If-None-Match");oS.oRequest.headers.Remove("If-Modified-Since"); oS.oRequest["Pragma"]="no-cache"; } }
FiddlerScript – Response Modification • staticfunctionOnBeforeResponse(oS:Session){ • oS.utilDecodeResponse();oS.utilPrependToResponseBody("InjectedContent!"); }
Scenario Performance Optimizing Performance with Fiddler
Build faster websites and services • Reduce request & response size • Reduce roundtrips • Optimize Compression • Optimize Caching • Simulate Slower Speeds
Beware the Observer Effect • Use Fiddler to improve performance • Be careful when using Fiddler to measure performance
Streaming Mode Timeline view of Buffering Mode Timeline view of Streaming Mode
NetMon + VRTA To minimize Observer Effect when taking low-level timing measurements, prefer packet-sniffer tools.
Scenario Test Integration Integrating Fiddler into your tools
ExecAction.exe • Calls into OnExecActionin script or extensions • Alternatively, invoke directly by sending a Windows Message: oCDS.dwData = 61180; // Magic Cookie oCDS.cbData= strlen(sData); oCDS.lpData= sData; SendMessage( FindWindow(NULL, "Fiddler - HTTP Debugging Proxy"), WM_COPYDATA, NULL, (LPARAM) &oCDS );
Fiddler application with extensions Your application hosting FiddlerCore Fiddler 2 YourApp.exe Inspector2 ExecAction.exe Inspector2 IFiddlerExtension IFiddlerExtension Fiddler ScriptEngine Your FiddlerScript FiddlerCore FiddlerCore Xceed*.dll Makecert.exe Makecert.exe
Programming with FiddlerCore // Call Startup to tell FiddlerCore to begin // listening on the specified port, register as // the system proxy and decrypt HTTPS traffic. Fiddler.FiddlerApplication.Startup(8877, true, true); • Fiddler.FiddlerApplication.BeforeResponse += delegate(Fiddler.SessionoS) { Console.WriteLine("{0}:HTTP {1} for {2}", oS.id, oS.responseCode, oS.fullUrl); }; // Call Shutdown to tell FiddlerCore to stop // listening and unregister as the system proxy Fiddler.FiddlerApplication.Shutdown();