internal bool SecureClientPipeDirect(X509Certificate2 certServer) { try { FiddlerApplication.DebugSpew(string.Format("SecureClientPipeDirect({0})", certServer.Subject)); this._httpsStream = new SslStream(new NetworkStream(this._baseSocket, false), false); this._httpsStream.AuthenticateAsServer(certServer, ClientPipe._bWantClientCert, CONFIG.oAcceptedClientHTTPSProtocols, false); return(true); } catch (AuthenticationException eX) { FiddlerApplication.Log.LogFormat("!SecureClientPipeDirect failed: {1} on pipe to ({0}).", new object[] { certServer.Subject, Utilities.DescribeException(eX) }); Trace.WriteLine(string.Format("!SecureClientPipeDirect failed: {1} on pipe to ({0}).", certServer.Subject, Utilities.DescribeException(eX))); base.End(); } catch (Exception eX2) { FiddlerApplication.Log.LogFormat("!SecureClientPipeDirect failed: {1} on pipe to ({0})", new object[] { certServer.Subject, Utilities.DescribeException(eX2) }); base.End(); } return(false); }
internal bool SecureExistingConnection(Session oS, string sCertCN, string sClientCertificateFilename, string sPoolingKey, ref int iHandshakeTime) { RemoteCertificateValidationCallback userCertificateValidationCallback = null; LocalCertificateSelectionCallback userCertificateSelectionCallback = null; Stopwatch stopwatch = Stopwatch.StartNew(); try { this.sPoolKey = sPoolingKey; X509CertificateCollection certificateCollectionFromFile = this.GetCertificateCollectionFromFile(sClientCertificateFilename); if (userCertificateValidationCallback == null) { userCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => ConfirmServerCertificate(oS, sCertCN, certificate, chain, sslPolicyErrors); } if (userCertificateSelectionCallback == null) { userCertificateSelectionCallback = (sender, targetHost, localCertificates, remoteCertificate, acceptableIssuers) => this.AttachClientCertificate(oS, sender, targetHost, localCertificates, remoteCertificate, acceptableIssuers); } base._httpsStream = new SslStream(new NetworkStream(base._baseSocket, false), false, userCertificateValidationCallback, userCertificateSelectionCallback); base._httpsStream.AuthenticateAsClient(sCertCN, certificateCollectionFromFile, CONFIG.oAcceptedServerHTTPSProtocols, false); iHandshakeTime = (int)stopwatch.ElapsedMilliseconds; } catch (Exception exception) { iHandshakeTime = (int)stopwatch.ElapsedMilliseconds; FiddlerApplication.DebugSpew(exception.StackTrace + "\n" + exception.Message); FiddlerApplication.Log.LogFormat("fiddler.network.https> Failed to secure existing connection for {0}. {1}{2}", new object[] { sCertCN, exception.Message, (exception.InnerException != null) ? (" InnerException: " + exception.InnerException.ToString()) : "." }); return(false); } return(true); }
public void End() { if (CONFIG.bDebugSpew) { FiddlerApplication.DebugSpew("Pipe::End() for {0}", new object[] { this._sPipeName }); } try { if (this._httpsStream != null) { this._httpsStream.Close(); } if (this._baseSocket != null) { this._baseSocket.Shutdown(SocketShutdown.Both); this._baseSocket.Close(); } } catch (Exception) { } this._baseSocket = null; this._httpsStream = null; }
public int Compare(object x, object y) { int num = -1; ListViewItem item = (ListViewItem)x; ListViewItem item2 = (ListViewItem)y; if (item.SubItems.Count <= this.col) { num = -1; } else if (item2.SubItems.Count <= this.col) { num = 1; } else if (this.bStringCompare) { num = string.Compare(item.SubItems[this.col].Text, item2.SubItems[this.col].Text, StringComparison.Ordinal); } else { try { num = int.Parse(item.SubItems[this.col].Text, NumberStyles.AllowThousands | NumberStyles.AllowLeadingSign) - int.Parse(item2.SubItems[this.col].Text, NumberStyles.AllowThousands | NumberStyles.AllowLeadingSign); } catch (Exception exception) { FiddlerApplication.DebugSpew(exception.Message + "\n" + item.SubItems[this.col].Text + "\n" + item2.SubItems[this.col].Text); } } if (!this.ascending) { num = -num; } return(num); }
internal bool SecureClientPipe(string sHostname, HTTPResponseHeaders oHeaders) { X509Certificate2 x509Certificate; try { x509Certificate = CertMaker.FindCert(sHostname); } catch (Exception ex) { FiddlerApplication.Log.LogFormat("fiddler.https> Failed to obtain certificate for {0} due to {1}", new object[] { sHostname, ex.Message }); x509Certificate = null; } try { if (x509Certificate == null) { FiddlerApplication.DoNotifyUser("Unable to find Certificate for " + sHostname, "HTTPS Interception Failure"); oHeaders.SetStatus(502, "Fiddler unable to generate certificate"); } if (CONFIG.bDebugSpew) { FiddlerApplication.DebugSpew("SecureClientPipe for: " + this.ToString() + " sending data to client:\n" + Utilities.ByteArrayToHexView(oHeaders.ToByteArray(true, true), 32)); } base.Send(oHeaders.ToByteArray(true, true)); bool result; if (oHeaders.HTTPResponseCode != 200) { FiddlerApplication.DebugSpew("SecureClientPipe returning FALSE because HTTPResponseCode != 200"); result = false; return(result); } this._httpsStream = new SslStream(new NetworkStream(this._baseSocket, false), false); this._httpsStream.AuthenticateAsServer(x509Certificate, ClientPipe._bWantClientCert, CONFIG.oAcceptedClientHTTPSProtocols, false); result = true; return(result); } catch (Exception eX) { FiddlerApplication.Log.LogFormat("SecureClientPipe ({0} failed: {1}.", new object[] { sHostname, Utilities.DescribeException(eX) }); try { base.End(); } catch (Exception) { } } return(false); }
public WinINETConnectoids() { string[] connectionNames = RASInfo.GetConnectionNames(); string[] array = connectionNames; for (int i = 0; i < array.Length; i++) { string text = array[i]; if (CONFIG.bDebugSpew) { FiddlerApplication.DebugSpew("Collecting information for Connectoid '{0}'", new object[] { text }); } if (!this._oConnectoids.ContainsKey(text)) { try { WinINETProxyInfo winINETProxyInfo = WinINETProxyInfo.CreateFromNamedConnection(text); if (winINETProxyInfo == null) { FiddlerApplication.Log.LogFormat("!WARNING: Failed to get proxy information for Connection '{0}'.", new object[] { text }); } else { WinINETConnectoid winINETConnectoid = new WinINETConnectoid(); winINETConnectoid.sConnectionName = text; if (!string.IsNullOrEmpty(winINETProxyInfo.sHttpProxy) && winINETProxyInfo.sHttpProxy.Contains(CONFIG.sFiddlerListenHostPort)) { FiddlerApplication.Log.LogString("When connecting, upstream proxy settings were already pointed at Fiddler. Clearing upstream proxy."); winINETProxyInfo.sHttpProxy = (winINETProxyInfo.sHttpsProxy = (winINETProxyInfo.sFtpProxy = null)); winINETProxyInfo.bUseManualProxies = false; winINETProxyInfo.bAllowDirect = true; } if (!string.IsNullOrEmpty(winINETProxyInfo.sPACScriptLocation) && (winINETProxyInfo.sPACScriptLocation == "file://" + CONFIG.GetPath("Pac") || winINETProxyInfo.sPACScriptLocation == "http://" + CONFIG.sFiddlerListenHostPort + "/proxy.pac")) { FiddlerApplication.Log.LogString("When connecting, upstream proxy script was already pointed at Fiddler. Clearing upstream proxy."); winINETProxyInfo.sPACScriptLocation = null; } winINETConnectoid.oOriginalProxyInfo = winINETProxyInfo; this._oConnectoids.Add(text, winINETConnectoid); } } catch (Exception eX) { FiddlerApplication.Log.LogFormat("!WARNING: Failed to get proxy information for Connection '{0}' due to {1}", new object[] { text, Utilities.DescribeException(eX) }); } } } }
internal bool ResendRequest() { bool b = this.pipeServer != null; if (!this.ConnectToHost()) { FiddlerApplication.DebugSpew("ConnectToHost returned null. Bailing..."); this.m_session.SetBitFlag(SessionFlags.ServerPipeReused, b); return(false); } try { this.pipeServer.IncrementUse(this.m_session.id); this.m_session.Timers.ServerConnected = this.pipeServer.dtConnected; this._bWasForwarded = this.pipeServer.isConnectedToGateway; this.m_session.SetBitFlag(SessionFlags.ServerPipeReused, this.pipeServer.iUseCount > 1); this.m_session.SetBitFlag(SessionFlags.SentToGateway, this._bWasForwarded); if (!this._bWasForwarded && !this.m_session.isHTTPS) { this.m_session.oRequest.headers.RenameHeaderItems("Proxy-Connection", "Connection"); } if (!this.pipeServer.isAuthenticated) { string str = this.m_session.oRequest.headers["Authorization"]; if ((str != null) && str.StartsWith("N")) { this.pipeServer.MarkAsAuthenticated(this.m_session.LocalProcessID); } } this.m_session.Timers.FiddlerBeginRequest = DateTime.Now; if (this.m_session.oFlags.ContainsKey("request-trickle-delay")) { int num = int.Parse(this.m_session.oFlags["request-trickle-delay"]); this.pipeServer.TransmitDelay = num; } this.pipeServer.Send(this.m_session.oRequest.headers.ToByteArray(true, true, this._bWasForwarded && !this.m_session.isHTTPS)); this.pipeServer.Send(this.m_session.requestBodyBytes); } catch (Exception exception) { if (this.bServerSocketReused && (this.m_session.state != SessionStates.Aborted)) { this.pipeServer = null; return(this.ResendRequest()); } FiddlerApplication.DebugSpew("ResendRequest() failed: " + exception.Message); this.m_session.oRequest.FailSession(0x1f8, "Fiddler - Send Failure", "ResendRequest() failed: " + exception.Message); return(false); } this.m_session.oFlags["x-EgressPort"] = this.pipeServer.LocalPort.ToString(); if (this.m_session.oFlags.ContainsKey("log-drop-request-body")) { this.m_session.oFlags["x-RequestBodyLength"] = (this.m_session.requestBodyBytes != null) ? this.m_session.requestBodyBytes.Length.ToString() : "0"; this.m_session.requestBodyBytes = new byte[0]; } return(true); }
internal bool SecureClientPipe(string sHostname, HTTPResponseHeaders oHeaders) { X509Certificate2 certificate; try { certificate = CertMaker.FindCert(sHostname, true); } catch (Exception exception) { FiddlerApplication.Log.LogFormat("fiddler.https> Failed to obtain certificate for {0} due to {1}", new object[] { sHostname, exception.Message }); certificate = null; } try { if (certificate == null) { FiddlerApplication.DoNotifyUser("Unable to find Certificate for " + sHostname, "HTTPS Interception Failure"); oHeaders.HTTPResponseCode = 0x1f6; oHeaders.HTTPResponseStatus = "502 Fiddler unable to generate certificate"; } if (CONFIG.bDebugSpew) { FiddlerApplication.DebugSpew("SecureClientPipe for: " + this.ToString() + " sending data to client:\n" + Utilities.ByteArrayToHexView(oHeaders.ToByteArray(true, true), 0x20)); } base.Send(oHeaders.ToByteArray(true, true)); if (oHeaders.HTTPResponseCode != 200) { FiddlerApplication.DebugSpew("SecureClientPipe returning FALSE because HTTPResponseCode != 200"); return(false); } base._httpsStream = new SslStream(new NetworkStream(base._baseSocket, false), false); base._httpsStream.AuthenticateAsServer(certificate, _bWantClientCert, CONFIG.oAcceptedClientHTTPSProtocols, false); return(true); } catch (Exception exception2) { FiddlerApplication.Log.LogFormat("Secure client pipe failed: {0}{1}.", new object[] { exception2.Message, (exception2.InnerException == null) ? string.Empty : (" InnerException: " + exception2.InnerException.Message) }); FiddlerApplication.DebugSpew("Secure client pipe failed: " + exception2.Message); try { base.End(); } catch (Exception) { } } return(false); }
public static void ScavengeCache() { if (DNSResolver.dictAddresses.Count < 1) { return; } if (CONFIG.bDebugSpew) { FiddlerApplication.DebugSpew("Scavenging DNS Cache..."); } List <string> list = new List <string>(); Dictionary <string, DNSResolver.DNSCacheEntry> obj; Monitor.Enter(obj = DNSResolver.dictAddresses); try { foreach (KeyValuePair <string, DNSResolver.DNSCacheEntry> current in DNSResolver.dictAddresses) { if (current.Value.iLastLookup < Utilities.GetTickCount() - DNSResolver.MSEC_DNS_CACHE_LIFETIME) { list.Add(current.Key); } } if (CONFIG.bDebugSpew) { FiddlerApplication.DebugSpew(string.Concat(new string[] { "Expiring ", list.Count.ToString(), " of ", DNSResolver.dictAddresses.Count.ToString(), " DNS Records." })); } foreach (string current2 in list) { DNSResolver.dictAddresses.Remove(current2); } } finally { Monitor.Exit(obj); } if (CONFIG.bDebugSpew) { FiddlerApplication.DebugSpew("Done scavenging DNS Cache..."); } }
public Session SendRequestAndWait(HTTPRequestHeaders oHeaders, byte[] arrRequestBodyBytes, StringDictionary oNewFlags, EventHandler <StateChangeEventArgs> onStateChange) { ManualResetEvent oMRE = new ManualResetEvent(false); Session session = this.SendRequest(oHeaders, arrRequestBodyBytes, oNewFlags, onStateChange); session.OnStateChanged += delegate(object sender, StateChangeEventArgs e) { if (e.newState >= SessionStates.Done) { FiddlerApplication.DebugSpew("SendRequestAndWait Session #{0} reached state {1}", new object[] { (sender as Session).Int32_0, e.newState }); oMRE.Set(); } }; oMRE.WaitOne(); return(session); }
internal bool SecureClientPipeDirect(X509Certificate2 certServer) { try { base._httpsStream = new SslStream(new NetworkStream(base._baseSocket, false), false); base._httpsStream.AuthenticateAsServer(certServer, _bWantClientCert, CONFIG.oAcceptedClientHTTPSProtocols, false); return(true); } catch (Exception exception) { FiddlerApplication.Log.LogFormat("Secure client pipe failed: {0}{1}.", new object[] { exception.Message, (exception.InnerException == null) ? string.Empty : (" InnerException: " + exception.InnerException.Message) }); FiddlerApplication.DebugSpew("Secure client pipe failed: " + exception.Message); try { base.End(); } catch (Exception) { } } return(false); }
internal static string[] GetConnectionNames() { if (CONFIG.bDebugSpew) { FiddlerApplication.DebugSpew("WinINET indicates connectivity is via: " + GetConnectedState()); } int lpcb = Marshal.SizeOf(typeof(RASENTRYNAME)); int lpcEntries = 0; RASENTRYNAME[] lprasentryname = new RASENTRYNAME[1]; lprasentryname[0].dwSize = lpcb; uint num3 = RasEnumEntries(IntPtr.Zero, IntPtr.Zero, lprasentryname, ref lpcb, ref lpcEntries); if ((num3 != 0) && (0x25b != num3)) { lpcEntries = 0; } string[] strArray = new string[lpcEntries + 1]; strArray[0] = "DefaultLAN"; if (lpcEntries != 0) { lprasentryname = new RASENTRYNAME[lpcEntries]; for (int i = 0; i < lpcEntries; i++) { lprasentryname[i].dwSize = Marshal.SizeOf(typeof(RASENTRYNAME)); } if (RasEnumEntries(IntPtr.Zero, IntPtr.Zero, lprasentryname, ref lpcb, ref lpcEntries) != 0) { return(strArray); } for (int j = 0; j < lpcEntries; j++) { strArray[j + 1] = lprasentryname[j].szEntryName; } } return(strArray); }
internal bool SecureExistingConnection(Session oS, string sCertCN, string sClientCertificateFilename, ref int iHandshakeTime) { Stopwatch stopwatch = Stopwatch.StartNew(); bool result; try { this.sPoolKey = this.sPoolKey.Replace("->http/", "->https/"); if (this.sPoolKey.EndsWith("->*")) { this.sPoolKey = this.sPoolKey.Replace("->*", string.Format("->https/{0}:{1}", oS.hostname, oS.port)); } X509CertificateCollection certificateCollectionFromFile = ServerPipe.GetCertificateCollectionFromFile(sClientCertificateFilename); this._httpsStream = new SslStream(new NetworkStream(this._baseSocket, false), false, (object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) => ServerPipe.ConfirmServerCertificate(oS, sCertCN, certificate, chain, sslPolicyErrors), (object sender, string targetHost, X509CertificateCollection localCertificates, X509Certificate remoteCertificate, string[] acceptableIssuers) => this.AttachClientCertificate(oS, sender, targetHost, localCertificates, remoteCertificate, acceptableIssuers)); SslProtocols enabledSslProtocols = CONFIG.oAcceptedServerHTTPSProtocols; if (oS.oFlags.ContainsKey("x-OverrideSslProtocols")) { enabledSslProtocols = Utilities.ParseSSLProtocolString(oS.oFlags["x-OverrideSslProtocols"]); } this._httpsStream.AuthenticateAsClient(sCertCN, certificateCollectionFromFile, enabledSslProtocols, FiddlerApplication.Prefs.GetBoolPref("fiddler.network.https.checkcertificaterevocation", false)); iHandshakeTime = (int)stopwatch.ElapsedMilliseconds; return(true); } catch (Exception ex) { iHandshakeTime = (int)stopwatch.ElapsedMilliseconds; FiddlerApplication.DebugSpew(ex.StackTrace + "\n" + ex.Message); string text = string.Format("fiddler.network.https> Failed to secure existing connection for {0}. {1}{2}", sCertCN, ex.Message, (ex.InnerException != null) ? (" InnerException: " + ex.InnerException.ToString()) : "."); if (oS.responseBodyBytes == null || oS.responseBodyBytes.Length == 0) { oS.responseBodyBytes = Encoding.UTF8.GetBytes(text); } FiddlerApplication.Log.LogString(text); result = false; } return(result); }
internal bool ReadRequest() { if (this.m_requestData != null) { FiddlerApplication.ReportException(new InvalidOperationException("ReadRequest called when requestData buffer already existed.")); return(false); } if (this.pipeClient == null) { FiddlerApplication.ReportException(new InvalidOperationException("ReadRequest called after pipeClient was null'd.")); return(false); } this.m_requestData = new PipeReadBuffer(true); this.m_session.SetBitFlag(SessionFlags.ClientPipeReused, this.pipeClient.iUseCount > 0u); this.pipeClient.IncrementUse(0); this.pipeClient.setReceiveTimeout(); int num = 0; bool flag = false; bool flag2 = false; byte[] array = new byte[ClientChatter._cbClientReadBuffer]; while (true) { try { num = this.pipeClient.Receive(array); goto IL_1F1; } catch (Exception ex) { if (CONFIG.bDebugSpew) { FiddlerApplication.DebugSpew(string.Format("ReadRequest {0} threw {1}", (this.pipeClient == null) ? "Null pipeClient" : this.pipeClient.ToString(), ex.Message)); } flag = true; goto IL_1F1; } goto IL_D2; IL_1DE: if (flag2 || flag) { goto IL_22F; } if (this.isRequestComplete()) { goto Block_17; } continue; IL_D2: flag2 = true; FiddlerApplication.DoReadRequestBuffer(this.m_session, array, 0); if (CONFIG.bDebugSpew) { FiddlerApplication.DebugSpew(string.Format("ReadRequest {0} returned {1}", (this.pipeClient == null) ? "Null pipeClient" : this.pipeClient.ToString(), num)); goto IL_1DE; } goto IL_1DE; IL_1F1: if (num <= 0) { goto IL_D2; } if (CONFIG.bDebugSpew) { FiddlerApplication.DebugSpew(string.Format("READ FROM {0}:\n{1}", this.pipeClient, Utilities.ByteArrayToHexView(array, 32, num))); } if (!FiddlerApplication.DoReadRequestBuffer(this.m_session, array, num)) { flag = true; } if (0L == this.m_requestData.Length) { this.m_session.Timers.ClientBeginRequest = DateTime.Now; if (1u == this.pipeClient.iUseCount && num > 2) { if (array[0] == 5) { break; } if (array[0] == 5) { break; } } int i; for (i = 0; i < num; i++) { if (13 != array[i] && 10 != array[i]) { break; } } this.m_requestData.Write(array, i, num - i); goto IL_1DE; } this.m_requestData.Write(array, 0, num); goto IL_1DE; } goto IL_1FD; Block_17: goto IL_22F; IL_1FD: FiddlerApplication.Log.LogFormat("It looks like someone is trying to send SOCKS traffic to us.\r\n{0}", new object[] { Utilities.ByteArrayToHexView(array, 16, Math.Min(num, 256)) }); return(false); IL_22F: array = null; if (!flag) { if (this.m_requestData.Length != 0L) { if (this.m_headers == null || this.m_session.state >= SessionStates.Done) { this._freeRequestData(); return(false); } if ("CONNECT" == this.m_headers.HTTPMethod) { this.m_session.isTunnel = true; this.m_sHostFromURI = this.m_session.PathAndQuery; } if (this.m_sHostFromURI != null) { if (this.m_headers.Exists("Host")) { if (!Utilities.areOriginsEquivalent(this.m_sHostFromURI, this.m_headers["Host"], this.m_session.isHTTPS ? 443 : (this.m_session.isFTP ? 21 : 80)) && (!this.m_session.isTunnel || !Utilities.areOriginsEquivalent(this.m_sHostFromURI, this.m_headers["Host"], 443))) { this.m_session.oFlags["X-Original-Host"] = this.m_headers["Host"]; this.m_session.oFlags["X-URI-Host"] = this.m_sHostFromURI; if (FiddlerApplication.Prefs.GetBoolPref("fiddler.network.SetHostHeaderFromURL", true)) { this.m_headers["Host"] = this.m_sHostFromURI; } } } else { if ("HTTP/1.1".OICEquals(this.m_headers.HTTPVersion)) { this.m_session.oFlags["X-Original-Host"] = string.Empty; } this.m_headers["Host"] = this.m_sHostFromURI; } this.m_sHostFromURI = null; } if (!this.m_headers.Exists("Host")) { this._freeRequestData(); return(false); } return(true); } } this._freeRequestData(); if (this.pipeClient == null) { return(false); } if (this.pipeClient.iUseCount < 2u || (this.pipeClient.bIsSecured && this.pipeClient.iUseCount < 3u)) { FiddlerApplication.Log.LogFormat("[Fiddler] No {0} request was received from ({1}) new client socket, port {2}.", new object[] { this.pipeClient.bIsSecured ? "HTTPS" : "HTTP", this.m_session.oFlags["X-ProcessInfo"], this.m_session.oFlags["X-CLIENTPORT"] }); } return(false); }
internal void ScanInspectors() { string path = CONFIG.GetPath("Inspectors"); try { TabPage key; Evidence securityEvidence = Assembly.GetExecutingAssembly().Evidence; foreach (FileInfo info in new DirectoryInfo(path).GetFiles()) { if (info.FullName.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) && !info.FullName.StartsWith("_", StringComparison.OrdinalIgnoreCase)) { Assembly assembly; try { if (CONFIG.bRunningOnCLRv4) { assembly = Assembly.LoadFrom(info.FullName); } else { assembly = Assembly.LoadFrom(info.FullName, securityEvidence); } } catch (Exception exception) { FiddlerApplication.LogAddonException(exception, "Failed to load " + info.FullName); goto Label_0283; } try { if (assembly.IsDefined(typeof(RequiredVersionAttribute), false)) { RequiredVersionAttribute customAttribute = (RequiredVersionAttribute)Attribute.GetCustomAttribute(assembly, typeof(RequiredVersionAttribute)); int num = Utilities.CompareVersions(customAttribute.RequiredVersion, CONFIG.FiddlerVersionInfo); if (num > 0) { FiddlerApplication.DoNotifyUser(string.Format("The Inspectors in {0} require Fiddler v{1} or later. (You have v{2})\n\nPlease install the latest version of Fiddler from http://www.fiddler2.com.\n\nCode: {3}", new object[] { info.FullName, customAttribute.RequiredVersion, CONFIG.FiddlerVersionInfo, num }), "Inspector Not Loaded"); } else { foreach (System.Type type in assembly.GetExportedTypes()) { if ((!type.IsAbstract && !type.IsInterface) && (type.IsPublic && type.IsSubclassOf(typeof(Inspector2)))) { try { TabPage page = new TabPage(); Inspector2 inspector = (Inspector2)Activator.CreateInstance(type); page = new TabPage { Font = new Font(page.Font.FontFamily, CONFIG.flFontSize), Tag = inspector }; if (inspector is IRequestInspector2) { this.m_RequestInspectors.Add(page, inspector); } else if (inspector is IResponseInspector2) { this.m_ResponseInspectors.Add(page, inspector); } } catch (Exception exception2) { FiddlerApplication.DoNotifyUser(string.Format("[Fiddler] Failure loading {0} inspector from {1}: {2}\n\n{3}", new object[] { type.Name, info.FullName.ToString(), exception2.Message, exception2.StackTrace }), "Inspector Failed"); } } } } } } catch (Exception exception3) { FiddlerApplication.DebugSpew(string.Format("[Fiddler] Failure loading inspectors from {0}: {1}", info.FullName.ToString(), exception3.Message)); } Label_0283 :; } } List <TabPage> list = new List <TabPage>(); List <TabPage> list2 = new List <TabPage>(); foreach (DictionaryEntry entry in this.m_RequestInspectors) { try { key = (TabPage)entry.Key; ((Inspector2)entry.Value).AddToTab(key); list.Add(key); key.Validating += new CancelEventHandler(this.m_Viewer.actValidateRequest); key.CausesValidation = true; continue; } catch (Exception exception4) { FiddlerApplication.DoNotifyUser(string.Format("[Fiddler] Failure initializing Request Inspector: {0}\n{1}", exception4.Message, exception4.StackTrace), "Initialization Error"); continue; } } bool flag = false; foreach (DictionaryEntry entry2 in this.m_ResponseInspectors) { try { key = (TabPage)entry2.Key; ((Inspector2)entry2.Value).AddToTab(key); if (key.Text.Contains("SyntaxView")) { flag = true; } list2.Add(key); key.Validating += new CancelEventHandler(this.m_Viewer.actValidateResponse); key.CausesValidation = true; continue; } catch (Exception exception5) { FiddlerApplication.DoNotifyUser(string.Format("[Fiddler] Failure initializing Response Inspector: {0}\n{1}", exception5.Message, exception5.StackTrace), "Initialization Error"); continue; } } if (!flag && FiddlerApplication.Prefs.GetBoolPref("fiddler.inspectors.response.AdvertiseSyntaxView", true)) { this._CreateSyntaxViewAd(); } InspectorComparer comparer = new InspectorComparer(this.m_RequestInspectors); list.Sort(comparer); comparer = new InspectorComparer(this.m_ResponseInspectors); list2.Sort(comparer); this.m_tabsRequest.TabPages.AddRange(list.ToArray()); this.m_tabsResponse.TabPages.AddRange(list2.ToArray()); } catch (Exception exception6) { FiddlerApplication.DoNotifyUser(string.Format("Failure loading inspectors: {0}", exception6.Message), "Error"); } }
internal bool ReadResponse() { int iMaxByteCount = 0; bool flag = false; bool flag2 = false; bool flag3 = false; byte[] arrBuffer = new byte[_cbServerReadBuffer]; do { try { iMaxByteCount = this.pipeServer.Receive(arrBuffer); if (0L == this.m_session.Timers.ServerBeginResponse.Ticks) { this.m_session.Timers.ServerBeginResponse = DateTime.Now; } if (iMaxByteCount <= 0) { flag = true; } else { if (CONFIG.bDebugSpew) { FiddlerApplication.DebugSpew(Utilities.ByteArrayToHexView(arrBuffer, 0x20, iMaxByteCount)); } this.m_responseData.Write(arrBuffer, 0, iMaxByteCount); this.m_responseTotalDataCount += iMaxByteCount; if ((this.m_inHeaders == null) && this.GetHeaders()) { if ((this.m_session.state == SessionStates.Aborted) && this.m_session.isAnyFlagSet(SessionFlags.ProtocolViolationInResponse)) { return(false); } FiddlerApplication.DoResponseHeadersAvailable(this.m_session); if (CONFIG.bStreamAudioVideo) { string str = this.m_inHeaders["Content-Type"]; if ((str.StartsWith("video/", StringComparison.OrdinalIgnoreCase) || str.StartsWith("audio/", StringComparison.OrdinalIgnoreCase)) || str.StartsWith("application/x-mms-framed", StringComparison.OrdinalIgnoreCase)) { this.m_session.bBufferResponse = false; } } if (!this.m_session.bBufferResponse) { this.m_session.bBufferResponse = this.m_session.HTTPMethodIs("CONNECT"); } if (!this.m_session.bBufferResponse && (this.m_session.oRequest.pipeClient == null)) { this.m_session.bBufferResponse = true; } if ((!this.m_session.bBufferResponse && ((0x191 == this.m_inHeaders.HTTPResponseCode) || (0x197 == this.m_inHeaders.HTTPResponseCode))) && this.m_session.oFlags.ContainsKey("x-AutoAuth")) { this.m_session.bBufferResponse = true; } this.m_session.ExecuteBasicResponseManipulationsUsingHeadersOnly(); this.m_session.SetBitFlag(SessionFlags.ResponseStreamed, !this.m_session.bBufferResponse); if (!this.m_session.bBufferResponse) { if (this.m_session.oFlags.ContainsKey("response-trickle-delay")) { int num2 = int.Parse(this.m_session.oFlags["response-trickle-delay"]); this.m_session.oRequest.pipeClient.TransmitDelay = num2; } if (this.m_session.oFlags.ContainsKey("log-drop-response-body") || FiddlerApplication.Prefs.GetBoolPref("fiddler.network.streaming.ForgetStreamedData", false)) { flag3 = true; } } } if ((this.m_inHeaders != null) && this.m_session.isFlagSet(SessionFlags.ResponseStreamed)) { this.LeakResponseBytes(); if (flag3) { this.m_session.SetBitFlag(SessionFlags.ResponseBodyDropped, true); if (this._lngLastChunkInfoOffset > -1L) { this.ReleaseStreamedChunkedData(); } else if (this.m_inHeaders.ExistsAndContains("Transfer-Encoding", "chunked")) { this.ReleaseStreamedChunkedData(); } else { this.ReleaseStreamedData(); } } } } } catch (Exception exception) { flag2 = true; if (exception is OperationCanceledException) { this.m_session.state = SessionStates.Aborted; FiddlerApplication.Log.LogFormat("fiddler.network.readresponse.failure> Session #{0} was aborted {1}", new object[] { this.m_session.id, exception.Message }); } else if (exception is OutOfMemoryException) { FiddlerApplication.ReportException(exception); this.m_session.state = SessionStates.Aborted; FiddlerApplication.Log.LogFormat("fiddler.network.readresponse.failure> Session #{0} Out of Memory", new object[] { this.m_session.id }); } else { FiddlerApplication.Log.LogFormat("fiddler.network.readresponse.failure> Session #{0} raised exception {1}", new object[] { this.m_session.id, exception.Message }); } } }while ((!flag && !flag2) && ((this.m_inHeaders == null) || !this.isResponseBodyComplete())); this.m_session.Timers.ServerDoneResponse = DateTime.Now; if (this.m_session.isFlagSet(SessionFlags.ResponseStreamed)) { this.m_session.Timers.ClientDoneResponse = this.m_session.Timers.ServerDoneResponse; } if ((this.m_responseTotalDataCount == 0L) && (this.m_inHeaders == null)) { flag2 = true; } arrBuffer = null; if (flag2) { this.m_responseData.Dispose(); this.m_responseData = null; return(false); } if (this.m_inHeaders == null) { FiddlerApplication.HandleHTTPError(this.m_session, SessionFlags.ProtocolViolationInResponse, true, true, "The Server did not return properly formatted HTTP Headers. Maybe missing altogether (e.g. HTTP/0.9), maybe only \\r\\r instead of \\r\\n\\r\\n?\n"); this.m_session.SetBitFlag(SessionFlags.ResponseStreamed, false); this.m_inHeaders = new HTTPResponseHeaders(CONFIG.oHeaderEncoding); this.m_inHeaders.HTTPVersion = "HTTP/1.0"; this.m_inHeaders.HTTPResponseCode = 200; this.m_inHeaders.HTTPResponseStatus = "200 This buggy server did not return headers"; this.iEntityBodyOffset = 0; return(true); } return(true); }
internal static string[] GetConnectionNames() { if (CONFIG.bDebugSpew) { FiddlerApplication.DebugSpew("WinINET indicates connectivity is via: " + RASInfo.GetConnectedState()); } string[] result; try { int dwSize = Marshal.SizeOf(typeof(RASInfo.RASENTRYNAME)); int num = 0; uint num2; if (Environment.OSVersion.Version.Major < 6) { RASInfo.RASENTRYNAME[] array = new RASInfo.RASENTRYNAME[1]; array[0].dwSize = dwSize; num2 = RASInfo.RasEnumEntries(IntPtr.Zero, IntPtr.Zero, array, ref dwSize, ref num); } else { num2 = RASInfo.RasEnumEntries(IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, ref dwSize, ref num); } if (num2 != 0u && 603u != num2) { FiddlerApplication.Log.LogFormat("! WARNING: RasEnumEntries failed (0x{0:x}). Ignoring non-LAN Connectoids. ", new object[] { num2 }); num = 0; } string[] array2 = new string[num + 1]; array2[0] = "DefaultLAN"; if (num == 0) { result = array2; } else { RASInfo.RASENTRYNAME[] array = new RASInfo.RASENTRYNAME[num]; for (int i = 0; i < num; i++) { array[i].dwSize = Marshal.SizeOf(typeof(RASInfo.RASENTRYNAME)); } num2 = RASInfo.RasEnumEntries(IntPtr.Zero, IntPtr.Zero, array, ref dwSize, ref num); if (num2 != 0u) { FiddlerApplication.Log.LogFormat("! WARNING: RasEnumEntries failed (0x{0:x}). Ignoring non-LAN Connectoids. ", new object[] { num2 }); result = new string[] { "DefaultLAN" }; } else { for (int j = 0; j < num; j++) { array2[j + 1] = array[j].szEntryName; } result = array2; } } } catch (Exception eX) { FiddlerApplication.Log.LogFormat("! WARNING: Enumerating connections failed. Ignoring non-LAN Connectoids.\n{0}", new object[] { Utilities.DescribeException(eX) }); result = new string[] { "DefaultLAN" }; } return(result); }
internal bool ReadRequest() { if (this.m_requestData != null) { FiddlerApplication.ReportException(new InvalidOperationException("ReadRequest called after requestData was null'd.")); return(false); } if (this.pipeClient == null) { FiddlerApplication.ReportException(new InvalidOperationException("ReadRequest called after pipeClient was null'd.")); return(false); } this.m_requestData = new MemoryStream(0x1000); this.pipeClient.IncrementUse(0); this.m_session.SetBitFlag(SessionFlags.ClientPipeReused, this.pipeClient.iUseCount > 1); this.pipeClient.setReceiveTimeout(); int iMaxByteCount = 0; bool flag = false; bool flag2 = false; byte[] arrBuffer = new byte[_cbClientReadBuffer]; do { try { iMaxByteCount = this.pipeClient.Receive(arrBuffer); } catch (Exception exception) { FiddlerApplication.DebugSpew("ReadRequest Failure: " + exception.Message); flag = true; } if (iMaxByteCount <= 0) { flag2 = true; FiddlerApplication.DebugSpew("ReadRequest read 0 bytes!!!!!"); } else { if (CONFIG.bDebugSpew) { FiddlerApplication.DebugSpew("READ FROM: " + this.pipeClient.ToString() + ":\n" + Utilities.ByteArrayToHexView(arrBuffer, 0x20, iMaxByteCount)); } if (this.m_requestData.Length == 0L) { this.m_session.Timers.ClientBeginRequest = DateTime.Now; int index = 0; while ((index < iMaxByteCount) && ((arrBuffer[index] == 13) || (arrBuffer[index] == 10))) { index++; } this.m_requestData.Write(arrBuffer, index, iMaxByteCount - index); } else { this.m_requestData.Write(arrBuffer, 0, iMaxByteCount); } } }while ((!flag2 && !flag) && !this.isRequestComplete()); arrBuffer = null; if (flag || (this.m_requestData.Length == 0L)) { if ((this.pipeClient.iUseCount < 2) || (this.pipeClient.bIsSecured && (this.pipeClient.iUseCount < 3))) { FiddlerApplication.Log.LogFormat("[Fiddler] Failed to read {0} request from ({1}) new client socket, port {2}.", new object[] { this.pipeClient.bIsSecured ? "HTTPS" : "HTTP", this.m_session.oFlags["X-ProcessInfo"], this.m_session.oFlags["X-CLIENTPORT"] }); } this._freeRequestData(); return(false); } if ((this.m_headers == null) || (this.m_session.state >= SessionStates.Done)) { this._freeRequestData(); return(false); } if ("CONNECT" == this.m_headers.HTTPMethod) { this.m_session.isTunnel = true; this.m_sHostFromURI = this.m_session.PathAndQuery; } if (this.m_sHostFromURI != null) { if (this.m_headers.Exists("Host") && !Utilities.areOriginsEquivalent(this.m_sHostFromURI, this.m_headers["Host"], (this.m_session.isTunnel || this.m_session.isHTTPS) ? 0x1bb : (this.m_session.isFTP ? 0x15 : 80))) { this.m_session.oFlags["X-Original-Host"] = this.m_headers["Host"]; this.m_headers["Host"] = this.m_sHostFromURI; } else if (!this.m_headers.Exists("Host")) { if (this.m_headers.HTTPVersion.Equals("HTTP/1.1", StringComparison.OrdinalIgnoreCase)) { this.m_session.oFlags["X-Original-Host"] = string.Empty; } this.m_headers["Host"] = this.m_sHostFromURI; } this.m_sHostFromURI = null; } if (!this.m_headers.Exists("Host")) { this._freeRequestData(); return(false); } return(true); }