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); }
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 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 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 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); }
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); }
private bool actSendRawRequest() { try { FiddlerApplication.oProxy.InjectCustomRequest(this.txtRaw.Text); return(true); } catch (Exception exception) { FiddlerApplication.DoNotifyUser(exception.Message, "Custom Request Failed"); return(false); } }
public void CheckForUpdates(bool bVerbose) { try { VersionStruct verServer = new VersionStruct(); verServer = this.GetLatestVersion(CONFIG.bIsBeta); FiddlerApplication.Prefs.SetStringPref("fiddler.welcomemsg", verServer.sWelcomeMsg); int num = CompareVersions(ref verServer, CONFIG.FiddlerVersionInfo); if ((num > 1) || (bVerbose && (num > 0))) { verServer.sWhatIsNew = verServer.sWhatIsNew + string.Format("\r\n\r\n------------------------------\r\nWould you like to learn more?\r\n{0}{1}&IsBeta={2}", CONFIG.GetUrl("ChangeList"), Application.ProductVersion, CONFIG.bIsBeta.ToString()); frmUpdate oUpdatePrompt = new frmUpdate("Update Announcement (from v" + Application.ProductVersion + " to v" + verServer.Major.ToString() + "." + verServer.Minor.ToString() + "." + verServer.Build.ToString() + "." + verServer.Private.ToString() + ")", "Good news! An improved version of Fiddler is now available.\r\n\r\n" + verServer.sWhatIsNew, !verServer.bMustCleanInstall, bVerbose ? MessageBoxDefaultButton.Button1 : MessageBoxDefaultButton.Button2) { StartPosition = FormStartPosition.CenterScreen }; DialogResult updateDecision = FiddlerApplication.UI.GetUpdateDecision(oUpdatePrompt); if (DialogResult.Yes == updateDecision) { Utilities.LaunchHyperlink(CONFIG.GetUrl("InstallLatest")); } else if (DialogResult.Retry == updateDecision) { try { RegistryKey oReg = Registry.CurrentUser.OpenSubKey(CONFIG.GetRegPath("Root"), true); if (oReg != null) { Utilities.SetRegistryString(oReg, "UpdatePending", "True"); oReg.Close(); } } catch { } } } else if (bVerbose) { FiddlerApplication.DoNotifyUser("Your version of Fiddler is up-to-date.\n\nThanks for checking!", "FiddlerUpdate"); } } catch (Exception exception) { if (bVerbose) { MessageBox.Show("There was an error retrieving version information. You can check for updates manually by visiting https://www.fiddler2.com/\n\n" + exception.ToString(), "Error retrieving version information"); } } }
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); }
private void ScanPathForTranscoders(string sPath) { try { if (Directory.Exists(sPath)) { Evidence securityEvidence = Assembly.GetExecutingAssembly().Evidence; FileInfo[] files = new DirectoryInfo(sPath).GetFiles(); bool boolPref = FiddlerApplication.Prefs.GetBoolPref("fiddler.debug.extensions.verbose", false); if (boolPref) { FiddlerApplication.Log.LogFormat("Searching for Transcoders under {0}", new object[] { sPath }); } foreach (FileInfo info in files) { if (info.FullName.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) && !info.FullName.StartsWith("_", StringComparison.OrdinalIgnoreCase)) { Assembly assembly; if (boolPref) { FiddlerApplication.Log.LogFormat("Looking for Transcoders inside {0}", new object[] { info.FullName.ToString() }); } 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_0105; } this.ScanAssemblyForTranscoders(assembly); Label_0105 :; } } } } catch (Exception exception2) { FiddlerApplication.DoNotifyUser(string.Format("[Fiddler] Failure loading Transcoders: {0}", exception2.Message), "Transcoders Load Error"); } }
private void HandleScriptQuickLinkClick(object sender, EventArgs e) { try { MethodInfo info = (MethodInfo)htMenuScripts[sender]; if (((info.GetParameters().Length != 2) || (info.GetParameters()[0].ParameterType != typeof(string))) || (info.GetParameters()[1].ParameterType != typeof(string))) { throw new InvalidDataException("Handler function was incorrectly defined. Should be function(string,string);"); } info.Invoke(null, new object[] { (sender as MenuItem).Text, (sender as MenuItem).Tag as string }); } catch (Exception exception) { FiddlerApplication.DoNotifyUser(exception.Message, "Script Error"); } }
private void HandleScriptToolsClick(object sender, EventArgs e) { try { MethodInfo info = (MethodInfo)htMenuScripts[sender]; if ((info.GetParameters().Length == 1) && (info.GetParameters()[0].ParameterType == typeof(Session[]))) { info.Invoke(null, new object[] { FiddlerApplication._frmMain.GetSelectedSessions() }); } else { info.Invoke(null, null); } } catch (Exception exception) { FiddlerApplication.DoNotifyUser(exception.Message, "Script Error"); } }
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); }
private static void HandleItemClick(object sender, EventArgs e) { RegistryKey key = Registry.CurrentUser.OpenSubKey(CONFIG.GetRegPath("MenuExt") + (sender as MenuItem).Text); if (key != null) { string sExecute = (string)key.GetValue("Command"); string sParams = (string)key.GetValue("Parameters"); string sMethodName = (string)key.GetValue("ScriptMethod"); key.Close(); if ((sMethodName != null) && ((FiddlerApplication.scriptRules == null) || !FiddlerApplication.scriptRules.DoMethod(sMethodName))) { FiddlerApplication.DoNotifyUser(string.Format("Failed to execute script method: {0}\n(Case sensitive. Ensure your script includes a function of that name.)", sMethodName), "Scripting Error"); } if (sExecute != null) { Utilities.RunExecutable(sExecute, sParams); } } }
internal static bool exportRootToDesktop() { try { byte[] rootCertBytes = CertMaker.getRootCertBytes(); if (rootCertBytes != null) { File.WriteAllBytes(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + Path.DirectorySeparatorChar + "FiddlerRoot.cer", rootCertBytes); bool result = true; return(result); } FiddlerApplication.DoNotifyUser("The root certificate could not be located.", "Export Failed"); } catch (Exception eX) { FiddlerApplication.ReportException(eX, "Certificate Export Failed"); bool result = false; return(result); } return(false); }
internal void NotifyOfCompilerError(IVsaError e) { if (this._RulesCompileFailed == null) { string lineText; string[] strArray = e.LineText.Split(new char[] { '\n' }); if ((e.Line >= 2) && (e.Line < strArray.Length)) { lineText = "\t\t" + strArray[e.Line - 2].Trim() + "\nERROR LINE -->\t" + strArray[e.Line - 1].Trim() + "\n\t\t" + strArray[e.Line].Trim(); } else { lineText = e.LineText; } FiddlerApplication.DoNotifyUser(string.Format("FiddlerScript compilation failed on line {0}:\n\n---------------------- SOURCE -------------------------------\n\n{1}\n\n-------------------------------------------------------------------\n\n{2}", e.Line, lineText, e.Description), "FiddlerScript Error", MessageBoxIcon.Hand); } else { this._RulesCompileFailed(e.Description, e.Line, e.StartColumn, e.EndColumn); } }
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); }
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); }
private static void VistaClearTracks(bool bClearFiles, bool bClearCookies) { int num = 0; if (bClearCookies) { num = 2; } if (bClearFiles) { num = 0x100c; } try { using (Process.Start("rundll32.exe", "inetcpl.cpl,ClearMyTracksByProcess " + num.ToString())) { } } catch (Exception exception) { FiddlerApplication.DoNotifyUser("Failed to launch ClearMyTracksByProcess.\n" + exception.Message, "Error"); } }
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"); } }
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); }
public static string GetPath(string sWhatPath) { switch (sWhatPath) { case "App": return(Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar); case "AutoFiddlers_Machine": return(string.Concat(new object[] { Path.GetDirectoryName(Application.ExecutablePath), Path.DirectorySeparatorChar, "Scripts", Path.DirectorySeparatorChar })); case "AutoFiddlers_User": return(CONFIG.sUserPath + "Scripts" + Path.DirectorySeparatorChar); case "AutoResponderDefaultRules": return(CONFIG.sUserPath + "AutoResponder.xml"); case "Captures": return(FiddlerApplication.Prefs.GetStringPref("fiddler.config.path.captures", CONFIG.sUserPath + "Captures" + Path.DirectorySeparatorChar)); case "CustomRules": return(CONFIG.sScriptPath); case "DefaultClientCertificate": return(FiddlerApplication.Prefs.GetStringPref("fiddler.config.path.defaultclientcert", CONFIG.sUserPath + "ClientCertificate.cer")); case "FiddlerRootCert": return(CONFIG.sUserPath + "DO_NOT_TRUST_FiddlerRoot.cer"); case "Filters": return(CONFIG.sUserPath + "Filters" + Path.DirectorySeparatorChar); case "Inspectors": return(string.Concat(new object[] { Path.GetDirectoryName(Application.ExecutablePath), Path.DirectorySeparatorChar, "Inspectors", Path.DirectorySeparatorChar })); case "Inspectors_User": return(CONFIG.sUserPath + "Inspectors" + Path.DirectorySeparatorChar); case "PerUser-ISA-Config": { string text = "C:\\"; try { text = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); } catch (Exception) { } return(text + "\\microsoft\\firewall client 2004\\management.ini"); } case "PerMachine-ISA-Config": { string text = "C:\\"; try { text = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData); } catch (Exception) { } return(text + "\\microsoft\\firewall client 2004\\management.ini"); } case "MakeCert": { string text = FiddlerApplication.Prefs.GetStringPref("fiddler.config.path.makecert", Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + "MakeCert.exe"); if (!File.Exists(text)) { text = "MakeCert.exe"; } return(text); } case "MyDocs": { string text = "C:\\"; try { text = Environment.GetFolderPath(Environment.SpecialFolder.Personal); } catch (Exception ex) { FiddlerApplication.DoNotifyUser("Initialization Error", "Failed to retrieve path to your My Documents folder.\nThis generally means you have a relative environment variable.\nDefaulting to C:\\\n\n" + ex.Message); } return(text); } case "Pac": return(FiddlerApplication.Prefs.GetStringPref("fiddler.config.path.pac", string.Concat(new object[] { CONFIG.sUserPath, "Scripts", Path.DirectorySeparatorChar, "BrowserPAC.js" }))); case "Requests": return(FiddlerApplication.Prefs.GetStringPref("fiddler.config.path.requests", string.Concat(new object[] { CONFIG.sUserPath, "Captures", Path.DirectorySeparatorChar, "Requests", Path.DirectorySeparatorChar }))); case "Responses": return(FiddlerApplication.Prefs.GetStringPref("fiddler.config.path.responses", string.Concat(new object[] { CONFIG.sUserPath, "Captures", Path.DirectorySeparatorChar, "Responses", Path.DirectorySeparatorChar }))); case "Root": return(CONFIG.sUserPath); case "SafeTemp": { string text = "C:\\"; try { text = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache); } catch (Exception ex2) { FiddlerApplication.DoNotifyUser("Failed to retrieve path to your Internet Cache folder.\nThis generally means you have a relative environment variable.\nDefaulting to C:\\\n\n" + ex2.Message, "GetPath(SafeTemp) Failed"); } return(text); } case "SampleRules": return(string.Concat(new object[] { Path.GetDirectoryName(Application.ExecutablePath), Path.DirectorySeparatorChar, "Scripts", Path.DirectorySeparatorChar, "SampleRules.js" })); case "Scripts": return(CONFIG.sUserPath + "Scripts" + Path.DirectorySeparatorChar); case "TemplateResponses": return(FiddlerApplication.Prefs.GetStringPref("fiddler.config.path.templateresponses", string.Concat(new object[] { Path.GetDirectoryName(Application.ExecutablePath), Path.DirectorySeparatorChar, "ResponseTemplates", Path.DirectorySeparatorChar }))); case "Tools": return(FiddlerApplication.Prefs.GetStringPref("fiddler.config.path.Tools", string.Concat(new object[] { Path.GetDirectoryName(Application.ExecutablePath), Path.DirectorySeparatorChar, "Tools", Path.DirectorySeparatorChar }))); case "Transcoders_Machine": return(string.Concat(new object[] { Path.GetDirectoryName(Application.ExecutablePath), Path.DirectorySeparatorChar, "ImportExport", Path.DirectorySeparatorChar })); case "Transcoders_User": return(CONFIG.sUserPath + "ImportExport" + Path.DirectorySeparatorChar); } return("C:\\"); }
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 X509Certificate2 method_2(string string_1, bool bool_1) { if (string_1.IndexOfAny(new char[] { '"', '\r', '\n', '\0' }) != -1) { return(null); } if (!bool_1 && (this.GetRootCertificate() == null)) { try { this.GetWriterLock(); if ((this.GetRootCertificate() == null) && !this.CreateRootCertificate()) { FiddlerApplication.DoNotifyUser("Creation of the root certificate was not successful.", "Certificate Error"); return(null); } } finally { this.FreeWriterLock(); } } X509Certificate2 certificate = null; try { X509Certificate2 certificate2; this.GetWriterLock(); if (!this.certServerCache.TryGetValue(string_1, out certificate2)) { certificate2 = LoadCertificateFromWindowsStore(string_1); } if (certificate2 != null) { if (CONFIG.bDebugCertificateGeneration) { FiddlerApplication.Log.LogFormat("/Fiddler.CertMaker>{1} A racing thread already successfully CreatedCert({0})", new object[] { string_1, Thread.CurrentThread.ManagedThreadId }); } return(certificate2); } certificate = this.engin.GetRootCertificate(string_1, bool_1); if (certificate != null) { if (bool_1) { this.certRoot = certificate; } else { this.certServerCache[string_1] = certificate; } } } finally { this.FreeWriterLock(); } if ((certificate == null) && !bool_1) { FiddlerApplication.Log.LogFormat("!Fiddler.CertMaker> Failed to create certificate for '{0}'.", new object[] { string_1 }); smethod_3(this.GetRootCertificate()); } return(certificate); }
private bool ScanAssemblyForTranscoders(Assembly assemblyInput) { bool result = false; bool boolPref = FiddlerApplication.Prefs.GetBoolPref("fiddler.debug.extensions.verbose", false); try { if (!Utilities.FiddlerMeetsVersionRequirement(assemblyInput, "Importers and Exporters")) { FiddlerApplication.Log.LogFormat("Assembly {0} did not specify a RequiredVersionAttribute. Aborting load of transcoders.", new object[] { assemblyInput.CodeBase }); bool result2 = false; return(result2); } Type[] exportedTypes = assemblyInput.GetExportedTypes(); for (int i = 0; i < exportedTypes.Length; i++) { Type type = exportedTypes[i]; if (!type.IsAbstract && type.IsPublic && type.IsClass) { if (!typeof(ISessionImporter).IsAssignableFrom(type)) { goto IL_235; } try { if (!FiddlerTranscoders.AddToImportOrExportCollection(this.m_Importers, type)) { FiddlerApplication.Log.LogFormat("WARNING: SessionImporter {0} from {1} failed to specify any ImportExportFormat attributes.", new object[] { type.Name, assemblyInput.CodeBase }); } else { result = true; if (boolPref) { FiddlerApplication.Log.LogFormat(" Added SessionImporter {0}", new object[] { type.FullName }); } } goto IL_235; } catch (Exception ex) { FiddlerApplication.DoNotifyUser(string.Format("[Fiddler] Failure loading {0} SessionImporter from {1}: {2}\n\n{3}\n\n{4}", new object[] { type.Name, assemblyInput.CodeBase, ex.Message, ex.StackTrace, ex.InnerException }), "Extension Load Error"); goto IL_235; } IL_167: try { if (!FiddlerTranscoders.AddToImportOrExportCollection(this.m_Exporters, type)) { FiddlerApplication.Log.LogFormat("WARNING: SessionExporter {0} from {1} failed to specify any ImportExportFormat attributes.", new object[] { type.Name, assemblyInput.CodeBase }); } else { result = true; if (boolPref) { FiddlerApplication.Log.LogFormat(" Added SessionExporter {0}", new object[] { type.FullName }); } } } catch (Exception ex2) { FiddlerApplication.DoNotifyUser(string.Format("[Fiddler] Failure loading {0} SessionExporter from {1}: {2}\n\n{3}\n\n{4}", new object[] { type.Name, assemblyInput.CodeBase, ex2.Message, ex2.StackTrace, ex2.InnerException }), "Extension Load Error"); } goto IL_22A; IL_235: if (typeof(ISessionExporter).IsAssignableFrom(type)) { goto IL_167; } } IL_22A :; } } catch (Exception ex3) { FiddlerApplication.DoNotifyUser(string.Format("[Fiddler] Failure loading Importer/Exporter from {0}: {1}", assemblyInput.CodeBase, ex3.Message), "Extension Load Error"); bool result2 = false; return(result2); } return(result); }
public static string GetPath(string sWhatPath) { string folderPath; switch (sWhatPath) { case "App": return(Path.GetDirectoryName(Application.ExecutablePath) + @"\"); case "AutoFiddlers_Machine": return(Path.GetDirectoryName(Application.ExecutablePath) + @"\Scripts\"); case "AutoFiddlers_User": return(sUserPath + @"Scripts\"); case "AutoResponderDefaultRules": return(sUserPath + @"\AutoResponder.xml"); case "Captures": return(FiddlerApplication.Prefs.GetStringPref("fiddler.config.path.captures", sUserPath + @"Captures\")); case "CustomRules": return(sScriptPath); case "DefaultClientCertificate": return(FiddlerApplication.Prefs.GetStringPref("fiddler.config.path.defaultclientcert", sUserPath + "ClientCertificate.cer")); case "FiddlerRootCert": return(sUserPath + "DO_NOT_TRUST_FiddlerRoot.cer"); case "Inspectors": return(Path.GetDirectoryName(Application.ExecutablePath) + @"\Inspectors\"); case "PerUser-ISA-Config": folderPath = "C:"; try { folderPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); } catch (Exception) { } return(folderPath + @"\microsoft\firewall client 2004\management.ini"); case "PerMachine-ISA-Config": folderPath = "C:"; try { folderPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData); } catch (Exception) { } return(folderPath + @"\microsoft\firewall client 2004\management.ini"); case "MakeCert": folderPath = FiddlerApplication.Prefs.GetStringPref("fiddler.config.path.makecert", Path.GetDirectoryName(Application.ExecutablePath) + @"\MakeCert.exe"); if (!File.Exists(folderPath)) { folderPath = "MakeCert.exe"; } return(folderPath); case "MyDocs": folderPath = "C:"; try { folderPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); } catch (Exception exception) { FiddlerApplication.DoNotifyUser("Initialization Error", "Failed to retrieve path to your My Documents folder.\nThis generally means you have a relative environment variable.\nDefaulting to C:\\\n\n" + exception.Message); } return(folderPath); case "Pac": return(FiddlerApplication.Prefs.GetStringPref("fiddler.config.path.pac", sUserPath + @"Scripts\BrowserPAC.js")); case "Requests": return(FiddlerApplication.Prefs.GetStringPref("fiddler.config.path.requests", sUserPath + @"Captures\Requests\")); case "Responses": return(FiddlerApplication.Prefs.GetStringPref("fiddler.config.path.responses", sUserPath + @"Captures\Responses\")); case "Root": return(sUserPath); case "SafeTemp": folderPath = "C:"; try { folderPath = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache); } catch (Exception exception2) { FiddlerApplication.DoNotifyUser("Failed to retrieve path to your Internet Cache folder.\nThis generally means you have a relative environment variable.\nDefaulting to C:\\\n\n" + exception2.Message, "GetPath(SafeTemp) Failed"); } return(folderPath); case "SampleRules": return(Path.GetDirectoryName(Application.ExecutablePath) + @"\Scripts\SampleRules.js"); case "Scripts": return(sUserPath + @"Scripts\"); case "TemplateResponses": return(FiddlerApplication.Prefs.GetStringPref("fiddler.config.path.templateresponses", Path.GetDirectoryName(Application.ExecutablePath) + @"\ResponseTemplates\")); case "TextEditor": return(FiddlerApplication.Prefs.GetStringPref("fiddler.config.path.texteditor", m_TextEditor)); case "Transcoders_Machine": return(Path.GetDirectoryName(Application.ExecutablePath) + @"\ImportExport\"); case "Transcoders_User": return(sUserPath + @"ImportExport\"); case "WINDIFF": { string stringPref = FiddlerApplication.Prefs.GetStringPref("fiddler.config.path.comparetool", null); if (string.IsNullOrEmpty(stringPref)) { if (m_CompareTool == "windiff.exe") { if (File.Exists(GetPath("App") + "windiff.exe")) { return(GetPath("App") + "windiff.exe"); } RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\WinMerge.exe", false); if (key != null) { string str3 = (string)key.GetValue(string.Empty, null); key.Close(); if (str3 != null) { return(str3); } } } return(m_CompareTool); } return(stringPref); } } return("C:"); }
private bool actSendRequestFromWizard(bool bBreakRequest) { this.txtBuilderURL.Text = this.txtBuilderURL.Text.Trim(); if (!this.txtBuilderURL.Text.StartsWith("http", StringComparison.OrdinalIgnoreCase)) { if (this.txtBuilderURL.Text.Contains("://")) { MessageBox.Show("Only HTTP:// and HTTPS:// URLs are supported.\n\nInvalid URI: " + this.txtBuilderURL.Text, "Invalid URI"); return(false); } this.txtBuilderURL.Text = "http://" + this.txtBuilderURL.Text; } bool flag = this.txtBuilderURL.Text.Contains("#"); int result = 0; int num2 = 10; if (flag) { string s = string.Empty; string str = frmPrompt.GetUserString("Sequential Requests Starting At", "All instances of the # character will be replaced with a consecutive integer starting at: ", "0", true); if (str == null) { flag = false; } if (flag) { s = frmPrompt.GetUserString("Sequential Requests Ending At", "End at: ", "10", true); if (s == null) { flag = false; } } if (flag && (!int.TryParse(str, out result) || !int.TryParse(s, out num2))) { flag = false; } } try { StringBuilder builder; Label_0108: builder = new StringBuilder(0x400); string text = this.txtBuilderURL.Text; if (flag) { text = text.Replace("#", result.ToString()); } builder.AppendFormat("{0} {1} {2}\r\n", this.cbxBuilderMethod.Text, text, this.cbxBuilderHTTPVersion.Text); builder.Append(this.txtBuilderRequestHeaders.Text.Trim()); builder.Append("\r\n\r\n"); HTTPRequestHeaders oHeaders = Parser.ParseRequest(builder.ToString()); builder = null; byte[] bytes = Utilities.getEntityBodyEncoding(oHeaders, null).GetBytes(this.txtBuilderRequestBody.Text); string str4 = this.txtBuilderURL.Text; int index = str4.IndexOf("//", StringComparison.Ordinal); if (index > -1) { str4 = str4.Substring(index + 2); } int length = str4.IndexOfAny(new char[] { '/', '?' }); if (length > -1) { str4 = str4.Substring(0, length).ToLower(); } oHeaders["Host"] = str4; if (flag && oHeaders.ExistsAndContains("Host", "#")) { oHeaders["Host"] = oHeaders["Host"].Replace("#", result.ToString()); } if ((this.cbFixContentLength.Checked && (oHeaders.Exists("Content-Length") || (bytes.Length > 0))) && !oHeaders.ExistsAndContains("Transfer-Encoding", "chunked")) { oHeaders["Content-Length"] = bytes.Length.ToString(); } this.txtBuilderRequestHeaders.Text = oHeaders.ToString(false, false); Session session = new Session((HTTPRequestHeaders)oHeaders.Clone(), bytes); session.SetBitFlag(SessionFlags.RequestGeneratedByFiddler, true); session.oFlags["x-From-Builder"] = "true"; bool flag2 = this.cbSelectBuilderResult.Checked; if (bBreakRequest) { session.oFlags["x-breakrequest"] = "Builder"; flag2 = true; } if (flag) { if (session.oRequest.headers.ExistsAndContains("Referer", "#")) { session.oRequest["Referer"] = session.oRequest["Referer"].Replace("#", result.ToString()); } } else if (flag2) { session.oFlags["x-Builder-Inspect"] = "1"; } if (this.cbAutoAuthenticate.Checked) { session.oFlags["x-AutoAuth"] = "(default)"; } if (this.cbFollowRedirects.Checked) { session.oFlags["x-Builder-MaxRedir"] = FiddlerApplication.Prefs.GetInt32Pref("fiddler.requestbuilder.followredirects.max", 10).ToString(); } ThreadPool.UnsafeQueueUserWorkItem(new WaitCallback(session.Execute), null); if (flag && (result < num2)) { result++; goto Label_0108; } return(true); } catch (Exception exception) { FiddlerApplication.DoNotifyUser(exception.Message, "Custom Request Failed"); return(false); } }
static CONFIG() { try { IPGlobalProperties iPGlobalProperties = IPGlobalProperties.GetIPGlobalProperties(); string domainName = iPGlobalProperties.DomainName; IsMicrosoftMachine = !string.IsNullOrEmpty(domainName) && domainName.EndsWith("microsoft.com", StringComparison.OrdinalIgnoreCase); sMachineNameLowerCase = iPGlobalProperties.HostName.ToLower(); iPGlobalProperties = null; } catch (Exception) { IsMicrosoftMachine = false; } RegistryKey oReg = Registry.LocalMachine.OpenSubKey(GetRegPath("LMIsBeta")); if (oReg != null) { bIsBeta = Utilities.GetRegistryBool(oReg, "IsBeta", bIsBeta); bVersionCheckBlocked = Utilities.GetRegistryBool(oReg, "BlockUpdateCheck", bVersionCheckBlocked); if (Utilities.GetRegistryBool(oReg, "ForceViewerMode", false)) { bIsViewOnly = true; } if (bVersionCheckBlocked) { bVersionCheck = false; } oReg.Close(); } oReg = Registry.CurrentUser.OpenSubKey(sRootKey); if (oReg != null) { m_bForceExclusivePort = Utilities.GetRegistryBool(oReg, "ExclusivePort", m_bForceExclusivePort); bUseEventLogForExceptions = Utilities.GetRegistryBool(oReg, "UseEventLogForExceptions", bUseEventLogForExceptions); m_bCheckForISA = Utilities.GetRegistryBool(oReg, "CheckForISA", m_bCheckForISA); m_TextEditor = (string)oReg.GetValue("TextEditor", m_TextEditor); m_CompareTool = (string)oReg.GetValue("CompareTool", m_CompareTool); bBreakOnImages = Utilities.GetRegistryBool(oReg, "BreakOnImages", bBreakOnImages); sHostsThatBypassFiddler = (string)oReg.GetValue("FiddlerBypass", string.Empty); sGatewayUsername = (string)oReg.GetValue("GatewayUsername", sGatewayUsername); sGatewayPassword = (string)oReg.GetValue("GatewayPassword", sGatewayPassword); sMakeCertParamsRoot = (string)oReg.GetValue("MakeCertParamsRoot", sMakeCertParamsRoot); sMakeCertParamsEE = (string)oReg.GetValue("MakeCertParamsEE", sMakeCertParamsEE); sMakeCertRootCN = (string)oReg.GetValue("MakeCertRootCN", sMakeCertRootCN); sMakeCertSubjectO = (string)oReg.GetValue("MakeCertSubjectO", sMakeCertSubjectO); m_JSEditor = (string)oReg.GetValue("JSEditor", m_JSEditor); ListenPort = Utilities.GetRegistryInt(oReg, "ListenPort", m_ListenPort); bLoadScript = Utilities.GetRegistryBool(oReg, "LoadScript", bLoadScript); bLoadInspectors = Utilities.GetRegistryBool(oReg, "LoadInspectors", bLoadInspectors); bLoadExtensions = Utilities.GetRegistryBool(oReg, "LoadExtensions", bLoadExtensions); foreach (string str2 in Environment.GetCommandLineArgs()) { if (str2.IndexOf("port:", StringComparison.OrdinalIgnoreCase) > -1) { int result = 0; if (int.TryParse(str2.Substring(str2.IndexOf("port:", StringComparison.OrdinalIgnoreCase) + 5), NumberStyles.Integer, NumberFormatInfo.InvariantInfo, out result)) { ListenPort = result; bUsingPortOverride = true; } } else if (str2.IndexOf("quiet", StringComparison.OrdinalIgnoreCase) == 1) { bQuietMode = true; if (IsMicrosoftMachine) { FiddlerApplication.logSelfHost(110); } } else if (str2.IndexOf("extoff", StringComparison.OrdinalIgnoreCase) == 1) { bLoadExtensions = bLoadInspectors = false; } else if (str2.IndexOf("noscript", StringComparison.OrdinalIgnoreCase) == 1) { bLoadScript = false; } else if (str2.IndexOf("viewer", StringComparison.OrdinalIgnoreCase) == 1) { bIsViewOnly = true; } } iHotkeyMod = Utilities.GetRegistryInt(oReg, "HotkeyMod", iHotkeyMod); iHotkey = Utilities.GetRegistryInt(oReg, "Hotkey", iHotkey); flFontSize = Utilities.GetRegistryFloat(oReg, "FontSize", flFontSize); flFontSize = Math.Min(flFontSize, 24f); flFontSize = Math.Max(flFontSize, 4f); int argb = Utilities.GetRegistryInt(oReg, "colorDisabledEdit", -1); if (argb != -1) { colorDisabledEdit = System.Drawing.Color.FromArgb(argb); } bAttachOnBoot = Utilities.GetRegistryBool(oReg, "AttachOnBoot", bAttachOnBoot); iStartupCount = (uint)(1 + Utilities.GetRegistryInt(oReg, "StartupCount", 0)); bAutoLoadScript = Utilities.GetRegistryBool(oReg, "AutoReloadScript", bAutoLoadScript); m_bAllowRemoteConnections = Utilities.GetRegistryBool(oReg, "AllowRemote", m_bAllowRemoteConnections); bReuseServerSockets = Utilities.GetRegistryBool(oReg, "ReuseServerSockets", bReuseServerSockets); bReuseClientSockets = Utilities.GetRegistryBool(oReg, "ReuseClientSockets", bReuseClientSockets); bAutoProxyLogon = Utilities.GetRegistryBool(oReg, "AutoProxyLogon", bAutoProxyLogon); bDebugSpew = Utilities.GetRegistryBool(oReg, "DebugSpew", bDebugSpew); bReportHTTPErrors = Utilities.GetRegistryBool(oReg, "ReportHTTPErrors", bReportHTTPErrors); if (bDebugSpew) { FiddlerApplication.Log.LogString("Fiddler DebugSpew is enabled."); Trace.WriteLine("Fiddler DebugSpew is enabled."); } bHideOnMinimize = Utilities.GetRegistryBool(oReg, "HideOnMinimize", bHideOnMinimize); bAlwaysShowTrayIcon = Utilities.GetRegistryBool(oReg, "AlwaysShowTrayIcon", bAlwaysShowTrayIcon); bForwardToGateway = Utilities.GetRegistryBool(oReg, "UseGateway", bForwardToGateway); bEnableIPv6 = Utilities.GetRegistryBool(oReg, "EnableIPv6", bEnableIPv6); bCaptureCONNECT = Utilities.GetRegistryBool(oReg, "CaptureCONNECT", bCaptureCONNECT); bCaptureFTP = Utilities.GetRegistryBool(oReg, "CaptureFTP", bCaptureFTP); bMapSocketToProcess = Utilities.GetRegistryBool(oReg, "MapSocketToProcess", bMapSocketToProcess); bUseXceedDecompressForGZIP = Utilities.GetRegistryBool(oReg, "UseXceedDecompressForGZIP", bUseXceedDecompressForGZIP); bUseXceedDecompressForDeflate = Utilities.GetRegistryBool(oReg, "UseXceedDecompressForDeflate", bUseXceedDecompressForDeflate); bUseAESForSAZ = Utilities.GetRegistryBool(oReg, "UseAESForSAZ", bUseAESForSAZ); bStreamAudioVideo = Utilities.GetRegistryBool(oReg, "AutoStreamAudioVideo", bStreamAudioVideo); bShowDefaultClientCertificateNeededPrompt = Utilities.GetRegistryBool(oReg, "ShowDefaultClientCertificateNeededPrompt", bShowDefaultClientCertificateNeededPrompt); bMITM_HTTPS = Utilities.GetRegistryBool(oReg, "CaptureHTTPS", bMITM_HTTPS); bIgnoreServerCertErrors = Utilities.GetRegistryBool(oReg, "IgnoreServerCertErrors", bIgnoreServerCertErrors); iReverseProxyForPort = Utilities.GetRegistryInt(oReg, "ReverseProxyForPort", iReverseProxyForPort); sReverseProxyHostname = (string)oReg.GetValue("ReverseProxyHostname", sReverseProxyHostname); bVersionCheck = Utilities.GetRegistryBool(oReg, "CheckForUpdates", bVersionCheck); iShowProcessFilter = (ProcessFilterCategories)Utilities.GetRegistryInt(oReg, "ShowProcessFilter", (int)iShowProcessFilter); m_sAdditionalScriptReferences = (string)oReg.GetValue("ScriptReferences", string.Empty); sHookConnectionNamed = (string)oReg.GetValue("HookConnectionNamed", sHookConnectionNamed); bHookAllConnections = Utilities.GetRegistryBool(oReg, "HookAllConnections", bHookAllConnections); bHookWithPAC = Utilities.GetRegistryBool(oReg, "HookWithPAC", bHookWithPAC); if (oReg.GetValue("HeaderEncoding") != null) { try { oHeaderEncoding = Encoding.GetEncoding((string)oReg.GetValue("HeaderEncoding")); } catch (Exception exception) { FiddlerApplication.DoNotifyUser(exception.Message, "Invalid HeaderEncoding specified in registry"); oHeaderEncoding = Encoding.UTF8; } } sUserPath = (string)oReg.GetValue("UserPath", sUserPath); if (!sUserPath.EndsWith(Path.DirectorySeparatorChar.ToString())) { sUserPath = sUserPath + Path.DirectorySeparatorChar; } sScriptPath = (string)oReg.GetValue("ScriptFullPath", sUserPath + @"Scripts\CustomRules.js"); oReg.Close(); } if ((Environment.OSVersion.Version.Major < 6) && (Environment.OSVersion.Version.Minor < 1)) { bMapSocketToProcess = false; } }