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)); }
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"); } }
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"); } }
internal void DoOnLoad() { foreach (IFiddlerExtension extension in this.m_Extensions.Values) { try { extension.OnLoad(); continue; } catch (Exception exception) { FiddlerApplication.LogAddonException(exception, "Extension threw during OnLoad"); continue; } } }
public void Dispose() { foreach (IFiddlerExtension extension in this.m_Extensions.Values) { try { extension.OnBeforeUnload(); continue; } catch (Exception exception) { FiddlerApplication.LogAddonException(exception, "Extension threw during OnBeforeUnload"); continue; } } this.m_AutoFiddlers.Clear(); this.m_Extensions.Clear(); }
public static Session[] DoImport(string sImportFormat, bool bAddToSessionList, Dictionary <string, object> dictOptions, EventHandler <ProgressCallbackEventArgs> ehPCEA) { if (string.IsNullOrEmpty(sImportFormat)) { return(null); } TranscoderTuple importer = FiddlerApplication.oTranscoders.GetImporter(sImportFormat); if (importer == null) { return(null); } Session[] array; try { ISessionImporter sessionImporter = (ISessionImporter)Activator.CreateInstance(importer.typeFormatter); if (ehPCEA == null) { ehPCEA = delegate(object sender, ProgressCallbackEventArgs e) { string text = (e.PercentComplete > 0) ? ("Import is " + e.PercentComplete + "% complete; ") : string.Empty; FiddlerApplication.Log.LogFormat("{0}{1}", new object[] { text, e.ProgressText }); Application.DoEvents(); }; } array = sessionImporter.ImportSessions(sImportFormat, dictOptions, ehPCEA); sessionImporter.Dispose(); if (array == null) { return(null); } } catch (Exception eX) { FiddlerApplication.LogAddonException(eX, "Importer for " + sImportFormat + " failed."); array = null; } return(array); }
public static bool DoExport(string sExportFormat, Session[] oSessions, Dictionary <string, object> dictOptions, EventHandler <ProgressCallbackEventArgs> ehPCEA) { if (string.IsNullOrEmpty(sExportFormat)) { return(false); } TranscoderTuple exporter = FiddlerApplication.oTranscoders.GetExporter(sExportFormat); if (exporter == null) { FiddlerApplication.Log.LogFormat("No exporter for the format '{0}' was available.", new object[] { sExportFormat }); return(false); } bool result = false; try { ISessionExporter sessionExporter = (ISessionExporter)Activator.CreateInstance(exporter.typeFormatter); if (ehPCEA == null) { ehPCEA = delegate(object sender, ProgressCallbackEventArgs e) { string text = (e.PercentComplete > 0) ? ("Export is " + e.PercentComplete + "% complete; ") : string.Empty; FiddlerApplication.Log.LogFormat("{0}{1}", new object[] { text, e.ProgressText }); }; } result = sessionExporter.ExportSessions(sExportFormat, oSessions, dictOptions, ehPCEA); sessionExporter.Dispose(); } catch (Exception eX) { FiddlerApplication.LogAddonException(eX, "Exporter for " + sExportFormat + " failed."); result = false; } return(result); }
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 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 void ScanPathForExtensions(string sPath) { try { 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 FiddlerExtensions 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 FiddlerExtensions 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_024A; } try { if (Utilities.FiddlerMeetsVersionRequirement(assembly, "FiddlerExtensions")) { foreach (Type type in assembly.GetExportedTypes()) { if (((!type.IsAbstract && type.IsPublic) && (type.IsClass && typeof(IFiddlerExtension).IsAssignableFrom(type))) && !this.m_Extensions.ContainsKey(type.GUID)) { try { IFiddlerExtension extension = (IFiddlerExtension)Activator.CreateInstance(type); this.m_Extensions.Add(type.GUID, extension); if (extension is IAutoTamper) { this.m_AutoFiddlers.Add(extension as IAutoTamper); } } catch (Exception exception2) { FiddlerApplication.DoNotifyUser(string.Format("[Fiddler] Failure loading {0} FiddlerExtensions from {1}: {2}\n\n{3}\n\n{4}", new object[] { type.Name, info.FullName.ToString(), exception2.Message, exception2.StackTrace, exception2.InnerException }), "Extension Load Error"); } } } } } catch (Exception exception3) { FiddlerApplication.DoNotifyUser(string.Format("[Fiddler] Failure loading FiddlerExtensions from {0}: {1}", info.FullName.ToString(), exception3.Message), "Extension Load Error"); } Label_024A :; } } } catch (Exception exception4) { FiddlerApplication.DoNotifyUser(string.Format("[Fiddler] Failure loading FiddlerExtensions: {0}", exception4.Message), "Extension Load Error"); } }