X-Git-Url: http://git.ipfire.org/?p=people%2Fpmueller%2Fipfire-2.x.git;a=blobdiff_plain;f=html%2Fcgi-bin%2Fids.cgi;h=d9082979dcc94bea2d4f9780fff2345a089992fc;hp=111aea66796182b0b7b95d283e8c4ffacf92a162;hb=32810952ccb7190822848f75b4c417f6e1b9ad5f;hpb=6e9654de9bc100ce6720a492ca4baca119e8958b diff --git a/html/cgi-bin/ids.cgi b/html/cgi-bin/ids.cgi index 111aea6679..d9082979dc 100644 --- a/html/cgi-bin/ids.cgi +++ b/html/cgi-bin/ids.cgi @@ -26,8 +26,8 @@ use File::Temp qw/ tempfile tempdir /; use strict; # enable only the following on debugging purpose -#use warnings; -#use CGI::Carp 'fatalsToBrowser'; +use warnings; +use CGI::Carp 'fatalsToBrowser'; require '/var/ipfire/general-functions.pl'; require "${General::swroot}/lang.pl"; @@ -43,8 +43,6 @@ my %checked=(); my %selected=(); my %netsettings=(); our $errormessage = ''; -our $md5 = '0';# not '' to avoid displaying the wrong message when INSTALLMD5 not set -our $realmd5 = ''; our $results = ''; our $tempdir = ''; our $url=''; @@ -56,7 +54,6 @@ $snortsettings{'ENABLE_SNORT'} = 'off'; $snortsettings{'ENABLE_SNORT_GREEN'} = 'off'; $snortsettings{'ENABLE_SNORT_BLUE'} = 'off'; $snortsettings{'ENABLE_SNORT_ORANGE'} = 'off'; -$snortsettings{'ENABLE_PREPROCESSOR_HTTP_INSPECT'} = 'off'; $snortsettings{'ENABLE_GUARDIAN'} = 'off'; $snortsettings{'GUARDIAN_INTERFACE'} = `cat /var/ipfire/red/iface`; $snortsettings{'GUARDIAN_HOSTGATEWAYBYTE'} = '1'; @@ -65,13 +62,11 @@ $snortsettings{'GUARDIAN_ALERTFILE'} = '/var/log/snort/alert'; $snortsettings{'GUARDIAN_IGNOREFILE'} = '/var/ipfire/guardian/guardian.ignore'; $snortsettings{'GUARDIAN_TARGETFILE'} = '/var/ipfire/guardian/guardian.target'; $snortsettings{'GUARDIAN_TIMELIMIT'} = '86400'; -$snortsettings{'GUARDIAN_IGNOREFILE_CONTENT'} = `cat $snortsettings{'GUARDIAN_IGNOREFILE'}`; $snortsettings{'ACTION'} = ''; $snortsettings{'ACTION2'} = ''; $snortsettings{'RULES'} = ''; $snortsettings{'OINKCODE'} = ''; $snortsettings{'INSTALLDATE'} = ''; -$snortsettings{'INSTALLMD5'} = ''; &Header::getcgihash(\%snortsettings, {'wantfile' => 1, 'filevar' => 'FH'}); @@ -106,23 +101,12 @@ if (-e "/etc/snort/snort.conf") { if ( $temp =~ /$_/ ){next;} else { push(@snortconfig,"#include \$RULE_PATH/".$_);} } - + # Loop over each line foreach my $line (@snortconfig) { # Trim the line chomp $line; - if ($snortsettings{'ACTION'} eq $Lang::tr{'save'}) { - # Check for preprocessor settings - if ($line =~ /preprocessor http_inspect/) { - # Strip out leading # from rule line - $line =~ s/\# ?//i; - if (($snortsettings{'ENABLE_PREPROCESSOR_HTTP_INSPECT'} eq 'off')) { - $line = "# $line"; - } - } - } - # Check for a line with .rules if ($line =~ /\.rules$/) { # Parse out rule file name @@ -238,7 +222,7 @@ if (-e "/etc/snort/snort.conf") { if (!exists $snortsettings{"SNORT_RULE_$rule"}) { $line = "# $line"; } - + } # Check for rule state @@ -276,9 +260,13 @@ if (-e "/etc/snort/snort.conf") { ####################### End added for snort rules control ################################# if ($snortsettings{'RULES'} eq 'subscripted') { - $url="http://www.snort.org/pub-bin/oinkmaster.cgi/$snortsettings{'OINKCODE'}/snortrules-snapshot-2.6_s.tar.gz"; + #$url="http://dl.snort.org/sub-rules/snortrules-snapshot-2.8_s.tar.gz?oink_code=$snortsettings{'OINKCODE'}"; + $url="http://dl.snort.org/sub-rules/snortrules-snapshot-2853_s.tar.gz?oink_code=$snortsettings{'OINKCODE'}"; + #$url="http://www.snort.org/pub-bin/oinkmaster.cgi/$snortsettings{'OINKCODE'}/snortrules-snapshot-2.8_s.tar.gz"; } elsif ($snortsettings{'RULES'} eq 'registered') { - $url="http://www.snort.org/pub-bin/oinkmaster.cgi/$snortsettings{'OINKCODE'}/snortrules-snapshot-2.6.tar.gz"; + $url="http://dl.snort.org/reg-rules/snortrules-snapshot-2.8.tar.gz?oink_code=$snortsettings{'OINKCODE'}"; + #$url="http://dl.snort.org/reg-rules/snortrules-snapshot-2853.tar.gz?oink_code=$snortsettings{'OINKCODE'}"; + #$url="http://www.snort.org/pub-bin/oinkmaster.cgi/$snortsettings{'OINKCODE'}/snortrules-snapshot-2.8.tar.gz"; } else { $url="http://www.snort.org/pub-bin/downloads.cgi/Download/comm_rules/Community-Rules-CURRENT.tar.gz"; } @@ -295,19 +283,19 @@ if ($snortsettings{'ACTION'} eq $Lang::tr{'save'} && $snortsettings{'ACTION2'} e system ('/usr/bin/touch', "${General::swroot}/snort/enable"); } else { unlink "${General::swroot}/snort/enable"; - } + } if ($snortsettings{'ENABLE_SNORT_GREEN'} eq 'on') { system ('/usr/bin/touch', "${General::swroot}/snort/enable_green"); } else { unlink "${General::swroot}/snort/enable_green"; - } + } if ($snortsettings{'ENABLE_SNORT_BLUE'} eq 'on') { system ('/usr/bin/touch', "${General::swroot}/snort/enable_blue"); } else { unlink "${General::swroot}/snort/enable_blue"; - } + } if ($snortsettings{'ENABLE_SNORT_ORANGE'} eq 'on') { system ('/usr/bin/touch', "${General::swroot}/snort/enable_orange"); @@ -319,7 +307,7 @@ if ($snortsettings{'ACTION'} eq $Lang::tr{'save'} && $snortsettings{'ACTION2'} e system ('/usr/bin/touch', "${General::swroot}/snort/enable_preprocessor_http_inspect"); } else { unlink "${General::swroot}/snort/enable_preprocessor_http_inspect"; - } + } if ($snortsettings{'ENABLE_GUARDIAN'} eq 'on') { system ('/usr/bin/touch', "${General::swroot}/guardian/enable"); @@ -331,7 +319,7 @@ if ($snortsettings{'ACTION'} eq $Lang::tr{'save'} && $snortsettings{'ACTION2'} e } elsif ($snortsettings{'ACTION'} eq $Lang::tr{'save'} && $snortsettings{'ACTION2'} eq "guardian" ){ open(IGNOREFILE, ">$snortsettings{'GUARDIAN_IGNOREFILE'}") or die "Unable to write guardian ignore file $snortsettings{'GUARDIAN_IGNOREFILE'}"; - print IGNOREFILE $snortsettings{'GUARDIAN_IGNOREFILE_CONTENT'}; + print IGNOREFILE $snortsettings{'IGNOREFILE_CONTENT'}; close(IGNOREFILE); open(GUARDIAN, ">/var/ipfire/guardian/guardian.conf") or die "Unable to write guardian conf /var/ipfire/guardian/guardian.conf"; print GUARDIAN <&1`; - $results .= ""; + my $filename = &downloadrulesfile(); + if (defined $filename) { + $results = "$Lang::tr{'installed updates'}\n
";
+						$results .=`/usr/local/bin/oinkmaster.pl -s -u file://$filename -C /var/ipfire/snort/oinkmaster.conf -o /etc/snort/rules 2>&1`;
+						$results .= "
"; + } + unlink ($filename); } - unlink ($filename); + } } + + } $checked{'ENABLE_SNORT'}{'off'} = ''; @@ -384,9 +377,6 @@ $checked{'ENABLE_SNORT_BLUE'}{$snortsettings{'ENABLE_SNORT_BLUE'}} = "checked='c $checked{'ENABLE_SNORT_ORANGE'}{'off'} = ''; $checked{'ENABLE_SNORT_ORANGE'}{'on'} = ''; $checked{'ENABLE_SNORT_ORANGE'}{$snortsettings{'ENABLE_SNORT_ORANGE'}} = "checked='checked'"; -$checked{'ENABLE_PREPROCESSOR_HTTP_INSPECT'}{'off'} = ''; -$checked{'ENABLE_PREPROCESSOR_HTTP_INSPECT'}{'on'} = ''; -$checked{'ENABLE_PREPROCESSOR_HTTP_INSPECT'}{$snortsettings{'ENABLE_PREPROCESSOR_HTTP_INSPECT'}} = "checked='checked'"; $checked{'ENABLE_GUARDIAN'}{'off'} = ''; $checked{'ENABLE_GUARDIAN'}{'on'} = ''; $checked{'ENABLE_GUARDIAN'}{$snortsettings{'ENABLE_GUARDIAN'}} = "checked='checked'"; @@ -401,7 +391,7 @@ $selected{'RULES'}{$snortsettings{'RULES'}} = "selected='selected'"; ####################### Added for snort rules control ################################# print ""; print < +