snort/0040755000000000000000000000000007334572145010737 5ustar rootrootsnort/index.cgi0100755000000000000000000001620407334572145012535 0ustar rootroot#!/usr/bin/perl # # Snort Webmin Module # # Copyright (C) 2001 Mike Baptiste/MSB Networks # mike@msbnetworks.com # http://msbnetworks.com/snort/ # # 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 2 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, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Do common initialization and get common routines # Note this also does the acl acess lookup require 'snort-lib.pl'; # Lets check and make sure the module was configured with defaults during installation, # or that settings have been previously saved, otherwise, lets dump them to the config screen ($snort_bin) = $config{'snort_path'} =~ /^(\S+)/; # Strip any options - note this will choke if there are spaces in path! if ((! -r $snort_bin) || (! -r $config{'snort_config'}) || (! -d $config{'snort_rules_path'})) { # Check if they can change config first! if ($access{'noconfig'}) { $whatfailed = $text{'error_confchk'}; &snort_error($text{'error_config'}); } else { &redirect("/config.cgi?snort"); # Redirect user to config section exit; } } # Send the header &header($text{'index_title'}, "", undef, 1, 1, 0, &help_search_link("snort", "man", "doc", "google")); print "
\n"; # Display icons for global options if user can modify them if ($access{'net'} || $access{'pp'} || $access{'out'} || $access{'text'}) { print "

$text{'index_opts'}

\n"; push(@olinks, "conf_net.cgi") if $access{'net'}; push(@olinks, "conf_preproc.cgi") if $access{'pp'}; push(@olinks, "conf_output.cgi") if $access{'out'}; push(@olinks, "conf_text.cgi") if $access{'text'}; @otitles = map { /conf_(\S+).cgi/; $text{$1."_title"} } @olinks; @oicons = map { /^conf_(\S+).cgi/; "images/$1.gif"; } @olinks; # Lets toss in an ACID link if they use it if ($config{'acid_url'}) { push(@olinks, $config{'acid_url'}); push(@otitles, "Goto ACID"); push(@oicons, "images/acid.png"); } &icons_table(\@olinks, \@otitles, \@oicons); print "
\n"; } # Scan the configuration file for rule sets $sconf = read_file_lines($config{'snort_config'}); @rulefiles = grep(/\w+\.rules/, @$sconf); # Display rules if they can modify them print "

$text{'index_rules'}\n"; print "
\"$text{'index_enabled'}\" = $text{'index_enabled'}  \"$text{'index_disabled'}\" = $text{'index_disabled'}\n"; print "
$text{'index_rule_msg'}" if ($access{'rules'} ne "*"); foreach $ruleset (@rulefiles) { ($rule) = $ruleset =~ /[#]*(\S+)\.rules/; # Check to see if user can access a given ruleset if ($access{'rules'} ne "*") { if ($access{'rules'} =~ /^\!/) { # The access array is all EXCEPT selected next if ($access{'rules'} =~ /\b$rule\b/); } else { next if ($access{'rules'} !~ /\b$rule\b/); } } # If the ruleset is commented out - its disabled if ($access{'ruleview'} || $access{'ruleedit'} || $access{'ruleadd'} || $access{'ruledel'}) { $rulerow{$rule} = "$rule"; } else { $rulerow{$rule} = "$rule"; } if ($ruleset =~ /^#/) { # The ruleset is disabled $rulerow{$rule} .= "\"$text{'index_disabled'}\""; $rulerow{$rule} .= "$text{'index_enable'}" if $access{'ruletog'}; } else { $rulerow{$rule} .= "\"$text{'index_enabled'}\""; $rulerow{$rule} .= "$text{'index_disable'}" if $access{'ruletog'}; } } # Now we output the rules in the columns # # NOTE - There may be a MUCH more elegant way of doing this. I spent WAY too much time # thinking about this and trying to get this table pretty and printing properly across # three columns. If you have ideas for improvement, pass them on! # # The trick is keeping the list in alphabetical order reading down one column at a time # Make sure that the code can handle < 3 rulesets @ruleidx = sort keys %rulerow; $numitems = @ruleidx; if ($numitems > 0) { if ($numitems >= 3) { $numcols = 3 } else { $numcols = $numitems } $limit = int($numitems/$numcols); $extra = $numitems - ($numcols * $limit); # How many items will be in bottom row # Lets display the rulesets in 3 columns of 3 columns each # We need to make sure we only display headers if we have enough rules to display print "

\n"; for ($i=1; $i <= $numcols; $i++) { print ""; print "" if $access{'ruletog'}; print "\n" if ($i < $numcols); } print "\n"; # Now lets output the data for ($i=0; $i <= $limit; $i++) { next if ((!$extra) && ($i == $limit)); # Skip bottom extra row if necessary print ""; # For the last row, we do something special $offset = 0; for ($j=$i; $j < $numitems; $j+=$limit) { # On the last row ($i = $limit) only loop $extra times next if (($extra <= $offset) && ($i == $limit)); print "" if $offset; print $rulerow{$ruleidx[$j]}; $j++ if ($extra > $offset++); # Tweak index value in non perfect tables } print "\n"; } print "
$text{'index_rule_hdr1'}$text{'index_rule_hdr2'}$text{'index_rule_hdr3'} 
 
\n"; } # if ($numitems > 0) print "

\n
\n"; # Lets see if snort is already running or not if ($access{'apply'}) { if (open(PID, $config{'snort_pid'})) { chop($pid = ); close(PID); } print "
\n"; if ($pid && kill(0, $pid)) { print "$text{'index_apply_info'}

\n"; print "\n"; print "\n"; print "\n"; } else { # Unable to find PID - show start button print "$text{'index_start_hdr'}
\n"; print "$text{'index_start_info'}\n

\n"; print "\n"; } # Check if Snort is running and allow user to (re)start it if allowed print "

\n"; print "
\n"; } # if ($access{'apply'}) # we're done here, just print the footer and quit &footer("/", $text{"index"}); exit; snort/lang/0040755000000000000000000000000007334547243011661 5ustar rootrootsnort/lang/en0100644000000000000000000000712407334547243012207 0ustar rootrootyes=Yes no=No save=Save Changes undo=Reset Changes index_title=Snort IDS index_opts=Global Snort Configuration index_rules=Rulesets index_rule_hdr1=Rule Set index_rule_hdr2=Status index_rule_hdr3=Action index_enabled=Enabled index_disabled=Disabled index_enable=Enable index_disable=Disable index_rule_msg=Other rulesets exist, but you do not have access rights to them index_apply_info=You must restart Snort for any changes to take effect! index_start=Start Snort index_stop=Stop Snort index_restart=Restart Snort index_start_hdr=Snort does not appear to be running index_start_info=(If you know Snort is running, check the PID file setting in the module configuration) net_title=Network Settings net_ecannot=You are not authorized to change the Snort network settings net_header=Snort Network Settings net_col1=Network Variable net_col2=Setting preproc_title=PreProcessors preproc_ecannot=You are not authorized to change the Snort preprocessor settings preproc_header=Snort Preprocessor Settings preproc_col1=Preprocessor preproc_col2=Options preproc_col3=Status output_title=Alerts & Logging output_ecannot=You are not authorized to change the Snort output settings output_header=Snort Alert/Output Settings output_col1=Output Type output_col2=Options output_col3=Status text_title=Edit Config File text_ecannot=You are not authorized to change the Snort configuration file rule_status_norule=You must specify a ruleset! rule_status_rulenf=Can't find ruleset rule_title=Edit Ruleset rule_error=Unable to access ruleset rule_noacc=You are not authorized to access ruleset rule_noedit=You are not authorized to edit rules rule_noadd=You are not authorized to add rules rule_nodel=You are not authorized to delete rules rule_nofile=Rule file cannot be found rule_noview=You are not authorized to view rules rule_norule=You must specify a ruleset to edit rule_header=Current Rules in rule_hdr1=Ruleset rule_col1=Rule rule_col2=Signature rule_col3=Status rule_col4=Action rule_addbutton=Add Rule back_link=Snort Administration lib_config_notfound=Unable to open Snort config file lib_config_unknown_type=Unknown Config Type! acl_rules=Rulesets this user can access acl_rall=All Rulesets acl_rsel=Selected Rulesets -> acl_rnsel=All Except Selected -> acl_text=Can user manually edit config file? acl_net=Can user change network settings? acl_pp=Can user change preprocessor settings? acl_out=Can user change output settings? acl_apply=Can user apply changes? acl_ruleview=Can user view rules? acl_ruletog=Can user enable/disable rules? acl_ruleedit=Can user edit rules? acl_ruleadd=Can user add rules? acl_ruledel=Can user delete rules? error_confchk=The Snort module is not properly configured error_config=Your userid cannot update the configuration. Please contact your Webmin administrator. save_rule_noadd=You are not authorized to add rules save_rule_noedit=You are not authorized to edit rules save_rule_nodel=You are not authorized to delete rules save_rule_notog=You are not authorized to enable/disable rules save_rule_accerr=Unable to update ruleset save_rule_cmderr=Unknown rule edit command save_rule_notfound=The rule you wish to edit cannot be found in save_rule_confirm=Delete Confirmation save_rule_back=Rule Configuration save_rule_cdhdr=Are you sure you want to delete the following rule? save_rule_edhdr=Edit Rule save_rule_einst=Make any changes below and submit ctl_noacc=You are not authorized to control the Snort process ctl_restart_err=Error restarting Snort $1 $2 ctl_start_err=Error starting Snort $1 $2 ctl_stop_err=Error stopping Snort $1 $2 ctl_start_nocmd=Unable to start Snort - No valid start command is configured snort/images/0040755000000000000000000000000007334061371012176 5ustar rootrootsnort/images/icon.gif0100644000000000000000000000212107334562154013613 0ustar rootrootGIF89a00@ ` @ @@@`@@@@@` `@``````` @` @` @` @`@ @@@`@@@@@ @ @@ @` @ @ @ @ @@@ @@@@@`@@@@@@@@@@`@ `@@`@``@`@`@`@`@@ @@@`@@@@@@ @@@`@@@@@@ @@@`@@@@@@ @@@`@@@@@ @` @ ` @ @@@`@@@@@` `@``````` @` @`ࠀ @` @` @` @ ` @ @@@`@@@@@` `@``````` @` @` @`𠠤!,00 H*\ȰÇ# |GQE3fq#ǎp$''(reG{0apf̛8cάxfΟ:wb\ M]jofL4Ԩ+j*jҭ\J1'Q9Yk{eϷsE3$Fpe+Zy64@3L8;/,e~9ff+:te\ze>X5˺M&iF!o'WtlS~pw/z;x9.qzjXjolPdWh;snort/images/net.gif0100644000000000000000000000073607333523427013462 0ustar rootrootGIF89a00fff!,000t*]W*پ+\=w1}"d'$nNɃ=t*X^_*@ gqnwq\mv;_|{~y\ zk{\}qx]RyVST ­˥T  kg?:A hn⦋3j|@FԤC"!T ftl r@hfsBB;tJQ\RtկRE,PcQS3FE5+UJ ,6JpvP݆7p=yOIqBVq@ Cwٮ͉Kȗ"ĈE˕<%;snort/images/preproc.gif0100644000000000000000000000040307333525001014323 0ustar rootrootGIF89a00̙fff!,00Ԅ+{)~Gc]&d:Ci1v't``0O1hڪꝀ-2elvq-qiSWiU7gqh3527بTI)!ij)r(Zs`w*ŵ5[զ; \(R=^խSy*Oac"{ԷαwzM\Rh#UY=!F/_f9ږh7)Q)69yQຎ9jE4 / C{/svtD(h)y#rI\kܚieeigeJq9EA6vʒZ䇳6͆\ yrҶ%1%>ESi׏PB0s6R%F)6nۤ(lFh͆l:=Hl2=(pMۣ2^Ԛ)uUg )z-bLj/q%+y1Rf>GI5m鼧sɅZ&E 9yNúf˾󞝢{vUŪYY |@霏MKږ((8m[YƳ)7f3F9&yX nBH!p1X{{2Xm߫-JX񘳶Z@B5.8l)c|tC>ylnBň>B6}OsYF67U)[I|/$n0D"a'C)BT|j$ɛob.7! + kM;EVG#ϟg!Y {jcBJ B!Jk} 0뽧h1)늠$&DԀǂ4 -H2/g3^v4uJ]Ǥj)Ֆڤye emKUÍx?Gx<gox^. ~L s$ m)H$[G!>Α@f Q@e"_Z"%BסG%T87 0CAYcVK(ac s6_=4łr:%5{He[ZS_Js8s\`=:ϡG>q,G{ \X qa`)K1'[((EHd%utp`V$CP.DF. SSBKJpYDvKu&:G D ߢn= Ȼt&S #{60*=ks>%EAj:[.W_z? >@qFO:N5 `xf 8!%^I ZV/J贍@:h?y"TFk :1ч7?b@e 1B jxLj2 B@m2ҹs yьb"Ȳ)fh)ɤHIg6 ڞՍglY@ǭ' Ґaq` XPû2- )d^-%Jsxm#s6`Y2lښuo%BzNNM9ϼz5l8sC\c@1sa8L&Zmz;|J?a}V+׈)Y˨,%>=s|ʗ|Ngn>xL W\f{h* bI xLO>3)T)9Bkl!Ӛ"Fiw\:_B`ĆCzHzG)BZ,hQ)GHm-z2o9@Ĥ|@KI1!4s~F| L#\fhgkF E:uin77K؞qUg֊Eۢļ˷Hz͛'5YH-D'#)nѾGqL|╍m}kn?> 4H!O#-;) !з-&ҷ-2;I)%s锔ec1ޣ9+WEW?gc?h:D~"_z1KnaF#hhaB^Ly.j2!YEϺ QdټfßoFZl8"fEjon ?;Fh 9{D]#NN0;;m߸xFAQJڶec=;n|,q?6+[SBJG2cxk|o)@k rJB:MaoNRzZ͚t2cn}G^{vy|fmIhj_ Զg!-5#Zk6OW~z2!-Ȯ_'߽͍M)#cDJJRj>PZc~>''eE_W+x>;mm /"9 9DQ C(GzO1!0U^_'@.0b>7%>MȃĹsCqgIZ#Yh^yv~elͨ&N}?87o⼧7 9FMmzͷ>z+{ @u|_ހc6Phs^1uxFT:FDAF*E1nitJ,C ="a1Hy` {j4":7& d(RCI]n+q9(ț\kd0f,#UקTSy*g0x=0IENDB`snort/images/text.gif0100644000000000000000000000046107333573171013654 0ustar rootrootGIF89a00`d`!Made with GIMP! ,00x0I8ͻ`HdihpL x|@P;H T*PaJEX``X$̬Oot̵fX=`|EMzZmgtv}r:pO{xYV8sw~QP7rWy|ncj$prt_name\n"; if ($_[2]) { printf " %s$text{'index_enabled'}%s\n", $_[3] ? "checked" : "", $_[3] ? "" : "", $_[3] ? "" : ""; printf " %s$text{'index_disabled'}%s\n", $_[3] ? "" : "checked", $_[3] ? "" : "", $_[3] ? "" : ""; } else { print " \n"; } } # get_config($type) # # Get the current configuration # Configuration info is stored in an array of hashes # We only return data of a specific type (passed in) # # As of Snort 1.8, those types are # var (Network Variables) # pre (Preprocessors) # out (Output config) # rule (Rule Includes) # # Each array element is a pointer to a hash for each element # # name -> Name of setting (or rule file in case of rules) # value -> Value for setting (empty if rule) # line -> Line number in file of this setting # index -> position in list # disabled -> set true if setting is commented out # sub get_config { local($type) = @_; local($lnum, $idx, %rv); local($comm, $name, $value); $lnum = 0; $idx = 0; open(FILE, $config{'snort_config'}) || &snort_error($text{'lib_config_notfound'}, " ", $config{'snort_config'}, ": ", $@); while($line = ) { $comm = ""; $name = ""; $value = ""; $line =~ s/\r|\n//g; # strip out newlines $line =~ s/\s+$//; # strip trailing spaces # if we hit a ruletype, lets skip it to avoid grabbing the innards if ($line =~ /ruletype\s+\w+/) { do { $tline = ; $lnum++; } while ($tline !~ /}/); } # Parse the setting based on teh setting type we are looking for $match = 0; if ($type eq 'var') { # The format of these lines is var 'var name' 'var value' # Note we do NOT allow var settings to be commented - otherwise we pick up # The example ones above the actual settings. $match = 1 if (($name, $value) = $line =~ /^var\s+(\S+)\s*(.*)$/); # $match = 1 if (($comm, $name, $value) = $line =~ /^([#]*)\s*var\s*([a-zA-Z_0-9\-]+)[:]*\s*(.*)$/); } elsif ($type eq 'pre') { # The format of these lines is preprocessor (proc name) and optional settings following an optional : $match = 1 if (($comm, $name, $value) = $line =~ /^([#]*)\s*preprocessor\s*([a-zA-Z_0-9\-]+)[:]*\s*(.*)$/); } elsif ($type eq 'out') { # The format of these lines is output 'out name': output settings $match = 1 if (($comm, $name, $value) = $line =~ /^([#]*)\s*output\s*([a-zA-Z_0-9\-]+)[:]*\s*(.*)$/); } elsif ($type eq 'rule') { # The format of these lines is include (rulset name).rules $match = 1 if (($comm, $name, $value) = $line =~ /^([#]*)\s*include\s+(\S+)\.rules$/); } else { # If we ever get here there is a problem close(FILE); &snort_error($text{'lib_config_unknown_type'}, ": ", $type); } if ($match) { # We found a valid setting local(%dir); if ($comm) { $dir{'disabled'} = 1; } # Flag if the setting is commented out $dir{'value'} = $value; $dir{'line'} = $lnum; $dir{'index'} = $idx++; # A user MIGHT have duplicates of an item name in comments - if htey do, add increment # $name .= "__" . $idx if ($rv{$name}); $rv{$name} = {%dir}; } $lnum++; } # while($line = ) { close(FILE); return \%rv; } sub snort_error { &header($text{'error'}, ""); print "
\n

",($whatfailed ? "$whatfailed : " : ""),join(" ", @_),"

\n
\n"; &footer("index.cgi", $text{'back_link'}); exit; } 1; snort/save_net.cgi0100755000000000000000000000240407334570333013224 0ustar rootroot#!/usr/bin/perl # # save_net.cgi # # This script takes in the new network settings # and saves them in the configuration file # Do common initialization and get common routines require 'snort-lib.pl'; ReadParse(); # Check if user can switch rule status $whatfailed = "Unable to save changes"; $access{'net'} || &snort_error($text{'net_ecannot'}); # Lets lock the file here to be sure we get the right line numbers lock_file($config{'snort_config'}); # Read in rule config data $conf = &get_config("var"); # Lets find any changes and replace the lines $data = &read_file_lines($config{'snort_config'}); foreach $key (keys %$conf) { if ($$conf{$key}->{'value'} ne $in{$key}) { $data_idx = $$conf{$key}->{'line'}; # We shouldn't need this, but just in case someone has duplicates... ($outkey) = split('__', $key); # Make sure we strip the index for saving in the conf file $new_tuple= "var " . $outkey; $new_tuple .= " " . $in{$key} if $in{$key}; $$data[$data_idx] = $new_tuple; } } &flush_file_lines(); # Store the new data unlock_file($config{'snort_config'}); # Log the change &webmin_log("net", undef, $config{'snort_config'}, { 'file' => $config{'snort_config'} }); # Redirect user back to main page &redirect("index.cgi"); snort/defaultacl0100644000000000000000000000013407334557702012763 0ustar rootrootrules=* text=y net=y pp=y out=y apply=y ruleview=y ruletog=y ruleedit=y ruleadd=y ruledel=y snort/acl_security.pl0100644000000000000000000000621607334570333013761 0ustar rootroot#!/usr/bin/perl require './snort-lib.pl'; # # YOU MUST UPDATE THIS ARRAY WHEN ADDING CHOICES! # # Below are the remaining Yes/No options. To add more, just include the name here # which will be the access key AND should correspond to a lang entry acl_(name) my @opts=('text','ruletog','net','ruleedit','pp','ruleadd','out','ruledel','apply','ruleview'); # acl_security_form(&options) # Output HTML for editing global security options sub acl_security_form { # Determine if user can change All, Selected, or Unselected rules local $m = $_[0]->{'rules'} eq '*' ? 0 : $_[0]->{'rules'} =~ /^\!/ ? 2 : 1; # Ruleset permissions are stored in a single value (rules) # If the value is set to "*", the user can edit all rulesets # If a user can edit selected rulesets, rules will contain the list # delimited by spaces # If a user can edit al rules except those selected, the list of # rulesets will have "!" in front of each ruleset print " $text{'acl_rules'}\n"; print "\n", $m == 2 ? 'checked' : '', $text{'acl_rnsel'}; print "
\n"; printf " %s
\n", $m == 0 ? 'checked' : '', $text{'acl_rall'}; printf " %s
\n", $m == 1 ? 'checked' : '', $text{'acl_rsel'}; printf " %s
\n"; # Now we'll output the Y/N choices in 2 columns of settings (4 cols total) local $tr_flag = 1; # Used to include table TR where appropriate local $set_name; foreach $choice (@opts) { if ($tr_flag) { print ""; $tr_flag = 0; } else { $tr_flag = 1; } $set_name = "acl_" . $choice; print "$text{$set_name} \n"; printf " $text{'yes'}\n", $_[0]->{$choice} ? "checked" : ""; printf " $text{'no'}\n", $_[0]->{$choice} ? "" : "checked"; } } # acl_security_save(&options) # Parse the form for global security options sub acl_security_save { # Borrowed from bind8 config code # This allows us to easily store rulesets user can update if ($in{'rules_def'} == 1) { $_[0]->{'rules'} = "*"; } elsif ($in{'rules_def'} == 2) { $_[0]->{'rules'} = join(" ", "!", split(/\0/, $in{'rules'})); } else { $_[0]->{'rules'} = join(" ", split(/\0/, $in{'rules'})); } # Now store all the Yes/No choices foreach $key (@opts) { $_[0]->{$key} = $in{$key}; } } snort/conf_net.cgi0100755000000000000000000000163207334570333013215 0ustar rootroot#!/usr/bin/perl # conf_net.cgi # Display a form for updating the Snort network settings require './snort-lib.pl'; &ReadParse(); $access{'net'} || &snort_error($text{'net_ecannot'}); # Get all network variables $conf = &get_config("var"); &header($text{'net_title'}, ""); print "
\n"; print "
\n"; print "\n"; print "\n"; print "\n"; foreach $opt (sort {$$conf{$a}->{'index'} <=> $$conf{$b}->{'index'}} (keys %$conf)) { &std_setting($opt, $$conf{$opt}->{'value'}, 0, 0); } print "
$text{'net_header'}
$text{'net_col1'}$text{'net_col2'} 
\n

\n"; print " ", "\n"; print "

\n"; print "
\n"; &footer("index.cgi", $text{'back_link'}); snort/save_text.cgi0100755000000000000000000000106007334570333013417 0ustar rootroot#!/usr/bin/perl # save_text.cgi # # Save the Snort config file (code heavily based on bind8 save_text.cgi) require './snort-lib.pl'; &ReadParseMime(); $access{'text'} || &snort_error($text{'text_ecannot'}); &lock_file($config{'snort_config'}); $in{'text'} =~ s/\r//g; open(FILE, ">$config{'snort_config'}"); print FILE $in{'text'}; close(FILE); &unlock_file($config{'snort_config'}); # Log event including file diff if enabled &webmin_log("text_config", undef, $config{'snort_config'}, { 'file' => $config{'snort_config'} }); &redirect("index.cgi"); snort/rule_status.cgi0100755000000000000000000000211507334570333013771 0ustar rootroot#!/usr/bin/perl # # rule_status.cgi # # This script accepts input via a GET request to enable or disable # a specific set of Snort rules # Do common initialization and get common routines require 'snort-lib.pl'; ReadParse(); $whatfailed = "Unable to switch ruleset status"; &snort_error($text{'rule_status_norule'}) if (!$in{'rule'}); # Check if user can switch rule status # Read in rule config data $conf = &get_config("rule"); # Make sure the rule actually exists &snort_error($text{'rule_status_rulenf'}, ": ", $in{'rule'}) if (!$$conf{$in{'rule'}}); # Lets update the tuple $newtuple = "include " . $in{'rule'} . ".rules\n"; $newtuple = "#" . $newtuple if (!$$conf{$in{'rule'}}->{'disabled'}); # Lock the file for the update and update the tuple lock_file($config{'snort_config'}); &replace_file_line($config{'snort_config'}, $$conf{$in{'rule'}}->{'line'}, $newtuple); unlock_file($config{'snort_config'}); # Log the change &webmin_log("rule_status", undef, $config{'snort_config'}, { 'file' => $config{'snort_config'} }); # Redirect user back to main page &redirect("index.cgi"); snort/conf_output.cgi0100755000000000000000000000173307334570333013771 0ustar rootroot#!/usr/bin/perl # conf_output.cgi # Display a form for updating the Snort alert/output settings require './snort-lib.pl'; &ReadParse(); $access{'out'} || &snort_error($text{'output_ecannot'}); # Get all output variables $conf = &get_config("out"); &header($text{'output_title'}, ""); print "
\n"; print "
\n"; print "\n"; print "\n"; print "\n"; foreach $opt (sort {$$conf{$a}->{'index'} <=> $$conf{$b}->{'index'}} (keys %$conf)) { &std_setting($opt, $$conf{$opt}->{'value'}, 1, !$$conf{$opt}->{'disabled'}); } print "
$text{'output_header'}
$text{'output_col1'}$text{'output_col2'}$text{'output_col3'}
\n

\n"; print " ", "\n"; print "

\n"; print "
\n"; &footer("index.cgi", $text{'back_link'}); snort/conf_preproc.cgi0100755000000000000000000000175007334570333014102 0ustar rootroot#!/usr/bin/perl # conf_preproc.cgi # Display a form for updating the Snort preprocessor settings require './snort-lib.pl'; &ReadParse(); $access{'pp'} || &snort_error($text{'preproc_ecannot'}); # Get all preprocessor variables $conf = &get_config("pre"); &header($text{'preproc_title'}, ""); print "
\n"; print "
\n"; print "\n"; print "\n"; print "\n"; foreach $opt (sort {$$conf{$a}->{'index'} <=> $$conf{$b}->{'index'}} (keys %$conf)) { &std_setting($opt, $$conf{$opt}->{'value'}, 1, !$$conf{$opt}->{'disabled'}); } print "
$text{'preproc_header'}
$text{'preproc_col1'}$text{'preproc_col2'}$text{'preproc_col3'}
\n

\n"; print " ", "\n"; print "

\n"; print "
\n"; &footer("index.cgi", $text{'back_link'}); snort/conf_text.cgi0100755000000000000000000000143607334570333013415 0ustar rootroot#!/usr/bin/perl # text_text.cgi # Display a form for manually editing the Snort config file # Based on bind8 function in Webmin require './snort-lib.pl'; &ReadParse(); $access{'text'} || &snort_error($text{'text_ecannot'}); &header($text{'text_title'}, ""); print "
$config{'snort_config'}
\n"; print "
\n"; open(FILE, $config{'snort_config'}); @sconf = map { &html_escape($_) } ; close(FILE); print "
\n"; print "\n

\n"; print " ", "\n"; print "

\n"; print "
\n"; &footer("index.cgi", $text{'back_link'}); snort/save_preproc.cgi0100755000000000000000000000270307334570333014112 0ustar rootroot#!/usr/bin/perl # # save_preproc.cgi # # This script takes in the new preprocessor settings # and saves them in the configuration file # Do common initialization and get common routines require 'snort-lib.pl'; ReadParse(); # Check if user can switch rule status $whatfailed = "Unable to save changes"; $access{'pp'} || &snort_error($text{'preproc_ecannot'}); # Lets lock the file here to be sure we get the right line numbers lock_file($config{'snort_config'}); # Read in rule config data $conf = &get_config("pre"); # Lets find any changes and replace the lines $data = &read_file_lines($config{'snort_config'}); foreach $key (keys %$conf) { $stat_key = join("", $key, "_stat"); # Check for option changes or a change in status if (($$conf{$key}->{'value'} ne $in{$key}) || ($$conf{$key}->{'disabled'} == $in{$stat_key})) { # The data has changed, lets $data_idx = $$conf{$key}->{'line'}; ($outkey) = split('__', $key); # Make sure we strip the index for saving in the conf file $new_tuple= "preprocessor " . $outkey; $new_tuple .= ": " . $in{$key} if $in{$key}; $new_tuple = "#" . $new_tuple if (!$in{$stat_key}); $$data[$data_idx] = $new_tuple; } } &flush_file_lines(); # Store the new data unlock_file($config{'snort_config'}); # Log the change &webmin_log("preproc", undef, $config{'snort_config'}, { 'file' => $config{'snort_config'} }); # Redirect user back to main page &redirect("index.cgi"); snort/conf_rules.cgi0100644000000000000000000001174107334570333013560 0ustar rootroot#!/usr/bin/perl # # conf_rules.cgi # # This script displays all rules in a given rule file and allows the user # to edit them. It will also grab out any reference information and # activate links to IDS, CVE, etc. # # Since rule files can be queit large, rules are not displayed in fields # Instead, you must click edit to edit a rule and the field will appear. # Note that this is a precursor to a new rule editing screen which will # be interactive and provide choices according to the Snort rules document. # require './snort-lib.pl'; # External URLs to Snort rule info %refurls = ('arachnids' => 'http://www.whitehats.com/IDS/', 'bugtraq' => 'http://www.securityfocus.com/bid/', 'cve' => 'http://cve.mitre.org/cgi-bin/cvename.cgi?name=', 'mcafee' => 'http://vil.nai.com/vil/dispVirus.asp?virus_k='); &ReadParse(); # If the user can't view rules - well we'll bail right here &snort_error($text{'rule_noview'}) if (!$access{'ruleview'}); # Check to see if user can access a given ruleset $whatsfailed = $text{'rule_error'}; if ($access{'rules'} ne "*") { if ($access{'rules'} =~ /^\!/) { # The access array is all EXCEPT selected &snort_error($text{'rule_noacc'}, " ", $in{'rule'}) if ($access{'rules'} =~ /\b$in{'rule'}\b/); } else { &snort_error($text{'rule_noacc'}, " ", $in{'rule'}) if ($access{'rules'} !~ /\b$in{'rule'}\b/); } } # Some basic error checking &snort_error($text{'rule_norule'}) if !$in{'rule'}; $rulefile = $config{'snort_rules_path'} . "/" . $in{'rule'} . ".rules"; &snort_error($text{'rule_nofile'}, " ($rulefile)") if (! -r $rulefile); # Grab the rule file and parse it into arrays if ($access{'ruletog'} || $access{'ruleedit'} || $access{'ruledel'}) { $readonly = 0; } else { $readonly = 1; } $rules = &read_file_lines($rulefile); # Lets start the page &header($text{'rule_title'}, "", undef, 1, 1, 0, &help_search_link("snort", "man", "doc", "google")); print "
\n"; if ($access{'ruleadd'}) { print "
\n"; print "\n"; } print "\n"; print "\n"; print ""; print "" if !$readonly; print "\n"; # Dump the rule rows for each rule found $rulectr = 1; foreach $newrule (@$rules) { next if ($newrule !~ /->.+(.+)/); # Try to see if its a rule or bogus comment # To pass the rule into other scripts for processing, first search for a snort id which will # be unique, but works only with offical rules and Snort 1.8 or higher. # If a Snort ID can't be found, lets include the entire rule in the links (making pages HUGE) # Maybe at some point we can put in a paging setup to only display X rules per page if ($newrule =~ /sid:\s*(\d+)\s*;/) { $rulevar = $1; # We found a Snort ID } else { # Lets convert the rule into a GET compatible format. $rulevar = urlize($newrule); } print ""; ($prt_rule) = $newrule =~ /^[#]*\s*(.+)/; # Strip off the comment for printing $prt_rule = &html_escape($prt_rule); # Lets include links to vulnerability databases where appropriate foreach $site (keys %refurls) { $prt_rule =~ s/(reference\:.*)($site)(\s*\,\s*)(\S+?)\;/$1$2$3$4<\/a>\;/ig; } print "\n"; # Check to see if the rule is enabled or disabled if ($newrule =~ /^[#]+/) { print "\n"; print "\n"; print "\n" if !$readonly; print "\n"; } # If we can add rules, lets give them space print "\n" if ($access{'ruleadd'}); print "
$text{'rule_header'} $rulefile
$text{'rule_col1'}$text{'rule_col2'}$text{'rule_col3'}$text{'rule_col4'}
" . $rulectr++ . "" . $prt_rule . "\"$text{'index_disabled'}\"" if !$readonly; print "$text{'index_enable'} " if $access{'ruletog'}; } else { print "\"$text{'index_enabled'}\"" if !$readonly; print "$text{'index_disable'} " if $access{'ruletog'}; } print "Edit " if $access{'ruleedit'}; print "Delete" if $access{'ruledel'}; print "
\n"; print "\n" if ($access{'ruleadd'}); print "
\n"; &footer("index.cgi", $text{'back_link'}); snort/save_output.cgi0100755000000000000000000000266507334570333014007 0ustar rootroot#!/usr/bin/perl # # save_output.cgi # # This script takes in the new output settings # and saves them in the configuration file # Do common initialization and get common routines require 'snort-lib.pl'; ReadParse(); # Check if user can switch rule status $whatfailed = "Unable to save changes"; $access{'out'} || &snort_error($text{'output_ecannot'}); # Lets lock the file here to be sure we get the right line numbers lock_file($config{'snort_config'}); # Read in rule config data $conf = &get_config("out"); # Lets find any changes and replace the lines $data = &read_file_lines($config{'snort_config'}); foreach $key (keys %$conf) { $stat_key = join("", $key, "_stat"); # Check for option changes or a change in status if (($$conf{$key}->{'value'} ne $in{$key}) || ($$conf{$key}->{'disabled'} == $in{$stat_key})) { # The data has changed, lets $data_idx = $$conf{$key}->{'line'}; ($outkey) = split('__', $key); # Make sure we strip the index for saving in the conf file $new_tuple= "output " . $outkey; $new_tuple .= ": " . $in{$key} if $in{$key}; $new_tuple = "#" . $new_tuple if (!$in{$stat_key}); $$data[$data_idx] = $new_tuple; } } &flush_file_lines(); # Store the new data unlock_file($config{'snort_config'}); # Log the change &webmin_log("output", undef, $config{'snort_config'}, { 'file' => $config{'snort_config'} }); # Redirect user back to main page &redirect("index.cgi"); snort/save_rules.cgi0100644000000000000000000001256707334570333013600 0ustar rootroot#!/usr/bin/perl # # save_rules.cgi # # Save changes to rules, based on the action submitted # # Rules can be enabled/disabled, edited, deleted, and added # Not for editing a rule this script will present the small form # to modify a rule and also accept the input to save the changes # require './snort-lib.pl'; &ReadParse(); # Lets check access rules against what they want to do $whatfailed = $text{'save_rule_accerr'}; if ($access{'rules'} ne "*") { if ($access{'rules'} =~ /^\!/) { # The access array is all EXCEPT selected &snort_error($text{'rule_noacc'}, " ", $in{'ruleset'}) if ($access{'rules'} =~ /\b$in{'ruleset'}\b/); } else { &snort_error($text{'rule_noacc'}, " ", $in{'ruleset'}) if ($access{'rules'} !~ /\b$in{'ruleset'}\b/); } } &snort_error($text{'save_rule_notog'}) if ((!$access{'ruletog'}) && ($in{'action'} =~ /able$/)); &snort_error($text{'save_rule_noedit'}) if ((!$access{'ruleedit'}) && ($in{'action'} eq 'edit')); &snort_error($text{'save_rule_noadd'}) if ((!$access{'ruleadd'}) && $in{'newrule'}); &snort_error($text{'save_rule_nodel'}) if ((!$access{'ruledel'}) && ($in{'action'} =~ /delete$/)); # Lets check and see if its an aborted edit if (($in{'action'} eq 'delete') && ($in{'submit'} eq $text{'no'})) { &redirect("conf_rules.cgi?rule=$in{'ruleset'}"); exit; } # Looks like we're allowed to do whatever we want to do # Lets grab the rule file to start with &snort_error($text{'rule_norule'}) if !$in{'ruleset'}; $rulefile = $config{'snort_rules_path'} . "/" . $in{'ruleset'} . ".rules"; &snort_error($text{'rule_nofile'}, " ($rulefile)") if (! -r $rulefile); # If we are updating or deleting a rule, lets find it in the file # The rule to be changed may be a complete rule OR a Snort ID &lock_file($rulefile); $rules = &read_file_lines($rulefile); $oldrule = ""; if ($in{'rule'}) { $linenum = 0; if ($in{'rule'} =~ /^(\d+)$/) { # Its a Snort ID foreach $tmprule (@$rules) { if ($tmprule =~ /sid\:\s*($in{'rule'})\s*\;/) { $oldrule = $tmprule; last; } $linenum++; } } else { # We've got an older style rule, lets do a hard match foreach $tmprule (@$rules) { if ($tmprule == $in{'rule'}) { $oldrule = $tmprule; last; } $linenum++; } } # If we didn't find anything - return an error if (!$oldrule) { &unlock_file($rulefile); &snort_error($text{'save_rule_notfound'}, " ", $rulefile); } } # This is where we return intermediate screens if necessary # If we are editing a rule, lets intercept here and return the form if necessary if ($in{'action'} eq 'edit') { &unlock_file($rulefile); &header($text{'save_rule_edhdr'}, "", undef, 1, 1, 0, &help_search_link("snort", "man", "doc", "google")); print "
\n

$text{'save_rule_einst'}

\n"; print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
\n
\n"; print "
\n"; &footer("conf_rules.cgi?rule=$in{'ruleset'}", $text{'save_rule_back'}); exit; } elsif ($in{'action'} eq 'wantdelete') { # Lets give them a confirmation page to make SURE they want to delete the rule &unlock_file($rulefile); # No need for lock anymore &header($text{'save_rule_confirm'}, "", undef, 1, 1, 0, &help_search_link("snort", "man", "doc", "google")); print "
\n

$text{'save_rule_cdhdr'}

\n"; print "
$oldrule
\n"; print "
\n"; print "\n"; foreach $formkey (keys %in) { next if ($formkey eq 'action'); # Already sent above print "\n"; } print "
\n
\n"; print "
\n"; &footer("conf_rules.cgi?rule=$in{'ruleset'}", $text{'save_rule_back'}); exit; } # Lets determine the action they want us to take and do it if ($in{'action'} eq 'enable') { $oldrule =~ s/^[#]+\s*//; splice(@$rules, $linenum, 1, $oldrule); } elsif ($in{'action'} eq 'disable') { splice(@$rules, $linenum, 1, "#" . $oldrule); } elsif ($in{'action'} eq 'edityes') { splice(@$rules, $linenum, 1, $in{'editrule'}); $in{'action'} = 'edit'; # For web log } elsif ($in{'action'} eq 'delete') { splice(@$rules, $linenum, 1); # Remove rule from file } elsif ($in{'newrule'}) { push(@$rules, $in{'newrule'}); # Add new rule to end of file $in{'action'} = 'add'; # For web log } else { # Don't know what they want to do &unlock_file($rulefile); &snort_error($text{'save_rule_cmderr'}); } # Lets flush the file and save any changes &flush_file_lines(); &unlock_file($rulefile); # Save web log of event $rule_action = "rules:$in{'action'}"; &webmin_log($rule_action, undef, $rulefile, \%in); # Jump back to the rule page they were at &redirect("conf_rules.cgi?rule=$in{'ruleset'}"); snort/snort_ctl.cgi0100644000000000000000000000336307334570333013431 0ustar rootroot#!/usr/bin/perl # snort_ctl.cgi # # Used to start, stop, and restart the snort process require './snort-lib.pl'; &ReadParse(); $access{'apply'} || &snort_error($text{'ctl_noacc'}); # We have 3 funcitons here, start, stop, and restart if ($in{'submit'} eq $text{'index_restart'}) { # Lets restart the process with a HUP &kill_logged('TERM', $in{'pid'}) || &snort_error(&text('ctl_restart_err', $in{'pid'}, "

" . &html_escape($!) . "")); &webmin_log("restart"); $in{'submit'} = $text{'index_start'}; # Fake out start code to execute after stop for restart } # We split the if here since we need to start for a restart which is actually a stop/start if ($in{'submit'} eq $text{'index_start'}) { # Lets start the process - we have a couple choices to do so if ($config{'snort_rc'}) { $cmd = $config{'snort_rc'}; } elsif ($config{'snort_path'}) { $cmd = $config{'snort_path'}; } else { # Whoops - no command is available :( &snort_error($text{'ctl_start_nocmd'}); } # Lets start and see what we get back $temp = &tempname(); $rv = &system_logged("$cmd $temp 2>&1"); $out = `cat $temp`; unlink($temp); # If we got anything back, well thats not a good thing if ($rv || $out =~ /err/) { &snort_error(&text('ctl_start_err', "

" . &html_escape($out) . "", "" . &html_escape($rv) . "")); } # Cool - started OK - lets log it &webmin_log("start"); } elsif ($in{'submit'} eq $text{'index_stop'}) { # Lets stop the process &kill_logged('TERM', $in{'pid'}) || &snort_error(&text('ctl_stop_err', $in{'pid'}, "

" . &html_escape($!) . "")); &webmin_log("stop"); } # We're done here - lets jump back home &redirect(""); exit; snort/LICENSE0100664000000000000000000003537707334572107011760 0ustar rootroot GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.