/// <summary> /// Initializes a new instance of the <see cref="HttpInjectFile"/> class. /// /// </summary> /// <param name="plugin"></param> public HttpInjectFile(IPlugin plugin, InjectFileConfig injectFileConfig) { this.plugin = plugin; this.injectFileConfig = injectFileConfig; // Verifying plugin parameters if (plugin == null) { throw new Exception("Plugin configuration is invalid"); } if (plugin.Config == null) { throw new Exception("Plugin configuration is invalid"); } if (plugin.Config.PluginBaseDir == null) { throw new Exception("Plugin.Config.ApplicationBaseDir is invalid"); } }
public Plugin_HttpInjectFile(PluginProperties pluginProperties) { this.InitializeComponent(); // Textbox OnFocus/OnFocusLost custom implementations. this.tb_RequestedUrlRegex.GotFocus += this.TextBoxGotFocus; this.tb_RequestedUrlRegex.LostFocus += this.TextBoxLostFocus; this.tb_RequestedUrlRegex.Text = this.watermarkHttpRegex; this.tb_RequestedUrlRegex.ForeColor = System.Drawing.Color.LightGray; this.dgv_InjectionTriggerURLs.AutoGenerateColumns = false; DataGridViewTextBoxColumn columnRequestedHost = new DataGridViewTextBoxColumn(); columnRequestedHost.DataPropertyName = "RequestedHostRegex"; columnRequestedHost.Name = "RequestedHostRegex"; columnRequestedHost.HeaderText = "Requested host"; columnRequestedHost.ReadOnly = true; columnRequestedHost.Width = 200; this.dgv_InjectionTriggerURLs.Columns.Add(columnRequestedHost); DataGridViewTextBoxColumn columnRequestedPath = new DataGridViewTextBoxColumn(); columnRequestedPath.DataPropertyName = "RequestedPathRegex"; columnRequestedPath.Name = "RequestedPathRegex"; columnRequestedPath.HeaderText = "Requested path"; columnRequestedPath.ReadOnly = true; columnRequestedPath.Width = 200; this.dgv_InjectionTriggerURLs.Columns.Add(columnRequestedPath); DataGridViewTextBoxColumn columnReplacementResource = new DataGridViewTextBoxColumn(); columnReplacementResource.DataPropertyName = "ReplacementResource"; columnReplacementResource.Name = "ReplacementResource"; columnReplacementResource.HeaderText = "Replacement resource"; columnReplacementResource.ReadOnly = true; columnReplacementResource.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; this.dgv_InjectionTriggerURLs.Columns.Add(columnReplacementResource); this.injectFileRecords = new BindingList <InjectFileRecord>(); this.dgv_InjectionTriggerURLs.DataSource = this.injectFileRecords; // Verify passed parameter(s) if (pluginProperties == null) { throw new Exception("Parameter PluginParameters is null"); } if (pluginProperties.HostApplication == null) { throw new Exception("Parameter HostApplication is null"); } if (pluginProperties.ApplicationBaseDir == null) { throw new Exception("Parameter ApplicationBaseDir is null"); } if (pluginProperties.PluginBaseDir == null) { throw new Exception("Parameter PluginBaseDir is null"); } // Plugin configuration this.pluginProperties = pluginProperties; this.pluginProperties.PluginName = "HTTP inject file"; this.pluginProperties.PluginType = "Intrusive"; this.pluginProperties.AttackServiceDependency = "HttpsReverseProxy"; this.pluginProperties.PluginDescription = "Answer an HTTP request by injecting a custom replacement file"; this.pluginProperties.Ports = new Dictionary <int, IpProtocols>(); // Set inject file config file path this.injectFileConfigFilePath = Path.Combine(this.pluginProperties.HostApplication.HostWorkingDirectory, @"attackservices\HttpReverseProxy\plugins\injectfile\plugin.config"); this.injectFileConfig = new InjectFileConfig() { InjectFileConfigFilePath = this.injectFileConfigFilePath, IsDebuggingOn = this.Config.HostApplication.IsDebuggingOn, BasisDirectory = this.Config.PluginBaseDir }; // Instantiate infrastructureLayer layer this.infrastructureLayer = new InjectFile.Infrastructure.HttpInjectFile(this, this.injectFileConfig); }