From 1286e0d41e75dd691a54ac130ae6d70bfc284e14 Mon Sep 17 00:00:00 2001 From: Stefan Schantl Date: Sun, 5 Aug 2018 12:57:44 +0200 Subject: [PATCH] ids.cgi: Rework section to configure the IDS Signed-off-by: Stefan Schantl --- html/cgi-bin/ids.cgi | 92 +++++++++++++++++++++++------------------- langs/de/cgi-bin/de.pl | 4 ++ langs/en/cgi-bin/en.pl | 4 ++ 3 files changed, 59 insertions(+), 41 deletions(-) diff --git a/html/cgi-bin/ids.cgi b/html/cgi-bin/ids.cgi index 4d7552d26e..0dce9e994d 100644 --- a/html/cgi-bin/ids.cgi +++ b/html/cgi-bin/ids.cgi @@ -32,9 +32,8 @@ require "${General::swroot}/ids-functions.pl"; my %color = (); my %mainsettings = (); -my %netsettings = (); my %idsrules = (); -my %snortsettings=(); +my %idssettings=(); my %rulesetsources = (); my %cgiparams=(); my %checked=(); @@ -44,22 +43,15 @@ my %selected=(); &General::readhash("${General::swroot}/main/settings", \%mainsettings); &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color); -# Get netsettings. -&General::readhash("${General::swroot}/ethernet/settings", \%netsettings); +# Get the available network zones, based on the config type of the system and store +# the list of zones in an array. +my @network_zones = &IDS::get_available_network_zones(); my $idsusedrulefilesfile = "$IDS::settingsdir/suricata-used-rulefiles.yaml"; my $errormessage; &Header::showhttpheaders(); -# Default settings for snort. -$snortsettings{'ENABLE_SNORT'} = 'off'; -$snortsettings{'ENABLE_SNORT_GREEN'} = 'off'; -$snortsettings{'ENABLE_SNORT_BLUE'} = 'off'; -$snortsettings{'ENABLE_SNORT_ORANGE'} = 'off'; -$snortsettings{'RULES'} = ''; -$snortsettings{'OINKCODE'} = ''; - #Get GUI values &Header::getcgihash(\%cgiparams); @@ -319,27 +311,18 @@ if ($cgiparams{'RULESET'} eq $Lang::tr{'update'}) { } } -# Read-in snortsettings -&General::readhash("$IDS::settingsdir/settings", \%snortsettings); - -$checked{'ENABLE_SNORT'}{'off'} = ''; -$checked{'ENABLE_SNORT'}{'on'} = ''; -$checked{'ENABLE_SNORT'}{$snortsettings{'ENABLE_SNORT'}} = "checked='checked'"; -$checked{'ENABLE_SNORT_GREEN'}{'off'} = ''; -$checked{'ENABLE_SNORT_GREEN'}{'on'} = ''; -$checked{'ENABLE_SNORT_GREEN'}{$snortsettings{'ENABLE_SNORT_GREEN'}} = "checked='checked'"; -$checked{'ENABLE_SNORT_BLUE'}{'off'} = ''; -$checked{'ENABLE_SNORT_BLUE'}{'on'} = ''; -$checked{'ENABLE_SNORT_BLUE'}{$snortsettings{'ENABLE_SNORT_BLUE'}} = "checked='checked'"; -$checked{'ENABLE_SNORT_ORANGE'}{'off'} = ''; -$checked{'ENABLE_SNORT_ORANGE'}{'on'} = ''; -$checked{'ENABLE_SNORT_ORANGE'}{$snortsettings{'ENABLE_SNORT_ORANGE'}} = "checked='checked'"; +# Read-in idssettings +&General::readhash("$IDS::settingsdir/settings", \%idssettings); + +$checked{'ENABLE_IDS'}{'off'} = ''; +$checked{'ENABLE_IDS'}{'on'} = ''; +$checked{'ENABLE_IDS'}{$idssettings{'ENABLE_IDS'}} = "checked='checked'"; $selected{'RULES'}{'nothing'} = ''; $selected{'RULES'}{'community'} = ''; $selected{'RULES'}{'emerging'} = ''; $selected{'RULES'}{'registered'} = ''; $selected{'RULES'}{'subscripted'} = ''; -$selected{'RULES'}{$snortsettings{'RULES'}} = "selected='selected'"; +$selected{'RULES'}{$idssettings{'RULES'}} = "selected='selected'"; &Header::openpage($Lang::tr{'intrusion detection system'}, 1, ''); @@ -382,33 +365,60 @@ print < - RED Snort + $Lang::tr{'ids activate'} $Lang::tr{'intrusion detection system'} + + + +   + + + +

+ + - GREEN Snort + $Lang::tr{'ids analyze incomming traffic'} + $Lang::tr{'ids analyze routing traffic'} + + END ; -# Check if a blue device is configured. -if ($netsettings{'BLUE_DEV'}) { - print "BLUE Snort\n"; -} +# Loop through the array of available networks and print config options. +foreach my $zone (@network_zones) { + my $checked_input; + my $checked_forward; -print "\n"; + # Convert current zone name to upper case. + my $zone_upper = uc($zone); -print "\n"; + # Grab checkbox status from settings hash. + if ($idssettings{"ENABLE_IDS_INPUT_$zone_upper"} eq "on") { + $checked_input = "checked = 'checked'"; + } -# Check if an orange device is configured. -if ($netsettings{'ORANGE_DEV'}) { - print "ORANGE Snort\n"; + # Do the same for the forward setting. + if ($idssettings{"ENABLE_IDS_FORWARD_$zone_upper"} eq "on") { + $checked_forward = "checked = 'checked'"; + } + + print "\n"; + print "\n"; + print "$Lang::tr{'ids active on'} $Lang::tr{$zone}\n"; + print "\n"; + + print "\n"; + print "$Lang::tr{'ids active on'} $Lang::tr{$zone}\n"; + print "\n"; + print "\n"; } print < @@ -438,7 +448,7 @@ print < - Oinkcode:  + Oinkcode:  diff --git a/langs/de/cgi-bin/de.pl b/langs/de/cgi-bin/de.pl index 6e3dba4dba..53d3141c2f 100644 --- a/langs/de/cgi-bin/de.pl +++ b/langs/de/cgi-bin/de.pl @@ -1323,6 +1323,10 @@ 'idle' => 'Leerlauf', 'idle timeout' => 'Leerlauf-Wartezeit in Min. (0 zum Deaktivieren):', 'idle timeout not set' => 'Leerlauf-Wartezeit nicht angegeben.', +'ids activate' => 'Aktiviere', +'ids analyze incomming traffic' => 'Analysiere eingehende (INPUT) Packete', +'ids analyze routing traffic' => 'Analysiere zu routende (FORWARD) Packete', +'ids active on' => 'Aktiv auf', 'ids log viewer' => 'Ansicht IDS-Protokoll', 'ids logs' => 'IDS-Protokolldateien', 'ids preprocessor' => 'IDS-Präprozessor', diff --git a/langs/en/cgi-bin/en.pl b/langs/en/cgi-bin/en.pl index 3ec5af57e0..e6fd9b18b3 100644 --- a/langs/en/cgi-bin/en.pl +++ b/langs/en/cgi-bin/en.pl @@ -1353,6 +1353,10 @@ 'idle' => 'Idle', 'idle timeout' => 'Idle timeout (mins; 0 to disable):', 'idle timeout not set' => 'Idle timeout not set.', +'ids activate' => 'Activate', +'ids analyze incomming traffic' => 'Analyze incomming (INPUT) traffic', +'ids analyze routing traffic' => 'Analyze to-route (FORWARD) traffic', +'ids active on' => 'Active on', 'ids log viewer' => 'IDS log viewer', 'ids logs' => 'IDS Logs', 'ids preprocessor' => 'IDS preprocessor', -- 2.39.2