internal bool Detach(bool bDontCheckIfAttached) { if (!bDontCheckIfAttached && !this._bIsAttached) { return(true); } if (CONFIG.bIsViewOnly) { return(true); } bool result; try { this._bDetaching = true; Proxy._setDynamicRegistryKey(false); if (this.oAllConnectoids.UnhookAllConnections()) { this._bIsAttached = false; FiddlerApplication.OnFiddlerDetach(); this.WriteAutoProxyPACFile(false); return(true); } result = false; } finally { this._bDetaching = false; } return(result); }
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); }
internal static void OnFiddlerDetach() { if (FiddlerApplication.FiddlerDetach != null) { FiddlerApplication.FiddlerDetach(); } }
public static void Startup(int iListenPort, bool bRegisterAsSystemProxy, bool bDecryptSSL, bool bAllowRemote) { FiddlerCoreStartupFlags fiddlerCoreStartupFlags = FiddlerCoreStartupFlags.Default; if (bRegisterAsSystemProxy) { fiddlerCoreStartupFlags |= FiddlerCoreStartupFlags.RegisterAsSystemProxy; } else { fiddlerCoreStartupFlags &= ~FiddlerCoreStartupFlags.RegisterAsSystemProxy; } if (bDecryptSSL) { fiddlerCoreStartupFlags |= FiddlerCoreStartupFlags.DecryptSSL; } else { fiddlerCoreStartupFlags &= ~FiddlerCoreStartupFlags.DecryptSSL; } if (bAllowRemote) { fiddlerCoreStartupFlags |= FiddlerCoreStartupFlags.AllowRemoteClients; } else { fiddlerCoreStartupFlags &= ~FiddlerCoreStartupFlags.AllowRemoteClients; } FiddlerApplication.Startup(iListenPort, fiddlerCoreStartupFlags); }
private X509Certificate AttachClientCertificate(Session oS, object sender, string targetHost, X509CertificateCollection localCertificates, X509Certificate remoteCertificate, string[] acceptableIssuers) { if (localCertificates.Count > 0) { this.MarkAsAuthenticated(oS.LocalProcessID); oS.oFlags["x-client-cert"] = localCertificates[0].Subject + " Serial#" + localCertificates[0].GetSerialNumberString(); return(localCertificates[0]); } if ((remoteCertificate != null) || (acceptableIssuers.Length >= 1)) { X509Certificate certificate = this._GetDefaultCertificate(); if (certificate != null) { this.MarkAsAuthenticated(oS.LocalProcessID); oS.oFlags["x-client-cert"] = certificate.Subject + " Serial#" + certificate.GetSerialNumberString(); return(certificate); } if (CONFIG.bShowDefaultClientCertificateNeededPrompt && FiddlerApplication.Prefs.GetBoolPref("fiddler.network.https.clientcertificate.ephemeral.prompt-for-missing", true)) { FiddlerApplication.DoNotifyUser("The server [" + targetHost + "] requests a client certificate.\nPlease save a client certificate in the following location:\n\n" + CONFIG.GetPath("DefaultClientCertificate"), "Client Certificate Requested"); FiddlerApplication.Prefs.SetBoolPref("fiddler.network.https.clientcertificate.ephemeral.prompt-for-missing", false); } FiddlerApplication.Log.LogFormat("The server [{0}] requested a client certificate, but no client certificate was available.", new object[] { targetHost }); } return(null); }
private static void HandlePrefChanged(object sender, PrefChangeEventArgs oPref) { if (oPref.PrefName == "fiddler.ui.toolbar.visible") { if (oPref.ValueBool) { FiddlerApplication.UIInvoke(new MethodInvoker(FiddlerToolbar._DoShow)); } else { FiddlerApplication.UIInvoke(new MethodInvoker(FiddlerToolbar._DoHide)); } } else if (oPref.PrefName == "fiddler.ui.rules.removeencoding") { if (tsbRemoveEncodings != null) { bool flag2 = oPref.ValueString == bool.TrueString; tsbRemoveEncodings.Checked = flag2; } } else if ((oPref.PrefName == "fiddler.ui.rules.bufferresponses") && (tsbStreaming != null)) { bool flag3 = !oPref.ValueBool; tsbStreaming.Checked = flag3; } }
public bool DoMethod(string sMethodName, object[] oParams) { if (!this.Ready) { return(false); } if (this._typeScriptHandlers == null) { return(false); } try { MethodInfo method = this._typeScriptHandlers.GetMethod(sMethodName); if (method != null) { method.Invoke(null, oParams); } else { return(false); } } catch (Exception exception) { FiddlerApplication.DoNotifyUser(string.Concat(new object[] { "There was a problem with your FiddlerScript.\n\n", exception.Message, "\n", exception.StackTrace, "\n\n", exception.InnerException }), "FiddlerScript Error invoking " + sMethodName); return(false); } return(true); }
internal bool DoOnQuickExec(string sCommand) { foreach (IFiddlerExtension extension in this.m_Extensions.Values) { if (extension is IHandleExecAction) { try { if ((extension as IHandleExecAction).OnExecAction(sCommand)) { return(true); } continue; } catch (Exception exception) { FiddlerApplication.LogAddonException(exception, "Extension threw during OnExecAction"); continue; } } } if (FiddlerApplication.scriptRules == null) { return(false); } return(FiddlerApplication.scriptRules.DoExecAction(sCommand)); }
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); }
private void _ParseAndSendServerMessages() { WebSocketMessage[] array = WebSocket._ParseMessagesFromStream(this, ref this.strmServerBytes, false, true); WebSocketMessage[] array2 = array; for (int i = 0; i < array2.Length; i++) { WebSocketMessage webSocketMessage = array2[i]; webSocketMessage.Timers.dtDoneRead = DateTime.Now; List <WebSocketMessage> obj; Monitor.Enter(obj = this.listMessages); try { this.listMessages.Add(webSocketMessage); } finally { Monitor.Exit(obj); } FiddlerApplication.DoOnWebSocketMessage(this._mySession, webSocketMessage); if (!webSocketMessage.WasAborted) { webSocketMessage.Timers.dtBeginSend = DateTime.Now; this.oCP.Send(webSocketMessage.ToByteArray()); webSocketMessage.Timers.dtDoneSend = DateTime.Now; } } }
private bool isRequestComplete() { if (this.m_headers == null) { if (!this.HeadersAvailable()) { return(false); } if (!this.ParseRequestForHeaders()) { string str; if (this.m_requestData != null) { str = Utilities.ByteArrayToHexView(this.m_requestData.GetBuffer(), 0x18, (int)Math.Min(this.m_requestData.Length, 0x800L)); } else { str = "{Fiddler:no data}"; } if (this.m_headers == null) { this.m_headers = new HTTPRequestHeaders(); this.m_headers.HTTPMethod = "BAD"; this.m_headers["Host"] = "BAD-REQUEST"; this.m_headers.RequestPath = "/BAD_REQUEST"; } this.FailSession(400, "Fiddler - Bad Request", "[Fiddler] Request Header parsing failed. Request was:\n" + str); return(true); } this.m_session._AssignID(); FiddlerApplication.DoRequestHeadersAvailable(this.m_session); } if (this.m_headers.ExistsAndEquals("Transfer-encoding", "chunked")) { long num; long num2; return(Utilities.IsChunkedBodyComplete(this.m_session, this.m_requestData, (long)this.iEntityBodyOffset, out num2, out num)); } if (this.m_headers.Exists("Content-Length")) { long result = 0L; try { if (!long.TryParse(this.m_headers["Content-Length"], NumberStyles.Integer, NumberFormatInfo.InvariantInfo, out result) || (result < 0L)) { FiddlerApplication.HandleHTTPError(this.m_session, SessionFlags.ProtocolViolationInRequest, true, true, "Request content length was invalid.\nContent-Length: " + this.m_headers["Content-Length"]); this.FailSession(400, "Fiddler - Bad Request", "[Fiddler] Request Content-Length header parsing failed.\nContent-Length: " + this.m_headers["Content-Length"]); return(true); } return(this.m_requestData.Length >= (this.iEntityBodyOffset + result)); } catch { this.FailSession(400, "Fiddler - Bad Request", "[Fiddler] Unknown error: Check content length header?"); return(false); } } return(true); }
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 bool Attach() { if (!this._bIsAttached) { this.CollectConnectoidAndGatewayInfo(); WinINETProxyInfo oNewInfo = new WinINETProxyInfo { bUseManualProxies = true, bAllowDirect = true, sHttpProxy = CONFIG.sFiddlerListenHostPort }; if (CONFIG.bCaptureCONNECT) { oNewInfo.sHttpsProxy = CONFIG.sFiddlerListenHostPort; } else { oNewInfo.sHttpsProxy = this.piPrior.sHttpsProxy; } if (this.piPrior.bUseManualProxies) { oNewInfo.sFtpProxy = this.piPrior.sFtpProxy; oNewInfo.sSocksProxy = this.piPrior.sSocksProxy; } if (CONFIG.bCaptureFTP) { oNewInfo.sFtpProxy = CONFIG.sFiddlerListenHostPort; } oNewInfo.sHostsThatBypass = CONFIG.sHostsThatBypassFiddler; if (CONFIG.bHookWithPAC) { if (FiddlerApplication.Prefs.GetBoolPref("fiddler.proxy.pacfile.usefileprotocol", true)) { oNewInfo.sPACScriptLocation = "file://" + CONFIG.GetPath("Pac"); } else { oNewInfo.sPACScriptLocation = "http://" + CONFIG.sFiddlerListenHostPort + "/proxy.pac"; } } if (!CONFIG.bIsViewOnly) { if (this.oAllConnectoids.HookConnections(oNewInfo)) { this._bIsAttached = true; FiddlerApplication.OnFiddlerAttach(); this.WriteAutoProxyPACFile(true); } else { FiddlerApplication.DoNotifyUser("Failed to register Fiddler as the system proxy.", "Error"); _setDynamicRegistryKey(false); return(false); } _setDynamicRegistryKey(true); } } return(true); }
private void ScanPathForTranscoders(string sPath) { try { if (Directory.Exists(sPath)) { Evidence evidence = Assembly.GetExecutingAssembly().Evidence; bool boolPref; if (boolPref = FiddlerApplication.Prefs.GetBoolPref("fiddler.debug.extensions.verbose", false)) { FiddlerApplication.Log.LogFormat("Searching for Transcoders under {0}", new object[] { sPath }); } FileInfo[] files = new DirectoryInfo(sPath).GetFiles("*.dll"); FileInfo[] array = files; for (int i = 0; i < array.Length; i++) { FileInfo fileInfo = array[i]; if (!Utilities.IsNotExtension(fileInfo.Name)) { if (boolPref) { FiddlerApplication.Log.LogFormat("Looking for Transcoders inside {0}", new object[] { fileInfo.FullName.ToString() }); } Assembly assemblyInput; try { if (CONFIG.bRunningOnCLRv4) { assemblyInput = Assembly.LoadFrom(fileInfo.FullName); } else { assemblyInput = Assembly.LoadFrom(fileInfo.FullName, evidence); } } catch (Exception eX) { FiddlerApplication.LogAddonException(eX, "Failed to load " + fileInfo.FullName); goto IL_F1; } this.ScanAssemblyForTranscoders(assemblyInput); } IL_F1 :; } } } catch (Exception ex) { FiddlerApplication.DoNotifyUser(string.Format("[Fiddler] Failure loading Transcoders: {0}", ex.Message), "Transcoders Load Error"); } }
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); }
private void cbAutoRespond_CheckedChanged(object sender, EventArgs e) { FiddlerApplication._AutoResponder.IsEnabled = this.cbAutoRespond.Checked; if (this.cbAutoRespond.Checked && CONFIG.IsMicrosoftMachine) { FiddlerApplication.logSelfHostOnePerSession(30); } this.pnlAutoResponders.Enabled = this.cbAutoRespond.Checked; FiddlerApplication.UI.pageResponder.ImageIndex = this.cbAutoRespond.Checked ? 0x18 : 0x17; }
private bool GetHeaders() { if (!this.HeadersAvailable()) { return(false); } if (!this.ParseResponseForHeaders()) { string str; this.m_session.SetBitFlag(SessionFlags.ProtocolViolationInResponse, true); this._PoisonPipe(); if (this.m_responseData != null) { str = "<plaintext>\n" + Utilities.ByteArrayToHexView(this.m_responseData.GetBuffer(), 0x18, (int)Math.Min(this.m_responseData.Length, 0x800L)); } else { str = "{Fiddler:no data}"; } this.m_session.oRequest.FailSession(500, "Fiddler - Bad Response", string.Format("[Fiddler] Response Header parsing failed.\n{0}Response Data:\n{1}", this.m_session.isFlagSet(SessionFlags.ServerPipeReused) ? "This can be caused by an illegal HTTP response earlier on this reused server socket-- for instance, a HTTP/304 response which illegally contains a body.\n" : string.Empty, str)); return(true); } if ((this.m_inHeaders.HTTPResponseCode <= 0x63) || (this.m_inHeaders.HTTPResponseCode >= 200)) { return(true); } if (this.m_inHeaders.Exists("Content-Length") && ("0" != this.m_inHeaders["Content-Length"].Trim())) { FiddlerApplication.HandleHTTPError(this.m_session, SessionFlags.ProtocolViolationInResponse, false, true, "HTTP/1xx responses MUST NOT contain a body, but a non-zero content-length was returned."); } if (FiddlerApplication.Prefs.GetBoolPref("fiddler.network.streaming.leakhttp1xx", true) && (this.m_session.oRequest.pipeClient != null)) { try { StringDictionary dictionary; this.m_session.oRequest.pipeClient.Send(this.m_inHeaders.ToByteArray(true, true)); (dictionary = this.m_session.oFlags)["x-fiddler-Stream1xx"] = dictionary["x-fiddler-Stream1xx"] + "Returned a HTTP/" + this.m_inHeaders.HTTPResponseCode.ToString() + " message from the server."; } catch (Exception exception) { if (FiddlerApplication.Prefs.GetBoolPref("fiddler.network.streaming.abortifclientaborts", false)) { throw new Exception("Leaking HTTP/1xx response to client failed", exception); } FiddlerApplication.Log.LogFormat("fiddler.network.streaming> Streaming of HTTP/1xx headers from #{0} to client failed: {1}", new object[] { this.m_session.id, exception.Message }); } } else { StringDictionary dictionary2; (dictionary2 = this.m_session.oFlags)["x-fiddler-streaming"] = dictionary2["x-fiddler-streaming"] + "Eating a HTTP/" + this.m_inHeaders.HTTPResponseCode.ToString() + " message from the stream."; } this._deleteInformationalMessage(); return(this.GetHeaders()); }
internal static void DoAfterSessionComplete(Session oSession) { if (oSession.isFlagSet(SessionFlags.Ignored)) { return; } if (FiddlerApplication.AfterSessionComplete != null) { FiddlerApplication.AfterSessionComplete(oSession); } }
internal static void DoRequestHeadersAvailable(Session oSession) { if (oSession.isFlagSet(SessionFlags.Ignored)) { return; } if (FiddlerApplication.RequestHeadersAvailable != null) { FiddlerApplication.RequestHeadersAvailable(oSession); } }
internal static void DoBeforeReturningError(Session oSession) { if (oSession.isFlagSet(SessionFlags.Ignored)) { return; } if (FiddlerApplication.BeforeReturningError != null) { FiddlerApplication.BeforeReturningError(oSession); } }
static FiddlerApplication() { FiddlerApplication.Counters = new DataPoints(); FiddlerApplication._Log = new Logger(false); FiddlerApplication.Janitor = new PeriodicWorker(); FiddlerApplication._Prefs = null; FiddlerApplication.oTranscoders = new FiddlerTranscoders(); FiddlerApplication.slLeakedFiles = new List <string>(); FiddlerApplication._SetXceedLicenseKeys(); FiddlerApplication._Prefs = new PreferenceBag(null); }
internal static void LogAddonException(Exception eX, string sTitle) { if (FiddlerApplication.Prefs.GetBoolPref("fiddler.debug.extensions.showerrors", false) || FiddlerApplication.Prefs.GetBoolPref("fiddler.debug.extensions.verbose", false)) { FiddlerApplication.Log.LogFormat("!Exception from Extension: {0}", new object[] { Utilities.DescribeException(eX) }); FiddlerApplication.ReportException(eX, sTitle, "Fiddler has encountered an unexpected problem with an extension."); } }
public SplashScreen() { try { this.InitializeComponent(); } catch (ArgumentException exception) { FiddlerApplication.DoNotifyUser("It appears that one of your computer's fonts is missing, or your\nMicrosoft .NET Framework installation is corrupt. If you see the Font file in\nthe c:\\windows\\fonts folder, then try reinstalling the .NET Framework and\nall updates from WindowsUpdate.\n\n" + exception.Message + "\n" + exception.StackTrace, "Fiddler is unable to start"); } this.lblVersion.Text = string.Format("v{0}{1}", Application.ProductVersion, CONFIG.bIsBeta ? " beta" : string.Empty); }
private bool ParseResponseForHeaders() { if ((this.m_responseData != null) && (this.iEntityBodyOffset >= 4)) { this.m_inHeaders = new HTTPResponseHeaders(CONFIG.oHeaderEncoding); byte[] bytes = this.m_responseData.GetBuffer(); string str = CONFIG.oHeaderEncoding.GetString(bytes, 0, this.iEntityBodyOffset).Trim(); if ((str == null) || (str.Length < 1)) { this.m_inHeaders = null; return(false); } string[] sHeaderLines = str.Replace("\r\n", "\n").Split(new char[] { '\n' }); if (sHeaderLines.Length >= 1) { int index = sHeaderLines[0].IndexOf(' '); if (index > 0) { this.m_inHeaders.HTTPVersion = sHeaderLines[0].Substring(0, index).ToUpper(); sHeaderLines[0] = sHeaderLines[0].Substring(index + 1).Trim(); if (!this.m_inHeaders.HTTPVersion.StartsWith("HTTP/", StringComparison.OrdinalIgnoreCase)) { FiddlerApplication.HandleHTTPError(this.m_session, SessionFlags.ProtocolViolationInResponse, false, true, "Response does not start with HTTP. Data:\n\n\t" + sHeaderLines[0]); return(false); } this.m_inHeaders.HTTPResponseStatus = sHeaderLines[0]; bool flag = false; index = sHeaderLines[0].IndexOf(' '); if (index > 0) { flag = int.TryParse(sHeaderLines[0].Substring(0, index).Trim(), NumberStyles.Integer, NumberFormatInfo.InvariantInfo, out this.m_inHeaders.HTTPResponseCode); } else { flag = int.TryParse(sHeaderLines[0].Trim(), NumberStyles.Integer, NumberFormatInfo.InvariantInfo, out this.m_inHeaders.HTTPResponseCode); } if (!flag) { FiddlerApplication.HandleHTTPError(this.m_session, SessionFlags.ProtocolViolationInResponse, false, true, "Response headers did not contain a status code. Data:\n\n\t" + sHeaderLines[0]); return(false); } string sErrors = string.Empty; if (!Parser.ParseNVPHeaders(this.m_inHeaders, sHeaderLines, 1, ref sErrors)) { FiddlerApplication.HandleHTTPError(this.m_session, SessionFlags.ProtocolViolationInResponse, false, true, "Incorrectly formed response headers.\n" + sErrors); } return(true); } FiddlerApplication.HandleHTTPError(this.m_session, SessionFlags.ProtocolViolationInResponse, false, true, "Cannot parse HTTP response; Status line contains no spaces. Data:\n\n\t" + sHeaderLines[0]); } } return(false); }
internal void CollectConnectoidAndGatewayInfo() { try { this.oAllConnectoids = new WinINETConnectoids(); this.RefreshUpstreamGatewayInformation(); } catch (Exception eX) { FiddlerApplication.ReportException(eX, "System Error"); } }
internal static void DoNotifyUser(string sMessage, string sTitle, MessageBoxIcon oIcon) { if (FiddlerApplication.OnNotification != null) { NotificationEventArgs e = new NotificationEventArgs(string.Format("{0} - {1}", sTitle, sMessage)); FiddlerApplication.OnNotification(null, e); } if (!CONFIG.QuietMode) { MessageBox.Show(sMessage, sTitle, MessageBoxButtons.OK, oIcon); } }
public X509Certificate2 GetRootCertificate(string string_2, bool bool_0) { X509Certificate2 certificate = null; int num; string str2; string stringPref = FiddlerApplication.Prefs.GetStringPref("fiddler.certmaker.DateFormatString", "MM/dd/yyyy"); int num2 = -FiddlerApplication.Prefs.GetInt32Pref("fiddler.certmaker.GraceDays", 0x16e); DateTime time = DateTime.Now.AddDays((double)num2); if (bool_0) { str2 = string.Format(CONFIG.sMakeCertParamsRoot, new object[] { string_2, CONFIG.sMakeCertSubjectO, CONFIG.sMakeCertRootCN, FiddlerApplication.Prefs.GetStringPref("fiddler.certmaker.Root.SigAlg", this.string_1), time.ToString(stringPref, CultureInfo.InvariantCulture), FiddlerApplication.Prefs.GetStringPref("fiddler.certmaker.Root.extraparams", string.Empty) }); } else { str2 = string.Format(CONFIG.sMakeCertParamsEE, new object[] { string_2, CONFIG.sMakeCertSubjectO, CONFIG.sMakeCertRootCN, FiddlerApplication.Prefs.GetStringPref("fiddler.certmaker.EE.SigAlg", this.string_1), time.ToString(stringPref, CultureInfo.InvariantCulture), FiddlerApplication.Prefs.GetStringPref("fiddler.certmaker.EE.extraparams", string.Empty) }); } if (CONFIG.bDebugCertificateGeneration) { FiddlerApplication.Log.LogFormat("/Fiddler.CertMaker> Invoking makecert.exe with arguments: {0}", new object[] { str2 }); } string str = Utilities.GetExecutableOutput(this.string_0, str2, out num); if (CONFIG.bDebugCertificateGeneration) { FiddlerApplication.Log.LogFormat("/Fiddler.CertMaker>{3}-CreateCert({0}) => ({1}){2}", new object[] { string_2, num, (num == 0) ? "." : ("\r\n" + str), Thread.CurrentThread.ManagedThreadId }); } if (num == 0) { int num3 = 6; do { certificate = NewCertificateProvider.LoadCertificateFromWindowsStore(string_2); Thread.Sleep((int)(50 * (6 - num3))); if (CONFIG.bDebugCertificateGeneration && (certificate == null)) { FiddlerApplication.Log.LogFormat("!WARNING: Couldn't find certificate for {0} on try #{1}", new object[] { string_2, 6 - num3 }); } num3--; }while ((certificate == null) && (num3 >= 0)); } if (certificate == null) { string sMessage = string.Format("Creation of the interception certificate failed.\n\nmakecert.exe returned {0}.\n\n{1}", num, str); FiddlerApplication.Log.LogFormat("Fiddler.CertMaker> [{0} {1}] Returned Error: {2} ", new object[] { this.string_0, str2, sMessage }); if (CONFIG.bDebugCertificateGeneration) { FiddlerApplication.DoNotifyUser(sMessage, "Unable to Generate Certificate"); } } return(certificate); }