aboutsummaryrefslogtreecommitdiffstats
path: root/config/snort
diff options
context:
space:
mode:
Diffstat (limited to 'config/snort')
-rwxr-xr-xconfig/snort/snort.inc1463
-rwxr-xr-xconfig/snort/snort.xml25
-rwxr-xr-xconfig/snort/snort_alerts.php135
-rw-r--r--config/snort/snort_barnyard.php53
-rw-r--r--config/snort/snort_blocked.php141
-rwxr-xr-xconfig/snort/snort_check_for_rule_updates.php757
-rwxr-xr-xconfig/snort/snort_define_servers.php37
-rwxr-xr-xconfig/snort/snort_download_rules.php59
-rwxr-xr-xconfig/snort/snort_download_updates.php129
-rwxr-xr-xconfig/snort/snort_interfaces.php387
-rwxr-xr-xconfig/snort/snort_interfaces_edit.php394
-rw-r--r--config/snort/snort_interfaces_global.php187
-rw-r--r--config/snort/snort_interfaces_suppress.php12
-rw-r--r--config/snort/snort_interfaces_suppress_edit.php27
-rw-r--r--config/snort/snort_interfaces_whitelist.php17
-rw-r--r--config/snort/snort_interfaces_whitelist_edit.php51
-rw-r--r--config/snort/snort_list_view.php103
-rw-r--r--config/snort/snort_log_view.php89
-rwxr-xr-xconfig/snort/snort_preprocessors.php988
-rwxr-xr-xconfig/snort/snort_rules.php608
-rwxr-xr-xconfig/snort/snort_rules_edit.php26
-rw-r--r--config/snort/snort_rules_flowbits.php277
-rwxr-xr-xconfig/snort/snort_rulesets.php294
-rwxr-xr-xconfig/snort/snort_sync.xml193
24 files changed, 4841 insertions, 1611 deletions
diff --git a/config/snort/snort.inc b/config/snort/snort.inc
index c36fc873..44dd133e 100755
--- a/config/snort/snort.inc
+++ b/config/snort/snort.inc
@@ -33,21 +33,58 @@
require_once("pfsense-utils.inc");
require_once("config.inc");
require_once("functions.inc");
+require_once("service-utils.inc");
+require_once("pkg-utils.inc");
// Needed on 2.0 because of filter_get_vpns_list()
require_once("filter.inc");
+// Snort GUI needs some extra PHP memory space to manipulate large rules arrays
+ini_set("memory_limit", "192M");
+
+// Explicitly declare these as global so they work through function call includes
+global $snort_rules_file, $snort_version, $emerging_threats_version, $snort_rules_upd_log;
+global $all_rules, $flowbit_rules_file, $snort_enforcing_rules_file, $rebuild_rules, $is_postinstall;
+global $snort_community_rules_filename, $snort_community_rules_url, $emergingthreats_filename;
+
/* package version */
-$snort_version = "2.9.2.3";
-$pfSense_snort_version = "2.5.4";
+$snort_version = "2.9.4.1";
+$pfSense_snort_version = "2.5.8";
$snort_package_version = "Snort {$snort_version} pkg v. {$pfSense_snort_version}";
-$snort_rules_file = "snortrules-snapshot-2923.tar.gz";
-$emerging_threats_version = "2.9.3";
+
+// Define SNORTDIR and SNORTLIBDIR constants according to FreeBSD version (PBI support or no PBI)
+if (floatval(php_uname("r")) >= 8.3) {
+ exec("/usr/local/sbin/pbi_info | grep 'snort-{$snort_version}' | xargs /usr/local/sbin/pbi_info | awk '/Prefix/ {print $2}'",$pbidirarray);
+ $snort_pbidir = "{$pbidirarray[0]}";
+ /* In case this is an initial Snort install and pbi_info() above returned null, set a sane default value */
+ if (empty($snort_pbidir))
+ $snort_pbidir = "/usr/pbi/snort-" . php_uname("m");
+ define("SNORTDIR", "{$snort_pbidir}/etc/snort");
+ define("SNORTLIBDIR", "{$snort_pbidir}/lib/snort");
+}
+else {
+ define("SNORTDIR", "/usr/local/etc/snort");
+ define("SNORTLIBDIR", "/usr/local/lib/snort");
+}
+
+define("SNORTLOGDIR", "/var/log/snort");
+
+/* Important file definitions */
+$snort_rules_file = "snortrules-snapshot-2941.tar.gz";
+$emerging_threats_version = "2.9.0";
+$emergingthreats_filename = "emerging.rules.tar.gz";
+$snort_community_rules_url = "https://s3.amazonaws.com/snort-org/www/rules/community/";
+$snort_community_rules_filename = "community-rules.tar.gz";
$flowbit_rules_file = "flowbit-required.rules";
$snort_enforcing_rules_file = "snort.rules";
+$snort_rules_upd_log = SNORTLOGDIR;
+$snort_rules_upd_log .= "/snort_rules_update.log";
-define("SNORTDIR", "/usr/local/etc/snort");
-define("SNORTLOGDIR", "/var/log/snort");
+/* Rebuild Rules Flag -- if "on", rebuild enforcing rules and flowbit-rules files */
+$rebuild_rules = "off";
+
+/* Post-install Flag -- normally "false" except during post-install of package */
+$is_postinstall = false;
if (!is_array($config['installedpackages']['snortglobal']))
$config['installedpackages']['snortglobal'] = array();
@@ -99,6 +136,55 @@ function snort_generate_id() {
return $snort_uuid;
}
+function snort_load_suppress_sigs($snortcfg) {
+
+ global $config;
+
+ /**********************************************************/
+ /* This function loads the GEN_ID and SIG_ID for all the */
+ /* suppressed alert entries from the Suppression List of */
+ /* the passed Snort interface. The results are returned */
+ /* in an array with GEN_ID and SIG_ID as the keys. */
+ /**********************************************************/
+
+ $suppress = array();
+
+ if (!is_array($config['installedpackages']['snortglobal']))
+ return;
+ if (!is_array($config['installedpackages']['snortglobal']['suppress']))
+ return;
+ if (!is_array($config['installedpackages']['snortglobal']['suppress']['item']))
+ return;
+ $a_suppress = $config['installedpackages']['snortglobal']['suppress']['item'];
+
+ foreach ($a_suppress as $a_id => $alist) {
+ if ($alist['name'] == $snortcfg['suppresslistname']) {
+ if (!empty($alist['suppresspassthru'])) {
+ $tmplist = str_replace("\r", "", base64_decode($alist['suppresspassthru']));
+ $tmp = explode("\n", $tmplist);
+ foreach ($tmp as $line) {
+ // Skip any blank lines
+ if (trim($line, " \n") == "")
+ continue;
+ // Skip any comment lines
+ if (preg_match('/^\s*#/', $line))
+ continue;
+ if (preg_match('/gen_id\b\s*(\d+),\s*sig_id\b\s*(\d+)/i', $line, $matches)) {
+ $genid = $matches[1];
+ $sigid = $matches[2];
+ if (!empty($genid) && !empty($sigid))
+ $suppress[$genid][$sigid] = "suppress";
+ }
+ }
+ unset($tmp);
+ }
+ break;
+ }
+ }
+ unset($alist);
+ return $suppress;
+}
+
/* func builds custom white lists */
function snort_find_list($find_name, $type = 'whitelist') {
global $config;
@@ -117,117 +203,120 @@ function snort_find_list($find_name, $type = 'whitelist') {
return array();
}
-/* func builds custom whitelests */
+/* func builds custom whitelists and the HOME_NET variable */
function snort_build_list($snortcfg, $listname = "", $whitelist = false) {
global $config, $g;
-
- /* Add loopback to whitelist (ftphelper) */
- $home_net = "127.0.0.1 ";
+ global $aliastable, $filterdns;
+ $home_net = array();
if ($listname == 'default' || empty($listname)) {
- $wanip = 'yes'; $wangw = 'yes'; $wandns = 'yes'; $vips = 'yes'; $vpns = 'yes';
+ $localnet = 'yes'; $wanip = 'yes'; $wangw = 'yes'; $wandns = 'yes'; $vips = 'yes'; $vpns = 'yes';
} else {
$list = snort_find_list($listname);
if (empty($list))
return $list;
+ $localnet = $list['localnets'];
$wanip = $list['wanips'];
$wangw = $list['wangateips'];
$wandns = $list['wandnsips'];
$vips = $list['vips'];
$vpns = $list['vpnips'];
if (!empty($list['address']) && is_alias($list['address'])) {
- $home_net .= trim(filter_expand_alias($list['address']));
- $home_net .= " ";
+ $home_net = explode(" ", trim(filter_expand_alias($list['address'])));
}
}
- /* Always put snort running interface in the list */
+ /* Always add loopback to HOME_NET and whitelist (ftphelper) */
+ if (!in_array("127.0.0.1", $home_net))
+ $home_net[] = "127.0.0.1";
+
+ /********************************************************************/
+ /* Always put the interface running Snort in HOME_NET and whitelist */
+ /* unless it's the WAN. WAN options are handled further down. */
+ /********************************************************************/
$snortip = get_interface_ip($snortcfg['interface']);
- if (is_ipaddr($snortip))
- $home_net .= "{$snortip} ";
+ if (is_ipaddr($snortip)) {
+ if ($snortcfg['interface'] <> "wan") {
+ $sn = get_interface_subnet($snortcfg['interface']);
+ $ip = gen_subnet($snortip, $sn) . "/{$sn}";
+ if (!in_array($ip, $home_net))
+ $home_net[] = $ip;
+ }
+ }
+
if (function_exists('get_interface_ipv6')) {
$snortip = get_interface_ipv6($snortcfg['interface']);
if (is_ipaddrv6($snortip)) {
- if ($whitelist === false) {
+ if ($snortcfg['interface'] <> "wan") {
$sn = get_interface_subnetv6($snortcfg['interface']);
- $home_net .= "{$snortip}/{$sn} ";
- } else
- $home_net .= "{$snortip} ";
+ $ip = gen_subnetv6($snortip, $sn). "/{$sn}";
+ if (!in_array($ip, $home_net))
+ $home_net[] = $ip;
+ }
}
}
-
- /* iterate through interface list and write out whitelist items
- * and also compile a home_net list for snort.
- */
- if ($wanip == 'yes') {
- /* build an interface array list */
- if (function_exists('get_configured_interface_list'))
- $int_array = get_configured_interface_list();
- else {
- $int_array = array('wan', 'lan');
- for ($j = 1; isset ($config['interfaces']['opt' . $j]); $j++)
- if(isset($config['interfaces']['opt' . $j]['enable']))
- $int_array[] = "opt{$j}";
- }
+ if ($localnet == 'yes') {
+ /*************************************************************************/
+ /* Iterate through the interface list and write out whitelist items and */
+ /* also compile a HOME_NET list of all the local interfaces for snort. */
+ /* Skip the WAN interface as we do not typically want that whole subnet */
+ /* whitelisted (just the interface IP itself). */
+ /*************************************************************************/
+ $int_array = get_configured_interface_list();
foreach ($int_array as $int) {
- /* calculate interface subnet information */
- if (function_exists('get_interface_ip')) {
- if (!interface_has_gateway($int))
+ if ($int == "wan")
+ continue;
+ $subnet = get_interface_ip($int);
+ if (is_ipaddr($subnet)) {
+ $sn = get_interface_subnet($int);
+ $ip = gen_subnet($subnet, $sn) . "/{$sn}";
+ if (!in_array($ip, $home_net))
+ $home_net[] = $ip;
+ }
+ if (function_exists("get_interface_ipv6")) {
+ if ($int == "wan")
continue;
- $subnet = get_interface_ip($int);
- if (is_ipaddr($subnet)) {
- if ($whitelist === false) {
- $sn = get_interface_subnet($int);
- $home_net .= "{$subnet}/{$sn} ";
- } else
- $home_net .= "{$subnet} ";
- }
- if (function_exists("get_interface_ipv6")) {
- if (!interface_has_gatewayv6($int))
- continue;;
- $subnet = get_interface_ipv6($int);
- if (is_ipaddrv6($subnet)) {
- if ($whitelist === false) {
- $sn = get_interface_subnetv6($int);
- $home_net .= "{$subnet}/{$sn} ";
- } else
- $home_net .= "{$subnet} ";
- }
- }
- } else {
- $ifcfg = $config['interfaces'][$int];
- switch ($ifcfg['ipaddr']) {
- case "pppoe":
- case "pptp":
- case "l2tp":
- $subnet = find_interface_ip("ng0");
- if (is_ipaddr($subnet))
- $home_net .= "{$subnet} ";
- break;
- case "dhcp":
- $subnet = find_interface_ip(snort_get_real_interface($int));
- if (is_ipaddr($subnet))
- $home_net .= "{$subnet} ";
- break;
- default:
- if (is_ipaddr($ifcfg['ipaddr'])) {
- $home_net .= "{$ifcfg['ipaddr']} ";
- }
- break;
+ $subnet = get_interface_ipv6($int);
+ if (is_ipaddrv6($subnet)) {
+ $sn = get_interface_subnetv6($int);
+ $ip = gen_subnetv6($subnet, $sn). "/{$sn}";
+ if (!in_array($ip, $home_net))
+ $home_net[] = $ip;
}
}
}
}
+ if ($wanip == 'yes') {
+ $ip = get_interface_ip("wan");
+ if (is_ipaddr($ip)) {
+ if (!in_array($ip, $home_net))
+ $home_net[] = $ip;
+ }
+ if (function_exists("get_interface_ipv6")) {
+ $ip = get_interface_ipv6("wan");
+ if (is_ipaddrv6($ip)) {
+ if (!in_array($ip, $home_net))
+ $home_net[] = $ip;
+ }
+ }
+ }
+
if ($wangw == 'yes') {
+ /* Grab the default gateway if set */
+ $default_gw = exec("/sbin/route -n get default |grep 'gateway:' | /usr/bin/awk '{ print $2 }'");
+ if (is_ipaddr($default_gw) && !in_array($default_gw, $home_net))
+ $home_net[] = $default_gw;
+
+ /* Get any other interface gateway and put in $HOME_NET if not there already */
$gw = get_interface_gateway($snortcfg['interface']);
- if (is_ipaddr($gw))
- $home_net .= "{$gw} ";
+ if (is_ipaddr($gw) && !in_array($gw, $home_net))
+ $home_net[] = $gw;
if (function_exists("get_interface_gatewayv6")) {
$gw = get_interface_gatewayv6($snortcfg['interface']);
- if (is_ipaddrv6($gw))
- $home_net .= "{$gw} ";
+ if (is_ipaddrv6($gw) && !in_array($gw, $home_net))
+ $home_net[] = $gw;
}
}
@@ -235,8 +324,8 @@ function snort_build_list($snortcfg, $listname = "", $whitelist = false) {
/* Add DNS server for WAN interface to whitelist */
$dns_servers = get_dns_servers();
foreach ($dns_servers as $dns) {
- if ($dns)
- $home_net .= "{$dns} ";
+ if ($dns && !in_array($dns, $home_net))
+ $home_net[] = $dns;
}
}
@@ -245,10 +334,8 @@ function snort_build_list($snortcfg, $listname = "", $whitelist = false) {
if (is_array($config['virtualip']) && is_array($config['virtualip']['vip'])) {
foreach($config['virtualip']['vip'] as $vip) {
if ($vip['subnet'] && $vip['mode'] != 'proxyarp') {
- if ($whitelist === false)
- $home_net .= "{$vip['subnet']}/{$vip['subnet_bits']} ";
- else
- $home_net .= "{$vip['subnet']} ";
+ if (!in_array("{$vip['subnet']}/{$vip['subnet_bits']}", $home_net))
+ $home_net[] = "{$vip['subnet']}/{$vip['subnet_bits']}";
}
}
}
@@ -256,27 +343,31 @@ function snort_build_list($snortcfg, $listname = "", $whitelist = false) {
/* grab a list of vpns and whitelist if user desires added by nestorfish 954 */
if ($vpns == 'yes') {
- if ($config['version'] <= 6) // chk what pfsense version were on
- $vpns_list = get_vpns_list();
- else
- $vpns_list = filter_get_vpns_list();
-
- if (!empty($vpns_list))
- $home_net .= "{$vpns_list} ";
+ $vpns_list = filter_get_vpns_list();
+ if (!empty($vpns_list)) {
+ /* Convert the returned space-delimited string to an array */
+ /* and then add each VPN address to our HOME_NET array. */
+ $vpns = explode(" ", $vpns_list);
+ foreach ($vpns as $vpn)
+ $home_net[] = trim($vpn);
+ unset($vpns, $vpns_list);
+ }
}
- $home_net = trim($home_net);
- $validator = explode(" ", $home_net);
$valresult = array();
- foreach ($validator as $vald) {
+ foreach ($home_net as $vald) {
if (empty($vald))
continue;
$vald = trim($vald);
if (empty($valresult[$vald]))
$valresult[$vald] = $vald;
}
- unset($home_net, $validator);
+ /* Release memory no longer required */
+ unset($home_net);
+
+ /* Sort the list and return it */
+ natsort($valresult);
return $valresult;
}
@@ -295,8 +386,8 @@ function snort_barnyard_stop($snortcfg, $if_real) {
$snort_uuid = $snortcfg['uuid'];
if (file_exists("{$g['varrun_path']}/barnyard2_{$if_real}{$snort_uuid}.pid") && isvalidpid("{$g['varrun_path']}/barnyard2_{$if_real}{$snort_uuid}.pid")) {
+ log_error("[Snort] Barnyard2 STOP for {$snortcfg['descr']}({$if_real})...");
killbypid("{$g['varrun_path']}/barnyard2_{$if_real}{$snort_uuid}.pid");
- @unlink("{$g['varrun_path']}/barnyard2_{$if_real}{$snort_uuid}.pid");
}
}
@@ -305,13 +396,11 @@ function snort_stop($snortcfg, $if_real) {
$snort_uuid = $snortcfg['uuid'];
if (file_exists("{$g['varrun_path']}/snort_{$if_real}{$snort_uuid}.pid") && isvalidpid("{$g['varrun_path']}/snort_{$if_real}{$snort_uuid}.pid")) {
+ log_error("[Snort] Snort STOP for {$snortcfg['descr']}({$if_real})...");
killbypid("{$g['varrun_path']}/snort_{$if_real}{$snort_uuid}.pid");
- exec("/bin/rm {$g['varrun_path']}/snort_{$if_real}{$snort_uuid}.pid");
}
snort_barnyard_stop($snortcfg, $if_real);
-
- log_error("Interface Rule STOP for {$snortcfg['descr']}({$if_real})...");
}
function snort_barnyard_start($snortcfg, $if_real) {
@@ -321,9 +410,10 @@ function snort_barnyard_start($snortcfg, $if_real) {
$snort_uuid = $snortcfg['uuid'];
/* define snortbarnyardlog_chk */
- if ($snortcfg['barnyard_enable'] == 'on' && !empty($snortcfg['barnyard_mysql']))
+ if ($snortcfg['barnyard_enable'] == 'on' && !empty($snortcfg['barnyard_mysql'])) {
+ log_error("[Snort] Barnyard2 START for {$snortcfg['descr']}({$if_real})...");
exec("/usr/local/bin/barnyard2 -r {$snort_uuid} -f \"snort_{$snort_uuid}_{$if_real}.u2\" --pid-path {$g['varrun_path']} --nolock-pidfile -c {$snortdir}/snort_{$snort_uuid}_{$if_real}/barnyard2.conf -d /var/log/snort/snort_{$if_real}{$snort_uuid} -D -q");
-
+ }
}
function snort_start($snortcfg, $if_real) {
@@ -332,14 +422,37 @@ function snort_start($snortcfg, $if_real) {
$snortdir = SNORTDIR;
$snort_uuid = $snortcfg['uuid'];
- if ($snortcfg['enable'] == 'on')
+ if ($snortcfg['enable'] == 'on') {
+ log_error("[Snort] Snort START for {$snortcfg['descr']}({$if_real})...");
exec("/usr/local/bin/snort -R {$snort_uuid} -D -q -l /var/log/snort/snort_{$if_real}{$snort_uuid} --pid-path {$g['varrun_path']} --nolock-pidfile -G {$snort_uuid} -c {$snortdir}/snort_{$snort_uuid}_{$if_real}/snort.conf -i {$if_real}");
+ }
else
return;
snort_barnyard_start($snortcfg, $if_real);
+}
+
+/**************************************************************/
+/* This function sends a SIGHUP to the Snort instance on the */
+/* passed interface to cause Snort to reload and parse the */
+/* running configuration without stopping packet processing. */
+/* It also executes the reload as a background process and */
+/* returns control immediately to the caller. */
+/**************************************************************/
+function snort_reload_config($snortcfg, $if_real) {
+ global $config, $g;
+
+ $snortdir = SNORTDIR;
+ $snort_uuid = $snortcfg['uuid'];
- log_error("Interface Rule START for {$snortcfg['descr']}({$if_real})...");
+ /******************************************************/
+ /* Only send the SIGHUP if Snort is running and we */
+ /* can find a valid PID for the process. */
+ /******************************************************/
+ if (file_exists("{$g['varrun_path']}/snort_{$if_real}{$snort_uuid}.pid") && isvalidpid("{$g['varrun_path']}/snort_{$if_real}{$snort_uuid}.pid")) {
+ log_error("[Snort] Snort RELOAD CONFIG for {$snortcfg['descr']}({$if_real})...");
+ exec("/bin/pkill -SIGHUP -F {$g['varrun_path']}/snort_{$if_real}{$snort_uuid}.pid 2>&1 &");
+ }
}
function snort_get_friendly_interface($interface) {
@@ -394,8 +507,7 @@ function snort_get_real_interface($interface) {
this code block is for deleteing logs while keeping the newest file,
snort is linked to these files while running, do not take the easy way out
by touch and rm, snort will lose sync and not log.
-
- */
+*/
function snort_post_delete_logs($snort_uuid = 0) {
global $config, $g;
@@ -427,9 +539,15 @@ function snort_post_delete_logs($snort_uuid = 0) {
}
function snort_postinstall() {
- global $config, $g;
+ global $config, $g, $snort_rules_file, $emerging_threats_version;
+ global $snort_version, $rebuild_rules, $is_postinstall;
$snortdir = SNORTDIR;
+ $snortlibdir = SNORTLIBDIR;
+ $rcdir = RCFILEPREFIX;
+
+ /* Set flag for post-install in progress */
+ $is_postinstall = true;
/* cleanup default files */
@rename("{$snortdir}/snort.conf-sample", "{$snortdir}/snort.conf");
@@ -440,25 +558,55 @@ function snort_postinstall() {
@rename("{$snortdir}/generators-sample", "{$snortdir}/generators");
@rename("{$snortdir}/reference.config-sample", "{$snortdir}/reference.config");
@rename("{$snortdir}/gen-msg.map-sample", "{$snortdir}/gen-msg.map");
- @unlink("{$snortdir}/sid");
- @unlink("/usr/local/etc/rc.d/snort");
- @unlink("/usr/local/etc/rc.d/barnyard2");
- /* remove example files */
- if (file_exists('/usr/local/lib/snort/dynamicrules/lib_sfdynamic_example_rule.so.0'))
- exec('rm /usr/local/lib/snort/dynamicrules/lib_sfdynamic_example*');
+ /* fix up the preprocessor rules filenames from a PBI package install */
+ $preproc_rules = array("decoder.rules", "preprocessor.rules", "sensitive-data.rules");
+ foreach ($preproc_rules as $file) {
+ if (file_exists("{$snortdir}/preproc_rules/{$file}-sample"))
+ @rename("{$snortdir}/preproc_rules/{$file}-sample", "{$snortdir}/preproc_rules/{$file}");
+ }
- if (file_exists('/usr/local/lib/snort/dynamicpreprocessor/lib_sfdynamic_preprocessor_example.so'))
- exec('/bin/rm /usr/local/lib/snort/dynamicpreprocessor/lib_sfdynamic_preprocessor_example*');
+ /* Remove any previously installed scripts since we rebuild them */
+ @unlink("{$snortdir}/sid");
+ @unlink("{$rcdir}/snort.sh");
+ @unlink("{$rcdir}/barnyard2");
+
+ /* remove example library files */
+ $files = glob("{$snortlibdir}/dynamicrules/*_example*");
+ foreach ($files as $f)
+ @unlink($f);
+ $files = glob("{$snortlibdir}/dynamicpreprocessor/*_example*");
+ foreach ($files as $f)
+ @unlink($f);
/* remake saved settings */
if ($config['installedpackages']['snortglobal']['forcekeepsettings'] == 'on') {
+ log_error(gettext("[Snort] Saved settings detected... rebuilding installation with saved settings..."));
update_status(gettext("Saved settings detected..."));
- update_output_window(gettext("Please wait... rebuilding files..."));
+ update_output_window(gettext("Please wait... rebuilding installation with saved settings..."));
+ log_error(gettext("[Snort] Downloading and updating configured rule types..."));
+ update_output_window(gettext("Please wait... downloading and updating configured rule types..."));
@include_once("/usr/local/pkg/snort/snort_check_for_rule_updates.php");
+ update_status(gettext("Generating snort.conf configuration file from saved settings..."));
+ $rebuild_rules = "on";
sync_snort_package_config();
- update_output_window(gettext("Finnished Rebuilding files..."));
+ $rebuild_rules = "off";
+ update_output_window(gettext("Finished rebuilding files..."));
+ log_error(gettext("[Snort] Finished rebuilding installation from saved settings..."));
+
+ /* Only try to start Snort if not in reboot */
+ if (!$g['booting']) {
+ update_status(gettext("Starting Snort using rebuilt configuration..."));
+ update_output_window(gettext("Please wait... while Snort is started..."));
+ log_error(gettext("[Snort] Starting Snort using rebuilt configuration..."));
+ update_output_window(gettext("Snort has been started using the rebuilt configuration..."));
+ start_service("snort");
+ }
}
+
+ /* Done with post-install, so clear flag */
+ $is_postinstall = false;
+ log_error(gettext("[Snort] Package post-installation tasks completed..."));
}
function snort_Getdirsize($node) {
@@ -592,17 +740,20 @@ function snort_rm_blocked_install_cron($should_install) {
}
switch($should_install) {
case true:
- if(!$is_installed) {
- $cron_item = array();
- $cron_item['minute'] = "$snort_rm_blocked_min";
- $cron_item['hour'] = "$snort_rm_blocked_hr";
- $cron_item['mday'] = "$snort_rm_blocked_mday";
- $cron_item['month'] = "$snort_rm_blocked_month";
- $cron_item['wday'] = "$snort_rm_blocked_wday";
- $cron_item['who'] = "root";
- $cron_item['command'] = "/usr/bin/nice -n20 /usr/local/sbin/expiretable -t $snort_rm_blocked_expire snort2c";
+ $cron_item = array();
+ $cron_item['minute'] = "$snort_rm_blocked_min";
+ $cron_item['hour'] = "$snort_rm_blocked_hr";
+ $cron_item['mday'] = "$snort_rm_blocked_mday";
+ $cron_item['month'] = "$snort_rm_blocked_month";
+ $cron_item['wday'] = "$snort_rm_blocked_wday";
+ $cron_item['who'] = "root";
+ $cron_item['command'] = "/usr/bin/nice -n20 /usr/local/sbin/expiretable -t $snort_rm_blocked_expire snort2c";
+
+ /* Add cron job if not already installed, else just update the existing one */
+ if (!$is_installed)
$config['cron']['item'][] = $cron_item;
- }
+ elseif ($is_installed)
+ $config['cron']['item'][$x] = $cron_item;
break;
case false:
if ($is_installed == true)
@@ -672,17 +823,20 @@ function snort_rules_up_install_cron($should_install) {
}
switch($should_install) {
case true:
- if(!$is_installed) {
- $cron_item = array();
- $cron_item['minute'] = "$snort_rules_up_min";
- $cron_item['hour'] = "$snort_rules_up_hr";
- $cron_item['mday'] = "$snort_rules_up_mday";
- $cron_item['month'] = "$snort_rules_up_month";
- $cron_item['wday'] = "$snort_rules_up_wday";
- $cron_item['who'] = "root";
- $cron_item['command'] = "/usr/bin/nice -n20 /usr/local/bin/php -f /usr/local/pkg/snort/snort_check_for_rule_updates.php >> /tmp/snort_update.log";
+ $cron_item = array();
+ $cron_item['minute'] = "$snort_rules_up_min";
+ $cron_item['hour'] = "$snort_rules_up_hr";
+ $cron_item['mday'] = "$snort_rules_up_mday";
+ $cron_item['month'] = "$snort_rules_up_month";
+ $cron_item['wday'] = "$snort_rules_up_wday";
+ $cron_item['who'] = "root";
+ $cron_item['command'] = "/usr/bin/nice -n20 /usr/local/bin/php -f /usr/local/pkg/snort/snort_check_for_rule_updates.php";
+
+ /* Add cron job if not already installed, else just update the existing one */
+ if (!$is_installed)
$config['cron']['item'][] = $cron_item;
- }
+ elseif ($is_installed)
+ $config['cron']['item'][$x] = $cron_item;
break;
case false:
if($is_installed == true)
@@ -693,13 +847,17 @@ function snort_rules_up_install_cron($should_install) {
/* Only run when all ifaces needed to sync. Expects filesystem rw */
function sync_snort_package_config() {
- global $config, $g;
+ global $config, $g, $flowbit_rules_file, $snort_enforcing_rules_file;
+ global $snort_version, $rebuild_rules, $is_postinstall;
+
+ $snortdir = SNORTDIR;
+ $rcdir = RCFILEPREFIX;
conf_mount_rw();
- /* do not start config build if rules is empty */
- if (!is_array($config['installedpackages']['snortglobal']) && !is_array($config['installedpackages']['snortglobal']['rule'])) {
- exec('/bin/rm /usr/local/etc/rc.d/snort.sh');
+ /* do not start config build if rules is empty or there are no Snort settings */
+ if (!is_array($config['installedpackages']['snortglobal']) || !is_array($config['installedpackages']['snortglobal']['rule'])) {
+ @unlink("{$rcdir}/snort.sh");
conf_mount_ro();
return;
}
@@ -708,10 +866,10 @@ function sync_snort_package_config() {
foreach ($snortconf as $value) {
$if_real = snort_get_real_interface($value['interface']);
- /* create snort configuration file */
+ /* create a snort.conf file for interface */
snort_generate_conf($value);
- /* create barnyard2 configuration file */
+ /* create barnyard2.conf file for interface */
if ($value['barnyard_enable'] == 'on')
snort_create_barnyard2_conf($value, $if_real);
}
@@ -730,7 +888,11 @@ function sync_snort_package_config() {
snort_rules_up_install_cron($snortglob['autorulesupdate7'] != "never_up" ? true : false);
configure_cron();
-
+
+ /* Do not attempt package sync if reinstalling package or booting */
+ if (!$is_postinstall && !$g['booting'])
+ snort_sync_on_changes();
+
conf_mount_ro();
}
@@ -748,7 +910,7 @@ function snort_build_sid_msg_map($rules_path, $sid_file) {
/* First check if we were passed a directory, a single file */
/* or an array of filenames to read. Set our $rule_files */
/* variable accordingly. If we can't figure it out, return */
- /* an empty rules map array. */
+ /* and don't write a sid_msg_map file. */
if (is_string($rules_path)) {
if (is_dir($rules_path))
$rule_files = glob($rules_path . "*.rules");
@@ -858,11 +1020,19 @@ function snort_merge_reference_configs($cfg_in, $cfg_out) {
/* Sort the new reference map. */
uksort($outMap,'strnatcasecmp');
+ /**********************************************************/
+ /* Do NOT write an empty references.config file, just */
+ /* exit instead. */
+ /**********************************************************/
+ if (empty($outMap))
+ return false;
+
/* Format and write it to the supplied output file. */
$format = "config reference: %-12s %s\n";
foreach ($outMap as $key=>$value)
$outMap[$key] = sprintf($format, $key, $value);
@file_put_contents($cfg_out, array_values($outMap));
+ return true;
}
function snort_merge_classification_configs($cfg_in, $cfg_out) {
@@ -895,11 +1065,19 @@ function snort_merge_classification_configs($cfg_in, $cfg_out) {
/* Sort the new classification map. */
uksort($outMap,'strnatcasecmp');
+ /**********************************************************/
+ /* Do NOT write an empty classification.config file, just */
+ /* exit instead. */
+ /**********************************************************/
+ if (empty($outMap))
+ return false;
+
/* Format and write it to the supplied output file. */
$format = "config classification: %s,%s\n";
foreach ($outMap as $key=>$value)
$outMap[$key] = sprintf($format, $key, $value);
@file_put_contents($cfg_out, array_values($outMap));
+ return true;
}
function snort_load_rules_map($rules_path) {
@@ -1013,8 +1191,13 @@ function snort_load_rules_map($rules_path) {
}
$gid = snort_get_gid($rule);
+ if (!is_array($map_ref[$gid]))
+ $map_ref[$gid] = array();
+ if (!is_array($map_ref[$gid][$sid]))
+ $map_ref[$gid][$sid] = array();
$map_ref[$gid][$sid]['rule'] = $rule;
$map_ref[$gid][$sid]['category'] = basename($file, ".rules");
+
if (preg_match('/^\s*\#+/', $rule))
$map_ref[$gid][$sid]['disabled'] = 1;
else
@@ -1077,20 +1260,35 @@ function snort_get_flowbits($rule) {
/*************************************************************/
/* This will pull out "flowbits:" options from the rule text */
- /* and return them in an array. */
+ /* and return them in an array (minus the "flowbits:" part). */
/*************************************************************/
$flowbits = array();
- if (preg_match_all('/flowbits\b:\s*(set|setx|unset|toggle|isset|isnotset)\s*,([^;]+)/i', $rule, $matches)) {
+
+ /* Grab any "flowbits:set, setx, unset, isset or toggle" options first. */
+ /* Examine flowbits targets for logical operators to capture all targets */
+ if (preg_match_all('/flowbits\b\s*:\s*(set|setx|unset|toggle|isset|isnotset)\s*,([^;]+)/i', $rule, $matches)) {
$i = -1;
while (++$i < count($matches[1])) {
- $flowbits[] = trim($matches[1][$i]) ."," . trim($matches[2][$i]);
+ $action = trim($matches[1][$i]);
+ $target = preg_split('/[&|]/', $matches[2][$i]);
+ foreach ($target as $t)
+ $flowbits[] = "{$action}," . trim($t);
}
}
+
+ /* Include the "flowbits:noalert or reset" options, if present. */
+ if (preg_match_all('/flowbits\b\s*:\s*(noalert|reset)\b/i', $rule, $matches)) {
+ $i = -1;
+ while (++$i < count($matches[1])) {
+ $flowbits[] = trim($matches[1][$i]);
+ }
+ }
+
return $flowbits;
}
-function snort_get_checked_flowbits(&$rules_map) {
+function snort_get_checked_flowbits($rules_map) {
/*************************************************************/
/* This function checks all the currently enabled rules to */
@@ -1114,11 +1312,16 @@ function snort_get_checked_flowbits(&$rules_map) {
foreach ($rulem2['flowbits'] as $flowbit) {
if (empty($flowbit))
continue;
- $action = substr($flowbit, 0, strpos($flowbit, ","));
- if (preg_match('/is(not)?set/i', $action)) {
- $tmp = substr($flowbit, strpos($flowbit, ",") +1 );
- if (!empty($tmp) && !in_array($tmp, $checked_flowbits))
- $checked_flowbits[] = $tmp;
+ /* If no comma in flowbits option, then skip it. */
+ $pos = strpos($flowbit, ",");
+ if ($pos === false)
+ continue;
+ $action = substr(strtolower($flowbit), 0, $pos);
+ if ($action == "isset" || $action == "isnotset") {
+ $target = preg_split('/[&|]/', substr($flowbit, $pos + 1));
+ foreach ($target as $t)
+ if (!empty($t) && !isset($checked_flowbits[$t]))
+ $checked_flowbits[$t] = $action;
}
}
}
@@ -1128,7 +1331,7 @@ function snort_get_checked_flowbits(&$rules_map) {
return $checked_flowbits;
}
-function snort_get_set_flowbits(&$rules_map) {
+function snort_get_set_flowbits($rules_map) {
/*********************************************************/
/* This function checks all the currently enabled rules */
@@ -1150,11 +1353,16 @@ function snort_get_set_flowbits(&$rules_map) {
foreach ($rulem2['flowbits'] as $flowbit) {
if (empty($flowbit))
continue;
- $action = substr($flowbit, 0, strpos($flowbit, ","));
- if (preg_match('/^set/i', $action)) {
- $tmp = substr($flowbit, strpos($flowbit, ",") +1 );
- if (!empty($tmp) && !in_array($tmp, $set_flowbits))
- $set_flowbits[] = $tmp;
+ /* If no comma in flowbits option, then skip it. */
+ $pos = strpos($flowbit, ",");
+ if ($pos === false)
+ continue;
+ $action = substr(strtolower($flowbit), 0, $pos);
+ if ($action == "set" || $action == "toggle" || $action == "setx") {
+ $target = preg_split('/[&|]/', substr($flowbit, $pos + 1));
+ foreach ($target as $t)
+ if (!empty($t) && !isset($set_flowbits[$t]))
+ $set_flowbits[$t] = $action;
}
}
}
@@ -1164,7 +1372,7 @@ function snort_get_set_flowbits(&$rules_map) {
return $set_flowbits;
}
-function snort_find_flowbit_required_rules(&$all_rules, &$unchecked_flowbits) {
+function snort_find_flowbit_required_rules($all_rules, $unchecked_flowbits) {
/********************************************************/
/* This function finds all rules that must be enabled */
@@ -1188,7 +1396,7 @@ function snort_find_flowbit_required_rules(&$all_rules, &$unchecked_flowbits) {
$action = substr($flowbit, 0, strpos($flowbit, ","));
if (!strcasecmp(substr($action, 0, 3), "set")) {
$tmp = substr($flowbit, strpos($flowbit, ",") +1 );
- if (!empty($tmp) && in_array($tmp, $unchecked_flowbits)) {
+ if (!empty($tmp) && isset($unchecked_flowbits[$tmp])) {
if (!is_array($required_flowbits_rules[$k1]))
$required_flowbits_rules[$k1] = array();
if (!is_array($required_flowbits_rules[$k1][$k2]))
@@ -1212,7 +1420,7 @@ function snort_find_flowbit_required_rules(&$all_rules, &$unchecked_flowbits) {
return $required_flowbits_rules;
}
-function snort_resolve_flowbits($rule_path) {
+function snort_resolve_flowbits($active_rules) {
/******************************************************/
/* This function auto-resolves flowbit requirements */
@@ -1222,31 +1430,32 @@ function snort_resolve_flowbits($rule_path) {
/* enabled. For any that are not enabled, they are */
/* copied to an array, enabled, and returned. */
/* */
- /* $rule_path --> rules files of the interface */
- /* to resolve flowbit dependencies */
- /* for. This can be either of the */
- /* following: */
- /* - directory of *.rules files */
- /* - array of *.rules filenames */
- /* - a single *.rules filename */
+ /* $active_rules --> Rules Map array containing */
+ /* the current rules for the */
+ /* interface to resolve flowbit */
+ /* dependencies for. */
+ /* */
+ /* NOTE: this function assumes the global variable */
+ /* $all_rules is populated with all the rules */
+ /* currently downloaded. */
/******************************************************/
+ global $all_rules;
$snortdir = SNORTDIR;
- /* First, load up all the enabled rules. */
- $rules_map = snort_load_rules_map($rule_path);
-
- /* Next, find all the "checked" and "set" flowbits. */
- $checked_flowbits = snort_get_checked_flowbits($rules_map);
- $set_flowbits = snort_get_set_flowbits($rules_map);
+ /* Check $all_rules array to be sure it is filled. */
+ if (empty($all_rules)) {
+ log_error(gettext("[Snort] WARNING: Flowbit resolution not done - no rules in {$snortdir}/rules/ ..."));
+ return array();
+ }
- /* We're done with the first rules array, so cleanup */
- /* to conserve memory. */
- unset($rules_map);
+ /* First, find all the "checked" and "set" flowbits. */
+ $checked_flowbits = snort_get_checked_flowbits($active_rules);
+ $set_flowbits = snort_get_set_flowbits($active_rules);
/* Next find any "checked" flowbits without matching */
/* "set" flowbit rules in the enabled rule set. */
- $delta_flowbits = array_diff($checked_flowbits, $set_flowbits);
+ $delta_flowbits = array_diff_key($checked_flowbits, $set_flowbits);
/* Cleanup and release the memory we no longer need. */
unset($checked_flowbits);
@@ -1254,11 +1463,9 @@ function snort_resolve_flowbits($rule_path) {
/* Now find all the needed "set flowbit" rules from */
/* the master list of all rules. */
- $all_rules_map = snort_load_rules_map("{$snortdir}/rules/");
- $required_rules = snort_find_flowbit_required_rules($all_rules_map, $delta_flowbits);
+ $required_rules = snort_find_flowbit_required_rules($all_rules, $delta_flowbits);
/* Cleanup and release memory we no longer need. */
- unset($all_rules_map);
unset($delta_flowbits);
return $required_rules;
@@ -1272,11 +1479,13 @@ function snort_write_flowbit_rules_file($flowbit_rules, $rule_file) {
/* given. */
/************************************************/
+ global $flowbit_rules_file;
+
/* See if we were passed a directory or full */
/* filename to write the rules to, and adjust */
/* the destination argument accordingly. */
if (is_dir($rule_file))
- $rule_file = rtrim($rule_file, '/').'/flowbit-required.rules';
+ $rule_file = rtrim($rule_file, '/')."/{$flowbit_rules_file}";
if (empty($flowbit_rules)) {
@file_put_contents($rule_file, "");
@@ -1302,7 +1511,7 @@ function snort_write_flowbit_rules_file($flowbit_rules, $rule_file) {
}
}
-function snort_load_vrt_policy($policy) {
+function snort_load_vrt_policy($policy, $load_rules_map=true) {
/************************************************/
/* This function returns an array of all rules */
@@ -1312,23 +1521,32 @@ function snort_load_vrt_policy($policy) {
/* 1. connectivity */
/* 2. balanced */
/* 3. security */
+ /* */
+ /* $load_rules --> load a local copy of all */
+ /* the rules if true. If */
+ /* false, assume the global */
+ /* $all_rules array is valid. */
/************************************************/
+ global $all_rules;
$snortdir = SNORTDIR;
$vrt_policy_rules = array();
- /* Create regular expression for searching. */
- $policy_pcre = "/policy\\s" . $policy . "/i";
-
- /* First, load up all the rules we have. */
- $all_rules_map = snort_load_rules_map("{$snortdir}/rules/");
+ /* Refresh the map of all the rules if flag */
+ /* is set. */
+ if ($load_rules_map) {
+ /* Since only Snort VRT rules have IPS Policy metadata, */
+ /* limit our search to just those files. */
+ $snort_vrt_files = glob("{$snortdir}/rules/snort_*.rules");
+ $all_rules = array();
+ $all_rules = snort_load_rules_map($snort_vrt_files);
+ }
- /* Now walk the rules list and find all those */
- /* that are defined as active for the chosen */
- /* security policy. */
- foreach ($all_rules_map as $k1 => $arulem) {
+ /* Now walk the rules list and find all those that are defined */
+ /* defined as active for the chosen security policy. */
+ foreach ($all_rules as $k1 => $arulem) {
foreach ($arulem as $k2 => $arulem2) {
- if (preg_match($policy_pcre, $arulem2['rule'])) {
+ if (strripos($arulem2['rule'], "policy {$policy}-ips") !== false) {
if (!preg_match('/flowbits\s*:\s*noalert/i', $arulem2['rule'])) {
if (!is_array($vrt_policy_rules[$k1]))
$vrt_policy_rules[$k1] = array();
@@ -1347,7 +1565,12 @@ function snort_load_vrt_policy($policy) {
}
/* Release memory we no longer need. */
- unset($all_rules_map, $arulem, $arulem2);
+ unset($arulem, $arulem2);
+
+ /* If we loaded the ALL_RULES map, */
+ /* then release the global memory. */
+ if ($load_rules_map == true)
+ unset($GLOBALS['all_rules']);
/* Return all the rules that match the policy. */
return $vrt_policy_rules;
@@ -1363,7 +1586,7 @@ function snort_write_enforcing_rules_file($rule_map, $rule_path) {
global $snort_enforcing_rules_file;
- $rule_file = "/snort.rules";
+ $rule_file = "/{$snort_enforcing_rules_file}";
/* See if we were passed a directory or full */
/* filename to write the rules to, and adjust */
@@ -1389,6 +1612,9 @@ function snort_write_enforcing_rules_file($rule_map, $rule_path) {
@fwrite($fp, "# to the rules in this file.\n\n");
foreach ($rule_map as $rulem) {
foreach ($rulem as $rulem2) {
+ /* No reason to write disabled rules to enforcing file, so skip them. */
+ if ($rulem2['disabled'] == 1)
+ continue;
@fwrite($fp, $rulem2['rule']);
}
}
@@ -1402,9 +1628,17 @@ function snort_load_sid_mods($sids, $value) {
/* This function parses the string of */
/* SID values in $sids and returns an */
/* array with the SID as the key and */
- /* passed $value as the value. The SID */
- /* values in $sids are assumed to be */
- /* delimited by "||". */
+ /* value. The SID values in $sids are */
+ /* assumed to be delimited by "||". */
+ /* */
+ /* $sids ==> string of SID values from */
+ /* saved config file. */
+ /* */
+ /* $value ==> type of mod (enable or */
+ /* disable). Not currently */
+ /* utilized, but maintained */
+ /* so as not to break legacy */
+ /* code elsewhere. */
/*****************************************/
$result = array();
@@ -1413,7 +1647,7 @@ function snort_load_sid_mods($sids, $value) {
$tmp = explode("||", $sids);
foreach ($tmp as $v) {
if (preg_match('/\s\d+/', $v, $match))
- $result[trim($match[0])] = $value;
+ $result[trim($match[0])] = trim($match[0]);
}
unset($tmp);
@@ -1458,14 +1692,13 @@ function snort_modify_sids(&$rule_map, $snortcfg) {
if (!empty($disablesid)) {
foreach ($rule_map as $k1 => $rulem) {
foreach ($rulem as $k2 => $v) {
- if (in_array($k2, $disablesid) && $v['disabled'] == 0) {
+ if (in_array($k2, $disablesid) && $v['disabled'] == 0) {
$rule_map[$k1][$k2]['rule'] = "# " . $v['rule'];
$rule_map[$k1][$k2]['disabled'] = 1;
}
}
}
}
-
unset($enablesid, $disablesid);
}
@@ -1475,6 +1708,7 @@ function snort_create_rc() {
global $config, $g;
$snortdir = SNORTDIR;
+ $rcdir = RCFILEPREFIX;
if (!is_array($config['installedpackages']['snortglobal']['rule']))
return;
@@ -1493,23 +1727,59 @@ function snort_create_rc() {
$start_barnyard = <<<EOE
if [ ! -f {$g['varrun_path']}/barnyard2_{$if_real}{$snort_uuid}.pid ]; then
- /bin/pgrep -xf '/usr/local/bin/barnyard2 -r {$snort_uuid} -f snort_{$snort_uuid}_{$if_real}.u2 --pid-path {$g['varrun_path']} --nolock-pidfile -c {$snortdir}/snort_{$snort_uuid}_{$if_real}/barnyard2.conf -d /var/log/snort/snort_{$if_real}{$snort_uuid} -D -q' > {$g['varrun_path']}/barnyard2_{$if_real}{$snort_uuid}.pid
- fi
- /bin/pgrep -F {$g['varrun_path']}/barnyard2_{$if_real}{$snort_uuid}.pid
- if [ $? = 0 ]; then
- /bin/pkill -HUP -F {$g['varrun_path']}/barnyard2_{$if_real}{$snort_uuid}.pid -a
+ pid=`/bin/pgrep -xf '/usr/local/bin/barnyard2 -r {$snort_uuid} -f snort_{$snort_uuid}_{$if_real}.u2 --pid-path {$g['varrun_path']} --nolock-pidfile -c {$snortdir}/snort_{$snort_uuid}_{$if_real}/barnyard2.conf -d /var/log/snort/snort_{$if_real}{$snort_uuid} -D -q' > {$g['varrun_path']}/barnyard2_{$if_real}{$snort_uuid}.pid`
else
- /usr/local/bin/barnyard2 -r {$snort_uuid} -f snort_{$snort_uuid}_{$if_real}.u2 --pid-path {$g['varrun_path']} --nolock-pidfile -c {$snortdir}/snort_{$snort_uuid}_{$if_real}/barnyard2.conf -d /var/log/snort/snort_{$if_real}{$snort_uuid} -D -q
+ pid=`/bin/pgrep -F {$g['varrun_path']}/barnyard2_{$if_real}{$snort_uuid}.pid`
fi
+ if [ ! -z \$pid ]; then
+ /usr/bin/logger -p daemon.info -i -t SnortStartup "Barnyard2 STOP for {$value['descr']}({$snort_uuid}_{$if_real})..."
+ /bin/pkill $pid -a
+ time=0 timeout=30
+ while kill -0 \$pid 2>/dev/null; do
+ sleep 1
+ time=\$((time+1))
+ if [ \$time -gt \$timeout ]; then
+ break
+ fi
+ done
+ if [ -f /var/run/barnyard2_{$if_real}{$snort_uuid}.pid ]; then
+ /bin/rm /var/run/barnyard2_{$if_real}{$snort_uuid}.pid
+ fi
+ fi
+ /usr/bin/logger -p daemon.info -i -t SnortStartup "Barnyard2 START for {$value['descr']}({$snort_uuid}_{$if_real})..."
+ /usr/local/bin/barnyard2 -r {$snort_uuid} -f snort_{$snort_uuid}_{$if_real}.u2 --pid-path {$g['varrun_path']} --nolock-pidfile -c {$snortdir}/snort_{$snort_uuid}_{$if_real}/barnyard2.conf -d /var/log/snort/snort_{$if_real}{$snort_uuid} -D -q
EOE;
$stop_barnyard2 = <<<EOE
if [ -f {$g['varrun_path']}/barnyard2_{$if_real}{$snort_uuid}.pid ]; then
+ /usr/bin/logger -p daemon.info -i -t SnortStartup "Barnyard2 STOP for {$value['descr']}({$snort_uuid}_{$if_real})..."
+ pid=`/bin/pgrep -F {$g['varrun_path']}/barnyard2_{$if_real}{$snort_uuid}.pid`
/bin/pkill -F {$g['varrun_path']}/barnyard2_{$if_real}{$snort_uuid}.pid -a
- /bin/rm /var/run/barnyard2_{$if_real}{$snort_uuid}.pid
+ time=0 timeout=30
+ while kill -0 \$pid 2>/dev/null; do
+ sleep 1
+ time=\$((time+1))
+ if [ \$time -gt \$timeout ]; then
+ break
+ fi
+ done
+ if [ -f /var/run/barnyard2_{$if_real}{$snort_uuid}.pid ]; then
+ /bin/rm /var/run/barnyard2_{$if_real}{$snort_uuid}.pid
+ fi
else
- /bin/pkill -xf '/usr/local/bin/barnyard2 -r {$snort_uuid} -f snort_{$snort_uuid}_{$if_real}.u2 --pid-path {$g['varrun_path']} --nolock-pidfile -c {$snortdir}/snort_{$snort_uuid}_{$if_real}/barnyard2.conf -d /var/log/snort/snort_{$if_real}{$snort_uuid} -D -q'
+ pid=`/bin/pgrep -xf '/usr/local/bin/barnyard2 -r {$snort_uuid} -f snort_{$snort_uuid}_{$if_real}.u2 --pid-path {$g['varrun_path']} --nolock-pidfile -c {$snortdir}/snort_{$snort_uuid}_{$if_real}/barnyard2.conf -d /var/log/snort/snort_{$if_real}{$snort_uuid} -D -q'`
+ if [ ! -z \$pid ]; then
+ /bin/pkill -xf '/usr/local/bin/barnyard2 -r {$snort_uuid} -f snort_{$snort_uuid}_{$if_real}.u2 --pid-path {$g['varrun_path']} --nolock-pidfile -c {$snortdir}/snort_{$snort_uuid}_{$if_real}/barnyard2.conf -d /var/log/snort/snort_{$if_real}{$snort_uuid} -D -q'
+ time=0 timeout=30
+ while kill -0 \$pid 2>/dev/null; do
+ sleep 1
+ time=\$((time+1))
+ if [ \$time -gt \$timeout ]; then
+ break
+ fi
+ done
+ fi
fi
EOE;
@@ -1521,19 +1791,18 @@ EOE;
$start_snort_iface_start[] = <<<EOE
###### For Each Iface
-#### Only try to restart if snort is running on Iface
+ # Start snort and barnyard2
if [ ! -f {$g['varrun_path']}/snort_{$if_real}{$snort_uuid}.pid ]; then
- /bin/pgrep -xf '/usr/local/bin/snort -R {$snort_uuid} -D -q -l /var/log/snort/snort_{$if_real}{$snort_uuid} --pid-path {$g['varrun_path']} --nolock-pidfile -G {$snort_uuid} -c {$snortdir}/snort_{$snort_uuid}_{$if_real}/snort.conf -i {$if_real}' > {$g['varrun_path']}/snort_{$if_real}{$snort_uuid}.pid
+ pid=`/bin/pgrep -xf '/usr/local/bin/snort -R {$snort_uuid} -D -q -l /var/log/snort/snort_{$if_real}{$snort_uuid} --pid-path {$g['varrun_path']} --nolock-pidfile -G {$snort_uuid} -c {$snortdir}/snort_{$snort_uuid}_{$if_real}/snort.conf -i {$if_real}'`
+ else
+ pid=`/bin/pgrep -F {$g['varrun_path']}/snort_{$if_real}{$snort_uuid}.pid`
fi
- /bin/pgrep -nF {$g['varrun_path']}/snort_{$if_real}{$snort_uuid}.pid
- if [ $? = 0 ]; then
- /bin/pkill -HUP -F {$g['varrun_path']}/snort_{$if_real}{$snort_uuid}.pid -a
- /usr/bin/logger -p daemon.info -i -t SnortStartup "Snort SOFT START For {$value['descr']}({$snort_uuid}_{$if_real})..."
+ if [ ! -z \$pid ]; then
+ /usr/bin/logger -p daemon.info -i -t SnortStartup "Snort SOFT RESTART for {$value['descr']}({$snort_uuid}_{$if_real})..."
+ /bin/pkill -HUP \$pid
else
- # Start snort and barnyard2
- /bin/rm {$g['varrun_path']}/snort_{$if_real}{$snort_uuid}.pid
+ /usr/bin/logger -p daemon.info -i -t SnortStartup "Snort START for {$value['descr']}({$snort_uuid}_{$if_real})..."
/usr/local/bin/snort -R {$snort_uuid} -D -q -l /var/log/snort/snort_{$if_real}{$snort_uuid} --pid-path {$g['varrun_path']} --nolock-pidfile -G {$snort_uuid} -c {$snortdir}/snort_{$snort_uuid}_{$if_real}/snort.conf -i {$if_real}
- /usr/bin/logger -p daemon.info -i -t SnortStartup "Snort START For {$value['descr']}({$snort_uuid}_{$if_real})..."
fi
sleep 2
@@ -1543,12 +1812,35 @@ EOE;
$start_snort_iface_stop[] = <<<EOE
- /usr/bin/logger -p daemon.info -i -t SnortStartup "Snort STOP For {$value['descr']}({$snort_uuid}_{$if_real})..."
if [ -f {$g['varrun_path']}/snort_{$if_real}{$snort_uuid}.pid ]; then
+ pid=`/bin/pgrep -F {$g['varrun_path']}/snort_{$if_real}{$snort_uuid}.pid`
+ /usr/bin/logger -p daemon.info -i -t SnortStartup "Snort STOP for {$value['descr']}({$snort_uuid}_{$if_real})..."
/bin/pkill -F {$g['varrun_path']}/snort_{$if_real}{$snort_uuid}.pid -a
- /bin/rm /var/run/snort_{$if_real}{$snort_uuid}.pid
- else
- /bin/pkill -xf '/usr/local/bin/snort -R {$snort_uuid} -D -q -l /var/log/snort/snort_{$if_real}{$snort_uuid} --pid-path {$g['varrun_path']} --nolock-pidfile -G {$snort_uuid} -c {$snortdir}/snort_{$snort_uuid}_{$if_real}/snort.conf -i {$if_real}'
+ time=0 timeout=30
+ while kill -0 \$pid 2>/dev/null; do
+ sleep 1
+ time=\$((time+1))
+ if [ \$time -gt \$timeout ]; then
+ break
+ fi
+ done
+ if [ -f /var/run/snort_{$if_real}{$snort_uuid}.pid ]; then
+ /bin/rm /var/run/snort_{$if_real}{$snort_uuid}.pid
+ fi
+ else
+ pid=`/bin/pgrep -xf '/usr/local/bin/snort -R {$snort_uuid} -D -q -l /var/log/snort/snort_{$if_real}{$snort_uuid} --pid-path {$g['varrun_path']} --nolock-pidfile -G {$snort_uuid} -c {$snortdir}/snort_{$snort_uuid}_{$if_real}/snort.conf -i {$if_real}'`
+ if [ ! -z \$pid ]; then
+ /usr/bin/logger -p daemon.info -i -t SnortStartup "Snort STOP for {$value['descr']}({$snort_uuid}_{$if_real})..."
+ /bin/pkill -xf '/usr/local/bin/snort -R {$snort_uuid} -D -q -l /var/log/snort/snort_{$if_real}{$snort_uuid} --pid-path {$g['varrun_path']} --nolock-pidfile -G {$snort_uuid} -c {$snortdir}/snort_{$snort_uuid}_{$if_real}/snort.conf -i {$if_real}'
+ time=0 timeout=30
+ while kill -0 \$pid 2>/dev/null; do
+ sleep 1
+ time=\$((time+1))
+ if [ \$time -gt \$timeout ]; then
+ break
+ fi
+ done
+ fi
fi
sleep 2
@@ -1584,6 +1876,7 @@ case $1 in
rc_stop
;;
restart)
+ rc_stop
rc_start
;;
esac
@@ -1591,11 +1884,11 @@ esac
EOD;
/* write out snort.sh */
- if (!@file_put_contents("/usr/local/etc/rc.d/snort.sh", $snort_sh_text)) {
- log_error("Could not open /usr/local/etc/rc.d/snort.sh for writing.");
+ if (!@file_put_contents("{$rcdir}/snort.sh", $snort_sh_text)) {
+ log_error("Could not open {$rcdir}/snort.sh for writing.");
return;
}
- @chmod("/usr/local/etc/rc.d/snort.sh", 0755);
+ @chmod("{$rcdir}/snort.sh", 0755);
}
/* open barnyard2.conf for writing */
@@ -1642,13 +1935,16 @@ function snort_generate_barnyard2_conf($snortcfg, $if_real) {
config reference_file: {$snortdir}/snort_{$snort_uuid}_{$if_real}/reference.config
config classification_file: {$snortdir}/snort_{$snort_uuid}_{$if_real}/classification.config
config gen_file: {$snortdir}/snort_{$snort_uuid}_{$if_real}/gen-msg.map
-config sid_file: {$snortdir}/snort_{$snort_uuid}_{$if_real}/sid-msg.map
+config sid_file: {$snortdir}/snort_{$snort_uuid}_{$if_real}/sid-msg.map
config hostname: $snortbarnyardlog_hostname_info_chk
config interface: {$if_real}
config decode_data_link
config waldo_file: /var/log/snort/snort_{$if_real}{$snort_uuid}/barnyard2/{$snort_uuid}_{$if_real}.waldo
+# Show year in timestamps
+config show_year
+
## START user pass through ##
{$snortbarnyardlog_config_pass_thru}
@@ -1671,23 +1967,38 @@ EOD;
}
function snort_deinstall() {
- global $config, $g;
+
+ global $config, $g, $snort_rules_upd_log;
$snortdir = SNORTDIR;
+ $snortlibdir = SNORTLIBDIR;
$snortlogdir = SNORTLOGDIR;
+ $rcdir = RCFILEPREFIX;
+
+ log_error(gettext("[Snort] Snort package uninstall in progress..."));
- /* decrease bpf buffers back to 4096, from 20480 */
+ /* Make sure all active Snort processes are terminated */
+ /* Log a message only if a running process is detected */
+ if (is_service_running("snort"))
+ log_error(gettext("[Snort] Snort STOP for all interfaces..."));
mwexec('/usr/bin/killall snort', true);
sleep(2);
mwexec('/usr/bin/killall -9 snort', true);
sleep(2);
+
+ /* Make sure all active Barnyard2 processes are terminated */
+ /* Log a message only if a running process is detected */
+ if (is_service_running("barnyard2"))
+ log_error(gettext("[Snort] Barnyard2 STOP for all interfaces..."));
mwexec('/usr/bin/killall barnyard2', true);
sleep(2);
mwexec('/usr/bin/killall -9 barnyard2', true);
sleep(2);
+
+ /* Remove the snort user and group */
mwexec('/usr/sbin/pw userdel snort; /usr/sbin/pw groupdel snort', true);
- /* Remove snort cron entries Ugly code needs smoothness*/
+ /* Remove snort cron entries Ugly code needs smoothness */
if (!function_exists('snort_deinstall_cron')) {
function snort_deinstall_cron($crontask) {
global $config, $g;
@@ -1709,52 +2020,106 @@ function snort_deinstall() {
}
}
- mwexec("/bin/rm {$snortdir}/*.md5; /bin/rm -r {$snortdir}/snort_*");
+ /* Remove all the Snort cron jobs. */
snort_deinstall_cron("snort2c");
snort_deinstall_cron("snort_check_for_rule_updates.php");
snort_deinstall_cron("snort_check_cron_misc.inc");
configure_cron();
+ /**********************************************************/
+ /* Test for existence of library backup tarballs in /tmp. */
+ /* If these are present, then a package "delete" */
+ /* operation is in progress and we need to wipe out the */
+ /* configuration files. Otherwise we leave the binary- */
+ /* side configuration intact since only a GUI files */
+ /* deinstall and reinstall operation is in progress. */
+ /* */
+ /* XXX: hopefully a better method presents itself in */
+ /* future versions of pfSense. */
+ /**********************************************************/
+ if (file_exists("/tmp/pkg_libs.tgz") || file_exists("/tmp/pkg_bins.tgz")) {
+ log_error(gettext("[Snort] Package deletion requested... removing all files..."));
+ mwexec("/bin/rm -rf {$snortdir}");
+ mwexec("/bin/rm -rf {$snortlibdir}/dynamicrules");
+ mwexec("/bin/rm -f {$rcdir}/snort.sh");
+ mwexec("/bin/rm -rf /usr/local/pkg/snort");
+ mwexec("/bin/rm -rf /usr/local/www/snort");
+ mwexec("/bin/rm -rf /usr/local/etc/snort");
+ }
+
/* Keep this as a last step */
- if ($config['installedpackages']['snortglobal']['forcekeepsettings'] != 'on')
+ if ($config['installedpackages']['snortglobal']['forcekeepsettings'] != 'on') {
+ log_error(gettext("Not saving settings... all Snort configuration info and logs deleted..."));
unset($config['installedpackages']['snortglobal']);
+ unset($config['installedpackages']['snortsync']);
+ @unlink("{$snort_rules_upd_log}");
+ mwexec("/bin/rm -rf {$snortlogdir}");
+ log_error(gettext("[Snort] The package has been removed from this system..."));
+ }
}
function snort_prepare_rule_files($snortcfg, $snortcfgdir) {
- global $snort_enforcing_rules_file, $flowbit_rules_file;
+
+ global $snort_enforcing_rules_file, $flowbit_rules_file, $rebuild_rules, $all_rules;
$snortdir = SNORTDIR;
+ $no_rules_defined = true;
+
+ /* If there is no reason to rebuild the rules, exit to save time. */
+ if ($rebuild_rules == "off")
+ return;
+ /* Log a message for rules rebuild in progress */
+ log_error(gettext("[Snort] Updating rules configuration for: " . snort_get_friendly_interface($snortcfg['interface']) . " ..."));
+
+ /* Only rebuild rules if some are selected or an IPS Policy is enabled */
if (!empty($snortcfg['rulesets']) || $snortcfg['ips_policy_enable'] == 'on') {
$enabled_rules = array();
$enabled_files = array();
+ $no_rules_defined = false;
+
+ /* Load up all the rules into a Rules Map array. */
+ $all_rules = array();
+ $all_rules = snort_load_rules_map("{$snortdir}/rules/");
- /* Create an array with the full path filenames of the enabled */
- /* rule category files if we have any. */
+ /* Create an array with the filenames of the enabled */
+ /* rule category files if we have any. */
if (!empty($snortcfg['rulesets'])) {
- foreach (explode("||", $snortcfg['rulesets']) as $file) {
- if (file_exists("{$snortdir}/rules/{$file}"))
- $enabled_files[] = "{$snortdir}/rules/{$file}";
+ foreach (explode("||", $snortcfg['rulesets']) as $file){
+ $category = basename($file, ".rules");
+ if (!is_array($enabled_files[$category]))
+ $enabled_files[$category] = array();
+ $enabled_files[$category] = $file;
}
- /* Load our rules map in preparation for writing the enforcing rules file. */
- $enabled_rules = snort_load_rules_map($enabled_files);
- }
+ /****************************************************/
+ /* Walk the ALL_RULES map array and copy the rules */
+ /* matching our selected file categories to the */
+ /* ENABLED_RULES map array. */
+ /****************************************************/
+ foreach ($all_rules as $k1 => $rulem) {
+ foreach ($rulem as $k2 => $v) {
+ if (isset($enabled_files[$v['category']])) {
+ if (!is_array($enabled_rules[$k1]))
+ $enabled_rules[$k1] = array();
+ if (!is_array($enabled_rules[$k1][$k2]))
+ $enabled_rules[$k1][$k2] = array();
+ $enabled_rules[$k1][$k2]['rule'] = $v['rule'];
+ $enabled_rules[$k1][$k2]['category'] = $v['category'];
+ $enabled_rules[$k1][$k2]['disabled'] = $v['disabled'];
+ $enabled_rules[$k1][$k2]['flowbits'] = $v['flowbits'];
+ }
+ }
+ }
- /* Remove any existing rules files (except custom rules) prior to building a new set. */
- foreach (glob("{$snortcfgdir}/rules/*.rules") as $file) {
- $tmpfile = basename($file);
- if (in_array("{$snortdir}/rules/{$tmpfile}", $enabled_files))
- continue;
- if ($tmpfile != "custom.rules" && $tmpfile != $flowbit_rules_file &&
- $tmpfile != $snort_enforcing_rules_file)
- @unlink($file);
+ /* Release memory we no longer need. */
+ unset($enabled_files, $rulem, $v);
}
/* Check if a pre-defined Snort VRT policy is selected. If so, */
/* add all the VRT policy rules to our enforcing rule set. */
if (!empty($snortcfg['ips_policy'])) {
- $policy_rules = snort_load_vrt_policy($snortcfg['ips_policy']);
+ $policy_rules = snort_load_vrt_policy($snortcfg['ips_policy'], false);
foreach ($policy_rules as $k1 => $policy) {
foreach ($policy as $k2 => $p) {
if (!is_array($enabled_rules[$k1]))
@@ -1767,46 +2132,63 @@ function snort_prepare_rule_files($snortcfg, $snortcfgdir) {
$enabled_rules[$k1][$k2]['flowbits'] = $p['flowbits'];
}
}
- unset($policy_rules);
+ unset($policy_rules, $policy, $p);
}
/* Process any enablesid or disablesid modifications for the selected rules. */
snort_modify_sids($enabled_rules, $snortcfg);
- /* Check for and disable any rules dependent upon disabled preprocessors. */
- log_error('Checking for and disabling any rules dependent upon disabled preprocessors for ' . snort_get_friendly_interface($snortcfg['interface']) . '...');
- snort_filter_preproc_rules($snortcfg, $enabled_rules);
+ /* Check for and disable any rules dependent upon disabled preprocessors if */
+ /* this option is enabled for the interface. */
+ if ($snortcfg['preproc_auto_rule_disable'] == "on") {
+ log_error('[Snort] Checking for rules dependent on disabled preprocessors for: ' . snort_get_friendly_interface($snortcfg['interface']) . '...');
+ snort_filter_preproc_rules($snortcfg, $enabled_rules);
+ }
/* Write the enforcing rules file to the Snort interface's "rules" directory. */
snort_write_enforcing_rules_file($enabled_rules, "{$snortcfgdir}/rules/{$snort_enforcing_rules_file}");
- unset($enabled_rules);
/* If auto-flowbit resolution is enabled, generate the dependent flowbits rules file. */
if ($snortcfg['autoflowbitrules'] == 'on') {
- log_error('Resolving and auto-enabling flowbit required rules for ' . snort_get_friendly_interface($snortcfg['interface']) . '...');
- $enabled_files[] = "{$snortcfgdir}/rules/{$snort_enforcing_rules_file}";
- snort_write_flowbit_rules_file(snort_resolve_flowbits($enabled_files), "{$snortcfgdir}/rules/{$flowbit_rules_file}");
+ log_error('[Snort] Enabling any flowbit-required rules for: ' . snort_get_friendly_interface($snortcfg['interface']) . '...');
+ $fbits = snort_resolve_flowbits($enabled_rules);
+
+ /* Check for and disable any flowbit-required rules dependent upon */
+ /* disabled preprocessors if this option is enabled for the interface. */
+ if ($snortcfg['preproc_auto_rule_disable'] == "on") {
+ log_error('[Snort] Checking flowbit rules dependent on disabled preprocessors for: ' . snort_get_friendly_interface($snortcfg['interface']) . '...');
+ snort_filter_preproc_rules($snortcfg, $fbits, true);
+ }
+ snort_write_flowbit_rules_file($fbits, "{$snortcfgdir}/rules/{$flowbit_rules_file}");
+ unset($fbits);
} else
/* Just put an empty file to always have the file present */
snort_write_flowbit_rules_file(array(), "{$snortcfgdir}/rules/{$flowbit_rules_file}");
- unset($enabled_files);
+ unset($GLOBALS['all_rules']);
} else {
snort_write_enforcing_rules_file(array(), "{$snortcfgdir}/rules/{$snort_enforcing_rules_file}");
snort_write_flowbit_rules_file(array(), "{$snortcfgdir}/rules/{$flowbit_rules_file}");
}
- if (!empty($snortcfg['customrules']))
+ if (!empty($snortcfg['customrules'])) {
@file_put_contents("{$snortcfgdir}/rules/custom.rules", base64_decode($snortcfg['customrules']));
+ $no_rules_defined = false;
+ }
else
@file_put_contents("{$snortcfgdir}/rules/custom.rules", "");
+ /* Log a warning if the interface has no rules defined or enabled */
+ if ($no_rules_defined)
+ log_error(gettext("[Snort] Warning - no text rules selected for: " . snort_get_friendly_interface($snortcfg['interface']) . " ..."));
+
/* Build a new sid-msg.map file from the enabled */
/* rules and copy it to the interface directory. */
+ log_error(gettext("[Snort] Building new sig-msg.map file for " . snort_get_friendly_interface($snortcfg['interface']) . "..."));
snort_build_sid_msg_map("{$snortcfgdir}/rules/", "{$snortcfgdir}/sid-msg.map");
}
-function snort_filter_preproc_rules($snortcfg, &$active_rules) {
+function snort_filter_preproc_rules($snortcfg, &$active_rules, $persist_log = false) {
/**************************************************/
/* This function checks the $active_rules array */
@@ -1819,11 +2201,22 @@ function snort_filter_preproc_rules($snortcfg, &$active_rules) {
/* the interface */
/* $active_rules -> rules_map array of enabled */
/* rules for the interface */
+ /* */
+ /* NOTE: This feature must be enabled in the GUI */
+ /* by the user. Use of this feature can */
+ /* severely degrade Snort's ability to */
+ /* detect threats by disabling potentially */
+ /* crucial detection rules. */
/**************************************************/
global $config;
- if (empty($active_rules))
+ $snortlogdir = SNORTLOGDIR;
+ $disabled_count = 0;
+ $log_msg = array();
+
+ /* Check if no rules or if this option is disabled */
+ if (empty($active_rules) || $snortcfg['preproc_auto_rule_disable'] <> 'on')
return;
/***************************************************
@@ -1833,8 +2226,20 @@ function snort_filter_preproc_rules($snortcfg, &$active_rules) {
* IMPORTANT -- Keep this part of the code current *
* with changes to preprocessor rule options in *
* Snort VRT rules. *
+ * *
+ * *
+ * Format of array is: *
+ * "rule_option" => "dependent_preprocessor" *
+ * *
+ * Last Update: 04/05/2013 *
+ * *
+ * Added: http_inspect content modifiers and *
+ * various "service" metadata values. *
+ * *
***************************************************/
$rule_opts_preprocs = array("ssl_version:" => "ssl_preproc","ssl_state:" => "ssl_preproc",
+ "service ssl" => "ssl_preproc", "service ftp" => "ftp_preprocessor",
+ "service telnet" => "ftp_preprocessor", "service dns" => "dns_preprocessor",
"dce_iface:" => "dce_rpc_2", "dce_opnum:" => "dce_rpc_2",
"dce_stub_data;" => "dce_rpc_2", "sd_pattern:" => "sensitive_data",
"sip_method:" => "sip_preproc", "sip_stat_code:" => "sip_preproc",
@@ -1843,7 +2248,16 @@ function snort_filter_preproc_rules($snortcfg, &$active_rules) {
"gtp_version:" => "gtp_preproc", "modbus_func:" => "modbus_preproc",
"modbus_unit:" => "modbus_preproc", "modbus_data;" => "modbus_preproc",
"dnp3_func:" => "dnp3_preproc", "dnp3_obj:" => "dnp3_preproc",
- "dnp3_ind:" => "dnp3_preproc", "dnp3_data;" => "dnp3_preproc");
+ "dnp3_ind:" => "dnp3_preproc", "dnp3_data;" => "dnp3_preproc",
+ "http_client_body;" => "http_inspect", "http_cookie;" => "http_inspect",
+ "http_raw_cookie;" => "http_inspect", "http_header;" => "http_inspect",
+ "http_raw_header;" => "http_inspect", "http_method;" => "http_inspect",
+ "http_uri;" => "http_inspect", "http_raw_uri;" => "http_inspect",
+ "http_stat_code;" => "http_inspect", "http_stat_msg;" => "http_inspect",
+ "uricontent:" => "http_inspect", "urilen:" => "http_inspect",
+ "http_encode;" => "http_inspect", "service http" => "http_inspect",
+ "service imap" => "imap_preproc", "service pop2" => "pop_preproc",
+ "service pop3" => "pop_preproc", "service smtp" => "smtp_preprocessor");
/***************************************************
* Iterate the enabled rules, and check for rule *
@@ -1855,31 +2269,102 @@ function snort_filter_preproc_rules($snortcfg, &$active_rules) {
***************************************************/
foreach ($active_rules as $k1 => $rulem) {
foreach ($rulem as $k2 => $v) {
- if ($v['disabled'] == 0)
+
+ /* If rule is already disabled, skip it. */
+ if ($v['disabled'] == 1)
continue;
+
foreach ($rule_opts_preprocs as $opt => $preproc) {
- $pcre = "/\s*\b" . $opt . "/i";
+ $pcre = "/\s*\b" . preg_quote($opt) . "/i";
if (($snortcfg[$preproc] != 'on') && preg_match($pcre, $v['rule'])) {
$active_rules[$k1][$k2]['rule'] = "# " . $v['rule'];
$active_rules[$k1][$k2]['disabled'] = 1;
+ $disabled_count++;
+
+ /* Accumulate auto-disabled rules for logging */
+ $tmp = $active_rules[$k1][$k2]['category'] . ",";
+ $tmp .= "{$k1}:{$k2},{$preproc},{$opt}";
+ $log_msg[] = $tmp;
break;
}
}
}
}
+
+ /* Release memory we no longer need. */
+ unset($rulem, $v, $preproc);
+
+ /***************************************************************/
+ /* If we are persisting the log from the last pass, then open */
+ /* the log file in append mode. Otherwise open in overwrite */
+ /* to clear the log in case we have zero disabled rules. */
+ /* */
+ /* Typically "persist log" mode is used on the second pass */
+ /* when flowbit-required rules are being assessed after the */
+ /* primary enforcing rules have been evaluated. */
+ /***************************************************************/
+ $iface = snort_get_friendly_interface($snortcfg['interface']);
+ $file = "{$snortlogdir}/{$iface}_disabled_preproc_rules.log";
+ if ($persist_log)
+ $fp = fopen($file, 'a');
+ else
+ $fp = fopen($file, 'w');
+
+ /***************************************************/
+ /* Log a warning if we auto-disabled any rules */
+ /* just so the user is aware protection is less */
+ /* than optimal with the preprocessors disabled. */
+ /***************************************************/
+ if ($disabled_count > 0) {
+ log_error(gettext("[Snort] Warning: auto-disabled {$disabled_count} rules due to disabled preprocessor dependencies."));
+ natcasesort($log_msg);
+ if ($fp) {
+ /* Only write the header when not persisting the log */
+ if (!$persist_log) {
+ @fwrite($fp, "#\n# Run Time: " . date("Y-m-d H:i:s") . "\n#\n");
+ @fwrite($fp, "#\n# These rules were auto-disabled because they contain options or operators\n");
+ @fwrite($fp, "# dependent on preprocessors that are currently NOT ENABLED on the Preprocessors\n");
+ @fwrite($fp, "# tab. Without these dependent preprocessors enabled, Snort would fail to start\n");
+ @fwrite($fp, "# if the rules listed below were enabled. Therefore the listed rules have been\n");
+ @fwrite($fp, "# automatically disabled. This behavior is controlled by the Auto-Rule Disable\n");
+ @fwrite($fp, "# feature on the Preprocessors tab.\n#\n");
+ @fwrite($fp, "# WARNING: Using the auto-disable rule feature is not recommended because it can\n");
+ @fwrite($fp, "# significantly reduce the threat detection capabilities of Snort!\n#");
+ @fwrite($fp, "\n# In the list below, the PREPROCESSOR column is the disabled preprocessor that\n");
+ @fwrite($fp, "# triggered the auto-disable of the rule represented by GID:SID. The RULE OPTION\n");
+ @fwrite($fp, "# column shows the specific rule option or content modifier contained within\n");
+ @fwrite($fp, "# the rule text that requires the preprocessor be enabled in order to execute.\n#");
+ @fwrite($fp, "\n# RULE CATEGORY GID:SID PREPROCESSOR RULE OPTION\n");
+ }
+ foreach ($log_msg as $m) {
+ $tmp = explode(",", $m);
+ @fwrite($fp, sprintf("%-30s %-10s %-20s %s", $tmp[0], $tmp[1], $tmp[2], $tmp[3]) . "\n");
+ }
+ }
+ log_error(gettext("[Snort] See '{$file}' for list of auto-disabled rules."));
+ unset($log_msg);
+ }
+ if ($fp)
+ fclose($fp);
}
function snort_generate_conf($snortcfg) {
- global $config, $g;
+
+ global $config, $g, $flowbit_rules_file, $snort_enforcing_rules_file, $rebuild_rules;
$snortdir = SNORTDIR;
+ $snortlibdir = SNORTLIBDIR;
$snortlogdir = SNORTLOGDIR;
- $flowbit_rules_file = "flowbit-required.rules";
- $snort_enforcing_rules_file = "snort.rules";
if (!is_array($config['installedpackages']['snortglobal']['rule']))
return;
+ /* See if we should protect and not modify the preprocessor rules files */
+ if (!empty($snortcfg['protect_preproc_rules']))
+ $protect_preproc_rules = $snortcfg['protect_preproc_rules'];
+ else
+ $protect_preproc_rules = "off";
+
$if_real = snort_get_real_interface($snortcfg['interface']);
$snort_uuid = $snortcfg['uuid'];
$snortcfgdir = "{$snortdir}/snort_{$snort_uuid}_{$if_real}";
@@ -1902,8 +2387,8 @@ function snort_generate_conf($snortcfg) {
"{$snortlogdir}/snort_{$if_real}{$snort_uuid}",
"{$snortlogdir}/snort_{$if_real}{$snort_uuid}/barnyard2",
"{$snortcfgdir}/preproc_rules",
- "dynamicrules" => "/usr/local/lib/snort/dynamicrules",
- "dynamicengine" => "/usr/local/lib/snort/dynamicengine",
+ "dynamicrules" => "{$snortlibdir}/dynamicrules",
+ "dynamicengine" => "{$snortlibdir}/dynamicengine",
"dynamicpreprocessor" => "{$snortcfgdir}/dynamicpreprocessor"
);
foreach ($snort_dirs as $dir) {
@@ -1911,13 +2396,24 @@ function snort_generate_conf($snortcfg) {
safe_mkdir($dir);
}
+ /********************************************************************/
+ /* For fail-safe on an initial startup following installation, and */
+ /* before a rules update has occurred, copy the default config */
+ /* files to the interface directory. If files already exist in */
+ /* the interface directory, or they are newer, that means a rule */
+ /* update has been done and we should leave the customized files */
+ /* put in place by the rules update process. */
+ /********************************************************************/
$snort_files = array("gen-msg.map", "classification.config", "reference.config",
"sid-msg.map", "unicode.map", "threshold.conf", "preproc_rules/preprocessor.rules",
"preproc_rules/decoder.rules", "preproc_rules/sensitive-data.rules"
);
foreach ($snort_files as $file) {
- if (file_exists("{$snortdir}/{$file}"))
- @copy("{$snortdir}/{$file}", "{$snortcfgdir}/{$file}");
+ if (file_exists("{$snortdir}/{$file}")) {
+ $ftime = filemtime("{$snortdir}/{$file}");
+ if (!file_exists("{$snortcfgdir}/{$file}") || ($ftime > filemtime("{$snortcfgdir}/{$file}")))
+ @copy("{$snortdir}/{$file}", "{$snortcfgdir}/{$file}");
+ }
}
/* define alertsystemlog */
@@ -1936,8 +2432,7 @@ function snort_generate_conf($snortcfg) {
$pfkill = "";
if ($snortcfg['blockoffenderskill'] == "on")
$pfkill = "kill";
- /* No subnets to default addresses */
- $spoink_wlist = snort_build_list($snortcfg, $snortcfg['whitelistname'], true);
+ $spoink_wlist = snort_build_list($snortcfg, $snortcfg['whitelistname']);
/* write whitelist */
@file_put_contents("{$snortcfgdir}/{$snortcfg['whitelistname']}", implode("\n", $spoink_wlist));
$spoink_type = "output alert_pf: {$snortcfgdir}/{$snortcfg['whitelistname']},snort2c,{$snortcfg['blockoffendersip']},{$pfkill}";
@@ -1968,7 +2463,7 @@ function snort_generate_conf($snortcfg) {
"telnet_ports" => "23","snmp_ports" => "161", "ftp_ports" => "21",
"ssh_ports" => $ssh_port, "pop2_ports" => "109", "pop3_ports" => "110",
"imap_ports" => "143", "sip_proxy_ports" => "5060:5090,16384:32768",
- "sip_ports" => "5060, 5061", "auth_ports" => "113", "finger_ports" => "79",
+ "sip_ports" => "5060,5061", "auth_ports" => "113", "finger_ports" => "79",
"irc_ports" => "6665,6666,6667,6668,6669,7000", "smb_ports" => "139,445",
"nntp_ports" => "119", "rlogin_ports" => "513", "rsh_ports" => "514",
"ssl_ports" => "443,465,563,636,989,990,992,993,994,995",
@@ -1985,7 +2480,7 @@ function snort_generate_conf($snortcfg) {
foreach ($snort_ports as $alias => $avalue) {
if (!empty($snortcfg["def_{$alias}"]) && is_alias($snortcfg["def_{$alias}"]))
$snort_ports[$alias] = filter_expand_alias($snortcfg["def_{$alias}"]);
- $snort_ports[$alias] = str_replace(" ", ",", trim($snort_ports[$alias]));
+ $snort_ports[$alias] = preg_replace('/\s+/', ',', trim($snort_ports[$alias]));
$portvardef .= "portvar " . strtoupper($alias) . " [" . $snort_ports[$alias] . "]\n";
}
@@ -1999,41 +2494,53 @@ preprocessor perfmonitor: time 300 file {$snortlogdir}/snort_{$if_real}{$snort_u
EOD;
- $def_server_flow_depth_type = '300';
- if ((!empty($snortcfg['server_flow_depth'])) || ($snortcfg['server_flow_depth'] == '0'))
- $def_server_flow_depth_type = $snortcfg['server_flow_depth'];
+ /* Pull in the user-configurable HTTP_INSPECT global preprocessor options */
+ $http_inspect_memcap = "150994944";
+ if (!empty($snortcfg['http_inspect_memcap']))
+ $http_inspect_memcap = $snortcfg['http_inspect_memcap'];
+ /* Pull in the user-configurable HTTP_INSPECT server preprocessor options */
+ $server_flow_depth = '300';
+ if ((!empty($snortcfg['server_flow_depth'])) || ($snortcfg['server_flow_depth'] == '0'))
+ $server_flow_depth = $snortcfg['server_flow_depth'];
$http_server_profile = "all";
if (!empty($snortcfg['http_server_profile']))
$http_server_profile = $snortcfg['http_server_profile'];
-
- $def_client_flow_depth_type = '300';
+ $client_flow_depth = '300';
if ((!empty($snortcfg['client_flow_depth'])) || ($snortcfg['client_flow_depth'] == '0'))
- $def_client_flow_depth_type = $snortcfg['client_flow_depth'];
-
- if ($snortcfg['noalert_http_inspect'] == 'on')
- $noalert_http_inspect = "no_alerts ";
+ $client_flow_depth = $snortcfg['client_flow_depth'];
+ if ($snortcfg['noalert_http_inspect'] == 'on' || empty($snortcfg['noalert_http_inspect']))
+ $noalert_http_inspect = "no_alerts";
else
$noalert_http_inspect = "";
+ $http_inspect_server_opts = "enable_cookie \\\n\textended_response_inspection \\\n\tnormalize_javascript \\\n";
+ $http_inspect_server_opts .= "\tinspect_gzip \\\n\tnormalize_utf \\\n\tunlimited_decompress \\\n";
+ $http_inspect_server_opts .= "\tnormalize_headers \\\n\tnormalize_cookies";
+ if ($snortcfg['http_inspect_enable_xff'] == "on")
+ $http_inspect_server_opts .= " \\\n\tenable_xff";
+
+ /* If Stream5 is enabled, then we can enable the "log_uri" and "log_hostname" options */
+ if ($snortcfg['stream5_reassembly'] == "on") {
+ if ($snortcfg['http_inspect_log_uri'] == "on")
+ $http_inspect_server_opts .= " \\\n\tlog_uri";
+ if ($snortcfg['http_inspect_log_hostname'] == "on")
+ $http_inspect_server_opts .= " \\\n\tlog_hostname";
+ }
$http_ports = str_replace(",", " ", $snort_ports['http_ports']);
+
/* def http_inspect */
$http_inspect = <<<EOD
-# HTTP Inspect #
-preprocessor http_inspect: global iis_unicode_map unicode.map 1252 compress_depth 65535 decompress_depth 65535
+# HTTP Inspect #
+preprocessor http_inspect: global iis_unicode_map unicode.map 1252 compress_depth 65535 decompress_depth 65535 memcap {$http_inspect_memcap}
-preprocessor http_inspect_server: server default profile {$http_server_profile} {$noalert_http_inspect}\
- ports { {$http_ports} } \
+preprocessor http_inspect_server: server default profile {$http_server_profile} {$noalert_http_inspect} \
+ ports { {$http_ports} } \
http_methods { GET POST PUT SEARCH MKCOL COPY MOVE LOCK UNLOCK NOTIFY POLL BCOPY BDELETE BMOVE LINK UNLINK OPTIONS HEAD DELETE TRACE TRACK CONNECT SOURCE SUBSCRIBE UNSUBSCRIBE PROPFIND PROPPATCH BPROPFIND BPROPPATCH RPC_CONNECT PROXY_SUCCESS BITS_POST CCM_POST SMS_POST RPC_IN_DATA RPC_OUT_DATA RPC_ECHO_DATA } \
- server_flow_depth {$def_server_flow_depth_type} \
- client_flow_depth {$def_client_flow_depth_type} \
- enable_cookie \
- extended_response_inspection \
- inspect_gzip \
- normalize_utf \
- unlimited_decompress \
- normalize_javascript
-
+ server_flow_depth {$server_flow_depth} \
+ client_flow_depth {$client_flow_depth} \
+ {$http_inspect_server_opts}
+
EOD;
/* def ftp_preprocessor */
@@ -2136,28 +2643,35 @@ PIPELINING CHUNKING DATA DSN RSET QUIT ONEX QUEU STARTTLS TICK TIME TURNME VERB
log_filename \
qp_decode_depth 0 \
b64_decode_depth 0 \
- bitenc_decode_depth 0
+ bitenc_decode_depth 0 \
+ uu_decode_depth 0
EOD;
/* def sf_portscan */
+ $sf_pscan_protocol = "all";
+ if (!empty($snortcfg['pscan_protocol']))
+ $sf_pscan_protocol = $snortcfg['pscan_protocol'];
+ $sf_pscan_type = "all";
+ if (!empty($snortcfg['pscan_type']))
+ $sf_pscan_type = $snortcfg['pscan_type'];
+ $sf_pscan_memcap = "10000000";
+ if (!empty($snortcfg['pscan_memcap']))
+ $sf_pscan_memcap = $snortcfg['pscan_memcap'];
+ $sf_pscan_sense_level = "medium";
if (!empty($snortcfg['pscan_sense_level']))
$sf_pscan_sense_level = $snortcfg['pscan_sense_level'];
- else
- $sf_pscan_sense_level = "medium";
-
+ $sf_pscan_ignore_scanners = "\$HOME_NET";
if (!empty($snortcfg['pscan_ignore_scanners']) && is_alias($snortcfg['pscan_ignore_scanners'])) {
$sf_pscan_ignore_scanners = filter_expand_alias($snortcfg['pscan_ignore_scanners']);
$sf_pscan_ignore_scanners = preg_replace('/\s+/', ',', trim($sf_pscan_ignore_scanners));
}
- else
- $sf_pscan_ignore_scanners = "\$HOME_NET";
$sf_portscan = <<<EOD
# sf Portscan #
-preprocessor sfportscan: scan_type { all } \
- proto { all } \
- memcap { 10000000 } \
+preprocessor sfportscan: scan_type { {$sf_pscan_type} } \
+ proto { {$sf_pscan_protocol} } \
+ memcap { {$sf_pscan_memcap} } \
sense_level { {$sf_pscan_sense_level} } \
ignore_scanners { {$sf_pscan_ignore_scanners} }
@@ -2243,18 +2757,16 @@ EOD;
$sensitive_data = "preprocessor sensitive_data:\n";
- /* stream5 queued settings */
- $def_max_queued_bytes_type = '';
- if ((!empty($snortcfg['max_queued_bytes'])) || ($snortcfg['max_queued_bytes'] == '0'))
- $def_max_queued_bytes_type = ", max_queued_bytes {$snortcfg['max_queued_bytes']}";
-
- $def_max_queued_segs_type = '';
- if ((!empty($snortcfg['max_queued_segs'])) || ($snortcfg['max_queued_segs'] == '0'))
- $def_max_queued_segs_type = ", max_queued_segs {$snortcfg['max_queued_segs']}";
-
- $def_stream5_mem_cap = '';
- if (!empty($snortcfg['stream5_mem_cap']))
- $def_stream5_mem_cap = ", memcap {$snortcfg['stream5_mem_cap']}";
+ /**************************************************************/
+ /* Default the HTTP_INSPECT preprocessor to "on" if not set. */
+ /* The preprocessor is required by hundreds of Snort rules, */
+ /* and without it Snort may not start and/or the number of */
+ /* rules required to be disabled reduces Snort's capability. */
+ /* Alerts from the HTTP_INSPECT preprocessor default to "off" */
+ /* unless a specific value has been set by the user. */
+ /**************************************************************/
+ if (empty($snortcfg['http_inspect']))
+ $snortcfg['http_inspect'] = 'on';
/* define servers and ports snortdefservers */
$snort_servers = array (
@@ -2287,15 +2799,23 @@ EOD;
"perform_stat", "http_inspect", "other_preprocs", "ftp_preprocessor", "smtp_preprocessor", "ssl_preproc", "sip_preproc", "gtp_preproc",
"sf_portscan", "dce_rpc_2", "dns_preprocessor", "sensitive_data", "pop_preproc", "imap_preproc", "dnp3_preproc", "modbus_preproc"
);
+ $default_disabled_preprocs = array(
+ "sf_portscan", "gtp_preproc", "sensitive_data", "dnp3_preproc", "modbus_preproc"
+ );
$snort_preprocessors = "";
foreach ($snort_preproc as $preproc) {
- if ($snortcfg[$preproc] == 'on') {
- /* NOTE: The $$ is not a bug. Its a advanced feature of php */
+ if ($snortcfg[$preproc] == 'on' || empty($snortcfg[$preproc]) ) {
+
+ /* If preprocessor is not explicitly "on" or "off", then default to "off" if in our default disabled list */
+ if (empty($snortcfg[$preproc]) && in_array($preproc, $default_disabled_preprocs))
+ continue;
+
+ /* NOTE: The $$ is not a bug. It is an advanced feature of php */
if (!empty($snort_preproc_libs[$preproc])) {
$preproclib = "libsf_" . $snort_preproc_libs[$preproc];
if (!file_exists($snort_dirs['dynamicpreprocessor'] . "{$preproclib}.so")) {
- if (file_exists("/usr/local/lib/snort/dynamicpreprocessor/{$preproclib}.so")) {
- @copy("/usr/local/lib/snort/dynamicpreprocessor/{$preproclib}.so", "{$snort_dirs['dynamicpreprocessor']}/{$preproclib}.so");
+ if (file_exists("{$snortlibdir}/dynamicpreprocessor/{$preproclib}.so")) {
+ @copy("{$snortlibdir}/dynamicpreprocessor/{$preproclib}.so", "{$snort_dirs['dynamicpreprocessor']}/{$preproclib}.so");
$snort_preprocessors .= $$preproc;
$snort_preprocessors .= "\n";
} else
@@ -2317,28 +2837,32 @@ EOD;
if (file_exists("{$snortcfgdir}/classification.config"))
$snort_misc_include_rules .= "include {$snortcfgdir}/classification.config\n";
if (is_dir("{$snortcfgdir}/preproc_rules")) {
- if ($snortcfg['sensitive_data'] == 'on') {
+ if ($snortcfg['sensitive_data'] == 'on' && $protect_preproc_rules == "off") {
$sedcmd = '/^#alert.*classtype:sdf/s/^#//';
if (file_exists("{$snortcfgdir}/preproc_rules/sensitive-data.rules"))
$snort_misc_include_rules .= "include \$PREPROC_RULE_PATH/sensitive-data.rules\n";
} else
$sedcmd = '/^alert.*classtype:sdf/s/^/#/';
if (file_exists("{$snortcfgdir}/preproc_rules/decoder.rules") &&
- file_exists("{$snortcfgdir}/preproc_rules/preprocessor.rules")) {
+ file_exists("{$snortcfgdir}/preproc_rules/preprocessor.rules") && $protect_preproc_rules == "off") {
@file_put_contents("{$g['tmp_path']}/sedcmd", $sedcmd);
mwexec("/usr/bin/sed -I '' -f {$g['tmp_path']}/sedcmd {$snortcfgdir}/preproc_rules/preprocessor.rules");
mwexec("/usr/bin/sed -I '' -f {$g['tmp_path']}/sedcmd {$snortcfgdir}/preproc_rules/decoder.rules");
@unlink("{$g['tmp_path']}/sedcmd");
-
$snort_misc_include_rules .= "include \$PREPROC_RULE_PATH/decoder.rules\n";
$snort_misc_include_rules .= "include \$PREPROC_RULE_PATH/preprocessor.rules\n";
- } else {
+ } else if (file_exists("{$snortcfgdir}/preproc_rules/decoder.rules") &&
+ file_exists("{$snortcfgdir}/preproc_rules/preprocessor.rules") && $protect_preproc_rules == "on") {
+ $snort_misc_include_rules .= "include \$PREPROC_RULE_PATH/decoder.rules\n";
+ $snort_misc_include_rules .= "include \$PREPROC_RULE_PATH/preprocessor.rules\n";
+ }
+ else {
$snort_misc_include_rules .= "config autogenerate_preprocessor_decoder_rules\n";
- log_error("Seems preprocessor/decoder rules are missing, enabling autogeneration of them");
+ log_error("[Snort] Seems preprocessor/decoder rules are missing, enabling autogeneration of them");
}
} else {
$snort_misc_include_rules .= "config autogenerate_preprocessor_decoder_rules\n";
- log_error("Seems preprocessor/decoder rules are missing, enabling autogeneration of them");
+ log_error("[Snort] Seems preprocessor/decoder rules are missing, enabling autogeneration of them");
}
/* generate rule sections to load */
@@ -2346,12 +2870,84 @@ EOD;
$selected_rules_sections = "include \$RULE_PATH/{$snort_enforcing_rules_file}\n";
$selected_rules_sections .= "include \$RULE_PATH/{$flowbit_rules_file}\n";
$selected_rules_sections .= "include \$RULE_PATH/custom.rules\n";
+
+ /* Create the actual rules files and save in the interface directory */
snort_prepare_rule_files($snortcfg, $snortcfgdir);
$cksumcheck = "all";
if ($snortcfg['cksumcheck'] == 'on')
$cksumcheck = "none";
+ /* Pull in user-configurable options for Frag3 preprocessor settings */
+ $frag3_disabled = "";
+ if ($snortcfg['frag3_detection'] == "off")
+ $frag3_disabled = ", disabled";
+ $frag3_memcap = "memcap 4194304";
+ if (!empty($snortcfg['frag3_memcap']) || $snortcfg['frag3_memcap'] == "0")
+ $frag3_memcap = "memcap {$snortcfg['frag3_memcap']}";
+ $frag3_max_frags = "max_frags 8192";
+ if (!empty($snortcfg['frag3_max_frags']))
+ $frag3_max_frags = "max_frags {$snortcfg['frag3_max_frags']}";
+ $frag3_overlap_limit = "overlap_limit 0";
+ if (!empty($snortcfg['frag3_overlap_limit']))
+ $frag3_overlap_limit = "overlap_limit {$snortcfg['frag3_overlap_limit']}";
+ $frag3_min_frag_len = "min_fragment_length 0";
+ if (!empty($snortcfg['frag3_min_frag_len']))
+ $frag3_min_frag_len = "min_fragment_length {$snortcfg['frag3_min_frag_len']}";
+ $frag3_timeout = "timeout 60";
+ if (!empty($snortcfg['frag3_timeout']))
+ $frag3_timeout = "timeout {$snortcfg['frag3_timeout']}";
+ $frag3_policy = "policy bsd";
+ if (!empty($snortcfg['frag3_policy']))
+ $frag3_policy = "policy {$snortcfg['frag3_policy']}";
+
+ /* Pull in user-configurable options for Stream5 preprocessor settings */
+ $stream5_reassembly = "";
+ if ($snortcfg['stream5_reassembly'] == "off")
+ $stream5_reassembly = "disabled,";
+ $stream5_track_tcp = "yes";
+ if ($snortcfg['stream5_track_tcp'] =="off")
+ $stream5_track_tcp = "no";
+ $stream5_track_udp = "yes";
+ if ($snortcfg['stream5_track_udp'] =="off")
+ $stream5_track_udp = "no";
+ $stream5_track_icmp = "no";
+ if ($snortcfg['stream5_track_icmp'] =="on")
+ $stream5_track_icmp = "yes";
+ $stream5_require_3whs = "";
+ if ($snortcfg['stream5_require_3whs'] == "on")
+ $stream5_require_3whs = ", require_3whs 0";
+ $stream5_no_reassemble_async = "";
+ if ($snortcfg['stream5_no_reassemble_async'] == "on")
+ $stream5_no_reassemble_async = ", dont_reassemble_async";
+ $stream5_dont_store_lg_pkts = "";
+ if ($snortcfg['stream5_dont_store_lg_pkts'] == "on")
+ $stream5_dont_store_lg_pkts = ", dont_store_large_packets";
+ $stream5_max_queued_bytes_type = "";
+ if ((!empty($snortcfg['max_queued_bytes'])) || ($snortcfg['max_queued_bytes'] == '0'))
+ $stream5_max_queued_bytes_type = ", max_queued_bytes {$snortcfg['max_queued_bytes']}";
+ $stream5_max_queued_segs_type = "";
+ if ((!empty($snortcfg['max_queued_segs'])) || ($snortcfg['max_queued_segs'] == '0'))
+ $stream5_max_queued_segs_type = ", max_queued_segs {$snortcfg['max_queued_segs']}";
+ $stream5_mem_cap = "";
+ if (!empty($snortcfg['stream5_mem_cap']))
+ $stream5_mem_cap = ", memcap {$snortcfg['stream5_mem_cap']}";
+ $stream5_overlap_limit = "overlap_limit 0";
+ if (!empty($snortcfg['stream5_overlap_limit']))
+ $stream5_overlap_limit = "overlap_limit {$snortcfg['stream5_overlap_limit']}";
+ $stream5_policy = "policy bsd";
+ if (!empty($snortcfg['stream5_policy']))
+ $stream5_policy = "policy {$snortcfg['stream5_policy']}";
+ $stream5_tcp_timeout = "timeout 30";
+ if (!empty($snortcfg['stream5_tcp_timeout']))
+ $stream5_tcp_timeout = "timeout {$snortcfg['stream5_tcp_timeout']}";
+ $stream5_udp_timeout = "timeout 30";
+ if (!empty($snortcfg['stream5_udp_timeout']))
+ $stream5_udp_timeout = "timeout {$snortcfg['stream5_udp_timeout']}";
+ $stream5_icmp_timeout = "timeout 30";
+ if (!empty($snortcfg['stream5_icmp_timeout']))
+ $stream5_icmp_timeout = "timeout {$snortcfg['stream5_icmp_timeout']}";
+
/* build snort configuration file */
$snort_conf_text = <<<EOD
@@ -2393,6 +2989,9 @@ config pcre_match_limit_recursion: 1500
config detection: search-method {$snort_performance} search-optimize max-pattern-len 20 max_queue_events 5
config event_queue: max_queue 8 log 5 order_events content_length
+# Configure to show year in timestamps
+config show_year
+
# Configure protocol aware flushing #
# For more information see README.stream5 #
config paf_max: 16000
@@ -2410,12 +3009,13 @@ preprocessor normalize_ip6
preprocessor normalize_icmp6
# Flow and stream #
-preprocessor frag3_global: max_frags 65536
-preprocessor frag3_engine: policy bsd detect_anomalies overlap_limit 10 min_fragment_length 100 timeout 180
+preprocessor frag3_global: {$frag3_memcap}, {$frag3_max_frags}{$frag3_disabled}
+preprocessor frag3_engine: {$frag3_policy} detect_anomalies {$frag3_timeout} {$frag3_overlap_limit} {$frag3_min_frag_len}
-preprocessor stream5_global: track_tcp yes, track_udp yes, track_icmp no, max_tcp 262144, max_udp 131072, max_active_responses 2, min_response_seconds 5{$def_stream5_mem_cap}
-preprocessor stream5_tcp: policy BSD, overlap_limit 10, timeout 180, ports both all{$def_max_queued_bytes_type}{$def_max_queued_segs_type}
-preprocessor stream5_udp: timeout 180
+preprocessor stream5_global:{$stream5_reassembly} track_tcp {$stream5_track_tcp}, track_udp {$stream5_track_udp}, track_icmp {$stream5_track_icmp}, max_tcp 262144, max_udp 131072, max_active_responses 2, min_response_seconds 5{$stream5_mem_cap}
+preprocessor stream5_tcp: {$stream5_policy}, {$stream5_overlap_limit}, {$stream5_tcp_timeout}, ports both all{$stream5_max_queued_bytes_type}{$stream5_max_queued_segs_type}{$stream5_require_3whs}{$stream5_no_reassemble_async}$stream5_dont_store_lg_pkts
+preprocessor stream5_udp: {$stream5_udp_timeout}
+preprocessor stream5_icmp: {$stream5_icmp_timeout}
{$snort_preprocessors}
@@ -2450,4 +3050,193 @@ EOD;
unset($home_net, $external_net, $vardef, $portvardef);
}
+/* Uses XMLRPC to synchronize the changes to a remote node */
+function snort_sync_on_changes() {
+ global $config, $g, $is_postinstall;
+
+ /* Do not attempt a package sync while booting up or installing package */
+ if ($g['booting'] || $is_postinstall)
+ return;
+
+ if (is_array($config['installedpackages']['snortsync']['config'])){
+ $snort_sync=$config['installedpackages']['snortsync']['config'][0];
+ $synconchanges = $snort_sync['varsynconchanges'];
+ $synctimeout = $snort_sync['varsynctimeout'];
+ $syncdownloadrules = $snort_sync['vardownloadrules'];
+ switch ($synconchanges){
+ case "manual":
+ if (is_array($snort_sync[row])){
+ $rs=$snort_sync[row];
+ }
+ else{
+ log_error("[snort] xmlrpc sync is enabled but there are no hosts configured as replication targets.");
+ return;
+ }
+ break;
+ case "auto":
+ if (is_array($config['installedpackages']['carpsettings']) && is_array($config['installedpackages']['carpsettings']['config'])){
+ $system_carp=$config['installedpackages']['carpsettings']['config'][0];
+ $rs[0]['varsyncipaddress']=$system_carp['synchronizetoip'];
+ $rs[0]['varsyncusername']=$system_carp['username'];
+ $rs[0]['varsyncpassword']=$system_carp['password'];
+ $rs[0]['varsyncsnortstart']="no";
+ if ($system_carp['synchronizetoip'] ==""){
+ log_error("[snort] xmlrpc sync is enabled but there are no system backup hosts configured as replication targets.");
+ return;
+ }
+ }
+ else{
+ log_error("[snort] xmlrpc sync is enabled but there are no system backup hosts configured as replication targets.");
+ return;
+ }
+ break;
+ default:
+ return;
+ break;
+ }
+ if (is_array($rs)){
+ log_error("[snort] Snort pkg xmlrpc sync is starting.");
+ foreach($rs as $sh){
+ if ($sh['varsyncsnortstart'])
+ $syncstartsnort = $sh['varsyncsnortstart'];
+ else
+ $syncstartsnort = "OFF";
+ $sync_to_ip = $sh['varsyncipaddress'];
+ $password = $sh['varsyncpassword'];
+ if($sh['varsyncusername'])
+ $username = $sh['varsyncusername'];
+ else
+ $username = 'admin';
+ if($password && $sync_to_ip)
+ snort_do_xmlrpc_sync($syncdownloadrules, $sync_to_ip, $username, $password, $synctimeout, $syncstartsnort);
+ }
+ log_error("[snort] Snort pkg xmlrpc sync completed.");
+ }
+ }
+}
+
+/* Do the actual XMLRPC sync */
+function snort_do_xmlrpc_sync($syncdownloadrules, $sync_to_ip, $username, $password, $synctimeout, $syncstartsnort) {
+ global $config, $g, $is_postinstall;
+
+ /* Do not attempt a package sync while booting up or installing package */
+ if ($g['booting'] || $is_postinstall)
+ return;
+
+ if(!$username || !$password || !$sync_to_ip) {
+ log_error("[snort] A required XMLRPC sync parameter (user, host IP or password) is empty ... aborting pkg sync");
+ return;
+ }
+
+ /* Test key variables and set defaults if empty */
+ if(!$synctimeout)
+ $synctimeout=150;
+
+ $xmlrpc_sync_neighbor = $sync_to_ip;
+ if($config['system']['webgui']['protocol'] != "") {
+ $synchronizetoip = $config['system']['webgui']['protocol'];
+ $synchronizetoip .= "://";
+ }
+ $port = $config['system']['webgui']['port'];
+ /* if port is empty lets rely on the protocol selection */
+ if($port == "") {
+ if($config['system']['webgui']['protocol'] == "http")
+ $port = "80";
+ else
+ $port = "443";
+ }
+ $synchronizetoip .= $sync_to_ip;
+
+ /* xml will hold the sections to sync */
+ $xml = array();
+ $xml['snortglobal'] = $config['installedpackages']['snortglobal'];
+ /* assemble xmlrpc payload */
+ $params = array(
+ XML_RPC_encode($password),
+ XML_RPC_encode($xml)
+ );
+
+ /* set a few variables needed for sync code borrowed from filter.inc */
+ $url = $synchronizetoip;
+ log_error("[snort] Beginning Snort pkg configuration XMLRPC sync to {$url}:{$port}.");
+ $method = 'pfsense.merge_installedpackages_section_xmlrpc';
+ $msg = new XML_RPC_Message($method, $params);
+ $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port);
+ $cli->setCredentials($username, $password);
+
+ /* send our XMLRPC message and timeout after defined sync timeout value*/
+ $resp = $cli->send($msg, $synctimeout);
+ if(!$resp) {
+ $error = "A communications error occurred while attempting snort XMLRPC sync with {$url}:{$port}.";
+ log_error($error);
+ file_notice("sync_settings", $error, "snort Settings Sync", "");
+ } elseif($resp->faultCode()) {
+ $error = "An error code was received while attempting snort XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString();
+ log_error($error);
+ file_notice("sync_settings", $error, "snort Settings Sync", "");
+ } else {
+ log_error("[snort] Snort pkg configuration XMLRPC sync successfully completed with {$url}:{$port}.");
+ }
+
+ $downloadrulescmd = "";
+ if ($syncdownloadrules == "yes") {
+ $downloadrulescmd = "log_error(gettext(\"[snort] XMLRPC pkg sync: Update of downloaded rule sets requested...\"));\n";
+ $downloadrulescmd .= "include_once(\"/usr/local/pkg/snort/snort_check_for_rule_updates.php\");\n";
+ }
+ $snortstart = "";
+ if ($syncstartsnort == "ON") {
+ $snortstart = "log_error(gettext(\"[snort] XMLRPC pkg sync: Checking Snort status...\"));\n";
+ $snortstart .= "if (!is_process_running(\"snort\")) {\n";
+ $snortstart .= "log_error(gettext(\"[snort] XMLRPC pkg sync: Snort not running. Sending a start command...\"));\n";
+ $snortstart .= "exec(\"/usr/local/etc/rc.d/snort.sh start 2>&1 &\");\n}\n";
+ $snortstart .= "else {log_error(gettext(\"[snort] XMLRPC pkg sync: Snort is running...\"));\n}\n";
+ }
+
+ /* Build a series of commands for the secondary host to execute that will load the new settings. */
+ $execcmd = <<<EOD
+ require_once("/usr/local/pkg/snort/snort.inc");
+ require_once("service-utils.inc");
+ global \$g, \$rebuild_rules, \$snort_gui_include, \$is_postinstall, \$pkg_interface;
+ \$orig_pkg_interface = \$pkg_interface;
+ \$is_postinstall = true;
+ \$snort_gui_include = false;
+ \$pkg_interface = "console";
+ {$downloadrulescmd}
+ \$is_postinstall = false;
+ log_error(gettext("[snort] XMLRPC pkg sync: Generating snort.conf file using Master Host's settings..."));
+ \$rebuild_rules = "on";
+ sync_snort_package_config();
+ \$rebuild_rules = "off";
+ {$snortstart}
+ log_error(gettext("[snort] XMLRPC pkg sync process on this host is complete..."));
+ \$pkg_interface = \$orig_pkg_interface;
+ return true;
+
+EOD;
+
+ /* assemble xmlrpc payload */
+ $method = 'pfsense.exec_php';
+ $params = array(
+ XML_RPC_encode($password),
+ XML_RPC_encode($execcmd)
+ );
+
+ log_error("[snort] Snort XMLRPC sending reload configuration cmd to {$url}:{$port}.");
+ $msg = new XML_RPC_Message($method, $params);
+ $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port);
+ $cli->setCredentials($username, $password);
+ $resp = $cli->send($msg, $synctimeout);
+ if(!$resp) {
+ $error = "A communications error occurred while attempting snort XMLRPC sync with {$url}:{$port} (pfsense.exec_php).";
+ log_error($error);
+ file_notice("sync_settings", $error, "snort Settings Sync", "");
+ } elseif($resp->faultCode()) {
+ $error = "An error code was received while attempting snort XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString();
+ log_error($error);
+ file_notice("sync_settings", $error, "snort Settings Sync", "");
+ } else {
+ log_error("[snort] Snort pkg XMLRPC reload configuration success with {$url}:{$port} (pfsense.exec_php).");
+ }
+}
+
?>
diff --git a/config/snort/snort.xml b/config/snort/snort.xml
index b18e66e1..1066b75c 100755
--- a/config/snort/snort.xml
+++ b/config/snort/snort.xml
@@ -46,8 +46,8 @@
<requirements>Describe your package requirements here</requirements>
<faq>Currently there are no FAQ items provided.</faq>
<name>Snort</name>
- <version>2.9.2.3</version>
- <title>Services:2.9.2.3 pkg v. 2.5.3</title>
+ <version>2.9.4.1</version>
+ <title>Services:2.9.4.1 pkg v. 2.5.8</title>
<include_file>/usr/local/pkg/snort/snort.inc</include_file>
<menu>
<name>Snort</name>
@@ -74,6 +74,11 @@
<item>http://www.pfsense.com/packages/config/snort/snort_check_cron_misc.inc</item>
</additional_files_needed>
<additional_files_needed>
+ <prefix>/usr/local/pkg/snort/</prefix>
+ <chmod>077</chmod>
+ <item>http://www.pfsense.com/packages/config/snort/snort_sync.xml</item>
+ </additional_files_needed>
+ <additional_files_needed>
<prefix>/usr/local/www/snort/</prefix>
<chmod>077</chmod>
<item>http://www.pfsense.com/packages/config/snort/snort_alerts.php</item>
@@ -163,6 +168,21 @@
<chmod>077</chmod>
<item>http://www.pfsense.com/packages/config/snort/snort_interfaces_suppress_edit.php</item>
</additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/snort/</prefix>
+ <chmod>077</chmod>
+ <item>http://www.pfsense.com/packages/config/snort/snort_log_view.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/snort/</prefix>
+ <chmod>077</chmod>
+ <item>http://www.pfsense.com/packages/config/snort/snort_list_view.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/snort/</prefix>
+ <chmod>077</chmod>
+ <item>http://www.pfsense.com/packages/config/snort/snort_rules_flowbits.php</item>
+ </additional_files_needed>
<fields>
</fields>
<custom_add_php_command>
@@ -177,3 +197,4 @@
snort_deinstall();
</custom_php_deinstall_command>
</packagegui>
+
diff --git a/config/snort/snort_alerts.php b/config/snort/snort_alerts.php
index e6ebefeb..8c42fa89 100755
--- a/config/snort/snort_alerts.php
+++ b/config/snort/snort_alerts.php
@@ -38,6 +38,7 @@ require_once("guiconfig.inc");
require_once("/usr/local/pkg/snort/snort.inc");
$snortalertlogt = $config['installedpackages']['snortglobal']['snortalertlogtype'];
+$supplist = array();
if ($_GET['instance'])
$instanceid = $_GET['instance'];
@@ -80,8 +81,10 @@ if ($_POST['todelete'] || $_GET['todelete']) {
$ip = $_POST['todelete'];
else if($_GET['todelete'])
$ip = $_GET['todelete'];
- if (is_ipaddr($ip))
+ if (is_ipaddr($ip)) {
exec("/sbin/pfctl -t snort2c -T delete {$ip}");
+ $savemsg = "Host IP address {$ip} has been removed from the Blocked Table.";
+ }
}
if ($_GET['act'] == "addsuppress" && is_numeric($_GET['sidid']) && is_numeric($_GET['gen_id'])) {
@@ -99,7 +102,7 @@ if ($_GET['act'] == "addsuppress" && is_numeric($_GET['sidid']) && is_numeric($_
$s_list = array();
$s_list['name'] = $a_instance[$instanceid]['interface'] . "suppress";
$s_list['uuid'] = uniqid();
- $s_list['descr'] = "Auto generted list for suppress";
+ $s_list['descr'] = "Auto-generated list for suppress";
$s_list['suppresspassthru'] = base64_encode($suppress);
$a_suppress[] = $s_list;
$a_instance[$instanceid]['suppresslistname'] = $s_list['name'];
@@ -115,6 +118,7 @@ if ($_GET['act'] == "addsuppress" && is_numeric($_GET['sidid']) && is_numeric($_
}
}
}
+ $savemsg = "An entry for 'suppress gen_id {$_GET['gen_id']}, sig_id {$_GET['sidid']}' has been added to the Suppress List.";
write_config();
sync_snort_package_config();
}
@@ -157,6 +161,9 @@ if ($_POST['download']) {
exit;
}
+/* Load up an array with the current Suppression List GID,SID values */
+$supplist = snort_load_suppress_sigs($a_instance[$instanceid]);
+
$pgtitle = "Services: Snort: Snort Alerts";
include_once("head.inc");
@@ -177,6 +184,9 @@ if ($pconfig['arefresh'] == 'on')
if ($input_errors) {
print_input_errors($input_errors); // TODO: add checks
}
+ if ($savemsg) {
+ print_info_box($savemsg);
+ }
?>
<form action="/snort/snort_alerts.php" method="post" id="formalert">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
@@ -190,20 +200,20 @@ if ($pconfig['arefresh'] == 'on')
$tab_array[4] = array(gettext("Blocked"), false, "/snort/snort_blocked.php");
$tab_array[5] = array(gettext("Whitelists"), false, "/snort/snort_interfaces_whitelist.php");
$tab_array[6] = array(gettext("Suppress"), false, "/snort/snort_interfaces_suppress.php");
+ $tab_array[7] = array(gettext("Sync"), false, "/pkg_edit.php?xml=snort/snort_sync.xml");
display_top_tabs($tab_array);
?>
</td></tr>
<tr>
- <td>
- <table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0">
+ <td><div id="mainarea">
+ <table id="maintable" class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="6">
<tr>
- <td width="22%" class="listtopic"><?php printf(gettext('Last %s Alert Entries.'),$anentries); ?></td>
- <td width="78%" class="listtopic"><?php echo gettext('Latest Alert Entries Are Listed First.'); ?></td>
+ <td colspan="2" class="listtopic"><?php echo gettext("Alert Log View Settings"); ?></td>
</tr>
<tr>
<td width="22%" class="vncell"><?php echo gettext('Instance to inspect'); ?></td>
<td width="78%" class="vtable">
- <br/> <select name="instance" id="instance" class="formselect" onChange="document.getElementById('formalert').submit()">
+ <select name="instance" id="instance" class="formselect" onChange="document.getElementById('formalert').submit()">
<?php
foreach ($a_instance as $id => $instance) {
$selected = "";
@@ -212,14 +222,14 @@ if ($pconfig['arefresh'] == 'on')
echo "<option value='{$id}' {$selected}> (" . snort_get_friendly_interface($instance['interface']) . "){$instance['descr']}</option>\n";
}
?>
- </select><br/> <?php echo gettext('Choose which instance alerts you want to inspect.'); ?>
+ </select>&nbsp;&nbsp;<?php echo gettext('Choose which instance alerts you want to inspect.'); ?>
</td>
<tr>
<td width="22%" class="vncell"><?php echo gettext('Save or Remove Logs'); ?></td>
<td width="78%" class="vtable">
- <input name="download" type="submit" class="formbtn" value="Download"> <?php echo gettext('All ' .
- 'log files will be saved.'); ?> <a href="/snort/snort_alerts.php?action=clear&instance=<?=$instanceid;?>">
- <input name="delete" type="button" class="formbtn" value="Clear"
+ <input name="download" type="submit" class="formbtns" value="Download"> <?php echo gettext('All ' .
+ 'log files will be saved.'); ?>&nbsp;&nbsp;<a href="/snort/snort_alerts.php?action=clear&instance=<?=$instanceid;?>">
+ <input name="delete" type="submit" class="formbtns" value="Clear"
onclick="return confirm('Do you really want to remove all instance logs?')"></a>
<span class="red"><strong><?php echo gettext('Warning:'); ?></strong></span> <?php echo ' ' . gettext('all log files will be deleted.'); ?>
</td>
@@ -227,32 +237,45 @@ if ($pconfig['arefresh'] == 'on')
<tr>
<td width="22%" class="vncell"><?php echo gettext('Auto Refresh and Log View'); ?></td>
<td width="78%" class="vtable">
- <input name="save" type="submit" class="formbtn" value="Save">
+ <input name="save" type="submit" class="formbtns" value="Save">
<?php echo gettext('Refresh'); ?> <input name="arefresh" type="checkbox" value="on"
<?php if ($config['installedpackages']['snortglobal']['alertsblocks']['arefresh']=="on") echo "checked"; ?>>
- <?php printf(gettext('%sDefault%s is %sON%s.'), '<strong>', '</strong>', '<strong>', '</strong>'); ?>
+ <?php printf(gettext('%sDefault%s is %sON%s.'), '<strong>', '</strong>', '<strong>', '</strong>'); ?>&nbsp;&nbsp;
<input name="alertnumber" type="text" class="formfld" id="alertnumber" size="5" value="<?=htmlspecialchars($anentries);?>">
- <?php printf(gettext('Enter the number of log entries to view. %sDefault%s is %s250%s.'), '<strong>', '</strong>', '<strong>', '</strong>'); ?>
+ <?php printf(gettext('Enter number of log entries to view. %sDefault%s is %s250%s.'), '<strong>', '</strong>', '<strong>', '</strong>'); ?>
</td>
</tr>
<tr>
- <td colspan="2" ><br/><br/></td>
+ <td colspan="2" class="listtopic"><?php printf(gettext("Last %s Alert Entries"), $anentries); ?>&nbsp;&nbsp;
+ <?php echo gettext("(Most recent entries are listed first)"); ?></td>
</tr>
<tr>
- <td width="100%" colspan="2" class='vtable'>
- <table id="myTable" width="100%" class="sortable" border="1" cellpadding="0" cellspacing="0">
- <thead>
- <th class='listhdr' width='10%' axis="date"><?php echo gettext("Date"); ?></th>
- <th class='listhdrr' width='5%' axis="number"><?php echo gettext("PRI"); ?></th>
- <th class='listhdrr' width='3%' axis="string"><?php echo gettext("PROTO"); ?></th>
- <th class='listhdrr' width='7%' axis="string"><?php echo gettext("CLASS"); ?></th>
- <th class='listhdrr' width='15%' axis="string"><?php echo gettext("SRC"); ?></th>
- <th class='listhdrr' width='5%' axis="string"><?php echo gettext("SRCPORT"); ?></th>
- <th class='listhdrr' width='15%' axis="string"><?php echo gettext("DST"); ?></th>
- <th class='listhdrr' width='5%' axis="string"><?php echo gettext("DSTPORT"); ?></th>
- <th class='listhdrr' width='5%' axis="string"><?php echo gettext("SID"); ?></th>
- <th class='listhdrr' width='20%' axis="string"><?php echo gettext("DESCRIPTION"); ?></th>
- </thead>
+ <td width="100%" colspan="2">
+ <table id="myTable" style="table-layout: fixed;" width="100%" class="sortable" border="1" cellpadding="0" cellspacing="0">
+ <colgroup>
+ <col width="9%" align="center" axis="date">
+ <col width="45" align="center" axis="number">
+ <col width="65" align="center" axis="string">
+ <col width="10%" axis="string">
+ <col width="13%" align="center" axis="string">
+ <col width="8%" align="center" axis="string">
+ <col width="13%" align="center" axis="string">
+ <col width="8%" align="center" axis="string">
+ <col width="9%" align="center" axis="number">
+ <col axis="string">
+ </colgroup>
+ <thead>
+ <th class="listhdrr" axis="date"><?php echo gettext("DATE"); ?></th>
+ <th class="listhdrr" axis="number"><?php echo gettext("PRI"); ?></th>
+ <th class="listhdrr" axis="string"><?php echo gettext("PROTO"); ?></th>
+ <th class="listhdrr" axis="string"><?php echo gettext("CLASS"); ?></th>
+ <th class="listhdrr" axis="string"><?php echo gettext("SRC"); ?></th>
+ <th class="listhdrr" axis="string"><?php echo gettext("SPORT"); ?></th>
+ <th class="listhdrr" axis="string"><?php echo gettext("DST"); ?></th>
+ <th class="listhdrr" axis="string"><?php echo gettext("DPORT"); ?></th>
+ <th class="listhdrr" axis="number"><?php echo gettext("SID"); ?></th>
+ <th class="listhdrr" axis="string"><?php echo gettext("DESCRIPTION"); ?></th>
+ </thead>
<tbody>
<?php
@@ -269,8 +292,10 @@ if (file_exists("/var/log/snort/snort_{$if_real}{$snort_uuid}/alert")) {
if(count($fields) < 11)
continue;
+ /* Time */
+ $alert_time = substr($fields[0], strpos($fields[0], '-')+1, -8);
/* Date */
- $alert_date = substr($fields[0], 0, -8);
+ $alert_date = substr($fields[0], 0, strpos($fields[0], '-'));
/* Description */
$alert_descr = $fields[4];
$alert_descr_url = urlencode($fields[4]);
@@ -280,41 +305,48 @@ if (file_exists("/var/log/snort/snort_{$if_real}{$snort_uuid}/alert")) {
$alert_proto = $fields[5];
/* IP SRC */
$alert_ip_src = $fields[6];
+ /* Add zero-width space as soft-break opportunity after each colon if we have an IPv6 address */
+ $alert_ip_src = str_replace(":", ":&#8203;", $alert_ip_src);
if (isset($tmpblocked[$fields[6]])) {
- $alert_ip_src .= "<a href='?instance={$id}&todelete=" . trim(urlencode($fields[6])) . "'>
- <img title=\"" . gettext("Remove from blocked ips") . "\" border=\"0\" width='10' height='10' name='todelete' id='todelete' alt=\"Delete\" src=\"../themes/{$g['theme']}/images/icons/icon_x.gif\"></a>";
+ $alert_ip_src .= "<br/><a href='?instance={$id}&todelete=" . trim(urlencode($fields[6])) . "'>
+ <img title=\"" . gettext("Remove host from Blocked Table") . "\" border=\"0\" width='10' height='10' name='todelete' id='todelete' alt=\"Remove from Blocked Hosts\" src=\"../themes/{$g['theme']}/images/icons/icon_x.gif\"/></a>";
}
/* IP SRC Port */
$alert_src_p = $fields[7];
/* IP Destination */
$alert_ip_dst = $fields[8];
+ /* Add zero-width space as soft-break opportunity after each colon if we have an IPv6 address */
+ $alert_ip_dst = str_replace(":", ":&#8203;", $alert_ip_dst);
if (isset($tmpblocked[$fields[8]])) {
- $alert_ip_dst .= "<a href='?instance={$id}&todelete=" . trim(urlencode($fields[8])) . "'>
- <img title=\"" . gettext("Remove from blocked ips") . "\" border=\"0\" width='10' height='10' name='todelete' id='todelete' alt=\"Delete\" src=\"../themes/{$g['theme']}/images/icons/icon_x.gif\"></a>";
+ $alert_ip_dst .= "<br/><a href='?instance={$id}&todelete=" . trim(urlencode($fields[8])) . "'>
+ <img title=\"" . gettext("Remove host from Blocked Table") . "\" border=\"0\" width='10' height='10' name='todelete' id='todelete' alt=\"Remove from Blocked Hosts\" src=\"../themes/{$g['theme']}/images/icons/icon_x.gif\"/></a>";
}
/* IP DST Port */
$alert_dst_p = $fields[9];
/* SID */
- $alert_sid_str = "{$fields[1]}:{$fields[2]}:{$fields[3]}";
+ $alert_sid_str = "{$fields[1]}:{$fields[2]}";
+ if (!isset($supplist[$fields[1]][$fields[2]])) {
+ $sidsupplink = "<a href='?instance={$instanceid}&act=addsuppress&sidid={$fields[2]}&gen_id={$fields[1]}&descr={$alert_descr_url}'>";
+ $sidsupplink .= "<img src='../themes/{$g['theme']}/images/icons/icon_plus.gif' width='10' height='10' border='0' ";
+ $sidsupplink .= "title='" . gettext("Add this gen_id:sig_id to Suppress List") . "'></a>";
+ }
+ else {
+ $sidsupplink = "<img src='../themes/{$g['theme']}/images/icons/icon_plus_d.gif' width='10' height='10' border='0' ";
+ $sidsupplink .= "title='" . gettext("This gen_id:sig_id already in Suppress List") . "'/>";
+ }
$alert_class = $fields[11];
echo "<tr>
- <td class='listr' width='10%'>{$alert_date}</td>
- <td class='listr' width='5%' >{$alert_priority}</td>
- <td class='listr' width='3%'>{$alert_proto}</td>
- <td class='listr' width='7%' >{$alert_class}</td>
- <td class='listr' width='15%'>{$alert_ip_src}</td>
- <td class='listr' width='5%'>{$alert_src_p}</td>
- <td class='listr' width='15%'>{$alert_ip_dst}</td>
- <td class='listr' width='5%'>{$alert_dst_p}</td>
- <td class='listr' width='5%' >
- {$alert_sid_str}
- <a href='?instance={$instanceid}&act=addsuppress&sidid={$fields[2]}&gen_id={$fields[1]}&descr={$alert_descr_url}'>
- <img src='../themes/{$g['theme']}/images/icons/icon_plus.gif'
- width='10' height='10' border='0'
- title='" . gettext("click to add to suppress list") . "'></a>
- </td>
- <td class='listr' width='20%'>{$alert_descr}</td>
+ <td class='listr' align='center'>{$alert_date}<br/>{$alert_time}</td>
+ <td class='listr' align='center'>{$alert_priority}</td>
+ <td class='listr' align='center'>{$alert_proto}</td>
+ <td class='listr' style=\"word-wrap:break-word;\">{$alert_class}</td>
+ <td class='listr' align='center'>{$alert_ip_src}</td>
+ <td class='listr' align='center'>{$alert_src_p}</td>
+ <td class='listr' align='center'>{$alert_ip_dst}</td>
+ <td class='listr' align='center'>{$alert_dst_p}</td>
+ <td class='listr' align='center'>{$alert_sid_str}<br/>{$sidsupplink}</td>
+ <td class='listr' style=\"word-wrap:break-word;\">{$alert_descr}</td>
</tr>\n";
$counter++;
@@ -329,6 +361,7 @@ if (file_exists("/var/log/snort/snort_{$if_real}{$snort_uuid}/alert")) {
</td>
</tr>
</table>
+</div>
</td></tr>
</table>
</form>
diff --git a/config/snort/snort_barnyard.php b/config/snort/snort_barnyard.php
index ccbe3c26..2773fe95 100644
--- a/config/snort/snort_barnyard.php
+++ b/config/snort/snort_barnyard.php
@@ -32,7 +32,7 @@
require_once("guiconfig.inc");
require_once("/usr/local/pkg/snort/snort.inc");
-global $g;
+global $g, $rebuild_rules;
$id = $_GET['id'];
if (isset($_POST['id']))
@@ -87,6 +87,9 @@ if ($_POST) {
}
write_config();
+
+ /* No need to rebuild rules if just toggling Barnyard2 on or off */
+ $rebuild_rules = "off";
sync_snort_package_config();
/* after click go to this page */
@@ -147,20 +150,32 @@ function enable_change(enable_change) {
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td>
<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Snort Interfaces"), true, "/snort/snort_interfaces.php");
+ $tab_array[1] = array(gettext("Global Settings"), false, "/snort/snort_interfaces_global.php");
+ $tab_array[2] = array(gettext("Updates"), false, "/snort/snort_download_updates.php");
+ $tab_array[3] = array(gettext("Alerts"), false, "/snort/snort_alerts.php");
+ $tab_array[4] = array(gettext("Blocked"), false, "/snort/snort_blocked.php");
+ $tab_array[5] = array(gettext("Whitelists"), false, "/snort/snort_interfaces_whitelist.php");
+ $tab_array[6] = array(gettext("Suppress"), false, "/snort/snort_interfaces_suppress.php");
+ $tab_array[7] = array(gettext("Sync"), false, "/pkg_edit.php?xml=snort/snort_sync.xml");
+ display_top_tabs($tab_array);
+ echo '</td></tr>';
+ echo '<tr><td>';
+ $menu_iface=($if_friendly?substr($if_friendly,0,5)." ":"Iface ");
$tab_array = array();
- $tab_array[] = array(gettext("Snort Interfaces"), false, "/snort/snort_interfaces.php");
- $tab_array[] = array(gettext("If Settings"), false, "/snort/snort_interfaces_edit.php?id={$id}");
- $tab_array[] = array(gettext("Categories"), false, "/snort/snort_rulesets.php?id={$id}");
- $tab_array[] = array(gettext("Rules"), false, "/snort/snort_rules.php?id={$id}");
- $tab_array[] = array(gettext("Variables"), false, "/snort/snort_define_servers.php?id={$id}");
- $tab_array[] = array(gettext("Preprocessors"), false, "/snort/snort_preprocessors.php?id={$id}");
- $tab_array[] = array(gettext("Barnyard2"), true, "/snort/snort_barnyard.php?id={$id}");
+ $tab_array[] = array($menu_iface . gettext("Settings"), false, "/snort/snort_interfaces_edit.php?id={$id}");
+ $tab_array[] = array($menu_iface . gettext("Categories"), false, "/snort/snort_rulesets.php?id={$id}");
+ $tab_array[] = array($menu_iface . gettext("Rules"), false, "/snort/snort_rules.php?id={$id}");
+ $tab_array[] = array($menu_iface . gettext("Variables"), false, "/snort/snort_define_servers.php?id={$id}");
+ $tab_array[] = array($menu_iface . gettext("Preprocessors"), false, "/snort/snort_preprocessors.php?id={$id}");
+ $tab_array[] = array($menu_iface . gettext("Barnyard2"), true, "/snort/snort_barnyard.php?id={$id}");
display_top_tabs($tab_array);
?>
</td></tr>
<tr>
- <td class="tabcont">
- <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <td><div id="mainarea">
+ <table id="maintable" class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
<tr>
<td colspan="2" valign="top" class="listtopic"><?php echo gettext("General Barnyard2 " .
"Settings"); ?></td>
@@ -173,12 +188,12 @@ function enable_change(enable_change) {
<?php echo gettext("This will enable barnyard2 for this interface. You will also have to set the database credentials."); ?></td>
</tr>
<tr>
- <td colspan="2" valign="top" class="listtopic"><?php echo gettext("Mysql Settings"); ?></td>
+ <td colspan="2" valign="top" class="listtopic"><?php echo gettext("MySQL Settings"); ?></td>
</tr>
<tr>
- <td width="22%" valign="top" class="vncell"><?php echo gettext("Log to a Mysql Database"); ?></td>
- <td width="78%" class="vtable"><input name="barnyard_mysql"
- type="text" class="formfld" id="barnyard_mysql" size="100"
+ <td width="22%" valign="top" class="vncell"><?php echo gettext("Log to a MySQL Database"); ?></td>
+ <td width="78%" class="vtable"><input name="barnyard_mysql"
+ type="text" class="formfld" id="barnyard_mysql" style="width:95%;" size="85"
value="<?=htmlspecialchars($pconfig['barnyard_mysql']);?>"> <br>
<span class="vexpl"><?php echo gettext("Example: output database: alert, mysql, " .
"dbname=snort user=snort host=localhost password=xyz"); ?><br>
@@ -191,8 +206,8 @@ function enable_change(enable_change) {
<tr>
<td width="22%" valign="top" class="vncell"<?php echo gettext("Advanced configuration " .
"pass through"); ?></td>
- <td width="78%" class="vtable"><textarea name="barnconfigpassthru"
- cols="60" rows="7" id="barnconfigpassthru" ><?=htmlspecialchars($pconfig['barnconfigpassthru']);?></textarea>
+ <td width="78%" class="vtable"><textarea name="barnconfigpassthru" style="width:95%;"
+ cols="65" rows="7" id="barnconfigpassthru" ><?=htmlspecialchars($pconfig['barnconfigpassthru']);?></textarea>
<br>
<?php echo gettext("Arguments here will be automatically inserted into the running " .
"barnyard2 configuration."); ?></td>
@@ -207,10 +222,12 @@ function enable_change(enable_change) {
<td width="22%" valign="top">&nbsp;</td>
<td width="78%"><span class="vexpl"><span class="red"><strong><?php echo gettext("Note:"); ?></strong></span>
<br>
- <?php echo gettext("Please save your settings befor you click start."); ?> </td>
+ <?php echo gettext("Please save your settings before you click start."); ?> </td>
</tr>
</table>
-
+ </div>
+ </td>
+ </tr>
</table>
</form>
<script language="JavaScript">
diff --git a/config/snort/snort_blocked.php b/config/snort/snort_blocked.php
index def5dd22..43b351ab 100644
--- a/config/snort/snort_blocked.php
+++ b/config/snort/snort_blocked.php
@@ -134,62 +134,70 @@ if ($pconfig['brefresh'] == 'on')
<?php if ($savemsg) print_info_box($savemsg); ?>
<form action="/snort/snort_blocked.php" method="post">
-<table width="99%" border="0" cellpadding="0" cellspacing="0">
-<tr><td>
-<?php
- $tab_array = array();
- $tab_array[0] = array(gettext("Snort Interfaces"), false, "/snort/snort_interfaces.php");
- $tab_array[1] = array(gettext("Global Settings"), false, "/snort/snort_interfaces_global.php");
- $tab_array[2] = array(gettext("Updates"), false, "/snort/snort_download_updates.php");
- $tab_array[3] = array(gettext("Alerts"), false, "/snort/snort_alerts.php");
- $tab_array[4] = array(gettext("Blocked"), true, "/snort/snort_blocked.php");
- $tab_array[5] = array(gettext("Whitelists"), false, "/snort/snort_interfaces_whitelist.php");
- $tab_array[6] = array(gettext("Suppress"), false, "/snort/snort_interfaces_suppress.php");
- display_top_tabs($tab_array);
-?>
-</td></tr>
- <tr>
- <td>
- <table id="maintable" class="tabcont" width="100%" border="0"
- cellpadding="0" cellspacing="0">
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+<tr>
+ <td>
+ <?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Snort Interfaces"), false, "/snort/snort_interfaces.php");
+ $tab_array[1] = array(gettext("Global Settings"), false, "/snort/snort_interfaces_global.php");
+ $tab_array[2] = array(gettext("Updates"), false, "/snort/snort_download_updates.php");
+ $tab_array[3] = array(gettext("Alerts"), false, "/snort/snort_alerts.php");
+ $tab_array[4] = array(gettext("Blocked"), true, "/snort/snort_blocked.php");
+ $tab_array[5] = array(gettext("Whitelists"), false, "/snort/snort_interfaces_whitelist.php");
+ $tab_array[6] = array(gettext("Suppress"), false, "/snort/snort_interfaces_suppress.php");
+ $tab_array[7] = array(gettext("Sync"), false, "/pkg_edit.php?xml=snort/snort_sync.xml");
+ display_top_tabs($tab_array);
+ ?>
+ </td>
+</tr>
+<tr>
+ <td><div id="mainarea">
+ <table id="maintable" class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
<tr>
- <td width="22%" colspan="0" class="listtopic"><?php printf(gettext("Last %s " .
- "Blocked."), $bnentries); ?></td>
- <td width="78%" class="listtopic"><?php echo gettext("This page lists hosts that have " .
- "been blocked by Snort."); ?>&nbsp;&nbsp;<?=$blocked_msg_txt;?></td>
+ <td colspan="2" class="listtopic"><?php echo gettext("Blocked Hosts Log View Settings"); ?></td>
</tr>
<tr>
<td width="22%" class="vncell"><?php echo gettext("Save or Remove Hosts"); ?></td>
<td width="78%" class="vtable">
- <input name="download" type="submit" class="formbtn" value="Download"> <?php echo gettext("All " .
- "blocked hosts will be saved."); ?> <input name="remove" type="submit"
- class="formbtn" value="Clear"> <span class="red"><strong><?php echo gettext("Warning:"); ?></strong></span>
- <?php echo gettext("all hosts will be removed."); ?></form>
+ <input name="download" type="submit" class="formbtns" value="Download"> <?php echo gettext("All " .
+ "blocked hosts will be saved."); ?>&nbsp;&nbsp;<input name="remove" type="submit"
+ class="formbtns" value="Clear">&nbsp;<span class="red"><strong><?php echo gettext("Warning:"); ?></strong></span>
+ <?php echo gettext("all hosts will be removed."); ?>
</td>
</tr>
<tr>
<td width="22%" class="vncell"><?php echo gettext("Auto Refresh and Log View"); ?></td>
<td width="78%" class="vtable">
- <input name="save" type="submit" class="formbtn" value="Save"> <?php echo gettext("Refresh"); ?> <input
+ <input name="save" type="submit" class="formbtns" value="Save"> <?php echo gettext("Refresh"); ?> <input
name="brefresh" type="checkbox" value="on"
<?php if ($config['installedpackages']['snortglobal']['alertsblocks']['brefresh']=="on" || $config['installedpackages']['snortglobal']['alertsblocks']['brefresh']=='') echo "checked"; ?>>
- <?php printf(gettext("%sDefault%s is %sON%s."), '<strong>', '</strong>', '<strong>', '</strong>'); ?> <input
+ <?php printf(gettext("%sDefault%s is %sON%s."), '<strong>', '</strong>', '<strong>', '</strong>'); ?>&nbsp;&nbsp;<input
name="blertnumber" type="text" class="formfld" id="blertnumber"
size="5" value="<?=htmlspecialchars($bnentries);?>"> <?php printf(gettext("Enter the " .
"number of blocked entries to view. %sDefault%s is %s500%s."), '<strong>', '</strong>', '<strong>', '</strong>'); ?>
</td>
</tr>
- <tr>
- <td colspan="2">
- <table id="sortabletable1" class="sortable" width="100%" border="0"
- cellpadding="0" cellspacing="0">
- <tr id="frheader">
- <td width="5%" class="listhdrr">#</td>
- <td width="15%" class="listhdrr"><?php echo gettext("IP"); ?></td>
- <td width="70%" class="listhdrr"><?php echo gettext("Alert Description"); ?></td>
- <td width="5%" class="listhdrr"><?php echo gettext("Remove"); ?></td>
- </tr>
- <?php
+ <tr>
+ <td colspan="2" class="listtopic"><?php printf(gettext("Last %s Hosts Blocked by Snort"), $bnentries); ?></td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <table id="sortabletable1" style="table-layout: fixed;" class="sortable" width="100%" border="0" cellpadding="2" cellspacing="0">
+ <colgroup>
+ <col width="5%" align="center" axis="number">
+ <col width="15%" align="center" axis="string">
+ <col width="70%" align="left" axis="string">
+ <col width="10%" align="center">
+ </colgroup>
+ <thead>
+ <th class="listhdrr" axis="number">#</th>
+ <th class="listhdrr" axis="string"><?php echo gettext("IP"); ?></th>
+ <th class="listhdrr" axis="string"><?php echo gettext("Alert Description"); ?></th>
+ <th class="listhdrr"><?php echo gettext("Remove"); ?></th>
+ </thead>
+ <tbody>
+ <?php
/* set the arrays */
$blocked_ips_array = array();
if (is_array($blocked_ips)) {
@@ -232,37 +240,52 @@ if ($pconfig['brefresh'] == 'on')
$src_ip_list[$blocked_ip] = array("N\A\n");
}
- /* buil final list, preg_match, buld html */
+ /* build final list, preg_match, build html */
$counter = 0;
foreach($src_ip_list as $blocked_ip => $blocked_msg) {
- $blocked_desc = "<br/>" . implode("<br/>", $blocked_msg);
+ $blocked_desc = implode("<br/>", $blocked_msg);
if($counter > $bnentries)
break;
else
$counter++;
- /* use one echo to do the magic*/
- echo "<tr>
- <td width='5%' >&nbsp;{$counter}</td>
- <td width='15%' >&nbsp;{$blocked_ip}</td>
- <td width='70%' >&nbsp;{$blocked_desc}</td>
- <td width='5%' align=\"center\" valign=\"top\"'><a href='snort_blocked.php?todelete=" . trim(urlencode($blocked_ip)) . "'>
- <img title=\"" . gettext("Delete") . "\" border=\"0\" name='todelete' id='todelete' alt=\"Delete\" src=\"../themes/{$g['theme']}/images/icons/icon_x.gif\"></a></td>
- </tr>\n";
+ /* Add zero-width space as soft-break opportunity after each colon if we have an IPv6 address */
+ $tmp_ip = str_replace(":", ":&#8203;", $blocked_ip);
+ /* use one echo to do the magic*/
+ echo "<tr>
+ <td align=\"center\" valign=\"middle\" class=\"listr\">{$counter}</td>
+ <td valign=\"middle\" class=\"listr\">{$tmp_ip}</td>
+ <td valign=\"middle\" class=\"listr\">{$blocked_desc}</td>
+ <td align=\"center\" valign=\"middle\" class=\"listr\"><a href='snort_blocked.php?todelete=" . trim(urlencode($blocked_ip)) . "'>
+ <img title=\"" . gettext("Delete host from Blocked Table") . "\" border=\"0\" name='todelete' id='todelete' alt=\"Delete host from Blocked Table\" src=\"../themes/{$g['theme']}/images/icons/icon_x.gif\"></a></td>
+ </tr>\n";
}
- echo "\n<tr><td colspan='3' align=\"center\" valign=\"top\">{$counter} items listed.</td></tr>";
- } else
- echo "\n<tr><td colspan='3' align=\"center\" valign=\"top\"><br><strong>There are currently no items being blocked by snort.</strong></td></tr>";
-
+ }
?>
- </table>
- </td>
- </tr>
-</table>
- </td>
- </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2" class="vexpl" align="center">
+ <?php if (!empty($blocked_ips_array)) {
+ if ($counter > 1)
+ echo "{$counter}" . gettext(" host IP addresses are currently being blocked.");
+ else
+ echo "{$counter}" . gettext(" host IP address is currently being blocked.");
+ }
+ else {
+ echo gettext("There are currently no hosts being blocked by Snort.");
+ }
+ ?>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </td>
+</tr>
</table>
</form>
<?php
diff --git a/config/snort/snort_check_for_rule_updates.php b/config/snort/snort_check_for_rule_updates.php
index af5d378c..2b60b6ce 100755
--- a/config/snort/snort_check_for_rule_updates.php
+++ b/config/snort/snort_check_for_rule_updates.php
@@ -31,71 +31,179 @@
require_once("functions.inc");
require_once("service-utils.inc");
-require_once("/usr/local/pkg/snort/snort.inc");
+require_once "/usr/local/pkg/snort/snort.inc";
-global $snort_gui_include;
+global $snort_gui_include, $vrt_enabled, $et_enabled, $rebuild_rules, $snort_rules_upd_log;
+global $protect_preproc_rules, $is_postinstall, $snort_community_rules_filename;
+global $snort_community_rules_url, $snort_rules_file, $emergingthreats_filename, $g, $pkg_interface;
$snortdir = SNORTDIR;
-
-if (!isset($snort_gui_include))
+$snortlibdir = SNORTLIBDIR;
+$snortlogdir = SNORTLOGDIR;
+
+/* Save the state of $pkg_interface so we can restore it */
+$pkg_interface_orig = $pkg_interface;
+if ($snort_gui_include)
+ $pkg_interface = "";
+else
$pkg_interface = "console";
-$tmpfname = "{$snortdir}/tmp/snort_rules_up";
-$snort_filename_md5 = "{$snort_rules_file}.md5";
-$snort_filename = "{$snort_rules_file}";
-$emergingthreats_filename_md5 = "emerging.rules.tar.gz.md5";
-$emergingthreats_filename = "emerging.rules.tar.gz";
-
/* define checks */
$oinkid = $config['installedpackages']['snortglobal']['oinkmastercode'];
$snortdownload = $config['installedpackages']['snortglobal']['snortdownload'];
$emergingthreats = $config['installedpackages']['snortglobal']['emergingthreats'];
+$snortcommunityrules = $config['installedpackages']['snortglobal']['snortcommunityrules'];
$vrt_enabled = $config['installedpackages']['snortglobal']['snortdownload'];
$et_enabled = $config['installedpackages']['snortglobal']['emergingthreats'];
-/* Start of code */
-conf_mount_rw();
+/* Directory where we download rule tarballs */
+$tmpfname = "{$snortdir}/tmp/snort_rules_up";
-if (!is_dir($tmpfname))
- exec("/bin/mkdir -p {$tmpfname}");
+/* Snort VRT rules files and URL */
+$snort_filename_md5 = "{$snort_rules_file}.md5";
+$snort_filename = "{$snort_rules_file}";
+//$snort_rule_url = "http://www.snort.org/pub-bin/oinkmaster.cgi/{$oinkid}/";
+/* Use current Sourcefire VRT download URL and abandon the old CGI one */
+$snort_rule_url = "https://www.snort.org/reg-rules/";
+
+/* Emerging Threats rules MD5 file */
+$emergingthreats_filename_md5 = "{$emergingthreats_filename}.md5";
+
+/* Snort GPLv2 Community Rules MD5 file */
+$snort_community_rules_filename_md5 = "{$snort_community_rules_filename}.md5";
+
+/* Custom function for rules file download via URL */
+function snort_download_file_url($url, $file_out) {
+
+ /************************************************/
+ /* This function downloads the file specified */
+ /* by $url using the CURL library functions and */
+ /* saves the content to the file specified by */
+ /* $file. */
+ /* */
+ /************************************************/
+
+ global $g, $config, $pkg_interface, $last_curl_error;
+
+ /* Array of message strings for HTTP Response Codes */
+ $http_resp_msg = array( 200 => "OK", 202 => "Accepted", 204 => "No Content", 205 => "Reset Content",
+ 206 => "Partial Content", 301 => "Moved Permanently", 302 => "Found",
+ 305 => "Use Proxy", 307 => "Temporary Redirect", 400 => "Bad Request",
+ 401 => "Unauthorized", 402 => "Payment Required", 403 => "Forbidden",
+ 404 => "Not Found", 405 => "Method Not Allowed", 407 => "Proxy Authentication Required",
+ 408 => "Request Timeout", 410 => "Gone", 500 => "Internal Server Error",
+ 501 => "Not Implemented", 502 => "Bad Gateway", 503 => "Service Unavailable",
+ 504 => "Gateway Timeout", 505 => "HTTP Version Not Supported" );
+
+ $last_curl_error = "";
+
+ /* If not in console mode, use the built-in progress-bar function */
+ if ($pkg_interface <> "console")
+ return download_file_with_progress_bar($url, $file_out);
+
+ /* Otherwise, use our custom function with no output */
+ /* (Note: required to suppress errors from XMLRPC) */
+ $fp = fopen($file_out, "wb");
+ if ($fp) {
+ $ch = curl_init($url);
+ if (!$ch)
+ return false;
+ curl_setopt($ch, CURLOPT_FILE, $fp);
+ curl_setopt($ch, CURLOPT_HEADER, false);
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
+ curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Win64; x64; Trident/6.0)");
+ /* Don't verify SSL peers since we don't have the certificates to do so. */
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
+ curl_setopt($ch, CURLOPT_TIMEOUT, 0);
+ $counter = 0;
+ $rc = true;
+ /* Try up to 4 times to download the file before giving up */
+ while ($counter < 4) {
+ $counter++;
+ $rc = curl_exec($ch);
+ if ($rc === true)
+ break;
+ log_error(gettext("[Snort] Rules download error: " . curl_error($ch)));
+ log_error(gettext("[Snort] Will retry in 15 seconds..."));
+ sleep(15);
+ }
+ if ($rc === false)
+ $last_curl_error = curl_error($ch);
+ $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+ if (isset($http_resp_msg[$http_code]))
+ $last_curl_error = $http_resp_msg[$http_code];
+ curl_close($ch);
+ fclose($fp);
+ /* If we had to try more than once, log it */
+ if ($counter > 1)
+ log_error(gettext("File '" . basename($file_out) . "' download attempts: {$counter} ..."));
+ return ($http_code == 200) ? true : $http_code;
+ }
+ else {
+ $last_curl_error = gettext("Failed to create file " . $file_out);
+ log_error(gettext("[Snort] Failed to create file {$file_out} ..."));
+ return false;
+ }
+}
-/* Set user agent to Mozilla */
-ini_set('user_agent','Mozilla/4.0 (compatible; MSIE 6.0)');
-ini_set("memory_limit","150M");
+/* Start of code */
+conf_mount_rw();
/* remove old $tmpfname files */
if (is_dir("{$tmpfname}"))
exec("/bin/rm -r {$tmpfname}");
-/* Make sure snortdir exits */
+/* Make sure required snortdirs exsist */
exec("/bin/mkdir -p {$snortdir}/rules");
exec("/bin/mkdir -p {$snortdir}/signatures");
+exec("/bin/mkdir -p {$snortdir}/preproc_rules");
exec("/bin/mkdir -p {$tmpfname}");
-exec("/bin/mkdir -p /usr/local/lib/snort/dynamicrules");
+exec("/bin/mkdir -p {$snortlibdir}/dynamicrules");
+exec("/bin/mkdir -p {$snortlogdir}");
+
+/* See if we need to automatically clear the Update Log based on 1024K size limit */
+if (file_exists($snort_rules_upd_log)) {
+ if (1048576 < filesize($snort_rules_upd_log))
+ exec("/bin/rm -r {$snort_rules_upd_log}");
+}
+
+/* Log start time for this rules update */
+error_log(gettext("Starting rules update... Time: " . date("Y-m-d H:i:s") . "\n"), 3, $snort_rules_upd_log);
+$last_curl_error = "";
/* download md5 sig from snort.org */
if ($snortdownload == 'on') {
- update_status(gettext("Downloading snort.org md5 file..."));
- $max_tries = 4;
- while ($max_tries > 0) {
- $image = @file_get_contents("http://www.snort.org/pub-bin/oinkmaster.cgi/{$oinkid}/{$snort_filename_md5}");
- if (false === $image) {
- $max_tries--;
- if ($max_tries > 0)
- sleep(30);
- continue;
- } else
- break;
- }
- log_error("Snort MD5 Attempts: " . (4 - $max_tries + 1));
- @file_put_contents("{$tmpfname}/{$snort_filename_md5}", $image);
- if (0 == filesize("{$tmpfname}/{$snort_filename_md5}")) {
- update_status(gettext("Please wait... You may only check for New Rules every 15 minutes..."));
- log_error(gettext("Please wait... You may only check for New Rules every 15 minutes..."));
- update_output_window(gettext("Rules are released every month from snort.org. You may download the Rules at any time."));
+ if ($pkg_interface <> "console")
+ update_status(gettext("Downloading Snort VRT md5 file..."));
+ error_log(gettext("\tDownloading Snort VRT md5 file...\n"), 3, $snort_rules_upd_log);
+ $rc = snort_download_file_url("{$snort_rule_url}{$snort_filename_md5}/{$oinkid}/", "{$tmpfname}/{$snort_filename_md5}");
+ if ($rc === true) {
+ if ($pkg_interface <> "console")
+ update_status(gettext("Done downloading snort.org md5."));
+ error_log("\tChecking Snort VRT md5 file...\n", 3, $snort_rules_upd_log);
+ }
+ else {
+ error_log(gettext("\tSnort VRT md5 download failed.\n"), 3, $snort_rules_upd_log);
+ if ($rc == 403) {
+ $snort_err_msg = gettext("Too many attempts or Oinkcode not authorized for this Snort version.\n");
+ $snort_err_msg .= gettext("\tFree Registered User accounts may download Snort VRT Rules once every 15 minutes.\n");
+ $snort_err_msg .= gettext("\tPaid Subscriber accounts have no download limits.\n");
+ }
+ else
+ $snort_err_msg = gettext("Server returned error code '{$rc}'.");
+ if ($pkg_interface <> "console") {
+ update_status(gettext("Snort VRT md5 error ... Server returned error code {$rc} ..."));
+ update_output_window(gettext("Snort VRT rules will not be updated.\n{$snort_err_msg}"));
+ }
+ log_error(gettext("[Snort] Snort VRT md5 download failed..."));
+ log_error(gettext("[Snort] Server returned error code '{$rc}'..."));
+ error_log(gettext("\t{$snort_err_msg}\n"), 3, $snort_rules_upd_log);
+ if ($pkg_interface == "console")
+ error_log(gettext("\tServer error message was '{$last_curl_error}'\n"), 3, $snort_rules_upd_log);
+ error_log(gettext("\tSnort VRT rules will not be updated.\n"), 3, $snort_rules_upd_log);
$snortdownload = 'off';
- } else
- update_status(gettext("Done downloading snort.org md5"));
+ }
}
/* Check if were up to date snort.org */
@@ -104,8 +212,10 @@ if ($snortdownload == 'on') {
$md5_check_new = file_get_contents("{$tmpfname}/{$snort_filename_md5}");
$md5_check_old = file_get_contents("{$snortdir}/{$snort_filename_md5}");
if ($md5_check_new == $md5_check_old) {
- update_status(gettext("Snort rules are up to date..."));
- log_error("Snort rules are up to date...");
+ if ($pkg_interface <> "console")
+ update_status(gettext("Snort VRT rules are up to date..."));
+ log_error(gettext("[Snort] Snort VRT rules are up to date..."));
+ error_log(gettext("\tSnort VRT rules are up to date.\n"), 3, $snort_rules_upd_log);
$snortdownload = 'off';
}
}
@@ -113,84 +223,246 @@ if ($snortdownload == 'on') {
/* download snortrules file */
if ($snortdownload == 'on') {
- update_status(gettext("There is a new set of Snort.org rules posted. Downloading..."));
- log_error(gettext("There is a new set of Snort.org rules posted. Downloading..."));
- $max_tries = 4;
- while ($max_tries > 0) {
- download_file_with_progress_bar("http://www.snort.org/pub-bin/oinkmaster.cgi/{$oinkid}/{$snort_filename}", "{$tmpfname}/{$snort_filename}");
- if (300000 > filesize("{$tmpfname}/$snort_filename")){
- $max_tries--;
- if ($max_tries > 0)
- sleep(30);
- continue;
- } else
- break;
- }
- update_status(gettext("Done downloading rules file."));
- log_error("Snort Rules Attempts: " . (4 - $max_tries + 1));
- if (300000 > filesize("{$tmpfname}/$snort_filename")){
- update_output_window(gettext("Snort rules file download failed..."));
- log_error(gettext("Snort rules file download failed..."));
- log_error("Failed Rules Filesize: " . filesize("{$tmpfname}/$snort_filename"));
+ if ($pkg_interface <> "console")
+ update_status(gettext("There is a new set of Snort VRT rules posted. Downloading..."));
+ log_error(gettext("[Snort] There is a new set of Snort VRT rules posted. Downloading..."));
+ error_log(gettext("\tThere is a new set of Snort VRT rules posted. Downloading...\n"), 3, $snort_rules_upd_log);
+ $rc = snort_download_file_url("{$snort_rule_url}{$snort_filename}/{$oinkid}/", "{$tmpfname}/{$snort_filename}");
+ if ($rc === true) {
+ if ($pkg_interface <> "console")
+ update_status(gettext("Done downloading Snort VRT rules file."));
+ error_log(gettext("\tDone downloading rules file.\n"),3, $snort_rules_upd_log);
+ if (trim(file_get_contents("{$tmpfname}/{$snort_filename_md5}")) != trim(md5_file("{$tmpfname}/{$snort_filename}"))){
+ if ($pkg_interface <> "console")
+ update_output_window(gettext("Snort VRT rules file MD5 checksum failed..."));
+ log_error(gettext("[Snort] Snort VRT rules file download failed. Bad MD5 checksum..."));
+ log_error(gettext("[Snort] Failed File MD5: " . md5_file("{$tmpfname}/{$snort_filename}")));
+ log_error(gettext("[Snort] Expected File MD5: " . file_get_contents("{$tmpfname}/{$snort_filename_md5}")));
+ error_log(gettext("\tSnort VRT rules file download failed. Bad MD5 checksum.\n"), 3, $snort_rules_upd_log);
+ error_log(gettext("\tDownloaded Snort VRT file MD5: " . md5_file("{$tmpfname}/{$snort_filename}") . "\n"), 3, $snort_rules_upd_log);
+ error_log(gettext("\tExpected Snort VRT file MD5: " . file_get_contents("{$tmpfname}/{$snort_filename_md5}") . "\n"), 3, $snort_rules_upd_log);
+ error_log(gettext("\tSnort VRT rules file download failed. Snort VRT rules will not be updated.\n"), 3, $snort_rules_upd_log);
+ $snortdownload = 'off';
+ }
+ }
+ else {
+ if ($pkg_interface <> "console")
+ update_output_window(gettext("Snort VRT rules file download failed..."));
+ log_error(gettext("[Snort] Snort VRT rules file download failed... server returned error '{$rc}'..."));
+ error_log(gettext("\tSnort VRT rules file download failed. Server returned error {$rc}.\n"), 3, $snort_rules_upd_log);
+ if ($pkg_interface == "console")
+ error_log(gettext("\tThe error text was '{$last_curl_error}'\n"), 3, $snort_rules_upd_log);
+ error_log(gettext("\tSnort VRT rules will not be updated.\n"), 3, $snort_rules_upd_log);
$snortdownload = 'off';
}
}
+/* download md5 sig from Snort GPLv2 Community Rules */
+if ($snortcommunityrules == 'on') {
+ if ($pkg_interface <> "console")
+ update_status(gettext("Downloading Snort GPLv2 Community Rules md5 file..."));
+ error_log(gettext("\tDownloading Snort GPLv2 Community Rules md5 file...\n"), 3, $snort_rules_upd_log);
+ $rc = snort_download_file_url("{$snort_community_rules_url}{$snort_community_rules_filename_md5}", "{$tmpfname}/{$snort_community_rules_filename_md5}");
+ if ($rc === true) {
+ if ($pkg_interface <> "console")
+ update_status(gettext("Done downloading Snort GPLv2 Community Rules md5"));
+ error_log(gettext("\tChecking Snort GPLv2 Community Rules md5.\n"), 3, $snort_rules_upd_log);
+ if (file_exists("{$snortdir}/{$snort_community_rules_filename_md5}") && $snortcommunityrules == "on") {
+ /* Check if were up to date Snort GPLv2 Community Rules */
+ $snort_comm_md5_check_new = file_get_contents("{$tmpfname}/{$snort_community_rules_filename_md5}");
+ $snort_comm_md5_check_old = file_get_contents("{$snortdir}/{$snort_community_rules_filename_md5}");
+ if ($snort_comm_md5_check_new == $snort_comm_md5_check_old) {
+ if ($pkg_interface <> "console")
+ update_status(gettext("Snort GPLv2 Community Rules are up to date..."));
+ log_error(gettext("[Snort] Snort GPLv2 Community Rules are up to date..."));
+ error_log(gettext("\tSnort GPLv2 Community Rules are up to date.\n"), 3, $snort_rules_upd_log);
+ $snortcommunityrules = 'off';
+ }
+ }
+ }
+ else {
+ if ($pkg_interface <> "console")
+ update_output_window(gettext("Snort GPLv2 Community Rules md5 file download failed. Community Rules will not be updated."));
+ log_error(gettext("[Snort] Snort GPLv2 Community Rules md5 file download failed. Server returned error code '{$rc}'."));
+ error_log(gettext("\tSnort GPLv2 Community Rules md5 file download failed. Server returned error code '{$rc}'.\n"), 3, $snort_rules_upd_log);
+ if ($pkg_interface == "console")
+ error_log(gettext("\tThe error text is '{$last_curl_error}'\n"), 3, $snort_rules_upd_log);
+ error_log(gettext("\tSnort GPLv2 Community Rules will not be updated.\n"), 3, $snort_rules_upd_log);
+ $snortcommunityrules = 'off';
+ }
+}
+
+/* download Snort GPLv2 Community rules file */
+if ($snortcommunityrules == "on") {
+ if ($pkg_interface <> "console")
+ update_status(gettext("There is a new set of Snort GPLv2 Community Rules posted. Downloading..."));
+ log_error(gettext("[Snort] There is a new set of Snort GPLv2 Community Rules posted. Downloading..."));
+ error_log(gettext("\tThere is a new set of Snort GPLv2 Community Rules posted. Downloading...\n"), 3, $snort_rules_upd_log);
+ $rc = snort_download_file_url("{$snort_community_rules_url}{$snort_community_rules_filename}", "{$tmpfname}/{$snort_community_rules_filename}");
+
+ /* Test for a valid rules file download. Turn off Snort Community update if download failed. */
+ if ($rc === true) {
+ if (trim(file_get_contents("{$tmpfname}/{$snort_community_rules_filename_md5}")) != trim(md5_file("{$tmpfname}/{$snort_community_rules_filename}"))){
+ if ($pkg_interface <> "console")
+ update_output_window(gettext("Snort GPLv2 Community Rules file MD5 checksum failed..."));
+ log_error(gettext("[Snort] Snort GPLv2 Community Rules file download failed. Bad MD5 checksum..."));
+ log_error(gettext("[Snort] Failed File MD5: " . md5_file("{$tmpfname}/{$snort_community_rules_filename}")));
+ log_error(gettext("[Snort] Expected File MD5: " . file_get_contents("{$tmpfname}/{$snort_community_rules_filename_md5}")));
+ error_log(gettext("\tSnort GPLv2 Community Rules file download failed. Community Rules will not be updated.\n"), 3, $snort_rules_upd_log);
+ error_log(gettext("\tDownloaded Snort GPLv2 file MD5: " . md5_file("{$tmpfname}/{$snort_community_rules_filename}") . "\n"), 3, $snort_rules_upd_log);
+ error_log(gettext("\tExpected Snort GPLv2 file MD5: " . file_get_contents("{$tmpfname}/{$snort_community_rules_filename_md5}") . "\n"), 3, $snort_rules_upd_log);
+ $snortcommunityrules = 'off';
+ }
+ else {
+ if ($pkg_interface <> "console")
+ update_status(gettext('Done downloading Snort GPLv2 Community Rules file.'));
+ log_error("[Snort] Snort GPLv2 Community Rules file update downloaded successfully");
+ error_log(gettext("\tDone downloading Snort GPLv2 Community Rules file.\n"), 3, $snort_rules_upd_log);
+ }
+ }
+ else {
+ if ($pkg_interface <> "console") {
+ update_status(gettext("The server returned error code {$rc} ... skipping GPLv2 Community Rules..."));
+ update_output_window(gettext("Snort GPLv2 Community Rules file download failed..."));
+ }
+ log_error(gettext("[Snort] Snort GPLv2 Community Rules file download failed. Server returned error '{$rc}'..."));
+ error_log(gettext("\tSnort GPLv2 Community Rules download failed. Server returned error '{$rc}'...\n"), 3, $snort_rules_upd_log);
+ if ($pkg_interface == "console")
+ error_log(gettext("\tThe error text is '{$last_curl_error}'\n"), 3, $snort_rules_upd_log);
+ $snortcommunityrules = 'off';
+ }
+}
+
+/* Untar Snort GPLv2 Community rules to tmp */
+if ($snortcommunityrules == 'on') {
+ safe_mkdir("{$snortdir}/tmp/community");
+ if (file_exists("{$tmpfname}/{$snort_community_rules_filename}")) {
+ if ($pkg_interface <> "console") {
+ update_status(gettext("Extracting Snort GPLv2 Community Rules..."));
+ update_output_window(gettext("Installing Snort GPLv2 Community Rules..."));
+ }
+ error_log(gettext("\tExtracting and installing Snort GPLv2 Community Rules...\n"), 3, $snort_rules_upd_log);
+ exec("/usr/bin/tar xzf {$tmpfname}/{$snort_community_rules_filename} -C {$snortdir}/tmp/community/");
+
+ $files = glob("{$snortdir}/tmp/community/community-rules/*.rules");
+ foreach ($files as $file) {
+ $newfile = basename($file);
+ @copy($file, "{$snortdir}/rules/GPLv2_{$newfile}");
+ }
+ /* base etc files for Snort GPLv2 Community rules */
+ foreach (array("classification.config", "reference.config", "gen-msg.map", "unicode.map") as $file) {
+ if (file_exists("{$snortdir}/tmp/community/community-rules/{$file}"))
+ @copy("{$snortdir}/tmp/community/community-rules/{$file}", "{$snortdir}/tmp/GPLv2_{$file}");
+ }
+ /* Copy snort community md5 sig to snort dir */
+ if (file_exists("{$tmpfname}/{$snort_community_rules_filename_md5}")) {
+ if ($pkg_interface <> "console")
+ update_status(gettext("Copying md5 signature to snort directory..."));
+ @copy("{$tmpfname}/{$snort_community_rules_filename_md5}", "{$snortdir}/{$snort_community_rules_filename_md5}");
+ }
+ if ($pkg_interface <> "console") {
+ update_status(gettext("Extraction of Snort GPLv2 Community Rules completed..."));
+ update_output_window(gettext("Installation of Snort GPLv2 Community Rules file completed..."));
+ }
+ error_log(gettext("\tInstallation of Snort GPLv2 Community Rules completed.\n"), 3, $snort_rules_upd_log);
+ exec("rm -r {$snortdir}/tmp/community");
+ }
+}
+
/* download md5 sig from emergingthreats.net */
if ($emergingthreats == 'on') {
- update_status(gettext("Downloading emergingthreats md5 file..."));
-
+ if ($pkg_interface <> "console")
+ update_status(gettext("Downloading EmergingThreats md5 file..."));
+ error_log(gettext("\tDownloading EmergingThreats md5 file...\n"), 3, $snort_rules_upd_log);
/* If using Sourcefire VRT rules with ET, then we should use the open-nogpl ET rules. */
if ($vrt_enabled == "on")
- $image = @file_get_contents("http://rules.emergingthreats.net/open-nogpl/snort-{$emerging_threats_version}/emerging.rules.tar.gz.md5");
+ $rc = snort_download_file_url("http://rules.emergingthreats.net/open-nogpl/snort-{$emerging_threats_version}/{$emergingthreats_filename_md5}", "{$tmpfname}/{$emergingthreats_filename_md5}");
else
- $image = @file_get_contents("http://rules.emergingthreats.net/open/snort-{$emerging_threats_version}/emerging.rules.tar.gz.md5");
-
- /* XXX: error checking */
- @file_put_contents("{$tmpfname}/{$emergingthreats_filename_md5}", $image);
- update_status(gettext("Done downloading emergingthreats md5"));
-
- if (file_exists("{$snortdir}/{$emergingthreats_filename_md5}")) {
- /* Check if were up to date emergingthreats.net */
- $emerg_md5_check_new = file_get_contents("{$tmpfname}/{$emergingthreats_filename_md5}");
- $emerg_md5_check_old = file_get_contents("{$snortdir}/{$emergingthreats_filename_md5}");
- if ($emerg_md5_check_new == $emerg_md5_check_old) {
- update_status(gettext("Emerging threat rules are up to date..."));
- log_error(gettext("Emerging threat rules are up to date..."));
- $emergingthreats = 'off';
+ $rc = snort_download_file_url("http://rules.emergingthreats.net/open/snort-{$emerging_threats_version}/{$emergingthreats_filename_md5}", "{$tmpfname}/{$emergingthreats_filename_md5}");
+ if ($rc === true) {
+ if ($pkg_interface <> "console")
+ update_status(gettext("Done downloading EmergingThreats md5"));
+ error_log(gettext("\tChecking EmergingThreats md5.\n"), 3, $snort_rules_upd_log);
+ if (file_exists("{$snortdir}/{$emergingthreats_filename_md5}") && $emergingthreats == "on") {
+ /* Check if were up to date emergingthreats.net */
+ $emerg_md5_check_new = file_get_contents("{$tmpfname}/{$emergingthreats_filename_md5}");
+ $emerg_md5_check_old = file_get_contents("{$snortdir}/{$emergingthreats_filename_md5}");
+ if ($emerg_md5_check_new == $emerg_md5_check_old) {
+ if ($pkg_interface <> "console")
+ update_status(gettext("Emerging Threats rules are up to date..."));
+ log_error(gettext("[Snort] Emerging Threat rules are up to date..."));
+ error_log(gettext("\tEmerging Threats rules are up to date.\n"), 3, $snort_rules_upd_log);
+ $emergingthreats = 'off';
+ }
}
}
+ else {
+ if ($pkg_interface <> "console")
+ update_output_window(gettext("EmergingThreats md5 file download failed. EmergingThreats rules will not be updated."));
+ log_error(gettext("[Snort] EmergingThreats md5 file download failed. Server returned error code '{$rc}'."));
+ error_log(gettext("\tEmergingThreats md5 file download failed. Server returned error code '{$rc}'.\n"), 3, $snort_rules_upd_log);
+ if ($pkg_interface == "console")
+ error_log(gettext("\tThe error text is '{$last_curl_error}'\n"), 3, $snort_rules_upd_log);
+ error_log(gettext("\tEmergingThreats rules will not be updated.\n"), 3, $snort_rules_upd_log);
+ $emergingthreats = 'off';
+ }
}
/* download emergingthreats rules file */
if ($emergingthreats == "on") {
- update_status(gettext("There is a new set of Emergingthreats rules posted. Downloading..."));
- log_error(gettext("There is a new set of Emergingthreats rules posted. Downloading..."));
+ if ($pkg_interface <> "console")
+ update_status(gettext("There is a new set of EmergingThreats rules posted. Downloading..."));
+ log_error(gettext("[Snort] There is a new set of EmergingThreats rules posted. Downloading..."));
+ error_log(gettext("\tThere is a new set of EmergingThreats rules posted. Downloading...\n"), 3, $snort_rules_upd_log);
/* If using Sourcefire VRT rules with ET, then we should use the open-nogpl ET rules. */
if ($vrt_enabled == "on")
- download_file_with_progress_bar("http://rules.emergingthreats.net/open-nogpl/snort-{$emerging_threats_version}/emerging.rules.tar.gz", "{$tmpfname}/{$emergingthreats_filename}");
+ $rc = snort_download_file_url("http://rules.emergingthreats.net/open-nogpl/snort-{$emerging_threats_version}/emerging.rules.tar.gz", "{$tmpfname}/{$emergingthreats_filename}");
else
- download_file_with_progress_bar("http://rules.emergingthreats.net/open/snort-{$emerging_threats_version}/emerging.rules.tar.gz", "{$tmpfname}/{$emergingthreats_filename}");
-
- update_status(gettext('Done downloading Emergingthreats rules file.'));
- log_error("Emergingthreats rules file update downloaded succsesfully");
+ $rc = snort_download_file_url("http://rules.emergingthreats.net/open/snort-{$emerging_threats_version}/emerging.rules.tar.gz", "{$tmpfname}/{$emergingthreats_filename}");
+
+ /* Test for a valid rules file download. Turn off ET update if download failed. */
+ if ($rc === true) {
+ if (trim(file_get_contents("{$tmpfname}/{$emergingthreats_filename_md5}")) != trim(md5_file("{$tmpfname}/{$emergingthreats_filename}"))){
+ if ($pkg_interface <> "console")
+ update_output_window(gettext("EmergingThreats rules file MD5 checksum failed..."));
+ log_error(gettext("[Snort] EmergingThreats rules file download failed. Bad MD5 checksum..."));
+ log_error(gettext("[Snort] Failed File MD5: " . md5_file("{$tmpfname}/{$emergingthreats_filename}")));
+ log_error(gettext("[Snort] Expected File MD5: " . file_get_contents("{$tmpfname}/{$emergingthreats_filename_md5}")));
+ error_log(gettext("\tEmergingThreats rules file download failed. EmergingThreats rules will not be updated.\n"), 3, $snort_rules_upd_log);
+ error_log(gettext("\tDownloaded ET file MD5: " . md5_file("{$tmpfname}/{$emergingthreats_filename}") . "\n"), 3, $snort_rules_upd_log);
+ error_log(gettext("\tExpected ET file MD5: " . file_get_contents("{$tmpfname}/{$emergingthreats_filename_md5}") . "\n"), 3, $snort_rules_upd_log);
+ $emergingthreats = 'off';
+ }
+ else {
+ if ($pkg_interface <> "console")
+ update_status(gettext('Done downloading EmergingThreats rules file.'));
+ log_error("[Snort] EmergingThreats rules file update downloaded successfully");
+ error_log(gettext("\tDone downloading EmergingThreats rules file.\n"), 3, $snort_rules_upd_log);
+ }
+ }
+ else {
+ if ($pkg_interface <> "console") {
+ update_status(gettext("The server returned error code {$rc} ... skipping EmergingThreats update..."));
+ update_output_window(gettext("EmergingThreats rules file download failed..."));
+ }
+ log_error(gettext("[Snort] EmergingThreats rules file download failed. Server returned error '{$rc}'..."));
+ error_log(gettext("\tEmergingThreats rules file download failed. Server returned error '{$rc}'...\n"), 3, $snort_rules_upd_log);
+ if ($pkg_interface == "console")
+ error_log(gettext("\tThe error text is '{$last_curl_error}'\n"), 3, $snort_rules_upd_log);
+ $emergingthreats = 'off';
+ }
}
-/* Normalize rulesets */
-$sedcmd = "s/^#alert/# alert/g\n";
-$sedcmd .= "s/^##alert/# alert/g\n";
-$sedcmd .= "s/^#[ \\t#]*alert/# alert/g\n";
-$sedcmd .= "s/^##\\talert/# alert/g\n";
-$sedcmd .= "s/^\\talert/alert/g\n";
-$sedcmd .= "s/^[ \\t]*alert/alert/g\n";
-@file_put_contents("{$snortdir}/tmp/sedcmd", $sedcmd);
-
/* Untar emergingthreats rules to tmp */
if ($emergingthreats == 'on') {
safe_mkdir("{$snortdir}/tmp/emerging");
if (file_exists("{$tmpfname}/{$emergingthreats_filename}")) {
- update_status(gettext("Extracting EmergingThreats.org rules..."));
+ if ($pkg_interface <> "console") {
+ update_status(gettext("Extracting EmergingThreats.org rules..."));
+ update_output_window(gettext("Installing EmergingThreats rules..."));
+ }
+ error_log(gettext("\tExtracting and installing EmergingThreats.org rules...\n"), 3, $snort_rules_upd_log);
exec("/usr/bin/tar xzf {$tmpfname}/{$emergingthreats_filename} -C {$snortdir}/tmp/emerging rules/");
$files = glob("{$snortdir}/tmp/emerging/rules/*.rules");
@@ -199,7 +471,7 @@ if ($emergingthreats == 'on') {
@copy($file, "{$snortdir}/rules/{$newfile}");
}
/* IP lists for Emerging Threats rules */
- $files = glob("{$snortdir}/tmp/emerging/rules/*.txt");
+ $files = glob("{$snortdir}/tmp/emerging/rules/*ips.txt");
foreach ($files as $file) {
$newfile = basename($file);
@copy($file, "{$snortdir}/rules/{$newfile}");
@@ -207,31 +479,39 @@ if ($emergingthreats == 'on') {
/* base etc files for Emerging Threats rules */
foreach (array("classification.config", "reference.config", "gen-msg.map", "unicode.map") as $file) {
if (file_exists("{$snortdir}/tmp/emerging/rules/{$file}"))
- @copy("{$snortdir}/tmp/emerging/rules/{$file}", "{$snortdir}/ET_{$file}");
+ @copy("{$snortdir}/tmp/emerging/rules/{$file}", "{$snortdir}/tmp/ET_{$file}");
}
-// /* make sure default rules are in the right format */
-// exec("/usr/bin/sed -I '' -f {$snortdir}/tmp/sedcmd {$snortdir}/rules/emerging*.rules");
-
/* Copy emergingthreats md5 sig to snort dir */
- if (file_exists("{$tmpfname}/$emergingthreats_filename_md5")) {
- update_status(gettext("Copying md5 sig to snort directory..."));
- @copy("{$tmpfname}/$emergingthreats_filename_md5", "{$snortdir}/$emergingthreats_filename_md5");
+ if (file_exists("{$tmpfname}/{$emergingthreats_filename_md5}")) {
+ if ($pkg_interface <> "console")
+ update_status(gettext("Copying md5 signature to snort directory..."));
+ @copy("{$tmpfname}/{$emergingthreats_filename_md5}", "{$snortdir}/{$emergingthreats_filename_md5}");
+ }
+ if ($pkg_interface <> "console") {
+ update_status(gettext("Extraction of EmergingThreats.org rules completed..."));
+ update_output_window(gettext("Installation of EmergingThreats rules completed..."));
}
- update_status(gettext("Extraction of EmergingThreats.org rules completed..."));
+ error_log(gettext("\tInstallation of EmergingThreats.org rules completed.\n"), 3, $snort_rules_upd_log);
+ exec("rm -r {$snortdir}/tmp/emerging");
}
}
/* Untar snort rules file individually to help people with low system specs */
if ($snortdownload == 'on') {
if (file_exists("{$tmpfname}/{$snort_filename}")) {
- if ($pfsense_stable == 'yes')
- $freebsd_version_so = 'FreeBSD-7-2';
- else
- $freebsd_version_so = 'FreeBSD-8-1';
-
- update_status(gettext("Extracting Snort VRT rules..."));
- /* extract snort.org rules and add prefix to all snort.org files*/
+ /* Currently, only FreeBSD-8-1 and FreeBSD-9-0 precompiled SO rules exist from Snort.org */
+ /* Default to FreeBSD 8.1, and then test for FreeBSD 9.x */
+ $freebsd_version_so = 'FreeBSD-8-1';
+ if (substr(php_uname("r"), 0, 1) == '9')
+ $freebsd_version_so = 'FreeBSD-9-0';
+
+ if ($pkg_interface <> "console") {
+ update_status(gettext("Extracting Snort VRT rules..."));
+ update_output_window(gettext("Installing Sourcefire VRT rules..."));
+ }
+ error_log(gettext("\tExtracting and installing Snort VRT rules...\n"), 3, $snort_rules_upd_log);
+ /* extract snort.org rules and add prefix to all snort.org files */
safe_mkdir("{$snortdir}/tmp/snortrules");
exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir}/tmp/snortrules rules/");
$files = glob("{$snortdir}/tmp/snortrules/rules/*.rules");
@@ -246,154 +526,223 @@ if ($snortdownload == 'on') {
@copy($file, "{$snortdir}/rules/{$newfile}");
}
exec("rm -r {$snortdir}/tmp/snortrules");
-
/* extract so rules */
- update_status(gettext("Extracting Snort VRT Shared Objects rules..."));
- exec('/bin/mkdir -p /usr/local/lib/snort/dynamicrules/');
+ if ($pkg_interface <> "console") {
+ update_status(gettext("Extracting Snort VRT Shared Objects rules..."));
+ update_output_window(gettext("Installing precompiled Shared Objects rules for {$freebsd_version_so}..."));
+ }
+ exec("/bin/mkdir -p {$snortlibdir}/dynamicrules/");
+ error_log(gettext("\tUsing Snort VRT precompiled SO rules for {$freebsd_version_so} ...\n"), 3, $snort_rules_upd_log);
$snort_arch = php_uname("m");
$nosorules = false;
if ($snort_arch == 'i386'){
- exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir}/tmp so_rules/precompiled/$freebsd_version_so/i386/{$snort_version}/");
- exec("/bin/cp {$snortdir}/tmp/so_rules/precompiled/$freebsd_version_so/i386/{$snort_version}/* /usr/local/lib/snort/dynamicrules/");
- } else if ($snort_arch == 'amd64') {
- exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir}/tmp so_rules/precompiled/$freebsd_version_so/x86-64/{$snort_version}/");
- exec("/bin/cp {$snortdir}/tmp/so_rules/precompiled/$freebsd_version_so/x86-64/{$snort_version}/* /usr/local/lib/snort/dynamicrules/");
+ exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir}/tmp so_rules/precompiled/{$freebsd_version_so}/i386/{$snort_version}/");
+ exec("/bin/cp {$snortdir}/tmp/so_rules/precompiled/{$freebsd_version_so}/i386/{$snort_version}/* {$snortlibdir}/dynamicrules/");
+ } elseif ($snort_arch == 'amd64') {
+ exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir}/tmp so_rules/precompiled/{$freebsd_version_so}/x86-64/{$snort_version}/");
+ exec("/bin/cp {$snortdir}/tmp/so_rules/precompiled/{$freebsd_version_so}/x86-64/{$snort_version}/* {$snortlibdir}/dynamicrules/");
} else
$nosorules = true;
exec("rm -r {$snortdir}/tmp/so_rules");
-
if ($nosorules == false) {
- /* extract so rules none bin and rename */
- update_status(gettext("Copying Snort VRT Shared Objects rules..."));
- exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir}/tmp so_rules/");
+ /* extract so stub rules, rename and copy to the rules folder. */
+ if ($pkg_interface <> "console")
+ update_status(gettext("Copying Snort VRT Shared Objects rules..."));
+ exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir}/tmp --exclude precompiled/ --exclude src/ so_rules/");
$files = glob("{$snortdir}/tmp/so_rules/*.rules");
foreach ($files as $file) {
$newfile = basename($file, ".rules");
@copy($file, "{$snortdir}/rules/snort_{$newfile}.so.rules");
}
exec("rm -r {$snortdir}/tmp/so_rules");
-
- /* extract base etc files */
- update_status(gettext("Extracting Snort VRT base config files..."));
- exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir}/tmp etc/");
- foreach (array("classification.config", "reference.config", "gen-msg.map", "unicode.map") as $file) {
- if (file_exists("{$snortdir}/tmp/etc/{$file}"))
- @copy("{$snortdir}/tmp/etc/{$file}", "{$snortdir}/VRT_{$file}");
- }
- exec("rm -r {$snortdir}/tmp/etc");
-
- /* Untar snort signatures */
- $signature_info_chk = $config['installedpackages']['snortglobal']['signatureinfo'];
- if ($premium_url_chk == 'on') {
+ }
+ /* extract base etc files */
+ if ($pkg_interface <> "console") {
+ update_status(gettext("Extracting Snort VRT config and map files..."));
+ update_output_window(gettext("Copying config and map files..."));
+ }
+ exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir}/tmp etc/");
+ foreach (array("classification.config", "reference.config", "gen-msg.map", "unicode.map") as $file) {
+ if (file_exists("{$snortdir}/tmp/etc/{$file}"))
+ @copy("{$snortdir}/tmp/etc/{$file}", "{$snortdir}/tmp/VRT_{$file}");
+ }
+ exec("rm -r {$snortdir}/tmp/etc");
+ /* Untar snort signatures */
+ $signature_info_chk = $config['installedpackages']['snortglobal']['signatureinfo'];
+ if ($premium_url_chk == 'on') {
+ if ($pkg_interface <> "console")
update_status(gettext("Extracting Snort VRT Signatures..."));
- exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} doc/signatures/");
+ exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} doc/signatures/");
+ if ($pkg_interface <> "console")
update_status(gettext("Done extracting Signatures."));
- if (is_dir("{$snortdir}/doc/signatures")) {
+ if (is_dir("{$snortdir}/doc/signatures")) {
+ if ($pkg_interface <> "console")
update_status(gettext("Copying Snort VRT signatures..."));
- exec("/bin/cp -r {$snortdir}/doc/signatures {$snortdir}/signatures");
+ exec("/bin/cp -r {$snortdir}/doc/signatures {$snortdir}/signatures");
+ if ($pkg_interface <> "console")
update_status(gettext("Done copying signatures."));
- }
- }
-
- foreach (glob("/usr/local/lib/snort/dynamicrules/*example*") as $file)
- @unlink($file);
-
- exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} preproc_rules/");
-
-// /* make sure default rules are in the right format */
-// exec("/usr/bin/sed -I '' -f {$snortdir}/tmp/sedcmd {$snortdir}/rules/snort_*.rules");
-
- if (file_exists("{$tmpfname}/{$snort_filename_md5}")) {
- update_status(gettext("Copying md5 sig to snort directory..."));
- @copy("{$tmpfname}/$snort_filename_md5", "{$snortdir}/$snort_filename_md5");
}
}
- update_status(gettext("Extraction of Snort VRT rules completed..."));
+ /* Extract the Snort preprocessor rules */
+ if ($pkg_interface <> "console")
+ update_output_window(gettext("Extracting preprocessor rules files..."));
+ exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir}/tmp preproc_rules/");
+
+ if (file_exists("{$tmpfname}/{$snort_filename_md5}")) {
+ if ($pkg_interface <> "console")
+ update_status(gettext("Copying md5 signature to snort directory..."));
+ @copy("{$tmpfname}/{$snort_filename_md5}", "{$snortdir}/{$snort_filename_md5}");
+ }
+ if ($pkg_interface <> "console") {
+ update_status(gettext("Extraction of Snort VRT rules completed..."));
+ update_output_window(gettext("Installation of Sourcefire VRT rules completed..."));
+ }
+ error_log(gettext("\tInstallation of Snort VRT rules completed.\n"), 3, $snort_rules_upd_log);
}
}
-/* remove old $tmpfname files */
-if (is_dir("{$snortdir}/tmp")) {
- update_status(gettext("Cleaning up after rules extraction..."));
- exec("/bin/rm -r {$snortdir}/tmp");
-}
-
function snort_apply_customizations($snortcfg, $if_real) {
+ global $vrt_enabled;
$snortdir = SNORTDIR;
+
+ /* Update the Preprocessor rules for the master configuration and for the interface if Snort VRT rules are in use. */
+ if ($vrt_enabled == 'on') {
+ exec("/bin/mkdir -p {$snortdir}/snort_{$snortcfg['uuid']}_{$if_real}/preproc_rules");
+ $preproc_files = glob("{$snortdir}/tmp/preproc_rules/*.rules");
+ foreach ($preproc_files as $file) {
+ $newfile = basename($file);
+ @copy($file, "{$snortdir}/preproc_rules/{$newfile}");
+ /* Check if customized preprocessor rule protection is enabled for interface before overwriting them. */
+ if ($snortcfg['protect_preproc_rules'] <> 'on')
+ @copy($file, "{$snortdir}/snort_{$snortcfg['uuid']}_{$if_real}/preproc_rules/{$newfile}");
+ }
+ }
+ else {
+ exec("/bin/mkdir -p {$snortdir}/snort_{$snortcfg['uuid']}_{$if_real}/preproc_rules");
+ }
+
snort_prepare_rule_files($snortcfg, "{$snortdir}/snort_{$snortcfg['uuid']}_{$if_real}");
- /* Copy the master *.config and other *.map files to the interface's directory */
+ /* Copy the master config and map files to the interface directory */
@copy("{$snortdir}/classification.config", "{$snortdir}/snort_{$snortcfg['uuid']}_{$if_real}/classification.config");
@copy("{$snortdir}/gen-msg.map", "{$snortdir}/snort_{$snortcfg['uuid']}_{$if_real}/gen-msg.map");
@copy("{$snortdir}/reference.config", "{$snortdir}/snort_{$snortcfg['uuid']}_{$if_real}/reference.config");
@copy("{$snortdir}/unicode.map", "{$snortdir}/snort_{$snortcfg['uuid']}_{$if_real}/unicode.map");
}
-if ($snortdownload == 'on' || $emergingthreats == 'on') {
+if ($snortdownload == 'on' || $emergingthreats == 'on' || $snortcommunityrules == 'on') {
- update_status(gettext('Copying new config and map files...'));
+ if ($pkg_interface <> "console")
+ update_status(gettext('Copying new config and map files...'));
+ error_log(gettext("\tCopying new config and map files...\n"), 3, $snort_rules_upd_log);
- /* Determine which base etc file set to use for the master copy. */
- /* If the Snort VRT rules are not enabled, then use Emerging Threats. */
+ /* Determine which config and map file set to use for the master copy. */
+ /* If the Snort VRT rules are not enabled, then use Emerging Threats. */
if (($vrt_enabled == 'off') && ($et_enabled == 'on')) {
- foreach (array("classification.config", "reference.config", "gen-msg.map", "unicode.map") as $file) {
- if (file_exists("{$snortdir}/ET_{$file}"))
- @rename("{$snortdir}/ET_{$file}", "{$snortdir}/{$file}");
- }
+ $cfgs = glob("{$snortdir}/tmp/*reference.config");
+ $cfgs[] = "{$snortdir}/reference.config";
+ snort_merge_reference_configs($cfgs, "{$snortdir}/reference.config");
+ $cfgs = glob("{$snortdir}/tmp/*classification.config");
+ $cfgs[] = "{$snortdir}/classification.config";
+ snort_merge_classification_configs($cfgs, "{$snortdir}/classification.config");
}
elseif (($vrt_enabled == 'on') && ($et_enabled == 'off')) {
foreach (array("classification.config", "reference.config", "gen-msg.map", "unicode.map") as $file) {
- if (file_exists("{$snortdir}/VRT_{$file}"))
- @rename("{$snortdir}/VRT_{$file}", "{$snortdir}/{$file}");
+ if (file_exists("{$snortdir}/tmp/VRT_{$file}"))
+ @copy("{$snortdir}/tmp/VRT_{$file}", "{$snortdir}/{$file}");
}
}
- else {
- /* Both VRT and ET rules are enabled, so build combined */
- /* reference.config and classification.config files. */
- $cfgs = glob("{$snortdir}/*reference.config");
- snort_merge_reference_configs($cfgs, "{$snortdir}/reference.config");
- $cfgs = glob("{$snortdir}/*classification.config");
- snort_merge_classification_configs($cfgs, "{$snortdir}/classification.config");
- }
-
- /* Clean-up our temp versions of the config and map files. */
- update_status(gettext('Cleaning up temp files...'));
- $cfgs = glob("{$snortdir}/??*_*.config");
- foreach ($cfgs as $file) {
- if (file_exists($file))
- @unlink($file);
- }
- $cfgs = glob("{$snortdir}/??*_*.map");
- foreach ($cfgs as $file) {
- if (file_exists($file))
- @unlink($file);
+ elseif (($vrt_enabled == 'on') && ($et_enabled == 'on')) {
+ /* Both VRT and ET rules are enabled, so build combined */
+ /* reference.config and classification.config files. */
+ $cfgs = glob("{$snortdir}/tmp/*reference.config");
+ $cfgs[] = "{$snortdir}/reference.config";
+ snort_merge_reference_configs($cfgs, "{$snortdir}/reference.config");
+ $cfgs = glob("{$snortdir}/tmp/*classification.config");
+ $cfgs[] = "{$snortdir}/classification.config";
+ snort_merge_classification_configs($cfgs, "{$snortdir}/classification.config");
+ /* Use the unicode.map and gen-msg.map files from VRT rules. */
+ if (file_exists("{$snortdir}/tmp/VRT_unicode.map"))
+ @copy("{$snortdir}/tmp/VRT_unicode.map", "{$snortdir}/unicode.map");
+ if (file_exists("{$snortdir}/tmp/VRT_gen-msg.map"))
+ @copy("{$snortdir}/tmp/VRT_gen-msg.map", "{$snortdir}/gen-msg.map");
}
- /* Start the proccess for each configured interface */
+ /* Start the rules rebuild proccess for each configured interface */
if (is_array($config['installedpackages']['snortglobal']['rule'])) {
- foreach ($config['installedpackages']['snortglobal']['rule'] as $id => $value) {
- /* Create configuration for each active Snort interface */
+ /* Set the flag to force rule rebuilds since we downloaded new rules, */
+ /* except when in post-install mode. Post-install does its own rebuild. */
+ if ($is_postinstall)
+ $rebuild_rules = 'off';
+ else
+ $rebuild_rules = 'on';
+
+ /* Create configuration for each active Snort interface */
+ foreach ($config['installedpackages']['snortglobal']['rule'] as $id => $value) {
$if_real = snort_get_real_interface($value['interface']);
$tmp = "Updating rules configuration for: " . snort_get_friendly_interface($value['interface']) . " ...";
- update_status(gettext($tmp));
- log_error($tmp);
+ if ($pkg_interface <> "console"){
+ update_status(gettext($tmp));
+ update_output_window(gettext("Please wait while Snort interface files are being updated..."));
+ }
snort_apply_customizations($value, $if_real);
+
+ /* Log a message in Update Log if protecting customized preprocessor rules. */
+ $tmp = "\t" . $tmp . "\n";
+ if ($value['protect_preproc_rules'] == 'on') {
+ $tmp .= gettext("\tPreprocessor text rules flagged as protected and not updated for ");
+ $tmp .= snort_get_friendly_interface($value['interface']) . "...\n";
+ }
+ error_log($tmp, 3, $snort_rules_upd_log);
+ }
+ }
+ else {
+ if ($pkg_interface <> "console") {
+ update_output_window(gettext("Warning: No interfaces configured for Snort were found..."));
+ update_output_window(gettext("No interfaces currently have Snort configured and enabled on them..."));
+ }
+ error_log(gettext("\tWarning: No interfaces configured for Snort were found...\n"), 3, $snort_rules_upd_log);
+ }
+
+ /* Clear the rebuild rules flag. */
+ $rebuild_rules = 'off';
+
+ /* remove old $tmpfname files */
+ if (is_dir("{$snortdir}/tmp")) {
+ if ($pkg_interface <> "console")
+ update_status(gettext("Cleaning up after rules extraction..."));
+ exec("/bin/rm -r {$snortdir}/tmp");
+ }
+
+ /* Restart snort if already running and we are not rebooting to pick up the new rules. */
+ if (is_process_running("snort") && !$g['booting']) {
+ if ($pkg_interface <> "console") {
+ update_status(gettext('Restarting Snort to activate the new set of rules...'));
+ update_output_window(gettext("Please wait ... restarting Snort will take some time..."));
}
+ error_log(gettext("\tRestarting Snort to activate the new set of rules...\n"), 3, $snort_rules_upd_log);
+ restart_service("snort");
+ if ($pkg_interface <> "console")
+ update_output_window(gettext("Snort has restarted with your new set of rules..."));
+ log_error(gettext("[Snort] Snort has restarted with your new set of rules..."));
+ error_log(gettext("\tSnort has restarted with your new set of rules.\n"), 3, $snort_rules_upd_log);
+ }
+ else {
+ if ($pkg_interface <> "console")
+ update_output_window(gettext("The rules update task is complete..."));
}
- update_status(gettext('Restarting Snort to activate the new set of rules...'));
- exec("/bin/sh /usr/local/etc/rc.d/snort.sh restart");
- sleep(20);
- if (!is_process_running("snort"))
- exec("/bin/sh /usr/local/etc/rc.d/snort.sh start");
- update_output_window(gettext("Snort has restarted with your new set of rules..."));
- log_error("Snort has restarted with your new set of rules...");
}
-update_status(gettext("The Rules update has finished..."));
-log_error("The Rules update has finished...");
+if ($pkg_interface <> "console")
+ update_status(gettext("The Rules update has finished..."));
+log_error(gettext("[Snort] The Rules update has finished."));
+error_log(gettext("The Rules update has finished. Time: " . date("Y-m-d H:i:s"). "\n\n"), 3, $snort_rules_upd_log);
conf_mount_ro();
+/* Restore the state of $pkg_interface */
+$pkg_interface = $pkg_interface_orig;
+
?>
diff --git a/config/snort/snort_define_servers.php b/config/snort/snort_define_servers.php
index 4085b325..8c19325b 100755
--- a/config/snort/snort_define_servers.php
+++ b/config/snort/snort_define_servers.php
@@ -33,7 +33,7 @@
require_once("guiconfig.inc");
require_once("/usr/local/pkg/snort/snort.inc");
-global $g;
+global $g, $rebuild_rules;
$id = $_GET['id'];
if (isset($_POST['id']))
@@ -126,7 +126,9 @@ if ($_POST) {
write_config();
- sync_snort_package_config();
+ /* Update the snort conf file for this interface. */
+ $rebuild_rules = "off";
+ snort_generate_conf($a_nat[$id]);
/* after click go to this page */
header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' );
@@ -164,20 +166,32 @@ if ($savemsg)
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td>
<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Snort Interfaces"), true, "/snort/snort_interfaces.php");
+ $tab_array[1] = array(gettext("Global Settings"), false, "/snort/snort_interfaces_global.php");
+ $tab_array[2] = array(gettext("Updates"), false, "/snort/snort_download_updates.php");
+ $tab_array[3] = array(gettext("Alerts"), false, "/snort/snort_alerts.php");
+ $tab_array[4] = array(gettext("Blocked"), false, "/snort/snort_blocked.php");
+ $tab_array[5] = array(gettext("Whitelists"), false, "/snort/snort_interfaces_whitelist.php");
+ $tab_array[6] = array(gettext("Suppress"), false, "/snort/snort_interfaces_suppress.php");
+ $tab_array[7] = array(gettext("Sync"), false, "/pkg_edit.php?xml=snort/snort_sync.xml");
+ display_top_tabs($tab_array);
+ echo '</td></tr>';
+ echo '<tr><td class="tabnavtbl">';
+ $menu_iface=($if_friendly?substr($if_friendly,0,5)." ":"Iface ");
$tab_array = array();
- $tab_array[] = array(gettext("Snort Interfaces"), false, "/snort/snort_interfaces.php");
- $tab_array[] = array(gettext("If Settings"), false, "/snort/snort_interfaces_edit.php?id={$id}");
- $tab_array[] = array(gettext("Categories"), false, "/snort/snort_rulesets.php?id={$id}");
- $tab_array[] = array(gettext("Rules"), false, "/snort/snort_rules.php?id={$id}");
- $tab_array[] = array(gettext("Variables"), true, "/snort/snort_define_servers.php?id={$id}");
- $tab_array[] = array(gettext("Preprocessors"), false, "/snort/snort_preprocessors.php?id={$id}");
- $tab_array[] = array(gettext("Barnyard2"), false, "/snort/snort_barnyard.php?id={$id}");
+ $tab_array[] = array($menu_iface . gettext(" Settings"), false, "/snort/snort_interfaces_edit.php?id={$id}");
+ $tab_array[] = array($menu_iface . gettext("Categories"), false, "/snort/snort_rulesets.php?id={$id}");
+ $tab_array[] = array($menu_iface . gettext("Rules"), false, "/snort/snort_rules.php?id={$id}");
+ $tab_array[] = array($menu_iface . gettext("Variables"), true, "/snort/snort_define_servers.php?id={$id}");
+ $tab_array[] = array($menu_iface . gettext("Preprocessors"), false, "/snort/snort_preprocessors.php?id={$id}");
+ $tab_array[] = array($menu_iface . gettext("Barnyard2"), false, "/snort/snort_barnyard.php?id={$id}");
display_top_tabs($tab_array);
?>
</td></tr>
<tr>
- <td class="tabcont">
- <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <td><div id="mainarea">
+ <table id="maintable" class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
<tr>
<td colspan="2" valign="top" class="listtopic"><?php echo gettext("Define Servers"); ?></td>
</tr>
@@ -230,6 +244,7 @@ if ($savemsg)
</td>
</tr>
</table>
+</div>
</td></tr>
</table>
</form>
diff --git a/config/snort/snort_download_rules.php b/config/snort/snort_download_rules.php
index bbbf689c..562a6b36 100755
--- a/config/snort/snort_download_rules.php
+++ b/config/snort/snort_download_rules.php
@@ -34,6 +34,8 @@ require_once("functions.inc");
require_once("service-utils.inc");
require_once("/usr/local/pkg/snort/snort.inc");
+global $g;
+
$pgtitle = "Services: Snort: Update Rules";
include("head.inc");
?>
@@ -44,34 +46,43 @@ include("head.inc");
<?if($pfsense_stable == 'yes'){echo '<p class="pgtitle">' . $pgtitle . '</p>';}?>
<form action="/snort/snort_download_updates.php" method="GET">
-<table width="100%" border="0" cellpadding="0" cellspacing="0">
-<tr>
- <td>
- <div id="mainarea">
- <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
- <tr>
- <td ><!-- progress bar -->
- <table id="progholder" width='320' style='border-collapse: collapse; border: 1px solid #000000;' cellpadding='2' cellspacing='2'>
+
+<table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td align="center"><div id="boxarea">
+ <table id="maintable" class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
<tr>
- <td>
- <img border='0' src='../themes/<?= $g['theme']; ?>/images/misc/progress_bar.gif'
- width='280' height='23' name='progressbar' id='progressbar' alt='' />
+ <td class="tabcont" align="center">
+ <table width="420" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td style="background:url('../themes/<?= $g['theme']; ?>/images/misc/bar_left.gif')" height="15" width="5"></td>
+ <td style="background:url('../themes/<?= $g['theme']; ?>/images/misc/bar_gray.gif')" height="15" width="410">
+ <table id="progholder" width='410' cellpadding='0' cellspacing='0'>
+ <tr>
+ <td align="left"><img border='0' src='../themes/<?= $g['theme']; ?>/images/misc/bar_blue.gif'
+ width='0' height='15' name='progressbar' id='progressbar' alt='' /></td
+ </tr>
+ </table></td>
+ <td style="background:url('../themes/<?= $g['theme']; ?>/images/misc/bar_right.gif')" height="15" width="5"></td>
+ </tr>
+ </table>
</td>
</tr>
- </table>
- <br />
- <textarea cols="60" rows="2" name="status" id="status" wrap="hard">
- <?=gettext("Initializing...");?>
- </textarea>
- <textarea cols="60" rows="2" name="output" id="output" wrap="hard">
- </textarea>
- </td>
- </tr>
+ <tr>
+ <td class="tabcont" align="center">
+ <!-- status box -->
+ <textarea cols="85" rows="1" name="status" id="status" wrap="soft"><?=gettext("Initializing..."); ?>.</textarea>
+ <!-- command output box -->
+ <textarea cols="85" rows="12" name="output" id="output" wrap="soft"></textarea>
+ </td>
+ </tr>
+ <tr>
+ <td class="tabcont" align="center" valign="middle"><input type="submit" name="return" id="return" Value="Return"></td>
+ </tr>
</table>
- </div>
- </td>
-</tr>
- <tr><td><input type="submit" name="return" id="return" Value="Return"></td></tr>
+ </div>
+ </td>
+ </tr>
</table>
</form>
<?php include("fend.inc");?>
diff --git a/config/snort/snort_download_updates.php b/config/snort/snort_download_updates.php
index 0c879e44..c6e24532 100755
--- a/config/snort/snort_download_updates.php
+++ b/config/snort/snort_download_updates.php
@@ -36,16 +36,18 @@
require_once("guiconfig.inc");
require_once("/usr/local/pkg/snort/snort.inc");
-global $g;
+global $g, $snort_rules_upd_log, $snort_rules_file, $emergingthreats_filename;
$snortdir = SNORTDIR;
-$snort_upd_log = "/tmp/snort_update.log";
+
+$log = $snort_rules_upd_log;
/* load only javascript that is needed */
$snort_load_jquery = 'yes';
$snort_load_jquery_colorbox = 'yes';
$snortdownload = $config['installedpackages']['snortglobal']['snortdownload'];
$emergingthreats = $config['installedpackages']['snortglobal']['emergingthreats'];
+$snortcommunityrules = $config['installedpackages']['snortglobal']['snortcommunityrules'];
/* quick md5s chk */
$snort_org_sig_chk_local = 'N/A';
@@ -53,13 +55,28 @@ if (file_exists("{$snortdir}/{$snort_rules_file}.md5"))
$snort_org_sig_chk_local = file_get_contents("{$snortdir}/{$snort_rules_file}.md5");
$emergingt_net_sig_chk_local = 'N/A';
-if (file_exists("{$snortdir}/emerging.rules.tar.gz.md5"))
- $emergingt_net_sig_chk_local = file_get_contents("{$snortdir}/emerging.rules.tar.gz.md5");
+if (file_exists("{$snortdir}/{$emergingthreats_filename}.md5"))
+ $emergingt_net_sig_chk_local = file_get_contents("{$snortdir}/{$emergingthreats_filename}.md5");
+
+$snort_community_sig_chk_local = 'N/A';
+if (file_exists("{$snortdir}/{$snort_community_rules_filename}.md5"))
+ $snort_community_sig_chk_local = file_get_contents("{$snortdir}/{$snort_community_rules_filename}.md5");
+
+/* Check for postback to see if we should clear the update log file. */
+if (isset($_POST['clear'])) {
+ if (file_exists("{$snort_rules_upd_log}"))
+ mwexec("/bin/rm -f {$snort_rules_upd_log}");
+}
+
+if (isset($_POST['update'])) {
+ header("Location: /snort/snort_download_rules.php");
+ exit;
+}
/* check for logfile */
-$update_logfile_chk = 'no';
-if (file_exists("{$snort_upd_log}"))
- $update_logfile_chk = 'yes';
+$snort_rules_upd_logfile_chk = 'no';
+if (file_exists("{$snort_rules_upd_log}"))
+ $snort_rules_upd_logfile_chk = 'yes';
$pgtitle = "Services: Snort: Updates";
include_once("head.inc");
@@ -71,19 +88,25 @@ include_once("head.inc");
<?if($pfsense_stable == 'yes'){echo '<p class="pgtitle">' . $pgtitle . '</p>';}?>
<script language="javascript" type="text/javascript">
-function popup(url)
+function wopen(url, name, w, h)
{
- params = 'width='+screen.width;
- params += ', height='+screen.height;
- params += ', top=0, left=0'
- params += ', fullscreen=yes';
-
- newwin=window.open(url,'windowname4', params);
- if (window.focus) {newwin.focus()}
- return false;
+// Fudge factors for window decoration space.
+// In my tests these work well on all platforms & browsers.
+w += 32;
+h += 96;
+ var win = window.open(url,
+ name,
+ 'width=' + w + ', height=' + h + ', ' +
+ 'location=no, menubar=no, ' +
+ 'status=no, toolbar=no, scrollbars=yes, resizable=yes');
+ win.resizeTo(w, h);
+ win.focus();
}
+
</script>
+<form action="snort_download_updates.php" method="post" name="iform" id="iform">
+
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td>
<?php
@@ -95,60 +118,58 @@ function popup(url)
$tab_array[4] = array(gettext("Blocked"), false, "/snort/snort_blocked.php");
$tab_array[5] = array(gettext("Whitelists"), false, "/snort/snort_interfaces_whitelist.php");
$tab_array[6] = array(gettext("Suppress"), false, "/snort/snort_interfaces_suppress.php");
+ $tab_array[7] = array(gettext("Sync"), false, "/pkg_edit.php?xml=snort/snort_sync.xml");
display_top_tabs($tab_array);
?>
</td></tr>
<tr>
<td>
- <div id="mainarea3">
- <table id="maintable4" class="tabcont" width="100%" border="0"
- cellpadding="0" cellspacing="0">
+ <div id="mainarea">
+ <table id="maintable4" class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
<tr align="center">
<td>
<br/>
- <table id="download_rules" height="32px" width="725px" border="0"
- cellpadding="5px" cellspacing="0">
+ <table id="download_rules" height="32px" width="725px" border="0" cellpadding="5px" cellspacing="0">
<tr>
<td id="download_rules_td" style="background-color: #eeeeee">
<div height="32" width="725px" style="background-color: #eeeeee">
-
- <font color="#777777" size="1.5px">
+ <font color="#777777" size="2.5px">
<p style="text-align: left; margin-left: 225px;">
- <b><?php echo gettext("INSTALLED SIGNATURE RULESET"); ?></b></font><br>
- <br>
- <font color="#FF850A" size="1px"><b>SNORT.ORG >>></b></font>
- <font size="1px" color="#000000">&nbsp;&nbsp;<? echo $snort_org_sig_chk_local; ?></font><br>
- <font color="#FF850A" size="1px"><b>EMERGINGTHREATS.NET >>></b></font>
- <font size="1px" color="#000000">&nbsp;&nbsp;<? echo $emergingt_net_sig_chk_local; ?></font><br>
+ <b><?php echo gettext("INSTALLED RULESET SIGNATURES"); ?></b></font><br/><br/>
+ <font color="#FF850A" size="1px"><b>SNORT.ORG&nbsp;&nbsp;--></b></font>
+ <font size="1px" color="#000000">&nbsp;&nbsp;<? echo $snort_org_sig_chk_local; ?></font><br/>
+ <font color="#FF850A" size="1px"><b>EMERGINGTHREATS.NET&nbsp;&nbsp;--></b></font>
+ <font size="1px" color="#000000">&nbsp;&nbsp;<? echo $emergingt_net_sig_chk_local; ?></font><br/>
+ <font color="#FF850A" size="1px"><b>SNORT GPLv2 COMMUNITY RULES&nbsp;&nbsp;--></b></font>
+ <font size="1px" color="#000000">&nbsp;&nbsp;<? echo $snort_community_sig_chk_local; ?></font><br/>
</p>
</div>
</td>
</tr>
</table>
<br/>
- <table id="download_rules" height="32px" width="725px" border="0"
- cellpadding="5px" cellspacing="0">
+ <table id="download_rules" height="32px" width="725px" border="0" cellpadding="5px" cellspacing="0">
<tr>
<td id="download_rules_td" style='background-color: #eeeeee'>
<div height="32" width="725px" style='background-color: #eeeeee'>
-
<p style="text-align: left; margin-left: 225px;">
- <font color='#777777' size='1.5px'><b><?php echo gettext("UPDATE YOUR RULES"); ?></b></font><br>
+ <font color='#777777' size='2.5px'><b><?php echo gettext("UPDATE YOUR RULESET"); ?></b></font><br/>
<br/>
<?php
if ($snortdownload != 'on' && $emergingthreats != 'on') {
echo '
- <button disabled="disabled"><span class="download">' . gettext("Update Rules") . '&nbsp;&nbsp;&nbsp;&nbsp;</span></button><br/>
+ <button disabled="disabled"><span class="download">' . gettext("Update Rules") . '</span></button><br/>
<p style="text-align:left; margin-left:150px;">
- <font color="#fc3608" size="2px"><b>' . gettext("WARNING:") . '</b></font><font size="1px" color="#000000">&nbsp;&nbsp;' . gettext('No rule types have been selected for download. "Global Settings Tab"') . '</font><br>';
+ <font color="#fc3608" size="2px"><b>' . gettext("WARNING:") . '</b></font><font size="1px" color="#000000">&nbsp;&nbsp;' . gettext('No rule types have been selected for download. ') .
+ gettext('Visit the ') . '<a href="snort_interfaces_global.php">Global Settings Tab</a>' . gettext(' to select rule types.') . '</font><br/>';
echo '</p>' . "\n";
} else {
echo '
- <a href="/snort/snort_download_rules.php"><button ><span class="download">' . gettext("Update Rules") . '&nbsp;&nbsp;&nbsp;&nbsp;</span></button></a><br/>' . "\n";
+ <input type="submit" value="' . gettext("Update Rules") . '" name="update" id="Submit" class="formbtn" /><br/>' . "\n";
}
@@ -159,26 +180,24 @@ function popup(url)
</tr>
</table>
<br/>
- <table id="download_rules" height="32px" width="725px" border="0"
- cellpadding="5px" cellspacing="0">
+ <table id="download_rules" height="32px" width="725px" border="0" cellpadding="5px" cellspacing="0">
<tr>
<td id="download_rules_td" style='background-color: #eeeeee'>
<div height="32" width="725px" style='background-color: #eeeeee'>
-
<p style="text-align: left; margin-left: 225px;">
- <font color='#777777' size='1.5px'><b><?php echo gettext("VIEW UPDATE LOG"); ?></b></font><br>
+ <font color='#777777' size='2.5px'><b><?php echo gettext("VIEW UPDATE LOG"); ?></b></font><br/>
<br>
-
<?php
- if ($update_logfile_chk == 'yes') {
+ if ($snort_rules_upd_logfile_chk == 'yes') {
echo "
- <button href='/snort/snort_rules_edit.php?openruleset={$snort_upd_log}'><span class='pwhitetxt'>" . gettext("Update Log") . "&nbsp;&nbsp;&nbsp;&nbsp;</span></button>\n";
+ <button class=\"formbtn\" onclick=\"wopen('snort_log_view.php?logfile={$log}', 'LogViewer', 800, 600)\"><span class='pwhitetxt'>" . gettext("View Log") . "</span></button>";
+ echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"submit\" value=\"Clear Log\" name=\"clear\" id=\"Submit\" class=\"formbtn\" />\n";
}else{
echo "
- <button disabled='disabled' href='/snort/snort_rules_edit.php?openruleset={$snort_upd_log}'><span class='pwhitetxt'>" . gettext("Update Log") . "&nbsp;&nbsp;&nbsp;&nbsp;</span></button>\n";
+ <button disabled='disabled'><span class='pwhitetxt'>" . gettext("View Log") . "</span></button>&nbsp;&nbsp;&nbsp;" . gettext("Log is empty.") . "\n";
}
-
+ echo '<br><br>' . gettext("The log file is limited to 1024K in size and automatically clears when the limit is exceeded.");
?>
<br/>
</p>
@@ -189,15 +208,13 @@ function popup(url)
<br/>
- <table id="download_rules" height="32px" width="725px" border="0"
- cellpadding="5px" cellspacing="0">
+ <table id="download_rules" height="32px" width="725px" border="0" cellpadding="5px" cellspacing="0">
<tr>
<td id="download_rules_td" style='background-color: #eeeeee'>
- <div height="32" width="725px" style='background-color: #eeeeee'>
- <font color='#FF850A' size='1px'><b><?php echo gettext("NOTE:"); ?></b></font><font size='1px'
- color='#000000'>&nbsp;&nbsp;<?php echo gettext("Snort.org and Emergingthreats.net " .
- "will go down from time to time. Please be patient."); ?>
- </font>
+ <div height="32" width="725px" style='background-color: #eeeeee'><span class="vexpl">
+ <span class="red"><b><?php echo gettext("NOTE:"); ?></b></span>
+ &nbsp;&nbsp;<?php echo gettext("Snort.org and EmergingThreats.net " .
+ "will go down from time to time. Please be patient."); ?></span>
</div>
</td>
</tr>
@@ -207,16 +224,12 @@ function popup(url)
</tr>
</table>
</div>
-
-
-
-
-
<br>
</td>
</tr>
</table>
-<!-- end of final table --></div>
+<!-- end of final table -->
+</form>
<?php include("fend.inc"); ?>
</body>
</html>
diff --git a/config/snort/snort_interfaces.php b/config/snort/snort_interfaces.php
index e8e690a8..390b83eb 100755
--- a/config/snort/snort_interfaces.php
+++ b/config/snort/snort_interfaces.php
@@ -32,9 +32,10 @@ $nocsrf = true;
require_once("guiconfig.inc");
require_once("/usr/local/pkg/snort/snort.inc");
-global $g;
+global $g, $rebuild_rules;
$snortdir = SNORTDIR;
+$rcdir = RCFILEPREFIX;
$id = $_GET['id'];
if (isset($_POST['id']))
@@ -57,19 +58,38 @@ if (isset($_POST['del_x'])) {
exec("/bin/rm -r /var/log/snort/snort_{$if_real}{$snort_uuid}");
exec("/bin/rm -r {$snortdir}/snort_{$snort_uuid}_{$if_real}");
+ // If interface had auto-generated Suppress List, then
+ // delete that along with the interface
+ $autolist = "{$a_nat[$rulei]['interface']}" . "suppress";
+ if (is_array($config['installedpackages']['snortglobal']['suppress']) &&
+ is_array($config['installedpackages']['snortglobal']['suppress']['item'])) {
+ $a_suppress = &$config['installedpackages']['snortglobal']['suppress']['item'];
+ foreach ($a_suppress as $k => $i) {
+ if ($i['name'] == $autolist) {
+ unset($config['installedpackages']['snortglobal']['suppress']['item'][$k]);
+ break;
+ }
+ }
+ }
+
+ // Finally delete the interface's config entry entirely
unset($a_nat[$rulei]);
}
conf_mount_ro();
+ /* If all the Snort interfaces are removed, then unset the config array. */
+ if (empty($a_nat))
+ unset($a_nat);
+
write_config();
sleep(2);
- /* if there are no ifaces do not create snort.sh */
+ /* if there are no ifaces remaining do not create snort.sh */
if (!empty($config['installedpackages']['snortglobal']['rule']))
snort_create_rc();
else {
conf_mount_rw();
- @unlink('/usr/local/etc/rc.d/snort.sh');
+ @unlink("{$rcdir}/snort.sh");
conf_mount_ro();
}
@@ -93,11 +113,11 @@ if ($_GET['act'] == 'bartoggle' && is_numeric($id)) {
$if_friendly = snort_get_friendly_interface($snortcfg['interface']);
if (snort_is_running($snortcfg['uuid'], $if_real, 'barnyard2') == 'no') {
- log_error("Toggle(barnyard starting) for {$if_friendly}({$snortcfg['descr']}}...");
+ log_error("Toggle (barnyard starting) for {$if_friendly}({$snortcfg['descr']})...");
sync_snort_package_config();
snort_barnyard_start($snortcfg, $if_real);
} else {
- log_error("Toggle(barnyard stopping) for {$if_friendly}({$snortcfg['descr']}}...");
+ log_error("Toggle (barnyard stopping) for {$if_friendly}({$snortcfg['descr']})...");
snort_barnyard_stop($snortcfg, $if_real);
}
@@ -113,7 +133,7 @@ if ($_GET['act'] == 'toggle' && is_numeric($id)) {
$if_friendly = snort_get_friendly_interface($snortcfg['interface']);
if (snort_is_running($snortcfg['uuid'], $if_real) == 'yes') {
- log_error("Toggle(snort stopping) for {$if_friendly}({$snortcfg['descr']})...");
+ log_error("Toggle (snort stopping) for {$if_friendly}({$snortcfg['descr']})...");
snort_stop($snortcfg, $if_real);
header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' );
@@ -122,8 +142,12 @@ if ($_GET['act'] == 'toggle' && is_numeric($id)) {
header( 'Cache-Control: post-check=0, pre-check=0', false );
header( 'Pragma: no-cache' );
} else {
- log_error("Toggle(snort starting) for {$if_friendly}({$snortcfg['descr']})...");
+ log_error("Toggle (snort starting) for {$if_friendly}({$snortcfg['descr']})...");
+
+ /* set flag to rebuild interface rules before starting Snort */
+ $rebuild_rules = "on";
sync_snort_package_config();
+ $rebuild_rules = "off";
snort_start($snortcfg, $if_real);
header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' );
@@ -174,26 +198,28 @@ if ($pfsense_stable == 'yes')
?>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
-<tr><td>
-<?php
- $tab_array = array();
- $tab_array[0] = array(gettext("Snort Interfaces"), true, "/snort/snort_interfaces.php");
- $tab_array[1] = array(gettext("Global Settings"), false, "/snort/snort_interfaces_global.php");
- $tab_array[2] = array(gettext("Updates"), false, "/snort/snort_download_updates.php");
- $tab_array[3] = array(gettext("Alerts"), false, "/snort/snort_alerts.php");
- $tab_array[4] = array(gettext("Blocked"), false, "/snort/snort_blocked.php");
- $tab_array[5] = array(gettext("Whitelists"), false, "/snort/snort_interfaces_whitelist.php");
- $tab_array[6] = array(gettext("Suppress"), false, "/snort/snort_interfaces_suppress.php");
- display_top_tabs($tab_array);
-?>
-</td></tr>
<tr>
<td>
- <div id="mainarea2">
- <table class="tabcont" width="100%" border="0" cellpadding="0"
- cellspacing="0">
+ <?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Snort Interfaces"), true, "/snort/snort_interfaces.php");
+ $tab_array[1] = array(gettext("Global Settings"), false, "/snort/snort_interfaces_global.php");
+ $tab_array[2] = array(gettext("Updates"), false, "/snort/snort_download_updates.php");
+ $tab_array[3] = array(gettext("Alerts"), false, "/snort/snort_alerts.php");
+ $tab_array[4] = array(gettext("Blocked"), false, "/snort/snort_blocked.php");
+ $tab_array[5] = array(gettext("Whitelists"), false, "/snort/snort_interfaces_whitelist.php");
+ $tab_array[6] = array(gettext("Suppress"), false, "/snort/snort_interfaces_suppress.php");
+ $tab_array[7] = array(gettext("Sync"), false, "/pkg_edit.php?xml=snort/snort_sync.xml");
+ display_top_tabs($tab_array);
+ ?>
+ </td>
+</tr>
+<tr>
+ <td>
+ <div id="mainarea">
+ <table id="maintable" class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
<tr id="frheader">
- <td width="5%" class="list">&nbsp;</td>
+ <td width="3%" class="list">&nbsp;</td>
<td width="10%" class="listhdrr"><?php echo gettext("If"); ?></td>
<td width="13%" class="listhdrr"><?php echo gettext("Snort"); ?></td>
<td width="10%" class="listhdrr"><?php echo gettext("Performance"); ?></td>
@@ -201,44 +227,86 @@ if ($pfsense_stable == 'yes')
<td width="12%" class="listhdrr"><?php echo gettext("Barnyard2"); ?></td>
<td width="30%" class="listhdr"><?php echo gettext("Description"); ?></td>
<td width="3%" class="list">
- <table border="0" cellspacing="0" cellpadding="1">
+ <table border="0" cellspacing="0" cellpadding="0">
<tr>
- <td width="17"></td>
- <td><a href="snort_interfaces_edit.php?id=<?php echo $id_gen;?>"><img
- src="../themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif"
- width="17" height="17" border="0" title="<?php echo gettext('add interface');?>"></a></td>
+ <td></td>
+ <td align="center" valign="middle"><a href="snort_interfaces_edit.php?id=<?php echo $id_gen;?>"><img
+ src="../themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif"
+ width="17" height="17" border="0" title="<?php echo gettext('Add Snort interface mapping');?>"></a></td>
</tr>
</table>
</td>
</tr>
-<?php $nnats = $i = 0; foreach ($a_nat as $natent): ?>
-<tr valign="top" id="fr<?=$nnats;?>">
-<?php
+ <?php $nnats = $i = 0;
-/* convert fake interfaces to real and check if iface is up */
-/* There has to be a smarter way to do this */
- $if_real = snort_get_real_interface($natent['interface']);
- $snort_uuid = $natent['uuid'];
- if (snort_is_running($snort_uuid, $if_real) == 'no')
- $iconfn = 'pass';
- else
- $iconfn = 'block';
- if (snort_is_running($snort_uuid, $if_real, 'barnyard2') == 'no')
- $biconfn = 'pass';
- else
- $biconfn = 'block';
+ // Turn on buffering to speed up rendering
+ ini_set('output_buffering','true');
- ?>
- <td class="listt">
- <input type="checkbox" id="frc<?=$nnats;?>" name="rule[]" value="<?=$i;?>" onClick="fr_bgcolor('<?=$nnats;?>')" style="margin: 0; padding: 0;"></td>
- <td class="listr"
+ // Start buffering to fix display lag issues in IE9 and IE10
+ ob_start(null, 0);
+
+ /* If no interfaces are defined, then turn off the "no rules" warning */
+ $no_rules_footnote = false;
+ if ($id_gen == 0)
+ $no_rules = false;
+ else
+ $no_rules = true;
+
+ foreach ($a_nat as $natent): ?>
+ <tr valign="top" id="fr<?=$nnats;?>">
+ <?php
+
+ /* convert fake interfaces to real and check if iface is up */
+ /* There has to be a smarter way to do this */
+ $if_real = snort_get_real_interface($natent['interface']);
+ $natend_friendly= snort_get_friendly_interface($natent['interface']);
+ $snort_uuid = $natent['uuid'];
+ if (snort_is_running($snort_uuid, $if_real) == 'no'){
+ $iconfn = 'block';
+ $iconfn_msg1 = 'Snort is not running on ';
+ $iconfn_msg2 = '. Click to start.';
+ }
+ else{
+ $iconfn = 'pass';
+ $iconfn_msg1 = 'Snort is running on ';
+ $iconfn_msg2 = '. Click to stop.';
+ }
+ if (snort_is_running($snort_uuid, $if_real, 'barnyard2') == 'no'){
+ $biconfn = 'block';
+ $biconfn_msg1 = 'Barnyard2 is not running on ';
+ $biconfn_msg2 = '. Click to start.';
+ }
+ else{
+ $biconfn = 'pass';
+ $biconfn_msg1 = 'Barnyard2 is running on ';
+ $biconfn_msg2 = '. Click to stop.';
+ }
+
+ /* See if interface has any rules defined and set boolean flag */
+ $no_rules = true;
+ if (isset($natent['customrules']) && !empty($natent['customrules']))
+ $no_rules = false;
+ if (isset($natent['rulesets']) && !empty($natent['rulesets']))
+ $no_rules = false;
+ if (isset($natent['ips_policy']) && !empty($natent['ips_policy']))
+ $no_rules = false;
+ /* Do not display the "no rules" warning if interface disabled */
+ if ($natent['enable'] == "off")
+ $no_rules = false;
+ if ($no_rules)
+ $no_rules_footnote = true;
+ ?>
+ <td class="listt">
+ <input type="checkbox" id="frc<?=$nnats;?>" name="rule[]" value="<?=$i;?>" onClick="fr_bgcolor('<?=$nnats;?>')" style="margin: 0; padding: 0;">
+ </td>
+ <td class="listr"
id="frd<?=$nnats;?>"
ondblclick="document.location='snort_interfaces_edit.php?id=<?=$nnats;?>';">
<?php
- echo snort_get_friendly_interface($natent['interface']);
+ echo $natend_friendly;
?>
- </td>
- <td class="listr"
+ </td>
+ <td class="listr"
id="frd<?=$nnats;?>"
ondblclick="document.location='snort_interfaces_edit.php?id=<?=$nnats;?>';">
<?php
@@ -248,12 +316,13 @@ if ($pfsense_stable == 'yes')
echo "<a href='?act=toggle&id={$i}'>
<img src='../themes/{$g['theme']}/images/icons/icon_{$iconfn}.gif'
width='13' height='13' border='0'
- title='" . gettext('click to toggle start/stop snort') . "'></a>";
+ title='" . gettext($iconfn_msg1.$natend_friendly.$iconfn_msg2) . "'></a>";
+ echo ($no_rules) ? "&nbsp;<img src=\"../themes/{$g['theme']}/images/icons/icon_frmfld_imp.png\" width=\"15\" height=\"15\" border=\"0\">" : "";
} else
echo strtoupper("disabled");
?>
- </td>
- <td class="listr"
+ </td>
+ <td class="listr"
id="frd<?=$nnats;?>"
ondblclick="document.location='snort_interfaces_edit.php?id=<?=$nnats;?>';">
<?php
@@ -263,8 +332,9 @@ if ($pfsense_stable == 'yes')
}else{
$check_performance = "lowmem";
}
- ?> <?=strtoupper($check_performance);?></td>
- <td class="listr"
+ ?> <?=strtoupper($check_performance);?>
+ </td>
+ <td class="listr"
id="frd<?=$nnats;?>"
ondblclick="document.location='snort_interfaces_edit.php?id=<?=$nnats;?>';">
<?php
@@ -275,8 +345,9 @@ if ($pfsense_stable == 'yes')
} else {
$check_blockoffenders = disabled;
}
- ?> <?=strtoupper($check_blockoffenders);?></td>
- <td class="listr"
+ ?> <?=strtoupper($check_blockoffenders);?>
+ </td>
+ <td class="listr"
id="frd<?=$nnats;?>"
ondblclick="document.location='snort_interfaces_edit.php?id=<?=$nnats;?>';">
<?php
@@ -286,94 +357,140 @@ if ($pfsense_stable == 'yes')
echo "<a href='?act=bartoggle&id={$i}'>
<img src='../themes/{$g['theme']}/images/icons/icon_{$biconfn}.gif'
width='13' height='13' border='0'
- title='" . gettext('click to toggle start/stop barnyard') . "'></a>";
+ title='" . gettext($biconfn_msg1.$natend_friendly.$biconfn_msg2) . "'></a>";
} else
echo strtoupper("disabled");
?>
- </td>
- <td class="listbg"
+ </td>
+ <td class="listbg"
ondblclick="document.location='snort_interfaces_edit.php?id=<?=$nnats;?>';">
- <font color="#ffffff"> <?=htmlspecialchars($natent['descr']);?>&nbsp;
- </td>
- <td valign="middle" class="list" nowrap>
- <table border="0" cellspacing="0" cellpadding="1">
- <tr>
- <td><a href="snort_interfaces_edit.php?id=<?=$i;?>"><img
- src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif"
- width="17" height="17" border="0" title="<?php echo gettext('edit interface'); ?>"></a></td>
- </tr>
- </table>
-
- </tr>
- <?php $i++; $nnats++; endforeach; ?>
- <tr>
- <td class="list" colspan="8"></td>
- <td class="list" valign="middle" nowrap>
- <table border="0" cellspacing="0" cellpadding="1">
+ <font color="#ffffff"> <?=htmlspecialchars($natent['descr']);?>&nbsp;
+ </td>
+ <td valign="middle" class="list" nowrap>
+ <table border="0" cellspacing="0" cellpadding="0">
+ <tr>
+ <td><a href="snort_interfaces_edit.php?id=<?=$i;?>"><img
+ src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif"
+ width="17" height="17" border="0" title="<?php echo gettext('Edit Snort interface mapping'); ?>"></a>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <?php $i++; $nnats++; endforeach; ob_end_flush(); ?>
+ <tr>
+ <td class="list"></td>
+ <td class="list" colspan="6">
+ <?php if ($no_rules_footnote): ?><br><img src="../themes/<?= $g['theme']; ?>/images/icons/icon_frmfld_imp.png" width="15" height="15" border="0">
+ <span class="red">&nbsp;&nbsp <?php echo gettext("WARNING: Marked interface currently has no rules defined for Snort"); ?></span>
+ <?php else: ?>&nbsp;
+ <?php endif; ?>
+ </td>
+ <td class="list" valign="middle" nowrap>
+ <table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><?php if ($nnats == 0): ?><img
- src="../themes/<?= $g['theme']; ?>/images/icons/icon_x_d.gif"
- width="17" height="17" title="<?php echo gettext("delete selected interface"); ?>" border="0"><?php else: ?><input
- name="del" type="image"
- src="../themes/<?= $g['theme']; ?>/images/icons/icon_x.gif"
- width="17" height="17" title="<?php echo gettext("delete selected interface"); ?>"
- onclick="return confirm('Do you really want to delete the selected Snort mapping?')"><?php endif; ?></td>
+ src="../themes/<?= $g['theme']; ?>/images/icons/icon_x_d.gif"
+ width="17" height="17" " border="0">
+ <?php else: ?>
+ <input name="del" type="image"
+ src="../themes/<?= $g['theme']; ?>/images/icons/icon_x.gif"
+ width="17" height="17" title="<?php echo gettext("Delete selected Snort interface mapping(s)"); ?>"
+ onclick="return intf_del()">
+ <?php endif; ?></td>
</tr>
</table>
- </td>
- </tr>
- </table>
- </div>
- </td>
- </tr>
-</table>
-
-<br>
-<table width="100%" border="0" cellpadding="0" cellspacing="0">
- <tr>
- <td>
- <div id="mainarea4">
- <table class="tabcont" width="100%" border="0" cellpadding="0"
- cellspacing="0">
- <tr id="frheader">
- <td width="100%"><span class="red"><strong><?php echo gettext("Note:"); ?></strong></span> <br>
- <?php echo gettext('This is the <strong>Snort Menu</strong> where you can see an over ' .
- 'view of all your interface settings. <br> ' .
- 'Please edit the <strong>Global Settings</strong> tab before adding ' .
- 'an interface.'); ?> <br>
- <br>
- <span class="red"><strong><?php echo gettext("Warning:"); ?></strong></span> <br>
- <strong><?php echo gettext("New settings will not take effect until interface restart."); ?></strong>
- <br>
- <br>
- <strong>Click</strong> on the <img
- src="../themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif"
- width="17" height="17" border="0" title="<?php echo gettext("Add Icon"); ?>"> icon to add a
- interface.<strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Click</strong>
- on the <img
- src="../themes/<?= $g['theme']; ?>/images/icons/icon_pass.gif"
- width="13" height="13" border="0" title="<?php echo gettext("Start Icon"); ?>"> icon to <strong>start</strong>
- snort and barnyard2. <br>
- <strong>Click</strong> on the <img
- src="../themes/<?= $g['theme']; ?>/images/icons/icon_e.gif"
- width="17" height="17" border="0" title="<?php echo gettext("Edit Icon"); ?>"> icon to edit a
- interface and settings.<strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Click</strong>
- on the <img
- src="../themes/<?= $g['theme']; ?>/images/icons/icon_block.gif"
- width="13" height="13" border="0" title="<?php echo gettext("Stop Icon"); ?>"> icon to <strong>stop</strong>
- snort and barnyard2. <br>
- <strong> Click</strong> on the <img
- src="../themes/<?= $g['theme']; ?>/images/icons/icon_x.gif"
- width="17" height="17" border="0" title="<?php echo gettext("Delete Icon"); ?>"> icon to
- delete a interface and settings.</td>
- </tr>
- </table>
- </div>
-
- </tr>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="8">&nbsp;</td>
+ </tr>
+ <tr>
+ <td>&nbsp;</td>
+ <td colspan="6">
+ <table class="tabcont" width="100%" border="0" cellpadding="1" cellspacing="0">
+ <tr>
+ <td colspan="3" class="vexpl"><span class="red"><strong><?php echo gettext("Note:"); ?></strong></span> <br>
+ <?php echo gettext("This is the ") . "<strong>" . gettext("Snort Menu ") .
+ "</strong>" . gettext("where you can see an overview of all your interface settings.");
+ if (empty($a_nat)) {
+ echo gettext("Please visit the ") . "<strong>" . gettext("Global Settings") .
+ "</strong>" . gettext(" tab before adding an interface.");
+ }?>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="3" class="vexpl"><br>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="3" class="vexpl"><span class="red"><strong><?php echo gettext("Warning:"); ?></strong></span><br>
+ <strong><?php echo gettext("New settings will not take effect until interface restart."); ?></strong>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="3" class="vexpl"><br>
+ </td>
+ </tr>
+ <tr>
+ <td class="vexpl"><strong>Click</strong> on the <img src="../themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif"
+ width="17" height="17" border="0" title="<?php echo gettext("Add Icon"); ?>"> icon to add
+ an interface.
+ </td>
+ <td width="3%" class="vexpl">&nbsp;
+ </td>
+ <td class="vexpl"><img src="../themes/<?= $g['theme']; ?>/images/icons/icon_pass.gif"
+ width="13" height="13" border="0" title="<?php echo gettext("Running"); ?>">
+ <img src="../themes/<?= $g['theme']; ?>/images/icons/icon_block.gif"
+ width="13" height="13" border="0" title="<?php echo gettext("Not Running"); ?>"> icons will show current
+ snort and barnyard2 status.
+ </td>
+ </tr>
+ <tr>
+ <td class="vexpl"><strong>Click</strong> on the <img src="../themes/<?= $g['theme']; ?>/images/icons/icon_e.gif"
+ width="17" height="17" border="0" title="<?php echo gettext("Edit Icon"); ?>"> icon to edit
+ an interface and settings.
+ <td width="3%">&nbsp;
+ </td>
+ <td class="vexpl"><strong>Click</strong> on the status icons to <strong>toggle</strong> snort and barnyard2 status.
+ </td>
+ </tr>
+ <tr>
+ <td colspan="3" class="vexpl"><strong> Click</strong> on the <img src="../themes/<?= $g['theme']; ?>/images/icons/icon_x.gif"
+ width="17" height="17" border="0" title="<?php echo gettext("Delete Icon"); ?>"> icon to
+ delete an interface and settings.
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td>&nbsp;</td>
+ </tr>
+ </table>
+ </div>
</td>
+</tr>
</table>
</form>
+
+<script type="text/javascript">
+
+function intf_del() {
+ var isSelected = false;
+ var inputs = document.iform.elements;
+ for (var i = 0; i < inputs.length; i++) {
+ if (inputs[i].type == "checkbox") {
+ if (inputs[i].checked)
+ isSelected = true;
+ }
+ }
+ if (isSelected)
+ return confirm('Do you really want to delete the selected Snort mapping?');
+ else
+ alert("There is no Snort mapping selected for deletion. Click the checkbox beside the Snort mapping(s) you wish to delete.");
+}
+
+</script>
+
<?php
include("fend.inc");
?>
diff --git a/config/snort/snort_interfaces_edit.php b/config/snort/snort_interfaces_edit.php
index d0fabbf4..08d7d2ba 100755
--- a/config/snort/snort_interfaces_edit.php
+++ b/config/snort/snort_interfaces_edit.php
@@ -31,7 +31,7 @@
require_once("guiconfig.inc");
require_once("/usr/local/pkg/snort/snort.inc");
-global $g;
+global $g, $rebuild_rules;
if (!is_array($config['installedpackages']['snortglobal']))
$config['installedpackages']['snortglobal'] = array();
@@ -50,12 +50,28 @@ if (is_null($id)) {
}
$pconfig = array();
-if (empty($snortglob['rule'][$id]['uuid']))
+if (empty($snortglob['rule'][$id]['uuid'])) {
+ /* Adding new interface, so flag rules to build. */
$pconfig['uuid'] = snort_generate_id();
-else
+ $rebuild_rules = "on";
+}
+else {
$pconfig['uuid'] = $a_rule[$id]['uuid'];
+ $pconfig['descr'] = $a_rule[$id]['descr'];
+ $rebuild_rules = "off";
+}
$snort_uuid = $pconfig['uuid'];
+// Get the physical configured interfaces on the firewall
+if (function_exists('get_configured_interface_with_descr'))
+ $interfaces = get_configured_interface_with_descr();
+else {
+ $interfaces = array('wan' => 'WAN', 'lan' => 'LAN');
+ for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++)
+ $interfaces['opt' . $i] = $config['interfaces']['opt' . $i]['descr'];
+}
+
+// See if interface is already configured, and use its values
if (isset($id) && $a_rule[$id]) {
/* old options */
$pconfig = $a_rule[$id];
@@ -63,28 +79,32 @@ if (isset($id) && $a_rule[$id]) {
$pconfig['configpassthru'] = base64_decode($pconfig['configpassthru']);
if (empty($pconfig['uuid']))
$pconfig['uuid'] = $snort_uuid;
- if (!$pconfig['interface'])
- $pconfig['interface'] = "wan";
+}
+// Must be a new interface, so try to pick next available physical interface to use
+elseif (isset($id) && !isset($a_rule[$id])) {
+ $ifaces = get_configured_interface_list();
+ $ifrules = array();
+ foreach($a_rule as $r)
+ $ifrules[] = $r['interface'];
+ foreach ($ifaces as $i) {
+ if (!in_array($i, $ifrules)) {
+ $pconfig['interface'] = $i;
+ break;
+ }
+ }
+ if (count($ifrules) == count($ifaces)) {
+ $input_errors[] = "No more available interfaces to configure for Snort!";
+ $interfaces = array();
+ $pconfig = array();
+ }
}
if (isset($_GET['dup']))
unset($id);
if ($_POST["Submit"]) {
- if ($_POST['descr'] == '' && $pconfig['descr'] == '') {
- $input_errors[] = "Please enter a description for your reference.";
- }
-
if (!$_POST['interface'])
$input_errors[] = "Interface is mandatory";
-/*
- foreach ($a_rule as $natent) {
- if (isset($id) && ($a_rule[$id]) && ($a_rule[$id] === $natent))
- continue;
- if ($natent['interface'] == $_POST['interface'])
- $input_errors[] = "This interface is already configured for another instance";
- }
-*/
/* if no errors write to conf */
if (!$input_errors) {
@@ -92,7 +112,19 @@ if ($_POST["Submit"]) {
$natent['interface'] = $_POST['interface'];
$natent['enable'] = $_POST['enable'] ? 'on' : 'off';
$natent['uuid'] = $pconfig['uuid'];
- if ($_POST['descr']) $natent['descr'] = $_POST['descr']; else unset($natent['descr']);
+
+ /* See if the HOME_NET, EXTERNAL_NET, WHITELIST or SUPPRESS LIST values were changed */
+ $snort_reload = false;
+ if ($_POST['homelistname'] && ($_POST['homelistname'] <> $natent['homelistname']))
+ $snort_reload = true;
+ if ($_POST['externallistname'] && ($_POST['externallistname'] <> $natent['externallistname']))
+ $snort_reload = true;
+ if ($_POST['suppresslistname'] && ($_POST['suppresslistname'] <> $natent['suppresslistname']))
+ $snort_reload = true;
+ if ($_POST['whitelistname'] && ($_POST['whitelistname'] <> $natent['whitelistname']))
+ $snort_reload = true;
+
+ if ($_POST['descr']) $natent['descr'] = $_POST['descr']; else $natent['descr'] = strtoupper($natent['interface']);
if ($_POST['performance']) $natent['performance'] = $_POST['performance']; else unset($natent['performance']);
/* if post = on use on off or rewrite the conf */
if ($_POST['blockoffenders7'] == "on") $natent['blockoffenders7'] = 'on'; else $natent['blockoffenders7'] = 'off';
@@ -118,11 +150,28 @@ if ($_POST["Submit"]) {
} else
$a_rule[] = $natent;
+ /* If Snort is disabled on this interface, stop any running instance */
if ($natent['enable'] != 'on')
snort_stop($natent, $if_real);
+
+ /* Save configuration changes */
write_config();
+
+ /* Most changes don't require a rules rebuild, so default to "off" */
+ $rebuild_rules = "off";
+
+ /* Update snort.conf and snort.sh files for this interface */
sync_snort_package_config();
+ /*******************************************************/
+ /* Signal Snort to reload configuration if we changed */
+ /* HOME_NET, the Whitelist, EXTERNAL_NET or Suppress */
+ /* list values. The function only signals a running */
+ /* Snort instance to safely reload these parameters. */
+ /*******************************************************/
+ if ($snort_reload == true)
+ snort_reload_config($natent, $if_real);
+
header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' );
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
header( 'Cache-Control: no-store, no-cache, must-revalidate' );
@@ -143,29 +192,6 @@ include_once("head.inc");
<?php include("fbegin.inc"); ?>
-<script language="JavaScript">
-<!--
-
-function enable_blockoffenders() {
- var endis = !(document.iform.blockoffenders7.checked);
- document.iform.blockoffenderskill.disabled=endis;
- document.iform.blockoffendersip.disabled=endis;
-}
-
-function enable_change(enable_change) {
- endis = !(document.iform.enable.checked || enable_change);
- // make sure a default answer is called if this is invoked.
- endis2 = (document.iform.enable);
- document.iform.performance.disabled = endis;
- document.iform.blockoffenders7.disabled = endis;
- document.iform.alertsystemlog.disabled = endis;
- document.iform.externallistname.disabled = endis;
- document.iform.homelistname.disabled = endis;
- document.iform.suppresslistname.disabled = endis;
- document.iform.configpassthru.disabled = endis;
-}
-//-->
-</script>
<?if($pfsense_stable == 'yes'){echo '<p class="pgtitle">' . $pgtitle . '</p>';}?>
<?php
@@ -181,21 +207,33 @@ function enable_change(enable_change) {
<form action="snort_interfaces_edit.php<?php echo "?id=$id";?>" method="post" name="iform" id="iform">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
-<tr><td class="tabnavtbl">
+<tr><td>
<?php
- $tab_array = array();
- $tab_array[] = array(gettext("Snort Interfaces"), false, "/snort/snort_interfaces.php");
- $tab_array[] = array(gettext("If Settings"), true, "/snort/snort_interfaces_edit.php?id={$id}");
- $tab_array[] = array(gettext("Categories"), false, "/snort/snort_rulesets.php?id={$id}");
- $tab_array[] = array(gettext("Rules"), false, "/snort/snort_rules.php?id={$id}");
- $tab_array[] = array(gettext("Variables"), false, "/snort/snort_define_servers.php?id={$id}");
- $tab_array[] = array(gettext("Preprocessors"), false, "/snort/snort_preprocessors.php?id={$id}");
- $tab_array[] = array(gettext("Barnyard2"), false, "/snort/snort_barnyard.php?id={$id}");
- display_top_tabs($tab_array);
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Snort Interfaces"), true, "/snort/snort_interfaces.php");
+ $tab_array[1] = array(gettext("Global Settings"), false, "/snort/snort_interfaces_global.php");
+ $tab_array[2] = array(gettext("Updates"), false, "/snort/snort_download_updates.php");
+ $tab_array[3] = array(gettext("Alerts"), false, "/snort/snort_alerts.php");
+ $tab_array[4] = array(gettext("Blocked"), false, "/snort/snort_blocked.php");
+ $tab_array[5] = array(gettext("Whitelists"), false, "/snort/snort_interfaces_whitelist.php");
+ $tab_array[6] = array(gettext("Suppress"), false, "/snort/snort_interfaces_suppress.php");
+ $tab_array[7] = array(gettext("Sync"), false, "/pkg_edit.php?xml=snort/snort_sync.xml");
+ display_top_tabs($tab_array);
+ echo '</td></tr>';
+ echo '<tr><td class="tabnavtbl">';
+ $tab_array = array();
+ $menu_iface=($if_friendly?substr($if_friendly,0,5)." ":"Iface ");
+ $tab_array[] = array($menu_iface . gettext("Settings"), true, "/snort/snort_interfaces_edit.php?id={$id}");
+ $tab_array[] = array($menu_iface . gettext("Categories"), false, "/snort/snort_rulesets.php?id={$id}");
+ $tab_array[] = array($menu_iface . gettext("Rules"), false, "/snort/snort_rules.php?id={$id}");
+ $tab_array[] = array($menu_iface . gettext("Variables"), false, "/snort/snort_define_servers.php?id={$id}");
+ $tab_array[] = array($menu_iface . gettext("Preprocessors"), false, "/snort/snort_preprocessors.php?id={$id}");
+ $tab_array[] = array($menu_iface . gettext("Barnyard2"), false, "/snort/snort_barnyard.php?id={$id}");
+ display_top_tabs($tab_array);
?>
</td></tr>
-<tr><td class="tabcont">
-<table width="100%" border="0" cellpadding="6" cellspacing="0">
+<tr><td><div id="mainarea">
+<table id="maintable" class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
<tr>
<td colspan="2" valign="top" class="listtopic"><?php echo gettext("General Settings"); ?></td>
</tr>
@@ -215,32 +253,22 @@ function enable_change(enable_change) {
<tr>
<td width="22%" valign="top" class="vncellreq"><?php echo gettext("Interface"); ?></td>
<td width="78%" class="vtable">
- <select name="interface" class="formselect">
+ <select name="interface" class="formselect" tabindex="0">
<?php
- if (function_exists('get_configured_interface_with_descr'))
- $interfaces = get_configured_interface_with_descr();
- else {
- $interfaces = array('wan' => 'WAN', 'lan' => 'LAN');
- for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
- $interfaces['opt' . $i] = $config['interfaces']['opt' . $i]['descr'];
- }
- }
foreach ($interfaces as $iface => $ifacename): ?>
<option value="<?=$iface;?>"
- <?php if ($iface == $pconfig['interface']) echo "selected"; ?>><?=htmlspecialchars($ifacename);?>
+ <?php if ($iface == $pconfig['interface']) echo " selected"; ?>><?=htmlspecialchars($ifacename);?>
</option>
- <?php endforeach; ?>
- </select><br>
- <span class="vexpl"><?php echo gettext("Choose which interface this rule applies to."); ?><br/>
+ <?php endforeach; ?>
+ </select>&nbsp;&nbsp;
+ <span class="vexpl"><?php echo gettext("Choose which interface this Snort instance applies to."); ?><br/>
<span class="red"><?php echo gettext("Hint:"); ?> </span><?php echo gettext("in most cases, you'll want to use WAN here."); ?></span><br/></td>
</tr>
<tr>
<td width="22%" valign="top" class="vncellreq"><?php echo gettext("Description"); ?></td>
<td width="78%" class="vtable"><input name="descr" type="text"
- class="formfld" id="descr" size="40"
- value="<?=htmlspecialchars($pconfig['descr']);?>"> <br/>
- <span class="vexpl"><?php echo gettext("You may enter a description here for your " .
- "reference (not parsed)."); ?></span><br/></td>
+ class="formfld" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']); ?>"> <br/>
+ <span class="vexpl"><?php echo gettext("Enter a meaningful description here for your reference."); ?></span><br/></td>
</tr>
<tr>
<td colspan="2" valign="top" class="listtopic"><?php echo gettext("Alert Settings"); ?></td>
@@ -251,7 +279,7 @@ function enable_change(enable_change) {
<td width="78%" class="vtable"><input name="alertsystemlog"
type="checkbox" value="on"
<?php if ($pconfig['alertsystemlog'] == "on") echo "checked"; ?>
- onClick="enable_change(false)"><br>
+ onClick="enable_change(false)">
<?php echo gettext("Snort will send Alerts to the firewall's system logs."); ?></td>
</tr>
<tr>
@@ -259,7 +287,7 @@ function enable_change(enable_change) {
<td width="78%" class="vtable">
<input name="blockoffenders7" id="blockoffenders7" type="checkbox" value="on"
<?php if ($pconfig['blockoffenders7'] == "on") echo "checked"; ?>
- onClick="enable_blockoffenders()"><br>
+ onClick="enable_blockoffenders()">
<?php echo gettext("Checking this option will automatically block hosts that generate a " .
"Snort alert."); ?></td>
</tr>
@@ -267,11 +295,11 @@ function enable_change(enable_change) {
<td width="22%" valign="top" class="vncell"><?php echo gettext("Kill states"); ?></td>
<td width="78%" class="vtable">
<input name="blockoffenderskill" id="blockoffenderskill" type="checkbox" value="on" <?php if ($pconfig['blockoffenderskill'] == "on") echo "checked"; ?>>
- <br/><?php echo gettext("Checking this option will kill firewall states for the blocked ip"); ?>
+ <?php echo gettext("Checking this option will kill firewall states for the blocked IP"); ?>
</td>
</tr>
<tr>
- <td width="22%" valign="top" class="vncell"><?php echo gettext("Which ip to block"); ?></td>
+ <td width="22%" valign="top" class="vncell"><?php echo gettext("Which IP to block"); ?></td>
<td width="78%" class="vtable">
<select name="blockoffendersip" class="formselect" id="blockoffendersip">
<?php
@@ -283,8 +311,8 @@ function enable_change(enable_change) {
echo htmlspecialchars($btype) . '</option>';
}
?>
- </select>
- <br/><?php echo gettext("Which ip extracted from the packet you want to block"); ?>
+ </select>&nbsp;&nbsp;
+ <?php echo gettext("Select which IP extracted from the packet you wish to block"); ?>
</td>
</tr>
<tr>
@@ -303,7 +331,8 @@ function enable_change(enable_change) {
<?php if ($iface2 == $pconfig['performance']) echo "selected"; ?>>
<?=htmlspecialchars($ifacename2);?></option>
<?php endforeach; ?>
- </select><br>
+ </select>&nbsp;&nbsp;
+ <?php echo gettext("Choose a search performance setting"); ?><br/>
<span class="vexpl"><?php echo gettext("LOWMEM and AC-BNFA are recommended for low end " .
"systems, AC-SPLIT: low memory, high performance, short-hand for search-method ac split-any-any, AC: high memory, " .
"best performance, -NQ: the -nq option specifies that matches should not be queued and evaluated as they are found," .
@@ -315,86 +344,99 @@ function enable_change(enable_change) {
<td width="22%" valign="top" class="vncell"><?php echo gettext("Checksum Check Disable"); ?></td>
<td width="78%" class="vtable">
<input name="cksumcheck" id="cksumcheck" type="checkbox" value="on" <?php if ($pconfig['cksumcheck'] == "on") echo "checked"; ?>>
- <br><?php echo gettext("If ticked, checksum checking on Snort will be disabled to improve performance."); ?>
- <br><?php echo gettext("Most of this is already done at the firewall/filter level."); ?>
+ <?php echo gettext("Disable checksum checking within Snort to improve performance."); ?>
+ <br><span class="red"><?php echo gettext("Hint: ") . "</span>" .
+ gettext("Most of this is already done at the firewall/filter level, so it is usually safe to check this box."); ?>
</td>
</tr>
<tr>
<td colspan="2" valign="top" class="listtopic"><?php echo gettext("Choose the networks " .
- "snort should inspect and whitelist."); ?></td>
+ "Snort should inspect and whitelist."); ?></td>
</tr>
<tr>
- <td width="22%" valign="top" class="vncell"><?php echo gettext("Home net"); ?></td>
+ <td width="22%" valign="top" class="vncell"><?php echo gettext("Home Net"); ?></td>
<td width="78%" class="vtable">
+
<select name="homelistname" class="formselect" id="homelistname">
- <?php
- echo "<option value='default' >default</option>";
- /* find whitelist names and filter by type */
- if (is_array($snortglob['whitelist']['item'])) {
- foreach ($snortglob['whitelist']['item'] as $value) {
- $ilistname = $value['name'];
- if ($ilistname == $pconfig['homelistname'])
- echo "<option value='$ilistname' selected>";
- else
- echo "<option value='$ilistname'>";
- echo htmlspecialchars($ilistname) . '</option>';
+ <?php
+ echo "<option value='default' >default</option>";
+ /* find whitelist names and filter by type */
+ if (is_array($snortglob['whitelist']['item'])) {
+ foreach ($snortglob['whitelist']['item'] as $value) {
+ $ilistname = $value['name'];
+ if ($ilistname == $pconfig['homelistname'])
+ echo "<option value='$ilistname' selected>";
+ else
+ echo "<option value='$ilistname'>";
+ echo htmlspecialchars($ilistname) . '</option>';
+ }
}
- }
- ?>
- </select><br/>
- <span class="vexpl"><?php echo gettext("Choose the home net you will like this rule to " .
- "use."); ?> </span><br/>&nbsp;<br/><span class="red"><?php echo gettext("Note:"); ?></span>&nbsp;<?php echo gettext("Default home " .
- "net adds only local networks."); ?><br>
- <span class="red"><?php echo gettext("Hint:"); ?></span>&nbsp;<?php echo gettext("Most users add a list of " .
- "friendly ips that the firewall cant see."); ?><br/></td>
+ ?>
+ </select>
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" class="formbtns" value="View List"
+ onclick="viewList('<?=$id;?>','homelistname')" id="btnHomeNet"
+ title="<?php echo gettext("Click to view currently selected Home Net contents"); ?>"/>
+ <br/>
+ <span class="vexpl"><?php echo gettext("Choose the Home Net you want this interface to use."); ?></span>
+ <br/></br>
+ <span class="red"><?php echo gettext("Note:"); ?></span>&nbsp;<?php echo gettext("Default Home " .
+ "Net adds only local networks, WAN IPs, Gateways, VPNs and VIPs."); ?><br/>
+ <span class="red"><?php echo gettext("Hint:"); ?></span>&nbsp;<?php echo gettext("Create an Alias to hold a list of " .
+ "friendly IPs that the firewall cannot see or to customize the default Home Net."); ?><br/>
+ </td>
</tr>
<tr>
- <td width="22%" valign="top" class="vncell"><?php echo gettext("External net"); ?></td>
+ <td width="22%" valign="top" class="vncell"><?php echo gettext("External Net"); ?></td>
<td width="78%" class="vtable">
<select name="externallistname" class="formselect" id="externallistname">
- <?php
- echo "<option value='default' >default</option>";
- /* find whitelist names and filter by type */
- if (is_array($snortglob['whitelist']['item'])) {
- foreach ($snortglob['whitelist']['item'] as $value) {
- $ilistname = $value['name'];
- if ($ilistname == $pconfig['externallistname'])
- echo "<option value='$ilistname' selected>";
- else
- echo "<option value='$ilistname'>";
- echo htmlspecialchars($ilistname) . '</option>';
+ <?php
+ echo "<option value='default' >default</option>";
+ /* find whitelist names and filter by type */
+ if (is_array($snortglob['whitelist']['item'])) {
+ foreach ($snortglob['whitelist']['item'] as $value) {
+ $ilistname = $value['name'];
+ if ($ilistname == $pconfig['externallistname'])
+ echo "<option value='$ilistname' selected>";
+ else
+ echo "<option value='$ilistname'>";
+ echo htmlspecialchars($ilistname) . '</option>';
+ }
}
- }
- ?>
- </select><br/>
- <span class="vexpl"><?php echo gettext("Choose the external net you will like this rule " .
- "to use."); ?> </span>&nbsp;<br/><span class="red"><?php echo gettext("Note:"); ?></span>&nbsp;<?php echo gettext("Default " .
- "external net, networks that are not home net."); ?><br/>
- <span class="red"><?php echo gettext("Hint:"); ?></span>&nbsp;<?php echo gettext("Most users should leave this " .
- "setting at default."); ?><br/></td>
+ ?>
+ </select>&nbsp;&nbsp;
+ <span class="vexpl"><?php echo gettext("Choose the External Net you want this interface " .
+ "to use."); ?></span>&nbsp;<br/><br/>
+ <span class="red"><?php echo gettext("Note:"); ?></span>&nbsp;<?php echo gettext("Default " .
+ "External Net is networks that are not Home Net."); ?><br/>
+ <span class="red"><?php echo gettext("Hint:"); ?></span>&nbsp;<?php echo gettext("Most users should leave this " .
+ "setting at default. Create an Alias for custom External Net settings."); ?><br/>
+ </td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell"><?php echo gettext("Whitelist"); ?></td>
<td width="78%" class="vtable">
<select name="whitelistname" class="formselect" id="whitelistname">
- <?php
- /* find whitelist names and filter by type, make sure to track by uuid */
- echo "<option value='default' >default</option>\n";
- if (is_array($snortglob['whitelist']['item'])) {
- foreach ($snortglob['whitelist']['item'] as $value) {
- if ($value['name'] == $pconfig['whitelistname'])
- echo "<option value='{$value['name']}' selected>";
- else
- echo "<option value='{$value['name']}'>";
- echo htmlspecialchars($value['name']) . '</option>';
+ <?php
+ /* find whitelist names and filter by type, make sure to track by uuid */
+ echo "<option value='default' >default</option>\n";
+ if (is_array($snortglob['whitelist']['item'])) {
+ foreach ($snortglob['whitelist']['item'] as $value) {
+ if ($value['name'] == $pconfig['whitelistname'])
+ echo "<option value='{$value['name']}' selected>";
+ else
+ echo "<option value='{$value['name']}'>";
+ echo htmlspecialchars($value['name']) . '</option>';
+ }
}
- }
- ?>
- </select><br>
- <span class="vexpl"><?php echo gettext("Choose the whitelist you will like this rule to " .
- "use."); ?> </span><br/>&nbsp;<br/><span class="red"><?php echo gettext("Note:"); ?></span><br/>&nbsp;<?php echo gettext("Default " .
- "whitelist adds only local networks."); ?><br/>
- <span class="red"><?php echo gettext("Note:"); ?></span><br/>&nbsp;<?php echo gettext("This option will only be used when block offenders is on."); ?>
+ ?>
+ </select>
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" class="formbtns" value="View List" onclick="viewList('<?=$id;?>','whitelistname')"
+ id="btnWhitelist" title="<?php echo gettext("Click to view currently selected Whitelist contents"); ?>"/>
+ <br/>
+ <span class="vexpl"><?php echo gettext("Choose the whitelist you want this interface to " .
+ "use."); ?> </span><br/>&nbsp;<br/><span class="red"><?php echo gettext("Hint:"); ?></span>&nbsp;<?php echo gettext("Default " .
+ "whitelist adds local networks, WAN IPs, Gateways, VPNs and VIPs. Create an Alias to customize."); ?><br/>
+ <span class="red"><?php echo gettext("Note:"); ?></span>&nbsp;<?php echo gettext("This option will only be used when block offenders is on."); ?>
</td>
</tr>
<tr>
@@ -419,10 +461,14 @@ function enable_change(enable_change) {
}
}
?>
- </select><br>
+ </select>
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" class="formbtns" value="View List" onclick="viewList('<?=$id;?>','suppresslistname', 'suppress')"
+ id="btnSuppressList" title="<?php echo gettext("Click to view currently selected Suppression List contents"); ?>"/>
+ <br/>
<span class="vexpl"><?php echo gettext("Choose the suppression or filtering file you " .
- "will like this interface to use."); ?> </span><br/>&nbsp;<br/><span class="red"><?php echo gettext("Note:"); ?></span><br/>&nbsp;<?php echo gettext("Default " .
- "option disables suppression and filtering."); ?></td>
+ "want this interface to use."); ?> </span><br/>&nbsp;<br/><span class="red"><?php echo gettext("Note: ") . "</span>" .
+ gettext("Default option disables suppression and filtering."); ?>
+ </td>
</tr>
<tr>
<td colspan="2" valign="top" class="listtopic"><?php echo gettext("Arguments here will " .
@@ -432,29 +478,83 @@ function enable_change(enable_change) {
<td width="22%" valign="top" class="vncell"><?php echo gettext("Advanced configuration pass through"); ?></td>
<td width="78%" class="vtable">
<textarea wrap="off" name="configpassthru" cols="65" rows="12" id="configpassthru"><?=htmlspecialchars($pconfig['configpassthru']);?></textarea>
-
</td>
</tr>
<tr>
<td width="22%" valign="top"></td>
- <td width="78%"><input name="Submit" type="submit" class="formbtn" value="Save">
- <input name="id" type="hidden" value="<?=$id;?>">
+ <td width="78%"><input name="Submit" type="submit" class="formbtn" value="Save" title="<?php echo
+ gettext("Click to save settings and exit"); ?>"/>
+ <input name="id" type="hidden" value="<?=$id;?>"/>
</td>
</tr>
<tr>
<td width="22%" valign="top">&nbsp;</td>
- <td width="78%"><span class="vexpl"><span class="red"><strong><?php echo gettext("Note:"); ?></strong></span><br/>
- <?php echo gettext("Please save your settings before you click start."); ?>
+ <td width="78%"><span class="vexpl"><span class="red"><strong><?php echo gettext("Note: ") . "</strong></span>" .
+ gettext("Please save your settings before you attempt to start Snort."); ?>
</td>
</tr>
</table>
+</div>
</td></tr>
</table>
</form>
<script language="JavaScript">
<!--
-enable_change(false);
-enable_blockoffenders();
+function enable_blockoffenders() {
+ var endis = !(document.iform.blockoffenders7.checked);
+ document.iform.blockoffenderskill.disabled=endis;
+ document.iform.blockoffendersip.disabled=endis;
+ document.iform.whitelistname.disabled=endis;
+ document.iform.btnWhitelist.disabled=endis;
+}
+
+function enable_change(enable_change) {
+ endis = !(document.iform.enable.checked || enable_change);
+ // make sure a default answer is called if this is invoked.
+ endis2 = (document.iform.enable);
+ document.iform.performance.disabled = endis;
+ document.iform.blockoffenders7.disabled = endis;
+ document.iform.blockoffendersip.disabled=endis;
+ document.iform.blockoffenderskill.disabled=endis;
+ document.iform.alertsystemlog.disabled = endis;
+ document.iform.externallistname.disabled = endis;
+ document.iform.cksumcheck.disabled = endis;
+ document.iform.homelistname.disabled = endis;
+ document.iform.whitelistname.disabled=endis;
+ document.iform.suppresslistname.disabled = endis;
+ document.iform.configpassthru.disabled = endis;
+ document.iform.btnHomeNet.disabled=endis;
+ document.iform.btnWhitelist.disabled=endis;
+ document.iform.btnSuppressList.disabled=endis;
+}
+
+function wopen(url, name, w, h) {
+ // Fudge factors for window decoration space.
+ // In my tests these work well on all platforms & browsers.
+ w += 32;
+ h += 96;
+ var win = window.open(url,
+ name,
+ 'width=' + w + ', height=' + h + ', ' +
+ 'location=no, menubar=no, ' +
+ 'status=no, toolbar=no, scrollbars=yes, resizable=yes');
+ win.resizeTo(w, h);
+ win.focus();
+}
+
+function getSelectedValue(elemID) {
+ var ctrl = document.getElementById(elemID);
+ return ctrl.options[ctrl.selectedIndex].value;
+}
+
+function viewList(id, elemID, elemType) {
+ if (typeof elemType == "undefined") {
+ elemType = "whitelist";
+ }
+ var url = "snort_list_view.php?id=" + id + "&wlist=";
+ url = url + getSelectedValue(elemID) + "&type=" + elemType;
+ wopen(url, 'WhitelistViewer', 640, 480);
+}
//-->
</script>
<?php include("fend.inc"); ?>
diff --git a/config/snort/snort_interfaces_global.php b/config/snort/snort_interfaces_global.php
index 9dde8aaf..0b9c5f2d 100644
--- a/config/snort/snort_interfaces_global.php
+++ b/config/snort/snort_interfaces_global.php
@@ -50,6 +50,10 @@ $pconfig['snortloglimit'] = $config['installedpackages']['snortglobal']['snortlo
$pconfig['snortloglimitsize'] = $config['installedpackages']['snortglobal']['snortloglimitsize'];
$pconfig['autorulesupdate7'] = $config['installedpackages']['snortglobal']['autorulesupdate7'];
$pconfig['forcekeepsettings'] = $config['installedpackages']['snortglobal']['forcekeepsettings'];
+$pconfig['snortcommunityrules'] = $config['installedpackages']['snortglobal']['snortcommunityrules'];
+
+if (empty($pconfig['snortloglimit']))
+ $pconfig['snortloglimit'] = 'on';
/* if no errors move foward */
if (!$input_errors) {
@@ -58,7 +62,9 @@ if (!$input_errors) {
$config['installedpackages']['snortglobal']['snortdownload'] = $_POST['snortdownload'];
$config['installedpackages']['snortglobal']['oinkmastercode'] = $_POST['oinkmastercode'];
+ $config['installedpackages']['snortglobal']['snortcommunityrules'] = $_POST['snortcommunityrules'] ? 'on' : 'off';
$config['installedpackages']['snortglobal']['emergingthreats'] = $_POST['emergingthreats'] ? 'on' : 'off';
+
$config['installedpackages']['snortglobal']['rm_blocked'] = $_POST['rm_blocked'];
if ($_POST['snortloglimitsize']) {
$config['installedpackages']['snortglobal']['snortloglimit'] = $_POST['snortloglimit'];
@@ -110,9 +116,23 @@ if ($input_errors)
?>
+<script language="JavaScript">
+<!--
+function enable_snort_vrt(btn) {
+ if (btn == 'off') {
+ document.iform.oinkmastercode.disabled = "true";
+ }
+ if (btn == 'on') {
+ document.iform.oinkmastercode.disabled = "";
+ }
+}
+//-->
+</script>
+
+
<form action="snort_interfaces_global.php" method="post" enctype="multipart/form-data" name="iform" id="iform">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
-<tr><td class="tabnavtbl">
+<tr><td>
<?php
$tab_array = array();
$tab_array[0] = array(gettext("Snort Interfaces"), false, "/snort/snort_interfaces.php");
@@ -122,65 +142,81 @@ if ($input_errors)
$tab_array[4] = array(gettext("Blocked"), false, "/snort/snort_blocked.php");
$tab_array[5] = array(gettext("Whitelists"), false, "/snort/snort_interfaces_whitelist.php");
$tab_array[6] = array(gettext("Suppress"), false, "/snort/snort_interfaces_suppress.php");
+ $tab_array[7] = array(gettext("Sync"), false, "/pkg_edit.php?xml=snort/snort_sync.xml");
display_top_tabs($tab_array);
?>
</td></tr>
<tr>
- <td class="tabcont">
- <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <td>
+ <div id="mainarea">
+ <table id="maintable" class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
<tr>
<td colspan="2" valign="top" class="listtopic"><?php echo gettext("Please Choose The " .
"Type Of Rules You Wish To Download"); ?></td>
</tr>
- <td width="22%" valign="top" class="vncell"><?php echo gettext("Install Snort.org rules"); ?></td>
+ <td width="22%" valign="top" class="vncell"><?php printf(gettext("Install %sSnort VRT%s rules"), '<strong>' , '</strong>'); ?></td>
<td width="78%" class="vtable">
- <table cellpadding="0" cellspacing="0">
+ <table width="100%" border="0" cellpadding="2" cellspacing="0">
<tr>
- <td colspan="2"><input name="snortdownload" type="radio"
- id="snortdownload" value="off"
-<?php if($pconfig['snortdownload']=='off' || $pconfig['snortdownload']=='') echo 'checked'; ?>>
- <?php printf(gettext("Do %sNOT%s Install"), '<strong>', '</strong>'); ?></td>
+ <td><input name="snortdownload" type="radio" id="snortdownload" value="off" onclick="enable_snort_vrt('off')"
+ <?php if($pconfig['snortdownload']=='off' || $pconfig['snortdownload']=='') echo 'checked'; ?> >&nbsp;&nbsp;</td>
+ <td><span class="vexpl"><?php printf(gettext("Do %sNOT%s Install"), '<strong>', '</strong>'); ?></span></td>
</tr>
<tr>
- <td colspan="2"><input name="snortdownload" type="radio"
- id="snortdownload" value="on"
- <?php if($pconfig['snortdownload']=='on') echo 'checked'; ?>> <?php echo gettext("Install " .
- "Basic Rules or Premium rules"); ?> <br>
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a
- href="https://www.snort.org/signup" target="_blank"><?php echo gettext("Sign Up for a " .
- "Basic Rule Account"); ?></a><br>
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a
- href="http://www.snort.org/vrt/buy-a-subscription"
- target="_blank"><?php echo gettext("Sign Up for Sourcefire VRT Certified Premium " .
- "Rules. This Is Highly Recommended"); ?></a></td>
- </tr>
+ <td><input name="snortdownload" type="radio" id="snortdownload" value="on" onclick="enable_snort_vrt('on')"
+ <?php if($pconfig['snortdownload']=='on') echo 'checked'; ?>></td>
+ <td><span class="vexpl"><?php echo gettext("Install Basic Rules or Premium rules"); ?></span></td>
<tr>
<td>&nbsp;</td>
+ <td><a href="https://www.snort.org/signup" target="_blank"><?php echo gettext("Sign Up for a Basic Rule Account"); ?> </a><br>
+ <a href="http://www.snort.org/vrt/buy-a-subscription" target="_blank">
+ <?php echo gettext("Sign Up for Sourcefire VRT Certified Premium Rules. This Is Highly Recommended"); ?></a></td>
</tr>
- </table>
- <table width="100%" border="0" cellpadding="6" cellspacing="0">
<tr>
- <td colspan="2" valign="top" class="optsect_t2"><?php echo gettext("Oinkmaster code"); ?></td>
+ <td colspan="2">&nbsp;</td>
</tr>
+ </table>
+ <table width="100%" border="0" cellpadding="2" cellspacing="0">
<tr>
- <td class="vncell" valign="top"><?php echo gettext("Code"); ?></td>
- <td class="vtable"><input name="oinkmastercode" type="text"
+ <td colspan="2" valign="top"><b><span class="vexpl"><?php echo gettext("Oinkmaster Configuration"); ?></span></b></td>
+ </tr>
+ <tr>
+ <td valign="top"><span class="vexpl"><strong><?php echo gettext("Code"); ?><strong></span</td>
+ <td><input name="oinkmastercode" type="text"
class="formfld" id="oinkmastercode" size="52"
- value="<?=htmlspecialchars($pconfig['oinkmastercode']);?>"><br>
- <?php echo gettext("Obtain a snort.org Oinkmaster code and paste here."); ?></td>
-
+ value="<?=htmlspecialchars($pconfig['oinkmastercode']);?>"
+ <?php if($pconfig['snortdownload']<>'on') echo 'disabled'; ?>><br>
+ <?php echo gettext("Obtain a snort.org Oinkmaster code and paste it here."); ?></td>
+ </tr>
</table>
-
</tr>
<tr>
- <td width="22%" valign="top" class="vncell"><?php printf(gettext("Install %sEmergingthreats%s " .
+ <td width="22%" valign="top" class="vncell"><?php printf(gettext("Install %sSnort Community%s " .
+ "rules"), '<strong>' , '</strong>'); ?></td>
+ <td width="78%" class="vtable">
+ <table width="100%" border="0" cellpadding="2" cellspacing="0">
+ <tr>
+ <td valign="top" width="8%"><input name="snortcommunityrules" type="checkbox" value="yes"
+ <?php if ($config['installedpackages']['snortglobal']['snortcommunityrules']=="on") echo "checked"; ?> ></td>
+ <td><span class="vexpl"><?php echo gettext("The Snort Community Ruleset is a GPLv2 VRT certified ruleset that is distributed free of charge " .
+ "without any VRT License restrictions. This ruleset is updated daily and is a subset of the subscriber ruleset."); ?>
+ <br/><br/><?php printf(gettext("%sNote: %sIf you are a Snort VRT Paid Subscriber, the community ruleset is already built into your download of the Snort VRT rules, and there is no benefit in adding this rule set."),'<span class="red"><strong>' ,'</strong></span>'); ?></span><br></td>
+ </tr>
+ </table></td>
+</tr>
+<tr>
+ <td width="22%" valign="top" class="vncell"><?php printf(gettext("Install %sEmerging Threats%s " .
"rules"), '<strong>' , '</strong>'); ?></td>
- <td width="78%" class="vtable"><input name="emergingthreats"
- type="checkbox" value="yes"
- <?php if ($config['installedpackages']['snortglobal']['emergingthreats']=="on") echo "checked"; ?>
- ><br>
- <?php echo gettext("Emerging Threats is an open source community that produces fastest " .
- "moving and diverse Snort Rules."); ?></td>
+ <td width="78%" class="vtable">
+ <table width="100%" border="0" cellpadding="2" cellspacing="0">
+ <tr>
+ <td valign="top" width="8%"><input name="emergingthreats" type="checkbox" value="yes"
+ <?php if ($config['installedpackages']['snortglobal']['emergingthreats']=="on") echo "checked"; ?>>
+ <td><span class="vexpl"><?php echo gettext("Emerging Threats is an open source community that produces fast " .
+ "moving and diverse Snort Rules."); ?></span></td>
+ </tr>
+ </table>
+ </td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell"><?php echo gettext("Update rules " .
@@ -194,9 +230,9 @@ if ($input_errors)
<?php if ($iface3 == $pconfig['autorulesupdate7']) echo "selected"; ?>>
<?=htmlspecialchars($ifacename3);?></option>
<?php endforeach; ?>
- </select><br>
- <span class="vexpl"><?php echo gettext("Please select the update times for rules."); ?><br>
- <?php echo gettext("Hint: in most cases, every 12 hours is a good choice."); ?></span></td>
+ </select><span class="vexpl">&nbsp;&nbsp;<?php echo gettext("Please select the update times for rules."); ?><br/><br/>
+
+ <?php printf(gettext("%sHint%s: in most cases, every 12 hours is a good choice."), '<span class="red"><strong>','</strong></span>'); ?></span></td>
</tr>
<tr>
<td colspan="2" valign="top" class="listtopic"><?php echo gettext("General Settings"); ?></td>
@@ -209,40 +245,32 @@ if ($input_errors)
<br/>
<br/>
<span class="red"><strong><?php echo gettext("Note"); ?></span>:</strong><br>
- <?php echo gettext("Available space is"); ?> <strong><?php echo $snortlogCurrentDSKsize; ?>MB</strong></td>
+ <?php echo gettext("Available space is"); ?> <strong><?php echo $snortlogCurrentDSKsize; ?>&nbsp;MB</strong></td>
<td width="78%" class="vtable">
- <table cellpadding="0" cellspacing="0">
- <tr>
- <td colspan="2"><input name="snortloglimit" type="radio"
- id="snortloglimit" value="on"
-<?php if($pconfig['snortloglimit']=='on') echo 'checked'; ?>>
- <strong><?php echo gettext("Enable"); ?></strong> <?php echo gettext("directory size limit"); ?> (<strong><?php echo gettext("Default"); ?></strong>)</td>
- </tr>
- <tr>
- <td colspan="2"><input name="snortloglimit" type="radio"
- id="snortloglimit" value="off"
-<?php if($pconfig['snortloglimit']=='off') echo 'checked'; ?>> <strong><?php echo gettext("Disable"); ?></strong>
- <?php echo gettext("directory size limit"); ?><br>
- <br>
- <span class="red"><strong><?php echo gettext("Warning"); ?></span>:</strong> <?php echo gettext("Nanobsd " .
- "should use no more than 10MB of space."); ?></td>
- </tr>
- <tr>
- <td>&nbsp;</td>
- </tr>
- </table>
- <table width="100%" border="0" cellpadding="6" cellspacing="0">
- <tr>
- <td class="vncell3"><?php echo gettext("Size in"); ?> <strong>MB</strong></td>
- <td class="vtable"><input name="snortloglimitsize" type="text"
- class="formfld" id="snortloglimitsize" size="7"
- value="<?=htmlspecialchars($pconfig['snortloglimitsize']);?>">
- <?php echo gettext("Default is"); ?> <strong>20%</strong> <?php echo gettext("of available space."); ?></td>
-
- </table>
-
+ <table cellpadding="0" cellspacing="0">
+ <tr>
+ <td colspan="2"><input name="snortloglimit" type="radio" id="snortloglimit" value="on"
+ <?php if($pconfig['snortloglimit']=='on') echo 'checked'; ?>><span class="vexpl">
+ <strong><?php echo gettext("Enable"); ?></strong> <?php echo gettext("directory size limit"); ?> (<strong><?php echo gettext("Default"); ?></strong>)</span></td>
+ </tr>
+ <tr>
+ <td colspan="2"><input name="snortloglimit" type="radio" id="snortloglimit" value="off"
+ <?php if($pconfig['snortloglimit']=='off') echo 'checked'; ?>> <span class="vexpl"><strong><?php echo gettext("Disable"); ?></strong>
+ <?php echo gettext("directory size limit"); ?></span><br>
+ <br>
+ <span class="red"><strong><?php echo gettext("Warning"); ?></span>:</strong> <?php echo gettext("Nanobsd " .
+ "should use no more than 10MB of space."); ?></td>
+ </tr>
+ </table>
+ <table width="100%" border="0" cellpadding="2" cellspacing="0">
+ <tr>
+ <td><span class="vexpl"><?php echo gettext("Size in"); ?> <strong>MB</strong></span></td>
+ <td><input name="snortloglimitsize" type="text" class="formfld" id="snortloglimitsize" size="10" value="<?=htmlspecialchars($pconfig['snortloglimitsize']);?>">
+ &nbsp;&nbsp;<?php printf(gettext("Default is %s20%%%s of available space."), '<strong>', '</strong>'); ?></td>
+ </tr>
+ </table>
+ </td>
</tr>
-
<tr>
<td width="22%" valign="top" class="vncell"><?php echo gettext("Remove blocked hosts " .
"every"); ?></td>
@@ -255,10 +283,9 @@ if ($input_errors)
<?php if ($iface3 == $pconfig['rm_blocked']) echo "selected"; ?>>
<?=htmlspecialchars($ifacename3);?></option>
<?php endforeach; ?>
- </select><br>
- <span class="vexpl"><?php echo gettext("Please select the amount of time you would like " .
- "hosts to be blocked for."); ?><br>
- <?php echo gettext("Hint: in most cases, 1 hour is a good choice."); ?></span></td>
+ </select>&nbsp;&nbsp;
+ <?php echo gettext("Please select the amount of time you would like hosts to be blocked for."); ?><br/><br/>
+ <?php printf(gettext("%sHint:%s in most cases, 1 hour is a good choice."), '<span class="red"><strong>', '</strong></span>'); ?></td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell"><?php echo gettext("Keep snort settings " .
@@ -266,8 +293,7 @@ if ($input_errors)
<td width="78%" class="vtable"><input name="forcekeepsettings"
id="forcekeepsettings" type="checkbox" value="yes"
<?php if ($config['installedpackages']['snortglobal']['forcekeepsettings']=="on") echo "checked"; ?>
- ><br>
- <?php echo gettext("Settings will not be removed during deinstall."); ?></td>
+ >&nbsp;&nbsp;<?php echo gettext("Settings will not be removed during deinstall."); ?></td>
</tr>
<tr>
<td width="22%" valign="top">
@@ -279,10 +305,11 @@ if ($input_errors)
<td width="22%" valign="top">&nbsp;</td>
<td width="78%"><span class="vexpl"><span class="red"><strong><?php echo gettext("Note:"); ?><br>
</strong></span> <?php echo gettext("Changing any settings on this page will affect all " .
- "interfaces. Please, double check if your oink code is correct and " .
- "the type of snort.org account you hold."); ?></span></td>
+ "interfaces. Double check that your oink code is correct, and verify the " .
+ "type of Snort.org account you hold."); ?></span></td>
</tr>
</table>
+</div><br/>
</td></tr>
</table>
</form>
diff --git a/config/snort/snort_interfaces_suppress.php b/config/snort/snort_interfaces_suppress.php
index 93d3f2dc..8095ff37 100644
--- a/config/snort/snort_interfaces_suppress.php
+++ b/config/snort/snort_interfaces_suppress.php
@@ -79,12 +79,13 @@ if($pfsense_stable == 'yes'){echo '<p class="pgtitle">' . $pgtitle . '</p>';}
$tab_array[4] = array(gettext("Blocked"), false, "/snort/snort_blocked.php");
$tab_array[5] = array(gettext("Whitelists"), false, "/snort/snort_interfaces_whitelist.php");
$tab_array[6] = array(gettext("Suppress"), true, "/snort/snort_interfaces_suppress.php");
+ $tab_array[7] = array(gettext("Sync"), false, "/pkg_edit.php?xml=snort/snort_sync.xml");
display_top_tabs($tab_array);
?>
</td>
</tr>
-<tr><td class="tabcont">
-<table width="100%" border="0" cellpadding="0" cellspacing="0">
+<tr><td><div id="mainarea">
+<table id="maintable" class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="30%" class="listhdrr"><?php echo gettext("File Name"); ?></td>
<td width="60%" class="listhdr"><?php echo gettext("Description"); ?></td>
@@ -129,15 +130,16 @@ if($pfsense_stable == 'yes'){echo '<p class="pgtitle">' . $pgtitle . '</p>';}
width="17" height="17" border="0" title="<?php echo gettext("add a new list"); ?>"></a></td>
</tr>
</table>
+ </div>
</td>
</tr>
</table>
</td></tr>
<tr>
- <td colspan="3" width="100%"><span class="vexpl"><span class="red"><strong><?php echo gettext("Note:"); ?></strong></span>
+ <td colspan="3" width="100%"><br/><span class="vexpl"><span class="red"><strong><?php echo gettext("Note:"); ?></strong></span>
<p><span class="vexpl"><?php echo gettext("Here you can create event filtering and " .
- "suppression for your snort package rules."); ?><br>
- <?php echo gettext("Please note that you must restart a running rule so that changes can " .
+ "suppression for your snort package rules."); ?><br/><br/>
+ <?php echo gettext("Please note that you must restart a running Interface so that changes can " .
"take effect."); ?></span></p></td>
</tr>
</table>
diff --git a/config/snort/snort_interfaces_suppress_edit.php b/config/snort/snort_interfaces_suppress_edit.php
index 782b9784..5e12f656 100644
--- a/config/snort/snort_interfaces_suppress_edit.php
+++ b/config/snort/snort_interfaces_suppress_edit.php
@@ -58,7 +58,7 @@ function is_validwhitelistname($name) {
if (!is_string($name))
return false;
- if (!preg_match("/[^a-zA-Z0-9\.\/]/", $name))
+ if (!preg_match("/[^a-zA-Z0-9\_\.\/]/", $name))
return true;
return false;
@@ -88,7 +88,7 @@ if ($_POST['submit']) {
$input_errors[] = "Whitelist file names may not be named defaultwhitelist.";
if (is_validwhitelistname($_POST['name']) == false)
- $input_errors[] = "Whitelist file name may only consist of the characters a-z, A-Z and 0-9 _. Note: No Spaces. Press Cancel to reset.";
+ $input_errors[] = "Whitelist file name may only consist of the characters \"a-z, A-Z, 0-9 and _\". Note: No Spaces or dashes. Press Cancel to reset.";
/* check for name conflicts */
foreach ($a_suppress as $s_list) {
@@ -141,8 +141,22 @@ if ($savemsg)
?>
<form action="/snort/snort_interfaces_suppress_edit.php" name="iform" id="iform" method="post">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
-<tr><td class="tabcont">
-<table width="100%" border="0" cellpadding="6" cellspacing="0">
+<tr><td>
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Snort Interfaces"), false, "/snort/snort_interfaces.php");
+ $tab_array[1] = array(gettext("Global Settings"), false, "/snort/snort_interfaces_global.php");
+ $tab_array[2] = array(gettext("Updates"), false, "/snort/snort_download_updates.php");
+ $tab_array[3] = array(gettext("Alerts"), false, "/snort/snort_alerts.php");
+ $tab_array[4] = array(gettext("Blocked"), false, "/snort/snort_blocked.php");
+ $tab_array[5] = array(gettext("Whitelists"), false, "/snort/snort_interfaces_whitelist.php");
+ $tab_array[6] = array(gettext("Suppress"), true, "/snort/snort_interfaces_suppress.php");
+ $tab_array[7] = array(gettext("Sync"), false, "/pkg_edit.php?xml=/snort/snort_sync.xml");
+ display_top_tabs($tab_array);
+?>
+</td></tr>
+<tr><td><div id="mainarea">
+<table id="maintable" class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
<tr>
<td colspan="2" class="listtopic">Add the name and description of the file.</td>
</tr>
@@ -151,8 +165,8 @@ if ($savemsg)
<td width="78%" class="vtable"><input name="name" type="text" id="name"
class="formfld unkown" size="40" value="<?=htmlspecialchars($pconfig['name']);?>" /> <br />
<span class="vexpl"> <?php echo gettext("The list name may only consist of the " .
- "characters a-z, A-Z and 0-9."); ?> <span class="red"><?php echo gettext("Note:"); ?> </span>
- <?php echo gettext("No Spaces."); ?> </span></td>
+ "characters \"a-z, A-Z, 0-9 and _\"."); ?>&nbsp;&nbsp;<span class="red"><?php echo gettext("Note:"); ?> </span>
+ <?php echo gettext("No Spaces or dashes."); ?> </span></td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell"><?php echo gettext("Description"); ?></td>
@@ -205,6 +219,7 @@ if ($savemsg)
</td>
</tr>
</table>
+</div>
</td></tr>
</table>
</form>
diff --git a/config/snort/snort_interfaces_whitelist.php b/config/snort/snort_interfaces_whitelist.php
index f90cbe1f..73c9efda 100644
--- a/config/snort/snort_interfaces_whitelist.php
+++ b/config/snort/snort_interfaces_whitelist.php
@@ -85,13 +85,14 @@ if ($savemsg) print_info_box($savemsg);
$tab_array[4] = array(gettext("Blocked"), false, "/snort/snort_blocked.php");
$tab_array[5] = array(gettext("Whitelists"), true, "/snort/snort_interfaces_whitelist.php");
$tab_array[6] = array(gettext("Suppress"), false, "/snort/snort_interfaces_suppress.php");
+ $tab_array[7] = array(gettext("Sync"), false, "/pkg_edit.php?xml=snort/snort_sync.xml");
display_top_tabs($tab_array);
?>
</td>
</tr>
<tr>
- <td class="tabcont">
- <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <td><div id="mainarea">
+ <table id="maintable" class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
<tr>
<td width="20%" class="listhdrr">File Name</td>
<td width="40%" class="listhdrr">Values</td>
@@ -150,19 +151,25 @@ if ($savemsg) print_info_box($savemsg);
</td>
</tr>
</table>
+ </div>
</td>
</tr>
</table>
<br>
-<table width="100%" border="0" cellpadding="0"
- cellspacing="0">
+<table width="100%" border="0" cellpadding="1"
+ cellspacing="1">
+ <tr>
<td width="100%"><span class="vexpl"><span class="red"><strong><?php echo gettext("Note:"); ?></strong></span>
<p><span class="vexpl"><?php echo gettext("Here you can create whitelist files for your " .
"snort package rules."); ?><br>
<?php echo gettext("Please add all the ips or networks you want to protect against snort " .
"block decisions."); ?><br>
<?php echo gettext("Remember that the default whitelist only includes local networks."); ?><br>
- <?php echo gettext("Be careful, it is very easy to get locked out of you system."); ?></span></p></td>
+ <?php echo gettext("Be careful, it is very easy to get locked out of your system."); ?></span></p></td>
+ </tr>
+ <tr>
+ <td width="100%"><span class="vexpl"><?php echo gettext("Remember you must restart Snort on the interface for changes to take effect!"); ?></span></td>
+ </tr>
</table>
</form>
<?php include("fend.inc"); ?>
diff --git a/config/snort/snort_interfaces_whitelist_edit.php b/config/snort/snort_interfaces_whitelist_edit.php
index 378530ba..fc157375 100644
--- a/config/snort/snort_interfaces_whitelist_edit.php
+++ b/config/snort/snort_interfaces_whitelist_edit.php
@@ -66,7 +66,7 @@ function is_validwhitelistname($name) {
if (!is_string($name))
return false;
- if (!preg_match("/[^a-zA-Z0-9\.\/]/", $name))
+ if (!preg_match("/[^a-zA-Z0-9\_\.\/]/", $name))
return true;
return false;
@@ -80,6 +80,7 @@ if (isset($id) && $a_whitelist[$id]) {
$pconfig['detail'] = $a_whitelist[$id]['detail'];
$pconfig['address'] = $a_whitelist[$id]['address'];
$pconfig['descr'] = html_entity_decode($a_whitelist[$id]['descr']);
+ $pconfig['localnets'] = $a_whitelist[$id]['localnets'];
$pconfig['wanips'] = $a_whitelist[$id]['wanips'];
$pconfig['wangateips'] = $a_whitelist[$id]['wangateips'];
$pconfig['wandnsips'] = $a_whitelist[$id]['wandnsips'];
@@ -102,7 +103,7 @@ if ($_POST['submit']) {
$input_errors[] = gettext("Whitelist file names may not be named defaultwhitelist.");
if (is_validwhitelistname($_POST['name']) == false)
- $input_errors[] = gettext("Whitelist file name may only consist of the characters a-z, A-Z and 0-9 _. Note: No Spaces. Press Cancel to reset.");
+ $input_errors[] = gettext("Whitelist file name may only consist of the characters \"a-z, A-Z, 0-9 and _\". Note: No Spaces or dashes. Press Cancel to reset.");
/* check for name conflicts */
foreach ($a_whitelist as $w_list) {
@@ -124,6 +125,7 @@ if ($_POST['submit']) {
/* post user input */
$w_list['name'] = $_POST['name'];
$w_list['uuid'] = $whitelist_uuid;
+ $w_list['localnets'] = $_POST['localnets']? 'yes' : 'no';
$w_list['wanips'] = $_POST['wanips']? 'yes' : 'no';
$w_list['wangateips'] = $_POST['wangateips']? 'yes' : 'no';
$w_list['wandnsips'] = $_POST['wandnsips']? 'yes' : 'no';
@@ -168,8 +170,23 @@ if ($savemsg)
</script>
<form action="snort_interfaces_whitelist_edit.php" method="post" name="iform" id="iform">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
-<tr><td class="tabcont">
-<table width="100%" border="0" cellpadding="6" cellspacing="0">
+<tr><td>
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Snort Interfaces"), false, "/snort/snort_interfaces.php");
+ $tab_array[1] = array(gettext("Global Settings"), false, "/snort/snort_interfaces_global.php");
+ $tab_array[2] = array(gettext("Updates"), false, "/snort/snort_download_updates.php");
+ $tab_array[3] = array(gettext("Alerts"), false, "/snort/snort_alerts.php");
+ $tab_array[4] = array(gettext("Blocked"), false, "/snort/snort_blocked.php");
+ $tab_array[5] = array(gettext("Whitelists"), true, "/snort/snort_interfaces_whitelist.php");
+ $tab_array[6] = array(gettext("Suppress"), false, "/snort/snort_interfaces_suppress.php");
+ $tab_array[7] = array(gettext("Sync"), false, "/pkg_edit.php?xml=snort/snort_sync.xml");
+ display_top_tabs($tab_array);
+?>
+ </td>
+</tr>
+<tr><td><div id="mainarea">
+<table id="maintable" class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
<tr>
<td colspan="2" valign="top" class="listtopic"><?php echo gettext("Add the name and " .
"description of the file."); ?></td>
@@ -179,8 +196,8 @@ if ($savemsg)
<td class="vtable"><input name="name" type="text" id="name"
size="40" value="<?=htmlspecialchars($pconfig['name']);?>" /> <br />
<span class="vexpl"> <?php echo gettext("The list name may only consist of the " .
- "characters a-z, A-Z and 0-9."); ?> <span class="red"><?php echo gettext("Note:"); ?> </span>
- <?php echo gettext("No Spaces."); ?> </span></td>
+ "characters \"a-z, A-Z, 0-9 and _\"."); ?>&nbsp;&nbsp;<span class="red"><?php echo gettext("Note:"); ?> </span>
+ <?php echo gettext("No Spaces or dashes."); ?> </span></td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell"><?php echo gettext("Description"); ?></td>
@@ -190,24 +207,33 @@ if ($savemsg)
"reference (not parsed)."); ?> </span></td>
</tr>
<tr>
- <td colspan="2" valign="top" class="listtopic"><?php echo gettext("Add auto generated ips."); ?></td>
+ <td colspan="2" valign="top" class="listtopic"><?php echo gettext("Add auto-generated IP Addresses."); ?></td>
+ </tr>
+
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?php echo gettext("Local Networks"); ?></td>
+ <td width="78%" class="vtable"><input name="localnets" type="checkbox"
+ id="localnets" size="40" value="yes"
+ <?php if($pconfig['localnets'] == 'yes'){ echo "checked";} if($pconfig['localnets'] == ''){ echo "checked";} ?> />
+ <span class="vexpl"> <?php echo gettext("Add firewall Local Networks to the list (excluding WAN)."); ?> </span></td>
</tr>
+
<tr>
<td width="22%" valign="top" class="vncell"><?php echo gettext("WAN IPs"); ?></td>
<td width="78%" class="vtable"><input name="wanips" type="checkbox"
id="wanips" size="40" value="yes"
<?php if($pconfig['wanips'] == 'yes'){ echo "checked";} if($pconfig['wanips'] == ''){ echo "checked";} ?> />
- <span class="vexpl"> <?php echo gettext("Add WAN IPs to the list."); ?> </span></td>
+ <span class="vexpl"> <?php echo gettext("Add WAN interface IPs to the list."); ?> </span></td>
</tr>
<tr>
- <td width="22%" valign="top" class="vncell"><?php echo gettext("Wan Gateways"); ?></td>
+ <td width="22%" valign="top" class="vncell"><?php echo gettext("WAN Gateways"); ?></td>
<td width="78%" class="vtable"><input name="wangateips"
type="checkbox" id="wangateips" size="40" value="yes"
<?php if($pconfig['wangateips'] == 'yes'){ echo "checked";} if($pconfig['wangateips'] == ''){ echo "checked";} ?> />
<span class="vexpl"> <?php echo gettext("Add WAN Gateways to the list."); ?> </span></td>
</tr>
<tr>
- <td width="22%" valign="top" class="vncell"><?php echo gettext("Wan DNS servers"); ?></td>
+ <td width="22%" valign="top" class="vncell"><?php echo gettext("WAN DNS servers"); ?></td>
<td width="78%" class="vtable"><input name="wandnsips"
type="checkbox" id="wandnsips" size="40" value="yes"
<?php if($pconfig['wandnsips'] == 'yes'){ echo "checked";} if($pconfig['wandnsips'] == ''){ echo "checked";} ?> />
@@ -228,11 +254,11 @@ if ($savemsg)
<span class="vexpl"> <?php echo gettext("Add VPN Addresses to the list."); ?> </span></td>
</tr>
<tr>
- <td colspan="2" valign="top" class="listtopic"><?php echo gettext("Add your own custom ips."); ?></td>
+ <td colspan="2" valign="top" class="listtopic"><?php echo gettext("Add custom IP Addresses from configured Aliases."); ?></td>
</tr>
<tr>
<td width="22%" valign="top" class="vncellreq">
- <div id="addressnetworkport"><?php echo gettext("Alias of IP's"); ?></div>
+ <div id="addressnetworkport"><?php echo gettext("Alias Name:"); ?></div>
</td>
<td width="78%" class="vtable">
<input autocomplete="off" name="address" type="text" class="formfldalias" id="address" size="30" value="<?=htmlspecialchars($pconfig['address']);?>" />
@@ -247,6 +273,7 @@ if ($savemsg)
</td>
</tr>
</table>
+</div>
</td></tr>
</table>
</form>
diff --git a/config/snort/snort_list_view.php b/config/snort/snort_list_view.php
new file mode 100644
index 00000000..b7de064b
--- /dev/null
+++ b/config/snort/snort_list_view.php
@@ -0,0 +1,103 @@
+<?php
+/*
+ * snort_list_view.php
+ *
+ * Copyright (C) 2004, 2005 Scott Ullrich
+ * Copyright (C) 2011 Ermal Luci
+ * All rights reserved.
+ *
+ * Adapted for FreeNAS by Volker Theile (votdev@gmx.de)
+ * Copyright (C) 2006-2009 Volker Theile
+ *
+ * Adapted for Pfsense Snort package by Robert Zelaya
+ * Copyright (C) 2008-2009 Robert Zelaya
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+require_once("guiconfig.inc");
+require_once("/usr/local/pkg/snort/snort.inc");
+
+global $g, $config;
+
+$contents = '';
+
+$id = $_GET['id'];
+$wlist = $_GET['wlist'];
+$type = $_GET['type'];
+
+if (isset($id) && isset($wlist)) {
+ $a_rule = $config['installedpackages']['snortglobal']['rule'][$id];
+ if ($type == "whitelist") {
+ $list = snort_build_list($a_rule, $wlist);
+ $contents = implode("\n", $list);
+ }
+ elseif ($type == "suppress") {
+ $list = snort_find_list($wlist, $type);
+ $contents = str_replace("\r", "", base64_decode($list['suppresspassthru']));
+ }
+ else
+ $contents = gettext("\n\nERROR -- Requested List Type entity is not valid!");
+}
+else
+ $contents = gettext("\n\nERROR -- Supplied interface or List entity is not valid!");
+
+$pgtitle = array(gettext("Snort"), gettext(ucfirst($type) . " Viewer"));
+?>
+
+<?php include("head.inc");?>
+
+<body link="#000000" vlink="#000000" alink="#000000">
+<?php if ($savemsg) print_info_box($savemsg); ?>
+<?php // include("fbegin.inc");?>
+
+<form action="snort_whitelist_view.php" method="post">
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+<tr>
+ <td class="tabcont">
+ <table width="100%" cellpadding="0" cellspacing="6" bgcolor="#eeeeee">
+ <tr>
+ <td class="pgtitle" colspan="2">Snort: <?php echo gettext(ucfirst($type) . " Viewer"); ?></td>
+ </tr>
+ <tr>
+ <td align="left" width="20%">
+ <input type="button" class="formbtn" value="Return" onclick="window.close()">
+ </td>
+ <td align="right">
+ <b><?php echo gettext(ucfirst($type) . ": ") . '</b>&nbsp;' . $_GET['wlist']; ?>&nbsp;&nbsp;&nbsp;&nbsp;
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2" valign="top" class="label">
+ <div style="background: #eeeeee; width:100%; height:100%;" id="textareaitem"><!-- NOTE: The opening *and* the closing textarea tag must be on the same line. -->
+ <textarea style="width:100%; height:100%;" readonly wrap="off" rows="25" cols="80" name="code2"><?=$contents;?></textarea>
+ </div>
+ </td>
+ </tr>
+ </table>
+ </td>
+</tr>
+</table>
+</form>
+<?php // include("fend.inc");?>
+</body>
+</html>
diff --git a/config/snort/snort_log_view.php b/config/snort/snort_log_view.php
new file mode 100644
index 00000000..4fc8d990
--- /dev/null
+++ b/config/snort/snort_log_view.php
@@ -0,0 +1,89 @@
+<?php
+/*
+ * snort_log_view.php
+ *
+ * Copyright (C) 2004, 2005 Scott Ullrich
+ * Copyright (C) 2011 Ermal Luci
+ * All rights reserved.
+ *
+ * Adapted for FreeNAS by Volker Theile (votdev@gmx.de)
+ * Copyright (C) 2006-2009 Volker Theile
+ *
+ * Adapted for Pfsense Snort package by Robert Zelaya
+ * Copyright (C) 2008-2009 Robert Zelaya
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+require_once("guiconfig.inc");
+require_once("/usr/local/pkg/snort/snort.inc");
+
+$contents = '';
+
+// Read the contents of the argument passed to us.
+// Is it a fully qualified path and file?
+if (file_exists($_GET['logfile']))
+ $contents = file_get_contents($_GET['logfile']);
+// It is not something we can display, so print an error.
+else
+ $contents = gettext("\n\nERROR -- File: {$_GET['logfile']} not found!");
+
+$pgtitle = array(gettext("Snort"), gettext("Log File Viewer"));
+?>
+
+<?php include("head.inc");?>
+
+<body link="#000000" vlink="#000000" alink="#000000">
+<?php if ($savemsg) print_info_box($savemsg); ?>
+<?php // include("fbegin.inc");?>
+
+<form action="snort_log_view.php" method="post">
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+<tr>
+ <td class="tabcont">
+ <table width="100%" cellpadding="0" cellspacing="6" bgcolor="#eeeeee">
+ <tr>
+ <td class="pgtitle" colspan="2">Snort: Log File Viewer</td>
+ </tr>
+ <tr>
+ <td align="left" width="20%">
+ <input type="button" class="formbtn" value="Return" onclick="window.close()">
+ </td>
+ <td align="right">
+ <b><?php echo gettext("Log File: ") . '</b>&nbsp;' . $_GET['logfile']; ?>&nbsp;&nbsp;&nbsp;&nbsp;
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2" valign="top" class="label">
+ <div style="background: #eeeeee; width:100%; height:100%;" id="textareaitem"><!-- NOTE: The opening *and* the closing textarea tag must be on the same line. -->
+ <textarea style="width:100%; height:100%;" readonly wrap="off" rows="33" cols="80" name="code2"><?=$contents;?></textarea>
+ </div>
+ </td>
+ </tr>
+ </table>
+ </td>
+</tr>
+</table>
+</form>
+<?php // include("fend.inc");?>
+</body>
+</html>
diff --git a/config/snort/snort_preprocessors.php b/config/snort/snort_preprocessors.php
index 7d0348e9..12981398 100755
--- a/config/snort/snort_preprocessors.php
+++ b/config/snort/snort_preprocessors.php
@@ -34,7 +34,13 @@
require_once("guiconfig.inc");
require_once("/usr/local/pkg/snort/snort.inc");
-global $g;
+global $g, $rebuild_rules;
+$snortlogdir = SNORTLOGDIR;
+
+if (!is_array($config['installedpackages']['snortglobal'])) {
+ $config['installedpackages']['snortglobal'] = array();
+}
+$vrt_enabled = $config['installedpackages']['snortglobal']['snortdownload'];
if (!is_array($config['installedpackages']['snortglobal']['rule'])) {
$config['installedpackages']['snortglobal']['rule'] = array();
@@ -53,20 +59,41 @@ $pconfig = array();
if (isset($id) && $a_nat[$id]) {
$pconfig = $a_nat[$id];
- /* new options */
+ /* Get current values from config for page form fields */
$pconfig['perform_stat'] = $a_nat[$id]['perform_stat'];
$pconfig['server_flow_depth'] = $a_nat[$id]['server_flow_depth'];
$pconfig['http_server_profile'] = $a_nat[$id]['http_server_profile'];
$pconfig['client_flow_depth'] = $a_nat[$id]['client_flow_depth'];
+ $pconfig['stream5_reassembly'] = $a_nat[$id]['stream5_reassembly'];
+ $pconfig['stream5_require_3whs'] = $a_nat[$id]['stream5_require_3whs'];
+ $pconfig['stream5_track_tcp'] = $a_nat[$id]['stream5_track_tcp'];
+ $pconfig['stream5_track_udp'] = $a_nat[$id]['stream5_track_udp'];
+ $pconfig['stream5_track_icmp'] = $a_nat[$id]['stream5_track_icmp'];
$pconfig['max_queued_bytes'] = $a_nat[$id]['max_queued_bytes'];
$pconfig['max_queued_segs'] = $a_nat[$id]['max_queued_segs'];
+ $pconfig['stream5_overlap_limit'] = $a_nat[$id]['stream5_overlap_limit'];
+ $pconfig['stream5_policy'] = $a_nat[$id]['stream5_policy'];
$pconfig['stream5_mem_cap'] = $a_nat[$id]['stream5_mem_cap'];
+ $pconfig['stream5_tcp_timeout'] = $a_nat[$id]['stream5_tcp_timeout'];
+ $pconfig['stream5_udp_timeout'] = $a_nat[$id]['stream5_udp_timeout'];
+ $pconfig['stream5_icmp_timeout'] = $a_nat[$id]['stream5_icmp_timeout'];
+ $pconfig['stream5_no_reassemble_async'] = $a_nat[$id]['stream5_no_reassemble_async'];
+ $pconfig['stream5_dont_store_lg_pkts'] = $a_nat[$id]['stream5_dont_store_lg_pkts'];
$pconfig['http_inspect'] = $a_nat[$id]['http_inspect'];
+ $pconfig['http_inspect_memcap'] = $a_nat[$id]['http_inspect_memcap'];
+ $pconfig['http_inspect_enable_xff'] = $a_nat[$id]['http_inspect_enable_xff'];
+ $pconfig['http_inspect_log_uri'] = $a_nat[$id]['http_inspect_log_uri'];
+ $pconfig['http_inspect_log_hostname'] = $a_nat[$id]['http_inspect_log_hostname'];
$pconfig['noalert_http_inspect'] = $a_nat[$id]['noalert_http_inspect'];
$pconfig['other_preprocs'] = $a_nat[$id]['other_preprocs'];
$pconfig['ftp_preprocessor'] = $a_nat[$id]['ftp_preprocessor'];
$pconfig['smtp_preprocessor'] = $a_nat[$id]['smtp_preprocessor'];
$pconfig['sf_portscan'] = $a_nat[$id]['sf_portscan'];
+ $pconfig['pscan_protocol'] = $a_nat[$id]['pscan_protocol'];
+ $pconfig['pscan_type'] = $a_nat[$id]['pscan_type'];
+ $pconfig['pscan_sense_level'] = $a_nat[$id]['pscan_sense_level'];
+ $pconfig['pscan_memcap'] = $a_nat[$id]['pscan_memcap'];
+ $pconfig['pscan_ignore_scanners'] = $a_nat[$id]['pscan_ignore_scanners'];
$pconfig['dce_rpc_2'] = $a_nat[$id]['dce_rpc_2'];
$pconfig['dns_preprocessor'] = $a_nat[$id]['dns_preprocessor'];
$pconfig['sensitive_data'] = $a_nat[$id]['sensitive_data'];
@@ -77,25 +104,190 @@ if (isset($id) && $a_nat[$id]) {
$pconfig['dnp3_preproc'] = $a_nat[$id]['dnp3_preproc'];
$pconfig['modbus_preproc'] = $a_nat[$id]['modbus_preproc'];
$pconfig['gtp_preproc'] = $a_nat[$id]['gtp_preproc'];
+ $pconfig['preproc_auto_rule_disable'] = $a_nat[$id]['preproc_auto_rule_disable'];
+ $pconfig['protect_preproc_rules'] = $a_nat[$id]['protect_preproc_rules'];
+ $pconfig['frag3_detection'] = $a_nat[$id]['frag3_detection'];
+ $pconfig['frag3_overlap_limit'] = $a_nat[$id]['frag3_overlap_limit'];
+ $pconfig['frag3_min_frag_len'] = $a_nat[$id]['frag3_min_frag_len'];
+ $pconfig['frag3_policy'] = $a_nat[$id]['frag3_policy'];
+ $pconfig['frag3_max_frags'] = $a_nat[$id]['frag3_max_frags'];
+ $pconfig['frag3_memcap'] = $a_nat[$id]['frag3_memcap'];
+ $pconfig['frag3_timeout'] = $a_nat[$id]['frag3_timeout'];
+
+ /* If not using the Snort VRT rules, then disable */
+ /* the Sensitive Data (sdf) preprocessor. */
+ if ($vrt_enabled == "off")
+ $pconfig['sensitive_data'] = "off";
+
+ /************************************************************/
+ /* To keep new users from shooting themselves in the foot */
+ /* enable the most common required preprocessors by default */
+ /* and set reasonable values for any options. */
+ /************************************************************/
+ if (empty($pconfig['ftp_preprocessor']))
+ $pconfig['ftp_preprocessor'] = 'on';
+ if (empty($pconfig['smtp_preprocessor']))
+ $pconfig['smtp_preprocessor'] = 'on';
+ if (empty($pconfig['dce_rpc_2']))
+ $pconfig['dce_rpc_2'] = 'on';
+ if (empty($pconfig['dns_preprocessor']))
+ $pconfig['dns_preprocessor'] = 'on';
+ if (empty($pconfig['ssl_preproc']))
+ $pconfig['ssl_preproc'] = 'on';
+ if (empty($pconfig['pop_preproc']))
+ $pconfig['pop_preproc'] = 'on';
+ if (empty($pconfig['imap_preproc']))
+ $pconfig['imap_preproc'] = 'on';
+ if (empty($pconfig['sip_preproc']))
+ $pconfig['sip_preproc'] = 'on';
+ if (empty($pconfig['other_preprocs']))
+ $pconfig['other_preprocs'] = 'on';
+ if (empty($pconfig['http_inspect_memcap']))
+ $pconfig['http_inspect_memcap'] = "150994944";
+ if (empty($pconfig['frag3_overlap_limit']))
+ $pconfig['frag3_overlap_limit'] = '0';
+ if (empty($pconfig['frag3_min_frag_len']))
+ $pconfig['frag3_min_frag_len'] = '0';
+ if (empty($pconfig['frag3_max_frags']))
+ $pconfig['frag3_max_frags'] = '8192';
+ if (empty($pconfig['frag3_policy']))
+ $pconfig['frag3_policy'] = 'bsd';
+ if (empty($pconfig['frag3_memcap']))
+ $pconfig['frag3_memcap'] = '4194304';
+ if (empty($pconfig['frag3_timeout']))
+ $pconfig['frag3_timeout'] = '60';
+ if (empty($pconfig['frag3_detection']))
+ $pconfig['frag3_detection'] = 'on';
+ if (empty($pconfig['stream5_reassembly']))
+ $pconfig['stream5_reassembly'] = 'on';
+ if (empty($pconfig['stream5_track_tcp']))
+ $pconfig['stream5_track_tcp'] = 'on';
+ if (empty($pconfig['stream5_track_udp']))
+ $pconfig['stream5_track_udp'] = 'on';
+ if (empty($pconfig['stream5_track_icmp']))
+ $pconfig['stream5_track_icmp'] = 'off';
+ if (empty($pconfig['stream5_require_3whs']))
+ $pconfig['stream5_require_3whs'] = 'off';
+ if (empty($pconfig['stream5_overlap_limit']))
+ $pconfig['stream5_overlap_limit'] = '0';
+ if (empty($pconfig['stream5_tcp_timeout']))
+ $pconfig['stream5_tcp_timeout'] = '30';
+ if (empty($pconfig['stream5_udp_timeout']))
+ $pconfig['stream5_udp_timeout'] = '30';
+ if (empty($pconfig['stream5_icmp_timeout']))
+ $pconfig['stream5_icmp_timeout'] = '30';
+ if (empty($pconfig['stream5_no_reassemble_async']))
+ $pconfig['stream5_no_reassemble_async'] = 'off';
+ if (empty($pconfig['stream5_dont_store_lg_pkts']))
+ $pconfig['stream5_dont_store_lg_pkts'] = 'off';
+ if (empty($pconfig['stream5_policy']))
+ $pconfig['stream5_policy'] = 'bsd';
+ if (empty($pconfig['pscan_protocol']))
+ $pconfig['pscan_protocol'] = 'all';
+ if (empty($pconfig['pscan_type']))
+ $pconfig['pscan_type'] = 'all';
+ if (empty($pconfig['pscan_memcap']))
+ $pconfig['pscan_memcap'] = '10000000';
+ if (empty($pconfig['pscan_sense_level']))
+ $pconfig['pscan_sense_level'] = 'medium';
}
-if ($_POST) {
+/* Define the "disabled_preproc_rules.log" file for this interface */
+$iface = snort_get_friendly_interface($pconfig['interface']);
+$disabled_rules_log = "{$snortlogdir}/{$iface}_disabled_preproc_rules.log";
+
+if ($_POST['ResetAll']) {
+
+ /* Reset all the preprocessor settings to defaults */
+ $pconfig['perform_stat'] = "off";
+ $pconfig['server_flow_depth'] = "300";
+ $pconfig['http_server_profile'] = "all";
+ $pconfig['client_flow_depth'] = "300";
+ $pconfig['stream5_reassembly'] = "on";
+ $pconfig['stream5_require_3whs'] = "off";
+ $pconfig['stream5_track_tcp'] = "on";
+ $pconfig['stream5_track_udp'] = "on";
+ $pconfig['stream5_track_icmp'] = "off";
+ $pconfig['max_queued_bytes'] = "1048576";
+ $pconfig['max_queued_segs'] = "2621";
+ $pconfig['stream5_overlap_limit'] = "0";
+ $pconfig['stream5_policy'] = "bsd";
+ $pconfig['stream5_mem_cap'] = "8388608";
+ $pconfig['stream5_tcp_timeout'] = "30";
+ $pconfig['stream5_udp_timeout'] = "30";
+ $pconfig['stream5_icmp_timeout'] = "30";
+ $pconfig['stream5_no_reassemble_async'] = "off";
+ $pconfig['stream5_dont_store_lg_pkts'] = "off";
+ $pconfig['http_inspect'] = "on";
+ $pconfig['http_inspect_enable_xff'] = "off";
+ $pconfig['http_inspect_log_uri'] = "off";
+ $pconfig['http_inspect_log_hostname'] = "off";
+ $pconfig['noalert_http_inspect'] = "on";
+ $pconfig['http_inspect_memcap'] = "150994944";
+ $pconfig['other_preprocs'] = "on";
+ $pconfig['ftp_preprocessor'] = "on";
+ $pconfig['smtp_preprocessor'] = "on";
+ $pconfig['sf_portscan'] = "off";
+ $pconfig['pscan_protocol'] = "all";
+ $pconfig['pscan_type'] = "all";
+ $pconfig['pscan_sense_level'] = "medium";
+ $pconfig['pscan_ignore_scanners'] = "";
+ $pconfig['pscan_memcap'] = '10000000';
+ $pconfig['dce_rpc_2'] = "on";
+ $pconfig['dns_preprocessor'] = "on";
+ $pconfig['sensitive_data'] = "off";
+ $pconfig['ssl_preproc'] = "on";
+ $pconfig['pop_preproc'] = "on";
+ $pconfig['imap_preproc'] = "on";
+ $pconfig['sip_preproc'] = "on";
+ $pconfig['dnp3_preproc'] = "off";
+ $pconfig['modbus_preproc'] = "off";
+ $pconfig['gtp_preproc'] = "off";
+ $pconfig['preproc_auto_rule_disable'] = "off";
+ $pconfig['protect_preproc_rules'] = "off";
+ $pconfig['frag3_detection'] = "on";
+ $pconfig['frag3_overlap_limit'] = "0";
+ $pconfig['frag3_min_frag_len'] = "0";
+ $pconfig['frag3_policy'] = "bsd";
+ $pconfig['frag3_max_frags'] = "8192";
+ $pconfig['frag3_memcap'] = "4194304";
+ $pconfig['frag3_timeout'] = "60";
+
+ /* Log a message at the top of the page to inform the user */
+ $savemsg = "All preprocessor settings have been reset to the defaults.";
+}
+elseif ($_POST['Submit']) {
$natent = array();
$natent = $pconfig;
if ($_POST['pscan_ignore_scanners'] && !is_alias($_POST['pscan_ignore_scanners']))
- $input_errors[] = "Only aliases are allowed";
+ $input_errors[] = "Only aliases are allowed for the Portscan IGNORE_SCANNERS option.";
/* if no errors write to conf */
if (!$input_errors) {
/* post new options */
- if ($_POST['server_flow_depth'] != "") { $natent['server_flow_depth'] = $_POST['server_flow_depth']; }else{ $natent['server_flow_depth'] = ""; }
+ if ($_POST['server_flow_depth'] != "") { $natent['server_flow_depth'] = $_POST['server_flow_depth']; }else{ $natent['server_flow_depth'] = "300"; }
if ($_POST['http_server_profile'] != "") { $natent['http_server_profile'] = $_POST['http_server_profile']; }else{ $natent['http_server_profile'] = "all"; }
- if ($_POST['client_flow_depth'] != "") { $natent['client_flow_depth'] = $_POST['client_flow_depth']; }else{ $natent['client_flow_depth'] = ""; }
- if ($_POST['max_queued_bytes'] != "") { $natent['max_queued_bytes'] = $_POST['max_queued_bytes']; }else{ $natent['max_queued_bytes'] = ""; }
- if ($_POST['max_queued_segs'] != "") { $natent['max_queued_segs'] = $_POST['max_queued_segs']; }else{ $natent['max_queued_segs'] = ""; }
- if ($_POST['stream5_mem_cap'] != "") { $natent['stream5_mem_cap'] = $_POST['stream5_mem_cap']; }else{ $natent['stream5_mem_cap'] = ""; }
+ if ($_POST['client_flow_depth'] != "") { $natent['client_flow_depth'] = $_POST['client_flow_depth']; }else{ $natent['client_flow_depth'] = "300"; }
+ if ($_POST['http_inspect_memcap'] != "") { $natent['http_inspect_memcap'] = $_POST['http_inspect_memcap']; }else{ $natent['http_inspect_memcap'] = "150994944"; }
+ if ($_POST['stream5_overlap_limit'] != "") { $natent['stream5_overlap_limit'] = $_POST['stream5_overlap_limit']; }else{ $natent['stream5_overlap_limit'] = "0"; }
+ if ($_POST['stream5_policy'] != "") { $natent['stream5_policy'] = $_POST['stream5_policy']; }else{ $natent['stream5_policy'] = "bsd"; }
+ if ($_POST['stream5_mem_cap'] != "") { $natent['stream5_mem_cap'] = $_POST['stream5_mem_cap']; }else{ $natent['stream5_mem_cap'] = "8388608"; }
+ if ($_POST['stream5_tcp_timeout'] != "") { $natent['stream5_tcp_timeout'] = $_POST['stream5_tcp_timeout']; }else{ $natent['stream5_tcp_timeout'] = "30"; }
+ if ($_POST['stream5_udp_timeout'] != "") { $natent['stream5_udp_timeout'] = $_POST['stream5_udp_timeout']; }else{ $natent['stream5_udp_timeout'] = "30"; }
+ if ($_POST['stream5_icmp_timeout'] != "") { $natent['stream5_icmp_timeout'] = $_POST['stream5_icmp_timeout']; }else{ $natent['stream5_icmp_timeout'] = "30"; }
+ if ($_POST['max_queued_bytes'] != "") { $natent['max_queued_bytes'] = $_POST['max_queued_bytes']; }else{ $natent['max_queued_bytes'] = "1048576"; }
+ if ($_POST['max_queued_segs'] != "") { $natent['max_queued_segs'] = $_POST['max_queued_segs']; }else{ $natent['max_queued_segs'] = "2621"; }
+ if ($_POST['pscan_protocol'] != "") { $natent['pscan_protocol'] = $_POST['pscan_protocol']; }else{ $natent['pscan_protocol'] = "all"; }
+ if ($_POST['pscan_type'] != "") { $natent['pscan_type'] = $_POST['pscan_type']; }else{ $natent['pscan_type'] = "all"; }
+ if ($_POST['pscan_memcap'] != "") { $natent['pscan_memcap'] = $_POST['pscan_memcap']; }else{ $natent['pscan_memcap'] = "10000000"; }
if ($_POST['pscan_sense_level'] != "") { $natent['pscan_sense_level'] = $_POST['pscan_sense_level']; }else{ $natent['pscan_sense_level'] = "medium"; }
+ if ($_POST['frag3_overlap_limit'] != "") { $natent['frag3_overlap_limit'] = $_POST['frag3_overlap_limit']; }else{ $natent['frag3_overlap_limit'] = "0"; }
+ if ($_POST['frag3_min_frag_len'] != "") { $natent['frag3_min_frag_len'] = $_POST['frag3_min_frag_len']; }else{ $natent['frag3_min_frag_len'] = "0"; }
+ if ($_POST['frag3_policy'] != "") { $natent['frag3_policy'] = $_POST['frag3_policy']; }else{ $natent['frag3_policy'] = "bsd"; }
+ if ($_POST['frag3_max_frags'] != "") { $natent['frag3_max_frags'] = $_POST['frag3_max_frags']; }else{ $natent['frag3_max_frags'] = "8192"; }
+ if ($_POST['frag3_memcap'] != "") { $natent['frag3_memcap'] = $_POST['frag3_memcap']; }else{ $natent['frag3_memcap'] = "4194304"; }
+ if ($_POST['frag3_timeout'] != "") { $natent['frag3_timeout'] = $_POST['frag3_timeout']; }else{ $natent['frag3_timeout'] = "60"; }
if ($_POST['pscan_ignore_scanners'])
$natent['pscan_ignore_scanners'] = $_POST['pscan_ignore_scanners'];
@@ -104,6 +296,9 @@ if ($_POST) {
$natent['perform_stat'] = $_POST['perform_stat'] ? 'on' : 'off';
$natent['http_inspect'] = $_POST['http_inspect'] ? 'on' : 'off';
+ $natent['http_inspect_enable_xff'] = $_POST['http_inspect_enable_xff'] ? 'on' : 'off';
+ $natent['http_inspect_log_uri'] = $_POST['http_inspect_log_uri'] ? 'on' : 'off';
+ $natent['http_inspect_log_hostname'] = $_POST['http_inspect_log_hostname'] ? 'on' : 'off';
$natent['noalert_http_inspect'] = $_POST['noalert_http_inspect'] ? 'on' : 'off';
$natent['other_preprocs'] = $_POST['other_preprocs'] ? 'on' : 'off';
$natent['ftp_preprocessor'] = $_POST['ftp_preprocessor'] ? 'on' : 'off';
@@ -120,6 +315,20 @@ if ($_POST) {
$natent['sip_preproc'] = $_POST['sip_preproc'] ? 'on' : 'off';
$natent['modbus_preproc'] = $_POST['modbus_preproc'] ? 'on' : 'off';
$natent['gtp_preproc'] = $_POST['gtp_preproc'] ? 'on' : 'off';
+ $natent['preproc_auto_rule_disable'] = $_POST['preproc_auto_rule_disable'] ? 'on' : 'off';
+ $natent['protect_preproc_rules'] = $_POST['protect_preproc_rules'] ? 'on' : 'off';
+ $natent['frag3_detection'] = $_POST['frag3_detection'] ? 'on' : 'off';
+ $natent['stream5_reassembly'] = $_POST['stream5_reassembly'] ? 'on' : 'off';
+ $natent['stream5_track_tcp'] = $_POST['stream5_track_tcp'] ? 'on' : 'off';
+ $natent['stream5_track_udp'] = $_POST['stream5_track_udp'] ? 'on' : 'off';
+ $natent['stream5_track_icmp'] = $_POST['stream5_track_icmp'] ? 'on' : 'off';
+ $natent['stream5_require_3whs'] = $_POST['stream5_require_3whs'] ? 'on' : 'off';
+ $natent['stream5_no_reassemble_async'] = $_POST['stream5_no_reassemble_async'] ? 'on' : 'off';
+ $natent['stream5_dont_store_lg_pkts'] = $_POST['stream5_dont_store_lg_pkts'] ? 'on' : 'off';
+
+ /* If 'preproc_auto_rule_disable' is off, then clear log file */
+ if ($natent['preproc_auto_rule_disable'] == 'off')
+ @unlink("{$disabled_rules_log}");
if (isset($id) && $a_nat[$id])
$a_nat[$id] = $natent;
@@ -132,8 +341,15 @@ if ($_POST) {
write_config();
- $if_real = snort_get_real_interface($pconfig['interface']);
- sync_snort_package_config();
+ /* Set flag to rebuild rules for this interface */
+ $rebuild_rules = "on";
+
+ /*************************************************/
+ /* Update the snort conf file and rebuild the */
+ /* rules for this interface. */
+ /*************************************************/
+ snort_generate_conf($natent);
+ $rebuild_rules = "off";
/* after click go to this page */
header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' );
@@ -147,10 +363,10 @@ if ($_POST) {
}
$if_friendly = snort_get_friendly_interface($pconfig['interface']);
-$pgtitle = "Snort: Interface {$if_real} Preprocessors and Flow";
+$pgtitle = "Snort: Interface {$if_friendly}: Preprocessors and Flow";
include_once("head.inc");
?>
-<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="enable_change_all()">
<?php include("fbegin.inc"); ?>
<?php if($pfsense_stable == 'yes'){echo '<p class="pgtitle">' . $pgtitle . '</p>';}
@@ -172,40 +388,97 @@ include_once("head.inc");
</script>
<script type="text/javascript" src="/javascript/suggestions.js">
</script>
+
<form action="snort_preprocessors.php" method="post"
enctype="multipart/form-data" name="iform" id="iform">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td>
<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Snort Interfaces"), true, "/snort/snort_interfaces.php");
+ $tab_array[1] = array(gettext("Global Settings"), false, "/snort/snort_interfaces_global.php");
+ $tab_array[2] = array(gettext("Updates"), false, "/snort/snort_download_updates.php");
+ $tab_array[3] = array(gettext("Alerts"), false, "/snort/snort_alerts.php");
+ $tab_array[4] = array(gettext("Blocked"), false, "/snort/snort_blocked.php");
+ $tab_array[5] = array(gettext("Whitelists"), false, "/snort/snort_interfaces_whitelist.php");
+ $tab_array[6] = array(gettext("Suppress"), false, "/snort/snort_interfaces_suppress.php");
+ $tab_array[7] = array(gettext("Sync"), false, "/pkg_edit.php?xml=snort/snort_sync.xml");
+ display_top_tabs($tab_array);
+ echo '</td></tr>';
+ echo '<tr><td>';
+ $menu_iface=($if_friendly?substr($if_friendly,0,5)." ":"Iface ");
$tab_array = array();
- $tab_array[] = array(gettext("Snort Interfaces"), false, "/snort/snort_interfaces.php");
- $tab_array[] = array(gettext("If Settings"), false, "/snort/snort_interfaces_edit.php?id={$id}");
- $tab_array[] = array(gettext("Categories"), false, "/snort/snort_rulesets.php?id={$id}");
- $tab_array[] = array(gettext("Rules"), false, "/snort/snort_rules.php?id={$id}");
- $tab_array[] = array(gettext("Variables"), false, "/snort/snort_define_servers.php?id={$id}");
- $tab_array[] = array(gettext("Preprocessors"), true, "/snort/snort_preprocessors.php?id={$id}");
- $tab_array[] = array(gettext("Barnyard2"), false, "/snort/snort_barnyard.php?id={$id}");
+ $tab_array[] = array($menu_iface . gettext("Settings"), false, "/snort/snort_interfaces_edit.php?id={$id}");
+ $tab_array[] = array($menu_iface . gettext("Categories"), false, "/snort/snort_rulesets.php?id={$id}");
+ $tab_array[] = array($menu_iface . gettext("Rules"), false, "/snort/snort_rules.php?id={$id}");
+ $tab_array[] = array($menu_iface . gettext("Variables"), false, "/snort/snort_define_servers.php?id={$id}");
+ $tab_array[] = array($menu_iface . gettext("Preprocessors"), true, "/snort/snort_preprocessors.php?id={$id}");
+ $tab_array[] = array($menu_iface . gettext("Barnyard2"), false, "/snort/snort_barnyard.php?id={$id}");
display_top_tabs($tab_array);
?>
</td></tr>
-<tr><td class="tabcont">
-<table width="100%" border="0" cellpadding="6" cellspacing="0">
+<tr><td><div id="mainarea">
+<table id="maintable" class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
<tr>
- <td colspan="2" align="center" valign="middle">
- <span class="red"><strong><?php echo gettext("NOTE"); ?></strong></span><br>
+ <td colspan="2" align="left" valign="middle">
<?php echo gettext("Rules may be dependent on preprocessors! Disabling preprocessors may result in "); ?>
- <?php echo gettext("dependent rules being automatically disabled."); ?><br>
- <?php echo gettext("Defaults will be used when there is no user input."); ?><br></td>
+ <?php echo gettext("Snort start failures unless dependent rules are also disabled."); ?>
+ <?php echo gettext("The Auto-Rule Disable feature can be used, but note the warning about compromising protection. " .
+ "Defaults will be used where no user input is provided."); ?></td>
</tr>
<tr>
- <td colspan="2" valign="top" class="listtopic"><?php echo gettext("Performance Statistics"); ?></td>
+
+ <td colspan="2" valign="top" class="listtopic"><?php echo gettext("Preprocessors Configuration"); ?></td>
</tr>
<tr>
- <td width="22%" valign="top" class="vncell"><?php echo gettext("Enable"); ?></td>
- <td width="78%" class="vtable"><input name="perform_stat"
- type="checkbox" value="on"
- <?php if ($pconfig['perform_stat']=="on") echo "checked"; ?>
- onClick="enable_change(false)"> <?php echo gettext("Collect Performance Statistics for this interface."); ?></td>
+ <td width="22%" valign="top" class="vncell"><?php echo gettext("Enable Performance Stats"); ?></td>
+ <td width="78%" class="vtable"><input name="perform_stat" type="checkbox" value="on"
+ <?php if ($pconfig['perform_stat']=="on") echo "checked"; ?>>
+ <?php echo gettext("Collect Performance Statistics for this interface."); ?></td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?php echo gettext("Protect Customized Preprocessor Rules"); ?></td>
+ <td width="78%" class="vtable"><input name="protect_preproc_rules" type="checkbox" value="on"
+ <?php if ($pconfig['protect_preproc_rules']=="on") echo "checked ";
+ if ($vrt_enabled <> 'on') echo "disabled"; ?>>
+ <?php echo gettext("Check this box if you maintain customized preprocessor text rules files for this interface."); ?>
+ <table width="100%" border="0" cellpadding="2" cellpadding="2">
+ <tr>
+ <td width="3%">&nbsp;</td>
+ <td><?php echo gettext("Enable this only if you use customized preprocessor text rules files and " .
+ "you do not want them overwritten by automatic Snort VRT rule updates. " .
+ "This option is disabled when Snort VRT rules download is not enabled on the Global Settings tab."); ?><br/><br/>
+ <?php echo "<span class=\"red\"><strong>" . gettext("Hint: ") . "</strong></span>" .
+ gettext("Most users should leave this unchecked."); ?></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?php echo gettext("Auto Rule Disable"); ?></td>
+ <td width="78%" class="vtable"><input name="preproc_auto_rule_disable" type="checkbox" value="on"
+ <?php if ($pconfig['preproc_auto_rule_disable']=="on") echo "checked"; ?>>
+ <?php echo gettext("Auto-disable text rules dependent on disabled preprocessors for this interface. ");
+ echo gettext("Default is ") . '<strong>' . gettext("Not Checked"); ?></strong>.<br/>
+ <table width="100%" border="0" cellpadding="2" cellpadding="2">
+ <tr>
+ <td width="3%">&nbsp;</td>
+ <td><span class="red"><strong><?php echo gettext("Warning: "); ?></strong></span>
+ <?php echo gettext("Enabling this option allows Snort to automatically disable any text rules " .
+ "containing rule options or content modifiers that are dependent upon the preprocessors " .
+ "you have not enabled. This may facilitate starting Snort without errors related to " .
+ "disabled preprocessors, but can substantially compromise the level of protection by " .
+ "automatically disabling detection rules."); ?></td>
+ </tr>
+ <?php if (file_exists($disabled_rules_log) && filesize($disabled_rules_log) > 0): ?>
+ <tr>
+ <td width="3%">&nbsp;</td>
+ <td class="vexpl"><input type="button" class="formbtn" value="View" onclick="wopen('snort_rules_edit.php?id=<?=$id;?>&openruleset=<?=$disabled_rules_log;?>','FileViewer',800,600)"/>
+ &nbsp;&nbsp;&nbsp;<?php echo gettext("Click to view the list of currently auto-disabled rules"); ?></td>
+ </tr>
+ <?php endif; ?>
+ </table>
+ </td>
</tr>
<tr>
<td colspan="2" valign="top" class="listtopic"><?php echo gettext("HTTP Inspect Settings"); ?></td>
@@ -213,10 +486,57 @@ include_once("head.inc");
<tr>
<td width="22%" valign="top" class="vncell"><?php echo gettext("Enable"); ?></td>
<td width="78%" class="vtable"><input name="http_inspect"
- type="checkbox" value="on"
- <?php if ($pconfig['http_inspect']=="on") echo "checked"; ?>
- onClick="enable_change(false)"> <?php echo gettext("Use HTTP Inspect to " .
- "Normalize/Decode and detect HTTP traffic and protocol anomalies."); ?></td>
+ type="checkbox" value="on" id="http_inspect" onclick="http_inspect_enable_change()"
+ <?php if ($pconfig['http_inspect']=="on" || empty($pconfig['http_inspect'])) echo "checked"; ?>>
+ <?php echo gettext("Use HTTP Inspect to " .
+ "Normalize/Decode and detect HTTP traffic and protocol anomalies. Default is "); ?>
+ <strong><?php echo gettext("Checked"); ?></strong>.</td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?php echo gettext("Enable XFF/True-Client-IP"); ?></td>
+ <td width="78%" class="vtable"><input name="http_inspect_enable_xff"
+ type="checkbox" value="on" id="http_inspect_enable_xff"
+ <?php if ($pconfig['http_inspect_enable_xff']=="on") echo "checked"; ?>>
+ <?php echo gettext("Log original client IP present in X-Forwarded-For or True-Client-IP " .
+ "HTTP headers. Default is "); ?>
+ <strong><?php echo gettext("Not Checked"); ?></strong>.</td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?php echo gettext("Enable URI Logging"); ?></td>
+ <td width="78%" class="vtable"><input name="http_inspect_log_uri"
+ type="checkbox" value="on" id="http_inspect_log_uri"
+ <?php if ($pconfig['http_inspect_log_uri']=="on") echo "checked"; ?>>
+ <?php echo gettext("Parse URI data from the HTTP request and log it with other session data." .
+ " Default is "); ?>
+ <strong><?php echo gettext("Not Checked"); ?></strong>.</td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?php echo gettext("Enable Hostname Logging"); ?></td>
+ <td width="78%" class="vtable"><input name="http_inspect_log_hostname"
+ type="checkbox" value="on" id="http_inspect_log_hostname"
+ <?php if ($pconfig['http_inspect_log_hostname']=="on") echo "checked"; ?>>
+ <?php echo gettext("Parse Hostname data from the HTTP request and log it with other session data." .
+ " Default is "); ?>
+ <strong><?php echo gettext("Not Checked"); ?></strong>.</td>
+ </tr>
+ <tr>
+ <td valign="top" class="vncell"><?php echo gettext("HTTP Inspect Memory Cap"); ?></td>
+ <td class="vtable">
+ <table cellpadding="0" cellspacing="0">
+ <tr>
+ <td><input name="http_inspect_memcap" type="text" class="formfld"
+ id="http_inspect_memcap" size="6"
+ value="<?=htmlspecialchars($pconfig['http_inspect_memcap']);?>">&nbsp;&nbsp;
+ <?php echo gettext("Max memory in bytes to use for URI and Hostname logging. Min is ") .
+ "<strong>" . gettext("2304") . "</strong>" . gettext(" and Max is ") . "<strong>" .
+ gettext("603979776") . "</strong>" . gettext(" (576 MB)"); ?>.</td>
+ </tr>
+ </table>
+ <?php echo gettext("Maximum amount of memory the preprocessor will use for logging the URI and Hostname data. The default " .
+ "value is ") . "<strong>" . gettext("150,994,944") . "</strong>" . gettext(" (144 MB)."); ?>
+ <?php echo gettext(" This option determines the maximum HTTP sessions that will log URI and Hostname data at any given instant. ") .
+ gettext(" Max Logged Sessions = MEMCAP / 2304"); ?>.<br/>
+ </td>
</tr>
<tr>
<td valign="top" class="vncell"><?php echo gettext("HTTP server flow depth"); ?></td>
@@ -224,16 +544,16 @@ include_once("head.inc");
<table cellpadding="0" cellspacing="0">
<tr>
<td><input name="server_flow_depth" type="text" class="formfld"
- id="flow_depth" size="6"
+ id="server_flow_depth" size="6"
value="<?=htmlspecialchars($pconfig['server_flow_depth']);?>">&nbsp;&nbsp;<?php echo gettext("<strong>-1</strong> " .
"to <strong>65535</strong> (<strong>-1</strong> disables HTTP " .
"inspect, <strong>0</strong> enables all HTTP inspect)"); ?></td>
</tr>
</table>
<?php echo gettext("Amount of HTTP server response payload to inspect. Snort's " .
- "performance may increase by adjusting this value."); ?><br>
+ "performance may increase by adjusting this value."); ?><br/>
<?php echo gettext("Setting this value too low may cause false negatives. Values above 0 " .
- "are specified in bytes. Recommended setting is maximum (65535). Default value is <strong>300</strong>"); ?><br>
+ "are specified in bytes. Recommended setting is maximum (65535). Default value is <strong>300</strong>"); ?><br/>
</td>
</tr>
<tr>
@@ -241,16 +561,16 @@ include_once("head.inc");
<td width="78%" class="vtable">
<select name="http_server_profile" class="formselect" id="http_server_profile">
<?php
- $profile = array('All', 'Apache', 'IIS', 'IIS_4.0', 'IIS_5.0');
+ $profile = array('All', 'Apache', 'IIS', 'IIS4_0', 'IIS5_0');
foreach ($profile as $val): ?>
<option value="<?=strtolower($val);?>"
<?php if (strtolower($val) == $pconfig['http_server_profile']) echo "selected"; ?>>
<?=gettext($val);?></option>
<?php endforeach; ?>
- </select>&nbsp;&nbsp;<?php echo gettext("Choose the profile type of the protected web server."); ?><br>
- <?php echo gettext(" The default is <strong>All</strong>. "); ?>
- <?php echo gettext("IIS_4.0 and IIS_5.0 are identical to IIS except they alert on the "); ?>
- <?php echo gettext("double decoding vulnerability present in those two versions."); ?><br>
+ </select>&nbsp;&nbsp;<?php echo gettext("Choose the profile type of the protected web server. The default is ") .
+ "<strong>" . gettext("All") . "</strong>"; ?><br/>
+ <?php echo gettext("IIS_4.0 and IIS_5.0 are identical to IIS except they alert on the ") .
+ gettext("double decoding vulnerability present in those versions."); ?><br/>
</td>
</tr>
<tr>
@@ -259,7 +579,7 @@ include_once("head.inc");
<table cellpadding="0" cellspacing="0">
<tr>
<td><input name="client_flow_depth" type="text" class="formfld"
- id="flow_depth" size="6"
+ id="client_flow_depth" size="6"
value="<?=htmlspecialchars($pconfig['client_flow_depth']);?>"> <?php echo gettext("<strong>-1</strong> " .
"to <strong>1460</strong> (<strong>-1</strong> disables HTTP " .
"inspect, <strong>0</strong> enables all HTTP inspect)"); ?></td>
@@ -268,21 +588,175 @@ include_once("head.inc");
<?php echo gettext("Amount of raw HTTP client request payload to inspect. Snort's " .
"performance may increase by adjusting this value."); ?><br>
<?php echo gettext("Setting this value too low may cause false negatives. Values above 0 " .
- "are specified in bytes. Recommended setting is maximum (1460). Default value is <strong>300</strong>"); ?><br>
+ "are specified in bytes. Recommended setting is maximum (1460). Default value is <strong>300</strong>"); ?><br/>
</td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell"><?php echo gettext("Disable HTTP Alerts"); ?></td>
<td width="78%" class="vtable"><input name="noalert_http_inspect"
- type="checkbox" value="on"
- <?php if ($pconfig['noalert_http_inspect']=="on") echo "checked"; ?>
- onClick="enable_change(false)"> <?php echo gettext("Tick to turn off alerts from the HTTP Inspect " .
- "preprocessor. This has no effect on HTTP rules in the rule set."); ?></td>
+ type="checkbox" value="on" id="noalert_http_inspect"
+ <?php if ($pconfig['noalert_http_inspect']=="on" || empty($pconfig['noalert_http_inspect'])) echo "checked"; ?>
+ onClick="enable_change(false)"> <?php echo gettext("Turn off alerts from HTTP Inspect " .
+ "preprocessor. This has no effect on HTTP rules. Default is "); ?>
+ <strong><?php echo gettext("Checked"); ?></strong>.</td>
+ </tr>
+
+ <tr>
+ <td colspan="2" valign="top" class="listtopic"><?php echo gettext("Frag3 Settings"); ?></td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?php echo gettext("Enable"); ?></td>
+ <td width="78%" class="vtable"><input name="frag3_detection" type="checkbox" value="on" onclick="frag3_enable_change()"
+ <?php if ($pconfig['frag3_detection']=="on") echo "checked "; ?>
+ onClick="enable_change(false)">
+ <?php echo gettext("Use Frag3 Engine to detect IDS evasion attempts via target-based IP packet fragmentation. Default is ") .
+ "<strong>" . gettext("Checked") . "</strong>"; ?>.</td>
+ </tr>
+ <tr>
+ <td valign="top" class="vncell"><?php echo gettext("Memory Cap"); ?></td>
+ <td class="vtable">
+ <table cellpadding="0" cellspacing="0">
+ <tr>
+ <td><input name="frag3_memcap" type="text" class="formfld"
+ id="frag3_memcap" size="6"
+ value="<?=htmlspecialchars($pconfig['frag3_memcap']);?>">
+ <?php echo gettext("Memory cap (in bytes) for self preservation."); ?>.</td>
+ </tr>
+ </table>
+ <?php echo gettext("The maximum amount of memory allocated for Frag3 fragment reassembly. Default value is ") .
+ "<strong>" . gettext("4MB") . "</strong>"; ?>.<br/>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top" class="vncell"><?php echo gettext("Maximum Fragments"); ?></td>
+ <td class="vtable">
+ <table cellpadding="0" cellspacing="0">
+ <tr>
+ <td><input name="frag3_max_frags" type="text" class="formfld"
+ id="frag3_max_frags" size="6"
+ value="<?=htmlspecialchars($pconfig['frag3_max_frags']);?>">
+ <?php echo gettext("Maximum simultaneous fragments to track."); ?></td>
+ </tr>
+ </table>
+ <?php echo gettext("The maximum number of simultaneous fragments to track. Default value is ") .
+ "<strong>8192</strong>."; ?><br>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top" class="vncell"><?php echo gettext("Overlap Limit"); ?></td>
+ <td class="vtable">
+ <table cellpadding="0" cellspacing="0">
+ <tr>
+ <td><input name="frag3_overlap_limit" type="text" class="formfld"
+ id="frag3_overlap_limit" size="6"
+ value="<?=htmlspecialchars($pconfig['frag3_overlap_limit']);?>">
+ <?php echo gettext("Minimum is ") . "<strong>0</strong>" . gettext(" (unlimited), values greater than zero set the overlapped fragments per packet limit."); ?></td>
+ </tr>
+ </table>
+ <?php echo gettext("Sets the limit for the number of overlapping fragments allowed per packet. Default value is ") .
+ "<strong>0</strong>" . gettext(" (unlimited)."); ?><br>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top" class="vncell"><?php echo gettext("Minimum Fragment Length"); ?></td>
+ <td class="vtable">
+ <table cellpadding="0" cellspacing="0">
+ <tr>
+ <td><input name="frag3_min_frag_len" type="text" class="formfld"
+ id="frag3_min_frag_len" size="6"
+ value="<?=htmlspecialchars($pconfig['frag3_min_frag_len']);?>">
+ <?php echo gettext("Minimum is ") . "<strong>0</strong>" . gettext(" (check is disabled). Fragments smaller than or equal to this limit are considered malicious."); ?></td>
+ </tr>
+ </table>
+ <?php echo gettext("Defines smallest fragment size (payload size) that should be considered valid. Default value is ") .
+ "<strong>0</strong>" . gettext(" (check is disabled)."); ?><br>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top" class="vncell"><?php echo gettext("Timeout"); ?></td>
+ <td class="vtable">
+ <table cellpadding="0" cellspacing="0">
+ <tr>
+ <td><input name="frag3_timeout" type="text" class="formfld"
+ id="frag3_timeout" size="6"
+ value="<?=htmlspecialchars($pconfig['frag3_timeout']);?>">
+ <?php echo gettext("Timeout period in seconds for fragments in the engine."); ?></td>
+ </tr>
+ </table>
+ <?php echo gettext("Fragments in the engine for longer than this period will be automatically dropped. Default value is ") .
+ "<strong>" . gettext("60 ") . "</strong>" . gettext("seconds."); ?><br/>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?php echo gettext("Target Policy"); ?> </td>
+ <td width="78%" class="vtable">
+ <select name="frag3_policy" class="formselect" id="frag3_policy">
+ <?php
+ $profile = array( 'BSD', 'BSD-Right', 'First', 'Last', 'Linux', 'Solaris', 'Windows' );
+ foreach ($profile as $val): ?>
+ <option value="<?=strtolower($val);?>"
+ <?php if (strtolower($val) == $pconfig['frag3_policy']) echo "selected"; ?>>
+ <?=gettext($val);?></option>
+ <?php endforeach; ?>
+ </select>&nbsp;&nbsp;<?php echo gettext("Choose the IP fragmentation target policy appropriate for the protected hosts. The default is ") .
+ "<strong>" . gettext("BSD") . "</strong>"; ?>.<br/>
+ <?php echo gettext("Available OS targets are BSD, BSD-Right, First, Last, Linux, Solaris and Windows."); ?><br/></td>
+ </td>
</tr>
<tr>
<td colspan="2" valign="top" class="listtopic"><?php echo gettext("Stream5 Settings"); ?></td>
</tr>
<tr>
+ <td width="22%" valign="top" class="vncell"><?php echo gettext("Enable"); ?></td>
+ <td width="78%" class="vtable"><input name="stream5_reassembly" type="checkbox" value="on" onclick="stream5_enable_change()"
+ <?php if ($pconfig['stream5_reassembly']=="on") echo "checked "; ?>">
+ <?php echo gettext("Use Stream5 session reassembly for TCP, UDP and/or ICMP traffic. Default is ") .
+ "<strong>" . gettext("Checked") . "</strong>"; ?>.</td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?php echo gettext("Protocol Tracking"); ?></td>
+ <td width="78%" class="vtable">
+ <input name="stream5_track_tcp" type="checkbox" value="on" id="stream5_track_tcp"
+ <?php if ($pconfig['stream5_track_tcp']=="on") echo "checked"; ?>>
+ <?php echo gettext("Track and reassemble TCP sessions. Default is ") .
+ "<strong>" . gettext("Checked") . "</strong>."; ?>
+ <br/>
+ <input name="stream5_track_udp" type="checkbox" value="on" id="stream5_track_udp"
+ <?php if ($pconfig['stream5_track_udp']=="on") echo "checked"; ?>>
+ <?php echo gettext("Track and reassemble UDP sessions. Default is ") .
+ "<strong>" . gettext("Checked") . "</strong>."; ?>
+ <br/>
+ <input name="stream5_track_icmp" type="checkbox" value="on" id="stream5_track_icmp"
+ <?php if ($pconfig['stream5_track_icmp']=="on") echo "checked"; ?>>
+ <?php echo gettext("Track and reassemble ICMP sessions. Default is ") .
+ "<strong>" . gettext("Not Checked") . "</strong>."; ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?php echo gettext("Require 3-Way Handshake"); ?></td>
+ <td width="78%" class="vtable"><input name="stream5_require_3whs" type="checkbox" value="on"
+ <?php if ($pconfig['stream5_require_3whs']=="on") echo "checked "; ?>>
+ <?php echo gettext("Establish sessions only on completion of SYN/SYN-ACK/ACK handshake. Default is ") .
+ "<strong>" . gettext("Not Checked") . "</strong>"; ?>.</td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?php echo gettext("Do Not Reassemble Async"); ?></td>
+ <td width="78%" class="vtable"><input name="stream5_no_reassemble_async" type="checkbox" value="on"
+ <?php if ($pconfig['stream5_no_reassemble_async']=="on") echo "checked "; ?>>
+ <?php echo gettext("Do not queue packets for reassembly if traffic has not been seen in both directions. Default is ") .
+ "<strong>" . gettext("Not Checked") . "</strong>"; ?>.</td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?php echo gettext("Do Not Store Large TCP Packets"); ?></td>
+ <td width="78%" class="vtable">
+ <input name="stream5_dont_store_lg_pkts" type="checkbox" value="on"
+ <?php if ($pconfig['stream5_dont_store_lg_pkts']=="on") echo "checked "; ?>>
+ <?php echo gettext("Do not queue large packets in reassembly buffer to increase performance. Default is ") .
+ "<strong>" . gettext("Not Checked") . "</strong>"; ?>.<br/>
+ <?php echo "<span class=\"red\"><strong>" . gettext("Warning: ") . "</strong></span>" .
+ gettext("Enabling this option could result in missed packets. Recommended setting is not checked."); ?></td>
+ </tr>
+ <tr>
<td valign="top" class="vncell"><?php echo gettext("Max Queued Bytes"); ?></td>
<td class="vtable">
<table cellpadding="0" cellspacing="0">
@@ -292,11 +766,11 @@ include_once("head.inc");
value="<?=htmlspecialchars($pconfig['max_queued_bytes']);?>">
<?php echo gettext("Minimum is <strong>1024</strong>, Maximum is <strong>1073741824</strong> " .
"( default value is <strong>1048576</strong>, <strong>0</strong> " .
- "means Maximum )"); ?></td>
+ "means Maximum )"); ?>.</td>
</tr>
</table>
<?php echo gettext("The number of bytes to be queued for reassembly for TCP sessions in " .
- "memory. Default value is <strong>1048576</strong>"); ?><br>
+ "memory. Default value is <strong>1048576</strong>"); ?>.<br>
</td>
</tr>
<tr>
@@ -309,11 +783,11 @@ include_once("head.inc");
value="<?=htmlspecialchars($pconfig['max_queued_segs']);?>">
<?php echo gettext("Minimum is <strong>2</strong>, Maximum is <strong>1073741824</strong> " .
"( default value is <strong>2621</strong>, <strong>0</strong> means " .
- "Maximum )"); ?></td>
+ "Maximum )"); ?>.</td>
</tr>
</table>
<?php echo gettext("The number of segments to be queued for reassembly for TCP sessions " .
- "in memory. Default value is <strong>2621</strong>"); ?><br>
+ "in memory. Default value is <strong>2621</strong>"); ?>.<br>
</td>
</tr>
<tr>
@@ -325,25 +799,152 @@ include_once("head.inc");
id="stream5_mem_cap" size="6"
value="<?=htmlspecialchars($pconfig['stream5_mem_cap']);?>">
<?php echo gettext("Minimum is <strong>32768</strong>, Maximum is <strong>1073741824</strong> " .
- "( default value is <strong>8388608</strong>) "); ?></td>
+ "( default value is <strong>8388608</strong>) "); ?>.</td>
</tr>
</table>
<?php echo gettext("The memory cap in bytes for TCP packet storage " .
- "in RAM. Default value is <strong>8388608</strong> (8 MB)"); ?><br>
+ "in RAM. Default value is <strong>8388608</strong> (8 MB)"); ?>.<br>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top" class="vncell"><?php echo gettext("Overlap Limit"); ?></td>
+ <td class="vtable">
+ <table cellpadding="0" cellspacing="0">
+ <tr>
+ <td><input name="stream5_overlap_limit" type="text" class="formfld"
+ id="stream5_overlap_limit" size="6"
+ value="<?=htmlspecialchars($pconfig['stream5_overlap_limit']);?>">
+ <?php echo gettext("Minimum is ") . "<strong>0</strong>" . gettext(" (unlimited), and the maximum is ") .
+ "<strong>255</strong>."; ?></td>
+ </tr>
+ </table>
+ <?php echo gettext("Sets the limit for the number of overlapping fragments allowed per packet. Default value is ") .
+ "<strong>0</strong>" . gettext(" (unlimited)."); ?><br>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top" class="vncell"><?php echo gettext("TCP Session Timeout"); ?></td>
+ <td class="vtable">
+ <table cellpadding="0" cellspacing="0">
+ <tr>
+ <td><input name="stream5_tcp_timeout" type="text" class="formfld"
+ id="stream5_tcp_timeout" size="6"
+ value="<?=htmlspecialchars($pconfig['stream5_tcp_timeout']);?>">
+ <?php echo gettext("TCP Session timeout in seconds. Minimum is ") . "<strong>1</strong>" . gettext(" and the maximum is ") .
+ "<strong>86400</strong>" . gettext(" (approximately 1 day)"); ?>.</td>
+ </tr>
+ </table>
+ <?php echo gettext("Sets the session reassembly timeout period for TCP packets. Default value is ") .
+ "<strong>30</strong>" . gettext(" seconds."); ?><br>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top" class="vncell"><?php echo gettext("UDP Session Timeout"); ?></td>
+ <td class="vtable">
+ <table cellpadding="0" cellspacing="0">
+ <tr>
+ <td><input name="stream5_udp_timeout" type="text" class="formfld"
+ id="stream5_udp_timeout" size="6"
+ value="<?=htmlspecialchars($pconfig['stream5_udp_timeout']);?>">
+ <?php echo gettext("UDP Session timeout in seconds. Minimum is ") . "<strong>1</strong>" . gettext(" and the maximum is ") .
+ "<strong>86400</strong>" . gettext(" (approximately 1 day)"); ?>.</td>
+ </tr>
+ </table>
+ <?php echo gettext("Sets the session reassembly timeout period for UDP packets. Default value is ") .
+ "<strong>30</strong>" . gettext(" seconds."); ?><br>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top" class="vncell"><?php echo gettext("ICMP Session Timeout"); ?></td>
+ <td class="vtable">
+ <table cellpadding="0" cellspacing="0">
+ <tr>
+ <td><input name="stream5_icmp_timeout" type="text" class="formfld"
+ id="stream5_icmp_timeout" size="6"
+ value="<?=htmlspecialchars($pconfig['stream5_icmp_timeout']);?>">
+ <?php echo gettext("ICMP Session timeout in seconds. Minimum is ") . "<strong>1</strong>" . gettext(" and the maximum is ") .
+ "<strong>86400</strong>" . gettext(" (approximately 1 day)"); ?>.</td>
+ </tr>
+ </table>
+ <?php echo gettext("Sets the session reassembly timeout period for ICMP packets. Default value is ") .
+ "<strong>30</strong>" . gettext(" seconds."); ?><br>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?php echo gettext("IP Target Policy"); ?> </td>
+ <td width="78%" class="vtable">
+ <select name="stream5_policy" class="formselect" id="stream5_policy">
+ <?php
+ $profile = array( 'BSD', 'First', 'HPUX', 'HPUX10', 'Irix', 'Last', 'Linux', 'MacOS', 'Old-Linux',
+ 'Solaris', 'Vista', 'Windows', 'Win2003' );
+ foreach ($profile as $val): ?>
+ <option value="<?=strtolower($val);?>"
+ <?php if (strtolower($val) == $pconfig['stream5_policy']) echo "selected"; ?>>
+ <?=gettext($val);?></option>
+ <?php endforeach; ?>
+ </select>&nbsp;&nbsp;<?php echo gettext("Choose the TCP reassembly target policy appropriate for the protected hosts. The default is ") .
+ "<strong>" . gettext("BSD") . "</strong>"; ?>.<br/>
+ <?php echo gettext("Available OS targets are BSD, First, HPUX, HPUX10, Irix, Last, Linux, MacOS, Old Linux, Solaris, Vista, Windows, and Win2003 Server."); ?><br/></td>
</td>
</tr>
-
<tr>
<td colspan="2" valign="top" class="listtopic"><?php echo gettext("Portscan Settings"); ?></td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell"><?php echo gettext("Enable"); ?> <br>
<?php echo gettext("Portscan Detection"); ?></td>
- <td width="78%" class="vtable"><input name="sf_portscan"
- type="checkbox" value="on"
- <?php if ($pconfig['sf_portscan']=="on") echo "checked"; ?>
- onClick="enable_change(false)"><br>
- <?php echo gettext("Detects various types of portscans and portsweeps."); ?></td>
+ <td width="78%" class="vtable"><input name="sf_portscan" onclick="sf_portscan_enable_change()"
+ type="checkbox" value="on" id="sf_portscan"
+ <?php if ($pconfig['sf_portscan']=="on") echo "checked"; ?>>
+ <?php echo gettext("Use Portscan Detection to detect various types of port scans and sweeps. Default is ") .
+ "<strong>" . gettext("Not Checked") . "</strong>"; ?>.</td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?php echo gettext("Protocol"); ?> </td>
+ <td width="78%" class="vtable">
+ <select name="pscan_protocol" class="formselect" id="pscan_protocol">
+ <?php
+ $protos = array('all', 'tcp', 'udp', 'icmp', 'ip');
+ foreach ($protos as $val): ?>
+ <option value="<?=$val;?>"
+ <?php if ($val == $pconfig['pscan_protocol']) echo "selected"; ?>>
+ <?=gettext($val);?></option>
+ <?php endforeach; ?>
+ </select>&nbsp;&nbsp;<?php echo gettext("Choose the Portscan protocol type to alert for (all, tcp, udp, icmp or ip). Default is ") .
+ "<strong>" . gettext("all") . "</strong>."; ?><br/>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?php echo gettext("Scan Type"); ?> </td>
+ <td width="78%" class="vtable">
+ <select name="pscan_type" class="formselect" id="pscan_type">
+ <?php
+ $protos = array('all', 'portscan', 'portsweep', 'decoy_portscan', 'distributed_portscan');
+ foreach ($protos as $val): ?>
+ <option value="<?=$val;?>"
+ <?php if ($val == $pconfig['pscan_type']) echo "selected"; ?>>
+ <?=gettext($val);?></option>
+ <?php endforeach; ?>
+ </select>&nbsp;&nbsp;<?php echo gettext("Choose the Portscan scan type to alert for. Default is ") .
+ "<strong>" . gettext("all") . "</strong>."; ?><br/>
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td><?php echo gettext("PORTSCAN: one->one scan; one host scans multiple ports on another host."); ?></td>
+ </tr>
+ <tr>
+ <td><?php echo gettext("PORTSWEEP: one->many scan; one host scans a single port on multiple hosts."); ?></td>
+ </tr>
+ <tr>
+ <td><?php echo gettext("DECOY_PORTSCAN: one->one scan; attacker has spoofed source address inter-mixed with real scanning address."); ?></td>
+ </tr>
+ <tr>
+ <td><?php echo gettext("DISTRIBUTED_PORTSCAN: many->one scan; multiple hosts query one host for open services."); ?></td>
+ </tr>
+ <tr>
+ <td><?php echo gettext("ALL: alerts for all of the above scan types."); ?></td>
+ </tr>
+ </table>
+ </td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell"><?php echo gettext("Sensitivity"); ?> </td>
@@ -356,22 +957,51 @@ include_once("head.inc");
<?php if ($val == $pconfig['pscan_sense_level']) echo "selected"; ?>>
<?=gettext(ucfirst($val));?></option>
<?php endforeach; ?>
- </select><br>
- <?php echo gettext("LOW: alerts generated on error packets from the target host; "); ?>
- <?php echo gettext("this setting should see few false positives. "); ?><br>
- <?php echo gettext("MEDIUM: tracks connection counts, so will generate filtered alerts; may "); ?>
- <?php echo gettext("false positive on active hosts."); ?><br>
- <?php echo gettext("HIGH: tracks hosts using a time window; will catch some slow scans, but is "); ?>
- <?php echo gettext("very sensitive to active hosts."); ?><br/>
+ </select>&nbsp;&nbsp;<?php echo gettext("Choose the Portscan sensitivity level (Low, Medium, High). Default is ") .
+ "<strong>" . gettext("Medium") . "</strong>."; ?><br/>
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td><?php echo gettext("LOW: alerts generated on error packets from the target host; "); ?>
+ <?php echo gettext("this setting should see few false positives. "); ?></td>
+ </tr>
+ <tr>
+ <td><?php echo gettext("MEDIUM: tracks connection counts, so will generate filtered alerts; may "); ?>
+ <?php echo gettext("false positive on active hosts."); ?></td>
+ </tr>
+ <tr>
+ <td><?php echo gettext("HIGH: tracks hosts using a time window; will catch some slow scans, but is "); ?>
+ <?php echo gettext("very sensitive to active hosts."); ?></td>
+ </tr>
+ </table>
</td>
</tr>
- <td width="22%" valign="top" class="vncell"><?php echo gettext("Ignore Scanners"); ?> </td>
+ <tr>
+ <td valign="top" class="vncell"><?php echo gettext("Memory Cap"); ?></td>
+ <td class="vtable">
+ <table cellpadding="0" cellspacing="0">
+ <tr>
+ <td><input name="pscan_memcap" type="text" class="formfld"
+ id="pscan_memcap" size="6"
+ value="<?=htmlspecialchars($pconfig['pscan_memcap']);?>">
+ <?php echo gettext("Maximum memory in bytes to allocate for portscan detection. ") .
+ gettext("Default is ") . "<strong>" . gettext("10000000") . "</strong>" .
+ gettext(" (10 MB)"); ?>.</td>
+ </tr>
+ </table>
+ <?php echo gettext("The maximum number of bytes to allocate for portscan detection. The higher this number, ") .
+ gettext("the more nodes that can be tracked. Default is ") .
+ "<strong>10,000,000</strong>" . gettext(" bytes. (10 MB)"); ?><br>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?php echo gettext("Ignore Scanners"); ?></td>
<td width="78%" class="vtable">
<input name="pscan_ignore_scanners" type="text" size="40" autocomplete="off" class="formfldalias" id="pscan_ignore_scanners"
- value="<?=$pconfig['pscan_ignore_scanners'];?>"> <br><?php echo gettext("Ignores the specified entity as a source of scan alerts. Entity must be a defined alias.");?><br>
- <?php echo gettext("Default value: \$HOME_NET."); ?><?php echo gettext(" Leave " .
- "blank for default value."); ?>
+ value="<?=$pconfig['pscan_ignore_scanners'];?>">&nbsp;&nbsp;<?php echo gettext("Leave blank for default. ") .
+ gettext("Default value is ") . "<strong>" . gettext("\$HOME_NET") . "</strong>"; ?>.<br/>
+ <?php echo gettext("Ignores the specified entity as a source of scan alerts. Entity must be a defined alias."); ?><br/>
</td>
+ </tr>
<tr>
<td colspan="2" valign="top" class="listtopic"><?php echo gettext("General Preprocessor Settings"); ?></td>
</tr>
@@ -380,71 +1010,70 @@ include_once("head.inc");
<?php echo gettext("RPC Decode and Back Orifice detector"); ?></td>
<td width="78%" class="vtable"><input name="other_preprocs"
type="checkbox" value="on"
- <?php if ($pconfig['other_preprocs']=="on") echo "checked"; ?>
- onClick="enable_change(false)"><br>
- <?php echo gettext("Normalize/Decode RPC traffic and detects Back Orifice traffic on the network."); ?></td>
+ <?php if ($pconfig['other_preprocs']=="on") echo "checked"; ?>>
+ <?php echo gettext("Normalize/Decode RPC traffic and detects Back Orifice traffic on the network. Default is ") .
+ "<strong>" . gettext("Checked") . "</strong>"; ?>.</td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell"><?php echo gettext("Enable"); ?> <br>
<?php echo gettext("FTP and Telnet Normalizer"); ?></td>
<td width="78%" class="vtable"><input name="ftp_preprocessor"
type="checkbox" value="on"
- <?php if ($pconfig['ftp_preprocessor']=="on") echo "checked"; ?>
- onClick="enable_change(false)"><br>
- <?php echo gettext("Normalize/Decode FTP and Telnet traffic and protocol anomalies."); ?></td>
+ <?php if ($pconfig['ftp_preprocessor']=="on") echo "checked"; ?>>
+ <?php echo gettext("Normalize/Decode FTP and Telnet traffic and protocol anomalies. Default is ") .
+ "<strong>" . gettext("Checked") . "</strong>"; ?>.</td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell"><?php echo gettext("Enable"); ?> <br>
<?php echo gettext("POP Normalizer"); ?></td>
<td width="78%" class="vtable"><input name="pop_preproc"
type="checkbox" value="on"
- <?php if ($pconfig['pop_preproc']=="on") echo "checked"; ?>
- onClick="enable_change(false)"><br>
- <?php echo gettext("Normalize/Decode POP protocol for enforcement and buffer overflows."); ?></td>
+ <?php if ($pconfig['pop_preproc']=="on") echo "checked"; ?>>
+ <?php echo gettext("Normalize/Decode POP protocol for enforcement and buffer overflows. Default is ") .
+ "<strong>" . gettext("Checked") . "</strong>"; ?>.</td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell"><?php echo gettext("Enable"); ?> <br>
<?php echo gettext("IMAP Normalizer"); ?></td>
<td width="78%" class="vtable"><input name="imap_preproc"
type="checkbox" value="on"
- <?php if ($pconfig['imap_preproc']=="on") echo "checked"; ?>
- onClick="enable_change(false)"><br>
- <?php echo gettext("Normalize/Decode IMAP protocol for enforcement and buffer overflows."); ?></td>
+ <?php if ($pconfig['imap_preproc']=="on") echo "checked"; ?>>
+ <?php echo gettext("Normalize/Decode IMAP protocol for enforcement and buffer overflows. Default is ") .
+ "<strong>" . gettext("Checked") . "</strong>"; ?>.</td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell"><?php echo gettext("Enable"); ?> <br>
<?php echo gettext("SMTP Normalizer"); ?></td>
<td width="78%" class="vtable"><input name="smtp_preprocessor"
type="checkbox" value="on"
- <?php if ($pconfig['smtp_preprocessor']=="on") echo "checked"; ?>
- onClick="enable_change(false)"><br>
- <?php echo gettext("Normalize/Decode SMTP protocol for enforcement and buffer overflows."); ?></td>
+ <?php if ($pconfig['smtp_preprocessor']=="on") echo "checked"; ?>>
+ <?php echo gettext("Normalize/Decode SMTP protocol for enforcement and buffer overflows. Default is ") .
+ "<strong>" . gettext("Checked") . "</strong>"; ?>.</td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell"><?php echo gettext("Enable"); ?> <br>
<?php echo gettext("DCE/RPC2 Detection"); ?></td>
<td width="78%" class="vtable"><input name="dce_rpc_2"
type="checkbox" value="on"
- <?php if ($pconfig['dce_rpc_2']=="on") echo "checked"; ?>
- onClick="enable_change(false)"><br>
- <?php echo gettext("The DCE/RPC preprocessor detects and decodes SMB and DCE/RPC traffic."); ?></td>
+ <?php if ($pconfig['dce_rpc_2']=="on") echo "checked"; ?>>
+ <?php echo gettext("The DCE/RPC preprocessor detects and decodes SMB and DCE/RPC traffic. Default is ") .
+ "<strong>" . gettext("Checked") . "</strong>"; ?>.</td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell"><?php echo gettext("Enable"); ?> <br>
<?php echo gettext("SIP Detection"); ?></td>
<td width="78%" class="vtable"><input name="sip_preproc"
type="checkbox" value="on"
- <?php if ($pconfig['sip_preproc']=="on") echo "checked"; ?>
- onClick="enable_change(false)"><br>
- <?php echo gettext("The SIP preprocessor decodes SIP traffic and detects some vulnerabilities."); ?></td>
+ <?php if ($pconfig['sip_preproc']=="on") echo "checked"; ?>>
+ <?php echo gettext("The SIP preprocessor decodes SIP traffic and detects some vulnerabilities. Default is ") .
+ "<strong>" . gettext("Checked") . "</strong>"; ?>.</td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell"><?php echo gettext("Enable"); ?> <br>
<?php echo gettext("GTP Detection"); ?></td>
<td width="78%" class="vtable"><input name="gtp_preproc"
type="checkbox" value="on"
- <?php if ($pconfig['gtp_preproc']=="on") echo "checked"; ?>
- onClick="enable_change(false)"><br>
+ <?php if ($pconfig['gtp_preproc']=="on") echo "checked"; ?>>
<?php echo gettext("The GTP preprocessor decodes GPRS Tunneling Protocol traffic and detects intrusion attempts."); ?></td>
</tr>
<tr>
@@ -452,26 +1081,30 @@ include_once("head.inc");
<?php echo gettext("DNS Detection"); ?></td>
<td width="78%" class="vtable"><input name="dns_preprocessor"
type="checkbox" value="on"
- <?php if ($pconfig['dns_preprocessor']=="on") echo "checked"; ?>
- onClick="enable_change(false)"><br>
- <?php echo gettext("The DNS preprocessor decodes DNS Response traffic and detects some vulnerabilities."); ?></td>
+ <?php if ($pconfig['dns_preprocessor']=="on") echo "checked"; ?>>
+ <?php echo gettext("The DNS preprocessor decodes DNS Response traffic and detects vulnerabilities. Default is ") .
+ "<strong>" . gettext("Checked") . "</strong>"; ?>.</td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell"><?php echo gettext("Enable"); ?> <br> <?php echo gettext("SSL Data"); ?></td>
<td width="78%" class="vtable">
<input name="ssl_preproc" type="checkbox" value="on"
- <?php if ($pconfig['ssl_preproc']=="on") echo "checked"; ?>
- onClick="enable_change(false)"><br>
- <?php echo gettext("SSL data searches for irregularities during SSL protocol exchange"); ?>
- </td>
+ <?php if ($pconfig['ssl_preproc']=="on") echo "checked"; ?>>
+ <?php echo gettext("SSL data searches for irregularities during SSL protocol exchange. Default is ") .
+ "<strong>" . gettext("Checked") . "</strong>"; ?>.</td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell"><?php echo gettext("Enable"); ?> <br> <?php echo gettext("Sensitive Data"); ?></td>
<td width="78%" class="vtable">
<input name="sensitive_data" type="checkbox" value="on"
- <?php if ($pconfig['sensitive_data']=="on") echo "checked"; ?>
- onClick="enable_change(false)"><br>
- <?php echo gettext("Sensitive data searches for credit card or Social Security numbers in data"); ?>
+ <?php if ($pconfig['sensitive_data'] == "on")
+ echo "checked";
+ elseif ($vrt_enabled == "off")
+ echo "disabled";
+ ?>>
+ <?php echo gettext("Sensitive data searches for credit card or Social Security numbers and e-mail addresses in data."); ?>
+ <br/>
+ <span class="red"><strong><?php echo gettext("Note: "); ?></strong></span><?php echo gettext("To enable this preprocessor, you must select the Snort VRT rules on the Global Settings tab."); ?>
</td>
</tr>
<tr>
@@ -481,35 +1114,39 @@ include_once("head.inc");
<td width="22%" valign="top" class="vncell"><?php echo gettext("Enable"); ?> <br> <?php echo gettext("Modbus Detection"); ?></td>
<td width="78%" class="vtable">
<input name="modbus_preproc" type="checkbox" value="on"
- <?php if ($pconfig['modbus_preproc']=="on") echo "checked"; ?>
- onClick="enable_change(false)"><br>
- <?php echo gettext("Modbus is a protocol used in SCADA networks. The default port is TCP 502. If your network does " .
- "not contain Modbus-enabled devices, you should leave this preprocessor disabled."); ?>
+ <?php if ($pconfig['modbus_preproc']=="on") echo "checked"; ?>>
+ <?php echo gettext("Modbus is a protocol used in SCADA networks. The default port is TCP 502.") . "<br/>" .
+ gettext("If your network does not contain Modbus-enabled devices, you should leave this preprocessor disabled."); ?>
</td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell"><?php echo gettext("Enable"); ?> <br> <?php echo gettext("DNP3 Detection"); ?></td>
<td width="78%" class="vtable">
<input name="dnp3_preproc" type="checkbox" value="on"
- <?php if ($pconfig['dnp3_preproc']=="on") echo "checked"; ?>
- onClick="enable_change(false)"><br>
- <?php echo gettext("DNP3 is a protocol used in SCADA networks. The default port is TCP 20000. If your network does " .
- "not contain DNP3-enabled devices, you should leave this preprocessor disabled."); ?>
+ <?php if ($pconfig['dnp3_preproc']=="on") echo "checked"; ?>>
+ <?php echo gettext("DNP3 is a protocol used in SCADA networks. The default port is TCP 20000.") . "<br/>" .
+ gettext("If your network does not contain DNP3-enabled devices, you should leave this preprocessor disabled."); ?>
</td>
</tr>
<tr>
<td width="22%" valign="top">&nbsp;</td>
<td width="78%">
- <input name="Submit" type="submit" class="formbtn" value="Save">
- <input name="id" type="hidden" value="<?=$id;?>"></td>
+ <input name="Submit" type="submit" class="formbtn" value="Save" title="<?php echo
+ gettext("Save preprocessor settings"); ?>"/>
+ <input name="id" type="hidden" value="<?=$id;?>">&nbsp;&nbsp;&nbsp;&nbsp;
+ <input name="ResetAll" type="submit" class="formbtn" value="Reset" title="<?php echo
+ gettext("Reset all settings to defaults") . "\" onclick=\"return confirm('" .
+ gettext("WARNING: This will reset ALL preprocessor settings to their defaults. Click OK to continue or CANCEL to quit.") .
+ "')\""; ?>/></td>
</tr>
<tr>
<td width="22%" valign="top">&nbsp;</td>
- <td width="78%"><span class="vexpl"><span class="red"><strong><?php echo gettext("Note:"); ?></strong></span>
- <br>
- <?php echo gettext("Please save your settings before you click Start."); ?> </td>
+ <td width="78%"><span class="vexpl"><span class="red"><strong><?php echo gettext("Note: "); ?></strong></span>
+ <?php echo gettext("Please save your settings before you exit. Preprocessor changes will rebuild the rules file. This "); ?>
+ <?php echo gettext("may take several seconds. Snort must also be restarted to activate any changes made on this screen."); ?></td>
</tr>
</table>
+</div>
</td></tr></table>
</form>
<script type="text/javascript">
@@ -545,6 +1182,119 @@ function createAutoSuggest() {
setTimeout("createAutoSuggest();", 500);
+function frag3_enable_change() {
+ if (!document.iform.frag3_detection.checked) {
+ var msg = "WARNING: Disabling the Frag3 preprocessor is not recommended!\n\n";
+ msg = msg + "Snort may fail to start because of other dependent preprocessors or ";
+ msg = msg + "rule options. Are you sure you want to disable it?\n\n";
+ msg = msg + "Click OK to disable Frag3, or CANCEL to quit.";
+ if (!confirm(msg)) {
+ document.iform.frag3_detection.checked=true;
+ }
+ }
+ var endis = !(document.iform.frag3_detection.checked);
+ document.iform.frag3_overlap_limit.disabled=endis;
+ document.iform.frag3_min_frag_len.disabled=endis;
+ document.iform.frag3_policy.disabled=endis;
+ document.iform.frag3_max_frags.disabled=endis;
+ document.iform.frag3_memcap.disabled=endis;
+ document.iform.frag3_timeout.disabled=endis;
+}
+
+function http_inspect_enable_change() {
+ var endis = !(document.iform.http_inspect.checked);
+ document.iform.http_inspect_enable_xff.disabled=endis;
+ document.iform.server_flow_depth.disabled=endis;
+ document.iform.client_flow_depth.disabled=endis;
+ document.iform.http_server_profile.disabled=endis;
+ document.iform.http_inspect_memcap.disabled=endis;
+ document.iform.http_inspect_log_uri.disabled=endis;
+ document.iform.http_inspect_log_hostname.disabled=endis;
+}
+
+function sf_portscan_enable_change() {
+ var endis = !(document.iform.sf_portscan.checked);
+ document.iform.pscan_protocol.disabled=endis;
+ document.iform.pscan_type.disabled=endis;
+ document.iform.pscan_memcap.disabled=endis;
+ document.iform.pscan_sense_level.disabled=endis;
+ document.iform.pscan_ignore_scanners.disabled=endis;
+}
+
+function stream5_enable_change() {
+ if (!document.iform.stream5_reassembly.checked) {
+ var msg = "WARNING: Stream5 is a critical preprocessor, and disabling it is not recommended! ";
+ msg = msg + "The following preprocessors require Stream5 and will be automatically disabled if currently enabled:\n\n";
+ msg = msg + " SMTP\t\tPOP\t\tSIP\n";
+ msg = msg + " SENSITIVE_DATA\tSF_PORTSCAN\tDCE/RPC 2\n";
+ msg = msg + " IMAP\t\tDNS\t\tSSL\n";
+ msg = msg + " GTP\t\tDNP3\t\tMODBUS\n\n";
+ msg = msg + "Snort may fail to start because of other preprocessors or rule options dependent on Stream5. ";
+ msg = msg + "Are you sure you want to disable it?\n\n";
+ msg = msg + "Click OK to disable Stream5, or CANCEL to quit.";
+ if (!confirm(msg)) {
+ document.iform.stream5_reassembly.checked=true;
+ }
+ else {
+ alert("If Snort fails to start with Stream5 disabled, examine the system log for clues.");
+ document.iform.smtp_preprocessor.checked=false;
+ document.iform.dce_rpc_2.checked=false;
+ document.iform.sip_preproc.checked=false;
+ document.iform.sensitive_data.checked=false;
+ document.iform.imap_preproc.checked=false;
+ document.iform.pop_preproc.checked=false;
+ document.iform.ssl_preproc.checked=false;
+ document.iform.dns_preprocessor.checked=false;
+ document.iform.modbus_preproc.checked=false;
+ document.iform.dnp3_preproc.checked=false;
+ document.iform.sf_portscan.checked=false;
+ sf_portscan_enable_change();
+ }
+ }
+
+ var endis = !(document.iform.stream5_reassembly.checked);
+ document.iform.max_queued_bytes.disabled=endis;
+ document.iform.max_queued_segs.disabled=endis;
+ document.iform.stream5_mem_cap.disabled=endis;
+ document.iform.stream5_policy.disabled=endis;
+ document.iform.stream5_overlap_limit.disabled=endis;
+ document.iform.stream5_no_reassemble_async.disabled=endis;
+ document.iform.stream5_dont_store_lg_pkts.disabled=endis;
+ document.iform.stream5_tcp_timeout.disabled=endis;
+ document.iform.stream5_udp_timeout.disabled=endis;
+ document.iform.stream5_icmp_timeout.disabled=endis;
+}
+
+function enable_change_all() {
+ http_inspect_enable_change();
+ sf_portscan_enable_change();
+
+ // Enable/Disable Frag3 settings
+ var endis = !(document.iform.frag3_detection.checked);
+ document.iform.frag3_overlap_limit.disabled=endis;
+ document.iform.frag3_min_frag_len.disabled=endis;
+ document.iform.frag3_policy.disabled=endis;
+ document.iform.frag3_max_frags.disabled=endis;
+ document.iform.frag3_memcap.disabled=endis;
+ document.iform.frag3_timeout.disabled=endis;
+
+ // Enable/Disable Stream5 settings
+ endis = !(document.iform.stream5_reassembly.checked);
+ document.iform.max_queued_bytes.disabled=endis;
+ document.iform.max_queued_segs.disabled=endis;
+ document.iform.stream5_mem_cap.disabled=endis;
+ document.iform.stream5_policy.disabled=endis;
+ document.iform.stream5_overlap_limit.disabled=endis;
+ document.iform.stream5_no_reassemble_async.disabled=endis;
+ document.iform.stream5_dont_store_lg_pkts.disabled=endis;
+ document.iform.stream5_tcp_timeout.disabled=endis;
+ document.iform.stream5_udp_timeout.disabled=endis;
+ document.iform.stream5_icmp_timeout.disabled=endis;
+}
+
+// Set initial state of form controls
+enable_change_all();
+
</script>
<?php include("fend.inc"); ?>
</body>
diff --git a/config/snort/snort_rules.php b/config/snort/snort_rules.php
index 7457632d..ca63dae9 100755
--- a/config/snort/snort_rules.php
+++ b/config/snort/snort_rules.php
@@ -33,7 +33,7 @@
require_once("guiconfig.inc");
require_once("/usr/local/pkg/snort/snort.inc");
-global $g, $flowbit_rules_file;
+global $g, $flowbit_rules_file, $rebuild_rules;
$snortdir = SNORTDIR;
$rules_map = array();
@@ -67,10 +67,42 @@ function truncate($string, $length) {
* truncation was necessary. *
********************************/
if (strlen($string) > $length)
- $string = substr($string, 0, ($length - 3)) . "...";
+ $string = substr($string, 0, ($length - 2)) . "...";
return $string;
}
+function add_title_attribute($tag, $title) {
+
+ /********************************
+ * This function adds a "title" *
+ * attribute to the passed tag *
+ * and sets the value to the *
+ * value specified by "$title". *
+ ********************************/
+ $result = "";
+ if (empty($tag)) {
+ // If passed an empty element tag, then
+ // just create a <span> tag with title
+ $result = "<span title=\"" . $title . "\">";
+ }
+ else {
+ // Find the ending ">" for the element tag
+ $pos = strpos($tag, ">");
+ if ($pos !== false) {
+ // We found the ">" delimter, so add "title"
+ // attribute and close the element tag
+ $result = substr($tag, 0, $pos) . " title=\"" . $title . "\">";
+ }
+ else {
+ // We did not find the ">" delimiter, so
+ // something is wrong, just return the
+ // tag "as-is"
+ $result = $tag;
+ }
+ }
+ return $result;
+}
+
/* convert fake interfaces to real */
$if_real = snort_get_real_interface($pconfig['interface']);
$snort_uuid = $a_rule[$id]['uuid'];
@@ -92,6 +124,11 @@ if (empty($categories[0]) && ($currentruleset != "custom.rules")) {
$currentruleset = "custom.rules";
}
+/* One last sanity check -- if the rules directory is empty, default to loading custom rules */
+$tmp = glob("{$snortdir}/rules/*.rules");
+if (empty($tmp))
+ $currentruleset = "custom.rules";
+
$ruledir = "{$snortdir}/rules";
$rulefile = "{$ruledir}/{$currentruleset}";
if ($currentruleset != 'custom.rules') {
@@ -100,7 +137,7 @@ if ($currentruleset != 'custom.rules') {
if (substr($currentruleset, 0, 10) == "IPS Policy")
$rules_map = snort_load_vrt_policy($a_rule[$id]['ips_policy']);
elseif (!file_exists($rulefile))
- $input_errors[] = "{$currentruleset} seems to be missing!!! Please go to the Category tab and save the rule set again to regenerate it.";
+ $input_errors[] = gettext("{$currentruleset} seems to be missing!!! Please verify rules files have been downloaded, then go to the Categories tab and save the rule set again.");
else
$rules_map = snort_load_rules_map($rulefile);
}
@@ -155,6 +192,7 @@ if ($_GET['act'] == "toggle" && $_GET['ids'] && !empty($rules_map)) {
/* Update the config.xml file. */
write_config();
+ $_GET['openruleset'] = $currentruleset;
header("Location: /snort/snort_rules.php?id={$id}&openruleset={$currentruleset}");
exit;
}
@@ -190,6 +228,7 @@ if ($_GET['act'] == "resetcategory" && !empty($rules_map)) {
unset($a_rule[$id]['rule_sid_off']);
write_config();
+ $_GET['openruleset'] = $currentruleset;
header("Location: /snort/snort_rules.php?id={$id}&openruleset={$currentruleset}");
exit;
}
@@ -203,6 +242,17 @@ if ($_GET['act'] == "resetall" && !empty($rules_map)) {
/* Update the config.xml file. */
write_config();
+ $_GET['openruleset'] = $currentruleset;
+ header("Location: /snort/snort_rules.php?id={$id}&openruleset={$currentruleset}");
+ exit;
+}
+
+if ($_POST['clear']) {
+ unset($a_rule[$id]['customrules']);
+ write_config();
+ $rebuild_rules = "on";
+ snort_generate_conf($a_rule[$id]);
+ $rebuild_rules = "off";
header("Location: /snort/snort_rules.php?id={$id}&openruleset={$currentruleset}");
exit;
}
@@ -210,7 +260,9 @@ if ($_GET['act'] == "resetall" && !empty($rules_map)) {
if ($_POST['customrules']) {
$a_rule[$id]['customrules'] = base64_encode($_POST['customrules']);
write_config();
- sync_snort_package_config();
+ $rebuild_rules = "on";
+ snort_generate_conf($a_rule[$id]);
+ $rebuild_rules = "off";
$output = "";
$retcode = "";
exec("snort -c {$snortdir}/snort_{$snort_uuid}_{$if_real}/snort.conf -T 2>&1", $output, $retcode);
@@ -221,11 +273,31 @@ if ($_POST['customrules']) {
for($i = $start; $i > $end; $i--)
$error .= $output[$i];
$input_errors[] = "Custom rules have errors:\n {$error}";
- } else {
+ }
+ else {
header("Location: /snort/snort_rules.php?id={$id}&openruleset={$currentruleset}");
exit;
}
-} else if ($_POST) {
+}
+
+else if ($_POST['apply']) {
+
+ /* Save new configuration */
+ write_config();
+
+ /*************************************************/
+ /* Update the snort conf file and rebuild the */
+ /* rules for this interface. */
+ /*************************************************/
+ $rebuild_rules = "on";
+ snort_generate_conf($a_rule[$id]);
+ $rebuild_rules = "off";
+
+ /* Return to this same page */
+ header("Location: /snort/snort_rules.php?id={$id}&openruleset={$currentruleset}");
+ exit;
+}
+else if($_POST) {
unset($a_rule[$id]['customrules']);
write_config();
header("Location: /snort/snort_rules.php?id={$id}&openruleset={$currentruleset}");
@@ -255,6 +327,281 @@ if ($savemsg) {
?>
+<form action="/snort/snort_rules.php" method="post" name="iform" id="iform">
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr><td>
+ <?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Snort Interfaces"), true, "/snort/snort_interfaces.php");
+ $tab_array[1] = array(gettext("Global Settings"), false, "/snort/snort_interfaces_global.php");
+ $tab_array[2] = array(gettext("Updates"), false, "/snort/snort_download_updates.php");
+ $tab_array[3] = array(gettext("Alerts"), false, "/snort/snort_alerts.php");
+ $tab_array[4] = array(gettext("Blocked"), false, "/snort/snort_blocked.php");
+ $tab_array[5] = array(gettext("Whitelists"), false, "/snort/snort_interfaces_whitelist.php");
+ $tab_array[6] = array(gettext("Suppress"), false, "/snort/snort_interfaces_suppress.php");
+ $tab_array[7] = array(gettext("Sync"), false, "/pkg_edit.php?xml=snort/snort_sync.xml");
+ display_top_tabs($tab_array);
+ echo '</td></tr>';
+ echo '<tr><td class="tabnavtbl">';
+ $menu_iface=($if_friendly?substr($if_friendly,0,5)." ":"Iface ");;
+ $tab_array = array();
+ $tab_array[] = array($menu_iface . gettext("Settings"), false, "/snort/snort_interfaces_edit.php?id={$id}");
+ $tab_array[] = array($menu_iface . gettext("Categories"), false, "/snort/snort_rulesets.php?id={$id}");
+ $tab_array[] = array($menu_iface . gettext("Rules"), true, "/snort/snort_rules.php?id={$id}");
+ $tab_array[] = array($menu_iface . gettext("Variables"), false, "/snort/snort_define_servers.php?id={$id}");
+ $tab_array[] = array($menu_iface . gettext("Preprocessors"), false, "/snort/snort_preprocessors.php?id={$id}");
+ $tab_array[] = array($menu_iface . gettext("Barnyard2"), false, "/snort/snort_barnyard.php?id={$id}");
+ display_top_tabs($tab_array);
+ ?>
+ </td></tr>
+ <tr><td><div id="mainarea">
+ <table id="maintable" class="tabcont" width="100%" border="0" cellpadding="4" cellspacing="0">
+ <tr>
+ <td class="listtopic"><?php echo gettext("Available Rule Categories"); ?></td>
+ </tr>
+
+ <tr>
+ <td class="vncell" height="30px"><strong><?php echo gettext("Category:"); ?></strong>&nbsp;&nbsp;<select id="selectbox" name="selectbox" class="formselect" onChange="go()">
+ <option value='?id=<?=$id;?>&openruleset=custom.rules'>custom.rules</option>
+ <?php
+ $files = explode("||", $pconfig['rulesets']);
+ if ($a_rule[$id]['ips_policy_enable'] == 'on')
+ $files[] = "IPS Policy - " . ucfirst($a_rule[$id]['ips_policy']);
+ natcasesort($files);
+ foreach ($files as $value) {
+ if ($snortdownload != 'on' && substr($value, 0, 6) == "snort_")
+ continue;
+ if ($emergingdownload != 'on' && substr($value, 0, 8) == "emerging")
+ continue;
+ if (empty($value))
+ continue;
+ echo "<option value='?id={$id}&openruleset={$value}' ";
+ if ($value == $currentruleset)
+ echo "selected";
+ echo ">{$value}</option>\n";
+ }
+ ?>
+ </select>&nbsp;&nbsp;&nbsp;<?php echo gettext("Select the rule category to view"); ?>
+ </td>
+ </tr>
+
+ <?php if ($currentruleset == 'custom.rules'): ?>
+ <tr>
+ <td class="listtopic"><?php echo gettext("Defined Custom Rules"); ?></td>
+ </tr>
+ <tr>
+ <td valign="top" class="vtable">
+ <input type='hidden' name='openruleset' value='custom.rules'>
+ <input type='hidden' name='id' value='<?=$id;?>'>
+ <textarea wrap="soft" cols="90" rows="40" name="customrules"><?=$pconfig['customrules'];?></textarea>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <input name="Submit" type="submit" class="formbtn" value="<?php echo gettext(" Save "); ?>" title=" <?php echo gettext("Save custom rules"); ?>"/>&nbsp;&nbsp;
+ <input type="button" class="formbtn" value=" <?php echo gettext("Cancel"); ?>" onclick="history.back()" title="<?php echo gettext("Cancel changes and return to last page"); ?>"/>&nbsp;&nbsp;
+ <input name="clear" type="submit" class="formbtn" id="clear" value="<?php echo gettext("Clear"); ?>" onclick="return confirm('<?php echo gettext("This will erase all custom rules for the interface. Are you sure?"); ?>')" title="<?php echo gettext("Deletes all custom rules"); ?>"/>
+ </td>
+ </tr>
+ <?php else: ?>
+ <tr>
+ <td class="listtopic"><?php echo gettext("Rule Signature ID (SID) Enable/Disable Overrides"); ?></td>
+ </tr>
+ <tr>
+ <td class="vncell">
+ <table width="100%" align="center" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td width="50%" valign="middle" rowspan="2"><input type="submit" name="apply" id="apply" value="<?php echo gettext("Apply"); ?>" class="formbtn"
+ title="<?php echo gettext("Click to rebuild the rules with your changes"); ?>"/>
+ <input type='hidden' name='id' value='<?=$id;?>'/>
+ <input type='hidden' name='openruleset' value='<?=$currentruleset;?>'/></td>
+ <td class="vexpl" valign="middle"><?php echo "<a href='?id={$id}&openruleset={$currentruleset}&act=resetcategory'>
+ <img src=\"../themes/{$g['theme']}/images/icons/icon_x.gif\" width=\"15\" height=\"15\"
+ onmouseout='this.src=\"../themes/{$g['theme']}/images/icons/icon_x.gif\"'
+ onmouseover='this.src=\"../themes/{$g['theme']}/images/icons/icon_x_mo.gif\"' border='0'
+ title='" . gettext("Click to remove enable/disable changes for rules in the selected category only") . "'></a>"?>
+ &nbsp;&nbsp;<?php echo gettext("Remove Enable/Disable changes in the current Category"); ?></td>
+ </tr>
+ <tr>
+ <td class="vexpl" valign="middle"><?php echo "<a href='?id={$id}&openruleset={$currentruleset}&act=resetall'>
+ <img src=\"../themes/{$g['theme']}/images/icons/icon_x.gif\" width=\"15\" height=\"15\"
+ onmouseout='this.src=\"../themes/{$g['theme']}/images/icons/icon_x.gif\"'
+ onmouseover='this.src=\"../themes/{$g['theme']}/images/icons/icon_x_mo.gif\"' border='0'
+ title='" . gettext("Click to remove all enable/disable changes for rules in all categories") . "'></a>"?>
+ &nbsp;&nbsp;<?php echo gettext("Remove all Enable/Disable changes in all Categories"); ?></td>
+ </tr>
+ <tr>
+ <td colspan="2" class="vexpl" valign="middle"><span class="red"><strong><?php echo gettext("Note: ") . "</strong></span>" .
+ gettext("Snort must be restarted to activate any SID enable/disable changes."); ?></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+
+ <tr>
+ <td class="listtopic"><?php echo gettext("Selected Category's Rules"); ?></td>
+ </tr>
+ <tr>
+ <td>
+ <table id="myTable" class="sortable" style="table-layout: fixed;" width="100%" border="0" cellpadding="0" cellspacing="0">
+ <colgroup>
+ <col width="15" align="left" valign="middle">
+ <col width="9%" align="center" axis="number">
+ <col width="60" align="center" axis="string">
+ <col width="14%" align="center" axis="string">
+ <col width="11%" align="center" axis="string">
+ <col width="14%" align="center" axis="string">
+ <col width="11%" align="center" axis="string">
+ <col axis="string">
+ <col width="22" align="right" valign="middle">
+ </colgroup>
+ <thead>
+ <th class="list">&nbsp;</th>
+ <th class="listhdrr"><?php echo gettext("SID"); ?></th>
+ <th class="listhdrr"><?php echo gettext("Proto"); ?></th>
+ <th class="listhdrr"><?php echo gettext("Source"); ?></th>
+ <th class="listhdrr"><?php echo gettext("Port"); ?></th>
+ <th class="listhdrr"><?php echo gettext("Destination"); ?></th>
+ <th class="listhdrr"><?php echo gettext("Port"); ?></th>
+ <th class="listhdrr"><?php echo gettext("Message"); ?></th>
+ <th class="list"><a href="javascript: void(0)"
+ onclick="wopen('snort_rules_edit.php?id=<?=$id;?>&openruleset=<?=$currentruleset;?>','FileViewer',800,600)">
+ <img src="../themes/<?= $g['theme']; ?>/images/icons/icon_service_restart.gif" <?php
+ echo "onmouseover='this.src=\"../themes/{$g['theme']}/images/icons/icon_services_restart_mo.gif\"'
+ onmouseout='this.src=\"../themes/{$g['theme']}/images/icons/icon_service_restart.gif\"' ";?>
+ title="<?php echo gettext("Click to view full text of all the category rules"); ?>" width="17" height="17" border="0"></a></th>
+ </thead>
+ <tbody>
+
+ <?php
+ $counter = 0;
+ foreach ($rules_map as $k1 => $rulem) {
+ foreach ($rulem as $k2 => $v) {
+ $sid = snort_get_sid($v['rule']);
+ $gid = snort_get_gid($v['rule']);
+ if (isset($disablesid[$sid])) {
+ $textss = "<span class=\"gray\">";
+ $textse = "</span>";
+ $iconb = "icon_reject_d.gif";
+ }
+ elseif (($v['disabled'] == 1) && (!isset($enablesid[$sid]))) {
+ $textss = "<span class=\"gray\">";
+ $textse = "</span>";
+ $iconb = "icon_block_d.gif";
+ }
+ elseif (isset($enablesid[$sid])) {
+ $textss = $textse = "";
+ $iconb = "icon_reject.gif";
+ }
+ else {
+ $textss = $textse = "";
+ $iconb = "icon_block.gif";
+ }
+
+ // Pick off the first section of the rule (prior to the start of the MSG field),
+ // and then use a REGX split to isolate the remaining fields into an array.
+ $tmp = substr($v['rule'], 0, strpos($v['rule'], "("));
+ $tmp = trim(preg_replace('/^\s*#+\s*/', '', $tmp));
+ $rule_content = preg_split('/[\s]+/', $tmp);
+
+ // Create custom <span> tags for the fields we truncate so we can
+ // have a "title" attribute for tooltips to show the full string.
+ $srcspan = add_title_attribute($textss, $rule_content[2]);
+ $srcprtspan = add_title_attribute($textss, $rule_content[3]);
+ $dstspan = add_title_attribute($textss, $rule_content[5]);
+ $dstprtspan = add_title_attribute($textss, $rule_content[6]);
+
+ $protocol = $rule_content[1]; //protocol field
+ $source = truncate($rule_content[2], 14); //source field
+ $source_port = truncate($rule_content[3], 10); //source port field
+ $destination = truncate($rule_content[5], 14); //destination field
+ $destination_port = truncate($rule_content[6], 10); //destination port field
+ $message = snort_get_msg($v['rule']);
+
+ echo "<tr><td class=\"listt\" align=\"left\" valign=\"middle\"> $textss
+ <a href='?id={$id}&openruleset={$currentruleset}&act=toggle&ids={$sid}'>
+ <img src=\"../themes/{$g['theme']}/images/icons/{$iconb}\"
+ width=\"11\" height=\"11\" border=\"0\"
+ title='" . gettext("Click to toggle enabled/disabled state") . "'></a>
+ $textse
+ </td>
+ <td class=\"listlr\" align=\"center\">
+ {$textss}{$sid}{$textse}
+ </td>
+ <td class=\"listlr\" align=\"center\">
+ {$textss}{$protocol}{$textse}
+ </td>
+ <td class=\"listlr\" align=\"center\">
+ {$srcspan}{$source}{$textse}
+ </td>
+ <td class=\"listlr\" align=\"center\">
+ {$srcprtspan}{$source_port}{$textse}
+ </td>
+ <td class=\"listlr\" align=\"center\">
+ {$dstspan}{$destination}{$textse}
+ </td>
+ <td class=\"listlr\" align=\"center\">
+ {$dstprtspan}{$destination_port}{$textse}
+ </td>
+ <td class=\"listbg\" style=\"word-wrap:break-word; whitespace:pre-line;\"><font color=\"white\">
+ {$textss}{$message}{$textse}
+ </td>";
+ ?>
+ <td align="right" valign="middle" nowrap class="listt">
+ <a href="javascript: void(0)"
+ onclick="wopen('snort_rules_edit.php?id=<?=$id;?>&openruleset=<?=$currentruleset;?>&ids=<?=$sid;?>&gid=<?=$gid;?>','FileViewer',800,600)"><img
+ src="../themes/<?= $g['theme']; ?>/images/icons/icon_right.gif"
+ title="<?php echo gettext("Click to view the entire rule text"); ?>" width="17" height="17" border="0"></a>
+ </td>
+ </tr>
+ <?php
+ $counter++;
+ }
+ }
+ unset($rulem, $v);
+ ?>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table width="100%" border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td class="vexpl" colspan="2" height="30" valign="middle"><?php echo gettext("Rule Count: {$counter}"); ?></td>
+ </tr>
+ <tr>
+ <td width="16"><img src="../themes/<?= $g['theme']; ?>/images/icons/icon_block.gif"
+ width="11" height="11"></td>
+ <td><?php echo gettext("Rule default is Enabled"); ?></td>
+ </tr>
+ <tr>
+ <td width="16"><img src="../themes/<?= $g['theme']; ?>/images/icons/icon_block_d.gif"
+ width="11" height="11"></td>
+ <td nowrap><?php echo gettext("Rule default is Disabled"); ?></td>
+ </tr>
+ <tr>
+ <td width="16"><img src="../themes/<?= $g['theme']; ?>/images/icons/icon_reject.gif"
+ width="11" height="11"></td>
+ <td nowrap><?php echo gettext("Rule changed to Enabled by user"); ?></td>
+ </tr>
+ <tr>
+ <td width="16"><img src="../themes/<?= $g['theme']; ?>/images/icons/icon_reject_d.gif"
+ width="11" height="11"></td>
+ <td nowrap><?php echo gettext("Rule changed to Disabled by user"); ?></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <?php endif;?>
+ </table>
+ </div>
+ </td>
+ </tr>
+</table>
+</form>
+<?php include("fend.inc"); ?>
+
<script language="javascript" type="text/javascript">
function go()
{
@@ -263,243 +610,22 @@ function go()
if (destination)
location.href = destination;
}
-function popup(url)
+
+function wopen(url, name, w, h)
{
- params = 'width='+screen.width;
- params += ', height='+screen.height;
- params += ', top=0, left=0'
- params += ', fullscreen=yes';
-
- newwin=window.open(url,'windowname4', params);
- if (window.focus) {newwin.focus()}
- return false;
+// Fudge factors for window decoration space.
+// In my tests these work well on all platforms & browsers.
+w += 32;
+h += 96;
+ var win = window.open(url,
+ name,
+ 'width=' + w + ', height=' + h + ', ' +
+ 'location=no, menubar=no, ' +
+ 'status=no, toolbar=no, scrollbars=yes, resizable=yes');
+ win.resizeTo(w, h);
+ win.focus();
}
-</script>
-<form action="/snort/snort_rules.php" method="post" name="iform" id="iform">
-<table width="100%" border="0" cellpadding="0" cellspacing="0">
-<tr><td>
-<?php
- $tab_array = array();
- $tab_array[] = array(gettext("Snort Interfaces"), false, "/snort/snort_interfaces.php");
- $tab_array[] = array(gettext("If Settings"), false, "/snort/snort_interfaces_edit.php?id={$id}");
- $tab_array[] = array(gettext("Categories"), false, "/snort/snort_rulesets.php?id={$id}");
- $tab_array[] = array(gettext("Rules"), true, "/snort/snort_rules.php?id={$id}");
- $tab_array[] = array(gettext("Variables"), false, "/snort/snort_define_servers.php?id={$id}");
- $tab_array[] = array(gettext("Preprocessors"), false, "/snort/snort_preprocessors.php?id={$id}");
- $tab_array[] = array(gettext("Barnyard2"), false, "/snort/snort_barnyard.php?id={$id}");
- display_top_tabs($tab_array);
-?>
-</td></tr>
-<tr>
- <td>
- <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
- <tr>
- <td width="3%" class="list">&nbsp;</td>
- <td class="listhdr" colspan="4">
- <br/>Category:
- <select id="selectbox" name="selectbox" class="formselect" onChange="go()">
- <option value='?id=<?=$id;?>&openruleset=custom.rules'>custom.rules</option>
- <?php
- $files = explode("||", $pconfig['rulesets']);
- if ($a_rule[$id]['ips_policy_enable'] == 'on')
- $files[] = "IPS Policy - " . ucfirst($a_rule[$id]['ips_policy']);
- natcasesort($files);
- foreach ($files as $value) {
- if ($snortdownload != 'on' && substr($value, 0, 6) == "snort_")
- continue;
- if ($emergingdownload != 'on' && substr($value, 0, 8) == "emerging")
- continue;
- if (empty($value))
- continue;
- echo "<option value='?id={$id}&openruleset={$value}' ";
- if ($value == $currentruleset)
- echo "selected";
- echo ">{$value}</option>\n";
- }
- ?>
- </select>
- <br/>
- </td>
- <td class="listhdr" colspan="3" valign="middle">
-<?php if ($currentruleset != 'custom.rules'): ?>
- <?php echo "<a href='?id={$id}&openruleset={$currentruleset}&act=resetcategory'>
- <img src=\"../themes/{$g['theme']}/images/icons/icon_x.gif\"
- onmouseout='this.src=\"../themes/{$g['theme']}/images/icons/icon_x.gif\"'
- onmouseover='this.src=\"../themes/{$g['theme']}/images/icons/icon_x_mo.gif\"' border='0'
- title='" . gettext("Click to remove enable/disable changes for rules in the selected category only") . "'></a>"?>
- &nbsp;<?php echo gettext("Remove Enable/Disable changes in the current Category");?><br>
- <?php echo "<a href='?id={$id}&openruleset={$currentruleset}&act=resetall'>
- <img src=\"../themes/{$g['theme']}/images/icons/icon_x.gif\"
- onmouseout='this.src=\"../themes/{$g['theme']}/images/icons/icon_x.gif\"'
- onmouseover='this.src=\"../themes/{$g['theme']}/images/icons/icon_x_mo.gif\"' border='0'
- title='" . gettext("Click to remove all enable/disable changes for rules in all categories") . "'></a>"?>
- &nbsp;<?php echo gettext("Remove all Enable/Disable changes in all Categories");?>
-<?php endif;?>
- &nbsp;</td>
- <td width="3%" class="list">&nbsp;</td>
- </tr>
-<?php if ($currentruleset == 'custom.rules'): ?>
- <tr>
- <td width="3%" class="list">&nbsp;</td>
- <td colspan="7" valign="top" class="vtable">
- <input type='hidden' name='openruleset' value='custom.rules'>
- <input type='hidden' name='id' value='<?=$id;?>'>
-
- <textarea wrap="on" cols="85" rows="40" name="customrules"><?=$pconfig['customrules'];?></textarea>
- </td>
- <td width="3%" class="list">&nbsp;</td>
- </tr>
- <tr>
- <td width="3%" class="list">&nbsp;</td>
- <td colspan="7" class="vtable">
- <input name="Submit" type="submit" class="formbtn" value="Save">
- <input type="button" class="formbtn" value="Cancel" onclick="history.back()">
- </td>
- <td width="3%" class="list">&nbsp;</td>
- </tr>
-<?php else: ?>
- <tr>
- <td width="3%" class="list">&nbsp;</td>
- <td colspan="7" class="listhdr" >&nbsp;</td>
- <td width="3%" align="center" valign="middle" class="listt"><a href="javascript: void(0)"
- onclick="popup('snort_rules_edit.php?id=<?=$id;?>&openruleset=<?=$currentruleset;?>')">
- <img src="../themes/<?= $g['theme']; ?>/images/icons/icon_service_restart.gif" <?php
- echo "onmouseover='this.src=\"../themes/{$g['theme']}/images/icons/icon_services_restart_mo.gif\"'
- onmouseout='this.src=\"../themes/{$g['theme']}/images/icons/icon_service_restart.gif\"' ";?>
- title="<?php echo gettext("Click to view all rules"); ?>" width="17" height="17" border="0"></a></td>
- </tr>
- <tr id="frheader">
- <td width="3%" class="list">&nbsp;</td>
- <td width="9%" class="listhdrr"><?php echo gettext("SID"); ?></td>
- <td width="2%" class="listhdrr"><?php echo gettext("Proto"); ?></td>
- <td width="14%" class="listhdrr"><?php echo gettext("Source"); ?></td>
- <td width="12%" class="listhdrr"><?php echo gettext("Port"); ?></td>
- <td width="14%" class="listhdrr"><?php echo gettext("Destination"); ?></td>
- <td width="12%" class="listhdrr"><?php echo gettext("Port"); ?></td>
- <td width="31%" class="listhdrr"><?php echo gettext("Message"); ?></td>
- <td width="3%" class="list">&nbsp;</td>
- </tr>
-<?php
- foreach (array_keys($rules_map) as $k1) {
- foreach (array_keys($rules_map[$k1]) as $k2) {
- $sid = snort_get_sid($rules_map[$k1][$k2]['rule']);
- $gid = snort_get_gid($rules_map[$k1][$k2]['rule']);
- if (isset($disablesid[$sid])) {
- $textss = "<span class=\"gray\">";
- $textse = "</span>";
- $iconb = "icon_reject_d.gif";
- }
- elseif (($rules_map[$k1][$k2]['disabled'] == 1) && (!isset($enablesid[$sid]))) {
- $textss = "<span class=\"gray\">";
- $textse = "</span>";
- $iconb = "icon_block_d.gif";
- }
- elseif (isset($enablesid[$sid])) {
- $textss = $textse = "";
- $iconb = "icon_reject.gif";
- }
- else {
- $textss = $textse = "";
- $iconb = "icon_block.gif";
- }
-
- // Pick off the first section of the rule (prior to the start of the MSG field),
- // and then use a REGX split to isolate the remaining fields into an array.
- $tmp = substr($rules_map[$k1][$k2]['rule'], 0, strpos($rules_map[$k1][$k2]['rule'], "("));
- $tmp = trim(preg_replace('/^\s*#+\s*/', '', $tmp));
- $rule_content = preg_split('/[\s]+/', $tmp);
-
- $protocol = truncate($rule_content[1], 5); //protocol location
- $source = truncate($rule_content[2], 13); //source location
- $source_port = truncate($rule_content[3], 11); //source port location
- $destination = truncate($rule_content[5], 13); //destination location
- $destination_port = truncate($rule_content[6], 11); //destination port location
- $message = snort_get_msg($rules_map[$k1][$k2]['rule']);
-
- echo "<tr><td width=\"3%\" class=\"listt\" align=\"center\" valign=\"middle\"> $textss
- <a href='?id={$id}&openruleset={$currentruleset}&act=toggle&ids={$sid}'>
- <img src=\"../themes/{$g['theme']}/images/icons/{$iconb}\"
- width=\"10\" height=\"10\" border=\"0\"
- title='" . gettext("Click to toggle enabled/disabled state") . "'></a>
- $textse
- </td>
- <td width=\"9%\" class=\"listlr\">
- $textss $sid $textse
- </td>
- <td width=\"2%\" class=\"listlr\">
- $textss $protocol $textse
- </td>
- <td width=\"14%\" class=\"listlr\">
- $textss $source $textse
- </td>
- <td width=\"12%\" class=\"listlr\">
- $textss $source_port $textse
- </td>
- <td width=\"14%\" class=\"listlr\">
- $textss $destination $textse
- </td>
- <td width=\"12%\" class=\"listlr\">
- $textss $destination_port $textse
- </td>
- <td width=\"31%\" class=\"listbg\" style=\"word-break:break-all;\"><font color=\"white\">
- $textss $message $textse
- </td>";
- ?>
- <td width="3%" align="center" valign="middle" nowrap class="listt">
- <a href="javascript: void(0)"
- onclick="popup('snort_rules_edit.php?id=<?=$id;?>&openruleset=<?=$currentruleset;?>&ids=<?=$sid;?>&gid=<?=$gid;?>')"><img
- src="../themes/<?= $g['theme']; ?>/images/icons/icon_right.gif"
- title="<?php echo gettext("Click to view rule"); ?>" width="17" height="17" border="0"></a>
- <!-- Codes by Quackit.com -->
- </td>
- </tr>
-<?php
- }
- }
-?>
-
- </table>
- </td>
-</tr>
-<?php endif;?>
-<tr>
- <td colspan="9">
-<?php if ($currentruleset != 'custom.rules'): ?>
- <table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="1">
- <tr>
- <td width="16"><img
- src="../themes/<?= $g['theme']; ?>/images/icons/icon_block.gif"
- width="11" height="11"></td>
- <td><?php echo gettext("Rule default is Enabled"); ?></td>
- </tr>
- <tr>
- <td><img
- src="../themes/<?= $g['theme']; ?>/images/icons/icon_block_d.gif"
- width="11" height="11"></td>
- <td nowrap><?php echo gettext("Rule default is Disabled"); ?></td>
- </tr>
- <tr>
- <td><img
- src="../themes/<?= $g['theme']; ?>/images/icons/icon_reject.gif"
- width="11" height="11"></td>
- <td nowrap><?php echo gettext("Rule changed to Enabled by user"); ?></td>
- </tr>
- <tr>
- <td><img
- src="../themes/<?= $g['theme']; ?>/images/icons/icon_reject_d.gif"
- width="11" height="11"></td>
- <td nowrap><?php echo gettext("Rule changed to Disabled by user"); ?></td>
- </tr>
- </table>
-<?php endif;?>
- </td>
-</tr>
-</table>
-</td>
-</tr>
-</table>
-</form>
-<?php include("fend.inc"); ?>
+</script>
</body>
</html>
diff --git a/config/snort/snort_rules_edit.php b/config/snort/snort_rules_edit.php
index ab1a24b2..a1f45c07 100755
--- a/config/snort/snort_rules_edit.php
+++ b/config/snort/snort_rules_edit.php
@@ -62,6 +62,7 @@ $if_real = snort_get_real_interface($pconfig['interface']);
$snort_uuid = $a_rule[$id]['uuid'];
$file = $_GET['openruleset'];
$contents = '';
+$wrap_flag = "off";
// Read the contents of the argument passed to us.
// It may be an IPS policy string, an individual SID,
@@ -69,8 +70,10 @@ $contents = '';
// Test for the special case of an IPS Policy file.
if (substr($file, 0, 10) == "IPS Policy") {
$rules_map = snort_load_vrt_policy($a_rule[$id]['ips_policy']);
- if (isset($_GET['ids']))
+ if (isset($_GET['ids'])) {
$contents = $rules_map[$_GET['gid']][trim($_GET['ids'])]['rule'];
+ $wrap_flag = "soft";
+ }
else {
$contents = "# Snort IPS Policy - " . ucfirst($a_rule[$id]['ips_policy']) . "\n\n";
foreach (array_keys($rules_map) as $k1) {
@@ -86,6 +89,7 @@ if (substr($file, 0, 10) == "IPS Policy") {
elseif (isset($_GET['ids'])) {
$rules_map = snort_load_rules_map("{$snortdir}/rules/{$file}");
$contents = $rules_map[$_GET['gid']][trim($_GET['ids'])]['rule'];
+ $wrap_flag = "soft";
}
// Is it our special flowbit rules file?
elseif ($file == $flowbit_rules_file)
@@ -102,14 +106,14 @@ else {
exit;
}
-$pgtitle = array(gettext("Advanced"), gettext("File Viewer"));
+$pgtitle = array(gettext("Snort"), gettext("File Viewer"));
?>
<?php include("head.inc");?>
<body link="#000000" vlink="#000000" alink="#000000">
<?php if ($savemsg) print_info_box($savemsg); ?>
-<?php include("fbegin.inc");?>
+<?php // include("fbegin.inc");?>
<form action="snort_rules_edit.php" method="post">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
@@ -117,14 +121,20 @@ $pgtitle = array(gettext("Advanced"), gettext("File Viewer"));
<td class="tabcont">
<table width="100%" cellpadding="0" cellspacing="6" bgcolor="#eeeeee">
<tr>
- <td>
+ <td class="pgtitle" colspan="2">Snort: Rules Viewer</td>
+ </tr>
+ <tr>
+ <td width="20%">
<input type="button" class="formbtn" value="Return" onclick="window.close()">
</td>
+ <td align="right">
+ <b><?php echo gettext("Rules File: ") . '</b>&nbsp;' . $file; ?>&nbsp;&nbsp;&nbsp;&nbsp;
+ </td>
</tr>
<tr>
- <td valign="top" class="label">
- <div style="background: #eeeeee;" id="textareaitem"><!-- NOTE: The opening *and* the closing textarea tag must be on the same line. -->
- <textarea wrap="off" rows="33" cols="90" name="code2"><?=$contents;?></textarea>
+ <td valign="top" class="label" colspan="2">
+ <div style="background: #eeeeee; width:100%; height:100%;" id="textareaitem"><!-- NOTE: The opening *and* the closing textarea tag must be on the same line. -->
+ <textarea style="width:100%; height:100%;" wrap="<?=$wrap_flag?>" rows="33" cols="80" name="code2"><?=$contents;?></textarea>
</div>
</td>
</tr>
@@ -133,6 +143,6 @@ $pgtitle = array(gettext("Advanced"), gettext("File Viewer"));
</tr>
</table>
</form>
-<?php include("fend.inc");?>
+<?php // include("fend.inc");?>
</body>
</html>
diff --git a/config/snort/snort_rules_flowbits.php b/config/snort/snort_rules_flowbits.php
new file mode 100644
index 00000000..215399c6
--- /dev/null
+++ b/config/snort/snort_rules_flowbits.php
@@ -0,0 +1,277 @@
+<?php
+/*
+ * snort_rules_flowbits.php
+ * Copyright (C) 2004 Scott Ullrich
+ * Copyright (C) 2011-2012 Ermal Luci
+ * All rights reserved.
+ *
+ * originially part of m0n0wall (http://m0n0.ch/wall)
+ * Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
+ * All rights reserved.
+ *
+ * modified for the pfsense snort package
+ * Copyright (C) 2009-2010 Robert Zelaya.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+require_once("guiconfig.inc");
+require_once("/usr/local/pkg/snort/snort.inc");
+
+global $g, $flowbit_rules_file, $rebuild_rules;
+
+$snortdir = SNORTDIR;
+$rules_map = array();
+$supplist = array();
+
+if (!is_array($config['installedpackages']['snortglobal']['rule'])) {
+ $config['installedpackages']['snortglobal']['rule'] = array();
+}
+$a_nat = &$config['installedpackages']['snortglobal']['rule'];
+
+$id = $_GET['id'];
+if (isset($_POST['id']))
+ $id = $_POST['id'];
+if (is_null($id)) {
+ header("Location: /snort/snort_interfaces.php");
+ exit;
+}
+
+$if_real = snort_get_real_interface($a_nat[$id]['interface']);
+$snort_uuid = $a_nat[$id]['uuid'];
+
+/* We should normally never get to this page if Auto-Flowbits are disabled, but just in case... */
+if ($a_nat[$id]['autoflowbitrules'] == 'on') {
+ if (file_exists("{$snortdir}/snort_{$snort_uuid}_{$if_real}/rules/{$flowbit_rules_file}") &&
+ filesize("{$snortdir}/snort_{$snort_uuid}_{$if_real}/rules/{$flowbit_rules_file}") > 0) {
+ $rules_map = snort_load_rules_map("{$snortdir}/snort_{$snort_uuid}_{$if_real}/rules/{$flowbit_rules_file}");
+ }
+ else
+ $savemsg = "There are no flowbit-required rules necessary for the current enforcing rule set.";
+}
+else
+ $input_errors[] = "Auto-Flowbit rule generation is disabled for this interface!";
+
+if ($_GET['act'] == "addsuppress" && is_numeric($_GET['sidid']) && is_numeric($_GET['gen_id'])) {
+ $descr = snort_get_msg($rules_map[$_GET['gen_id']][$_GET['sidid']]['rule']);
+ if (empty($descr))
+ $suppress = "suppress gen_id {$_GET['gen_id']}, sig_id {$_GET['sidid']}\n";
+ else
+ $suppress = "# {$descr}\nsuppress gen_id {$_GET['gen_id']}, sig_id {$_GET['sidid']}";
+ if (!is_array($config['installedpackages']['snortglobal']['suppress']))
+ $config['installedpackages']['snortglobal']['suppress'] = array();
+ if (!is_array($config['installedpackages']['snortglobal']['suppress']['item']))
+ $config['installedpackages']['snortglobal']['suppress']['item'] = array();
+ $a_suppress = &$config['installedpackages']['snortglobal']['suppress']['item'];
+
+ if (empty($a_nat[$id]['suppresslistname']) || $a_nat[$id]['suppresslistname'] == 'default') {
+ $s_list = array();
+ $s_list['name'] = $a_nat[$id]['interface'] . "suppress";
+ $s_list['uuid'] = uniqid();
+ $s_list['descr'] = "Auto-generated list for alert suppression";
+ $s_list['suppresspassthru'] = base64_encode($suppress);
+ $a_suppress[] = $s_list;
+ $a_nat[$id]['suppresslistname'] = $s_list['name'];
+ } else {
+ foreach ($a_suppress as $a_id => $alist) {
+ if ($alist['name'] == $a_nat[$id]['suppresslistname']) {
+ if (!empty($alist['suppresspassthru'])) {
+ $tmplist = base64_decode($alist['suppresspassthru']);
+ $tmplist .= "\n{$suppress}";
+ $alist['suppresspassthru'] = base64_encode($tmplist);
+ $a_suppress[$a_id] = $alist;
+ }
+ }
+ }
+ }
+ write_config();
+ $rebuild_rules = "off";
+ sync_snort_package_config();
+ $savemsg = "Wrote suppress rule for gen_id {$_GET['gen_id']}, sig_id {$_GET['sidid']} to the {$a_nat[$id]['suppresslistname']} Suppression List.";
+}
+
+function truncate($string, $length) {
+
+ /********************************
+ * This function truncates the *
+ * passed string to the length *
+ * specified adding ellipsis if *
+ * truncation was necessary. *
+ ********************************/
+ if (strlen($string) > $length)
+ $string = substr($string, 0, ($length - 3)) . "...";
+ return $string;
+}
+
+/* Load up an array with the current Suppression List GID,SID values */
+$supplist = snort_load_suppress_sigs($a_nat[$id]);
+
+$if_friendly = snort_get_friendly_interface($a_nat[$id]['interface']);
+$pgtitle = "Services: Snort: {$if_friendly} Flowbit Rules";
+include_once("head.inc");
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC" >
+
+<?php
+include("fbegin.inc");
+if($pfsense_stable == 'yes'){echo '<p class="pgtitle">' . $pgtitle . '</p>';}
+if ($input_errors) print_input_errors($input_errors);
+if ($savemsg)
+ print_info_box($savemsg);
+?>
+<form action="snort_rules_flowbits.php" method="post" name="iform" id="iform">
+<div id="boxarea">
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+<tr>
+<td class="tabcont">
+<table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td valign="middle" class="listtopic"><?php echo gettext("Auto-Generated Flowbit-Required Rules"); ?></td>
+ </tr>
+ <tr>
+ <td width="78%" class="vncell">
+ <?php echo gettext("The rules listed below are required to be included in the rules set ") .
+ gettext("because they set flowbits that are checked and relied upon by rules in the enforcing rules set. ") .
+ gettext("If these dependent flowbits are not set, then some of your chosen rules may not fire. ") .
+ gettext("Enabling all the rules that set these dependent flowbits ensures your chosen rules fire as intended. ") .
+ gettext("Most flowbits rules contain the \"noalert\" keyword to prevent an alert from firing ") .
+ gettext("when the flowbit is detected. For those flowbit rules that do not contain the \"noalert\" option, click the ") .
+ gettext("icon displayed beside the Signature ID (SID) to add the alert to the Suppression List if desired."); ?></td>
+ </tr>
+ <tr>
+ <td valign="middle" class="listtopic"><?php echo gettext("Flowbit-Required Rules for {$if_friendly}"); ?></td>
+ </tr>
+ <tr>
+ <td width="78%" class="vncell">
+ <table width="100%" border="0 cellspacing="2" cellpadding="0">
+ <tr>
+ <td width="17px"><img src="../themes/<?=$g['theme']?>/images/icons/icon_plus.gif" width='12' height='12' border='0'/></td>
+ <td><span class="vexpl"><?php echo gettext("Alert is Not Suppressed"); ?></span></td>
+ <td rowspan="3" align="right"><input id="cancelbutton" name="cancelbutton" type="button" class="formbtn" onclick="history.back()" <?php
+ echo "value=\"" . gettext("Return") . "\" title=\"" . gettext("Return to previous page") . "\""; ?>/></td>
+ </tr>
+ <tr>
+ <td width="17px"><img src="../themes/<?=$g['theme']?>/images/icons/icon_plus_d.gif" width='12' height='12' border='0'/></td>
+ <td><span class="vexpl"><?php echo gettext("Alert has been Suppressed"); ?></span></td>
+ </tr>
+ <tr>
+ <td width="17px"> </td>
+ <td colspan="2" class="vexpl"><?php echo "<span class=\"red\"><strong>" .
+ gettext("Note: ") . "</strong></span>". gettext("the icon is only ") .
+ gettext("displayed for flowbit rules without the \"noalert\" option."); ?></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table id="myTable" width="100%" class="sortable" border="1" cellpadding="0" cellspacing="0">
+ <colgroup>
+ <col width="11%" axis="number">
+ <col width="10%" axis="string">
+ <col width="14%" axis="string">
+ <col width="14%" axis="string">
+ <col width="20%" axis="string">
+ <col axis="string">
+ </colgroup>
+ <thead>
+ <th class="listhdrr" axis="number"><?php echo gettext("SID"); ?></th>
+ <td class="listhdrr" axis="string"><?php echo gettext("Proto"); ?></th>
+ <th class="listhdrr" axis="string"><?php echo gettext("Source"); ?></th>
+ <th class="listhdrr" axis="string"><?php echo gettext("Destination"); ?></th>
+ <th class="listhdrr" axis="string"><?php echo gettext("Flowbits"); ?></th>
+ <th class="listhdrr" axis="string"><?php echo gettext("Message"); ?></th>
+ <thead>
+ <tbody>
+ <?php
+ $count = 0;
+ foreach ($rules_map as $k1 => $rulem) {
+ foreach ($rulem as $k2 => $v) {
+ $sid = snort_get_sid($v['rule']);
+ $gid = snort_get_gid($v['rule']);
+
+ // Pick off the first section of the rule (prior to the start of the MSG field),
+ // and then use a REGX split to isolate the remaining fields into an array.
+ $tmp = substr($v['rule'], 0, strpos($v['rule'], "("));
+ $tmp = trim(preg_replace('/^\s*#+\s*/', '', $tmp));
+ $rule_content = preg_split('/[\s]+/', $tmp);
+
+ $protocol = $rule_content[1]; //protocol
+ $source = truncate($rule_content[2], 14); //source
+ $destination = truncate($rule_content[5], 14); //destination
+ $message = snort_get_msg($v['rule']);
+ $flowbits = implode("; ", snort_get_flowbits($v['rule']));
+ if (strstr($flowbits, "noalert"))
+ $supplink = "";
+ else {
+ if (!isset($supplist[$gid][$sid])) {
+ $supplink = "<a href=\"?id={$id}&act=addsuppress&sidid={$sid}&gen_id={$gid}\">";
+ $supplink .= "<img src=\"../themes/{$g['theme']}/images/icons/icon_plus.gif\"";
+ $supplink .= "width='12' height='12' border='0' title='";
+ $supplink .= gettext("Click to add to Suppress List") . "'/></a>";
+ }
+ else {
+ $supplink .= "<img src=\"../themes/{$g['theme']}/images/icons/icon_plus_d.gif\"";
+ $supplink .= "width='12' height='12' border='0' title='";
+ $supplink .= gettext("Alert has been suppressed") . "'/>";
+ }
+ }
+
+ // Use "echo" to write the table HTML row-by-row.
+ echo "<tr>" .
+ "<td class=\"listr\">{$sid}&nbsp;{$supplink}</td>" .
+ "<td class=\"listr\">{$protocol}</td>" .
+ "<td class=\"listr\"><span title=\"{$rule_content[2]}\">{$source}</span></td>" .
+ "<td class=\"listr\"><span title=\"{$rule_content[5]}\">{$destination}</span></td>" .
+ "<td class=\"listr\" style=\"word-wrap:break-word; word-break:normal;\">{$flowbits}</td>" .
+ "<td class=\"listr\" style=\"word-wrap:break-word; word-break:normal;\">{$message}</td>" .
+ "</tr>";
+ $count++;
+ }
+ }
+ unset($rulem, $v);
+ ?>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <?php if ($count > 20): ?>
+ <tr>
+ <td align="center" valign="middle">
+ <input id="cancelbutton" name="cancelbutton" type="button" class="formbtn" onclick="history.back()" <?php
+ echo "value=\"" . gettext("Return") . "\" title=\"" . gettext("Return to previous page") . "\""; ?>/>
+ <input name="id" type="hidden" value="<?=$id;?>" />
+ </td>
+ </tr>
+ <?php endif; ?>
+</table>
+</td>
+</tr>
+</table>
+</div>
+</form>
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/config/snort/snort_rulesets.php b/config/snort/snort_rulesets.php
index 23a24bea..fa3efc1b 100755
--- a/config/snort/snort_rulesets.php
+++ b/config/snort/snort_rulesets.php
@@ -32,7 +32,7 @@
require_once("guiconfig.inc");
require_once("/usr/local/pkg/snort/snort.inc");
-global $g, $flowbit_rules_file;
+global $g, $flowbit_rules_file, $rebuild_rules;
$snortdir = SNORTDIR;
@@ -62,13 +62,30 @@ $if_real = snort_get_real_interface($pconfig['interface']);
$snort_uuid = $a_nat[$id]['uuid'];
$snortdownload = $config['installedpackages']['snortglobal']['snortdownload'];
$emergingdownload = $config['installedpackages']['snortglobal']['emergingthreats'];
+$snortcommunitydownload = $config['installedpackages']['snortglobal']['snortcommunityrules'];
+
+$no_emerging_files = false;
+$no_snort_files = false;
+$no_community_files = false;
+
+/* Test rule categories currently downloaded to $SNORTDIR/rules and set appropriate flags */
+$test = glob("{$snortdir}/rules/emerging-*.rules");
+if (empty($test))
+ $no_emerging_files = true;
+$test = glob("{$snortdir}/rules/snort_*.rules");
+if (empty($test))
+ $no_snort_files = true;
+if (!file_exists("{$snortdir}/rules/GPLv2_community.rules"))
+ $no_community_files = true;
if (($snortdownload == 'off') || ($a_nat[$id]['ips_policy_enable'] != 'on'))
$policy_select_disable = "disabled";
if ($a_nat[$id]['autoflowbitrules'] == 'on') {
- if (file_exists("{$snortdir}/snort_{$snort_uuid}_{$if_real}/rules/{$flowbit_rules_file}"))
- $btn_view_flowb_rules = "";
+ if (file_exists("{$snortdir}/snort_{$snort_uuid}_{$if_real}/rules/{$flowbit_rules_file}") &&
+ filesize("{$snortdir}/snort_{$snort_uuid}_{$if_real}/rules/{$flowbit_rules_file}") > 0) {
+ $btn_view_flowb_rules = " title=\"" . gettext("View flowbit-required rules") . "\"";
+ }
else
$btn_view_flowb_rules = " disabled";
}
@@ -95,12 +112,14 @@ else
/* alert file */
if ($_POST["Submit"]) {
- if ($_POST['ips_policy_enable'] == "on")
+ if ($_POST['ips_policy_enable'] == "on") {
$a_nat[$id]['ips_policy_enable'] = 'on';
- else
+ $a_nat[$id]['ips_policy'] = $_POST['ips_policy'];
+ }
+ else {
$a_nat[$id]['ips_policy_enable'] = 'off';
-
- $a_nat[$id]['ips_policy'] = $_POST['ips_policy'];
+ unset($a_nat[$id]['ips_policy']);
+ }
$enabled_items = "";
if (is_array($_POST['toenable']))
@@ -119,7 +138,14 @@ if ($_POST["Submit"]) {
}
write_config();
- sync_snort_package_config();
+
+ /*************************************************/
+ /* Update the snort conf file and rebuild the */
+ /* rules for this interface. */
+ /*************************************************/
+ $rebuild_rules = "on";
+ snort_generate_conf($a_nat[$id]);
+ $rebuild_rules = "off";
header("Location: /snort/snort_rulesets.php?id=$id");
exit;
@@ -128,6 +154,15 @@ if ($_POST["Submit"]) {
if ($_POST['unselectall']) {
$a_nat[$id]['rulesets'] = "";
+ if ($_POST['ips_policy_enable'] == "on") {
+ $a_nat[$id]['ips_policy_enable'] = 'on';
+ $a_nat[$id]['ips_policy'] = $_POST['ips_policy'];
+ }
+ else {
+ $a_nat[$id]['ips_policy_enable'] = 'off';
+ unset($a_nat[$id]['ips_policy']);
+ }
+
write_config();
sync_snort_package_config();
@@ -137,12 +172,29 @@ if ($_POST['unselectall']) {
if ($_POST['selectall']) {
$rulesets = array();
+
+ if ($_POST['ips_policy_enable'] == "on") {
+ $a_nat[$id]['ips_policy_enable'] = 'on';
+ $a_nat[$id]['ips_policy'] = $_POST['ips_policy'];
+ }
+ else {
+ $a_nat[$id]['ips_policy_enable'] = 'off';
+ unset($a_nat[$id]['ips_policy']);
+ }
+
if ($emergingdownload == 'on') {
$files = glob("{$snortdir}/rules/emerging*.rules");
foreach ($files as $file)
$rulesets[] = basename($file);
}
- if ($snortdownload == 'on') {
+ if ($snortcommunitydownload == 'on') {
+ $files = glob("{$snortdir}/rules/*_community.rules");
+ foreach ($files as $file)
+ $rulesets[] = basename($file);
+ }
+
+ /* Include the Snort VRT rules only if enabled and no IPS policy is set */
+ if ($snortdownload == 'on' && $a_nat[$id]['ips_policy_enable'] == 'off') {
$files = glob("{$snortdir}/rules/snort*.rules");
foreach ($files as $file)
$rulesets[] = basename($file);
@@ -181,47 +233,32 @@ if ($savemsg) {
?>
-<script language="javascript" type="text/javascript">
-function popup(url)
-{
- params = 'width='+screen.width;
- params += ', height='+screen.height;
- params += ', top=0, left=0'
- params += ', fullscreen=yes';
-
- newwin=window.open(url,'windowname4', params);
- if (window.focus) {newwin.focus()}
- return false;
-}
-function enable_change()
-{
- var endis = !(document.iform.ips_policy_enable.checked);
- document.iform.ips_policy.disabled=endis;
-
- for (var i = 0; i < document.iform.elements.length; i++) {
- if (document.iform.elements[i].type == 'checkbox') {
- var str = document.iform.elements[i].value;
- if (str.substr(0,6) == "snort_")
- document.iform.elements[i].disabled = !(endis);
- }
- }
-}
-</script>
-
<form action="snort_rulesets.php" method="post" name="iform" id="iform">
<input type="hidden" name="id" id="id" value="<?=$id;?>" />
-<table width="99%" border="0" cellpadding="0" cellspacing="0">
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td>
-<?php
- $tab_array = array();
- $tab_array[] = array(gettext("Snort Interfaces"), false, "/snort/snort_interfaces.php");
- $tab_array[] = array(gettext("If Settings"), false, "/snort/snort_interfaces_edit.php?id={$id}");
- $tab_array[] = array(gettext("Categories"), true, "/snort/snort_rulesets.php?id={$id}");
- $tab_array[] = array(gettext("Rules"), false, "/snort/snort_rules.php?id={$id}");
- $tab_array[] = array(gettext("Variables"), false, "/snort/snort_define_servers.php?id={$id}");
- $tab_array[] = array(gettext("Preprocessors"), false, "/snort/snort_preprocessors.php?id={$id}");
- $tab_array[] = array(gettext("Barnyard2"), false, "/snort/snort_barnyard.php?id={$id}");
- display_top_tabs($tab_array);
+<?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Snort Interfaces"), true, "/snort/snort_interfaces.php");
+ $tab_array[1] = array(gettext("Global Settings"), false, "/snort/snort_interfaces_global.php");
+ $tab_array[2] = array(gettext("Updates"), false, "/snort/snort_download_updates.php");
+ $tab_array[3] = array(gettext("Alerts"), false, "/snort/snort_alerts.php");
+ $tab_array[4] = array(gettext("Blocked"), false, "/snort/snort_blocked.php");
+ $tab_array[5] = array(gettext("Whitelists"), false, "/snort/snort_interfaces_whitelist.php");
+ $tab_array[6] = array(gettext("Suppress"), false, "/snort/snort_interfaces_suppress.php");
+ $tab_array[7] = array(gettext("Sync"), false, "/pkg_edit.php?xml=snort/snort_sync.xml");
+ display_top_tabs($tab_array);
+ echo '</td></tr>';
+ echo '<tr><td class="tabnavtbl">';
+ $menu_iface=($if_friendly?substr($if_friendly,0,5)." ":"Iface ");
+ $tab_array = array();
+ $tab_array[] = array($menu_iface . gettext("Settings"), false, "/snort/snort_interfaces_edit.php?id={$id}");
+ $tab_array[] = array($menu_iface . gettext("Categories"), true, "/snort/snort_rulesets.php?id={$id}");
+ $tab_array[] = array($menu_iface . gettext("Rules"), false, "/snort/snort_rules.php?id={$id}");
+ $tab_array[] = array($menu_iface . gettext("Variables"), false, "/snort/snort_define_servers.php?id={$id}");
+ $tab_array[] = array($menu_iface . gettext("Preprocessors"), false, "/snort/snort_preprocessors.php?id={$id}");
+ $tab_array[] = array($menu_iface . gettext("Barnyard2"), false, "/snort/snort_barnyard.php?id={$id}");
+ display_top_tabs($tab_array);
?>
</td></tr>
<tr>
@@ -233,12 +270,15 @@ function enable_change()
$iscfgdirempty = array();
if (file_exists("{$snortdir}/snort_{$snort_uuid}_{$if_real}/rules/custom.rules"))
$iscfgdirempty = (array)("{$snortdir}/snort_{$snort_uuid}_{$if_real}/rules/custom.rules");
- if (empty($isrulesfolderempty) && empty($iscfgdirempty)):
+ if (empty($isrulesfolderempty)):
?>
<tr>
- <td>
- <?php printf(gettext("# The rules directory is empty. %s/rules"), $snortdir); ?> <br/>
- <?php echo gettext("Please go to the Updates tab to download/fetch the rules configured."); ?>
+ <td class="vexpl"><br/>
+ <?php printf(gettext("# The rules directory is empty: %s%s/rules%s"), '<strong>',$snortdir,'</strong>'); ?> <br/><br/>
+ <?php echo gettext("Please go to the ") . '<a href="snort_download_updates.php"><strong>' . gettext("Updates") .
+ '</strong></a>' . gettext(" tab to download the rules configured on the ") .
+ '<a href="snort_interfaces_global.php"><strong>' . gettext("Global") .
+ '</strong></a>' . gettext(" tab."); ?>
</td>
</tr>
<?php else:
@@ -251,58 +291,61 @@ function enable_change()
?>
<tr>
<td>
- <table id="sortabletable1" class="sortable" width="100%" border="0"
+ <table width="100%" border="0"
cellpadding="0" cellspacing="0">
<tr>
<td colspan="6" class="listtopic"><?php echo gettext("Automatic flowbit resolution"); ?><br/></td>
</tr>
<tr>
<td colspan="6" valign="center" class="listn">
- <table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <table width="100%" border="0" cellpadding="2" cellspacing="2">
<tr>
<td width="15%" class="listn"><?php echo gettext("Resolve Flowbits"); ?></td>
- <td width="85%"><input name="autoflowbits" id="autoflowbitrules" type="checkbox" value="on" <?php if ($a_nat[$id]['autoflowbitrules'] == "on") echo "checked"; ?>/></td>
+ <td width="85%"><input name="autoflowbits" id="autoflowbitrules" type="checkbox" value="on"
+ <?php if ($a_nat[$id]['autoflowbitrules'] == "on" || empty($a_nat[$id]['autoflowbitrules'])) echo "checked"; ?>/>
+ &nbsp;&nbsp;<span class="vexpl"><?php echo gettext("If checked, Snort will auto-enable rules required for checked flowbits. ");
+ echo gettext("The Default is "); ?><strong><?php echo gettext("Checked."); ?></strong></span></td>
</tr>
<tr>
<td width="15%" class="vncell">&nbsp;</td>
<td width="85%" class="vtable">
- <?php echo gettext("If ticked, Snort will examine the enabled rules in your chosen " .
+ <?php echo gettext("Snort will examine the enabled rules in your chosen " .
"rule categories for checked flowbits. Any rules that set these dependent flowbits will " .
- "be automatically enabled and added to the list of files in the interface rules directory."); ?><br/><br/></td>
+ "be automatically enabled and added to the list of files in the interface rules directory."); ?><br/></td>
</tr>
<tr>
<td width="15%" class="listn"><?php echo gettext("Auto Flowbit Rules"); ?></td>
- <td width="85%"><input type="button" class="formbtn" value="View" onclick="popup('snort_rules_edit.php?id=<?=$id;?>&openruleset=<?=$flowbit_rules_file;?>')" <?php echo $btn_view_flowb_rules; ?>/></td>
+ <td width="85%"><input type="button" class="formbtns" value="View" onclick="parent.location='snort_rules_flowbits.php?id=<?=$id;?>'" <?php echo $btn_view_flowb_rules; ?>/>
+ &nbsp;&nbsp;<span class="vexpl"><?php echo gettext("Click to view auto-enabled rules required to satisfy flowbit dependencies"); ?></span></td>
</tr>
<tr>
<td width="15%">&nbsp;</td>
<td width="85%">
- <?php echo gettext("Click to view auto-enabled rules required to satisfy flowbit " .
- "dependencies from the selected rule categories below. Auto-enabled rules generating unwanted alerts " .
- "should have their GID:SID added to the Suppression List for the interface."); ?><br/><br/></td>
+ <?php printf(gettext("%sNote: %sAuto-enabled rules generating unwanted alerts should have their GID:SID added to the Suppression List for the interface."), '<span class="red"><strong>', '</strong></span>'); ?>
+ <br/></td>
</tr>
</table>
</td>
</tr>
<tr>
- <td colspan="6" class="listtopic"><?php echo gettext("Snort IPS Policy Selection"); ?><br/></td>
+ <td colspan="6" class="listtopic"><?php echo gettext("Snort IPS Policy selection"); ?><br/></td>
</tr>
<tr>
<td colspan="6" valign="center" class="listn">
- <table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <table width="100%" border="0" cellpadding="2" cellspacing="2">
<tr>
<td width="15%" class="listn"><?php echo gettext("Use IPS Policy"); ?></td>
<td width="85%"><input name="ips_policy_enable" id="ips_policy_enable" type="checkbox" value="on" <?php if ($a_nat[$id]['ips_policy_enable'] == "on") echo "checked"; ?>
- <?php if ($snortdownload == "off") echo "disabled" ?> onClick="enable_change()"/></td>
+ <?php if ($snortdownload == "off") echo "disabled" ?> onClick="enable_change()"/>&nbsp;&nbsp;<span class="vexpl">
+ <?php echo gettext("If checked, Snort will use rules from the pre-defined IPS policy selected below."); ?></span></td>
</tr>
<tr>
<td width="15%" class="vncell">&nbsp;</td>
<td width="85%" class="vtable">
- <?php echo gettext("If ticked, Snort will use rules from the pre-defined IPS policy " .
- "selected below. You must be using the Snort VRT rules to use this option."); ?><br/>
+ <?php printf(gettext("%sNote:%s You must be using the Snort VRT rules to use this option."),'<span class="red"><strong>','</strong></span>'); ?>
<?php echo gettext("Selecting this option disables manual selection of Snort VRT categories in the list below, " .
"although Emerging Threats categories may still be selected if enabled on the Global Settings tab. " .
- "These will be added to the pre-defined Snort IPS policy rules from the Snort VRT."); ?><br><br/></td>
+ "These will be added to the pre-defined Snort IPS policy rules from the Snort VRT."); ?><br/></td>
</tr>
<tr>
<td width="15%" class="listn"><?php echo gettext("IPS Policy"); ?></td>
@@ -311,43 +354,83 @@ function enable_change()
<option value="balanced" <?php if ($pconfig['ips_policy'] == "balanced") echo "selected"; ?>><?php echo gettext("Balanced"); ?></option>
<option value="security" <?php if ($pconfig['ips_policy'] == "security") echo "selected"; ?>><?php echo gettext("Security"); ?></option>
</select>
- </td>
+ &nbsp;&nbsp;<span class="vexpl"><?php echo gettext("Snort IPS policies are: Connectivity, Balanced or Security."); ?></span></td>
</tr>
<tr>
<td width="15%">&nbsp;</td>
<td width="85%">
- <?php echo gettext("Snort IPS policies are: Connectivity, Balanced or Security. " .
- "Connectivity blocks most major threats with few or no false positives. Balanced is a good starter policy. It " .
- "is speedy, has good base coverage level, and covers most threats of the day. It includes all rules in Connectivity. " .
- "Security is a stringent policy. It contains everything in the first two plus policy-type rules such as Flash in an Excel file."); ?><br/><br/></td>
+ <?php echo gettext("Connectivity blocks most major threats with few or no false positives. " .
+ "Balanced is a good starter policy. It is speedy, has good base coverage level, and covers " .
+ "most threats of the day. It includes all rules in Connectivity." .
+ "Security is a stringent policy. It contains everything in the first two " .
+ "plus policy-type rules such as Flash in an Excel file."); ?><br/></td>
</tr>
</table>
</td>
</tr>
<tr>
- <td colspan="6" class="listtopic"><?php echo gettext("Check the rulesets that you would like Snort to load at startup."); ?><br/></td>
+ <td colspan="6" class="listtopic"><?php echo gettext("Select the rulesets Snort will load at startup"); ?><br/></td>
</tr>
<tr>
- <td colspan="1" align="middle" valign="center"><br/><input value="Select All" type="submit" name="selectall" id="selectall" /><br/></td>
- <td colspan="1" align="middle" valign="center"><br/><input value="Unselect All" type="submit" name="unselectall" id="selectall" /><br/></td>
- <td colspan="1" align="middle" valign="center"><br/><input value="Save" class="formbtn" type="submit" name="Submit" id="Submit" /></td>
- <td colspan="3" valign="center"><?php echo gettext("Click to save changes and auto-resolve flowbit rules (if option is selected above)"); ?><br/></td>
+ <td colspan="6">
+ <table width=90% align="center" border="0" cellpadding="2" cellspacing="0">
+ <tr height="45px">
+ <td valign="middle"><input value="Select All" class="formbtns" type="submit" name="selectall" id="selectall" title="<?php echo gettext("Add all to enforcing rules"); ?>"/></td>
+ <td valign="middle"><input value="Unselect All" class="formbtns" type="submit" name="unselectall" id="unselectall" title="<?php echo gettext("Remove all from enforcing rules"); ?>"/></td>
+ <td valign="middle"><input value=" Save " class="formbtns" type="submit" name="Submit" id="Submit" title="<?php echo gettext("Save changes to enforcing rules and rebuild"); ?>"/></td>
+ <td valign="middle"><span class="vexpl"><?php echo gettext("Click to save changes and auto-resolve flowbit rules (if option is selected above)"); ?></span></td>
+ </tr>
+ </table>
</tr>
- <tr> <td colspan="6">&nbsp;</td> </tr>
+ <?php if ($no_community_files)
+ $msg_community = "NOTE: Snort Community Rules have not been downloaded. Perform a Rules Update to enable them.";
+ else
+ $msg_community = "Snort GPLv2 Community Rules (VRT certified)";
+ ?>
+ <?php if ($snortcommunitydownload == 'on'): ?>
<tr id="frheader">
- <?php if ($emergingdownload == 'on'): ?>
- <td width="5%" class="listhdrr"><?php echo gettext("Enabled"); ?></td>
+ <td width="5%" class="listhdrr"><?php echo gettext("Enabled"); ?></td>
+ <td colspan="5" class="listhdrr"><?php echo gettext('Ruleset: Snort GPLv2 Community Rules');?></td>
+ </tr>
+ <?php if (in_array("GPLv2_community.rules", $enabled_rulesets_array)): ?>
+ <tr>
+ <td width="5" class="listr" align="center" valign="top">
+ <input type="checkbox" name="toenable[]" value="GPLv2_community.rules" checked="checked"/></td>
+ <td colspan="5" class="listr"><a href='snort_rules.php?id=<?=$id;?>&openruleset=GPLv2_community.rules'><?php echo gettext("{$msg_community}"); ?></a></td>
+ </tr>
+ <?php else: ?>
+ <tr>
+ <td width="5" class="listr" align="center" valign="top">
+ <input type="checkbox" name="toenable[]" value="GPLv2_community.rules" <?php if ($snortcommunitydownload == 'off') echo "disabled"; ?>/></td>
+ <td colspan="5" class="listr"><?php echo gettext("{$msg_community}"); ?></td>
+ </tr>
+
+ <?php endif; ?>
+ <?php endif; ?>
+
+ <?php if ($no_emerging_files)
+ $msg_emerging = "downloaded.";
+ else
+ $msg_emerging = "enabled.";
+ if ($no_snort_files)
+ $msg_snort = "downloaded.";
+ else
+ $msg_snort = "enabled.";
+ ?>
+ <tr id="frheader">
+ <?php if ($emergingdownload == 'on' && !$no_emerging_files): ?>
+ <td width="5%" class="listhdrr" align="center"><?php echo gettext("Enabled"); ?></td>
<td width="25%" class="listhdrr"><?php echo gettext('Ruleset: Emerging Threats');?></td>
<?php else: ?>
- <td colspan="2" width="30%" class="listhdrr"><?php echo gettext("Emerging rules have not been enabled"); ?></td>
+ <td colspan="2" align="center" width="30%" class="listhdrr"><?php echo gettext("Emerging Threats rules not {$msg_emerging}"); ?></td>
<?php endif; ?>
- <?php if ($snortdownload == 'on'): ?>
- <td width="5%" class="listhdrr"><?php echo gettext("Enabled"); ?></td>
- <td width="25%" class="listhdrr"><?php echo gettext('Ruleset: Snort');?></td>
- <td width="5%" class="listhdrr"><?php echo gettext("Enabled"); ?></td>
- <td width="25%" class="listhdrr"><?php echo gettext('Ruleset: Snort SO');?></td>
+ <?php if ($snortdownload == 'on' && !$no_snort_files): ?>
+ <td width="5%" class="listhdrr" align="center"><?php echo gettext("Enabled"); ?></td>
+ <td width="25%" class="listhdrr"><?php echo gettext('Ruleset: Snort Text Rules');?></td>
+ <td width="5%" class="listhdrr" align="center"><?php echo gettext("Enabled"); ?></td>
+ <td width="25%" class="listhdrr"><?php echo gettext('Ruleset: Snort SO Rules');?></td>
<?php else: ?>
- <td colspan="2" width="60%" class="listhdrr"><?php echo gettext("Snort rules have not been enabled"); ?></td>
+ <td colspan="4" align="center" width="60%" class="listhdrr"><?php echo gettext("Snort VRT rules have not been {$msg_snort}"); ?></td>
<?php endif; ?>
</tr>
<?php
@@ -451,11 +534,11 @@ function enable_change()
</td>
</tr>
<tr>
-<td colspan="6" class="vtable">&nbsp;<br/></td>
+<td colspan="6" class="vexpl">&nbsp;<br/></td>
</tr>
<tr>
- <td colspan="2" align="middle" valign="center"><br/><input value="Save" type="submit" name="Submit" id="Submit" class="formbtn" /></td>
- <td colspan="4" valign="center">&nbsp;<br><br/></td>
+ <td colspan="6" align="center" valign="middle">
+ <input value="Save" type="submit" name="Submit" id="Submit" class="formbtn" title=" <?php echo gettext("Click to Save changes and rebuild rules"); ?>"/></td>
</tr>
<?php endif; ?>
</table>
@@ -467,5 +550,38 @@ function enable_change()
<?php
include("fend.inc");
?>
+
+<script language="javascript" type="text/javascript">
+
+function wopen(url, name, w, h)
+{
+// Fudge factors for window decoration space.
+// In my tests these work well on all platforms & browsers.
+w += 32;
+h += 96;
+ var win = window.open(url,
+ name,
+ 'width=' + w + ', height=' + h + ', ' +
+ 'location=no, menubar=no, ' +
+ 'status=no, toolbar=no, scrollbars=yes, resizable=yes');
+ win.resizeTo(w, h);
+ win.focus();
+}
+
+function enable_change()
+{
+ var endis = !(document.iform.ips_policy_enable.checked);
+ document.iform.ips_policy.disabled=endis;
+
+ for (var i = 0; i < document.iform.elements.length; i++) {
+ if (document.iform.elements[i].type == 'checkbox') {
+ var str = document.iform.elements[i].value;
+ if (str.substr(0,6) == "snort_")
+ document.iform.elements[i].disabled = !(endis);
+ }
+ }
+}
+</script>
+
</body>
</html>
diff --git a/config/snort/snort_sync.xml b/config/snort/snort_sync.xml
new file mode 100755
index 00000000..14a13321
--- /dev/null
+++ b/config/snort/snort_sync.xml
@@ -0,0 +1,193 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd">
+<?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?>
+<packagegui>
+ <copyright>
+<![CDATA[
+/* $Id$ */
+/* ========================================================================== */
+/*
+snortsync.xml
+part of pfSense (http://www.pfSense.com)
+Copyright (C) 2013 Marcello Coutinho
+based on pfblocker_sync.xml
+All rights reserved.
+
+Based on m0n0wall (http://m0n0.ch/wall)
+Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+All rights reserved.
+*/
+/* ========================================================================== */
+/*
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code MUST retain the above copyright notice,
+this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form MUST reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+*/
+/* ========================================================================== */
+]]></copyright>
+ <description><![CDATA[Describe your package here]]></description>
+ <requirements>Describe your package requirements here</requirements>
+ <faq>Currently there are no FAQ items provided.</faq>
+ <name>snortsync</name>
+ <version>1.0</version>
+ <title>Snort: XMLRPC Sync (EXPERIMENTAL)</title>
+ <include_file>/usr/local/pkg/snort/snort.inc</include_file>
+ <tabs>
+ <tab>
+ <text>Snort Interfaces</text>
+ <url>/snort/snort_interfaces.php</url>
+ </tab>
+ <tab>
+ <text>Global Settings</text>
+ <url>/snort/snort_interfaces_global.php</url>
+ </tab>
+ <tab>
+ <text>Updates</text>
+ <url>/snort/snort_download_updates.php</url>
+ </tab>
+ <tab>
+ <text>Alerts</text>
+ <url>/snort/snort_alerts.php</url>
+ </tab>
+ <tab>
+ <text>Blocked</text>
+ <url>/snort/snort_blocked.php</url>
+ </tab>
+ <tab>
+ <text>Whitelists</text>
+ <url>/snort/snort_interfaces_whitelist.php</url>
+ </tab>
+ <tab>
+ <text>Suppress</text>
+ <url>/snort/snort_interfaces_suppress.php</url>
+ </tab>
+ <tab>
+ <text>Sync</text>
+ <url>/pkg_edit.php?xml=snort/snort_sync.xml</url>
+ <active/>
+ </tab>
+ </tabs>
+ <fields>
+ <field>
+ <name>Snort Package XMLRPC Sync Settings</name>
+ <type>listtopic</type>
+ </field>
+ <field>
+ <fielddescr>Enable Sync</fielddescr>
+ <fieldname>varsynconchanges</fieldname>
+ <description><![CDATA[All changes will be synced with apply config to the IPs listed below if this option is checked.<br/><br/>
+ <b>Important:</b> While using "Sync to hosts defined below", only sync from host A to B, A to C but <b>do not</B> enable XMLRPC sync <b>to</b> A. This will result in a loop!]]></description>
+ <type>select</type>
+ <required/>
+ <default_value>disabled</default_value>
+ <options>
+ <option><name>Sync to configured system backup server</name><value>auto</value></option>
+ <option><name>Sync to host(s) defined below</name><value>manual</value></option>
+ <option><name>Do not sync this package configuration</name><value>disabled</value></option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>XMLRPC Timeout</fielddescr>
+ <fieldname>varsynctimeout</fieldname>
+ <description><![CDATA[Timeout in seconds for the XMLRPC timeout. Default: 150]]></description>
+ <type>input</type>
+ <default_value>150</default_value>
+ <size>5</size>
+ </field>
+
+ <field>
+ <fielddescr>Refresh Rule Sets</fielddescr>
+ <fieldname>vardownloadrules</fieldname>
+ <description><![CDATA[Ask target hosts to refresh rule sets files on each sync operation.<br/><br/>
+ During each Snort package sync operation, ask the target remote host to check for
+ a new set of posted rule sets files and refresh the local copies if necessary. The default is
+ to refresh the files if newer versions have been posted.<br/><br/>
+ <b>Note: </b>The sync process will wait for the rules download and rebuild to finish on the target remote host before returning.]]></description>
+ <type>select</type>
+ <default_value>yes</default_value>
+ <options>
+ <option><name>Signal target host to refresh rules files</name><value>yes</value></option>
+ <option><name>Do NOT ask target host to refresh rules files</name><value>no</value></option>
+ </options>
+ </field>
+
+ <field>
+ <fielddescr>Replication Targets</fielddescr>
+ <fieldname>none</fieldname>
+ <type>rowhelper</type>
+ <rowhelper>
+ <rowhelperfield>
+ <fielddescr>Enable</fielddescr>
+ <fieldname>varsyncdestinenable</fieldname>
+ <description><![CDATA[Enable this host as a replication target]]></description>
+ <type>checkbox</type>
+ </rowhelperfield>
+ <rowhelperfield>
+ <fielddescr>Protocol</fielddescr>
+ <fieldname>varsyncprotocol</fieldname>
+ <description><![CDATA[Choose the protocol of the destination host. Probably <b>http</b> or <b>https</b>]]></description>
+ <type>select</type>
+ <default_value>HTTP</default_value>
+ <options>
+ <option><name>HTTP</name><value>http</value></option>
+ <option><name>HTTPS</name><value>https</value></option>
+ </options>
+ </rowhelperfield>
+ <rowhelperfield>
+ <fielddescr>IP-Address</fielddescr>
+ <fieldname>varsyncipaddress</fieldname>
+ <description><![CDATA[IP Address of the destination host.]]></description>
+ <type>input</type>
+ <size>15</size>
+ </rowhelperfield>
+ <rowhelperfield>
+ <fielddescr>Port</fielddescr>
+ <fieldname>varsyncport</fieldname>
+ <description><![CDATA[Choose the sync port of the destination host.]]></description>
+ <type>input</type>
+ <size>3</size>
+ </rowhelperfield>
+ <rowhelperfield>
+ <fielddescr>Admin Password</fielddescr>
+ <fieldname>varsyncpassword</fieldname>
+ <description><![CDATA[Password of the user "admin" on the destination host.]]></description>
+ <type>password</type>
+ <size>20</size>
+ </rowhelperfield>
+ <rowhelperfield>
+ <fielddescr>Start Snort</fielddescr>
+ <fieldname>varsyncsnortstart</fieldname>
+ <description><![CDATA[Start Snort on target host if not already running.]]></description>
+ <type>checkbox</type>
+ <value>ON</value>
+ </rowhelperfield>
+ </rowhelper>
+ </field>
+ <field>
+ <name>WARNING: This feature is considered experimental and not recommended for production use</name>
+ <type>listtopic</type>
+ </field>
+ </fields>
+ <custom_delete_php_command>
+ </custom_delete_php_command>
+ <custom_php_resync_config_command>
+ write_config();snort_sync_on_changes();
+ </custom_php_resync_config_command>
+</packagegui>