IDS: Dynamically generate and import the HTTP ports.

With this commit suricata reads the HTTP port declarations from a newly
introduced external file
(/var/ipfire/suricata/suricata-http-ports.yaml).

This file dynamically will be generated. HTTP ports always are the
default port "80" and "81" for update Accelerator and HTTP access to the
WUI. In case the Web-proxy is used, the configured proxy port and/or Transparent
Proxy port also will be declared as a HTTP port and written to that file.

In case one of the proxy ports will be changed, the HTTP port file will
be re-generated and suricate restarted if launched. Also if an old
backup with snort will be restored the convert script handles the
generation of the HTTP ports file.

Finally the suricata-generate-http-ports-file as a tiny script which
simply generates the http ports file and needs to be launched during the
installation of a core update. (The script will no be required
anymore, so it could be deleted afterwards.)

Fixes #12308.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
This commit is contained in:
Stefan Schantl
2020-04-03 16:25:01 +02:00
committed by Arne Fitzenreiter
parent 6084e66e70
commit e698090e7f
6 changed files with 154 additions and 7 deletions

View File

@@ -2,7 +2,7 @@
###############################################################################
# #
# IPFire.org - A linux based firewall #
# Copyright (C) 2019 IPFire Development Team <info@ipfire.org> #
# Copyright (C) 2020 IPFire Development Team <info@ipfire.org> #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
@@ -298,7 +298,17 @@ if (-f $IDS::rulestarball) {
&IDS::set_ownership("$IDS::dns_servers_file");
#
## Step 11: Setup automatic ruleset updates.
## Step 11: Generate file which contains the HTTP ports.
#
# Call subfunction to generate the file.
&IDS::generate_http_ports_file();
# Set correct ownership for the http_ports_file.
&IDS::set_ownership("$IDS::http_ports_file");
#
## Step 12: Setup automatic ruleset updates.
#
# Check if a ruleset is configured.
@@ -308,7 +318,7 @@ if($rulessettings{"RULES"}) {
}
#
## Step 12: Grab used ruleset files from snort config file and convert
## Step 13: Grab used ruleset files from snort config file and convert
## them into the new format.
#
@@ -354,7 +364,7 @@ close(SNORTCONF);
&IDS::write_used_rulefiles_file(@enabled_rule_files);
#
## Step 13: Start the IDS if enabled.
## Step 14: Start the IDS if enabled.
#
# Check if the IDS should be started.

View File

@@ -0,0 +1,47 @@
#!/usr/bin/perl
###############################################################################
# #
# IPFire.org - A linux based firewall #
# Copyright (C) 2012 IPFire Development Team <info@ipfire.org> #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
###############################################################################
use strict;
require '/var/ipfire/general-functions.pl';
require "${General::swroot}/ids-functions.pl";
exit unless(-f $IDS::ids_settings_file and -f $IDS::rules_settings_file);
#
## Step 1: Generate and write the HTTP ports file.
#
# Call subfunction to generate the HTTP ports file.
&IDS::generate_http_ports_file();
# Set correct ownership.
&IDS::set_ownership("$IDS::http_ports_file");
#
## Step 2: Restart suricata if necessary.
#
# Check if the IDS should be started.
if(&IDS::ids_is_running()) {
# Call suricatactrl and reload the rules.
&IDS::call_suricatactrl("restart");
}

View File

@@ -30,7 +30,9 @@ vars:
ENIP_SERVER: "$HOME_NET"
port-groups:
HTTP_PORTS: "[80,81]"
# Incluse HTTP_PORTS declaration from external file.
include: /var/ipfire/suricata/suricata-http-ports.yaml
SHELLCODE_PORTS: "!80"
ORACLE_PORTS: 1521
SSH_PORTS: "[22,222]"