my $checkboxname = '';
if (-e "/etc/snort/snort.conf") {
+
+
# Open snort.conf file, read it in, close it, and re-open for writing
open(FILE, "/etc/snort/snort.conf") or die 'Unable to read snort config file.';
@snortconfig = <FILE>;
close(FILE);
open(FILE, ">/etc/snort/snort.conf") or die 'Unable to write snort config file.';
+ my @rules = `cd /etc/snort/rules/ && ls *.rules`; # With this loop the rule might be display with correct rulepath set
+ foreach (@rules) {
+ chomp $_;
+ my $temp = join(";",@snortconfig);
+ if ( $temp =~ /$_/ ){next;}
+ else { push(@snortconfig,"#include \$RULE_PATH/".$_);}
+ }
+
# Loop over each line
foreach my $line (@snortconfig) {
# Trim the line
chomp $line;
- # my @rules = `ls $snortrulepath`; With this loop the rule might be display with correct rulepath set
- # foreach my $line (@rules) {
- # # Trim the line
- # chomp $line;
-
# Check for a line with .rules
if ($line =~ /\.rules$/) {
# Parse out rule file name
if ($ruledisplaycnt > $rulecnt) {
print "</TABLE></TD><TD VALIGN='TOP'><TABLE>";
$ruledisplaycnt = 0;
- }
+ }
# Check if rule file is enabled
if ($snortrules{$rulefile}{"State"} eq 'Enabled') {
}
# Create rule file link, vars array, and display flag
- my $rulefilelink = "?RULEFILE=$rulefile";
+ my $rulefilelink = "?RULEFILE=$rulefile";
my $rulefiletoclose = '';
my @queryvars = ();
my $displayrulefilerules = 0;
# Check for passed in query string
if ($ENV{'QUERY_STRING'}) {
# Split out vars
- @queryvars = split(/\&/, $ENV{'QUERY_STRING'});
+ @queryvars = split(/\&/, $ENV{'QUERY_STRING'});
# Loop over values
foreach $value (@queryvars) {
# Split out var pairs
- ($var, $linkedrulefile) = split(/=/, $value);
+ ($var, $linkedrulefile) = split(/=/, $value);
# Check if var is 'RULEFILE'
if ($var eq 'RULEFILE') {
}
}
}
+
# Strip out extra & & ? from rulefilelink
$rulefilelink =~ s/^\?\&/\?/i;
# Close display table
print "</TR></TABLE></TD></TR>";
- }
+ }
# Close display table
print "</TABLE>";
# Increment ruledisplaycnt
- $ruledisplaycnt++;
+ $ruledisplaycnt++;
}
-
print "</TD></TR></TABLE></TD></TR></TABLE>";
print <<END
- <table width='100%'>
- <tr>
+<table width='100%'>
+<tr>
<td width='33%'> </td>
<td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'update'}' /></td>
<td width='33%'>
<!-- space for future online help link -->
</td>
- </tr>
- </table>
- </form>
+</tr>
+</table>
+</form>
END
;
&Header::closebox();