private void btnRespondImport_Click(object sender, EventArgs e) { string fileName; OpenFileDialog dialog = new OpenFileDialog { DefaultExt = "saz", RestoreDirectory = true, InitialDirectory = CONFIG.GetPath("Captures"), Title = "Import file for replay", Filter = "SAZ / Rules (*.saz;*.farx)|*.saz;*.farx|ZIP Files (*.zip)|*.zip" }; if (DialogResult.OK == dialog.ShowDialog(this)) { fileName = dialog.FileName; } else { dialog.Dispose(); return; } dialog.Dispose(); if (fileName.EndsWith(".farx", StringComparison.OrdinalIgnoreCase)) { FiddlerApplication._AutoResponder.ImportFARX(fileName); } else { FiddlerApplication._AutoResponder.ImportSAZ(fileName); } }
private static bool CreateCert(string sHostname, bool isRoot) { if (!isRoot && !rootCertExists()) { lock (oRootCertCreationLock) { if ((FindCert(CONFIG.sMakeCertRootCN, false) == null) && !createRootCert()) { FiddlerApplication.DoNotifyUser("Creation of the root certificate was not successful.", "Certificate Error"); return(false); } } } if (sHostname.IndexOfAny(new char[] { '"', '\r', '\n' }) == -1) { int num; string str3; string path = CONFIG.GetPath("MakeCert"); if (!File.Exists(path)) { FiddlerApplication.DoNotifyUser("Cannot locate:\n\t\"" + path + "\"\n\nPlease move makecert.exe to the Fiddler installation directory.", "MakeCert.exe not found"); throw new FileNotFoundException("Cannot locate: " + path + ". Please move makecert.exe to the Fiddler installation directory."); } string sParams = string.Format(isRoot ? CONFIG.sMakeCertParamsRoot : CONFIG.sMakeCertParamsEE, sHostname, CONFIG.sMakeCertSubjectO, CONFIG.sMakeCertRootCN); lock (oEECertCreationLock) { if (FindCert(sHostname, false) == null) { str3 = Utilities.GetExecutableOutput(path, sParams, out num); if (CONFIG.bDebugCertificateGeneration) { FiddlerApplication.Log.LogFormat("/Fiddler.CertMaker>{3}-CreateCert({0}) => ({1}){2}", new object[] { sHostname, num, (num == 0) ? "." : ("\r\n" + str3), Thread.CurrentThread.ManagedThreadId }); } if (num == 0) { Thread.Sleep(150); } } else { if (CONFIG.bDebugCertificateGeneration) { FiddlerApplication.Log.LogFormat("/Fiddler.CertMaker>{1} A racing thread already successfully CreatedCert({0})", new object[] { sHostname, Thread.CurrentThread.ManagedThreadId }); } return(true); } } if (num == 0) { return(true); } string sMessage = string.Format("Creation of the interception certificate failed.\n\nmakecert.exe returned {0}.\n\n{1}", num, str3); FiddlerApplication.Log.LogFormat("Fiddler.CertMaker> [{0}{1}] Returned Error: {2} ", new object[] { path, sParams, sMessage }); if (CONFIG.bDebugCertificateGeneration) { FiddlerApplication.DoNotifyUser(sMessage, "Unable to Generate Certificate"); } } return(false); }
internal void SaveDefaultRules() { if (this._bRuleListIsDirty) { this.SaveRules(CONFIG.GetPath("AutoResponderDefaultRules")); this._bRuleListIsDirty = false; } }
private void EnsureTranscoders() { if (((this.m_Importers == null) || (this.m_Exporters == null)) || ((this.m_Importers.Count == 0) || (this.m_Exporters.Count == 0))) { this.ScanPathForTranscoders(CONFIG.GetPath("Transcoders_Machine")); this.ScanPathForTranscoders(CONFIG.GetPath("Transcoders_User")); } }
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); }
internal void ScanExtensions() { this.ScanPathForExtensions(CONFIG.GetPath("AutoFiddlers_User")); this.ScanPathForExtensions(CONFIG.GetPath("AutoFiddlers_Machine")); if (this.m_Extensions.Count > 0) { FiddlerApplication.FiddlerBoot += new SimpleEventHandler(this.DoOnLoad); } if (CONFIG.IsMicrosoftMachine && (this.m_Extensions.Count > 5)) { FiddlerApplication.logSelfHostOnePerSession(60); } }
private MakeCertEngine() { if (Environment.OSVersion.Version.Major > 5) { this.string_1 = "sha256"; } this.string_0 = CONFIG.GetPath("MakeCert"); if (!System.IO.File.Exists(this.string_0)) { FiddlerApplication.Log.LogFormat("Cannot locate:\n\t\"{0}\"\n\nPlease move makecert.exe to the Fiddler installation directory.", new object[] { this.string_0 }); throw new FileNotFoundException("Cannot locate: \"" + this.string_0 + "\". Please move makecert.exe to the Fiddler installation directory."); } }
private void WriteAutoProxyPACFile(bool bUseFiddler) { if (!CONFIG.bIsViewOnly) { try { System.IO.File.WriteAllText(CONFIG.GetPath("Pac"), this._GetPACScriptText(bUseFiddler)); } catch (Exception exception) { FiddlerApplication.Log.LogFormat("Failed to update PAC file to indicate Listening={0} due to {1}", new object[] { bUseFiddler, exception.Message }); } } }
public bool ImportSAZ(string sFilename) { Session[] oSessions = Utilities.ReadSessionArchive(sFilename, true); if (oSessions == null) { return(false); } if (sFilename.StartsWith(CONFIG.GetPath("Captures"), StringComparison.OrdinalIgnoreCase)) { sFilename = sFilename.Substring(CONFIG.GetPath("Captures").Length); } else { sFilename = Utilities.CollapsePath(sFilename); } return(this.ImportSessions(oSessions, sFilename)); }
private static X509Certificate _GetDefaultCertificate() { if (FiddlerApplication.oDefaultClientCertificate != null) { return(FiddlerApplication.oDefaultClientCertificate); } X509Certificate x509Certificate = null; if (File.Exists(CONFIG.GetPath("DefaultClientCertificate"))) { x509Certificate = X509Certificate.CreateFromCertFile(CONFIG.GetPath("DefaultClientCertificate")); if (x509Certificate != null && FiddlerApplication.Prefs.GetBoolPref("fiddler.network.https.cacheclientcert", true)) { FiddlerApplication.oDefaultClientCertificate = x509Certificate; } } return(x509Certificate); }
public bool LoadRulesScript() { bool flag = false; try { string path = CONFIG.GetPath("CustomRules"); if (FiddlerApplication.Prefs.GetBoolPref("fiddler.script.delaycreate", true) && !File.Exists(path)) { path = CONFIG.GetPath("SampleRules"); } flag = this._LoadScript(path); } catch (Exception exception) { FiddlerApplication.DoNotifyUser(string.Concat(new object[] { "Failed to load script.\n ", exception.Message, "\n", exception.InnerException, exception.StackTrace }), "Script Failure", MessageBoxIcon.Hand); this.ClearScript(); } return(flag); }
public FiddlerScript() { this.objVSASite = new ScriptEngineSite(this); this.scriptsFolderWatcher = new FileSystemWatcher(); this.scriptsFolderWatcher.Filter = "CustomRules.js"; this.scriptsFolderWatcher.NotifyFilter = NotifyFilters.LastWrite; this.scriptsFolderWatcher.SynchronizingObject = FiddlerApplication.UI; this.scriptsFolderWatcher.Deleted += new FileSystemEventHandler(this.scriptsFolderWatcher_Notify); this.scriptsFolderWatcher.Created += new FileSystemEventHandler(this.scriptsFolderWatcher_Notify); this.scriptsFolderWatcher.Changed += new FileSystemEventHandler(this.scriptsFolderWatcher_Notify); try { this.scriptsFolderWatcher.Path = CONFIG.GetPath("Scripts"); this.scriptsFolderWatcher.EnableRaisingEvents = true; } catch (Exception exception) { FiddlerApplication.ReportException(exception, "ScriptWatcher Failure"); } }
private void scriptsFolderWatcher_Notify(object sender, FileSystemEventArgs e) { if ((CONFIG.bAutoLoadScript && CONFIG.bLoadScript) && string.Equals(e.Name, "CustomRules.js", StringComparison.OrdinalIgnoreCase)) { if ((Environment.TickCount - lastScriptLoadTickCount) < CONFIG.iScriptReloadInterval) { lastScriptLoadTickCount = Environment.TickCount; } else { if (CONFIG.IsMicrosoftMachine) { FiddlerApplication.logSelfHost(50); } lastScriptLoadTickCount = Environment.TickCount; Utilities.PlaySound(CONFIG.GetPath("App") + "LoadScript.wav", IntPtr.Zero, Utilities.SoundFlags.SND_FILENAME | Utilities.SoundFlags.SND_NOWAIT | Utilities.SoundFlags.SND_NODEFAULT | Utilities.SoundFlags.SND_ASYNC); Thread.Sleep(250); this.LoadRulesScript(); } } }
private static X509CertificateCollection GetCertificateCollectionFromFile(string sClientCertificateFilename) { X509CertificateCollection x509CertificateCollection = null; if (!string.IsNullOrEmpty(sClientCertificateFilename)) { sClientCertificateFilename = Utilities.EnsurePathIsAbsolute(CONFIG.GetPath("Root"), sClientCertificateFilename); if (File.Exists(sClientCertificateFilename)) { x509CertificateCollection = new X509CertificateCollection(); x509CertificateCollection.Add(X509Certificate.CreateFromCertFile(sClientCertificateFilename)); } else { FiddlerApplication.Log.LogFormat("!! ERROR: Specified client certificate file '{0}' does not exist.", new object[] { sClientCertificateFilename }); } } return(x509CertificateCollection); }
internal static void EnsureFoldersExist() { try { if (!Directory.Exists(CONFIG.GetPath("Captures"))) { Directory.CreateDirectory(CONFIG.GetPath("Captures")); } if (!Directory.Exists(CONFIG.GetPath("Requests"))) { Directory.CreateDirectory(CONFIG.GetPath("Requests")); } if (!Directory.Exists(CONFIG.GetPath("Responses"))) { Directory.CreateDirectory(CONFIG.GetPath("Responses")); } if (!Directory.Exists(CONFIG.GetPath("Scripts"))) { Directory.CreateDirectory(CONFIG.GetPath("Scripts")); } } catch (Exception ex) { FiddlerApplication.DoNotifyUser(ex.ToString(), "Folder Creation Failed"); } try { if (!FiddlerApplication.Prefs.GetBoolPref("fiddler.script.delaycreate", true) && !File.Exists(CONFIG.GetPath("CustomRules")) && File.Exists(CONFIG.GetPath("SampleRules"))) { File.Copy(CONFIG.GetPath("SampleRules"), CONFIG.GetPath("CustomRules")); } } catch (Exception ex2) { FiddlerApplication.DoNotifyUser(ex2.ToString(), "Initial file copies failed"); } }
internal X509CertificateCollection GetCertificateCollectionFromFile(string sClientCertificateFilename) { X509CertificateCollection certificates = null; if (!string.IsNullOrEmpty(sClientCertificateFilename)) { try { if (!Path.IsPathRooted(sClientCertificateFilename)) { sClientCertificateFilename = CONFIG.GetPath("Root") + sClientCertificateFilename; } } catch (Exception) { } if (System.IO.File.Exists(sClientCertificateFilename)) { certificates = new X509CertificateCollection(); certificates.Add(X509Certificate.CreateFromCertFile(sClientCertificateFilename)); } } return(certificates); }
// The OnExecAction function is called by either the QuickExec box in the Fiddler window, // or by the ExecAction.exe command line utility. public static bool OnExecAction(string[] sParams) { FiddlerApplication.UI.SetStatusText("ExecAction: " + sParams[0]); string sAction = sParams[0].ToLower(); switch (sAction) { case "bold": if (sParams.Length < 2) { uiBoldURI = null; FiddlerApplication.UI.SetStatusText("Bolding cleared"); return(false); } uiBoldURI = sParams[1]; FiddlerApplication.UI.SetStatusText("Bolding requests for " + uiBoldURI); return(true); case "bp": MessageBox.Show("bpu = breakpoint request for uri\nbpm = breakpoint request method\nbps=breakpoint response status\nbpafter = breakpoint response for URI"); return(true); case "bps": if (sParams.Length < 2) { bpStatus = -1; FiddlerApplication.UI.SetStatusText("Response Status breakpoint cleared"); return(false); } bpStatus = Int32.Parse(sParams[1]); FiddlerApplication.UI.SetStatusText("Response status breakpoint for " + sParams[1]); return(true); case "bpv": case "bpm": if (sParams.Length < 2) { bpMethod = null; FiddlerApplication.UI.SetStatusText("Request Method breakpoint cleared"); return(false); } bpMethod = sParams[1].ToUpper(); FiddlerApplication.UI.SetStatusText("Request Method breakpoint for " + bpMethod); return(true); case "bpu": if (sParams.Length < 2) { bpRequestURI = null; FiddlerApplication.UI.SetStatusText("RequestURI breakpoint cleared"); return(false); } bpRequestURI = sParams[1]; FiddlerApplication.UI.SetStatusText("RequestURI breakpoint for " + sParams[1]); return(true); case "bpa": case "bpafter": if (sParams.Length < 2) { bpResponseURI = null; FiddlerApplication.UI.SetStatusText("ResponseURI breakpoint cleared"); return(false); } bpResponseURI = sParams[1]; FiddlerApplication.UI.SetStatusText("ResponseURI breakpoint for " + sParams[1]); return(true); case "overridehost": if (sParams.Length < 3) { gs_OverridenHost = null; FiddlerApplication.UI.SetStatusText("Host Override cleared"); return(false); } gs_OverridenHost = sParams[1].ToLower(); gs_OverrideHostWith = sParams[2]; FiddlerApplication.UI.SetStatusText("Connecting to [" + gs_OverrideHostWith + "] for requests to [" + gs_OverridenHost + "]"); return(true); case "urlreplace": if (sParams.Length < 3) { gs_ReplaceToken = null; FiddlerApplication.UI.SetStatusText("URL Replacement cleared"); return(false); } gs_ReplaceToken = sParams[1]; gs_ReplaceTokenWith = sParams[2].Replace(" ", "%20"); // Simple helper FiddlerApplication.UI.SetStatusText("Replacing [" + gs_ReplaceToken + "] in URIs with [" + gs_ReplaceTokenWith + "]"); return(true); case "allbut": case "keeponly": if (sParams.Length < 2) { FiddlerApplication.UI.SetStatusText("Please specify Content-Type to retain during wipe."); return(false); } FiddlerApplication.UI.actSelectSessionsWithResponseHeaderValue("Content-Type", sParams[1]); FiddlerApplication.UI.actRemoveUnselectedSessions(); FiddlerApplication.UI.lvSessions.SelectedItems.Clear(); FiddlerApplication.UI.SetStatusText("Removed all but Content-Type: " + sParams[1]); return(true); case "stop": FiddlerApplication.UI.actDetachProxy(); return(true); case "start": FiddlerApplication.UI.actAttachProxy(); return(true); case "cls": case "clear": FiddlerApplication.UI.actRemoveAllSessions(); return(true); case "g": case "go": FiddlerApplication.UI.actResumeAllSessions(); return(true); case "goto": if (sParams.Length != 2) { return(false); } Utilities.LaunchHyperlink("http://www.google.com/search?hl=en&btnI=I%27m+Feeling+Lucky&q=" + Utilities.UrlEncode(sParams[1])); return(true); case "help": Utilities.LaunchHyperlink("http://fiddler2.com/r/?quickexec"); return(true); case "hide": FiddlerApplication.UI.actMinimizeToTray(); return(true); case "log": FiddlerApplication.Log.LogString((sParams.Length < 2) ? "User couldn't think of anything to say..." : sParams[1]); return(true); case "nuke": FiddlerApplication.UI.actClearWinINETCache(); FiddlerApplication.UI.actClearWinINETCookies(); return(true); case "screenshot": FiddlerApplication.UI.actCaptureScreenshot(false); return(true); case "show": FiddlerApplication.UI.actRestoreWindow(); return(true); case "tail": if (sParams.Length < 2) { FiddlerApplication.UI.SetStatusText("Please specify # of sessions to trim the session list to."); return(false); } FiddlerApplication.UI.TrimSessionList(int.Parse(sParams[1])); return(true); case "quit": FiddlerApplication.UI.actExit(); return(true); case "dump": FiddlerApplication.UI.actSelectAll(); FiddlerApplication.UI.actSaveSessionsToZip(CONFIG.GetPath("Captures") + "dump.saz"); FiddlerApplication.UI.actRemoveAllSessions(); FiddlerApplication.UI.SetStatusText("Dumped all sessions to " + CONFIG.GetPath("Captures") + "dump.saz"); return(true); default: if (sAction.StartsWith("http") || sAction.StartsWith("www")) { System.Diagnostics.Process.Start(sParams[0]); return(true); } else { FiddlerApplication.UI.SetStatusText("Requested ExecAction: '" + sAction + "' not found. Type HELP to learn more."); return(false); } } }
private static ICertificateProvider LoadOverrideCertProvider() { string stringPref = FiddlerApplication.Prefs.GetStringPref("fiddler.certmaker.assembly", CONFIG.GetPath("App") + "CertMaker.dll"); if (File.Exists(stringPref)) { Assembly assembly; try { assembly = Assembly.LoadFrom(stringPref); if (!Utilities.FiddlerMeetsVersionRequirement(assembly, "Certificate Maker")) { FiddlerApplication.Log.LogFormat("Assembly {0} did not specify a RequiredVersionAttribute. Aborting load of Certificate Generation module.", new object[] { assembly.CodeBase }); return(null); } } catch (Exception exception) { FiddlerApplication.LogAddonException(exception, "Failed to load CertMaker" + stringPref); return(null); } foreach (Type type in assembly.GetExportedTypes()) { if ((!type.IsAbstract && type.IsPublic) && (type.IsClass && typeof(ICertificateProvider).IsAssignableFrom(type))) { try { return((ICertificateProvider)Activator.CreateInstance(type)); } catch (Exception exception2) { FiddlerApplication.DoNotifyUser(string.Format("[Fiddler] Failure loading {0} CertMaker from {1}: {2}\n\n{3}\n\n{4}", new object[] { type.Name, assembly.CodeBase, exception2.Message, exception2.StackTrace, exception2.InnerException }), "Load Error"); } } } } return(null); }
internal void LoadRules() { this.LoadRules(CONFIG.GetPath("AutoResponderDefaultRules"), true); }
internal DefaultCertificateProvider() { this._sMakeCertLocation = CONFIG.GetPath("MakeCert"); }
static CONFIG() { CONFIG.sDefaultBrowserExe = "iexplore.exe"; CONFIG.sDefaultBrowserParams = string.Empty; CONFIG.bRunningOnCLRv4 = (Environment.Version.Major > 3); CONFIG.bQuietMode = !Environment.UserInteractive; CONFIG._pfcDecyptFilter = ProcessFilterCategories.All; CONFIG.sLVColInfo = null; CONFIG.bIsViewOnly = false; CONFIG.bUseXceedDecompressForGZIP = false; CONFIG.bUseXceedDecompressForDeflate = false; CONFIG.bMapSocketToProcess = true; CONFIG.bMITM_HTTPS = false; CONFIG.bUseSNIForCN = false; CONFIG.bIgnoreServerCertErrors = false; CONFIG.bStreamAudioVideo = false; CONFIG.bCheckCompressionIntegrity = false; CONFIG.bShowDefaultClientCertificateNeededPrompt = true; CONFIG.sFiddlerListenHostPort = "127.0.0.1:8888"; CONFIG.sMakeCertParamsRoot = "-r -ss my -n \"CN={0}{1}\" -sky signature -eku 1.3.6.1.5.5.7.3.1 -h 1 -cy authority -a sha1 -m 132 -b {3}{4}"; CONFIG.sMakeCertParamsEE = "-pe -ss my -n \"CN={0}{1}\" -sky exchange -in {2} -is my -eku 1.3.6.1.5.5.7.3.1 -cy end -a sha1 -m 132 -b {3}{4}"; CONFIG.sMakeCertRootCN = "DO_NOT_TRUST_FiddlerRoot"; CONFIG.sMakeCertSubjectO = ", O=DO_NOT_TRUST, OU=Created by http://www.fiddler2.com"; CONFIG.sRootUrl = "http://fiddler2.com/fiddlercore/"; CONFIG.sSecureRootUrl = "https://fiddler2.com/"; CONFIG.sRootKey = "SOFTWARE\\Microsoft\\FiddlerCore\\"; CONFIG.sUserPath = string.Concat(new object[] { CONFIG.GetPath("MyDocs"), Path.DirectorySeparatorChar, "FiddlerCore", Path.DirectorySeparatorChar }); CONFIG.sScriptPath = string.Concat(new object[] { CONFIG.sUserPath, "Scripts", Path.DirectorySeparatorChar, "CustomRules.js" }); CONFIG.bUseAESForSAZ = true; CONFIG.oAcceptedClientHTTPSProtocols = (SslProtocols)4092; CONFIG.oAcceptedServerHTTPSProtocols = SslProtocols.Default; CONFIG.FiddlerVersionInfo = Assembly.GetExecutingAssembly().GetName().Version; CONFIG.bIsBeta = false; CONFIG.bForwardToGateway = true; CONFIG._UpstreamGateway = GatewayType.System; CONFIG.bDebugSpew = false; CONFIG.oHeaderEncoding = Encoding.UTF8; CONFIG.oBodyEncoding = Encoding.UTF8; CONFIG.bReuseServerSockets = true; CONFIG.bReuseClientSockets = true; CONFIG.bCaptureCONNECT = true; CONFIG.bCaptureFTP = false; CONFIG.bUseEventLogForExceptions = false; CONFIG.bAutoProxyLogon = false; CONFIG.bEnableIPv6 = (Environment.OSVersion.Version.Major > 5); CONFIG.sHookConnectionNamed = "DefaultLAN"; CONFIG.bHookAllConnections = true; CONFIG.bHookWithPAC = false; CONFIG.m_bCheckForISA = true; CONFIG.m_ListenPort = 8888; CONFIG.bUsingPortOverride = false; CONFIG.bDebugCertificateGeneration = true; CONFIG.sAlternateHostname = "?"; CONFIG.sReverseProxyHostname = "localhost"; CONFIG.sMachineName = string.Empty; CONFIG.sMachineDomain = string.Empty; CONFIG.oHLSkipDecryption = null; try { IPGlobalProperties iPGlobalProperties = IPGlobalProperties.GetIPGlobalProperties(); CONFIG.sMachineDomain = iPGlobalProperties.DomainName.ToLowerInvariant(); CONFIG.sMachineName = iPGlobalProperties.HostName.ToLowerInvariant(); } catch (Exception) { } CONFIG.bQuietMode = true; CONFIG.bDebugSpew = false; CONFIG.m_ListenPort = 8866; if (Environment.OSVersion.Version.Major < 6 && Environment.OSVersion.Version.Minor < 1) { CONFIG.bMapSocketToProcess = false; } }
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) { return(null); } if (FiddlerApplication.ClientCertificateProvider != null) { X509Certificate x509Certificate = FiddlerApplication.ClientCertificateProvider(oS, targetHost, localCertificates, remoteCertificate, acceptableIssuers); if (x509Certificate != null && CONFIG.bDebugSpew) { Trace.WriteLine(string.Format("Session #{0} Attaching client certificate '{1}' when connecting to host '{2}'", oS.Int32_0, x509Certificate.Subject, targetHost)); } return(x509Certificate); } X509Certificate x509Certificate2 = ServerPipe._GetDefaultCertificate(); if (x509Certificate2 != null) { this.MarkAsAuthenticated(oS.LocalProcessID); oS.oFlags["x-client-cert"] = x509Certificate2.Subject + " Serial#" + x509Certificate2.GetSerialNumberString(); return(x509Certificate2); } if (CONFIG.bShowDefaultClientCertificateNeededPrompt && FiddlerApplication.Prefs.GetBoolPref("fiddler.network.https.clientcertificate.ephemeral.prompt-for-missing", true)) { FiddlerApplication.Prefs.SetBoolPref("fiddler.network.https.clientcertificate.ephemeral.prompt-for-missing", false); FiddlerApplication.DoNotifyUser("The server [" + targetHost + "] requests a client certificate.\nPlease save a client certificate using the filename:\n\n" + CONFIG.GetPath("DefaultClientCertificate"), "Client Certificate Requested"); } FiddlerApplication.Log.LogFormat("The server [{0}] requested a client certificate, but no client certificate was available.", new object[] { targetHost }); return(null); }
internal bool Attach(bool bCollectGWInfo) { if (this._bIsAttached) { return(true); } if (CONFIG.bIsViewOnly) { return(false); } if (bCollectGWInfo) { this.CollectConnectoidAndGatewayInfo(); } WinINETProxyInfo winINETProxyInfo = new WinINETProxyInfo(); winINETProxyInfo.bUseManualProxies = true; winINETProxyInfo.bAllowDirect = true; winINETProxyInfo.sHttpProxy = CONFIG.sFiddlerListenHostPort; if (CONFIG.bCaptureCONNECT) { winINETProxyInfo.sHttpsProxy = CONFIG.sFiddlerListenHostPort; } else { if (this.piSystemGateway != null && this.piSystemGateway.bUseManualProxies) { winINETProxyInfo.sHttpsProxy = this.piSystemGateway.sHttpsProxy; } } if (CONFIG.bCaptureFTP) { winINETProxyInfo.sFtpProxy = CONFIG.sFiddlerListenHostPort; } else { if (this.piSystemGateway != null && this.piSystemGateway.bUseManualProxies) { winINETProxyInfo.sFtpProxy = this.piSystemGateway.sFtpProxy; } } if (this.piSystemGateway != null && this.piSystemGateway.bUseManualProxies) { winINETProxyInfo.sSocksProxy = this.piSystemGateway.sSocksProxy; } winINETProxyInfo.sHostsThatBypass = CONFIG.sHostsThatBypassFiddler; if (CONFIG.bHookWithPAC) { if (FiddlerApplication.Prefs.GetBoolPref("fiddler.proxy.pacfile.usefileprotocol", true)) { winINETProxyInfo.sPACScriptLocation = "file://" + CONFIG.GetPath("Pac"); } else { winINETProxyInfo.sPACScriptLocation = "http://" + CONFIG.sFiddlerListenHostPort + "/proxy.pac"; } } if (this.oAllConnectoids == null) { this.CollectConnectoidAndGatewayInfo(); } if (this.oAllConnectoids.HookConnections(winINETProxyInfo)) { this._bIsAttached = true; FiddlerApplication.OnFiddlerAttach(); this.WriteAutoProxyPACFile(true); if (this.oRegistryWatcher == null && FiddlerApplication.Prefs.GetBoolPref("fiddler.proxy.WatchRegistry", true)) { this.oRegistryWatcher = RegistryWatcher.WatchKey(RegistryHive.CurrentUser, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", new EventHandler(this.ProxyRegistryKeysChanged)); } Proxy._setDynamicRegistryKey(true); return(true); } FiddlerApplication.DoNotifyUser("Failed to register Fiddler as the system proxy.", "Error"); Proxy._setDynamicRegistryKey(false); return(false); }
internal string _GetPACScriptText(bool bUseFiddler) { string stringPref; if (bUseFiddler) { stringPref = FiddlerApplication.Prefs.GetStringPref("fiddler.proxy.pacfile.text", "return 'PROXY " + CONFIG.sFiddlerListenHostPort + "';"); } else { stringPref = "return 'DIRECT';"; } return("//Autogenerated file; do not edit. Rewritten on attach and detach of Fiddler.\n//This Automatic Proxy Configuration script can be used by non-WinINET browsers.\n//Point your browser's Proxy AutoConfiguration URL to:\n// file:///" + HttpUtility.UrlPathEncode(CONFIG.GetPath("Pac")) + "\n\nfunction FindProxyForURL(url, host){\n " + stringPref + "\n}"); }
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"); } }
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); }
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) }); } } } }
private static ICertificateProvider LoadOverrideCertProvider() { string stringPref = FiddlerApplication.Prefs.GetStringPref("fiddler.certmaker.assembly", CONFIG.GetPath("App") + "CertMaker.dll"); if (!File.Exists(stringPref)) { return(null); } Assembly assembly; try { assembly = Assembly.LoadFrom(stringPref); if (!Utilities.FiddlerMeetsVersionRequirement(assembly, "Certificate Makers")) { FiddlerApplication.Log.LogFormat("Assembly {0} did not specify a RequiredVersionAttribute. Aborting load of Certificate Generation module.", new object[] { assembly.CodeBase }); ICertificateProvider result = null; return(result); } } catch (Exception ex) { FiddlerApplication.Log.LogFormat("Failed to load CertMaker from {0} due to {1}.", new object[] { stringPref, ex.Message }); ICertificateProvider result = null; return(result); } Type[] exportedTypes = assembly.GetExportedTypes(); for (int i = 0; i < exportedTypes.Length; i++) { Type type = exportedTypes[i]; if (!type.IsAbstract && type.IsPublic && type.IsClass && typeof(ICertificateProvider).IsAssignableFrom(type)) { try { ICertificateProvider result = (ICertificateProvider)Activator.CreateInstance(type); return(result); } catch (Exception ex2) { FiddlerApplication.DoNotifyUser(string.Format("[Fiddler] Failure loading {0} CertMaker from {1}: {2}\n\n{3}\n\n{4}", new object[] { type.Name, assembly.CodeBase, ex2.Message, ex2.StackTrace, ex2.InnerException }), "Load Error"); } } } FiddlerApplication.Log.LogFormat("Assembly {0} did not contain a recognized ICertificateProvider.", new object[] { assembly.CodeBase }); return(null); }