From 8d98e14a7f6ec1dc0a62fa50c2cb5bb5e20afb1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ermal=20Lu=E7i?= Date: Fri, 26 Feb 2010 16:04:05 +0000 Subject: Ticket #383. Escape special javascript characters. It would be wiser to prevent them from being used on certificate names. --- config/openvpn-client-export/vpn_openvpn_export.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config') diff --git a/config/openvpn-client-export/vpn_openvpn_export.php b/config/openvpn-client-export/vpn_openvpn_export.php index 2af4da59..95637c26 100755 --- a/config/openvpn-client-export/vpn_openvpn_export.php +++ b/config/openvpn-client-export/vpn_openvpn_export.php @@ -306,7 +306,7 @@ servers[][1][] = new Array(); servers[][1][][0] = ''; servers[][1][][1] = ''; servers[][1][][2] = ''; -servers[][1][][3] = ''; +servers[][1][][3] = ''; -- cgit v1.2.3 From 4b887e8bcd0237a72faa9fcfacaf8120b0cd123d Mon Sep 17 00:00:00 2001 From: Chris Buechler Date: Sun, 28 Feb 2010 21:28:06 -0500 Subject: fix text --- config/openvpn-client-export/vpn_openvpn_export.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'config') diff --git a/config/openvpn-client-export/vpn_openvpn_export.php b/config/openvpn-client-export/vpn_openvpn_export.php index 95637c26..8a30d6b6 100755 --- a/config/openvpn-client-export/vpn_openvpn_export.php +++ b/config/openvpn-client-export/vpn_openvpn_export.php @@ -505,7 +505,7 @@ function useproxy_changed(obj) { @@ -584,7 +584,7 @@ function useproxy_changed(obj) { -   Ip Addr :  +   IP Address :  -- cgit v1.2.3 From 05a1116c3d44fe5674bd4e9ea6cf54def8f959b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ermal=20Lu=E7i?= Date: Mon, 1 Mar 2010 21:07:28 +0000 Subject: The tls-auth needs a 1 at the end of the key. --- config/openvpn-client-export/openvpn-client-export.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'config') diff --git a/config/openvpn-client-export/openvpn-client-export.inc b/config/openvpn-client-export/openvpn-client-export.inc index 15096e6c..a2a59fb0 100755 --- a/config/openvpn-client-export/openvpn-client-export.inc +++ b/config/openvpn-client-export/openvpn-client-export.inc @@ -181,7 +181,7 @@ function openvpn_client_export_config($srvid, $usrid, $crtid, $useaddr, $usetoke if($nokeys == false) { if ($settings['tls']) - $conf .= "tls-auth {$prefix}-tls.key\n"; + $conf .= "tls-auth {$prefix}-tls.key 1\n"; } // add optional settings @@ -359,7 +359,7 @@ EOF; $configfile = "{$tempdir}/config.conf"; $conf .= << Date: Mon, 1 Mar 2010 19:27:05 -0700 Subject: Remove unused files for freeswitch_dev pkg, and update vhosts package fix http and add pcre to the php.ini so that preg works. --- config/vhosts/vhosts.inc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'config') diff --git a/config/vhosts/vhosts.inc b/config/vhosts/vhosts.inc index 3602b40a..9f394fb0 100644 --- a/config/vhosts/vhosts.inc +++ b/config/vhosts/vhosts.inc @@ -136,6 +136,7 @@ function vhosts_sync_package_php() $vhostarray_http[$x]['privatekey'] = ''; $vhostarray_http[$x]['enabled'] = $rowhelper['enabled']; $vhostarray_http[$x]['description'] = $rowhelper['description']; + $server_port = $rowhelper['port']; } $x++; } @@ -267,7 +268,7 @@ function vhosts_sync_package_php() $tmp .= "######### Options that are good to be but not neccesary to be changed #######\n"; $tmp .= "\n"; $tmp .= "## bind to port (default: 80)\n"; - $tmp .= "#server.port = 8001\n"; + $tmp .= "server.port = $server_port\n"; $tmp .= "\n"; $tmp .= "#the regex method isn't working\n"; $tmp .= "#\$HTTP[\"host\"] =~ \"(^|\\.)host01\\.com\$\" {\n"; @@ -321,9 +322,6 @@ function vhosts_sync_package_php() $tmp .= "\$SERVER[\"socket\"] == \"".$ipaddress.":".$port."\" {\n"; } - if (strlen($rowhelper['description']) > 0) { - $tmp .= "# ".$rowhelper['description']." \n\n"; - } $tmp .= " \$HTTP[\"host\"] == \"".$host."\" {\n"; $tmp .= " server.document-root = \"/usr/local/vhosts/".$directory."\"\n"; -- cgit v1.2.3 From 0e1bff71ad76325f6eb88335235ea0cbe52371cd Mon Sep 17 00:00:00 2001 From: mcrane Date: Mon, 1 Mar 2010 19:45:47 -0700 Subject: Get rid of the lan sip profile which confused people and made things harder and minor increment to the version. --- config/freeswitch/freeswitch.inc | 38 ---------------------------- config/freeswitch_dev/v_config.inc | 51 +++----------------------------------- 2 files changed, 4 insertions(+), 85 deletions(-) (limited to 'config') diff --git a/config/freeswitch/freeswitch.inc b/config/freeswitch/freeswitch.inc index aa3e4b74..147125a7 100644 --- a/config/freeswitch/freeswitch.inc +++ b/config/freeswitch/freeswitch.inc @@ -263,42 +263,6 @@ function byte_convert( $bytes ) { return round($bytes/pow($convention,$e),2).' '.$s[$e]; } -function lan_sip_profile() -{ - global $config; - clearstatcache(); - - //if the lan directory does not exist then create it - if (!is_dir('/usr/local/freeswitch/conf/sip_profiles/lan/')) { - exec("mkdir /usr/local/freeswitch/conf/sip_profiles/lan/"); - } - - //create the LAN profile if it doesn't exist - if (!file_exists('/usr/local/freeswitch/conf/sip_profiles/lan.xml')) { - $lan_ip = $config['interfaces']['lan']['ipaddr']; - if (strlen($lan_ip) > 0) { - exec("cp /usr/local/freeswitch/conf/sip_profiles/internal.xml /usr/local/freeswitch/conf/sip_profiles/lan.xml"); - - $filename = "/usr/local/freeswitch/conf/sip_profiles/lan.xml"; - $handle = fopen($filename,"rb"); - $contents = fread($handle, filesize($filename)); - fclose($handle); - - $handle = fopen($filename,"w"); - $contents = str_replace("", "", $contents); - $contents = str_replace("", "", $contents); - $contents = str_replace("", "", $contents); - $contents = str_replace("", "", $contents); - $contents = str_replace("", "", $contents); - fwrite($handle, $contents); - unset($contents); - fclose($handle); - unset($filename); - } - } - -} - function ListFiles($dir) { if($dh = opendir($dir)) { @@ -3741,8 +3705,6 @@ function freeswitch_php_install_command() "stop" => "/usr/local/freeswitch/bin/./freeswitch -stop" ) ); - - lan_sip_profile(); sync_package_freeswitch(); $handle = popen("/usr/local/etc/rc.d/freeswitch.sh start", "r"); diff --git a/config/freeswitch_dev/v_config.inc b/config/freeswitch_dev/v_config.inc index 596fb00f..a508cefc 100644 --- a/config/freeswitch_dev/v_config.inc +++ b/config/freeswitch_dev/v_config.inc @@ -319,46 +319,6 @@ function byte_convert( $bytes ) { return round($bytes/pow($convention,$e),2).' '.$s[$e]; } -function lan_sip_profile() -{ - global $config; - $v_settings_array = $config['installedpackages']['freeswitchsettings']['config'][0]; - foreach($v_settings_array as $name => $value) { - $$name = $value; - } - clearstatcache(); - - //if the lan directory does not exist then create it - if (!is_dir($v_conf_dir.'/sip_profiles/lan/')) { - exec("mkdir ".$v_conf_dir."/sip_profiles/lan/"); - } - - //create the LAN profile if it doesn't exist - if (!file_exists($v_conf_dir.'/sip_profiles/lan.xml')) { - $lan_ip = $config['interfaces']['lan']['ipaddr']; - if (strlen($lan_ip) > 0) { - exec("cp ".$v_conf_dir."/sip_profiles/internal.xml ".$v_conf_dir."/sip_profiles/lan.xml"); - - $filename = $v_conf_dir."/sip_profiles/lan.xml"; - $handle = fopen($filename,"rb"); - $contents = fread($handle, filesize($filename)); - fclose($handle); - - $handle = fopen($filename,"w"); - $contents = str_replace("", "", $contents); - $contents = str_replace("", "", $contents); - $contents = str_replace("", "", $contents); - $contents = str_replace("", "", $contents); - $contents = str_replace("", "", $contents); - fwrite($handle, $contents); - unset($contents); - fclose($handle); - unset($filename); - } - } - -} - function ListFiles($dir) { if($dh = opendir($dir)) { @@ -3923,23 +3883,20 @@ function v_install_phase_1() unlink_if_exists($v_conf_dir."/directory/default/brian.xml"); unlink_if_exists($v_conf_dir."/directory/default/example.com.xml"); unlink_if_exists($v_conf_dir."/dialplan/default/99999_enum.xml"); - - + write_rcfile(array( "file" => $v_name.".sh", "start" => $v_dir."/bin/./".$v_name." -nc", "stop" => $v_dir."/bin/./".$v_name." -stop" ) ); - - lan_sip_profile(); $static_output = 'Synchronize the config'; update_output_window($static_output); - + sync_package_freeswitch(); - + $static_output = 'Start the Service'; update_output_window($static_output); $handle = popen($v_startup_script_dir."/freeswitch.sh start", "r"); @@ -3951,7 +3908,7 @@ function v_install_phase_1() conf_mount_ro(); config_unlock(); - + } -- cgit v1.2.3 From 558eaefc6d866396decaea9ea25aedff1578d563 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ermal=20Lu=E7i?= Date: Tue, 2 Mar 2010 18:45:00 +0000 Subject: Remove check with 3rd party authenticate backends it does not make sense. --- config/openvpn-client-export/vpn_openvpn_export.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'config') diff --git a/config/openvpn-client-export/vpn_openvpn_export.php b/config/openvpn-client-export/vpn_openvpn_export.php index 8a30d6b6..042b2a9f 100755 --- a/config/openvpn-client-export/vpn_openvpn_export.php +++ b/config/openvpn-client-export/vpn_openvpn_export.php @@ -67,8 +67,6 @@ foreach($a_server as $sindex => & $server) { $ras_user[] = $ras_userent; } } - if (!count($ras_user)) - continue; $ras_serverent = array(); $prot = $server['protocol']; $port = $server['local_port']; -- cgit v1.2.3 From 3ec4ee84fc38b83577ea1f80a07f4c7d8a35af74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ermal=20Lu=E7i?= Date: Tue, 2 Mar 2010 19:40:13 +0000 Subject: Fix typo. --- config/openospfd/openospfd.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'config') diff --git a/config/openospfd/openospfd.inc b/config/openospfd/openospfd.inc index 6d50cce9..d64e8774 100644 --- a/config/openospfd/openospfd.inc +++ b/config/openospfd/openospfd.inc @@ -91,7 +91,7 @@ function ospfd_install_conf() { $ifconfigs .= "\t\tauth-type crypt\n"; $ifconfigs .= "\t\tauth-md 1 \"" . substr($conf['password'], 0, 15) . "\"\n"; $ifconfigs .= "\t\tauth-md-keyid 1\n"; - } else if (!empty($conf['passward'])) { + } else if (!empty($conf['password'])) { $options_present = true; $ifconfigs .= "\t\tauth-type simple\n"; $ifconfigs .= "\t\tauth-key \"" . substr($conf['password'], 0, 7) . "\"\n"; @@ -190,7 +190,7 @@ function ospfd_put_raw_config($conffile) { else { $config['installedpackages']['ospfd']['rawconfig'] = array(); $config['installedpackages']['ospfd']['rawconfig']['item'] = explode("\n",$_POST['ospfd_raw']); - //$config['installedpackages']['ospfd']['rawconfig'] = $conffile; + $config['installedpackages']['ospfd']['rawconfig'] = $conffile; } } -- cgit v1.2.3 From 9aef7a65f6bc406c34331af2f0edbf794a4920de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ermal=20Lu=E7i?= Date: Tue, 2 Mar 2010 20:03:30 +0000 Subject: Add neccessary file. --- config/openospfd/openospfd.xml | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'config') diff --git a/config/openospfd/openospfd.xml b/config/openospfd/openospfd.xml index fea7e67f..3088084c 100644 --- a/config/openospfd/openospfd.xml +++ b/config/openospfd/openospfd.xml @@ -9,6 +9,11 @@ 077 http://www.pfsense.com/packages/config/openospfd/openospfd.inc + + /usr/local/pkg/ + 077 + http://www.pfsense.com/packages/config/openbgpd/openospfd_interfaces.xml + OSPFd Modify ospfd settings. -- cgit v1.2.3 From 149e155a77852b5c6ab503fe509e8fb1a221ce76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ermal=20Lu=E7i?= Date: Wed, 3 Mar 2010 00:26:38 +0000 Subject: Allow config to be exported when using only server authentication based only on user/pass. --- .../openvpn-client-export.inc | 136 +++++++++++++-------- .../openvpn-client-export/vpn_openvpn_export.php | 62 ++++++++-- 2 files changed, 135 insertions(+), 63 deletions(-) (limited to 'config') diff --git a/config/openvpn-client-export/openvpn-client-export.inc b/config/openvpn-client-export/openvpn-client-export.inc index a2a59fb0..576a2a6e 100755 --- a/config/openvpn-client-export/openvpn-client-export.inc +++ b/config/openvpn-client-export/openvpn-client-export.inc @@ -109,10 +109,12 @@ function openvpn_client_export_config($srvid, $usrid, $crtid, $useaddr, $usetoke } // lookup user info - $user =& $config['system']['user'][$usrid]; - if (!$user) { - $input_errors[] = "Could not find user settings."; - return false; + if ($usrid) { + $user =& $config['system']['user'][$usrid]; + if (!$user) { + $input_errors[] = "Could not find user settings."; + return false; + } } // determine basic variables @@ -141,7 +143,8 @@ function openvpn_client_export_config($srvid, $usrid, $crtid, $useaddr, $usetoke $conf .= "persist-key\n"; $conf .= "proto {$proto}\n"; $conf .= "cipher {$cipher}\n"; - $conf .= "tls-client\n"; + if ($nokeys == false) + $conf .= "tls-client\n"; $conf .= "client\n"; $conf .= "resolv-retry infinite\n"; $conf .= "remote {$server_host} {$server_port}\n"; @@ -177,7 +180,8 @@ function openvpn_client_export_config($srvid, $usrid, $crtid, $useaddr, $usetoke } else { $conf .= "pkcs12 {$prefix}.p12\n"; } - } + } else if ($settings['mode'] == "server_user") + $conf .= "ca {$prefix}-ca.crt\n"; if($nokeys == false) { if ($settings['tls']) @@ -194,33 +198,48 @@ function openvpn_client_export_config($srvid, $usrid, $crtid, $useaddr, $usetoke } function openvpn_client_export_installer($srvid, $usrid, $crtid, $useaddr, $usetoken, $outpass, $proxy) { - global $config, $g; + global $config, $g, $input_errors; $ovpndir = "/usr/local/share/openvpn"; $workdir = "{$ovpndir}/client-export"; // lookup server settings $settings = $config['openvpn']['openvpn-server'][$srvid]; - if (empty($settings)) + if (empty($settings)) { + $input_errors[] = "Could not find a valid server config for id: {$srvid}"; return false; - if ($settings['disable']) + } + if ($settings['disable']) { + $input_errors[] = "This server is disabled."; return false; + } + + $nokeys = false; // lookup server certificate info $server_cert =& lookup_cert($settings['certref']); $server_ca =& lookup_ca($server_cert['caref']); - if (!$server_cert || !$server_ca) + if (!$server_cert || !$server_ca) { + $input_errors[] = "Could not find a valid certificate."; return false; + } // lookup user info - $user =& $config['system']['user'][$usrid]; - if (!$user) - return false; + if ($usrid) { + $user =& $config['system']['user'][$usrid]; + if (!$user) { + $input_errors[] = "Could not find the details about userid: {$usrid}"; + return false; + } + } // lookup user certificate info - $cert =& $user['cert'][$crtid]; - if (!$cert) - return false; + if ($settings['mode'] != "server_user") { + $cert =& $user['cert'][$crtid]; + if (!$cert) + return false; + } else + $nokeys = true; // create template directory $tempdir = $g['tmp_path'] . "/openvpn-export-".uniqid(); @@ -243,31 +262,35 @@ function openvpn_client_export_installer($srvid, $usrid, $crtid, $useaddr, $uset $pwdfle .= "{$proxy['password']}\n"; file_put_contents("{$confdir}/{$proxy['passwdfile']}", $pwdfle); } - $conf = openvpn_client_export_config($srvid, $usrid, $crtid, $useaddr, $usetoken, false, $proxy); - if (!$conf) + $conf = openvpn_client_export_config($srvid, $usrid, $crtid, $useaddr, $usetoken, $nokeys, $proxy); + if (!$conf) { + $input_errors[] = "Could not create a config to export."; return false; + } file_put_contents($cfgfile, $conf); - // write key files $cafile = "{$tempdir}/config/{$prefix}-ca.crt"; file_put_contents($cafile, base64_decode($server_ca['crt'])); - $crtfile = "{$tempdir}/config/{$prefix}-{$user['name']}.crt"; - file_put_contents($crtfile, base64_decode($cert['crt'])); - $keyfile = "{$tempdir}/config/{$prefix}-{$user['name']}.key"; - file_put_contents($keyfile, base64_decode($cert['prv'])); - if ($settings['tls']) { - $tlsfile = "{$tempdir}/config/{$prefix}-tls.key"; - file_put_contents($tlsfile, base64_decode($settings['tls'])); + // write key files + if ($settings['mode'] != "server_user") { + $crtfile = "{$tempdir}/config/{$prefix}-{$user['name']}.crt"; + file_put_contents($crtfile, base64_decode($cert['crt'])); + $keyfile = "{$tempdir}/config/{$prefix}-{$user['name']}.key"; + file_put_contents($keyfile, base64_decode($cert['prv'])); + if ($settings['tls']) { + $tlsfile = "{$tempdir}/config/{$prefix}-tls.key"; + file_put_contents($tlsfile, base64_decode($settings['tls'])); + } + + // convert to pkcs12 format + $p12file = "{$tempdir}/config/{$prefix}.p12"; + if ($usetoken) + openvpn_client_pem_to_pk12($p12file, $outpass, $crtfile, $keyfile); + else + openvpn_client_pem_to_pk12($p12file, $outpass, $crtfile, $keyfile, $cafile); } - // convert to pkcs12 format - $p12file = "{$tempdir}/config/{$prefix}.p12"; - if ($usetoken) - openvpn_client_pem_to_pk12($p12file, $outpass, $crtfile, $keyfile); - else - openvpn_client_pem_to_pk12($p12file, $outpass, $crtfile, $keyfile, $cafile); - // 7zip the configuration data chdir($tempdir); $files = "config "; @@ -278,6 +301,7 @@ function openvpn_client_export_installer($srvid, $usrid, $crtid, $useaddr, $uset $files .= "procchain-import"; else $files .= "procchain-standard"; + exec("/usr/local/libexec/p7zip/7z -y a archive.7z {$files}"); // create the final installer @@ -316,14 +340,18 @@ function viscosity_openvpn_client_config_exporter($srvid, $usrid, $crtid, $usead return false; // lookup user info - $user =& $config['system']['user'][$usrid]; - if (!$user) - return false; + if ($usrid) { + $user =& $config['system']['user'][$usrid]; + if (!$user) + return false; + } // lookup user certificate info - $cert =& $user['cert'][$crtid]; - if (!$cert) - return false; + if ($settings['mode'] != "server_user") { + $cert =& $user['cert'][$crtid]; + if (!$cert) + return false; + } // create template directory mkdir($tempdir, 0700, true); @@ -357,12 +385,15 @@ function viscosity_openvpn_client_config_exporter($srvid, $usrid, $crtid, $usead EOF; $configfile = "{$tempdir}/config.conf"; - $conf .= << & $server) { $ras_serverent['index'] = $sindex; $ras_serverent['name'] = $name; $ras_serverent['users'] = $ras_user; + $ras_serverent['mode'] = $server['mode']; $ras_server[] = $ras_serverent; } @@ -93,10 +94,20 @@ if($act == "conf") { $srvid = $_GET['srvid']; $usrid = $_GET['usrid']; $crtid = $_GET['crtid']; - if (($srvid === false) || ($usrid === false) || ($crtid === false)) { + if ($srvid === false) { + pfSenseHeader("vpn_openvpn_export.php"); + exit; + } else if (($config['openvpn']['openvpn-server'][$srvid]['mode'] != "server_user") && + (($usrid === false) || ($crtid === false))) { pfSenseHeader("vpn_openvpn_export.php"); exit; } + + if ($config['openvpn']['openvpn-server'][$srvid]['mode'] == "server_user") + $nokeys = true; + else + $nokeys = false; + if (empty($_GET['useaddr'])) { $error = true; $input_errors[] = "You need to specify an IP or hostname."; @@ -134,7 +145,7 @@ if($act == "conf") { } $exp_name = openvpn_client_export_prefix($srvid); - $exp_data = openvpn_client_export_config($srvid, $usrid, $crtid, $useaddr, $usetoken, false, $proxy); + $exp_data = openvpn_client_export_config($srvid, $usrid, $crtid, $useaddr, $usetoken, $nokeys, $proxy); if (!$exp_data) { $input_errors[] = "Failed to export config files!"; $error = true; @@ -156,10 +167,14 @@ if($act == "visc") { $srvid = $_GET['srvid']; $usrid = $_GET['usrid']; $crtid = $_GET['crtid']; - if (($srvid === false) || ($usrid === false) || ($crtid === false)) { - pfSenseHeader("vpn_openvpn_export.php"); - exit; - } + if ($srvid === false) { + pfSenseHeader("vpn_openvpn_export.php"); + exit; + } else if (($config['openvpn']['openvpn-server'][$srvid]['mode'] != "server_user") && + (($usrid === false) || ($crtid === false))) { + pfSenseHeader("vpn_openvpn_export.php"); + exit; + } if (empty($_GET['useaddr'])) { $error = true; $input_errors[] = "You need to specify an IP or hostname."; @@ -222,10 +237,14 @@ if($act == "inst") { $srvid = $_GET['srvid']; $usrid = $_GET['usrid']; $crtid = $_GET['crtid']; - if (($srvid === false) || ($usrid === false) || ($crtid === false)) { - pfSenseHeader("vpn_openvpn_export.php"); - exit; - } + if ($srvid === false) { + pfSenseHeader("vpn_openvpn_export.php"); + exit; + } else if (($config['openvpn']['openvpn-server'][$srvid]['mode'] != "server_user") && + (($usrid === false) || ($crtid === false))) { + pfSenseHeader("vpn_openvpn_export.php"); + exit; + } if (empty($_GET['useaddr'])) { $error = true; $input_errors[] = "You need to specify an IP or hostname."; @@ -299,6 +318,7 @@ var servers = new Array(); servers[] = new Array(); servers[][0] = ''; servers[][1] = new Array(); +servers[][2] = '';; & $user): ?> servers[][1][] = new Array(); servers[][1][][0] = ''; @@ -382,8 +402,10 @@ function download_begin(act, i) { var dlurl; dlurl = "/vpn_openvpn_export.php?act=" + act; dlurl += "&srvid=" + servers[index][0]; - dlurl += "&usrid=" + users[i][0]; - dlurl += "&crtid=" + users[i][1]; + if (users[i]) { + dlurl += "&usrid=" + users[i][0]; + dlurl += "&crtid=" + users[i][1]; + } dlurl += "&useaddr=" + useaddr; dlurl += "&usetoken=" + usetoken; if (usepass) @@ -425,6 +447,22 @@ function server_changed() { cell2.innerHTML += " / "; cell2.innerHTML += "Viscosity Bundle"; } + if (servers[index][2] == 'server_user') { + var row = table.insertRow(table.rows.length); + var cell0 = row.insertCell(0); + var cell1 = row.insertCell(1); + var cell2 = row.insertCell(2); + cell0.className = "listlr"; + cell0.innerHTML = "External authentication users"; + cell1.className = "listr"; + cell1.innerHTML = "none"; + cell2.className = "listr"; + cell2.innerHTML = "Configuration"; + cell2.innerHTML += " / "; + cell2.innerHTML += "Windows Installer"; + cell2.innerHTML += " / "; + cell2.innerHTML += "Viscosity Bundle"; + } } function useaddr_changed(obj) { -- cgit v1.2.3 From 2053c099e6e01cf9e5aff33204e153d0addd6f0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ermal=20Lu=E7i?= Date: Wed, 3 Mar 2010 01:01:21 +0000 Subject: Add tls-client to export. --- .../openvpn-client-export.inc | 30 ++++++++++------------ 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'config') diff --git a/config/openvpn-client-export/openvpn-client-export.inc b/config/openvpn-client-export/openvpn-client-export.inc index 576a2a6e..f113fb06 100755 --- a/config/openvpn-client-export/openvpn-client-export.inc +++ b/config/openvpn-client-export/openvpn-client-export.inc @@ -143,8 +143,7 @@ function openvpn_client_export_config($srvid, $usrid, $crtid, $useaddr, $usetoke $conf .= "persist-key\n"; $conf .= "proto {$proto}\n"; $conf .= "cipher {$cipher}\n"; - if ($nokeys == false) - $conf .= "tls-client\n"; + $conf .= "tls-client\n"; $conf .= "client\n"; $conf .= "resolv-retry infinite\n"; $conf .= "remote {$server_host} {$server_port}\n"; @@ -183,10 +182,8 @@ function openvpn_client_export_config($srvid, $usrid, $crtid, $useaddr, $usetoke } else if ($settings['mode'] == "server_user") $conf .= "ca {$prefix}-ca.crt\n"; - if($nokeys == false) { - if ($settings['tls']) - $conf .= "tls-auth {$prefix}-tls.key 1\n"; - } + if ($settings['tls']) + $conf .= "tls-auth {$prefix}-tls.key 1\n"; // add optional settings if ($settings['compression']) @@ -272,16 +269,17 @@ function openvpn_client_export_installer($srvid, $usrid, $crtid, $useaddr, $uset $cafile = "{$tempdir}/config/{$prefix}-ca.crt"; file_put_contents($cafile, base64_decode($server_ca['crt'])); + if ($settings['tls']) { + $tlsfile = "{$tempdir}/config/{$prefix}-tls.key"; + file_put_contents($tlsfile, base64_decode($settings['tls'])); + } + // write key files if ($settings['mode'] != "server_user") { $crtfile = "{$tempdir}/config/{$prefix}-{$user['name']}.crt"; file_put_contents($crtfile, base64_decode($cert['crt'])); $keyfile = "{$tempdir}/config/{$prefix}-{$user['name']}.key"; file_put_contents($keyfile, base64_decode($cert['prv'])); - if ($settings['tls']) { - $tlsfile = "{$tempdir}/config/{$prefix}-tls.key"; - file_put_contents($tlsfile, base64_decode($settings['tls'])); - } // convert to pkcs12 format $p12file = "{$tempdir}/config/{$prefix}.p12"; @@ -386,10 +384,10 @@ EOF; $configfile = "{$tempdir}/config.conf"; $conf .= "ca ca.crt\n"; + $conf .= "tls-auth ta.key 1\n"; if ($settings['mode'] != "server_user") { $conf .= << Date: Wed, 3 Mar 2010 21:05:56 +0000 Subject: Fix creation of interface settings written on config. Add passive option. Allow redistribute rules to be specified. --- config/openospfd/openospfd.inc | 15 ++++++++++++++- config/openospfd/openospfd.xml | 24 ++++++++++++++++++++++-- config/openospfd/openospfd_interfaces.xml | 6 ++++++ 3 files changed, 42 insertions(+), 3 deletions(-) (limited to 'config') diff --git a/config/openospfd/openospfd.inc b/config/openospfd/openospfd.inc index d64e8774..d38ec82f 100644 --- a/config/openospfd/openospfd.inc +++ b/config/openospfd/openospfd.inc @@ -54,13 +54,21 @@ function ospfd_install_conf() { if ($ospfd_conf['updatefib']) $conffile .= "fib-update no\n"; + if (is_array($ospfd_conf['row'])) { + foreach ($ospfd_conf['row'] as $redistr) { + if (isset($redistr['redistribute'])) + $conffile .= "no "; + $conffile .= "redistribute {$redistr['routevalue']}\n"; + } + } + if ($ospfd_conf['redistributeconnectedsubnets']) $conffile .= "redistribute connected\n"; if ($ospfd_conf['redistributedefaultroute']) $conffile .= "redistribute default\n"; - if ($ospfd_conf['resdistributestatic']) + if ($ospfd_conf['redistributestatic']) $conffile .= "redistribute static\n"; if ($ospfd_conf['spfholdtime']) @@ -78,6 +86,7 @@ function ospfd_install_conf() { foreach ($config['installedpackages']['ospfdinterfaces']['config'] as $conf) { $conffile .= "\tinterface " . $config['interfaces'][$conf['interface']]['if']; $options_present = false; + $ifconfigs = ""; if (!empty($conf['metric'])) { $options_present = true; $ifconfigs .= "\t\tmetric {$conf['metric']}\n"; @@ -108,6 +117,10 @@ function ospfd_install_conf() { $options_present = true; $ifconfigs .= "\t\trouter-dead-time {$conf['deadtimer']}\n"; } + if (!empty($conf['passive'])) { + $options_present = true; + $ifconfigs .= "\t\tpassive\n"; + } if (!empty($ifconfigs)) { $conffile .= " {\n {$ifconfigs} \n"; if ($options_present == true) diff --git a/config/openospfd/openospfd.xml b/config/openospfd/openospfd.xml index 3088084c..a5bc100c 100644 --- a/config/openospfd/openospfd.xml +++ b/config/openospfd/openospfd.xml @@ -54,7 +54,7 @@ Update FIB (Routing table) updatefib - Enables the updating of the host routing table + Disables the updating of the host routing table(turns into stub router). checkbox @@ -71,7 +71,7 @@ Redistribute static - resdistributestatic + redistributestatic Enables the redistribution of static routes checkbox @@ -93,6 +93,26 @@ If set to yes, decisions regarding AS-external routes are evaluated according to RFC 1583. The default is no. checkbox + + This rules will take precedence over any other redistribute option specified above. + none + rowhelper + + + Disable Redistribute + redistribute + Redistribute rules. + checkbox + 20 + + + Route value + routevalue + input + 25 + + + ospfd_install_conf(); diff --git a/config/openospfd/openospfd_interfaces.xml b/config/openospfd/openospfd_interfaces.xml index b8f2522e..ea4c0dfb 100644 --- a/config/openospfd/openospfd_interfaces.xml +++ b/config/openospfd/openospfd_interfaces.xml @@ -62,6 +62,12 @@ 30 input + + Interface is Passive + passive + Prevent transmission and reception of OSPF packets on this interface. The specified interface will be announced as a stub network. + checkbox + Enable MD5 password for this OSPFd interface (default no) md5password -- cgit v1.2.3 From c7c6a092ff24b9a988299545d791e8e020d84861 Mon Sep 17 00:00:00 2001 From: thompsa Date: Thu, 4 Mar 2010 15:58:00 +1300 Subject: Merge the conflicting frontend bind addresses into one, allowing ACL rules to choose the backend. Non-conflicting entries should not be affected. --- config/haproxy-dev/haproxy.inc | 391 ++++++++++++++++++++++++----------------- 1 file changed, 230 insertions(+), 161 deletions(-) (limited to 'config') diff --git a/config/haproxy-dev/haproxy.inc b/config/haproxy-dev/haproxy.inc index a799cd48..275ea8ab 100644 --- a/config/haproxy-dev/haproxy.inc +++ b/config/haproxy-dev/haproxy.inc @@ -58,44 +58,6 @@ $a_acltypes[] = array('name' => 'path_contains', 'descr' => 'Path contains', $a_acltypes[] = array('name' => 'source_ip', 'descr' => 'Source IP', 'mode' => '', 'syntax' => 'src'); -function haproxy_find_acl($name) { - global $a_acltypes; - - /* XXX why is this broken from xmlsync? */ - if (!$a_acltypes) { - $a_acltypes = array(); - $a_acltypes[] = array('name' => 'host_starts_with', 'descr' => 'Host starts with', - 'mode' => 'http', 'syntax' => 'hdr_beg(host) -i'); - $a_acltypes[] = array('name' => 'host_ends_with', 'descr' => 'Host ends with', - 'mode' =>'http', 'syntax' => 'hdr_end(host) -i'); - $a_acltypes[] = array('name' => 'host_matches', 'descr' => 'Host matches', - 'mode' =>'http', 'syntax' => 'hdr(host) -i'); - $a_acltypes[] = array('name' => 'host_regex', 'descr' => 'Host regex', - 'mode' =>'http', 'syntax' => 'hdr_reg(host) -i'); - $a_acltypes[] = array('name' => 'host_contains', 'descr' => 'Host contains', - 'mode' => 'http', 'syntax' => 'hdr_dir(host) -i'); - $a_acltypes[] = array('name' => 'path_starts_with', 'descr' => 'Path starts with', - 'mode' => 'http', 'syntax' => 'path_beg -i'); - $a_acltypes[] = array('name' => 'path_ends_with', 'descr' => 'Path ends with', - 'mode' => 'http', 'syntax' => 'path_end -i'); - $a_acltypes[] = array('name' => 'path_matches', 'descr' => 'Path matches', - 'mode' => 'http', 'syntax' => 'path -i'); - $a_acltypes[] = array('name' => 'path_regex', 'descr' => 'Path regex', - 'mode' => 'http', 'syntax' => 'path_reg -i'); - $a_acltypes[] = array('name' => 'path_contains', 'descr' => 'Path contains', - 'mode' => 'http', 'syntax' => 'path_dir -i'); - $a_acltypes[] = array('name' => 'source_ip', 'descr' => 'Source IP', - 'mode' => '', 'syntax' => 'src'); - } - - if($a_acltypes) { - foreach ($a_acltypes as $acl) { - if ($acl['name'] == $name) - return $acl; - } - } -} - function haproxy_custom_php_deinstall_command() { exec("rm /usr/local/sbin/haproxy"); exec("rm /usr/local/pkg/haproxy.inc"); @@ -158,6 +120,131 @@ EOD; exec("/usr/local/etc/rc.d/haproxy.sh start"); } +function haproxy_find_acl($name) { + global $a_acltypes; + + /* XXX why is this broken from xmlsync? */ + if (!$a_acltypes) { + $a_acltypes = array(); + $a_acltypes[] = array('name' => 'host_starts_with', 'descr' => 'Host starts with', + 'mode' => 'http', 'syntax' => 'hdr_beg(host) -i'); + $a_acltypes[] = array('name' => 'host_ends_with', 'descr' => 'Host ends with', + 'mode' =>'http', 'syntax' => 'hdr_end(host) -i'); + $a_acltypes[] = array('name' => 'host_matches', 'descr' => 'Host matches', + 'mode' =>'http', 'syntax' => 'hdr(host) -i'); + $a_acltypes[] = array('name' => 'host_regex', 'descr' => 'Host regex', + 'mode' =>'http', 'syntax' => 'hdr_reg(host) -i'); + $a_acltypes[] = array('name' => 'host_contains', 'descr' => 'Host contains', + 'mode' => 'http', 'syntax' => 'hdr_dir(host) -i'); + $a_acltypes[] = array('name' => 'path_starts_with', 'descr' => 'Path starts with', + 'mode' => 'http', 'syntax' => 'path_beg -i'); + $a_acltypes[] = array('name' => 'path_ends_with', 'descr' => 'Path ends with', + 'mode' => 'http', 'syntax' => 'path_end -i'); + $a_acltypes[] = array('name' => 'path_matches', 'descr' => 'Path matches', + 'mode' => 'http', 'syntax' => 'path -i'); + $a_acltypes[] = array('name' => 'path_regex', 'descr' => 'Path regex', + 'mode' => 'http', 'syntax' => 'path_reg -i'); + $a_acltypes[] = array('name' => 'path_contains', 'descr' => 'Path contains', + 'mode' => 'http', 'syntax' => 'path_dir -i'); + $a_acltypes[] = array('name' => 'source_ip', 'descr' => 'Source IP', + 'mode' => '', 'syntax' => 'src'); + } + + if($a_acltypes) { + foreach ($a_acltypes as $acl) { + if ($acl['name'] == $name) + return $acl; + } + } +} + +function write_backend($fd, $name, $pool, $frontend) { + if($pool['status'] != 'active' || !is_array($pool['ha_servers']['item'])) + continue; + + fwrite ($fd, "backend " . $name . "\n"); + if($pool['cookie_name'] && strtolower($frontend['type']) == "http") + fwrite ($fd, "\tcookie\t\t\t" . $pool['cookie_name'] . " insert indirect\n"); + + // https is an alias for tcp for clarity purpouses + if(strtolower($frontend['type']) == "https") { + $backend_type = "tcp"; + $httpchk = "ssl-hello-chk"; + } else { + $backend_type = $frontend['type']; + $httpchk = "httpchk"; + } + + fwrite ($fd, "\tmode\t\t\t" . $backend_type . "\n"); + + if($frontend['balance']) + fwrite ($fd, "\tbalance\t\t\t" . $frontend['balance'] . "\n"); + + if($frontend['connection_timeout']) + fwrite ($fd, "\tcontimeout\t\t" . $frontend['connection_timeout'] . "\n"); + + if($frontend['server_timeout']) + fwrite ($fd, "\tsrvtimeout\t\t" . $frontend['server_timeout'] . "\n"); + + if($frontend['retries']) + fwrite ($fd, "\tretries\t\t\t" . $frontend['retries'] . "\n"); + + if($frontend['stats_enabled']=='yes') { + fwrite ($fd, "\tstats\t\t\tenable\n"); + if($frontend['stats_uri']) + fwrite ($fd, "\tstats\t\t\turi ".$frontend['stats_uri']."\n"); + if($frontend['stats_realm']) + fwrite ($fd, "\tstats\t\t\trealm " . $frontend['stats_realm'] . "\n"); + else + fwrite ($fd, "\tstats\t\t\trealm .\n"); + fwrite ($fd, "\tstats\t\t\tauth " . $frontend['stats_username'].":". $frontend['stats_password']."\n"); + } + + $uri = $pool['monitor_uri']; + if ($pool['monitor_uri']) + $uri = $pool['monitor_uri']; + else + $uri = "/"; + fwrite ($fd, "\toption\t\t\t{$httpchk} HEAD " . $uri . " HTTP/1.0\n"); + + if($pool['cookie'] && strtolower($frontend['type']) == "http") + $cookie = " cookie {$pool['cookie']} "; + else + $cookie = ""; + if($pool['advanced']) { + $advanced = base64_decode($pool['advanced']); + $advanced_txt = " " . $advanced; + } else { + $advanced_txt = ""; + } + if($pool['checkinter']) + $checkinter = "check inter {$pool['checkinter']}"; + else + $checkinter = "check inter 1000"; + + $a_servers = &$pool['ha_servers']['item']; + foreach($a_servers as $be) { + if(!$be['port']) { + // the listener can specify a default port + $be['port'] = $frontend['svrport']; + } + if(!$be['port']) { + // last resort, use the frontend port + $ports = split(",", "{$frontend['port']},"); + $be['port'] = $ports[0]; + } + if (!$be['name']) + $be['name'] = $be['address']; + if($be['backup']) { + $isbackup = "backup"; + } else { + $isbackup = ""; + } + fwrite ($fd, "\tserver\t\t\t" . $be['name'] . " " . $be['address'].":" . $be['port'] . " $cookie " . " $checkinter $isbackup weight " . $be['weight'] . "{$advanced_txt}\n"); + } + fwrite ($fd, "\n"); +} + function haproxy_configure() { global $config, $g; @@ -187,17 +274,52 @@ function haproxy_configure() { fwrite ($fd, "\n"); } - // Construct and write out configuration file + // Try and get a unique array for address:port as frontends can duplicate + $a_bind = array(); if(is_array($a_backends)) { foreach ($a_backends as $backend) { - if($backend['status'] != 'active') continue; - // Define our backend name - $backendinfo = "listen {$backend['name']}\n"; + if(!$backend['pool']) + continue; + + $bname = $backend['extaddr'] . ":" . $backend['port']; + if (!is_array($a_bind[$bname])) { + $a_bind[$bname] = array(); + $a_bind[$bname]['config'] = array(); + // Settings which are constant for a merged frontend + $a_bind[$bname]['name'] = $backend['name']; + $a_bind[$bname]['defaultpool'] = $backend['pool'] . "_" . strtolower($backend['type']); + $a_bind[$bname]['extaddr'] = $backend['extaddr']; + $a_bind[$bname]['port'] = $backend['port']; + } + $bind = &$a_bind[$bname]; + + // Overwrite ? + $bind['type'] = $backend['type']; + $bind['forwardfor'] = $backend['forwardfor']; + $bind['httpclose'] = $backend['httpclose']; + $bind['max_connections'] = $backend['max_connections']; + $bind['client_timeout'] = $backend['client_timeout']; + $bind['advanced'] = $backend['advanced']; + + // pointer to each backend + $bind['config'][] = $backend; + } + } + + $a_pendingpl = array(); + + // Construct and write out configuration file + if(is_array($a_bind)) { + foreach ($a_bind as $bind) { + if (count($bind['config']) > 1) + $frontendinfo = "frontend {$bind['name']}-merged\n"; + else + $frontendinfo = "frontend {$bind['name']}\n"; // Prepare ports for processing by splitting - $portss = "{$backend['port']},"; + $portss = "{$bind['port']},"; $ports = split(",", $portss); // Initialize variable @@ -206,30 +328,30 @@ function haproxy_configure() { // Process and add bind directives for ports foreach($ports as $port) { if($port) { - if($backend['extaddr'] == "any") + if($bind['extaddr'] == "any") $listenip .= "\tbind\t\t\t0.0.0.0:{$port}\n"; - elseif($backend['extaddr']) - $listenip .= "\tbind\t\t\t{$backend['extaddr']}:{$port}\n"; + elseif($bind['extaddr']) + $listenip .= "\tbind\t\t\t{$bind['extaddr']}:{$port}\n"; else $listenip .= "\tbind\t\t\t" . get_current_wan_address('wan') . ":{$port}\n"; } } - fwrite ($fd, "{$backendinfo}"); + fwrite ($fd, "{$frontendinfo}"); fwrite ($fd, "{$listenip}"); // Advanced pass thru - if($backend['advanced']) { - $advanced = base64_decode($backend['advanced']); + if($bind['advanced']) { + $advanced = base64_decode($bind['advanced']); fwrite($fd, "\t" . $advanced . "\n"); } // https is an alias for tcp for clarity purpouses - if(strtolower($backend['type']) == "https") { + if(strtolower($bind['type']) == "https") { $backend_type = "tcp"; $httpchk = "ssl-hello-chk"; } else { - $backend_type = $backend['type']; + $backend_type = $bind['type']; $httpchk = "httpchk"; } @@ -237,134 +359,81 @@ function haproxy_configure() { fwrite ($fd, "\tlog\t\t\tglobal\n"); fwrite ($fd, "\toption\t\t\tdontlognull\n"); - if($backend['httpclose']) + if($bind['httpclose']) fwrite ($fd, "\toption\t\t\thttpclose\n"); - if($backend['forwardfor']) + if($bind['forwardfor']) fwrite ($fd, "\toption\t\t\tforwardfor\n"); - if($backend['max_connections']) - fwrite ($fd, "\tmaxconn\t\t\t" . $backend['max_connections'] . "\n"); - - if($backend['client_timeout']) - fwrite ($fd, "\tclitimeout\t\t" . $backend['client_timeout'] . "\n"); - - if($backend['balance']) - fwrite ($fd, "\tbalance\t\t\t" . $backend['balance'] . "\n"); - - if($backend['connection_timeout']) - fwrite ($fd, "\tcontimeout\t\t" . $backend['connection_timeout'] . "\n"); - - if($backend['server_timeout']) - fwrite ($fd, "\tsrvtimeout\t\t" . $backend['server_timeout'] . "\n"); + if($bind['max_connections']) + fwrite ($fd, "\tmaxconn\t\t\t" . $bind['max_connections'] . "\n"); - if($backend['retries']) - fwrite ($fd, "\tretries\t\t\t" . $backend['retries'] . "\n"); + if($bind['client_timeout']) + fwrite ($fd, "\tclitimeout\t\t" . $bind['client_timeout'] . "\n"); - if($backend['stats_enabled']=='yes') { - fwrite ($fd, "\tstats\t\t\tenable\n"); - if($backend['stats_uri']) - fwrite ($fd, "\tstats\t\t\turi ".$backend['stats_uri']."\n"); - if($backend['stats_realm']) - fwrite ($fd, "\tstats\t\t\trealm " . $backend['stats_realm'] . "\n"); - else - fwrite ($fd, "\tstats\t\t\trealm .\n"); - fwrite ($fd, "\tstats\t\t\tauth " . $backend['stats_username'].":". $backend['stats_password']."\n"); - } - - $a_acl=&$backend['ha_acls']['item']; - if(!is_array($a_acl)) - $a_acl=array(); + fwrite ($fd, "\tdefault_backend\t\t" . $bind['defaultpool'] . "\n"); + + // Combine the rest of the listener configs + foreach ($bind['config'] as $bconfig) { + $a_acl=&$bconfig['ha_acls']['item']; + if(!is_array($a_acl)) + $a_acl=array(); - foreach ($a_acl as $entry) { - $acl = haproxy_find_acl($entry['expression']); - if (!$acl) - continue; + $poolname = $bconfig['pool'] . "_" . strtolower($bconfig['type']); + if (!isset($a_pendingpl[$poolname])) { + $a_pendingpl[$poolname] = array(); + $a_pendingpl[$poolname]['name'] = $poolname; + $a_pendingpl[$poolname]['frontend'] = $bconfig; + } - // Filter out acls for different modes - if ($acl['mode'] != '' && $acl['mode'] != strtolower($backend['type'])) - continue; + foreach ($a_acl as $entry) { + $acl = haproxy_find_acl($entry['expression']); + if (!$acl) + continue; - if ($acl['syntax'] != '') - $expr = $acl['syntax'] . " " . $entry['value']; - else - $expr = $entry['expression'] . " " . $entry['value']; + // Filter out acls for different modes + if ($acl['mode'] != '' && $acl['mode'] != strtolower($bind['type'])) + continue; - fwrite ($fd, "\tacl\t\t\t".$entry['name']."\t".$expr."\n"); - } + if ($acl['syntax'] != '') + $expr = $acl['syntax'] . " " . $entry['value']; + else + $expr = $entry['expression'] . " " . $entry['value']; - if (is_array($a_pools)) { - foreach ($a_pools as $pool) { - if ($backend['pool'] == $pool['name'] && is_array($pool['ha_servers']['item'])) { - if($pool['status'] != 'active') - continue; - if($pool['cookie_name'] && strtolower($backend['type']) == "http") - fwrite ($fd, "\tcookie\t\t\t" . $pool['cookie_name'] . " insert indirect\n"); - - $uri = $pool['monitor_uri']; - if ($pool['monitor_uri']) - $uri = $pool['monitor_uri']; - else - $uri = "/"; - fwrite ($fd, "\toption\t\t\t{$httpchk} HEAD " . $uri . " HTTP/1.0\n"); - - if($pool['cookie'] && strtolower($backend['type']) == "http") - $cookie = " cookie {$pool['cookie']} "; - else - $cookie = ""; - if($pool['advanced']) { - $advanced = base64_decode($pool['advanced']); - $advanced_txt = " " . $advanced; - } else { - $advanced_txt = ""; - } - if($pool['checkinter']) - $checkinter = "check inter {$pool['checkinter']}"; - else - $checkinter = "check inter 1000"; - - $a_servers = &$pool['ha_servers']['item']; - foreach($a_servers as $be) { - if(!$be['port']) { - // the listener can specify a default port - $be['port'] = $backend['svrport']; - } - if(!$be['port']) { - // last resort, use the frontend port - $ports = split(",", "{$backend['port']},"); - $be['port'] = $ports[0]; - } - if (!$be['name']) - $be['name'] = $be['address']; - if($be['backup']) { - $isbackup = "backup"; - } else { - $isbackup = ""; - } - fwrite ($fd, "\tserver\t\t\t" . $be['name'] . " " . $be['address'].":" . $be['port'] . " $cookie " . " $checkinter $isbackup weight " . $be['weight'] . "{$advanced_txt}\n"); - } - - } + fwrite ($fd, "\tacl\t\t\t".$entry['name']."\t".$expr."\n"); + fwrite ($fd, "\tuse_backend\t\t$poolname if " . $entry['name'] . "\n"); } + } fwrite ($fd, "\n"); } - // Sync HAProxy configuration (if enabled) - if(isset($config['installedpackages']['haproxy']['enablesync'])) { - if($config['installedpackages']['haproxy']['synchost1']) { - haproxy_do_xmlrpc_sync($config['installedpackages']['haproxy']['synchost1'], - $config['installedpackages']['haproxy']['syncpassword']); - } - if($config['installedpackages']['haproxy']['synchost2']) { - haproxy_do_xmlrpc_sync($config['installedpackages']['haproxy']['synchost2'], - $config['installedpackages']['haproxy']['syncpassword']); - } - if($config['installedpackages']['haproxy']['synchost3']) { - haproxy_do_xmlrpc_sync($config['installedpackages']['haproxy']['synchost3'], - $config['installedpackages']['haproxy']['syncpassword']); + } + if (is_array($a_pendingpl) && is_array($a_pools)) { + foreach ($a_pendingpl as $pending) { + foreach ($a_pools as $pool) { + if ($pending['frontend']['pool'] == $pool['name']) { + write_backend($fd, $pending['name'], $pool, $pending['frontend']); + } } } } + fwrite ($fd, "\n"); + + // Sync HAProxy configuration (if enabled) + if(isset($config['installedpackages']['haproxy']['enablesync'])) { + if($config['installedpackages']['haproxy']['synchost1']) { + haproxy_do_xmlrpc_sync($config['installedpackages']['haproxy']['synchost1'], + $config['installedpackages']['haproxy']['syncpassword']); + } + if($config['installedpackages']['haproxy']['synchost2']) { + haproxy_do_xmlrpc_sync($config['installedpackages']['haproxy']['synchost2'], + $config['installedpackages']['haproxy']['syncpassword']); + } + if($config['installedpackages']['haproxy']['synchost3']) { + haproxy_do_xmlrpc_sync($config['installedpackages']['haproxy']['synchost3'], + $config['installedpackages']['haproxy']['syncpassword']); + } + } // create config file fclose($fd); -- cgit v1.2.3 From 1569952654e988b44cd8a6bc6d329a28025db8c9 Mon Sep 17 00:00:00 2001 From: thompsa Date: Thu, 4 Mar 2010 20:00:43 +1300 Subject: The $bind=&$array variable from one loop seems to be truncated by using the same named variable in the next loop. The last array member is duplicated by array[n-1]. --- config/haproxy-dev/haproxy.inc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'config') diff --git a/config/haproxy-dev/haproxy.inc b/config/haproxy-dev/haproxy.inc index 275ea8ab..12920103 100644 --- a/config/haproxy-dev/haproxy.inc +++ b/config/haproxy-dev/haproxy.inc @@ -293,18 +293,18 @@ function haproxy_configure() { $a_bind[$bname]['extaddr'] = $backend['extaddr']; $a_bind[$bname]['port'] = $backend['port']; } - $bind = &$a_bind[$bname]; + $b = &$a_bind[$bname]; // Overwrite ? - $bind['type'] = $backend['type']; - $bind['forwardfor'] = $backend['forwardfor']; - $bind['httpclose'] = $backend['httpclose']; - $bind['max_connections'] = $backend['max_connections']; - $bind['client_timeout'] = $backend['client_timeout']; - $bind['advanced'] = $backend['advanced']; + $b['type'] = $backend['type']; + $b['forwardfor'] = $backend['forwardfor']; + $b['httpclose'] = $backend['httpclose']; + $b['max_connections'] = $backend['max_connections']; + $b['client_timeout'] = $backend['client_timeout']; + $b['advanced'] = $backend['advanced']; // pointer to each backend - $bind['config'][] = $backend; + $b['config'][] = $backend; } } -- cgit v1.2.3 From a919a8f65a0a9b03b5ba48e92fb6e4201c26c805 Mon Sep 17 00:00:00 2001 From: Chris Buechler Date: Thu, 4 Mar 2010 04:35:10 -0500 Subject: fix text --- config/openospfd/openospfd.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'config') diff --git a/config/openospfd/openospfd.xml b/config/openospfd/openospfd.xml index a5bc100c..85d0e5bf 100644 --- a/config/openospfd/openospfd.xml +++ b/config/openospfd/openospfd.xml @@ -84,7 +84,7 @@ SPF Delay spfdelay - Set SPF delay in seconds. The delay between receiving an update to the link state database and starting the shortest path first calculation. The default value is 1; valid range is 1-10 sec-onds. + Set SPF delay in seconds. The delay between receiving an update to the link state database and starting the shortest path first calculation. The default value is 1; valid range is 1-10 seconds. input @@ -94,7 +94,7 @@ checkbox - This rules will take precedence over any other redistribute option specified above. + These rules take precedence over any redistribute options specified above. none rowhelper -- cgit v1.2.3 From 3bf52e0a4100cb31955babe79766c4a0e65bef69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ermal=20Lu=E7i?= Date: Thu, 4 Mar 2010 14:28:47 +0000 Subject: Use correct fle. --- config/openospfd/openospfd.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config') diff --git a/config/openospfd/openospfd.xml b/config/openospfd/openospfd.xml index 85d0e5bf..5aca00c2 100644 --- a/config/openospfd/openospfd.xml +++ b/config/openospfd/openospfd.xml @@ -12,7 +12,7 @@ /usr/local/pkg/ 077 - http://www.pfsense.com/packages/config/openbgpd/openospfd_interfaces.xml + http://www.pfsense.com/packages/config/openospfd/openospfd_interfaces.xml OSPFd -- cgit v1.2.3 From b80ebd2d768d5c3f8139af0eb7fce6b55d7ad059 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ermal=20Lu=E7i?= Date: Thu, 4 Mar 2010 22:36:23 +0000 Subject: Use the propper function to find the real interface in 2.0+. --- config/openospfd/openospfd.inc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'config') diff --git a/config/openospfd/openospfd.inc b/config/openospfd/openospfd.inc index d38ec82f..5b600506 100644 --- a/config/openospfd/openospfd.inc +++ b/config/openospfd/openospfd.inc @@ -84,7 +84,14 @@ function ospfd_install_conf() { if ($config['installedpackages']['ospfdinterfaces']['config']) { foreach ($config['installedpackages']['ospfdinterfaces']['config'] as $conf) { - $conffile .= "\tinterface " . $config['interfaces'][$conf['interface']]['if']; + if (intval($g['latest_config']) >= 6) { + $ospfdif = get_real_interface($conf['interface']); + if ($ospfdif) + $conffile .= "\tinterface {$ospfdif}"; + else + continue; + } else + $conffile .= "\tinterface " . $config['interfaces'][$conf['interface']]['if']; $options_present = false; $ifconfigs = ""; if (!empty($conf['metric'])) { -- cgit v1.2.3 From 012cd354237bda4768a7cd62ad902f0841fb78bb Mon Sep 17 00:00:00 2001 From: thompsa Date: Fri, 5 Mar 2010 13:30:18 +1300 Subject: Make the acl name unique by prefixing with _ --- config/haproxy-dev/haproxy.inc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'config') diff --git a/config/haproxy-dev/haproxy.inc b/config/haproxy-dev/haproxy.inc index 12920103..4207a3ca 100644 --- a/config/haproxy-dev/haproxy.inc +++ b/config/haproxy-dev/haproxy.inc @@ -374,6 +374,7 @@ function haproxy_configure() { fwrite ($fd, "\tdefault_backend\t\t" . $bind['defaultpool'] . "\n"); // Combine the rest of the listener configs + $i = 0; foreach ($bind['config'] as $bconfig) { $a_acl=&$bconfig['ha_acls']['item']; if(!is_array($a_acl)) @@ -400,8 +401,10 @@ function haproxy_configure() { else $expr = $entry['expression'] . " " . $entry['value']; - fwrite ($fd, "\tacl\t\t\t".$entry['name']."\t".$expr."\n"); - fwrite ($fd, "\tuse_backend\t\t$poolname if " . $entry['name'] . "\n"); + $aclname = $i . "_" . $entry['name']; + fwrite ($fd, "\tacl\t\t\t" . $aclname . "\t" . $expr . "\n"); + fwrite ($fd, "\tuse_backend\t\t" . $poolname . " if " . $aclname . "\n"); + $i++; } } -- cgit v1.2.3 From e4a794f7f93fae4b947b93fbdcc7d5eff659d675 Mon Sep 17 00:00:00 2001 From: thompsa Date: Fri, 5 Mar 2010 21:14:23 +1300 Subject: Dont enable the check on tcp mode unless the user specifies it, it doesnt make sense otherwise. --- config/haproxy-dev/haproxy.inc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'config') diff --git a/config/haproxy-dev/haproxy.inc b/config/haproxy-dev/haproxy.inc index 4207a3ca..455638a1 100644 --- a/config/haproxy-dev/haproxy.inc +++ b/config/haproxy-dev/haproxy.inc @@ -219,8 +219,10 @@ function write_backend($fd, $name, $pool, $frontend) { } if($pool['checkinter']) $checkinter = "check inter {$pool['checkinter']}"; - else + else if (strtolower($frontend['type']) != "tcp") $checkinter = "check inter 1000"; + else + $checkinter = ""; $a_servers = &$pool['ha_servers']['item']; foreach($a_servers as $be) { -- cgit v1.2.3 From 510b2c53882af06eb297491560cefe4b76425547 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 6 Mar 2010 11:58:24 -0500 Subject: Adding ospfd status page from buraglio@ --- config/openospfd/openospfd.xml | 25 ++++++++++----- config/openospfd/status_ospfd.php | 65 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 8 deletions(-) create mode 100644 config/openospfd/status_ospfd.php (limited to 'config') diff --git a/config/openospfd/openospfd.xml b/config/openospfd/openospfd.xml index 5aca00c2..add96bb7 100644 --- a/config/openospfd/openospfd.xml +++ b/config/openospfd/openospfd.xml @@ -5,15 +5,20 @@ /usr/local/pkg/openospfd.inc pkg_edit.php?xml=openospfd.xml&id=0 - /usr/local/pkg/ - 077 - http://www.pfsense.com/packages/config/openospfd/openospfd.inc - + /usr/local/pkg/ + 077 + http://www.pfsense.com/packages/config/openospfd/openospfd.inc + - /usr/local/pkg/ - 077 - http://www.pfsense.com/packages/config/openospfd/openospfd_interfaces.xml - + /usr/local/pkg/ + 077 + http://www.pfsense.com/packages/config/openospfd/openospfd_interfaces.xml + + + /usr/local/www/ + 077 + http://www.pfsense.com/packages/config/openospfd/status_ospfd.php + OSPFd Modify ospfd settings. @@ -31,6 +36,10 @@ Interface Settings pkg.php?xml=openospfd_interfaces.xml + + Status + /status_ospfd.php + ospfd diff --git a/config/openospfd/status_ospfd.php b/config/openospfd/status_ospfd.php new file mode 100644 index 00000000..d2c1e1a4 --- /dev/null +++ b/config/openospfd/status_ospfd.php @@ -0,0 +1,65 @@ +Basic OSPFd statistics
"; + +echo "

OSPF Summary

"; +echo '
';
+
+$summary = system('/usr/local/sbin/ospfctl show summary', $summary);
+
+echo "

OSPF Neighbors

"; +echo '
';
+
+$neighbor = system('/usr/local/sbin/ospfctl show neighbor', $neighbor);
+
+echo "

FIB

"; +echo '
';
+
+$rib = system('/usr/local/sbin/ospfctl show fib', $rib);
+
+echo "

RIB

"; +echo '
';
+
+$fib = system('/usr/local/sbin/ospfctl show rib', $fib);
+
+echo "

OSPF Interfaces

"; +echo '
';
+
+$interfaces = system('/usr/local/sbin/ospfctl show interfaces', $interfaces);
+
+echo "

OSPF Database

"; +echo '
';
+
+$database = system('/usr/local/sbin/ospfctl show database', $database);
+
+
+?>
+
-- 
cgit v1.2.3


From 95fcea5781f9c256a3adcae132353d85d6d05258 Mon Sep 17 00:00:00 2001
From: Scott Ullrich 
Date: Sat, 6 Mar 2010 12:10:40 -0500
Subject: Cleanup

---
 config/openospfd/status_ospfd.php | 73 +++++++++++++++++++++++++--------------
 1 file changed, 48 insertions(+), 25 deletions(-)

(limited to 'config')

diff --git a/config/openospfd/status_ospfd.php b/config/openospfd/status_ospfd.php
index d2c1e1a4..51578f13 100644
--- a/config/openospfd/status_ospfd.php
+++ b/config/openospfd/status_ospfd.php
@@ -27,39 +27,62 @@
     POSSIBILITY OF SUCH DAMAGE.
 */
 
+require("guiconfig.inc");
 
-echo "

Basic OSPFd statistics


"; +$pgtitle = "OpenOSPFD: Status"; +include("head.inc"); -echo "

OSPF Summary

"; -echo '
';
-
-$summary = system('/usr/local/sbin/ospfctl show summary', $summary);
-
-echo "

OSPF Neighbors

"; -echo '
';
-
-$neighbor = system('/usr/local/sbin/ospfctl show neighbor', $neighbor);
-
-echo "

FIB

"; -echo '
';
-
-$rib = system('/usr/local/sbin/ospfctl show fib', $rib);
+?>
 
-echo "

RIB

"; -echo '
';
+
+
+

+ -$fib = system('/usr/local/sbin/ospfctl show rib', $fib); +
+ + +
+ + + + + +
+
+
+
-echo "

OSPF Interfaces

"; -echo '
';
+ OSPF Database ";
-echo '
';
+?>
 
-$database = system('/usr/local/sbin/ospfctl show database', $database);
+		
+ + + +
+
+ + + +
-?> + + + \ No newline at end of file -- cgit v1.2.3 From d0b04056ac689204cd1538a5ee11b6903758110a Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 6 Mar 2010 12:11:25 -0500 Subject: Fix filename --- config/openospfd/status_ospfd.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'config') diff --git a/config/openospfd/status_ospfd.php b/config/openospfd/status_ospfd.php index 51578f13..80235e4b 100644 --- a/config/openospfd/status_ospfd.php +++ b/config/openospfd/status_ospfd.php @@ -45,14 +45,14 @@ include("head.inc"); $tab_array = array(); $tab_array[] = array(gettext("Settings"), false, "/pkg_edit.php?xml=openospfd.xml&id=0"); $tab_array[] = array(gettext("Interfaces"), false, "/pkg.php?xml=openospfd_neighbors.xml"); - $tab_array[] = array(gettext("Status"), true, "/openospfd_status.php"); + $tab_array[] = array(gettext("Status"), true, "/status_ospfd.php"); display_top_tabs($tab_array); ?> -- cgit v1.2.3 From f8ebd506c5a65479e695822a6e2c29fb2d0d1441 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 6 Mar 2010 12:12:06 -0500 Subject: Add (C) since the page was originally the BGP status page --- config/openospfd/status_ospfd.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'config') diff --git a/config/openospfd/status_ospfd.php b/config/openospfd/status_ospfd.php index 80235e4b..24f90862 100644 --- a/config/openospfd/status_ospfd.php +++ b/config/openospfd/status_ospfd.php @@ -3,6 +3,7 @@ /* status_ospfd.php Copyright (C) 2010 Nick Buraglio; nick@buraglio.com + Copyright (C) 2010 Scott Ullrich All rights reserved. Redistribution and use in source and binary forms, with or without @@ -52,7 +53,7 @@ include("head.inc");
-
+
-- cgit v1.2.3 From 79266bafc42f6a9e3b52ffbdac72ec628ba2e24c Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 6 Mar 2010 13:48:06 -0500 Subject: Correct link --- config/openospfd/status_ospfd.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config') diff --git a/config/openospfd/status_ospfd.php b/config/openospfd/status_ospfd.php index 24f90862..61ca5675 100644 --- a/config/openospfd/status_ospfd.php +++ b/config/openospfd/status_ospfd.php @@ -45,7 +45,7 @@ include("head.inc"); -- cgit v1.2.3 From 1ab04cff625cfce3f4dda6dc08ac40c2324b453a Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 6 Mar 2010 13:51:32 -0500 Subject: Fixup html. --- config/openospfd/status_ospfd.php | 94 +++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 52 deletions(-) (limited to 'config') diff --git a/config/openospfd/status_ospfd.php b/config/openospfd/status_ospfd.php index 61ca5675..caf7f32e 100644 --- a/config/openospfd/status_ospfd.php +++ b/config/openospfd/status_ospfd.php @@ -1,5 +1,4 @@ - - -

- - -
-
-
+
- -
- - - - - -
-
-
-
- - - -
- - - + + + +

+ +
+ + +
+ + + + + + + +
+
+
+
+ +
+ + +
+
- -
- - - - - - - - - \ No newline at end of file + + + -- cgit v1.2.3 From bed5a7ae26e79f91f4ba92beccd6558cf3cd4612 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 6 Mar 2010 13:54:35 -0500 Subject: Clean up formatting --- config/openospfd/openospfd_interfaces.xml | 86 ++++++++++++++++--------------- 1 file changed, 44 insertions(+), 42 deletions(-) (limited to 'config') diff --git a/config/openospfd/openospfd_interfaces.xml b/config/openospfd/openospfd_interfaces.xml index ea4c0dfb..2bae47ab 100644 --- a/config/openospfd/openospfd_interfaces.xml +++ b/config/openospfd/openospfd_interfaces.xml @@ -5,10 +5,10 @@ /usr/local/pkg/openospfd.inc pkg_edit.php?xml=openospfd.xml&id=0 - /usr/local/pkg/ - 077 - http://www.pfsense.com/packages/config/openospfd/openospfd.inc - + /usr/local/pkg/ + 077 + http://www.pfsense.com/packages/config/openospfd/openospfd.inc + OSPFd Modify ospfd settings. @@ -29,13 +29,13 @@ - Interface - interface - + Interface + interface + - Description - descr - + Description + descr + ospfd @@ -43,72 +43,74 @@ ospfd - - Interface - interface - Enter the desired participating interface here. - interfaces_selection + + Interface + interface + Enter the desired participating interface here. + interfaces_selection - + Metric metric Metric for this OSPF interface (leave blank for default). input - + - Description - descr + Description + descr 30 - input - + input + + + Interface is Passive + passive + Prevent transmission and reception of OSPF packets on this interface. The specified interface will be announced as a stub network. + checkbox + - Interface is Passive - passive - Prevent transmission and reception of OSPF packets on this interface. The specified interface will be announced as a stub network. - checkbox - - - Enable MD5 password for this OSPFd interface (default no) - md5password - Enables the use of an MD5 password to on this instance - checkbox - + Enable MD5 password for this OSPFd interface (default no) + md5password + Enables the use of an MD5 password to on this instance + checkbox + Password password Password for this OSPF interface. input - + Router Priority routerpriorityelections - Router priority when participating in elections for DR (Default 1) Valid range is 0-255. 0 will cause the router to not participate in election. + + Router priority when participating in elections for DR (Default 1) Valid range is 0-255. 0 will cause the router to not participate in election. + input - + Hello Interval hellointervalinseconds Hello Interval this OSPF interface in seconds (Default 10). input - + Retransmit Interval retransmitinterval Retransmit Interval this OSPF interface in seconds (Default 5). input - + Dead Timer deadtimer Dead Timer for this OSPF interface in seconds (Default 40). input - + - ospfd_install_conf(); - + ospfd_install_conf(); + - ospfd_validate_interface(); - + ospfd_validate_interface(); + -- cgit v1.2.3 From 9c4a2493372bc5c80b612b0be825013c4bbcb287 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 6 Mar 2010 15:21:42 -0500 Subject: Fix error --- config/openospfd/status_ospfd.php | 69 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) (limited to 'config') diff --git a/config/openospfd/status_ospfd.php b/config/openospfd/status_ospfd.php index caf7f32e..b20b7d04 100644 --- a/config/openospfd/status_ospfd.php +++ b/config/openospfd/status_ospfd.php @@ -32,12 +32,79 @@ require("guiconfig.inc"); $pgtitle = "OpenOSPFD: Status"; include("head.inc"); +/* List all of the commands as an index. */ +function listCmds() { + global $commands; + echo "

This status page includes the following information:\n"; + echo "

\n"; +} + +function execCmds() { + global $commands; + for ($i = 0; isset($commands[$i]); $i++ ) { + doCmdT($commands[$i][0], $commands[$i][1]); + } +} + +/* Define a command, with a title, to be executed later. */ +function defCmdT($title, $command) { + global $commands; + $title = htmlspecialchars($title,ENT_NOQUOTES); + $commands[] = array($title, $command); +} + +function doCmdT($title, $command) { + echo "

\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
" . $title . "
";		/* no newline after pre */
+
+	if ($command == "dumpconfigxml") {
+		$fd = @fopen("/conf/config.xml", "r");
+		if ($fd) {
+			while (!feof($fd)) {
+				$line = fgets($fd);
+				/* remove sensitive contents */
+				$line = preg_replace("/.*?<\\/password>/", "xxxxx", $line);
+				$line = preg_replace("/.*?<\\/pre-shared-key>/", "xxxxx", $line);
+				$line = preg_replace("/.*?<\\/rocommunity>/", "xxxxx", $line);
+				$line = str_replace("\t", "    ", $line);
+				echo htmlspecialchars($line,ENT_NOQUOTES);
+			}
+		}
+		fclose($fd);
+	} else {
+		$execOutput = "";
+		$execStatus = "";
+		exec ($command . " 2>&1", $execOutput, $execStatus);
+		for ($i = 0; isset($execOutput[$i]); $i++) {
+			if ($i > 0) {
+				echo "\n";
+			}
+			echo htmlspecialchars($execOutput[$i],ENT_NOQUOTES);
+		}
+	}
+    echo "
\n"; +} + +$pfSversion = str_replace("\n", "", file_get_contents("/etc/version")); +if(strstr($pfSversion, "1.2")) + $one_two = true; + ?> -

+ +

+
-- cgit v1.2.3 From 86926d1cc632261597eb53441c70bd142ad8a13a Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 6 Mar 2010 15:24:36 -0500 Subject: Add status tab --- config/openospfd/openospfd_interfaces.xml | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'config') diff --git a/config/openospfd/openospfd_interfaces.xml b/config/openospfd/openospfd_interfaces.xml index 2bae47ab..0608fade 100644 --- a/config/openospfd/openospfd_interfaces.xml +++ b/config/openospfd/openospfd_interfaces.xml @@ -26,6 +26,10 @@ pkg.php?xml=openospfd_interfaces.xml + + Status + /status_ospfd.php + -- cgit v1.2.3 From ca424140fcd49861c26e064f56733cceb79cd584 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 6 Mar 2010 15:27:28 -0500 Subject: Add missing --- config/openbgpd/openbgpd_status.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config') diff --git a/config/openbgpd/openbgpd_status.php b/config/openbgpd/openbgpd_status.php index cb83c6bf..2dce434d 100644 --- a/config/openbgpd/openbgpd_status.php +++ b/config/openbgpd/openbgpd_status.php @@ -94,7 +94,7 @@ function listCmds() { echo "

This status page includes the following information:\n"; echo "

\n"; } -- cgit v1.2.3 From 024ab5be05563a8161bbd3146a43c6bbedb51ea0 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 6 Mar 2010 15:39:09 -0500 Subject: Fix formatting --- config/openospfd/openospfd.xml | 58 +++++++++++++++++++-------------------- config/openospfd/status_ospfd.php | 18 ++++++------ 2 files changed, 37 insertions(+), 39 deletions(-) (limited to 'config') diff --git a/config/openospfd/openospfd.xml b/config/openospfd/openospfd.xml index add96bb7..cd32972c 100644 --- a/config/openospfd/openospfd.xml +++ b/config/openospfd/openospfd.xml @@ -60,42 +60,42 @@ input - - Update FIB (Routing table) - updatefib - Disables the updating of the host routing table(turns into stub router). - checkbox - - - Redistribute connected subnets - redistributeconnectedsubnets - Enables the redistribution of connected networks (Default no) - checkbox - - - Redistribute default route - redistributedefaultroute - Enables the redistribution of a default route to this device (Default no) - checkbox - - Redistribute static - redistributestatic - Enables the redistribution of static routes - checkbox - + Update FIB (Routing table) + updatefib + Disables the updating of the host routing table(turns into stub router). + checkbox + + + Redistribute connected subnets + redistributeconnectedsubnets + Enables the redistribution of connected networks (Default no) + checkbox + + + Redistribute default route + redistributedefaultroute + Enables the redistribution of a default route to this device (Default no) + checkbox + + + Redistribute static + redistributestatic + Enables the redistribution of static routes + checkbox + SPF Hold Time spfholdtime Set the SPF holdtime in seconds. The minimum time between two consecutive shortest path first calculations. The default value is 5 seconds; the valid range is 1-5 seconds. input - + SPF Delay spfdelay Set SPF delay in seconds. The delay between receiving an update to the link state database and starting the shortest path first calculation. The default value is 1; valid range is 1-10 seconds. input - + RFC 1583 compatible rfc1583 @@ -120,13 +120,13 @@ input 25 - + - ospfd_install_conf(); - + ospfd_install_conf(); + ospfd_validate_input(); - + \ No newline at end of file diff --git a/config/openospfd/status_ospfd.php b/config/openospfd/status_ospfd.php index b20b7d04..c60335de 100644 --- a/config/openospfd/status_ospfd.php +++ b/config/openospfd/status_ospfd.php @@ -35,8 +35,8 @@ include("head.inc"); /* List all of the commands as an index. */ function listCmds() { global $commands; - echo "

This status page includes the following information:\n"; - echo "

    \n"; + echo "
    This status page includes the following information:\n"; + echo "
      \n"; for ($i = 0; isset($commands[$i]); $i++ ) { echo "
    • " . $commands[$i][0] . "
    • \n"; } @@ -107,7 +107,7 @@ if(strstr($pfSversion, "1.2"))
      -
+
- - - - matched above + (!tags.indexOf("", "
-
-
-
+ + + +
+
-- cgit v1.2.3 From 68dc784cbe02be36d71bc3f83abed106469c7b68 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 6 Mar 2010 15:40:57 -0500 Subject: Clarify option disables --- config/openospfd/openospfd.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config') diff --git a/config/openospfd/openospfd.xml b/config/openospfd/openospfd.xml index cd32972c..d80ff258 100644 --- a/config/openospfd/openospfd.xml +++ b/config/openospfd/openospfd.xml @@ -61,7 +61,7 @@ - Update FIB (Routing table) + Disable FIB updates (Routing table) updatefib Disables the updating of the host routing table(turns into stub router). checkbox -- cgit v1.2.3 From e709c65038e0ff8a49c402700c17958ea45e64e9 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 6 Mar 2010 15:44:41 -0500 Subject: Make name of package uniform --- config/openospfd/openospfd.inc | 4 ++-- config/openospfd/openospfd.xml | 8 ++++---- config/openospfd/openospfd_interfaces.xml | 8 ++++---- config/openospfd/status_ospfd.php | 12 ++++++------ 4 files changed, 16 insertions(+), 16 deletions(-) (limited to 'config') diff --git a/config/openospfd/openospfd.inc b/config/openospfd/openospfd.inc index 5b600506..c94b9751 100644 --- a/config/openospfd/openospfd.inc +++ b/config/openospfd/openospfd.inc @@ -41,7 +41,7 @@ function ospfd_install_conf() { if($config['installedpackages']['ospfd']['config']) $ospfd_conf = &$config['installedpackages']['ospfd']['config'][0]; else { - log_error("OSPFd: No config data found."); + log_error("OpenOSPFd: No config data found."); return; } @@ -194,7 +194,7 @@ function ospfd_validate_input() { if ($_POST['spfdelay'] <> "" && ($_POST['spfdelay'] < 1 || $_POST['spfdelay'] > 10)) $input_errors[] = "SPF delay needs to be between 1 and 10."; if (!$config['installedpackages']['ospfdinterfaces']['config']) - $input_errors[] = "Please select an interface to use for OSPFd."; + $input_errors[] = "Please select an interface to use for OpenOSPFd."; } // get the raw ospfd confi file for manual inspection/editing diff --git a/config/openospfd/openospfd.xml b/config/openospfd/openospfd.xml index d80ff258..66079152 100644 --- a/config/openospfd/openospfd.xml +++ b/config/openospfd/openospfd.xml @@ -1,7 +1,7 @@ - OSPFd + OpenOSPFd 0.1 - Services: OSPFd + Services: OpenOSPFd /usr/local/pkg/openospfd.inc pkg_edit.php?xml=openospfd.xml&id=0 @@ -20,7 +20,7 @@ http://www.pfsense.com/packages/config/openospfd/status_ospfd.php - OSPFd + OpenOSPFd Modify ospfd settings.
Services
openospfd.xml @@ -56,7 +56,7 @@ Area area - OSPF area for this instance of OSPFd. + OpenOSPFd area for this instance of OSPF. input diff --git a/config/openospfd/openospfd_interfaces.xml b/config/openospfd/openospfd_interfaces.xml index 0608fade..7802abea 100644 --- a/config/openospfd/openospfd_interfaces.xml +++ b/config/openospfd/openospfd_interfaces.xml @@ -1,7 +1,7 @@ - OSPFd Interfaces + OpenOSPFd Interfaces 0.1 - Services: OSPFd + Services: OpenOSPFd /usr/local/pkg/openospfd.inc pkg_edit.php?xml=openospfd.xml&id=0 @@ -10,7 +10,7 @@ http://www.pfsense.com/packages/config/openospfd/openospfd.inc - OSPFd + OSPF Modify ospfd settings.
Services
openospfd.xml @@ -73,7 +73,7 @@ checkbox - Enable MD5 password for this OSPFd interface (default no) + Enable MD5 password for this OpenOSPFd interface (default no) md5password Enables the use of an MD5 password to on this instance checkbox diff --git a/config/openospfd/status_ospfd.php b/config/openospfd/status_ospfd.php index c60335de..c02e5d10 100644 --- a/config/openospfd/status_ospfd.php +++ b/config/openospfd/status_ospfd.php @@ -29,7 +29,7 @@ require("guiconfig.inc"); -$pgtitle = "OpenOSPFD: Status"; +$pgtitle = "OpenOSPFd: Status"; include("head.inc"); /* List all of the commands as an index. */ @@ -122,11 +122,11 @@ if(strstr($pfSversion, "1.2"))
-- cgit v1.2.3 From 52f993034380c1c77038730b00213a1e81a3b8e2 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 6 Mar 2010 15:47:00 -0500 Subject: Fix formatting --- config/openospfd/openospfd.inc | 44 +++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'config') diff --git a/config/openospfd/openospfd.inc b/config/openospfd/openospfd.inc index c94b9751..cc1d0de5 100644 --- a/config/openospfd/openospfd.inc +++ b/config/openospfd/openospfd.inc @@ -1,6 +1,6 @@ = 6) { $ospfdif = get_real_interface($conf['interface']); if ($ospfdif) @@ -107,27 +107,27 @@ function ospfd_install_conf() { $ifconfigs .= "\t\tauth-type crypt\n"; $ifconfigs .= "\t\tauth-md 1 \"" . substr($conf['password'], 0, 15) . "\"\n"; $ifconfigs .= "\t\tauth-md-keyid 1\n"; - } else if (!empty($conf['password'])) { + } else if (!empty($conf['password'])) { $options_present = true; $ifconfigs .= "\t\tauth-type simple\n"; $ifconfigs .= "\t\tauth-key \"" . substr($conf['password'], 0, 7) . "\"\n"; } if (!empty($conf['routerpriorityelections'])) { - $options_present = true; - $ifconfigs .= "\t\trouter-priority {$conf['routerpriorityelections']}\n"; - } + $options_present = true; + $ifconfigs .= "\t\trouter-priority {$conf['routerpriorityelections']}\n"; + } if (!empty($conf['retransmitinterval'])) { $options_present = true; $ifconfigs .= "\t\tretransmit-interval {$conf['retransmitinterval']}\n"; } if (!empty($conf['deadtimer'])) { - $options_present = true; - $ifconfigs .= "\t\trouter-dead-time {$conf['deadtimer']}\n"; - } + $options_present = true; + $ifconfigs .= "\t\trouter-dead-time {$conf['deadtimer']}\n"; + } if (!empty($conf['passive'])) { - $options_present = true; - $ifconfigs .= "\t\tpassive\n"; - } + $options_present = true; + $ifconfigs .= "\t\tpassive\n"; + } if (!empty($ifconfigs)) { $conffile .= " {\n {$ifconfigs} \n"; if ($options_present == true) @@ -168,7 +168,7 @@ function ospfd_install_conf() { } function ospfd_validate_interface() { - global $config, $g, $input_errors; + global $config, $g, $input_errors; if ($config['installedpackages']['ospfdinterfaces']['config']) { foreach ($config['installedpackages']['ospfdinterfaces']['config'] as $index => $conf) { @@ -199,19 +199,19 @@ function ospfd_validate_input() { // get the raw ospfd confi file for manual inspection/editing function ospfd_get_raw_config() { - return file_get_contents("/usr/local/etc/ospfd.conf"); + return file_get_contents("/usr/local/etc/ospfd.conf"); } // serialize the raw ospfd confi file to config.xml function ospfd_put_raw_config($conffile) { - global $config; - if ($conffile == "") - unset($config['installedpackages']['ospfd']['rawconfig']); - else { - $config['installedpackages']['ospfd']['rawconfig'] = array(); - $config['installedpackages']['ospfd']['rawconfig']['item'] = explode("\n",$_POST['ospfd_raw']); - $config['installedpackages']['ospfd']['rawconfig'] = $conffile; - } + global $config; + if ($conffile == "") + unset($config['installedpackages']['ospfd']['rawconfig']); + else { + $config['installedpackages']['ospfd']['rawconfig'] = array(); + $config['installedpackages']['ospfd']['rawconfig']['item'] = explode("\n",$_POST['ospfd_raw']); + $config['installedpackages']['ospfd']['rawconfig'] = $conffile; + } } function is_ospfd_running() { -- cgit v1.2.3 From 00c4a5f45db2aba344fba69304b932ccd23ffe6d Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 6 Mar 2010 15:55:17 -0500 Subject: Correct aftersaveredirect --- config/openospfd/openospfd_interfaces.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config') diff --git a/config/openospfd/openospfd_interfaces.xml b/config/openospfd/openospfd_interfaces.xml index 7802abea..5368f388 100644 --- a/config/openospfd/openospfd_interfaces.xml +++ b/config/openospfd/openospfd_interfaces.xml @@ -3,7 +3,7 @@ 0.1 Services: OpenOSPFd /usr/local/pkg/openospfd.inc - pkg_edit.php?xml=openospfd.xml&id=0 + pkg.php?xml=openospfd_interfaces.xml /usr/local/pkg/ 077 -- cgit v1.2.3 From 95c8dc4eeba3ebb9a096e3564cf1cb2223f83710 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 6 Mar 2010 16:03:31 -0500 Subject: Retain old settings --- config/openospfd/openospfd.xml | 2 +- config/openospfd/openospfd_interfaces.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'config') diff --git a/config/openospfd/openospfd.xml b/config/openospfd/openospfd.xml index 66079152..e1d8f0cb 100644 --- a/config/openospfd/openospfd.xml +++ b/config/openospfd/openospfd.xml @@ -1,5 +1,5 @@ - OpenOSPFd + ospfd 0.1 Services: OpenOSPFd /usr/local/pkg/openospfd.inc diff --git a/config/openospfd/openospfd_interfaces.xml b/config/openospfd/openospfd_interfaces.xml index 5368f388..b0d9e8ea 100644 --- a/config/openospfd/openospfd_interfaces.xml +++ b/config/openospfd/openospfd_interfaces.xml @@ -1,5 +1,5 @@ - OpenOSPFd Interfaces + OSPFd Interfaces 0.1 Services: OpenOSPFd /usr/local/pkg/openospfd.inc @@ -42,7 +42,7 @@ - ospfd + OpenOSPFd ospfd.sh ospfd -- cgit v1.2.3 From f71b09be0e7ba3aa82cb11a18ff5611d91c3a9d1 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 6 Mar 2010 16:19:24 -0500 Subject: Make tab name uniform --- config/openospfd/openospfd.inc | 2 +- config/openospfd/status_ospfd.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'config') diff --git a/config/openospfd/openospfd.inc b/config/openospfd/openospfd.inc index cc1d0de5..e0764031 100644 --- a/config/openospfd/openospfd.inc +++ b/config/openospfd/openospfd.inc @@ -222,4 +222,4 @@ function is_ospfd_running() { return false; } -?> +?> \ No newline at end of file diff --git a/config/openospfd/status_ospfd.php b/config/openospfd/status_ospfd.php index c02e5d10..e7a5b4ec 100644 --- a/config/openospfd/status_ospfd.php +++ b/config/openospfd/status_ospfd.php @@ -111,7 +111,7 @@ if(strstr($pfSversion, "1.2")) @@ -121,14 +121,14 @@ if(strstr($pfSversion, "1.2")) - - - + +
+ + ", "
- +?>
-- cgit v1.2.3 From 37f15e408cbafcd35e61fc1f6cd1e9c636f1945d Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 6 Mar 2010 16:26:25 -0500 Subject: Update service name --- config/openospfd/openospfd.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config') diff --git a/config/openospfd/openospfd.xml b/config/openospfd/openospfd.xml index e1d8f0cb..7e0713c0 100644 --- a/config/openospfd/openospfd.xml +++ b/config/openospfd/openospfd.xml @@ -42,7 +42,7 @@ - ospfd + OpenOSPFd ospfd.sh ospfd -- cgit v1.2.3 From 2ac9a4474875f588fa689e808cc809aadbf6738f Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 6 Mar 2010 16:35:27 -0500 Subject: Add helpful links to wikipedia which has a great article on ospf --- config/openospfd/openospfd.xml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'config') diff --git a/config/openospfd/openospfd.xml b/config/openospfd/openospfd.xml index 7e0713c0..a12d55dd 100644 --- a/config/openospfd/openospfd.xml +++ b/config/openospfd/openospfd.xml @@ -50,13 +50,21 @@ Router ID routerid - Specify the Router ID. + + wikipedia. + ]]> + input Area area - OpenOSPFd area for this instance of OSPF. + + wikipedia. + ]]> + input -- cgit v1.2.3 From 0b6c287292dfee8afa167feae5a31d9d2247f97b Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 6 Mar 2010 16:38:48 -0500 Subject: Fix RID text --- config/openospfd/openospfd.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'config') diff --git a/config/openospfd/openospfd.xml b/config/openospfd/openospfd.xml index a12d55dd..ebf30909 100644 --- a/config/openospfd/openospfd.xml +++ b/config/openospfd/openospfd.xml @@ -52,7 +52,7 @@ routerid wikipedia. + Specify the Router ID. RID is the highest logical (loopback) IP address configured on a router. For more information on router identifiers see wikipedia. ]]> input @@ -62,7 +62,7 @@ area wikipedia. + OpenOSPFd area for this instance of OSPF. For more information on Areas see wikipedia. ]]> input -- cgit v1.2.3 From 1c89ddf732b621aaceda0b6ea70b2cbf606868c8 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 6 Mar 2010 18:15:50 -0500 Subject: Download rules during installation --- config/apache_mod_security/apache_mod_security.inc | 8 ++++++++ config/apache_mod_security/apache_mod_security.xml | 15 --------------- 2 files changed, 8 insertions(+), 15 deletions(-) (limited to 'config') diff --git a/config/apache_mod_security/apache_mod_security.inc b/config/apache_mod_security/apache_mod_security.inc index 76aecabe..1126c309 100644 --- a/config/apache_mod_security/apache_mod_security.inc +++ b/config/apache_mod_security/apache_mod_security.inc @@ -62,6 +62,14 @@ function apache_mod_security_restart() { function apache_mod_security_install() { global $config, $g; + exec("/usr/bin/fetch -q -o " . rules_directory . "/ http://www.pfsense.com/packages/config/apache_mod_security/rules/10_asl_rules.conf"); + exec("/usr/bin/fetch -q -o " . rules_directory . "/ http://www.pfsense.com/packages/config/apache_mod_security/rules/a_exclude.conf"); + exec("/usr/bin/fetch -q -o " . rules_directory . "/ http://www.pfsense.com/packages/config/apache_mod_security/rules/blacklist.conf"); + exec("/usr/bin/fetch -q -o " . rules_directory . "/ http://www.pfsense.com/packages/config/apache_mod_security/rules/default.conf"); + exec("/usr/bin/fetch -q -o " . rules_directory . "/ http://www.pfsense.com/packages/config/apache_mod_security/rules/recons.conf"); + exec("/usr/bin/fetch -q -o " . rules_directory . "/ http://www.pfsense.com/packages/config/apache_mod_security/rules/rootkits.conf"); + exec("/usr/bin/fetch -q -o " . rules_directory . "/ http://www.pfsense.com/packages/config/apache_mod_security/rules/useragents.conf"); + // We might be reinstalling and a configuration // already exists. generate_apache_configuration(); diff --git a/config/apache_mod_security/apache_mod_security.xml b/config/apache_mod_security/apache_mod_security.xml index 23447a89..22ecb549 100644 --- a/config/apache_mod_security/apache_mod_security.xml +++ b/config/apache_mod_security/apache_mod_security.xml @@ -62,21 +62,6 @@ 0644 http://www.pfsense.com/packages/config/apache_mod_security/apache_mod_security_view_logs.php - - /usr/local/apachemodsecurity/rules/ - 0644 - http://www.pfsense.com/packages/config/apache_mod_security/rules/default.conf - - - /usr/local/apachemodsecurity/rules/ - 0644 - http://www.pfsense.com/packages/config/apache_mod_security/rules/10_asl_rules.conf - - - /usr/local/apachemodsecurity/rules/ - 0644 - http://www.pfsense.com/packages/config/apache_mod_security/rules/snortmodsec-rules.txt - Proxy Server Settings -- cgit v1.2.3 From 4f2486c194e67475384419942c8d5b2c27fdb93e Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 6 Mar 2010 18:39:01 -0500 Subject: Full path to output filename --- config/apache_mod_security/apache_mod_security.inc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'config') diff --git a/config/apache_mod_security/apache_mod_security.inc b/config/apache_mod_security/apache_mod_security.inc index 1126c309..639b2d4f 100644 --- a/config/apache_mod_security/apache_mod_security.inc +++ b/config/apache_mod_security/apache_mod_security.inc @@ -62,13 +62,13 @@ function apache_mod_security_restart() { function apache_mod_security_install() { global $config, $g; - exec("/usr/bin/fetch -q -o " . rules_directory . "/ http://www.pfsense.com/packages/config/apache_mod_security/rules/10_asl_rules.conf"); - exec("/usr/bin/fetch -q -o " . rules_directory . "/ http://www.pfsense.com/packages/config/apache_mod_security/rules/a_exclude.conf"); - exec("/usr/bin/fetch -q -o " . rules_directory . "/ http://www.pfsense.com/packages/config/apache_mod_security/rules/blacklist.conf"); - exec("/usr/bin/fetch -q -o " . rules_directory . "/ http://www.pfsense.com/packages/config/apache_mod_security/rules/default.conf"); - exec("/usr/bin/fetch -q -o " . rules_directory . "/ http://www.pfsense.com/packages/config/apache_mod_security/rules/recons.conf"); - exec("/usr/bin/fetch -q -o " . rules_directory . "/ http://www.pfsense.com/packages/config/apache_mod_security/rules/rootkits.conf"); - exec("/usr/bin/fetch -q -o " . rules_directory . "/ http://www.pfsense.com/packages/config/apache_mod_security/rules/useragents.conf"); + exec("/usr/bin/fetch -q -o " . rules_directory . "/10_asl_rules.conf http://www.pfsense.com/packages/config/apache_mod_security/rules/10_asl_rules.conf"); + exec("/usr/bin/fetch -q -o " . rules_directory . "/a_exclude.conf http://www.pfsense.com/packages/config/apache_mod_security/rules/a_exclude.conf"); + exec("/usr/bin/fetch -q -o " . rules_directory . "/blacklist.conf http://www.pfsense.com/packages/config/apache_mod_security/rules/blacklist.conf"); + exec("/usr/bin/fetch -q -o " . rules_directory . "/rules/default.conf http://www.pfsense.com/packages/config/apache_mod_security/rules/default.conf"); + exec("/usr/bin/fetch -q -o " . rules_directory . "/recons.conf http://www.pfsense.com/packages/config/apache_mod_security/rules/recons.conf"); + exec("/usr/bin/fetch -q -o " . rules_directory . "/rootkits.conf http://www.pfsense.com/packages/config/apache_mod_security/rules/rootkits.conf"); + exec("/usr/bin/fetch -q -o " . rules_directory . "/useragents.conf http://www.pfsense.com/packages/config/apache_mod_security/rules/useragents.conf"); // We might be reinstalling and a configuration // already exists. -- cgit v1.2.3 From a299a9630a0da05293bad6f8a3687fa88430eda9 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 6 Mar 2010 18:44:05 -0500 Subject: Ensure rules exists --- config/apache_mod_security/apache_mod_security.inc | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'config') diff --git a/config/apache_mod_security/apache_mod_security.inc b/config/apache_mod_security/apache_mod_security.inc index 639b2d4f..46948c37 100644 --- a/config/apache_mod_security/apache_mod_security.inc +++ b/config/apache_mod_security/apache_mod_security.inc @@ -62,14 +62,6 @@ function apache_mod_security_restart() { function apache_mod_security_install() { global $config, $g; - exec("/usr/bin/fetch -q -o " . rules_directory . "/10_asl_rules.conf http://www.pfsense.com/packages/config/apache_mod_security/rules/10_asl_rules.conf"); - exec("/usr/bin/fetch -q -o " . rules_directory . "/a_exclude.conf http://www.pfsense.com/packages/config/apache_mod_security/rules/a_exclude.conf"); - exec("/usr/bin/fetch -q -o " . rules_directory . "/blacklist.conf http://www.pfsense.com/packages/config/apache_mod_security/rules/blacklist.conf"); - exec("/usr/bin/fetch -q -o " . rules_directory . "/rules/default.conf http://www.pfsense.com/packages/config/apache_mod_security/rules/default.conf"); - exec("/usr/bin/fetch -q -o " . rules_directory . "/recons.conf http://www.pfsense.com/packages/config/apache_mod_security/rules/recons.conf"); - exec("/usr/bin/fetch -q -o " . rules_directory . "/rootkits.conf http://www.pfsense.com/packages/config/apache_mod_security/rules/rootkits.conf"); - exec("/usr/bin/fetch -q -o " . rules_directory . "/useragents.conf http://www.pfsense.com/packages/config/apache_mod_security/rules/useragents.conf"); - // We might be reinstalling and a configuration // already exists. generate_apache_configuration(); @@ -111,6 +103,20 @@ function apache_mod_security_deinstall() { // Regenerate apache configuration and handle server restart function apache_mod_security_resync() { global $config, $g; + if(!file_exists(rules_directory . "/10_asl_rules.conf")) + exec("/usr/bin/fetch -q -o " . rules_directory . "/10_asl_rules.conf http://www.pfsense.com/packages/config/apache_mod_security/rules/10_asl_rules.conf"); + if(!file_exists(rules_directory . "/a_exclude.conf")) + exec("/usr/bin/fetch -q -o " . rules_directory . "/a_exclude.conf http://www.pfsense.com/packages/config/apache_mod_security/rules/a_exclude.conf"); + if(!file_exists(rules_directory . "/blacklist.conf")) + exec("/usr/bin/fetch -q -o " . rules_directory . "/blacklist.conf http://www.pfsense.com/packages/config/apache_mod_security/rules/blacklist.conf"); + if(!file_exists(rules_directory . "/default.conf")) + exec("/usr/bin/fetch -q -o " . rules_directory . "/rules/default.conf http://www.pfsense.com/packages/config/apache_mod_security/rules/default.conf"); + if(!file_exists(rules_directory . "/recons.conf")) + exec("/usr/bin/fetch -q -o " . rules_directory . "/recons.conf http://www.pfsense.com/packages/config/apache_mod_security/rules/recons.conf"); + if(!file_exists(rules_directory . "/rootkits.conf")) + exec("/usr/bin/fetch -q -o " . rules_directory . "/rootkits.conf http://www.pfsense.com/packages/config/apache_mod_security/rules/rootkits.conf"); + if(!file_exists(rules_directory . "/useragents.conf")) + exec("/usr/bin/fetch -q -o " . rules_directory . "/useragents.conf http://www.pfsense.com/packages/config/apache_mod_security/rules/useragents.conf"); generate_apache_configuration(); apache_mod_security_checkconfig(); apache_mod_security_restart(); -- cgit v1.2.3 From fc4db470af7643f8d455de09571272dd11852f02 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 6 Mar 2010 18:45:46 -0500 Subject: Correct default bind to port description --- config/apache_mod_security/apache_mod_security_settings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config') diff --git a/config/apache_mod_security/apache_mod_security_settings.xml b/config/apache_mod_security/apache_mod_security_settings.xml index 5a5f28c4..31c777ce 100644 --- a/config/apache_mod_security/apache_mod_security_settings.xml +++ b/config/apache_mod_security/apache_mod_security_settings.xml @@ -95,7 +95,7 @@ - NOTE: Leave blank to bind to * + NOTE: Leave blank to bind to 80 ]]> input -- cgit v1.2.3 From ae255a2a82e9f6d876167707040f1474eece6391 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 6 Mar 2010 18:54:07 -0500 Subject: Run install routine on resync to ensure rc.d file exists --- config/apache_mod_security/apache_mod_security.inc | 1 + 1 file changed, 1 insertion(+) (limited to 'config') diff --git a/config/apache_mod_security/apache_mod_security.inc b/config/apache_mod_security/apache_mod_security.inc index 46948c37..94bdfdd2 100644 --- a/config/apache_mod_security/apache_mod_security.inc +++ b/config/apache_mod_security/apache_mod_security.inc @@ -103,6 +103,7 @@ function apache_mod_security_deinstall() { // Regenerate apache configuration and handle server restart function apache_mod_security_resync() { global $config, $g; + apache_mod_security_install(); if(!file_exists(rules_directory . "/10_asl_rules.conf")) exec("/usr/bin/fetch -q -o " . rules_directory . "/10_asl_rules.conf http://www.pfsense.com/packages/config/apache_mod_security/rules/10_asl_rules.conf"); if(!file_exists(rules_directory . "/a_exclude.conf")) -- cgit v1.2.3 From 03912ca67833fbface79426b6d6655310dfc5c57 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 6 Mar 2010 18:55:01 -0500 Subject: Unbreak --- config/apache_mod_security/apache_mod_security.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'config') diff --git a/config/apache_mod_security/apache_mod_security.inc b/config/apache_mod_security/apache_mod_security.inc index 94bdfdd2..64b8befc 100644 --- a/config/apache_mod_security/apache_mod_security.inc +++ b/config/apache_mod_security/apache_mod_security.inc @@ -74,7 +74,7 @@ function apache_mod_security_install() { require_once(\"/usr/local/pkg/apache_mod_security.inc\"); apache_mod_security_start(); ?> - ENDPHP\n"; +ENDPHP\n"; $stop = "/usr/local/bin/php -q -d auto_prepend_file=config.inc < - ENDPHP\n"; +ENDPHP\n"; write_rcfile(array( "file" => $filename, -- cgit v1.2.3 From 070951ebb3cd401df9e6ed52c827f93b3fb08b7a Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 6 Mar 2010 19:01:18 -0500 Subject: Ensure mod_mem_cache exists before attempting use --- config/apache_mod_security/apache_mod_security.inc | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'config') diff --git a/config/apache_mod_security/apache_mod_security.inc b/config/apache_mod_security/apache_mod_security.inc index 64b8befc..58139cc2 100644 --- a/config/apache_mod_security/apache_mod_security.inc +++ b/config/apache_mod_security/apache_mod_security.inc @@ -168,12 +168,14 @@ function generate_apache_configuration() { } // Setup mem_cache - if($config['installedpackages']['apachemodsecuritysettings']['config'][0]['mod_mem_cache']) { - if($config['installedpackages']['apachemodsecuritysettings']['config'][0]['mod_mem_cache_size']) - $mcachesize = $config['installedpackages']['apachemodsecuritysettings']['config'][0]['mod_mem_cache_size']; - else - $mcachesize = "100"; - //$mem_cache = "MCacheSize $mcachesize\n"; + if(file_exists("/usr/local/libexec/apache22/mod_mem_cache.so")) { + if($config['installedpackages']['apachemodsecuritysettings']['config'][0]['mod_mem_cache']) { + if($config['installedpackages']['apachemodsecuritysettings']['config'][0]['mod_mem_cache_size']) + $mcachesize = $config['installedpackages']['apachemodsecuritysettings']['config'][0]['mod_mem_cache_size']; + else + $mcachesize = "100"; + //$mem_cache = "MCacheSize $mcachesize\n"; + } } // CacheRoot Directive @@ -412,6 +414,9 @@ EOF; } +if(file_exists("/usr/local/libexec/apache22/mod_mem_cache.so")) + $mod_mem_cacheLoad = "Module mem_cache_module libexec/apache22/mod_mem_cache.so\n"; + $apache_config = << Date: Sat, 6 Mar 2010 19:31:20 -0500 Subject: Actually load rules --- config/apache_mod_security/apache_mod_security.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'config') diff --git a/config/apache_mod_security/apache_mod_security.inc b/config/apache_mod_security/apache_mod_security.inc index 58139cc2..5f895e3d 100644 --- a/config/apache_mod_security/apache_mod_security.inc +++ b/config/apache_mod_security/apache_mod_security.inc @@ -345,9 +345,9 @@ EOF; $mod_security_rules = ""; $files = return_dir_as_array(rules_directory); foreach($files as $file) { - if(file_exists($file)) { + if(file_exists(rules_directory . "/" . $file)) { // XXX: TODO integrate snorts rule on / off thingie - $file_txt = get_file_contents($file); + $file_txt = file_get_contents(rules_directory . "/" . $file); $mod_security_rules .= $file_txt . "\n"; } } -- cgit v1.2.3 From b994fc5f7ad9b928f56e2ab0dcadc937fa8e237e Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 6 Mar 2010 19:46:36 -0500 Subject: Version bumps for apache mod security --- config/apache_mod_security/apache_mod_security.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config') diff --git a/config/apache_mod_security/apache_mod_security.inc b/config/apache_mod_security/apache_mod_security.inc index 5f895e3d..528d284e 100644 --- a/config/apache_mod_security/apache_mod_security.inc +++ b/config/apache_mod_security/apache_mod_security.inc @@ -2,7 +2,7 @@ /* apache_mod_security.inc part of apache_mod_security package (http://www.pfSense.com) - Copyright (C) 2009 Scott Ullrich + Copyright (C) 2009, 2010 Scott Ullrich All rights reserved. Redistribution and use in source and binary forms, with or without -- cgit v1.2.3 From 330a0f8fadf1a0882df8ddc678d072bac6ae3472 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 6 Mar 2010 16:09:11 -0800 Subject: snort-dev, fix SNORT GUI for all modern browsers, start adding auto detect code based on pfsense version. --- config/snort-dev/snort.inc | 20 +++++++++++++++++++- config/snort-dev/snort_alerts.php | 9 +++++---- config/snort-dev/snort_barnyard.php | 1 + config/snort-dev/snort_blocked.php | 9 +++++---- config/snort-dev/snort_define_servers.php | 1 + config/snort-dev/snort_download_rules.php | 9 +++++---- config/snort-dev/snort_interfaces.php | 9 +++++---- config/snort-dev/snort_interfaces_edit.php | 1 + config/snort-dev/snort_interfaces_global.php | 9 +++++---- config/snort-dev/snort_preprocessors.php | 1 + config/snort-dev/snort_rules.php | 9 +++++---- config/snort-dev/snort_rulesets.php | 9 +++++---- 12 files changed, 58 insertions(+), 29 deletions(-) (limited to 'config') diff --git a/config/snort-dev/snort.inc b/config/snort-dev/snort.inc index 76a1e855..5c99f62a 100644 --- a/config/snort-dev/snort.inc +++ b/config/snort-dev/snort.inc @@ -34,6 +34,16 @@ require_once("pfsense-utils.inc"); // Needed on 2.0 because of filter_get_vpns_list() require_once("filter.inc"); +/* find out if were in 1.2.3-RELEASE */ + +$pfsense_ver_chk = exec('/bin/cat /etc/version'); +if ($pfsense_ver_chk == '1.2.3-RELEASE') +{ + $pfsense_stable = 'yes'; +}else{ + $pfsense_stable = 'no'; +} + /* Get id and realinterfaces */ $id = $_GET['id']; @@ -1173,7 +1183,15 @@ else /* grab a list of vpns and whitelist if user desires added by nestorfish 954 */ if($whitelistvpns) { - $vpns_list = filter_get_vpns_list(); + if ($pfsense_stable == 'yes') // chk what pfsense version were on + { + $vpns_list = get_vpns_list(); + } + if ($pfsense_stable == 'no') // chk what pfsense version were on + { + $vpns_list = filter_get_vpns_list(); + } + $whitelist_vpns = split(" ", $vpns_list); foreach($whitelist_vpns as $wl) if(trim($wl)) diff --git a/config/snort-dev/snort_alerts.php b/config/snort-dev/snort_alerts.php index dae9983c..4194f769 100644 --- a/config/snort-dev/snort_alerts.php +++ b/config/snort-dev/snort_alerts.php @@ -331,10 +331,11 @@ if ($pconfig['arefresh'] == 'on' || $pconfig['arefresh'] == '') $tab_array[] = array("Help & Info", false, "/snort/snort_help_info.php"); display_top_tabs($tab_array); ?> -
+
diff --git a/config/snort-dev/snort_barnyard.php b/config/snort-dev/snort_barnyard.php index 884eec5b..0e0bbf33 100644 --- a/config/snort-dev/snort_barnyard.php +++ b/config/snort-dev/snort_barnyard.php @@ -288,6 +288,7 @@ if($id != "") ?> +
+ +
diff --git a/config/snort-dev/snort_blocked.php b/config/snort-dev/snort_blocked.php index dcd2faaa..62323757 100644 --- a/config/snort-dev/snort_blocked.php +++ b/config/snort-dev/snort_blocked.php @@ -257,10 +257,11 @@ if ($pconfig['brefresh'] == 'on' || $pconfig['brefresh'] == '') $tab_array[] = array("Help & Info", false, "/snort/snort_help_info.php"); display_top_tabs($tab_array); ?> - - - - + +
+ + \n"; + echo "\n"; + } +} + +?> \ No newline at end of file diff --git a/config/snort-old/snort_blocked.php b/config/snort-old/snort_blocked.php new file mode 100644 index 00000000..ff158853 --- /dev/null +++ b/config/snort-old/snort_blocked.php @@ -0,0 +1,174 @@ + + + + + +

"; +?> + + + + + +
+
diff --git a/config/snort-dev/snort_define_servers.php b/config/snort-dev/snort_define_servers.php index 0602edf1..5b32f554 100644 --- a/config/snort-dev/snort_define_servers.php +++ b/config/snort-dev/snort_define_servers.php @@ -258,6 +258,7 @@ if($id != "") ?> +
- - -
diff --git a/config/snort-dev/snort_download_rules.php b/config/snort-dev/snort_download_rules.php index a8e3ca49..136e756b 100644 --- a/config/snort-dev/snort_download_rules.php +++ b/config/snort-dev/snort_download_rules.php @@ -245,10 +245,11 @@ setTimeout($.unblockUI, 2000); // --> - - - - + +
+ +
+
diff --git a/config/snort-dev/snort_interfaces.php b/config/snort-dev/snort_interfaces.php index c508222b..e74568a4 100644 --- a/config/snort-dev/snort_interfaces.php +++ b/config/snort-dev/snort_interfaces.php @@ -246,8 +246,9 @@ padding: 15px 10px 50% 50px; display_top_tabs($tab_array); ?> - - + diff --git a/config/snort-dev/snort_interfaces_edit.php b/config/snort-dev/snort_interfaces_edit.php index ab83f83f..1a02715c 100644 --- a/config/snort-dev/snort_interfaces_edit.php +++ b/config/snort-dev/snort_interfaces_edit.php @@ -409,6 +409,7 @@ if($id != "") ?> +
+
+
@@ -263,8 +264,8 @@ padding: 15px 10px 50% 50px;
- - + +
diff --git a/config/snort-dev/snort_interfaces_global.php b/config/snort-dev/snort_interfaces_global.php index 50ae9aec..36a56015 100644 --- a/config/snort-dev/snort_interfaces_global.php +++ b/config/snort-dev/snort_interfaces_global.php @@ -157,10 +157,11 @@ include("head.inc"); $tab_array[] = array("Help & Info", false, "/snort/snort_help_info.php"); display_top_tabs($tab_array); ?> - - \n"; - echo " \n"; - echo "
- - +
+ + diff --git a/config/snort-dev/snort_rules_edit.php b/config/snort-dev/snort_rules_edit.php index 412024d8..b770867f 100644 --- a/config/snort-dev/snort_rules_edit.php +++ b/config/snort-dev/snort_rules_edit.php @@ -1,243 +1,243 @@ -#!/usr/local/bin/php - "") { - if($_POST['highlight'] == "yes" or - $_POST['highlight'] == "enabled") { - $highlight = "yes"; - } else { - $highlight = "no"; - } -} else { - $highlight = "no"; -} - -if($_POST['rows'] <> "") - $rows = $_POST['rows']; -else - $rows = 1; - -if($_POST['cols'] <> "") - $cols = $_POST['cols']; -else - $cols = 66; - -if ($_POST) -{ - if ($_POST['save']) { - - /* get the changes */ - $rule_content2 = $_POST['code']; - - //copy string into file array for writing - $splitcontents[$lineid] = $rule_content2; - - //write the new .rules file - write_rule_file($splitcontents, $file); - - header("Location: /snort/snort_rules_edit.php?id=$id&openruleset=$file&ids=$ids"); - - } -} - -$pgtitle = array(gettext("Advanced"), gettext("File Editor")); - -// -?> - - - - -
+ + @@ -524,9 +457,9 @@ padding: 15px 10px 50% 50px;
Please edit the Global Settings tab before adding an interface.

- Click on the icon to add a interface.                           Click on the icon to start snort and barnyard. + Click on the icon to add a interface.Click on the icon to start snort and barnyard.
- Click on the icon to edit a interface and settings.      Click on the icon to stop snort and barnyard. + Click on the icon to edit a interface and settings.Click on the icon to stop snort and barnyard.
Click on the icon to delete a interface and settings. @@ -540,14 +473,82 @@ if ($pkg['tabs'] <> "") { + + +#footer2 +{ + position: relative; + top: -17px; + background-color: #cccccc; + background-image: none; + background-repeat: repeat; + background-attachment: scroll; + background-position: 0% 0%; + font-size: 0.9em; + padding-top: 0px; + padding-right: 0px; + padding-bottom: 0px; + padding-left: 10px; + clear: both; +} + + + +
+ \"Apps\" + Snort is a registered trademark of Sourcefire, Inc, Barnyard2 is a registered trademark of securixlive.com, Orion copyright Robert Zelaya, + Emergingthreats is a registered trademark of emergingthreats.net, Mysql is a registered trademark of Mysql.com +
\n"; +} + +if ($pfsense_stable != 'yes') { +$footer3 = " + + + +
+ Snort is a registered trademark of Sourcefire, Inc, Barnyard2 is a registered trademark of securixlive.com, Orion copyright Robert Zelaya, + Emergingthreats is a registered trademark of emergingthreats.net, Mysql is a registered trademark of Mysql.com +
\n"; +} +?> + + + -
- Apps - Snort® is a registered trademark of Sourcefire, Inc., Barnyard2® is a registered trademark of securixlive.com., Orion® copyright Robert Zelaya., - Emergingthreats is a registered trademark of emergingthreats.net., Mysql® is a registered trademark of Mysql.com. -
+ + Snort will log packets to a tcpdump-formatted file. The file then can be analyzed by an application such as Wireshark which understands pcap file formats. WARNING: File may become large. diff --git a/config/snort-dev/snort_interfaces_global.php b/config/snort-dev/snort_interfaces_global.php index 95b55517..de1ff812 100644 --- a/config/snort-dev/snort_interfaces_global.php +++ b/config/snort-dev/snort_interfaces_global.php @@ -33,8 +33,8 @@ */ $pgtitle = "Services: Snort: Global Settings"; -require("guiconfig.inc"); -require("/usr/local/pkg/snort/snort.inc"); +require_once("guiconfig.inc"); +require_once("/usr/local/pkg/snort/snort.inc"); /* make things short */ $pconfig['snortdownload'] = $config['installedpackages']['snortglobal']['snortdownload']; @@ -57,34 +57,7 @@ if ($_POST) { if ($_POST['enable']) { -// if ($_POST['timeout'] && (!is_numeric($_POST['timeout']) || ($_POST['timeout'] < 1))) { -// $input_errors[] = "The timeout must be at least 1 minute."; -// } -// if ($_POST['idletimeout'] && (!is_numeric($_POST['idletimeout']) || ($_POST['idletimeout'] < 1))) { -// $input_errors[] = "The idle timeout must be at least 1 minute."; -// } -// if (($_POST['radiusip'] && !is_ipaddr($_POST['radiusip']))) { -// $input_errors[] = "A valid IP address must be specified. [".$_POST['radiusip']."]"; -// } -// if (($_POST['radiusip2'] && !is_ipaddr($_POST['radiusip2']))) { -// $input_errors[] = "A valid IP address must be specified. [".$_POST['radiusip2']."]"; -// } -// if (($_POST['radiusport'] && !is_port($_POST['radiusport']))) { -// $input_errors[] = "A valid port number must be specified. [".$_POST['radiusport']."]"; -// } -// if (($_POST['radiusport2'] && !is_port($_POST['radiusport2']))) { -// $input_errors[] = "A valid port number must be specified. [".$_POST['radiusport2']."]"; -// } -// if (($_POST['radiusacctport'] && !is_port($_POST['radiusacctport']))) { -// $input_errors[] = "A valid port number must be specified. [".$_POST['radiusacctport']."]"; -// } -// if ($_POST['maxproc'] && (!is_numeric($_POST['maxproc']) || ($_POST['maxproc'] < 4) || ($_POST['maxproc'] > 100))) { -// $input_errors[] = "The total maximum number of concurrent connections must be between 4 and 100."; -// } -// $mymaxproc = $_POST['maxproc'] ? $_POST['maxproc'] : 16; -// if ($_POST['maxprocperip'] && (!is_numeric($_POST['maxprocperip']) || ($_POST['maxprocperip'] > $mymaxproc))) { -// $input_errors[] = "The maximum number of concurrent connections per client IP address may not be larger than the global maximum."; -// } +/* TODO:a dd check user input code. */ } @@ -250,16 +223,10 @@ include("head.inc"); Please choose the type of Alert logging you will like see in your alert file.
Hint: Best pratice is to chose full logging.
 WARNING: On change, alert file will be cleared.
- - - - diff --git a/config/snort-dev/snort_preprocessors.php b/config/snort-dev/snort_preprocessors.php index 8072484d..08fe2f03 100644 --- a/config/snort-dev/snort_preprocessors.php +++ b/config/snort-dev/snort_preprocessors.php @@ -30,16 +30,9 @@ POSSIBILITY OF SUCH DAMAGE. */ -/* -TODO: Nov 12 09 -Clean this code up its ugly -Important add error checking - -*/ - -require("guiconfig.inc"); -require("/usr/local/pkg/snort/snort.inc"); +require_once("guiconfig.inc"); +require_once("/usr/local/pkg/snort/snort.inc"); if (!is_array($config['installedpackages']['snortglobal']['rule'])) { $config['installedpackages']['snortglobal']['rule'] = array(); @@ -96,7 +89,7 @@ if (isset($id) && $a_nat[$id]) { $pconfig['def_imap_servers'] = $a_nat[$id]['def_imap_servers']; $pconfig['def_imap_ports'] = $a_nat[$id]['def_imap_ports']; $pconfig['def_sip_proxy_ip'] = $a_nat[$id]['def_sip_proxy_ip']; - $pconfig['ip def_sip_proxy_ports'] = $a_nat[$id]['ip def_sip_proxy_ports']; + $pconfig['def_sip_proxy_ports'] = $a_nat[$id]['def_sip_proxy_ports']; $pconfig['def_auth_ports'] = $a_nat[$id]['def_auth_ports']; $pconfig['def_finger_ports'] = $a_nat[$id]['def_finger_ports']; $pconfig['def_irc_ports'] = $a_nat[$id]['def_irc_ports']; @@ -171,7 +164,7 @@ if ($_POST) { if ($pconfig['def_imap_servers'] != "") { $natent['def_imap_servers'] = $pconfig['def_imap_servers']; } if ($pconfig['def_imap_ports'] != "") { $natent['def_imap_ports'] = $pconfig['def_imap_ports']; } if ($pconfig['def_sip_proxy_ip'] != "") { $natent['def_sip_proxy_ip'] = $pconfig['def_sip_proxy_ip']; } - if ($pconfig['ip def_sip_proxy_ports'] != "") { $natent['ip def_sip_proxy_ports'] = $pconfig['ip def_sip_proxy_ports']; } + if ($pconfig['def_sip_proxy_ports'] != "") { $natent['def_sip_proxy_ports'] = $pconfig['def_sip_proxy_ports']; } if ($pconfig['def_auth_ports'] != "") { $natent['def_auth_ports'] = $pconfig['def_auth_ports']; } if ($pconfig['def_finger_ports'] != "") { $natent['def_finger_ports'] = $pconfig['def_finger_ports']; } if ($pconfig['def_irc_ports'] != "") { $natent['def_irc_ports'] = $pconfig['def_irc_ports']; } @@ -207,6 +200,7 @@ if ($_POST) { /* enable this if you want the user to aprove changes */ // touch($d_natconfdirty_path); + sync_snort_package_all(); write_config(); @@ -327,10 +321,10 @@ if($id != "") Normalize/Decode RPC traffic and detects Back Orifice traffic on the network. - + + Normalize/Decode FTP and Telnet traffic and protocol anomalies. diff --git a/config/snort-dev/snort_rules.php b/config/snort-dev/snort_rules.php index 99e932b7..9d0cc89c 100644 --- a/config/snort-dev/snort_rules.php +++ b/config/snort-dev/snort_rules.php @@ -27,10 +27,11 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -require("guiconfig.inc"); -require("config.inc"); -require("/usr/local/pkg/snort/snort_gui.inc"); -require("/usr/local/pkg/snort/snort.inc"); + + +require_once("guiconfig.inc"); +require_once("/usr/local/pkg/snort/snort_gui.inc"); +require_once("/usr/local/pkg/snort/snort.inc"); if (!is_array($config['installedpackages']['snortglobal']['rule'])) { $config['installedpackages']['snortglobal']['rule'] = array(); @@ -453,7 +454,7 @@ function popup(url) return false; } // --> -
Install Snort.org rules diff --git a/config/snort-dev/snort_preprocessors.php b/config/snort-dev/snort_preprocessors.php index 945de8e5..f4462499 100644 --- a/config/snort-dev/snort_preprocessors.php +++ b/config/snort-dev/snort_preprocessors.php @@ -260,6 +260,7 @@ if($id != "") ?> +
+ + + + - - - - @@ -410,6 +381,7 @@ padding: 15px 10px 50% 50px; /* convert fake interfaces to real and check if iface is up */ /* There has to be a smarter way to do this */ $if_real = convert_friendly_interface_to_real_interface_name($natent['interface']); + $snort_uuid = $natent['uuid']; $color_up_ck = exec("/bin/ps -auwx | /usr/bin/grep -v grep | /usr/bin/grep snort | /usr/bin/awk '{print \$2;}' | sed 1q"); @@ -422,7 +394,7 @@ padding: 15px 10px 50% 50px; if ($color_up_ck != "") { //$color_up_pre = exec("/bin/cat /var/run/snort_{$if_real}{$nnats}{$if_real}.pid"); - $color_up_pre = exec("/usr/bin/top -a -U snort -u | grep -v grep | grep \"R $nnats$if_real\" | awk '{print \$1;}'"); + $color_up_pre = exec("/usr/bin/top -a -U snort -u | grep -v grep | grep \"R {$snort_uuid}_{$if_real}\" | awk '{print \$1;}'"); // /bin/ps -auwx | grep -v grep | grep "$id$if_real -c" | awk '{print $2;}' $color_up_s = exec("/usr/bin/top -U snort -u | grep snort | grep {$color_up_pre} | /usr/bin/awk '{print \$1;}'"); diff --git a/config/snort-dev/snort_interfaces_edit.php b/config/snort-dev/snort_interfaces_edit.php index 6bdb0dc7..f67cb828 100644 --- a/config/snort-dev/snort_interfaces_edit.php +++ b/config/snort-dev/snort_interfaces_edit.php @@ -48,6 +48,25 @@ if (isset($_GET['dup'])) { $after = $_GET['dup']; } +/* always have a limit of (65535) numbers only or snort will not start do to id limits */ +/* TODO: When inline gets added make the uuid the port number lisstening */ +//function gen_snort_uuid($fileline) +//{ + /* return the first 5 */ + //if (preg_match("/...../", $fileline, $matches1)) + //{ + //$uuid_final = "$matches1[0]"; + //} +//return $uuid_final; +//} + +/* gen uuid for each iface !inportant */ +if ($a_nat[$id]['interface'] == '') { + //$snort_uuid = gen_snort_uuid(strrev(uniqid(true))); + $snort_uuid = mt_rand(0, 65534); + $pconfig['uuid'] = $snort_uuid; +} + if (isset($id) && $a_nat[$id]) { /* old options */ @@ -97,10 +116,12 @@ if (isset($id) && $a_nat[$id]) { $pconfig['barnyard_enable'] = $a_nat[$id]['barnyard_enable']; $pconfig['barnyard_mysql'] = $a_nat[$id]['barnyard_mysql']; $pconfig['enable'] = $a_nat[$id]['enable']; + $pconfig['uuid'] = $a_nat[$id]['uuid']; $pconfig['interface'] = $a_nat[$id]['interface']; $pconfig['descr'] = $a_nat[$id]['descr']; $pconfig['performance'] = $a_nat[$id]['performance']; $pconfig['blockoffenders7'] = $a_nat[$id]['blockoffenders7']; + $pconfig['snortalertlogtype'] = $a_nat[$id]['snortalertlogtype']; $pconfig['alertsystemlog'] = $a_nat[$id]['alertsystemlog']; $pconfig['tcpdumplog'] = $a_nat[$id]['tcpdumplog']; $pconfig['snortunifiedlog'] = $a_nat[$id]['snortunifiedlog']; @@ -121,7 +142,7 @@ if (isset($_GET['dup'])) /* convert fake interfaces to real */ $if_real = convert_friendly_interface_to_real_interface_name($pconfig['interface']); -if ($_POST['Submit']) { +if ($_POST["Submit"]) { /* input validation */ // if(strtoupper($_POST['proto']) == "TCP" or strtoupper($_POST['proto']) == "UDP" or strtoupper($_POST['proto']) == "TCP/UDP") { @@ -167,26 +188,26 @@ if ($_POST['Submit']) { // if ($config['installedpackages']['snortglobal']['rule']) { -// if ($_POST['descr'] == "") { -// $input_errors[] = "Please enter a description for your reference."; -// } + if ($_POST['descr'] == "") { + $input_errors[] = "Please enter a description for your reference."; + } -// if ($id == "" && $config['installedpackages']['snortglobal']['rule'][0]['interface'] != "") { + if ($id == "" && $config['installedpackages']['snortglobal']['rule'][0]['interface'] != "") { -// $rule_array = $config['installedpackages']['snortglobal']['rule']; -// $id_c = -1; -// foreach ($rule_array as $value) { + $rule_array = $config['installedpackages']['snortglobal']['rule']; + $id_c = -1; + foreach ($rule_array as $value) { -// $id_c += 1; + $id_c += 1; -// $result_lan = $config['installedpackages']['snortglobal']['rule'][$id_c]['interface']; -// $if_real = convert_friendly_interface_to_real_interface_name($result_lan); + $result_lan = $config['installedpackages']['snortglobal']['rule'][$id_c]['interface']; + $if_real = convert_friendly_interface_to_real_interface_name($result_lan); -// if ($_POST['interface'] == $result_lan) { -// $input_errors[] = "Interface $result_lan is in use. Please select another interface."; -// } -// } -// } + if ($_POST['interface'] == $result_lan) { + $input_errors[] = "Interface $result_lan is in use. Please select another interface."; + } + } + } /* check for overlaps */ foreach ($a_nat as $natent) { @@ -204,10 +225,12 @@ if ($_POST['Submit']) { $natent['interface'] = $_POST['interface'] ? $_POST['interface'] : $pconfig['interface']; /* if post write to conf or rewite the answer */ $natent['enable'] = $_POST['enable'] ? on : off; + $natent['uuid'] = $pconfig['uuid']; $natent['descr'] = $_POST['descr'] ? $_POST['descr'] : $pconfig['descr']; $natent['performance'] = $_POST['performance'] ? $_POST['performance'] : $pconfig['performance']; /* if post = on use on off or rewrite the conf */ if ($_POST['blockoffenders7'] == "on") { $natent['blockoffenders7'] = on; }else{ $natent['blockoffenders7'] = off; } if ($_POST['enable'] == "") { $natent['blockoffenders7'] = $pconfig['blockoffenders7']; } + $natent['snortalertlogtype'] = $_POST['snortalertlogtype'] ? $_POST['snortalertlogtype'] : $pconfig['snortalertlogtype']; if ($_POST['alertsystemlog'] == "on") { $natent['alertsystemlog'] = on; }else{ $natent['alertsystemlog'] = off; } if ($_POST['enable'] == "") { $natent['alertsystemlog'] = $pconfig['alertsystemlog']; } if ($_POST['tcpdumplog'] == "on") { $natent['tcpdumplog'] = on; }else{ $natent['tcpdumplog'] = off; } if ($_POST['enable'] == "") { $natent['tcpdumplog'] = $pconfig['tcpdumplog']; } if ($_POST['snortunifiedlog'] == "on") { $natent['snortunifiedlog'] = on; }else{ $natent['snortunifiedlog'] = off; } if ($_POST['enable'] == "") { $natent['snortunifiedlog'] = $pconfig['snortunifiedlog']; } @@ -277,35 +300,61 @@ if ($_POST['Submit']) { write_config(); // stop_service("snort"); - if ($pconfig['interface'] != '' && $id != '') { + if ($pconfig['interface'] != "") { sync_snort_package_all(); - } - if ($pconfig['interface'] != '' && $id != '') { + //touch($d_natconfdirty_path); header("Location: /snort/snort_interfaces_edit.php?id=$id"); - }else{ - touch($d_natconfdirty_path); - header("Location: /snort/snort_interfaces.php"); - - } + exit; } } + if (isset($config['installedpackages']['snortglobal']['rule'][$id]['interface'])) + { + if (uniq_snort_proc($id, $if_real) == 'false') + { + $snort_up_ck = ''; + }else{ + $snort_up_ck = ''; + } + }else{ + $snort_up_ck = ''; + } + if ($_POST["Submit2"]) { - if ($id != '') - { - sync_snort_package_all(); - } + sync_snort_package_all($id, $if_real); sleep(1); - exec("/bin/sh /usr/local/etc/rc.d/snort.sh start {$id}{$if_real}"); + exec("/usr/local/bin/snort -u snort -g snort -R \"{$snort_uuid}_{$if_real}\" -D -q -l /var/log/snort -G {$snort_uuid} -c /usr/local/etc/snort/snort_{$snort_uuid}_{$if_real}/snort.conf -i {$if_real}"); header("Location: /snort/snort_interfaces_edit.php?id=$id"); exit; } -$ifname = strtoupper($pconfig['interface']); -$pgtitle = "Snort: Interface: $id$if_real Settings Edit"; + if ($_POST["Submit3"]) + { + sync_snort_package_all($id, $if_real); + sleep(1); + + $start_up_pre = exec("/usr/bin/top -a -U snort -u | grep -v grep | grep \"R {$snort_uuid}_{$if_real}\" | awk '{print \$1;}'"); + $start_up_s = exec("/usr/bin/top -U snort -u | grep snort | grep {$start_up_pre} | awk '{ print $1; }'"); + $start_up_r = exec("/usr/bin/top -U root -u | grep snort | grep {$start_up_pre} | awk '{ print $1; }'"); + + if ($start_up_s != '') + { + exec("/bin/kill {$start_up_s}"); + exec("/bin/rm /var/run/snort_{$snort_uuid}_{$if_real}*"); + } + + if ($start_up_r != '') + { + exec("/bin/kill {$start_up_r}"); + exec("/bin/rm /var/run/snort_{$snort_uuid}_{$if_real}*"); + } + } + +$iface_uuid = $a_nat[$id]['uuid']; +$pgtitle = "Snort: Interface Edit: $id $iface_uuid $if_real"; include("head.inc"); ?> @@ -313,7 +362,6 @@ include("head.inc"); -

@@ -536,10 +539,11 @@ if ($pkg['tabs'] <> "") { ?> + -
+
Apps Snort® is a registered trademark of Sourcefire, Inc., Barnyard2® is a registered trademark of securixlive.com., Orion® copyright Robert Zelaya., Emergingthreats is a registered trademark of emergingthreats.net., Mysql® is a registered trademark of Mysql.com. diff --git a/config/snort-dev/snort_interfaces_edit.php b/config/snort-dev/snort_interfaces_edit.php index f91f56eb..551c0460 100644 --- a/config/snort-dev/snort_interfaces_edit.php +++ b/config/snort-dev/snort_interfaces_edit.php @@ -305,6 +305,12 @@ if ($_POST["Submit"]) { } //touch($d_natconfdirty_path); + 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' ); + header( 'Cache-Control: post-check=0, pre-check=0', false ); + header( 'Pragma: no-cache' ); + sleep(2); header("Location: /snort/snort_interfaces_edit.php?id=$id"); exit; @@ -327,8 +333,13 @@ if ($_POST["Submit"]) { sync_snort_package_all($id, $if_real); sleep(1); exec("/usr/local/bin/snort -u snort -g snort -R \"{$snort_uuid}_{$if_real}\" -D -q -l /var/log/snort -G {$snort_uuid} -c /usr/local/etc/snort/snort_{$snort_uuid}_{$if_real}/snort.conf -i {$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' ); + header( 'Cache-Control: post-check=0, pre-check=0', false ); + header( 'Pragma: no-cache' ); + sleep(2); header("Location: /snort/snort_interfaces_edit.php?id=$id"); - exit; } if ($_POST["Submit3"]) @@ -351,6 +362,15 @@ if ($_POST["Submit"]) { exec("/bin/kill {$start_up_r}"); exec("/bin/rm /var/run/snort_{$snort_uuid}_{$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' ); + header( 'Cache-Control: post-check=0, pre-check=0', false ); + header( 'Pragma: no-cache' ); + sleep(2); + header("Location: /snort/snort_interfaces_edit.php?id=$id"); + + } $iface_uuid = $a_nat[$id]['uuid']; -- cgit v1.2.3 From e4e0be41bf8b479961c1ada2a3f9b0101021c59b Mon Sep 17 00:00:00 2001 From: robiscool Date: Wed, 17 Mar 2010 10:03:46 -0700 Subject: snort-dev, update snort.inc and snort.sh --- config/snort-dev/snort.inc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'config') diff --git a/config/snort-dev/snort.inc b/config/snort-dev/snort.inc index cd8f40ec..fa086e84 100644 --- a/config/snort-dev/snort.inc +++ b/config/snort-dev/snort.inc @@ -550,6 +550,9 @@ if ($id != '' && $if_real != '') //new /* if rules exist cp rules to each iface */ create_rules_iface($id, $if_real, $snort_uuid); + /* create snort bootup file snort.sh only create once */ + create_snort_sh(); + /* create barnyard2 configuration file */ $snortbarnyardlog_info_chk = $config['installedpackages']['snortglobal']['rule'][$id]['barnyard_enable']; if ($snortbarnyardlog_info_chk == 'on') -- cgit v1.2.3 From d802e0daa438ff5908f6d897db403d640c592fd3 Mon Sep 17 00:00:00 2001 From: robiscool Date: Wed, 17 Mar 2010 11:04:55 -0700 Subject: snort-dev, update snort.xml file --- config/snort-dev/snort.xml | 2 +- config/snort-dev/snort_whitelist.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'config') diff --git a/config/snort-dev/snort.xml b/config/snort-dev/snort.xml index b7077928..36659a11 100644 --- a/config/snort-dev/snort.xml +++ b/config/snort-dev/snort.xml @@ -99,7 +99,7 @@ http://www.pfsense.com/packages/config/snort-dev/snort_dynamic_ip_reload.php - /usr/local/pkg/ + /usr/local/pkg/snort/ 077 http://www.pfsense.com/packages/config/snort-dev/snort_whitelist.xml diff --git a/config/snort-dev/snort_whitelist.xml b/config/snort-dev/snort_whitelist.xml index 7e144f47..1ab7834a 100644 --- a/config/snort-dev/snort_whitelist.xml +++ b/config/snort-dev/snort_whitelist.xml @@ -112,6 +112,6 @@ - create_snort_conf(); + sync_snort_package_empty(); -- cgit v1.2.3 From 188bb811006990d5a825d3332d2092376501fbbb Mon Sep 17 00:00:00 2001 From: robiscool Date: Wed, 17 Mar 2010 11:48:13 -0700 Subject: snort-dev, update snort.inc for snort.xml --- config/snort-dev/snort.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'config') diff --git a/config/snort-dev/snort.inc b/config/snort-dev/snort.inc index fa086e84..b9dc590c 100644 --- a/config/snort-dev/snort.inc +++ b/config/snort-dev/snort.inc @@ -1452,8 +1452,8 @@ else if($vip['subnet']) $home_net .= $vip['subnet'] . " "; - if($config['installedpackages']['snortglobal']['whitelist']) - foreach($config['installedpackages']['snortglobal']['whitelist'] as $snort) + if($config['installedpackages']['snortglobal']['config']) + foreach($config['installedpackages']['snortglobal']['config'] as $snort) if($snort['ip']) $home_net .= $snort['ip'] . " "; -- cgit v1.2.3 From 7128847f29d3c191b3160bd3176de4b949d13373 Mon Sep 17 00:00:00 2001 From: robiscool Date: Wed, 17 Mar 2010 20:02:41 -0700 Subject: snort-dev, update paths for snort on gen tabs --- config/snort-dev/snort_alerts.php | 2 +- config/snort-dev/snort_blocked.php | 2 +- config/snort-dev/snort_download_rules.php | 2 +- config/snort-dev/snort_interfaces.php | 4 ++-- config/snort-dev/snort_interfaces_global.php | 2 +- config/snort-dev/snort_whitelist.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) (limited to 'config') diff --git a/config/snort-dev/snort_alerts.php b/config/snort-dev/snort_alerts.php index 453fc765..933db502 100644 --- a/config/snort-dev/snort_alerts.php +++ b/config/snort-dev/snort_alerts.php @@ -332,7 +332,7 @@ if ($pconfig['arefresh'] == 'on' || $pconfig['arefresh'] == '') $tab_array[] = array("Rule Updates", false, "/snort/snort_download_rules.php"); $tab_array[] = array("Alerts", true, "/snort/snort_alerts.php"); $tab_array[] = array("Blocked", false, "/snort/snort_blocked.php"); - $tab_array[] = array("Whitelists", false, "/pkg.php?xml=/snort_whitelist.xml"); + $tab_array[] = array("Whitelists", false, "/pkg.php?xml=/snort/snort_whitelist.xml"); $tab_array[] = array("Help & Info", false, "/snort/snort_help_info.php"); display_top_tabs($tab_array); ?> diff --git a/config/snort-dev/snort_blocked.php b/config/snort-dev/snort_blocked.php index 005e8033..39e9d5d1 100644 --- a/config/snort-dev/snort_blocked.php +++ b/config/snort-dev/snort_blocked.php @@ -258,7 +258,7 @@ if ($pconfig['brefresh'] == 'on' || $pconfig['brefresh'] == '') $tab_array[] = array("Rule Updates", false, "/snort/snort_download_rules.php"); $tab_array[] = array("Alerts", false, "/snort/snort_alerts.php"); $tab_array[] = array("Blocked", true, "/snort/snort_blocked.php"); - $tab_array[] = array("Whitelists", false, "/pkg.php?xml=/snort_whitelist.xml"); + $tab_array[] = array("Whitelists", false, "/pkg.php?xml=/snort/snort_whitelist.xml"); $tab_array[] = array("Help & Info", false, "/snort/snort_help_info.php"); display_top_tabs($tab_array); ?> diff --git a/config/snort-dev/snort_download_rules.php b/config/snort-dev/snort_download_rules.php index ead5d0c5..c150a934 100644 --- a/config/snort-dev/snort_download_rules.php +++ b/config/snort-dev/snort_download_rules.php @@ -113,7 +113,7 @@ echo "\n $tab_array[] = array("Rule Updates", true, "/snort/snort_download_rules.php"); $tab_array[] = array("Alerts", false, "/snort/snort_alerts.php"); $tab_array[] = array("Blocked", false, "/snort/snort_blocked.php"); - $tab_array[] = array("Whitelists", false, "/pkg.php?xml=/snort_whitelist.xml"); + $tab_array[] = array("Whitelists", false, "/pkg.php?xml=/snort/snort_whitelist.xml"); $tab_array[] = array("Help & Info", false, "/snort/snort_help_info.php"); display_top_tabs($tab_array); diff --git a/config/snort-dev/snort_interfaces.php b/config/snort-dev/snort_interfaces.php index e5e5c86b..b5bb7781 100644 --- a/config/snort-dev/snort_interfaces.php +++ b/config/snort-dev/snort_interfaces.php @@ -267,7 +267,7 @@ if ($_GET['act'] == "toggle" && $_GET['id'] != "") } -$pgtitle = "Services: Snort 2.8.5.3 pkg v. 1.14 Beta"; +$pgtitle = "Services: Snort 2.8.5.3 pkg v. 1.15 Beta"; include("head.inc"); ?> @@ -522,7 +522,7 @@ padding: 15px 10px 50% 50px;
This is the Snort Menu where you can see an over view of all your interface settings.
- Please edit the Global Settings tab befor adding an interface. + Please edit the Global Settings tab before adding an interface.

Click on the icon to add a interface.                           Click on the icon to start snort and barnyard.
diff --git a/config/snort-dev/snort_interfaces_global.php b/config/snort-dev/snort_interfaces_global.php index 2611e5c5..95b55517 100644 --- a/config/snort-dev/snort_interfaces_global.php +++ b/config/snort-dev/snort_interfaces_global.php @@ -154,7 +154,7 @@ include("head.inc"); $tab_array[] = array("Rule Updates", false, "/snort/snort_download_rules.php"); $tab_array[] = array("Alerts", false, "/snort/snort_alerts.php"); $tab_array[] = array("Blocked", false, "/snort/snort_blocked.php"); - $tab_array[] = array("Whitelists", false, "/pkg.php?xml=/snort_whitelist.xml"); + $tab_array[] = array("Whitelists", false, "/pkg.php?xml=/snort/snort_whitelist.xml"); $tab_array[] = array("Help & Info", false, "/snort/snort_help_info.php"); display_top_tabs($tab_array); ?>
diff --git a/config/snort-dev/snort_whitelist.xml b/config/snort-dev/snort_whitelist.xml index 1ab7834a..d98f83fa 100644 --- a/config/snort-dev/snort_whitelist.xml +++ b/config/snort-dev/snort_whitelist.xml @@ -73,7 +73,7 @@ Whitelist - /pkg.php?xml=/snort_whitelist.xml + /pkg.php?xml=/snort/snort_whitelist.xml -- cgit v1.2.3 From e073a1cb770bd7d4dbb46f74d72db704b800c681 Mon Sep 17 00:00:00 2001 From: robiscool Date: Wed, 17 Mar 2010 20:18:55 -0700 Subject: snort-dev, update snort-help-info.php --- config/snort-dev/snort_help_info.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config') diff --git a/config/snort-dev/snort_help_info.php b/config/snort-dev/snort_help_info.php index fb1395b8..f8d57d91 100644 --- a/config/snort-dev/snort_help_info.php +++ b/config/snort-dev/snort_help_info.php @@ -78,7 +78,7 @@ iframe $tab_array[] = array("Rule Updates", false, "/snort/snort_download_rules.php"); $tab_array[] = array("Alerts", false, "/snort/snort_alerts.php"); $tab_array[] = array("Blocked", false, "/snort/snort_blocked.php"); - $tab_array[] = array("Whitelists", false, "/pkg.php?xml=/snort_whitelist.xml"); + $tab_array[] = array("Whitelists", false, "/pkg.php?xml=/snort/snort_whitelist.xml"); $tab_array[] = array("Help & Info", true, "/snort/snort_help_info.php"); display_top_tabs($tab_array); ?> -- cgit v1.2.3 From 0f0953a249884f6bb3e67e76b1791be595772a50 Mon Sep 17 00:00:00 2001 From: thompsa Date: Fri, 19 Mar 2010 08:01:37 +1300 Subject: Fix typeo, base64deode -> base64_decode. --- config/haproxy-dev/haproxy.inc | 2 +- config/haproxy-stable/haproxy.inc | 2 +- config/haproxy/haproxy.inc | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'config') diff --git a/config/haproxy-dev/haproxy.inc b/config/haproxy-dev/haproxy.inc index 84a927c7..f14d479c 100644 --- a/config/haproxy-dev/haproxy.inc +++ b/config/haproxy-dev/haproxy.inc @@ -351,7 +351,7 @@ function haproxy_writeconf() { if(is_array($a_global)) { fwrite ($fd, "global\n"); if($a_global['advanced']) - fwrite ($fd, "\t" . base64deode($a_global['advanced']) . "\n"); + fwrite ($fd, "\t" . base64_decode($a_global['advanced']) . "\n"); fwrite ($fd, "\tmaxconn\t\t\t".$a_global['maxconn']."\n"); if($a_global['remotesyslog']) fwrite ($fd, "\tlog\t\t\t{$a_global['remotesyslog']}\t{$a_global['logfacility']}\t{$a_global['loglevel']}\n"); diff --git a/config/haproxy-stable/haproxy.inc b/config/haproxy-stable/haproxy.inc index 455638a1..5cc61e4b 100644 --- a/config/haproxy-stable/haproxy.inc +++ b/config/haproxy-stable/haproxy.inc @@ -259,7 +259,7 @@ function haproxy_configure() { if(is_array($a_global)) { fwrite ($fd, "global\n"); if($a_global['advanced']) - fwrite ($fd, "\t" . base64deode($a_global['advanced']) . "\n"); + fwrite ($fd, "\t" . base64_decode($a_global['advanced']) . "\n"); fwrite ($fd, "\tmaxconn\t\t\t".$a_global['maxconn']."\n"); if($a_global['remotesyslog']) fwrite ($fd, "\tlog\t\t\t{$a_global['remotesyslog']}\t{$a_global['logfacility']}\t{$a_global['loglevel']}\n"); diff --git a/config/haproxy/haproxy.inc b/config/haproxy/haproxy.inc index 536ef1f7..a94c84fd 100644 --- a/config/haproxy/haproxy.inc +++ b/config/haproxy/haproxy.inc @@ -109,7 +109,7 @@ function haproxy_configure() { if(is_array($a_global)) { fwrite ($fd, "global\n"); if($a_global['advanced']) - fwrite ($fd, "\t" . base64deode($a_global['advanced']) . "\n"); + fwrite ($fd, "\t" . base64_decode($a_global['advanced']) . "\n"); fwrite ($fd, "\tmaxconn\t\t\t".$a_global['maxconn']."\n"); if($a_global['remotesyslog']) fwrite ($fd, "\tlog\t\t\t{$a_global['remotesyslog']}\tlocal0\n"); @@ -417,4 +417,4 @@ function haproxy_do_xmlrpc_sync($sync_to_ip, $password) { } } -?> \ No newline at end of file +?> -- cgit v1.2.3 From 57b1446ac5fb0fead3c545264978aa7896d28654 Mon Sep 17 00:00:00 2001 From: Ermal Date: Tue, 23 Mar 2010 14:28:16 +0000 Subject: Move all spamd functions to its folder. --- config/spamd.inc | 323 ---------------------- config/spamd.xml | 211 -------------- config/spamd/spamd.inc | 323 ++++++++++++++++++++++ config/spamd/spamd.xml | 211 ++++++++++++++ config/spamd/spamd_db.php | 457 +++++++++++++++++++++++++++++++ config/spamd/spamd_db_ext.php | 239 ++++++++++++++++ config/spamd/spamd_exchexp.asp | 50 ++++ config/spamd/spamd_gather_stats.php | 82 ++++++ config/spamd/spamd_outlook.xml | 90 ++++++ config/spamd/spamd_rules.php | 34 +++ config/spamd/spamd_settings.xml | 192 +++++++++++++ config/spamd/spamd_verify_to_address.php | 144 ++++++++++ config/spamd/spamd_whitelist.xml | 132 +++++++++ config/spamd_db.php | 457 ------------------------------- config/spamd_db_ext.php | 239 ---------------- config/spamd_exchexp.asp | 50 ---- config/spamd_gather_stats.php | 82 ------ config/spamd_outlook.xml | 90 ------ config/spamd_rules.php | 34 --- config/spamd_settings.xml | 192 ------------- config/spamd_verify_to_address.php | 144 ---------- config/spamd_whitelist.xml | 132 --------- 22 files changed, 1954 insertions(+), 1954 deletions(-) delete mode 100644 config/spamd.inc delete mode 100644 config/spamd.xml create mode 100644 config/spamd/spamd.inc create mode 100644 config/spamd/spamd.xml create mode 100644 config/spamd/spamd_db.php create mode 100644 config/spamd/spamd_db_ext.php create mode 100644 config/spamd/spamd_exchexp.asp create mode 100644 config/spamd/spamd_gather_stats.php create mode 100644 config/spamd/spamd_outlook.xml create mode 100644 config/spamd/spamd_rules.php create mode 100644 config/spamd/spamd_settings.xml create mode 100644 config/spamd/spamd_verify_to_address.php create mode 100644 config/spamd/spamd_whitelist.xml delete mode 100644 config/spamd_db.php delete mode 100644 config/spamd_db_ext.php delete mode 100644 config/spamd_exchexp.asp delete mode 100644 config/spamd_gather_stats.php delete mode 100644 config/spamd_outlook.xml delete mode 100644 config/spamd_rules.php delete mode 100644 config/spamd_settings.xml delete mode 100644 config/spamd_verify_to_address.php delete mode 100644 config/spamd_whitelist.xml (limited to 'config') diff --git a/config/spamd.inc b/config/spamd.inc deleted file mode 100644 index 8747df29..00000000 --- a/config/spamd.inc +++ /dev/null @@ -1,323 +0,0 @@ - "") - $nextmta = $ss['nextmta']; - if($ss['greylistingparms'] <> "") - $passtime = " -G " . $ss['greylistingparms']; - if($ss['identifier'] <> "") - $identifier = " -n \"" . $ss['identifier'] . "\""; - // Default is greylisting, turn on blacklisting if not checked. - if($ss['greylisting'] <> "on") - $greylisting = " -b"; - if($ss['maxblack'] <> "") - $maxblack = " -B " . $ss['maxblack']; - if($ss['maxcon'] <> "") - $maxcon = " -c " . $ss['maxcon']; - if($ss['stuttersecs'] <> "") - $stuttersecs = " -S " . $ss['stuttersecs']; - if($ss['delaysecs'] <> "") - $delaysecs = " -s " . $ss['delaysecs']; - if($ss['window'] <> "") - $window = " -w " . $ss['window']; - if($ss['passtime'] <> "") - $passtime = $ss['passtime']; - if($ss['greyexp'] <> "") - $greyexp = $ss['greyexp']; - if($ss['whiteexp'] <> "") - $whiteexp = $ss['whiteexp']; - } - } - $greyparms = " -G {$passtime}:{$greyexp}:{$whiteexp}"; - $start = "if [ `mount | grep -v grep | grep fdescfs | wc -l` -lt 1 ]; then \n" . - "/sbin/mount -t fdescfs fdescfs /dev/fd\n" . - "fi\n" . - "/usr/local/sbin/spamd-setup -d &\n" . - "/sbin/pflogd &\n" . - "/usr/local/libexec/spamd {$greyparms}{$identifier}{$greylisting}{$maxcon}{$maxblack}{$window}{$replysmtperror} 127.0.0.1 &\n" . - "/usr/local/libexec/spamlogd\n"; - $stop = "/usr/bin/killall spamd-setup\n" . - "/usr/bin/killall spamlogd\n" . - "/usr/bin/killall spamd\n" . - "/usr/bin/killall pflogd\n" . - "sleep 2"; - log_error("Writing rc_file"); - write_rcfile(array( - "file" => "spamd.sh", - "start" => $start, - "stop" => $stop - ) - ); - log_error("Installing CRON"); - spamd_install_cron(true); - log_error("Mounting RO"); - conf_mount_ro(); - log_error("Unlocking config"); - config_unlock(); - log_error("Restart cron"); - mwexec("killall -HUP cron"); - log_error("Setting up spamd.conf symlink"); - mwexec("ln -s /etc/spamd.conf /usr/local/etc/spamd/spamd.conf"); - log_error("Stopping spamd"); - mwexec("/usr/local/etc/rc.d/spamd.sh stop"); - sleep(1); - log_error("Starting spamd"); - mwexec_bg("/usr/local/etc/rc.d/spamd.sh start"); - log_error("Reconfiguring filter"); - filter_configure(); - log_error("SpamD setup completed"); -} - -function spamd_generate_rules($type) { - global $config; - - $natrules = ""; - switch($type) { - case 'rdr': - $natrules .= "\n# spam table \n"; - $wanif = get_real_interface("wan"); - $natrules .= "table persist\n"; - $natrules .= "table persist\n"; - $natrules .= "table persist\n"; - if(file_exists("/var/db/whitelist.txt")) - $natrules .= "table persist file \"/var/db/whitelist.txt\"\n"; - $natrules .= "rdr pass on {$wanif} proto tcp from to port smtp -> 127.0.0.1 port spamd\n"; - $natrules .= "rdr pass on {$wanif} proto tcp from to port smtp -> 127.0.0.1 port spamd\n"; - $natrules .= "rdr pass on {$wanif} proto tcp from ! to port smtp -> 127.0.0.1 port spamd\n"; - if($config['installedpackages']['spamdsettings']['config']) - foreach($config['installedpackages']['spamdsettings']['config'] as $ss) - $nextmta = $ss['nextmta']; - if($nextmta <> "") { - $natrules .= "rdr pass on {$wanif} proto tcp from to port smtp -> {$nextmta} port smtp\n"; - } - - break; - } - - return $natrules; -} - -function remove_spaces($string) { - $string = str_replace(" ", "", $string); - return $string; -} - -function sync_spamd_config_to_backup() { - global $g, $config; - if(is_array($config['installedpackages']['carpsettings']['config'])) { - foreach($config['installedpackages']['carpsettings']['config'] as $carp) { - if($carp['synchronizetoip'] != "" ) { - $synctoip = $carp['synchronizetoip']; - $password = $carp['password']; - if($config['system']['username']) - $username = $config['system']['username']; - else - $username = "admin"; - } - } - } - if($synctoip and $password) { - 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"; - } - } - $params = array(XML_RPC_encode($password),XML_RPC_encode($xml)); - /* create files to sync array */ - $filetosync = array("/var/db/spamd", "/var/db/whitelist.txt"); - /* loop through files to sync list and sync them up */ - foreach($filetosync as $f2s) { - $f2c_contents = file_get_contents($f2s); - xmlrpc_sync_file($url, $password, $f2s, $f2c_contents, $port); - } - /* signal remote process config reload */ - xmlrpc_exec_shell($url, $password, "/usr/bin/killall -HUP spamlogd", $port); - xmlrpc_exec_shell($url, $password, "/usr/bin/killall -HUP spamd", $port); - } -} - -function custom_php_install_command() { - global $config, $g; - system("touch /var/db/whitelist.txt"); - system("touch /var/db/blacklist.txt"); - sync_package_spamd(); - exec("pw user mod_spamd -u 0"); -} - -function custom_php_deinstall_command() { - global $config, $g; - conf_mount_rw(); - exec("killall -9 spamd"); - unlink_if_exists("/usr/local/pkg/pf/spamd_rules.php"); - unlink_if_exists("/usr/local/www/spamd_rules.php"); - unlink_if_exists("/usr/local/etc/rc.d/spamd.sh"); - spamd_install_cron(false); - conf_mount_ro(); - filter_configure(); -} - -function spamd_install_cron($should_install) { - global $config, $g; - $is_installed = false; - if(!$config['cron']['item']) - return; - $x=0; - foreach($config['cron']['item'] as $item) { - if(strstr($item['command'], "spamd-setup")) { - $is_installed = true; - break; - } - $x++; - } - switch($should_install) { - case true: - if(!$is_installed) { - $cron_item = array(); - $cron_item['minute'] = "*/120"; - $cron_item['hour'] = "*"; - $cron_item['mday'] = "*"; - $cron_item['month'] = "*"; - $cron_item['wday'] = "*"; - $cron_item['who'] = "root"; - $cron_item['command'] = "/usr/bin/nice -n20 /usr/local/sbin/spamd-setup"; - $config['cron']['item'][] = $cron_item; - write_config("Installed SPAMD crontab entries."); - configure_cron(); - } - break; - case false: - if($is_installed == true) { - if($x > 0) { - unset($config['cron']['item'][$x]); - write_config(); - } - configure_cron(); - } - break; - } -} - -function spamd_validate_input($post, $input_errors) { - global $config, $g; - $nextmta = str_replace("$", "", $post['nextmta']); - if(stristr($nextmta, "{")) { - /* item is an alias, make sure the name exists */ - $nextmta = str_replace("$", "", $nextmta); - $found = false; - if($config['aliases']['alias']) { - foreach($config['aliases']['alias'] as $alias) { - if($alias['name'] == $nextmta) { - $found = true; - } - } - } - if($found == false) - $intput_errors = "Could not locate alias named " . htmlentities($nextmta); - } -} - -?> \ No newline at end of file diff --git a/config/spamd.xml b/config/spamd.xml deleted file mode 100644 index 5bbc5d71..00000000 --- a/config/spamd.xml +++ /dev/null @@ -1,211 +0,0 @@ - - - - - - - - Describe your package here - Describe your package requirements here - Currently there are no FAQ items provided. - spamdsources - 4.2 - SpamD: External Sources - /usr/local/pkg/spamd.inc - /var/db/spamd - - - SpamD -
Services
- spamd.xml -
- - spamd - /usr/local/etc/rc.d/spamd.sh - - - - SpamD External Sources - /pkg.php?xml=spamd.xml - - - - SpamD Whitelist - /pkg.php?xml=spamd_whitelist.xml - - - SpamD Settings - /pkg_edit.php?xml=spamd_settings.xml&id=0 - - - SpamD Database - /spamd_db.php - - - - ['installedpackages']['spamd']['config'] - - - Provider Name - providername - - - Provider Type - providertype - - - Description - providerdescription - - - - /usr/local/www/ - 0755 - http://www.pfsense.com/packages/config/spamd_rules.php - - - /usr/local/pkg/ - 0755 - http://www.pfsense.com/packages/config/spamd_whitelist.xml - - - /usr/local/pkg/ - 0755 - http://www.pfsense.com/packages/config/spamd_outlook.xml - - - /usr/local/pkg/ - 0755 - http://www.pfsense.com/packages/config/spamd.inc - - - /usr/local/pkg/ - 0755 - http://www.pfsense.com/packages/config/spamd_settings.xml - - - /usr/local/www/ - 0755 - http://www.pfsense.com/packages/config/spamd_db.php - - - /usr/local/www/ - 0755 - http://www.pfsense.com/packages/config/spamd_db_ext.php - - - /usr/local/bin/ - 0755 - http://www.pfsense.com/packages/config/spamd_gather_stats.php - - - - - - Provider Name - providername - Enter the name of the source - input - 30 - - - Provider Type - providertype - Select the Provider Type - select - 1 - black - - - - - - - Provider Description - providerdescription - Enter the description for this item - textarea - 30 - 40 - 4 - - - Reject message - rejectmessage - Enter the message to display to emailing parties that are on this providers list - textarea - 30 - 40 - 2 - - - Provider Method - providermethod - Select the Provider Method - select - 1 - http - - - - - - - - Provider URL or Filename - providerurl - Enter the URL to the provider. - textarea - 40 - 4 - - - - sync_package_spamd(); - - - sync_package_spamd(); - - - custom_php_install_command(); - - - custom_php_deinstall_command(); - - spamd_generate_rules -
diff --git a/config/spamd/spamd.inc b/config/spamd/spamd.inc new file mode 100644 index 00000000..8747df29 --- /dev/null +++ b/config/spamd/spamd.inc @@ -0,0 +1,323 @@ + "") + $nextmta = $ss['nextmta']; + if($ss['greylistingparms'] <> "") + $passtime = " -G " . $ss['greylistingparms']; + if($ss['identifier'] <> "") + $identifier = " -n \"" . $ss['identifier'] . "\""; + // Default is greylisting, turn on blacklisting if not checked. + if($ss['greylisting'] <> "on") + $greylisting = " -b"; + if($ss['maxblack'] <> "") + $maxblack = " -B " . $ss['maxblack']; + if($ss['maxcon'] <> "") + $maxcon = " -c " . $ss['maxcon']; + if($ss['stuttersecs'] <> "") + $stuttersecs = " -S " . $ss['stuttersecs']; + if($ss['delaysecs'] <> "") + $delaysecs = " -s " . $ss['delaysecs']; + if($ss['window'] <> "") + $window = " -w " . $ss['window']; + if($ss['passtime'] <> "") + $passtime = $ss['passtime']; + if($ss['greyexp'] <> "") + $greyexp = $ss['greyexp']; + if($ss['whiteexp'] <> "") + $whiteexp = $ss['whiteexp']; + } + } + $greyparms = " -G {$passtime}:{$greyexp}:{$whiteexp}"; + $start = "if [ `mount | grep -v grep | grep fdescfs | wc -l` -lt 1 ]; then \n" . + "/sbin/mount -t fdescfs fdescfs /dev/fd\n" . + "fi\n" . + "/usr/local/sbin/spamd-setup -d &\n" . + "/sbin/pflogd &\n" . + "/usr/local/libexec/spamd {$greyparms}{$identifier}{$greylisting}{$maxcon}{$maxblack}{$window}{$replysmtperror} 127.0.0.1 &\n" . + "/usr/local/libexec/spamlogd\n"; + $stop = "/usr/bin/killall spamd-setup\n" . + "/usr/bin/killall spamlogd\n" . + "/usr/bin/killall spamd\n" . + "/usr/bin/killall pflogd\n" . + "sleep 2"; + log_error("Writing rc_file"); + write_rcfile(array( + "file" => "spamd.sh", + "start" => $start, + "stop" => $stop + ) + ); + log_error("Installing CRON"); + spamd_install_cron(true); + log_error("Mounting RO"); + conf_mount_ro(); + log_error("Unlocking config"); + config_unlock(); + log_error("Restart cron"); + mwexec("killall -HUP cron"); + log_error("Setting up spamd.conf symlink"); + mwexec("ln -s /etc/spamd.conf /usr/local/etc/spamd/spamd.conf"); + log_error("Stopping spamd"); + mwexec("/usr/local/etc/rc.d/spamd.sh stop"); + sleep(1); + log_error("Starting spamd"); + mwexec_bg("/usr/local/etc/rc.d/spamd.sh start"); + log_error("Reconfiguring filter"); + filter_configure(); + log_error("SpamD setup completed"); +} + +function spamd_generate_rules($type) { + global $config; + + $natrules = ""; + switch($type) { + case 'rdr': + $natrules .= "\n# spam table \n"; + $wanif = get_real_interface("wan"); + $natrules .= "table persist\n"; + $natrules .= "table persist\n"; + $natrules .= "table persist\n"; + if(file_exists("/var/db/whitelist.txt")) + $natrules .= "table persist file \"/var/db/whitelist.txt\"\n"; + $natrules .= "rdr pass on {$wanif} proto tcp from to port smtp -> 127.0.0.1 port spamd\n"; + $natrules .= "rdr pass on {$wanif} proto tcp from to port smtp -> 127.0.0.1 port spamd\n"; + $natrules .= "rdr pass on {$wanif} proto tcp from ! to port smtp -> 127.0.0.1 port spamd\n"; + if($config['installedpackages']['spamdsettings']['config']) + foreach($config['installedpackages']['spamdsettings']['config'] as $ss) + $nextmta = $ss['nextmta']; + if($nextmta <> "") { + $natrules .= "rdr pass on {$wanif} proto tcp from to port smtp -> {$nextmta} port smtp\n"; + } + + break; + } + + return $natrules; +} + +function remove_spaces($string) { + $string = str_replace(" ", "", $string); + return $string; +} + +function sync_spamd_config_to_backup() { + global $g, $config; + if(is_array($config['installedpackages']['carpsettings']['config'])) { + foreach($config['installedpackages']['carpsettings']['config'] as $carp) { + if($carp['synchronizetoip'] != "" ) { + $synctoip = $carp['synchronizetoip']; + $password = $carp['password']; + if($config['system']['username']) + $username = $config['system']['username']; + else + $username = "admin"; + } + } + } + if($synctoip and $password) { + 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"; + } + } + $params = array(XML_RPC_encode($password),XML_RPC_encode($xml)); + /* create files to sync array */ + $filetosync = array("/var/db/spamd", "/var/db/whitelist.txt"); + /* loop through files to sync list and sync them up */ + foreach($filetosync as $f2s) { + $f2c_contents = file_get_contents($f2s); + xmlrpc_sync_file($url, $password, $f2s, $f2c_contents, $port); + } + /* signal remote process config reload */ + xmlrpc_exec_shell($url, $password, "/usr/bin/killall -HUP spamlogd", $port); + xmlrpc_exec_shell($url, $password, "/usr/bin/killall -HUP spamd", $port); + } +} + +function custom_php_install_command() { + global $config, $g; + system("touch /var/db/whitelist.txt"); + system("touch /var/db/blacklist.txt"); + sync_package_spamd(); + exec("pw user mod_spamd -u 0"); +} + +function custom_php_deinstall_command() { + global $config, $g; + conf_mount_rw(); + exec("killall -9 spamd"); + unlink_if_exists("/usr/local/pkg/pf/spamd_rules.php"); + unlink_if_exists("/usr/local/www/spamd_rules.php"); + unlink_if_exists("/usr/local/etc/rc.d/spamd.sh"); + spamd_install_cron(false); + conf_mount_ro(); + filter_configure(); +} + +function spamd_install_cron($should_install) { + global $config, $g; + $is_installed = false; + if(!$config['cron']['item']) + return; + $x=0; + foreach($config['cron']['item'] as $item) { + if(strstr($item['command'], "spamd-setup")) { + $is_installed = true; + break; + } + $x++; + } + switch($should_install) { + case true: + if(!$is_installed) { + $cron_item = array(); + $cron_item['minute'] = "*/120"; + $cron_item['hour'] = "*"; + $cron_item['mday'] = "*"; + $cron_item['month'] = "*"; + $cron_item['wday'] = "*"; + $cron_item['who'] = "root"; + $cron_item['command'] = "/usr/bin/nice -n20 /usr/local/sbin/spamd-setup"; + $config['cron']['item'][] = $cron_item; + write_config("Installed SPAMD crontab entries."); + configure_cron(); + } + break; + case false: + if($is_installed == true) { + if($x > 0) { + unset($config['cron']['item'][$x]); + write_config(); + } + configure_cron(); + } + break; + } +} + +function spamd_validate_input($post, $input_errors) { + global $config, $g; + $nextmta = str_replace("$", "", $post['nextmta']); + if(stristr($nextmta, "{")) { + /* item is an alias, make sure the name exists */ + $nextmta = str_replace("$", "", $nextmta); + $found = false; + if($config['aliases']['alias']) { + foreach($config['aliases']['alias'] as $alias) { + if($alias['name'] == $nextmta) { + $found = true; + } + } + } + if($found == false) + $intput_errors = "Could not locate alias named " . htmlentities($nextmta); + } +} + +?> \ No newline at end of file diff --git a/config/spamd/spamd.xml b/config/spamd/spamd.xml new file mode 100644 index 00000000..5bbc5d71 --- /dev/null +++ b/config/spamd/spamd.xml @@ -0,0 +1,211 @@ + + + + + + + + Describe your package here + Describe your package requirements here + Currently there are no FAQ items provided. + spamdsources + 4.2 + SpamD: External Sources + /usr/local/pkg/spamd.inc + /var/db/spamd + + + SpamD +
Services
+ spamd.xml +
+ + spamd + /usr/local/etc/rc.d/spamd.sh + + + + SpamD External Sources + /pkg.php?xml=spamd.xml + + + + SpamD Whitelist + /pkg.php?xml=spamd_whitelist.xml + + + SpamD Settings + /pkg_edit.php?xml=spamd_settings.xml&id=0 + + + SpamD Database + /spamd_db.php + + + + ['installedpackages']['spamd']['config'] + + + Provider Name + providername + + + Provider Type + providertype + + + Description + providerdescription + + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/spamd_rules.php + + + /usr/local/pkg/ + 0755 + http://www.pfsense.com/packages/config/spamd_whitelist.xml + + + /usr/local/pkg/ + 0755 + http://www.pfsense.com/packages/config/spamd_outlook.xml + + + /usr/local/pkg/ + 0755 + http://www.pfsense.com/packages/config/spamd.inc + + + /usr/local/pkg/ + 0755 + http://www.pfsense.com/packages/config/spamd_settings.xml + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/spamd_db.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/spamd_db_ext.php + + + /usr/local/bin/ + 0755 + http://www.pfsense.com/packages/config/spamd_gather_stats.php + + + + + + Provider Name + providername + Enter the name of the source + input + 30 + + + Provider Type + providertype + Select the Provider Type + select + 1 + black + + + + + + + Provider Description + providerdescription + Enter the description for this item + textarea + 30 + 40 + 4 + + + Reject message + rejectmessage + Enter the message to display to emailing parties that are on this providers list + textarea + 30 + 40 + 2 + + + Provider Method + providermethod + Select the Provider Method + select + 1 + http + + + + + + + + Provider URL or Filename + providerurl + Enter the URL to the provider. + textarea + 40 + 4 + + + + sync_package_spamd(); + + + sync_package_spamd(); + + + custom_php_install_command(); + + + custom_php_deinstall_command(); + + spamd_generate_rules +
diff --git a/config/spamd/spamd_db.php b/config/spamd/spamd_db.php new file mode 100644 index 00000000..112fdd71 --- /dev/null +++ b/config/spamd/spamd_db.php @@ -0,0 +1,457 @@ +","",$srcip); + $srcip = str_replace(" ","",$srcip); + // Make input safe + $srcip = escapeshellarg($srcip); + /* execute spamdb command */ + if($action == "'whitelist'") { + exec("/usr/local/sbin/spamdb -d {$srcip}"); + exec("/usr/local/sbin/spamdb -d {$srcip} -T"); + exec("/usr/local/sbin/spamdb -d {$srcip} -t"); + delete_from_blacklist($srcip); + mwexec("/sbin/pfctl -q -t blacklist -T replace -f /var/db/blacklist.txt"); + exec("echo spamdb -a {$srcip} > /tmp/tmp"); + exec("/usr/local/sbin/spamdb -a {$srcip}"); + } else if($action == "'delete'") { + exec("/usr/local/sbin/spamdb -d {$srcip}"); + exec("/usr/local/sbin/spamdb -d {$srcip} -T"); + exec("/usr/local/sbin/spamdb -d {$srcip} -t"); + delete_from_blacklist($srcip); + mwexec("/sbin/pfctl -q -t spamd -T delete $srcip"); + mwexec("/sbin/pfctl -q -t blacklist -T replace -f /var/db/blacklist.txt"); + } else if($action == "'spamtrap'") { + exec("/usr/local/sbin/spamdb -d {$srcip}"); + exec("/usr/local/sbin/spamdb -d {$srcip} -T"); + exec("/usr/local/sbin/spamdb -d {$srcip} -t"); + exec("/usr/local/sbin/spamdb -a {$srcip} -T"); + } else if($action == "'trapped'") { + exec("/usr/local/sbin/spamdb -T -d {$toaddress}"); + exec("/usr/local/sbin/spamdb -T -a '{$toaddress}'"); + } + /* signal a reload for real time effect. */ + mwexec("killall -HUP spamlogd"); + exit; +} + +/* spam trap e-mail address */ +if($_POST['spamtrapemail'] <> "") { + $spamtrapemail = escapeshellarg($_POST['spamtrapemail']); + exec("/usr/local/sbin/spamdb -d {$spamtrapemail}"); + exec("/usr/local/sbin/spamdb -d -T {$spamtrapemail}"); + exec("/usr/local/sbin/spamdb -d -t {$spamtrapemail}"); + exec("/usr/local/sbin/spamdb -T -a '{$toaddress}'"); + + mwexec("killall -HUP spamlogd"); + $savemsg = htmlentities($_POST['spamtrapemail']) . " added to spam trap database."; +} + +if($_GET['getstatus'] <> "") { + $status = exec("/usr/local/sbin/spamdb | grep \"{$_GET['getstatus']}\""); + if(stristr($status, "WHITE") == true) { + echo "WHITE"; + } else if(stristr($status, "TRAPPED") == true) { + echo "TRAPPED"; + } else if(stristr($status, "GREY") == true) { + echo "GREY"; + } else if(stristr($status, "SPAMTRAP") == true) { + echo "SPAMTRAP"; + } else { + echo "NOT FOUND"; + } + exit; +} + +/* spam trap e-mail address */ +if($_GET['spamtrapemail'] <> "") { + $spamtrapemail = escapeshellarg($_GET['spamtrapemail']); + $status = exec("spamdb -T -a {$spamtrapemail}"); + mwexec("killall -HUP spamlogd"); + if($status) + echo $status; + else + echo htmlentities($_POST['spamtrapemail']) . " added to spam trap database."; + exit; +} + +/* whitelist e-mail address */ +if($_GET['whitelist'] <> "") { + $spamtrapemail = escapeshellarg($_GET['spamtrapemail']); + $status = exec("spamdb -a {$spamtrapemail}"); + mwexec("killall -HUP spamlogd"); + if($status) + echo $status; + else + echo htmlentities($_POST['spamtrapemail']) . " added to whitelist database."; + exit; +} + +function delete_from_blacklist($srcip) { + config_lock(); + $blacklist = split("\n", file_get_contents("/var/db/blacklist.txt")); + $fd = fopen("/var/db/blacklist.txt", "w"); + foreach($blacklist as $bl) { + if($bl <> "") + if(!stristr($bl, $srcip)) + fwrite($fd, "{$bl}\n"); + } + fclose($fd); + mwexec("/sbin/pfctl -q -t spamd -T delete {$srcip}"); + mwexec("/sbin/pfctl -q -t blacklist -T replace -f /var/db/blacklist.txt"); + config_unlock(); +} + +function delete_from_whitelist($srcip) { + config_lock(); + $whitelist = split("\n", file_get_contents("/var/db/whitelist.txt")); + $fd = fopen("/var/db/whitelist.txt", "w"); + foreach($whitelist as $wl) { + if($wl <> "") + if(!stristr($wl, $srcip)) + fwrite($fd, "{$wl}\n"); + } + fclose($fd); + mwexec("/sbin/pfctl -q -t spamd -T delete $srcip"); + mwexec("/sbin/pfctl -q -t whitelist -T replace -f /var/db/whitelist.txt"); + config_unlock(); +} + +$pgtitle = "SpamD: Database"; +include("head.inc"); + +if(file_exists("/var/db/whitelist.txt")) + $whitelist_items = `cat /var/db/whitelist.txt | wc -l`; +else + $whitelist_items = 0; + +if(file_exists("/var/db/blacklist.txt")) + $blacklist_items = `cat /var/db/blacklist.txt | wc -l`; +else + $blacklist_items = 0; + +// Get an overall count of the database +$spamdb_items = `/usr/local/sbin/spamdb | wc -l`; + +// Get blacklist and whitelist count from database +$spamdb_white = `/usr/local/sbin/spamdb | grep WHITE | wc -l`; +$spamdb_black = `/usr/local/sbin/spamdb | grep BLACK | wc -l`; +$spamdb_grey = `/usr/local/sbin/spamdb | grep GREY | wc -l`; + +// Now count the user contributed whitelist and blacklist count +$whitelist_items = $whitelist_items + $spamdb_white; +$blacklist_items = $blacklist_items + $spamdb_black; + +?> + + +

+
+ + + + + + +

+ +

diff --git a/config/snort-dev/snort_rules.php b/config/snort-dev/snort_rules.php index ea0f8a0f..c08aea50 100644 --- a/config/snort-dev/snort_rules.php +++ b/config/snort-dev/snort_rules.php @@ -461,10 +461,11 @@ function popup(url) $tab_array[] = array("Barnyard2", false, "/snort/snort_barnyard.php?id={$id}"); display_top_tabs($tab_array); ?> - - - - + +
+ + + -
-
+
diff --git a/config/snort-dev/snort_rulesets.php b/config/snort-dev/snort_rulesets.php index 5133183e..2edfdde4 100644 --- a/config/snort-dev/snort_rulesets.php +++ b/config/snort-dev/snort_rulesets.php @@ -170,10 +170,11 @@ echo " - - - - + +
+ +
+
-- cgit v1.2.3 From 4ddcb729b32fe87ac4d6e87c62f62d3ea40f0d4b Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 6 Mar 2010 20:10:10 -0500 Subject: Check to see if something is already listening on the port selected and refuse to bind if something is already occupying the port. Log an error if needed. --- config/apache_mod_security/apache_mod_security.inc | 38 +++++++++++++++------- 1 file changed, 26 insertions(+), 12 deletions(-) (limited to 'config') diff --git a/config/apache_mod_security/apache_mod_security.inc b/config/apache_mod_security/apache_mod_security.inc index 528d284e..593e04b2 100644 --- a/config/apache_mod_security/apache_mod_security.inc +++ b/config/apache_mod_security/apache_mod_security.inc @@ -152,19 +152,33 @@ function generate_apache_configuration() { $servername = "ServerName " . `hostname` . "\n"; } - // Set global listening directive - if($config['installedpackages']['apachemodsecuritysettings']['config'][0]['globalbindtoipaddr']) { - $global_listen = $config['installedpackages']['apachemodsecuritysettings']['config'][0]['globalbindtoipaddr']; - if($config['installedpackages']['apachemodsecuritysettings']['config'][0]['globalbindtoport']) - $global_listen .= ":" . $config['installedpackages']['apachemodsecuritysettings']['config'][0]['globalbindtoport']; - else - $global_listen .= ":80"; + // Set global listening directive and ensure nothing is listening on this port already + $globalbind = $config['installedpackages']['apachemodsecuritysettings']['config'][0]['globalbindtoipaddr']; + $socksstat = split("\n", `/usr/bin/sockstat | awk '{ print $6 }' | grep ":{$globalbind}" | cut -d ":" -f2`); + if(is_array($socksstat)) { + foreach($socksstat as $ss) { + if($ss == $globalbind) { + $already_binded = true; + $input_errors[] = "Sorry, there is a process already listening on port {$globalbind}"; + } + } + } + if(!$already_binded) { + if($config['installedpackages']['apachemodsecuritysettings']['config'][0]['globalbindtoipaddr']) { + $global_listen = $config['installedpackages']['apachemodsecuritysettings']['config'][0]['globalbindtoipaddr']; + if($config['installedpackages']['apachemodsecuritysettings']['config'][0]['globalbindtoport']) + $global_listen .= ":" . $config['installedpackages']['apachemodsecuritysettings']['config'][0]['globalbindtoport']; + else + $global_listen .= ":80"; + } else { + $global_listen = "{$config['system']['hostname']}.{$config['system']['domain']}"; + if($config['installedpackages']['apachemodsecuritysettings']['config'][0]['globalbindtoport']) + $global_listen .= ":" . $config['installedpackages']['apachemodsecuritysettings']['config'][0]['globalbindtoport']; + else + $global_listen .= ":80"; + } } else { - $global_listen = "{$config['system']['hostname']}.{$config['system']['domain']}"; - if($config['installedpackages']['apachemodsecuritysettings']['config'][0]['globalbindtoport']) - $global_listen .= ":" . $config['installedpackages']['apachemodsecuritysettings']['config'][0]['globalbindtoport']; - else - $global_listen .= ":80"; + log_error("Could not start mod_security + mod_proxy on port {$global_listen}. Process is already bound to this port."); } // Setup mem_cache -- cgit v1.2.3 From 79eaddb089e8e8a2644f0e2886b63207ead06019 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 6 Mar 2010 20:22:20 -0500 Subject: Catch up to 2010 --- config/apache_mod_security/apache_mod_security.inc | 2 +- config/apache_mod_security/apache_mod_security.xml | 2 +- config/apache_mod_security/apache_mod_security_settings.xml | 2 +- config/apache_mod_security/apache_mod_security_view_logs.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'config') diff --git a/config/apache_mod_security/apache_mod_security.inc b/config/apache_mod_security/apache_mod_security.inc index 593e04b2..0338a0c6 100644 --- a/config/apache_mod_security/apache_mod_security.inc +++ b/config/apache_mod_security/apache_mod_security.inc @@ -509,7 +509,6 @@ LoadModule auth_digest_module libexec/apache22/mod_auth_digest.so LoadModule file_cache_module libexec/apache22/mod_file_cache.so LoadModule cache_module libexec/apache22/mod_cache.so LoadModule disk_cache_module libexec/apache22/mod_disk_cache.so -{$mod_mem_cache} LoadModule dumpio_module libexec/apache22/mod_dumpio.so LoadModule include_module libexec/apache22/mod_include.so LoadModule filter_module libexec/apache22/mod_filter.so @@ -548,6 +547,7 @@ LoadModule speling_module libexec/apache22/mod_speling.so LoadModule userdir_module libexec/apache22/mod_userdir.so LoadModule alias_module libexec/apache22/mod_alias.so LoadModule rewrite_module libexec/apache22/mod_rewrite.so +{$mod_mem_cache} diff --git a/config/apache_mod_security/apache_mod_security.xml b/config/apache_mod_security/apache_mod_security.xml index 22ecb549..ef56609b 100644 --- a/config/apache_mod_security/apache_mod_security.xml +++ b/config/apache_mod_security/apache_mod_security.xml @@ -9,7 +9,7 @@ /* apache_mod_security.xml part of apache_mod_security package (http://www.pfSense.com) - Copyright (C)2009 Scott Ullrich + Copyright (C)2009, 2010 Scott Ullrich All rights reserved. */ /* ========================================================================== */ diff --git a/config/apache_mod_security/apache_mod_security_settings.xml b/config/apache_mod_security/apache_mod_security_settings.xml index 31c777ce..e313f3c8 100644 --- a/config/apache_mod_security/apache_mod_security_settings.xml +++ b/config/apache_mod_security/apache_mod_security_settings.xml @@ -9,7 +9,7 @@ /* apache_mod_security_settings.xml part of apache_mod_security package (http://www.pfSense.com) - Copyright (C) 2008 Scott Ullrich + Copyright (C) 2008, 2009, 2010 Scott Ullrich All rights reserved. */ /* ========================================================================== */ diff --git a/config/apache_mod_security/apache_mod_security_view_logs.php b/config/apache_mod_security/apache_mod_security_view_logs.php index 1bba2c06..6ef2499a 100644 --- a/config/apache_mod_security/apache_mod_security_view_logs.php +++ b/config/apache_mod_security/apache_mod_security_view_logs.php @@ -3,7 +3,7 @@ /* apache_mod_security_view_logs.php.php part of pfSense (http://www.pfsense.com/) - Copyright (C) 2009 Scott Ullrich + Copyright (C) 2009, 2010 Scott Ullrich All rights reserved. Redistribution and use in source and binary forms, with or without -- cgit v1.2.3 From c93a0494ff6b13857b64e25714e7adc54152f931 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 6 Mar 2010 20:33:11 -0500 Subject: No need to generate apache rules multiple times --- config/apache_mod_security/apache_mod_security.inc | 1 - 1 file changed, 1 deletion(-) (limited to 'config') diff --git a/config/apache_mod_security/apache_mod_security.inc b/config/apache_mod_security/apache_mod_security.inc index 0338a0c6..71750be6 100644 --- a/config/apache_mod_security/apache_mod_security.inc +++ b/config/apache_mod_security/apache_mod_security.inc @@ -118,7 +118,6 @@ function apache_mod_security_resync() { exec("/usr/bin/fetch -q -o " . rules_directory . "/rootkits.conf http://www.pfsense.com/packages/config/apache_mod_security/rules/rootkits.conf"); if(!file_exists(rules_directory . "/useragents.conf")) exec("/usr/bin/fetch -q -o " . rules_directory . "/useragents.conf http://www.pfsense.com/packages/config/apache_mod_security/rules/useragents.conf"); - generate_apache_configuration(); apache_mod_security_checkconfig(); apache_mod_security_restart(); } -- cgit v1.2.3 From bd1d7867ed9b432d0a914fdf702ff3631daeafb1 Mon Sep 17 00:00:00 2001 From: robiscool Date: Sat, 6 Mar 2010 17:55:34 -0800 Subject: snort-dev, more GUI fixes for all browsers --- config/snort-dev/snort_blocked.php | 1 - 1 file changed, 1 deletion(-) (limited to 'config') diff --git a/config/snort-dev/snort_blocked.php b/config/snort-dev/snort_blocked.php index 62323757..6f3b9521 100644 --- a/config/snort-dev/snort_blocked.php +++ b/config/snort-dev/snort_blocked.php @@ -432,7 +432,6 @@ if ($blocked_ips_array[0] == '')
-
-- cgit v1.2.3 From 9bc689a67d5d0e02777a850d9829a40e44de0b5b Mon Sep 17 00:00:00 2001 From: robiscool Date: Sat, 6 Mar 2010 20:31:50 -0800 Subject: snort-dev, IE checkbox GUI fix --- config/snort-dev/snort_interfaces.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'config') diff --git a/config/snort-dev/snort_interfaces.php b/config/snort-dev/snort_interfaces.php index e74568a4..04627064 100644 --- a/config/snort-dev/snort_interfaces.php +++ b/config/snort-dev/snort_interfaces.php @@ -218,6 +218,12 @@ padding: 15px 10px 50% 50px; padding-top: 4px; padding-bottom: 4px; } +.listt4 { + +font-size: 11px; +padding-right :15px; +padding-left :15px; +} @@ -286,7 +292,7 @@ padding: 15px 10px 50% 50px; ?> -
"> Date: Sun, 7 Mar 2010 22:41:43 -0800 Subject: snort-dev, update binary files x86 MMX 3DNOW, update paths --- config/snort-dev/bin/7.2.x86/barnyard2 | Bin 0 -> 715041 bytes config/snort-dev/snort.xml | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 config/snort-dev/bin/7.2.x86/barnyard2 (limited to 'config') diff --git a/config/snort-dev/bin/7.2.x86/barnyard2 b/config/snort-dev/bin/7.2.x86/barnyard2 new file mode 100644 index 00000000..027dc43b Binary files /dev/null and b/config/snort-dev/bin/7.2.x86/barnyard2 differ diff --git a/config/snort-dev/snort.xml b/config/snort-dev/snort.xml index 6aa5c924..39adcf25 100644 --- a/config/snort-dev/snort.xml +++ b/config/snort-dev/snort.xml @@ -71,7 +71,7 @@ /usr/local/bin/ 077 - http://www.pfsense.com/packages/config/snort-dev/bin/barnyard2 + http://www.pfsense.com/packages/config/snort-dev/bin/7.2.x86/barnyard2 /usr/local/bin/ -- cgit v1.2.3 From 35c336d5136e95f2b04c82f2d32a8b96c651c210 Mon Sep 17 00:00:00 2001 From: robiscool Date: Tue, 9 Mar 2010 01:46:57 -0800 Subject: snort-dev, remove MMX 3DNOW builds and replace with clean builds --- config/snort-dev/bin/7.2.x86/barnyard2 | Bin 715041 -> 715041 bytes 1 file changed, 0 insertions(+), 0 deletions(-) (limited to 'config') diff --git a/config/snort-dev/bin/7.2.x86/barnyard2 b/config/snort-dev/bin/7.2.x86/barnyard2 index 027dc43b..9266051c 100644 Binary files a/config/snort-dev/bin/7.2.x86/barnyard2 and b/config/snort-dev/bin/7.2.x86/barnyard2 differ -- cgit v1.2.3 From d50272580111f24edbdd2de69b9f095be406db55 Mon Sep 17 00:00:00 2001 From: robiscool Date: Tue, 9 Mar 2010 03:37:57 -0800 Subject: snort-dev, reove snort.org SO.RULES because of 2.8.5.3 segment fault core dump --- config/snort-dev/snort_check_for_rule_updates.php | 57 ++++++++-------- config/snort-dev/snort_download_rules.php | 81 ++++++++++++----------- 2 files changed, 70 insertions(+), 68 deletions(-) (limited to 'config') diff --git a/config/snort-dev/snort_check_for_rule_updates.php b/config/snort-dev/snort_check_for_rule_updates.php index 3edaae3e..e626d895 100644 --- a/config/snort-dev/snort_check_for_rule_updates.php +++ b/config/snort-dev/snort_check_for_rule_updates.php @@ -476,34 +476,35 @@ if ($premium_url_chk == on) { // } //} -/* Copy so_rules dir to snort lib dir */ -if ($snort_md5_check_ok != on) { -if (file_exists("{$snortdir}/so_rules/precompiled/FreeBSD-7.0/i386/2.8.4/")) { - echo "Copying so_rules...\n"; - echo "May take a while...\n"; - exec("`/bin/cp -f {$snortdir}/so_rules/precompiled/FreeBSD-7.0/i386/2.8.4/* /usr/local/lib/snort/dynamicrules/`"); - exec("/bin/cp {$snortdir}/so_rules/bad-traffic.rules {$snortdir}/rules/bad-traffic.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/chat.rules {$snortdir}/rules/chat.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/dos.rules {$snortdir}/rules/dos.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/exploit.rules {$snortdir}/rules/exploit.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/imap.rules {$snortdir}/rules/imap.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/misc.rules {$snortdir}/rules/misc.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/multimedia.rules {$snortdir}/rules/multimedia.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/netbios.rules {$snortdir}/rules/netbios.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/nntp.rules {$snortdir}/rules/nntp.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/p2p.rules {$snortdir}/rules/p2p.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/smtp.rules {$snortdir}/rules/smtp.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/sql.rules {$snortdir}/rules/sql.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/web-client.rules {$snortdir}/rules/web-client.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/web.misc.rules {$snortdir}/rules/web.misc.so.rules"); - exec("/bin/rm -r {$snortdir}/so_rules"); - echo "Done copying so_rules.\n"; -} else { - echo "Directory so_rules does not exist...\n"; - echo "Error copying so_rules...\n"; - exit(0); - } -} +/* Copy so_rules dir to snort lib dir */ +/* Disabled untill I figure out why there is a segment falut core dump on 2.8.5.3 */ +//if ($snort_md5_check_ok != on) { +//if (file_exists("{$snortdir}/so_rules/precompiled/FreeBSD-7.0/i386/2.8.4/")) { +// echo "Copying so_rules...\n"; +// echo "May take a while...\n"; +// exec("`/bin/cp -f {$snortdir}/so_rules/precompiled/FreeBSD-7.0/i386/2.8.4/* /usr/local/lib/snort/dynamicrules/`"); +// exec("/bin/cp {$snortdir}/so_rules/bad-traffic.rules {$snortdir}/rules/bad-traffic.so.rules"); +// exec("/bin/cp {$snortdir}/so_rules/chat.rules {$snortdir}/rules/chat.so.rules"); +// exec("/bin/cp {$snortdir}/so_rules/dos.rules {$snortdir}/rules/dos.so.rules"); +// exec("/bin/cp {$snortdir}/so_rules/exploit.rules {$snortdir}/rules/exploit.so.rules"); +// exec("/bin/cp {$snortdir}/so_rules/imap.rules {$snortdir}/rules/imap.so.rules"); +// exec("/bin/cp {$snortdir}/so_rules/misc.rules {$snortdir}/rules/misc.so.rules"); +// exec("/bin/cp {$snortdir}/so_rules/multimedia.rules {$snortdir}/rules/multimedia.so.rules"); +// exec("/bin/cp {$snortdir}/so_rules/netbios.rules {$snortdir}/rules/netbios.so.rules"); +// exec("/bin/cp {$snortdir}/so_rules/nntp.rules {$snortdir}/rules/nntp.so.rules"); +// exec("/bin/cp {$snortdir}/so_rules/p2p.rules {$snortdir}/rules/p2p.so.rules"); +// exec("/bin/cp {$snortdir}/so_rules/smtp.rules {$snortdir}/rules/smtp.so.rules"); +// exec("/bin/cp {$snortdir}/so_rules/sql.rules {$snortdir}/rules/sql.so.rules"); +// exec("/bin/cp {$snortdir}/so_rules/web-client.rules {$snortdir}/rules/web-client.so.rules"); +// exec("/bin/cp {$snortdir}/so_rules/web.misc.rules {$snortdir}/rules/web.misc.so.rules"); +// exec("/bin/rm -r {$snortdir}/so_rules"); +// echo "Done copying so_rules.\n"; +//} else { +// echo "Directory so_rules does not exist...\n"; +// echo "Error copying so_rules...\n"; +// exit(0); +// } +//} /* Copy configs to snort dir */ if ($snort_md5_check_ok != on) { diff --git a/config/snort-dev/snort_download_rules.php b/config/snort-dev/snort_download_rules.php index 136e756b..4eb947c9 100644 --- a/config/snort-dev/snort_download_rules.php +++ b/config/snort-dev/snort_download_rules.php @@ -743,46 +743,47 @@ if ($premium_url_chk == on) { } } -/* Copy so_rules dir to snort lib dir */ -if ($snortdownload != "off") -{ - if ($snort_md5_check_ok != on) { - if (file_exists("{$snortdir}/so_rules/precompiled/FreeBSD-7.0/i386/2.8.4/")) { - update_status(gettext("Copying so_rules...")); - update_output_window(gettext("May take a while...")); - exec("/bin/cp -f {$snortdir}/so_rules/precompiled/FreeBSD-7.0/i386/2.8.4/* /usr/local/lib/snort/dynamicrules/"); - exec("/bin/cp {$snortdir}/so_rules/bad-traffic.rules {$snortdir}/rules/snort_bad-traffic.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/chat.rules {$snortdir}/rules/snort_chat.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/dos.rules {$snortdir}/rules/snort_dos.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/exploit.rules {$snortdir}/rules/snort_exploit.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/imap.rules {$snortdir}/rules/snort_imap.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/misc.rules {$snortdir}/rules/snort_misc.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/multimedia.rules {$snortdir}/rules/snort_multimedia.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/netbios.rules {$snortdir}/rules/snort_netbios.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/nntp.rules {$snortdir}/rules/snort_nntp.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/p2p.rules {$snortdir}/rules/snort_p2p.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/smtp.rules {$snortdir}/rules/snort_smtp.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/sql.rules {$snortdir}/rules/snort_sql.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/web-client.rules {$snortdir}/rules/snort_web-client.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/web.misc.rules {$snortdir}/rules/snort_web.misc.so.rules"); - exec("/bin/rm -r {$snortdir}/so_rules"); - update_status(gettext("Done copying so_rules.")); - }else{ - update_status(gettext("Directory so_rules does not exist...")); - update_output_window(gettext("Error copying so_rules...")); - echo ' -'; - echo ""; - echo ""; - conf_mount_ro(); - exit(0); - } - } -} +/* Copy so_rules dir to snort lib dir */ +/* Disabed untill I find out why there is a segment failt coredump when using these rules on 2.8.5.3 */ +//if ($snortdownload != "off") +//{ +// if ($snort_md5_check_ok != on) { +// if (file_exists("{$snortdir}/so_rules/precompiled/FreeBSD-7.0/i386/2.8.4/")) { +// update_status(gettext("Copying so_rules...")); +// update_output_window(gettext("May take a while...")); +// exec("/bin/cp -f {$snortdir}/so_rules/precompiled/FreeBSD-7.0/i386/2.8.4/* /usr/local/lib/snort/dynamicrules/"); +// exec("/bin/cp {$snortdir}/so_rules/bad-traffic.rules {$snortdir}/rules/snort_bad-traffic.so.rules"); +// exec("/bin/cp {$snortdir}/so_rules/chat.rules {$snortdir}/rules/snort_chat.so.rules"); +// exec("/bin/cp {$snortdir}/so_rules/dos.rules {$snortdir}/rules/snort_dos.so.rules"); +// exec("/bin/cp {$snortdir}/so_rules/exploit.rules {$snortdir}/rules/snort_exploit.so.rules"); +// exec("/bin/cp {$snortdir}/so_rules/imap.rules {$snortdir}/rules/snort_imap.so.rules"); +// exec("/bin/cp {$snortdir}/so_rules/misc.rules {$snortdir}/rules/snort_misc.so.rules"); +// exec("/bin/cp {$snortdir}/so_rules/multimedia.rules {$snortdir}/rules/snort_multimedia.so.rules"); +// exec("/bin/cp {$snortdir}/so_rules/netbios.rules {$snortdir}/rules/snort_netbios.so.rules"); +// exec("/bin/cp {$snortdir}/so_rules/nntp.rules {$snortdir}/rules/snort_nntp.so.rules"); +// exec("/bin/cp {$snortdir}/so_rules/p2p.rules {$snortdir}/rules/snort_p2p.so.rules"); +// exec("/bin/cp {$snortdir}/so_rules/smtp.rules {$snortdir}/rules/snort_smtp.so.rules"); +// exec("/bin/cp {$snortdir}/so_rules/sql.rules {$snortdir}/rules/snort_sql.so.rules"); +// exec("/bin/cp {$snortdir}/so_rules/web-client.rules {$snortdir}/rules/snort_web-client.so.rules"); +// exec("/bin/cp {$snortdir}/so_rules/web.misc.rules {$snortdir}/rules/snort_web.misc.so.rules"); +// exec("/bin/rm -r {$snortdir}/so_rules"); +// update_status(gettext("Done copying so_rules.")); +// }else{ +// update_status(gettext("Directory so_rules does not exist...")); +// update_output_window(gettext("Error copying so_rules...")); +// echo ' +//'; +// echo ""; +// echo ""; +// conf_mount_ro(); +// exit(0); +// } +// } +//} /* Copy renamed snort.org rules to snort dir */ if ($snortdownload != "off") -- cgit v1.2.3 From 8bb64bd0f8975d18a49f8d3709b5318162c589f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ermal=20Lu=E7i?= Date: Tue, 9 Mar 2010 23:11:36 +0000 Subject: On 2.0 show the friendly interface name. --- config/openospfd/openospfd_interfaces.xml | 1 + 1 file changed, 1 insertion(+) (limited to 'config') diff --git a/config/openospfd/openospfd_interfaces.xml b/config/openospfd/openospfd_interfaces.xml index b0d9e8ea..e8b18fcf 100644 --- a/config/openospfd/openospfd_interfaces.xml +++ b/config/openospfd/openospfd_interfaces.xml @@ -35,6 +35,7 @@ Interface interface + interface Description -- cgit v1.2.3 From b4c5f8f850f925b6d1446da697c4f1b1d12b70a8 Mon Sep 17 00:00:00 2001 From: robiscool Date: Tue, 9 Mar 2010 16:21:39 -0800 Subject: snort-dev, fix snort binary, add block option that was removed by someone --- config/snort-dev/snort.inc | 2 +- config/snort-dev/snort_download_rules.php | 82 ++++++++++++++++--------------- 2 files changed, 43 insertions(+), 41 deletions(-) (limited to 'config') diff --git a/config/snort-dev/snort.inc b/config/snort-dev/snort.inc index 5c99f62a..0bc1223a 100644 --- a/config/snort-dev/snort.inc +++ b/config/snort-dev/snort.inc @@ -841,7 +841,7 @@ if ($snortunifiedlog_info_chk == on) /* define spoink (DISABLED)*/ $spoink_info_chk = $config['installedpackages']['snortglobal']['rule'][$id]['blockoffenders7']; -if (0 && $spoink_info_chk == on) +if ($spoink_info_chk == on) $spoink_type = "output alert_pf: /var/db/whitelist,snort2c"; /* define servers and ports snortdefservers */ diff --git a/config/snort-dev/snort_download_rules.php b/config/snort-dev/snort_download_rules.php index 4eb947c9..4086f2d3 100644 --- a/config/snort-dev/snort_download_rules.php +++ b/config/snort-dev/snort_download_rules.php @@ -669,7 +669,7 @@ if ($snortdownload != "off") exec("/bin/mkdir -p {$snortdir}/rules_bk/"); exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir}/rules_bk rules/"); exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} etc/" . - " so_rules/precompiled/FreeBSD-7.0/i386/2.8.4/" . + " so_rules/precompiled/FreeBSD-7.0/i386/2.8.5.1/" . " so_rules/bad-traffic.rules/" . " so_rules/chat.rules/" . " so_rules/dos.rules/" . @@ -745,45 +745,47 @@ if ($premium_url_chk == on) { /* Copy so_rules dir to snort lib dir */ /* Disabed untill I find out why there is a segment failt coredump when using these rules on 2.8.5.3 */ -//if ($snortdownload != "off") -//{ -// if ($snort_md5_check_ok != on) { -// if (file_exists("{$snortdir}/so_rules/precompiled/FreeBSD-7.0/i386/2.8.4/")) { -// update_status(gettext("Copying so_rules...")); -// update_output_window(gettext("May take a while...")); -// exec("/bin/cp -f {$snortdir}/so_rules/precompiled/FreeBSD-7.0/i386/2.8.4/* /usr/local/lib/snort/dynamicrules/"); -// exec("/bin/cp {$snortdir}/so_rules/bad-traffic.rules {$snortdir}/rules/snort_bad-traffic.so.rules"); -// exec("/bin/cp {$snortdir}/so_rules/chat.rules {$snortdir}/rules/snort_chat.so.rules"); -// exec("/bin/cp {$snortdir}/so_rules/dos.rules {$snortdir}/rules/snort_dos.so.rules"); -// exec("/bin/cp {$snortdir}/so_rules/exploit.rules {$snortdir}/rules/snort_exploit.so.rules"); -// exec("/bin/cp {$snortdir}/so_rules/imap.rules {$snortdir}/rules/snort_imap.so.rules"); -// exec("/bin/cp {$snortdir}/so_rules/misc.rules {$snortdir}/rules/snort_misc.so.rules"); -// exec("/bin/cp {$snortdir}/so_rules/multimedia.rules {$snortdir}/rules/snort_multimedia.so.rules"); -// exec("/bin/cp {$snortdir}/so_rules/netbios.rules {$snortdir}/rules/snort_netbios.so.rules"); -// exec("/bin/cp {$snortdir}/so_rules/nntp.rules {$snortdir}/rules/snort_nntp.so.rules"); -// exec("/bin/cp {$snortdir}/so_rules/p2p.rules {$snortdir}/rules/snort_p2p.so.rules"); -// exec("/bin/cp {$snortdir}/so_rules/smtp.rules {$snortdir}/rules/snort_smtp.so.rules"); -// exec("/bin/cp {$snortdir}/so_rules/sql.rules {$snortdir}/rules/snort_sql.so.rules"); -// exec("/bin/cp {$snortdir}/so_rules/web-client.rules {$snortdir}/rules/snort_web-client.so.rules"); -// exec("/bin/cp {$snortdir}/so_rules/web.misc.rules {$snortdir}/rules/snort_web.misc.so.rules"); -// exec("/bin/rm -r {$snortdir}/so_rules"); -// update_status(gettext("Done copying so_rules.")); -// }else{ -// update_status(gettext("Directory so_rules does not exist...")); -// update_output_window(gettext("Error copying so_rules...")); -// echo ' -//'; -// echo ""; -// echo ""; -// conf_mount_ro(); -// exit(0); -// } -// } -//} +if ($snortdownload != "off") +{ + if ($snort_md5_check_ok != on) { + if (file_exists("{$snortdir}/so_rules/precompiled/FreeBSD-7.0/i386/2.8.5.1")) { + update_status(gettext("Copying so_rules...")); + update_output_window(gettext("May take a while...")); + exec("/bin/cp -f {$snortdir}/so_rules/precompiled/FreeBSD-7.0/i386/2.8.5.1/* /usr/local/lib/snort/dynamicrules/"); + exec("/bin/cp {$snortdir}/so_rules/bad-traffic.rules {$snortdir}/rules/snort_bad-traffic.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/chat.rules {$snortdir}/rules/snort_chat.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/dos.rules {$snortdir}/rules/snort_dos.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/exploit.rules {$snortdir}/rules/snort_exploit.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/imap.rules {$snortdir}/rules/snort_imap.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/misc.rules {$snortdir}/rules/snort_misc.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/multimedia.rules {$snortdir}/rules/snort_multimedia.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/netbios.rules {$snortdir}/rules/snort_netbios.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/nntp.rules {$snortdir}/rules/snort_nntp.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/p2p.rules {$snortdir}/rules/snort_p2p.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/smtp.rules {$snortdir}/rules/snort_smtp.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/sql.rules {$snortdir}/rules/snort_sql.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/web-activex.rules {$snortdir}/rules/snort_web-activex.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/web-client.rules {$snortdir}/rules/snort_web-client.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/web-iis.rules {$snortdir}/rules/snort_web-iis.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/web.misc.rules {$snortdir}/rules/snort_web.misc.so.rules"); + exec("/bin/rm -r {$snortdir}/so_rules"); + update_status(gettext("Done copying so_rules.")); + }else{ + update_status(gettext("Directory so_rules does not exist...")); + update_output_window(gettext("Error copying so_rules...")); + echo ' +'; + echo ""; + echo ""; + conf_mount_ro(); + exit(0); + } + } +} /* Copy renamed snort.org rules to snort dir */ if ($snortdownload != "off") -- cgit v1.2.3 From 0fd687c306b6ced446df87b2bfdcdc480a5eea02 Mon Sep 17 00:00:00 2001 From: jim-p Date: Wed, 10 Mar 2010 17:37:57 -0500 Subject: Add a package which backports the IP Range in Network Aliases functionality from 2.0 to 1.2.3. --- config/iprangealiases/iprangealiases.inc | 18 +++ config/iprangealiases/iprangealiases.patch | 249 +++++++++++++++++++++++++++++ config/iprangealiases/iprangealiases.xml | 65 ++++++++ 3 files changed, 332 insertions(+) create mode 100644 config/iprangealiases/iprangealiases.inc create mode 100644 config/iprangealiases/iprangealiases.patch create mode 100644 config/iprangealiases/iprangealiases.xml (limited to 'config') diff --git a/config/iprangealiases/iprangealiases.inc b/config/iprangealiases/iprangealiases.inc new file mode 100644 index 00000000..036bc195 --- /dev/null +++ b/config/iprangealiases/iprangealiases.inc @@ -0,0 +1,18 @@ + \ No newline at end of file diff --git a/config/iprangealiases/iprangealiases.patch b/config/iprangealiases/iprangealiases.patch new file mode 100644 index 00000000..6e1cdabb --- /dev/null +++ b/config/iprangealiases/iprangealiases.patch @@ -0,0 +1,249 @@ +--- /etc/inc/util.inc.orig 2010-03-09 13:01:37.000000000 -0500 ++++ /etc/inc/util.inc 2010-03-09 13:01:40.000000000 -0500 +@@ -78,6 +78,127 @@ + return long2ip(gen_subnet_mask_long($bits)); + } + ++/* Convert IP address to unsigned long int. */ ++function ip2ulong($ip) { ++ return sprintf("%u", ip2long($ip)); ++} ++ ++/* Find out how many IPs are contained within a given IP range ++ * e.g. 192.168.0.0 to 192.168.0.255 returns 256 ++ */ ++function ip_range_size($startip, $endip) { ++ if (is_ipaddr($startip) && is_ipaddr($endip)) { ++ // Operate as unsigned long because otherwise it wouldn't work ++ // when crossing over from 127.255.255.255 / 128.0.0.0 barrier ++ return abs(ip2ulong($startip) - ip2ulong($endip)) + 1; ++ } ++ return -1; ++} ++ ++/* Find the smallest possible subnet mask which can contain a given number of IPs ++ * e.g. 512 IPs can fit in a /23, but 513 IPs need a /22 ++ */ ++function find_smallest_cidr($number) { ++ $smallest = 1; ++ for ($b=32; $b > 0; $b--) { ++ $smallest = ($number <= pow(2,$b)) ? $b : $smallest; ++ } ++ return (32-$smallest); ++} ++ ++/* Return the previous IP address before the given address */ ++function ip_before($ip) { ++ return long2ip(ip2long($ip)-1); ++} ++ ++/* Return the next IP address after the given address */ ++function ip_after($ip) { ++ return long2ip(ip2long($ip)+1); ++} ++ ++/* Return true if the first IP is 'before' the second */ ++function ip_less_than($ip1, $ip2) { ++ // Compare as unsigned long because otherwise it wouldn't work when ++ // crossing over from 127.255.255.255 / 128.0.0.0 barrier ++ return ip2ulong($ip1) < ip2ulong($ip2); ++} ++ ++/* Return true if the first IP is 'after' the second */ ++function ip_greater_than($ip1, $ip2) { ++ // Compare as unsigned long because otherwise it wouldn't work ++ // when crossing over from 127.255.255.255 / 128.0.0.0 barrier ++ return ip2ulong($ip1) > ip2ulong($ip2); ++} ++ ++/* Convert a range of IPs to an array of subnets which can contain the range. */ ++function ip_range_to_subnet_array($startip, $endip) { ++ if (!is_ipaddr($startip) || !is_ipaddr($endip)) { ++ return array(); ++ } ++ ++ // Container for subnets within this range. ++ $rangesubnets = array(); ++ ++ // Figure out what the smallest subnet is that holds the number of IPs in the given range. ++ $cidr = find_smallest_cidr(ip_range_size($startip, $endip)); ++ ++ // Loop here to reduce subnet size and retest as needed. We need to make sure ++ // that the target subnet is wholly contained between $startip and $endip. ++ for ($cidr; $cidr <= 32; $cidr++) { ++ // Find the network and broadcast addresses for the subnet being tested. ++ $targetsub_min = gen_subnet($startip, $cidr); ++ $targetsub_max = gen_subnet_max($startip, $cidr); ++ ++ // Check best case where the range is exactly one subnet. ++ if (($targetsub_min == $startip) && ($targetsub_max == $endip)) { ++ // Hooray, the range is exactly this subnet! ++ return array("{$startip}/{$cidr}"); ++ } ++ ++ // These remaining scenarios will find a subnet that uses the largest ++ // chunk possible of the range being tested, and leave the rest to be ++ // tested recursively after the loop. ++ ++ // Check if the subnet begins with $startip and ends before $endip ++ if (($targetsub_min == $startip) && ip_less_than($targetsub_max, $endip)) { ++ break; ++ } ++ ++ // Check if the subnet ends at $endip and starts after $startip ++ if (ip_greater_than($targetsub_min, $startip) && ($targetsub_max == $endip)) { ++ break; ++ } ++ ++ // Check if the subnet is between $startip and $endip ++ if (ip_greater_than($targetsub_min, $startip) && ip_less_than($targetsub_max, $endip)) { ++ break; ++ } ++ } ++ ++ // Some logic that will recursivly search from $startip to the first IP before the start of the subnet we just found. ++ // NOTE: This may never be hit, the way the above algo turned out, but is left for completeness. ++ if ($startip != $targetsub_min) { ++ $rangesubnets = array_merge($rangesubnets, ip_range_to_subnet_array($startip, ip_before($targetsub_min))); ++ } ++ ++ // Add in the subnet we found before, to preserve ordering ++ $rangesubnets[] = "{$targetsub_min}/{$cidr}"; ++ ++ // And some more logic that will search after the subnet we found to fill in to the end of the range. ++ if ($endip != $targetsub_max) { ++ $rangesubnets = array_merge($rangesubnets, ip_range_to_subnet_array(ip_after($targetsub_max), $endip)); ++ } ++ return $rangesubnets; ++} ++ ++function is_iprange($range) { ++ if (substr_count($range, '-') != 1) { ++ return false; ++ } ++ list($ip1, $ip2) = explode ('-', $range); ++ return (is_ipaddr($ip1) && is_ipaddr($ip2)); ++} ++ + function is_numericint($arg) { + return (preg_match("/[^0-9]/", $arg) ? false : true); + } +--- /usr/local/www/firewall_aliases_edit.php.orig 2010-03-09 13:08:12.000000000 -0500 ++++ /usr/local/www/firewall_aliases_edit.php 2010-03-10 15:49:57.000000000 -0500 +@@ -96,11 +96,6 @@ + $reqdfields = explode(" ", "name address"); + $reqdfieldsn = explode(",", "Name,Address"); + +- if ($_POST['type'] == "network") { +- $reqdfields[] = "address_subnet"; +- $reqdfieldsn[] = "Subnet bit count"; +- } +- + do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); + + if(strtolower($_POST['name']) == "lan") +@@ -122,10 +117,13 @@ + $input_errors[] = "A valid address must be specified."; + } + if ($_POST['type'] == "network") { +- if (!is_ipaddr($_POST['address'])) { ++ if (!is_numeric($_POST['address_subnet']) && !is_iprange($_POST['address'])) { ++ $input_errors[] = "Subnet bit count must be specified"; ++ } ++ if (!is_ipaddr($_POST['address']) && !is_iprange($_POST['address'])) { + $input_errors[] = "A valid address must be specified."; + } +- if (!is_numeric($_POST['address_subnet'])) { ++ if (!is_numeric($_POST['address_subnet']) && !is_iprange($_POST['address'])) { + $input_errors[] = "A valid subnet bit count must be specified."; + } + } +@@ -160,21 +158,28 @@ + + $alias = array(); + $alias['name'] = $_POST['name']; +- if ($_POST['type'] == "network") +- $alias['address'] = $_POST['address'] . "/" . $_POST['address_subnet']; + +- else ++ $count = 1; ++ if ($_POST['type'] == "network") { ++ if (is_iprange($_POST['address'])) { ++ list($startip, $endip) = explode('-', $_POST["address"]); ++ $rangesubnets = ip_range_to_subnet_array($startip, $endip); ++ $count = count($rangesubnets); ++ $alias['address'] .= implode($rangesubnets, ' '); ++ } else { ++ $alias['address'] = $_POST['address'] . "/" . $_POST['address_subnet']; ++ } ++ } else { + $alias['address'] = $_POST['address']; ++ } + + $address = $alias['address']; + $final_address_detail = mb_convert_encoding($_POST['detail'],"HTML-ENTITIES","auto"); +- if($final_address_detail <> "") { +- $final_address_details .= $final_address_detail; ++ if($final_address_detail <> "") { ++ $final_address_details .= str_repeat($final_address_detail . "||", $count); + } else { +- $final_address_details .= "Entry added" . " "; +- $final_address_details .= date('r'); +- } +- $final_address_details .= "||"; ++ $final_address_details .= str_repeat("Entry added " . date('r') . "||", $count); ++ } + $isfirst = 0; + + if($_POST['type'] == "url") { +@@ -234,28 +239,38 @@ + } else { + /* item is a normal alias type */ + for($x=0; $x<299; $x++) { ++ $count = 1; + $comd = "\$subnet = \$_POST['address" . $x . "'];"; + eval($comd); + $comd = "\$subnet_address = \$_POST['address_subnet" . $x . "'];"; + eval($comd); + if($subnet <> "") { +- $address .= " "; +- $address .= $subnet; +- if($subnet_address <> "") $address .= "/" . $subnet_address; ++ if ($_POST['type'] == "network" && is_iprange($subnet)) { ++ list($startip, $endip) = explode('-', $subnet); ++ $rangesubnets = ip_range_to_subnet_array($startip, $endip); ++ $count = count($rangesubnets); ++ if ($address <> "") { ++ $address .= " "; ++ } ++ $address .= implode($rangesubnets, ' '); ++ } else { ++ $address .= " " . $subnet; ++ if ($subnet_address <> "") { ++ $address .= "/" . $subnet_address; ++ } ++ } + + /* Compress in details to a single key, data separated by pipes. + Pulling details here lets us only pull in details for valid + address entries, saving us from having to track which ones to + process later. */ +- $comd = "\$final_address_detail = mb_convert_encoding(\$_POST['detail" . $x . "'],'HTML-ENTITIES','auto');"; +- eval($comd); +- if($final_address_detail <> "") { +- $final_address_details .= $final_address_detail; +- } else { +- $final_address_details .= "Entry added" . " "; +- $final_address_details .= date('r'); +- } +- $final_address_details .= "||"; ++ $comd = "\$final_address_detail = mb_convert_encoding(\$_POST['detail" . $x . "'],'HTML-ENTITIES','auto');"; ++ eval($comd); ++ if($final_address_detail <> "") { ++ $final_address_details .= str_repeat($final_address_detail . "||", $count); ++ } else { ++ $final_address_details .= str_repeat("Entry added " . date('r') . "||", $count); ++ } + } + } + } diff --git a/config/iprangealiases/iprangealiases.xml b/config/iprangealiases/iprangealiases.xml new file mode 100644 index 00000000..a015c2dd --- /dev/null +++ b/config/iprangealiases/iprangealiases.xml @@ -0,0 +1,65 @@ + + + + + + . + 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. + */ +/* ========================================================================== */ + ]]> + + Patch to add IP Range Support to Network Aliases + pfSense 1.2.3 + None + IP Range Aliases + 0.1 + IP Range Aliases + /usr/local/pkg/iprangealiases.inc + + /usr/local/pkg/ + 077 + http://www.pfsense.com/packages/config/iprangealiases/iprangealiases.inc + + + /usr/local/pkg/ + 077 + http://www.pfsense.com/packages/config/iprangealiases/iprangealiases.patch + + + iprangealiases_install(); + + -- cgit v1.2.3 From b3040f34c6e321184cfea719284f029f0d5cc550 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 6 Mar 2010 21:23:20 -0500 Subject: Revert bind changes for time being --- config/apache_mod_security/apache_mod_security.inc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'config') diff --git a/config/apache_mod_security/apache_mod_security.inc b/config/apache_mod_security/apache_mod_security.inc index 71750be6..4eb24c2c 100644 --- a/config/apache_mod_security/apache_mod_security.inc +++ b/config/apache_mod_security/apache_mod_security.inc @@ -162,7 +162,7 @@ function generate_apache_configuration() { } } } - if(!$already_binded) { +// if(!$already_binded) { if($config['installedpackages']['apachemodsecuritysettings']['config'][0]['globalbindtoipaddr']) { $global_listen = $config['installedpackages']['apachemodsecuritysettings']['config'][0]['globalbindtoipaddr']; if($config['installedpackages']['apachemodsecuritysettings']['config'][0]['globalbindtoport']) @@ -176,9 +176,9 @@ function generate_apache_configuration() { else $global_listen .= ":80"; } - } else { - log_error("Could not start mod_security + mod_proxy on port {$global_listen}. Process is already bound to this port."); - } +// } else { +// log_error("Could not start mod_security + mod_proxy on port {$global_listen}. Process is already bound to this port."); +// } // Setup mem_cache if(file_exists("/usr/local/libexec/apache22/mod_mem_cache.so")) { -- cgit v1.2.3 From 78c993c07eab5ec35cfcfe099aa43a86356a7e48 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Wed, 10 Mar 2010 18:31:26 -0500 Subject: Add conf_mount_rw() and conf_mount_ro() items for NanoBSD --- config/openvpn-client-export/openvpn-client-export.inc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'config') diff --git a/config/openvpn-client-export/openvpn-client-export.inc b/config/openvpn-client-export/openvpn-client-export.inc index f113fb06..aabb32eb 100755 --- a/config/openvpn-client-export/openvpn-client-export.inc +++ b/config/openvpn-client-export/openvpn-client-export.inc @@ -35,6 +35,7 @@ require_once("globals.inc"); require_once("openvpn.inc"); function openvpn_client_export_install() { + conf_mount_rw(); $tarpath = "/tmp/openvpn-client-export.tgz"; $phpfile = "vpn_openvpn_export.php"; $ovpndir = "/usr/local/share/openvpn"; @@ -45,15 +46,18 @@ function openvpn_client_export_install() { exec("/usr/bin/tar zxf {$tarpath} -C {$ovpndir}"); unlink($tarpath); + conf_mount_ro(); } function openvpn_client_export_deinstall() { + conf_mount_rw(); $phpfile = "vpn_openvpn_export.php"; $ovpndir = "/usr/local/share/openvpn"; $workdir = "{$ovpndir}/client-export"; unlink_if_exists("/usr/local/www/{$phpfile}"); exec("/bin/rm -r {$workdir}"); + conf_mount_ro(); } function openvpn_client_export_prefix($srvid) { -- cgit v1.2.3 From c9fcb262f2cd4a5a123fa33f3932d10f020f3735 Mon Sep 17 00:00:00 2001 From: jim-p Date: Wed, 10 Mar 2010 18:59:38 -0500 Subject: Add some text stating that ranges are available and how they are used. --- config/iprangealiases/iprangealiases.patch | 18 +++++++++++++++++- config/iprangealiases/iprangealiases.xml | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'config') diff --git a/config/iprangealiases/iprangealiases.patch b/config/iprangealiases/iprangealiases.patch index 6e1cdabb..5a80e111 100644 --- a/config/iprangealiases/iprangealiases.patch +++ b/config/iprangealiases/iprangealiases.patch @@ -129,7 +129,7 @@ return (preg_match("/[^0-9]/", $arg) ? false : true); } --- /usr/local/www/firewall_aliases_edit.php.orig 2010-03-09 13:08:12.000000000 -0500 -+++ /usr/local/www/firewall_aliases_edit.php 2010-03-10 15:49:57.000000000 -0500 ++++ /usr/local/www/firewall_aliases_edit.php 2010-03-10 18:54:36.000000000 -0500 @@ -96,11 +96,6 @@ $reqdfields = explode(" ", "name address"); $reqdfieldsn = explode(",", "Name,Address"); @@ -247,3 +247,19 @@ } } } +@@ -358,7 +373,7 @@ + $url_str = gettext("URL"); + $update_freq_str = gettext("Update Freq."); + +-$networks_help = gettext("Networks can be expressed like 10.0.0.0 format. Select the CIDR (network mask) that pertains to each entry."); ++$networks_help = gettext("Networks can be expressed like 10.0.0.0 format. Select the CIDR (network mask) that pertains to each entry. You may also enter an IP Range such as 192.168.1.1-192.168.1.254."); + $hosts_help = gettext("Enter as many hosts as you would like. Hosts should be expressed in their ip address format."); + $ports_help = gettext("Enter as many ports as you wish. Port ranges can be expressed by seperating with a colon."); + $url_help = gettext("Enter as many urls as you wish. Also set the time that you would like the url refreshed in days. After saving {$g['product_name']} will download the URL and import the items into the alias."); +@@ -595,4 +610,4 @@ + } + fclose($fd); + } +-?> +\ No newline at end of file ++?> diff --git a/config/iprangealiases/iprangealiases.xml b/config/iprangealiases/iprangealiases.xml index a015c2dd..0464ec6a 100644 --- a/config/iprangealiases/iprangealiases.xml +++ b/config/iprangealiases/iprangealiases.xml @@ -46,7 +46,7 @@ pfSense 1.2.3 None IP Range Aliases - 0.1 + 0.2 IP Range Aliases /usr/local/pkg/iprangealiases.inc -- cgit v1.2.3 From e1dbec3e87eeef66c616653f7226ab2276ff6c16 Mon Sep 17 00:00:00 2001 From: robiscool Date: Thu, 11 Mar 2010 02:00:07 -0800 Subject: snort-dev, more GUI fixes, update help and info page --- config/snort-dev/css/style2.css | 111 +++++++++++++++++ config/snort-dev/help_and_info.html | 178 +++++++++++++++++++++------ config/snort-dev/images/footer.jpg | Bin 0 -> 57412 bytes config/snort-dev/images/logo.jpg | Bin 0 -> 74307 bytes config/snort-dev/javascript/tabs.js | 123 ++++++++++++++++++ config/snort-dev/snort.inc | 4 + config/snort-dev/snort.xml | 2 +- config/snort-dev/snort_alerts.php | 6 +- config/snort-dev/snort_barnyard.php | 3 +- config/snort-dev/snort_blocked.php | 6 +- config/snort-dev/snort_define_servers.php | 3 +- config/snort-dev/snort_download_rules.php | 9 +- config/snort-dev/snort_help_info.php | 50 ++++++-- config/snort-dev/snort_interfaces.php | 12 +- config/snort-dev/snort_interfaces_edit.php | 4 +- config/snort-dev/snort_interfaces_global.php | 4 +- config/snort-dev/snort_preprocessors.php | 3 +- config/snort-dev/snort_rules.php | 9 +- config/snort-dev/snort_rulesets.php | 10 +- 19 files changed, 464 insertions(+), 73 deletions(-) create mode 100644 config/snort-dev/css/style2.css create mode 100644 config/snort-dev/images/footer.jpg create mode 100644 config/snort-dev/images/logo.jpg create mode 100644 config/snort-dev/javascript/tabs.js (limited to 'config') diff --git a/config/snort-dev/css/style2.css b/config/snort-dev/css/style2.css new file mode 100644 index 00000000..cd253de1 --- /dev/null +++ b/config/snort-dev/css/style2.css @@ -0,0 +1,111 @@ +/* ----------------------------------- +general +----------------------------------- */ + +body +{ + margin: 0px; + padding: 0px; + font: 100%/1.4 helvetica, arial, sans-serif; + color: #444; + background: #fff; +} + +h1, h2, h3, h4, h5, h6 +{ + margin: 0 0 1em; + line-height: 1.1; +} + +h2, h3 { color: #003d5d; } +h2 { font-size: 218.75%; } + + +p +{ +margin-top: 35pt; +margin-right: 0pt; +margin-bottom: -25px; +margin-left: 0pt; +text-indent: 25px; +} + +img { border: none; } +a:link { color: #035389; } +a:visited { color: #09619C; } + +/* ----------------------------------- +Play Hide the tab +----------------------------------- */ + +div.items p:not(:target) {display: none} +div.items p:target {display: block} + + +/* ----------------------------------- +layout +----------------------------------- */ + +#container +{ + margin: 0 0px; + background: #fff; +} + +#header +{ + background: #fff; +} + +#header h1 { margin: 0; } + +#navigation +{ + float: left; + width: 100%; + background: #333; +} + +#navigation ul +{ + margin: 0; + padding: 0; +} + +#navigation ul li +{ + list-style-type: none; + display: inline; +} + +#navigation li a +{ + display: block; + float: left; + padding: 5px 10px; + color: #fff; + text-decoration: none; + border-right: 1px solid #fff; +} + +#navigation li a:hover +{ + background-color: #3366cc; + background-image: none; + background-repeat: repeat; + background-attachment: scroll; + background-position: 0% 0%; +} + +#content +{ + clear: left; + padding: 20px; +} + +#content h2 +{ + color: #000; + font-size: 160%; + margin: 0 0 .5em; +} \ No newline at end of file diff --git a/config/snort-dev/help_and_info.html b/config/snort-dev/help_and_info.html index d3875940..1f790257 100644 --- a/config/snort-dev/help_and_info.html +++ b/config/snort-dev/help_and_info.html @@ -4,47 +4,86 @@ Help & Info - + + - -

 About

- Pfsense Snort Package adds network protection from both internal and external threats
- without the expense of proprietary software. The Snort Package includes alert monitoring,
- blocked hosts monitoring, whitelists, rule editing/selecting, and auto rule downloads from multiple sources.

- - * Why should I care about my Network Security
- -
 Corporate network attacks have a 50% success rate. 
-
 More than 25% of Home PC's are infected with some spyware.

- - Snort 2.8.4.1_5 pkg v. 1.8 alpha was code by:

-Roberto Zelaya (robiscool)

- Special thanks to:

-Scott Ullrich (sullrich) for providing the basic snort code. -
- -

 Help

- * Where to ask your questions for the Snort Package

-
 Pfsense forums 
-
 Mailing Lists 
-
 Pfsense Snort FAQ 
- -

 Credits

- - -Pfsense Team for the Core GUI and networking.
-
- -pfSense is brought to you by a dedicated group of developers who are security and network professionals by trade. The following people are active developers of the pfSense project. Username is listed in parenthesis (generally also the person's forum username, IRC nickname, etc.).

- -Founders
+ + + + +
+ + +
+
+

+ Snort Package is a GUI based front-end for Sourcefire's Snort ® IDS/IPS software. The Snort Package goal is to be + the best open-source GUI to manage multiple snort sensors and multiple rule snapshots. The project other goal is to be a highly competitive GUI for + network monitoring for both private and enterprise use. Lastly, this project software development should bring programmers and users together to create + software. +

+

+ What is Snort ? Used by fortune 500 companies and goverments Snort is the most widely deployed IDS/IPS technology worldwide. It features rules based logging and + can perform content searching/matching in addition to being used to detect a variety of other attacks and probes, such as buffer overflows, stealth port + scans, CGI attacks, SMB probes, and much more. +

+

+ Requirements :
+ Minimum requirement 256 mb ram, 500 MHz CPU.
+ Recommended 500 mb ram, 1 Ghz CPU.
+ The more rules you run the more memory you need.
+ The more interfaces you select the more memory you need.

+ Development is done on a Alix 2D3 system (500 MHz AMD Geode LX800 CPU 256MB DDR DRAM). +

+
+
+

+About Me

+Coming soon............ + +

+
+
+

+Services

+Coming soon............ +

+
+
+

+Change Log

+Coming soon............ +

+
+
+

+PfSense is brought to you by a dedicated group of developers who are security and network professionals by trade. The following people are active developers of the pfSense project. +Username is listed in parenthesis (generally also the person's forum username, IRC nickname, etc.).

+ +Main Snort-dev Package Developer
+Robert Zelaya

+ +Founders
In alphabetical order

Chris Buechler (cmb)
Scott Ullrich (sullrich)

-Active Developers
+Active Developers
Listed in order of seniority along with date of first contribution.

Bill Marquette (billm) - February 2005
@@ -60,7 +99,7 @@ Jim Pingle (jim-p) - February 2009
Rob Zelaya (robiscool) - March 2009
Renato Botelho (rbgarga) - May 2009

-FreeBSD Developer Assistance
+FreeBSD Developer Assistance
We would like to thank the following FreeBSD developers for their assistance.

Max Laier (mlaier)
@@ -70,7 +109,7 @@ Bjoern A. Zeeb (bz)

among many others who help us directly, and everyone who contributes to FreeBSD.

-Inactive Developers
+Inactive Developers
The following individuals are no longer active contributors, having moved on because of other commitments, or employers forbidding contributions. We thank them for their past contributions.

Daniel Berlin (dberlin)
@@ -80,10 +119,71 @@ Scott Kamp (dingo)
Bachman Kharazmi (bkw)
Fernando Tarlá Cardoso Lemos (fernando)
Kyle Mott (kyle)
-Colin Smith (colin)
+Colin Smith (colin)
+

+
+
+

+Heros

+Coming soon............ +

+
+
+

+=========================
+ +Q: Do you have a quick install tutorial and tabs explanation.
+ +A: Yes.
+ + http://doc.pfsense.org/index.php/Setup_Snort_Package
+ +=========================
+ +Q: What interfaces can snort listen on ?
+ +A: Right now all WAN interfaces and LAN interfaces. But if you select a LAN interface you may need to adjust the snort rules to use the LAN interface.
+ +==========================
+ +Q: What logs does the snort package keep. ?
+ +A: Most of the snort logs are keept in the /var/log/snort.
+ Snorts syslogs' are saved to the /var/log/snort/snort_sys_0ng0.
+ +==========================
+ +Q: What is the best Performance setting ? or Snort is using 90% cpu and all my memory.
+ +A: Depends how much memory you have and how many rules you want to run.; lowmem for systems with less than 256 mb memory, ac-bnfa for systems
+ with over 256 mb of memory. The other options are; ac high memory, best performance, ac-std moderate memory, high performance,acs small
+ memory, moderate performance,ac-banded small memory,moderate performance,ac-sparsebands small memory, high performance.
+ + Short version: For most people ac-bnfa is the best setting.
+ +=========================
+ +Q: What is the Oinkmaster code ? How do I get the code ?
+ +A: The Oinkmaster code is your personal password in order to download snort rules.
+ You get a Oinkmaster code when you register with snort.org. It is free to register.
+ Goto https://www.snort.org/signup to get your personal code.
+ +=========================
+ +Q: What is the Snort.org subscriber option? How do I become a Snort.org subscriber?
-

 Thank Yous

+A: Snort.org subscribers get the the latest rule updates 30 days faster than registered users.
+ Goto http://www.snort.org/vrt/buy-a-subscription/. + It is highly suggested that you get a paid subscription so that you can always have the latest rules.
+ +=========================
+Q: When did you start working on the snort package.
+A: I started working on the snort package in May 2009.
+

+
+
- + \ No newline at end of file diff --git a/config/snort-dev/images/footer.jpg b/config/snort-dev/images/footer.jpg new file mode 100644 index 00000000..0cf9675a Binary files /dev/null and b/config/snort-dev/images/footer.jpg differ diff --git a/config/snort-dev/images/logo.jpg b/config/snort-dev/images/logo.jpg new file mode 100644 index 00000000..75abf478 Binary files /dev/null and b/config/snort-dev/images/logo.jpg differ diff --git a/config/snort-dev/javascript/tabs.js b/config/snort-dev/javascript/tabs.js new file mode 100644 index 00000000..c042d74d --- /dev/null +++ b/config/snort-dev/javascript/tabs.js @@ -0,0 +1,123 @@ +// CSS helper functions +CSS = { + // Adds a class to an element. + AddClass: function (e, c) { + if (!e.className.match(new RegExp("\\b" + c + "\\b", "i"))) + e.className += (e.className ? " " : "") + c; + }, + + // Removes a class from an element. + RemoveClass: function (e, c) { + e.className = e.className.replace(new RegExp(" \\b" + c + "\\b|\\b" + c + "\\b ?", "gi"), ""); + } +}; + +// Functions for handling tabs. +Tabs = { + // Changes to the tab with the specified ID. + GoTo: function (contentId, skipReplace) { + // This variable will be true if a tab for the specified + // content ID was found. + var foundTab = false; + + // Get the TOC element. + var toc = document.getElementById("toc"); + if (toc) { + var lis = toc.getElementsByTagName("li"); + for (var j = 0; j < lis.length; j++) { + var li = lis[j]; + + // Give the current tab link the class "current" and + // remove the class from any other TOC links. + var anchors = li.getElementsByTagName("a"); + for (var k = 0; k < anchors.length; k++) { + if (anchors[k].hash == "#" + contentId) { + CSS.AddClass(li, "current"); + foundTab = true; + break; + } else { + CSS.RemoveClass(li, "current"); + } + } + } + } + + // Show the content with the specified ID. + var divsToHide = []; + var divs = document.getElementsByTagName("div"); + for (var i = 0; i < divs.length; i++) { + var div = divs[i]; + + if (div.className.match(/\bcontent\b/i)) { + if (div.id == "_" + contentId) + div.style.display = "block"; + else + divsToHide.push(div); + } + } + + // Hide the other content boxes. + for (var i = 0; i < divsToHide.length; i++) + divsToHide[i].style.display = "none"; + + // Change the address bar. + if (!skipReplace) window.location.replace("#" + contentId); + }, + + OnClickHandler: function (e) { + // Stop the event (to stop it from scrolling or + // making an entry in the history). + if (!e) e = window.event; + if (e.preventDefault) e.preventDefault(); else e.returnValue = false; + + // Get the name of the anchor of the link that was clicked. + Tabs.GoTo(this.hash.substring(1)); + }, + + Init: function () { + if (!document.getElementsByTagName) return; + + // Attach an onclick event to all the anchor links on the page. + var anchors = document.getElementsByTagName("a"); + for (var i = 0; i < anchors.length; i++) { + var a = anchors[i]; + if (a.hash) a.onclick = Tabs.OnClickHandler; + } + + var contentId; + if (window.location.hash) contentId = window.location.hash.substring(1); + + var divs = document.getElementsByTagName("div"); + for (var i = 0; i < divs.length; i++) { + var div = divs[i]; + + if (div.className.match(/\bcontent\b/i)) { + if (!contentId) contentId = div.id; + div.id = "_" + div.id; + } + } + + if (contentId) Tabs.GoTo(contentId, true); + } +}; + +// Hook up the OnLoad event to the tab initialization function. +window.onload = Tabs.Init; + +// Hide the content while waiting for the onload event to trigger. +var contentId = window.location.hash || "#Introduction"; + +if (document.createStyleSheet) { + var style = document.createStyleSheet(); + style.addRule("div.content", "display: none;"); + style.addRule("div" + contentId, "display: block;"); +} else { + var head = document.getElementsByTagName("head")[0]; + if (head) { + var style = document.createElement("style"); + style.setAttribute("type", "text/css"); + style.appendChild(document.createTextNode("div.content { display: none; }")); + style.appendChild(document.createTextNode("div" + contentId + " { display: block; }")); + head.appendChild(style); + } +} \ No newline at end of file diff --git a/config/snort-dev/snort.inc b/config/snort-dev/snort.inc index 0bc1223a..4294966f 100644 --- a/config/snort-dev/snort.inc +++ b/config/snort-dev/snort.inc @@ -155,6 +155,7 @@ function snort_postinstall() chdir ("/usr/local/www/snort/css/"); exec('/usr/bin/fetch http://www.pfsense.com/packages/config/snort-dev/css/style.css'); + exec('/usr/bin/fetch http://www.pfsense.com/packages/config/snort-dev/css/style2.css'); chdir ("/usr/local/www/snort/images/"); exec('/usr/bin/fetch http://www.pfsense.com/packages/config/snort-dev/images/alert.jpg'); exec('/usr/bin/fetch http://www.pfsense.com/packages/config/snort-dev/images/down.gif'); @@ -164,11 +165,14 @@ function snort_postinstall() exec('/usr/bin/fetch http://www.pfsense.com/packages/config/snort-dev/images/icon-table-sort-desc.png'); exec('/usr/bin/fetch http://www.pfsense.com/packages/config/snort-dev/images/up.gif'); exec('/usr/bin/fetch http://www.pfsense.com/packages/config/snort-dev/images/up2.gif'); + exec('/usr/bin/fetch http://www.pfsense.com/packages/config/snort-dev/images/logo.jpg'); + exec('/usr/bin/fetch http://www.pfsense.com/packages/config/snort-dev/images/footer.jpg'); chdir ("/usr/local/www/snort/javascript/"); exec('/usr/bin/fetch http://www.pfsense.com/packages/config/snort-dev/javascript/jquery.blockUI.js'); exec('/usr/bin/fetch http://www.pfsense.com/packages/config/snort-dev/javascript/jquery-1.3.2.js'); exec('/usr/bin/fetch http://www.pfsense.com/packages/config/snort-dev/javascript/mootools.js'); exec('/usr/bin/fetch http://www.pfsense.com/packages/config/snort-dev/javascript/sortableTable.js'); + exec('/usr/bin/fetch http://www.pfsense.com/packages/config/snort-dev/javascript/tabs.js'); /* back to default */ chdir ("/root/"); diff --git a/config/snort-dev/snort.xml b/config/snort-dev/snort.xml index 39adcf25..6ab6ee7a 100644 --- a/config/snort-dev/snort.xml +++ b/config/snort-dev/snort.xml @@ -46,7 +46,7 @@ Describe your package requirements here Currently there are no FAQ items provided. Snort - 2.8.5.2 + 2.8.5.3 Services: Snort 2.8.5.2 pkg v. 1.9 /usr/local/pkg/snort/snort.inc diff --git a/config/snort-dev/snort_alerts.php b/config/snort-dev/snort_alerts.php index 4194f769..453fc765 100644 --- a/config/snort-dev/snort_alerts.php +++ b/config/snort-dev/snort_alerts.php @@ -36,6 +36,7 @@ require("globals.inc"); require("guiconfig.inc"); +require("/usr/local/pkg/snort/snort.inc"); $snortalertlogt = $config['installedpackages']['snortglobal']['snortalertlogtype']; $snort_logfile = '/var/log/snort/alert'; @@ -312,6 +313,10 @@ include("head.inc"); include("fbegin.inc"); +echo "

"; +if($pfsense_stable == 'yes'){echo $pgtitle;} +echo "

\n"; + /* refresh every 60 secs */ if ($pconfig['arefresh'] == 'on' || $pconfig['arefresh'] == '') { @@ -333,7 +338,6 @@ if ($pconfig['arefresh'] == 'on' || $pconfig['arefresh'] == '') ?>
diff --git a/config/snort-dev/snort_barnyard.php b/config/snort-dev/snort_barnyard.php index 0e0bbf33..10afa183 100644 --- a/config/snort-dev/snort_barnyard.php +++ b/config/snort-dev/snort_barnyard.php @@ -39,6 +39,7 @@ Important add error checking */ require("guiconfig.inc"); +require("/usr/local/pkg/snort/snort.inc"); if (!is_array($config['installedpackages']['snortglobal']['rule'])) { $config['installedpackages']['snortglobal']['rule'] = array(); @@ -229,6 +230,7 @@ include("head.inc"); +

+ @@ -60,12 +84,24 @@ include('head.inc'); ?> - -
- -
+
+ +
+
+
+ Apps + Snort® is a registered trademark of Sourcefire, Inc., Barnyard2® is a registered trademark of securixlive.com., Orion® copyright Robert Zelaya., + Emergingthreats is a registered trademark of emergingthreats.net., Mysql® is a registered trademark of Mysql.com. +
+ + diff --git a/config/snort-dev/snort_interfaces.php b/config/snort-dev/snort_interfaces.php index 04627064..e5b42e4d 100644 --- a/config/snort-dev/snort_interfaces.php +++ b/config/snort-dev/snort_interfaces.php @@ -31,7 +31,7 @@ require("guiconfig.inc"); require("/usr/local/pkg/snort/snort_gui.inc"); -include_once("/usr/local/pkg/snort/snort.inc"); +require("/usr/local/pkg/snort/snort.inc"); $id = $_GET['id']; if (isset($_POST['id'])) @@ -178,12 +178,13 @@ if ($_GET['act'] == "toggle" && $_GET['id'] != "") header("Location: snort_interfaces.php"); } -$pgtitle = "Services: Snort 2.8.5.2 pkg v. 1.9"; +$pgtitle = "Services: Snort 2.8.5.3 pkg v. 1.10 Alpha"; include("head.inc"); ?> +

@@ -252,7 +247,6 @@ padding-left :15px; display_top_tabs($tab_array); ?>
diff --git a/config/snort-dev/snort_interfaces_edit.php b/config/snort-dev/snort_interfaces_edit.php index 1a02715c..9d2301f0 100644 --- a/config/snort-dev/snort_interfaces_edit.php +++ b/config/snort-dev/snort_interfaces_edit.php @@ -300,7 +300,7 @@ if ($_POST["Submit"]) { } $ifname = strtoupper($pconfig['interface']); -$pgtitle = "Snort: Interface: {$ifname} Settings Edit"; +$pgtitle = "Snort: Interface: $id$if_real Settings Edit"; include("head.inc"); ?> @@ -308,6 +308,7 @@ include("head.inc"); +

- -
- - -
-
-

- Snort Package is a GUI based front-end for Sourcefire's Snort ® IDS/IPS software. The Snort Package goal is to be - the best open-source GUI to manage multiple snort sensors and multiple rule snapshots. The project other goal is to be a highly competitive GUI for - network monitoring for both private and enterprise use. Lastly, this project software development should bring programmers and users together to create - software. -

-

- What is Snort ? Used by fortune 500 companies and goverments Snort is the most widely deployed IDS/IPS technology worldwide. It features rules based logging and - can perform content searching/matching in addition to being used to detect a variety of other attacks and probes, such as buffer overflows, stealth port - scans, CGI attacks, SMB probes, and much more. -

-

- Requirements :
- Minimum requirement 256 mb ram, 500 MHz CPU.
- Recommended 500 mb ram, 1 Ghz CPU.
- The more rules you run the more memory you need.
- The more interfaces you select the more memory you need.

- Development is done on a Alix 2D3 system (500 MHz AMD Geode LX800 CPU 256MB DDR DRAM). -

-
-
-

-About Me

-Coming soon............ - -

-
-
-

-Services

-Coming soon............ -

-
-
-

-Change Log

-Coming soon............ -

-
-
-

-PfSense is brought to you by a dedicated group of developers who are security and network professionals by trade. The following people are active developers of the pfSense project. -Username is listed in parenthesis (generally also the person's forum username, IRC nickname, etc.).

- -Main Snort-dev Package Developer
-Robert Zelaya

- -Founders
-In alphabetical order

- -Chris Buechler (cmb)
-Scott Ullrich (sullrich)

- -Active Developers
-Listed in order of seniority along with date of first contribution.

- -Bill Marquette (billm) - February 2005
-Holger Bauer (hoba) - May 2005
-Erik Kristensen (ekristen) - August 2005
-Seth Mos (smos) - November 2005
-Scott Dale (sdale) - December 2006
-Martin Fuchs (mfuchs) - June 2007
-Ermal Luçi (ermal) - January 2008
-Matthew Grooms (mgrooms) - July 2008
-Mark Crane (mcrane) - October 2008
-Jim Pingle (jim-p) - February 2009
-Rob Zelaya (robiscool) - March 2009
-Renato Botelho (rbgarga) - May 2009

- -FreeBSD Developer Assistance
-We would like to thank the following FreeBSD developers for their assistance.

- -Max Laier (mlaier)
-Christian S.J. Peron (csjp)
-Andrew Thompson (thompsa)
-Bjoern A. Zeeb (bz)

- -among many others who help us directly, and everyone who contributes to FreeBSD.

- -Inactive Developers
-The following individuals are no longer active contributors, having moved on because of other commitments, or employers forbidding contributions. We thank them for their past contributions.

- -Daniel Berlin (dberlin)
-Daniel Haischt (dsh)
-Espen Johansen (lsf)
-Scott Kamp (dingo)
-Bachman Kharazmi (bkw)
-Fernando Tarlá Cardoso Lemos (fernando)
-Kyle Mott (kyle)
-Colin Smith (colin)
-

-
-
-

-Heros

-Coming soon............ -

-
-
-

-=========================
- -Q: Do you have a quick install tutorial and tabs explanation.
- -A: Yes.
- - http://doc.pfsense.org/index.php/Setup_Snort_Package
- -=========================
- -Q: What interfaces can snort listen on ?
- -A: Right now all WAN interfaces and LAN interfaces. But if you select a LAN interface you may need to adjust the snort rules to use the LAN interface.
- -==========================
- -Q: What logs does the snort package keep. ?
- -A: Most of the snort logs are keept in the /var/log/snort.
- Snorts syslogs' are saved to the /var/log/snort/snort_sys_0ng0.
- -==========================
- -Q: What is the best Performance setting ? or Snort is using 90% cpu and all my memory.
- -A: Depends how much memory you have and how many rules you want to run.; lowmem for systems with less than 256 mb memory, ac-bnfa for systems
- with over 256 mb of memory. The other options are; ac high memory, best performance, ac-std moderate memory, high performance,acs small
- memory, moderate performance,ac-banded small memory,moderate performance,ac-sparsebands small memory, high performance.
- - Short version: For most people ac-bnfa is the best setting.
- -=========================
- -Q: What is the Oinkmaster code ? How do I get the code ?
- -A: The Oinkmaster code is your personal password in order to download snort rules.
- You get a Oinkmaster code when you register with snort.org. It is free to register.
- Goto https://www.snort.org/signup to get your personal code.
- -=========================
- -Q: What is the Snort.org subscriber option? How do I become a Snort.org subscriber?
- -A: Snort.org subscribers get the the latest rule updates 30 days faster than registered users.
- Goto http://www.snort.org/vrt/buy-a-subscription/. - It is highly suggested that you get a paid subscription so that you can always have the latest rules.
- -=========================
- -Q: When did you start working on the snort package.
- -A: I started working on the snort package in May 2009.
-

-
-
- - \ No newline at end of file diff --git a/config/snort-dev/help_and_info.php b/config/snort-dev/help_and_info.php new file mode 100644 index 00000000..ff31d6d0 --- /dev/null +++ b/config/snort-dev/help_and_info.php @@ -0,0 +1,196 @@ + + + + +Help & Info + + + + + + + + + +
+ + +
+
+

+ Snort Package is a GUI based front-end for Sourcefire\'s Snort ® IDS/IPS software. The Snort Package goal is to be + the best open-source GUI to manage multiple snort sensors and multiple rule snapshots. The project other goal is to be a highly competitive GUI for + network monitoring for both private and enterprise use. Lastly, this project software development should bring programmers and users together to create + software. +

+

+ What is Snort ? Used by fortune 500 companies and goverments Snort is the most widely deployed IDS/IPS technology worldwide. It features rules based logging and + can perform content searching/matching in addition to being used to detect a variety of other attacks and probes, such as buffer overflows, stealth port + scans, CGI attacks, SMB probes, and much more. +

+

+ Requirements :
+ Minimum requirement 256 mb ram, 500 MHz CPU.
+ Recommended 500 mb ram, 1 Ghz CPU.
+ The more rules you run the more memory you need.
+ The more interfaces you select the more memory you need.

+ Development is done on a Alix 2D3 system (500 MHz AMD Geode LX800 CPU 256MB DDR DRAM). +

+
+
+

+About Me

+Coming soon............ + +

+
+
+

+Services

+Coming soon............ +

+
+
+

+Change Log

+Coming soon............ +

+
+
+

+PfSense is brought to you by a dedicated group of developers who are security and network professionals by trade. The following people are active developers of the pfSense project. +Username is listed in parenthesis (generally also the person\'s forum username, IRC nickname, etc.).

+ +Main Snort-dev Package Developer
+Robert Zelaya

+ +Founders
+In alphabetical order

+ +Chris Buechler (cmb)
+Scott Ullrich (sullrich)

+ +Active Developers
+Listed in order of seniority along with date of first contribution.

+ +Bill Marquette (billm) - February 2005
+Holger Bauer (hoba) - May 2005
+Erik Kristensen (ekristen) - August 2005
+Seth Mos (smos) - November 2005
+Scott Dale (sdale) - December 2006
+Martin Fuchs (mfuchs) - June 2007
+Ermal Luçi (ermal) - January 2008
+Matthew Grooms (mgrooms) - July 2008
+Mark Crane (mcrane) - October 2008
+Jim Pingle (jim-p) - February 2009
+Rob Zelaya (robiscool) - March 2009
+Renato Botelho (rbgarga) - May 2009

+ +FreeBSD Developer Assistance
+We would like to thank the following FreeBSD developers for their assistance.

+ +Max Laier (mlaier)
+Christian S.J. Peron (csjp)
+Andrew Thompson (thompsa)
+Bjoern A. Zeeb (bz)

+ +among many others who help us directly, and everyone who contributes to FreeBSD.

+ +Inactive Developers
+The following individuals are no longer active contributors, having moved on because of other commitments, or employers forbidding contributions. We thank them for their past contributions.

+ +Daniel Berlin (dberlin)
+Daniel Haischt (dsh)
+Espen Johansen (lsf)
+Scott Kamp (dingo)
+Bachman Kharazmi (bkw)
+Fernando Tarlá Cardoso Lemos (fernando)
+Kyle Mott (kyle)
+Colin Smith (colin)
+

+
+
+

+Heros

+Coming soon............ +

+
+
+

+=========================
+ +Q: Do you have a quick install tutorial and tabs explanation.
+ +A: Yes.
+ + http://doc.pfsense.org/index.php/Setup_Snort_Package
+ +=========================
+ +Q: What interfaces can snort listen on ?
+ +A: Right now all WAN interfaces and LAN interfaces. But if you select a LAN interface you may need to adjust the snort rules to use the LAN interface.
+ +==========================
+ +Q: What logs does the snort package keep. ?
+ +A: Most of the snort logs are keept in the /var/log/snort.
+ Snorts syslogs\' are saved to the /var/log/snort/snort_sys_0ng0.
+ +==========================
+ +Q: What is the best Performance setting ? or Snort is using 90% cpu and all my memory.
+ +A: Depends how much memory you have and how many rules you want to run.; lowmem for systems with less than 256 mb memory, ac-bnfa for systems
+ with over 256 mb of memory. The other options are; ac high memory, best performance, ac-std moderate memory, high performance,acs small
+ memory, moderate performance,ac-banded small memory,moderate performance,ac-sparsebands small memory, high performance.
+ + Short version: For most people ac-bnfa is the best setting.
+ +=========================
+ +Q: What is the Oinkmaster code ? How do I get the code ?
+ +A: The Oinkmaster code is your personal password in order to download snort rules.
+ You get a Oinkmaster code when you register with snort.org. It is free to register.
+ Goto https://www.snort.org/signup to get your personal code.
+ +=========================
+ +Q: What is the Snort.org subscriber option? How do I become a Snort.org subscriber?
+ +A: Snort.org subscribers get the the latest rule updates 30 days faster than registered users.
+ Goto http://www.snort.org/vrt/buy-a-subscription/. + It is highly suggested that you get a paid subscription so that you can always have the latest rules.
+ +=========================
+ +Q: When did you start working on the snort package.
+ +A: I started working on the snort package in May 2009.
+

+
+
+ + +'; +?> \ No newline at end of file diff --git a/config/snort-dev/snort.xml b/config/snort-dev/snort.xml index 6ab6ee7a..6a46cf7e 100644 --- a/config/snort-dev/snort.xml +++ b/config/snort-dev/snort.xml @@ -141,7 +141,7 @@ /usr/local/www/snort/ 077 - http://www.pfsense.com/packages/config/snort-dev/help_and_info.html + http://www.pfsense.com/packages/config/snort-dev/help_and_info.php /usr/local/www/snort/ diff --git a/config/snort-dev/snort_help_info.php b/config/snort-dev/snort_help_info.php index ce3d1948..fb1395b8 100644 --- a/config/snort-dev/snort_help_info.php +++ b/config/snort-dev/snort_help_info.php @@ -86,7 +86,7 @@ iframe
- +
-- cgit v1.2.3 From 06d66037a1f68bee687bec1c7093c33d0a4cc2bd Mon Sep 17 00:00:00 2001 From: thompsa Date: Fri, 12 Mar 2010 14:43:39 +1300 Subject: Only run haproxy on the carp master by checking the status when a link event happens. --- config/haproxy-dev/haproxy.inc | 114 +++++++++++++++++++++++++++++++++- config/haproxy-dev/haproxy_global.php | 33 ++++++++++ 2 files changed, 145 insertions(+), 2 deletions(-) (limited to 'config') diff --git a/config/haproxy-dev/haproxy.inc b/config/haproxy-dev/haproxy.inc index 455638a1..26a58c28 100644 --- a/config/haproxy-dev/haproxy.inc +++ b/config/haproxy-dev/haproxy.inc @@ -62,6 +62,9 @@ function haproxy_custom_php_deinstall_command() { exec("rm /usr/local/sbin/haproxy"); exec("rm /usr/local/pkg/haproxy.inc"); exec("rm /usr/local/www/haproxy*"); + exec("rm /etc/devd/haproxy.conf"); + exec("/etc/rc.d/devd restart"); + haproxy_install_cron(false); } function haproxy_custom_php_install_command() { @@ -84,6 +87,8 @@ haproxy_enable=\${haproxy-"YES"} start_cmd="haproxy_start" stop_postcmd="haproxy_stop" +check_cmd="haproxy_check" +extra_commands="check" load_rc_config \$name @@ -101,6 +106,20 @@ haproxy_start () { ENDOFF } +haproxy_check () { + echo "Checking haproxy." + /usr/bin/env \ + PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \ + /usr/local/bin/php -q -d auto_prepend_file=config.inc < +ENDOFF +} + haproxy_stop () { echo "Stopping haproxy." killall haproxy @@ -115,11 +134,77 @@ EOD; fclose($fd); exec("chmod a+rx /usr/local/etc/rc.d/haproxy.sh"); + $devd = << 0) { + unset($config['cron']['item'][$x]); + parse_config(true); + write_config(); + } + configure_cron(); + } + break; + } +} + function haproxy_find_acl($name) { global $a_acltypes; @@ -248,6 +333,12 @@ function write_backend($fd, $name, $pool, $frontend) { } function haproxy_configure() { + // reload haproxy + haproxy_writeconf(); + return haproxy_check_run(1); +} + +function haproxy_writeconf() { global $config, $g; $a_global = &$config['installedpackages']['haproxy']; @@ -448,20 +539,39 @@ function haproxy_configure() { exec("fetch -q -o /usr/bin/limits http://files.pfsense.org/extras/{$freebsd_version}/limits"); exec("chmod a+rx /usr/bin/limits"); } +} + +function haproxy_check_run($reload) { + global $config, $g; + + $a_global = &$config['installedpackages']['haproxy']; exec("/usr/bin/limits -n 300014"); - // reload haproxy if(isset($a_global['enable'])) { - if(is_process_running('haproxy')) { + if (isset($a_global['carpdev'])) { + $status = get_carp_interface_status($a_global['carpdev']); + if ($status != "MASTER") { + exec("/bin/pkill -F /var/run/haproxy.pid haproxy"); + return (0); + } else if (is_process_running('haproxy') && $reload == 0) { + return (0); + } + /* fallthrough */ + } + if (is_process_running('haproxy')) { exec("/usr/local/sbin/haproxy -f /var/etc/haproxy.cfg -p /var/run/haproxy.pid -st `cat /var/run/haproxy.pid`"); } else { exec("/usr/local/sbin/haproxy -f /var/etc/haproxy.cfg -p /var/run/haproxy.pid -D"); } return (0); } else { + if ($reload && is_process_running('haproxy')) { + exec("/bin/pkill -F /var/run/haproxy.pid haproxy"); + } return (1); } + } function haproxy_do_xmlrpc_sync($sync_to_ip, $password) { diff --git a/config/haproxy-dev/haproxy_global.php b/config/haproxy-dev/haproxy_global.php index f7864a4d..7f4ce483 100755 --- a/config/haproxy-dev/haproxy_global.php +++ b/config/haproxy-dev/haproxy_global.php @@ -56,6 +56,9 @@ if ($_POST) { $reqdfieldsn = explode(",", "Maximum connections"); } + if ($_POST['carpdev'] == "disabled") + unset($_POST['carpdev']); + do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); if ($_POST['maxconn'] && (!is_numeric($_POST['maxconn']))) @@ -78,6 +81,7 @@ if ($_POST) { $config['installedpackages']['haproxy']['remotesyslog'] = $_POST['remotesyslog'] ? $_POST['remotesyslog'] : false; $config['installedpackages']['haproxy']['logfacility'] = $_POST['logfacility'] ? $_POST['logfacility'] : false; $config['installedpackages']['haproxy']['loglevel'] = $_POST['loglevel'] ? $_POST['loglevel'] : false; + $config['installedpackages']['haproxy']['carpdev'] = $_POST['carpdev'] ? $_POST['carpdev'] : false; $config['installedpackages']['haproxy']['syncpassword'] = $_POST['syncpassword'] ? $_POST['syncpassword'] : false; $config['installedpackages']['haproxy']['advanced'] = base64_encode($_POST['advanced']) ? $_POST['advanced'] : false; $config['installedpackages']['haproxy']['nbproc'] = $_POST['nbproc'] ? $_POST['nbproc'] : false; @@ -98,6 +102,7 @@ $pconfig['synchost3'] = $config['installedpackages']['haproxy']['synchost3']; $pconfig['remotesyslog'] = $config['installedpackages']['haproxy']['remotesyslog']; $pconfig['logfacility'] = $config['installedpackages']['haproxy']['logfacility']; $pconfig['loglevel'] = $config['installedpackages']['haproxy']['loglevel']; +$pconfig['carpdev'] = $config['installedpackages']['haproxy']['carpdev']; $pconfig['advanced'] = base64_decode($config['installedpackages']['haproxy']['advanced']); $pconfig['nbproc'] = $config['installedpackages']['haproxy']['nbproc']; @@ -270,6 +275,34 @@ function enable_change(enable_change) {
+ Carp monitor + + +
+ Monitor carp interface and only run haproxy on the firewall which is MASTER. +
  -- cgit v1.2.3 From 9cf42f047c49d03b518f17b0688ed9c46fd6ec63 Mon Sep 17 00:00:00 2001 From: thompsa Date: Fri, 12 Mar 2010 15:21:55 +1300 Subject: Remove /usr/local/etc/rc.d/haproxy.sh --- config/haproxy-dev/haproxy.inc | 1 + 1 file changed, 1 insertion(+) (limited to 'config') diff --git a/config/haproxy-dev/haproxy.inc b/config/haproxy-dev/haproxy.inc index 26a58c28..10d7c24b 100644 --- a/config/haproxy-dev/haproxy.inc +++ b/config/haproxy-dev/haproxy.inc @@ -62,6 +62,7 @@ function haproxy_custom_php_deinstall_command() { exec("rm /usr/local/sbin/haproxy"); exec("rm /usr/local/pkg/haproxy.inc"); exec("rm /usr/local/www/haproxy*"); + exec("rm /usr/local/etc/rc.d/haproxy.sh"); exec("rm /etc/devd/haproxy.conf"); exec("/etc/rc.d/devd restart"); haproxy_install_cron(false); -- cgit v1.2.3 From c68429d0148425c085cb16ab33bb6b054fa9a558 Mon Sep 17 00:00:00 2001 From: thompsa Date: Fri, 12 Mar 2010 15:50:23 +1300 Subject: Fix broken devd script and make local haproxy_is_running() function since is_process_running() is broken as we are called through the rc.d script by the same name. --- config/haproxy-dev/haproxy.inc | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'config') diff --git a/config/haproxy-dev/haproxy.inc b/config/haproxy-dev/haproxy.inc index 10d7c24b..dc9b8983 100644 --- a/config/haproxy-dev/haproxy.inc +++ b/config/haproxy-dev/haproxy.inc @@ -138,16 +138,17 @@ EOD; $devd = << Date: Fri, 12 Mar 2010 16:02:01 +1300 Subject: Dont restart haproxy unless we are doing carp checks or reloading. --- config/haproxy-dev/haproxy.inc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'config') diff --git a/config/haproxy-dev/haproxy.inc b/config/haproxy-dev/haproxy.inc index dc9b8983..61cc71e6 100644 --- a/config/haproxy-dev/haproxy.inc +++ b/config/haproxy-dev/haproxy.inc @@ -569,7 +569,9 @@ function haproxy_check_run($reload) { } log_error("Starting haproxy on CARP master."); /* fallthrough */ - } + } else if ($reload == 0)) + return (0); + if (haproxy_is_running()) { exec("/usr/local/sbin/haproxy -f /var/etc/haproxy.cfg -p /var/run/haproxy.pid -st `cat /var/run/haproxy.pid`"); } else { -- cgit v1.2.3 From dbe7a7f25fb3ca9880adf7e9df5c0e6a9d67dcb2 Mon Sep 17 00:00:00 2001 From: thompsa Date: Fri, 12 Mar 2010 16:06:44 +1300 Subject: Only install the cron entry if we are monitoring carp. --- config/haproxy-dev/haproxy.inc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'config') diff --git a/config/haproxy-dev/haproxy.inc b/config/haproxy-dev/haproxy.inc index 61cc71e6..eff614ec 100644 --- a/config/haproxy-dev/haproxy.inc +++ b/config/haproxy-dev/haproxy.inc @@ -65,7 +65,6 @@ function haproxy_custom_php_deinstall_command() { exec("rm /usr/local/etc/rc.d/haproxy.sh"); exec("rm /etc/devd/haproxy.conf"); exec("/etc/rc.d/devd restart"); - haproxy_install_cron(false); } function haproxy_custom_php_install_command() { @@ -156,7 +155,6 @@ EOD; fclose($fd); exec("/etc/rc.d/devd restart"); - haproxy_install_cron(true); conf_mount_ro(); exec("/usr/local/etc/rc.d/haproxy.sh start"); @@ -536,6 +534,11 @@ function haproxy_writeconf() { // create config file fclose($fd); + if (isset($a_global['carpdev'])) + haproxy_install_cron(true); + else + haproxy_install_cron(false); + $freebsd_version = substr(trim(`uname -r`), 0, 1); if(!file_exists("/usr/bin/limits")) { exec("fetch -q -o /usr/bin/limits http://files.pfsense.org/extras/{$freebsd_version}/limits"); -- cgit v1.2.3 From 155c3634e0e4e6a4fc7b3488bdf032a1661e8779 Mon Sep 17 00:00:00 2001 From: thompsa Date: Fri, 12 Mar 2010 16:08:10 +1300 Subject: Put back the cron removal on deinstall. --- config/haproxy-dev/haproxy.inc | 1 + 1 file changed, 1 insertion(+) (limited to 'config') diff --git a/config/haproxy-dev/haproxy.inc b/config/haproxy-dev/haproxy.inc index eff614ec..97a20faa 100644 --- a/config/haproxy-dev/haproxy.inc +++ b/config/haproxy-dev/haproxy.inc @@ -65,6 +65,7 @@ function haproxy_custom_php_deinstall_command() { exec("rm /usr/local/etc/rc.d/haproxy.sh"); exec("rm /etc/devd/haproxy.conf"); exec("/etc/rc.d/devd restart"); + haproxy_install_cron(false); } function haproxy_custom_php_install_command() { -- cgit v1.2.3 From e455a5327161728e87d8b214c0b31d9007d5e90a Mon Sep 17 00:00:00 2001 From: thompsa Date: Fri, 12 Mar 2010 17:43:00 +1300 Subject: Remove the 'status' from the backend pool and just show it disabled if no listeners are using it. --- config/haproxy-dev/haproxy.inc | 2 +- config/haproxy-dev/haproxy_pool_edit.php | 11 ----------- config/haproxy-dev/haproxy_pools.php | 33 +++++++++++++++++--------------- 3 files changed, 19 insertions(+), 27 deletions(-) (limited to 'config') diff --git a/config/haproxy-dev/haproxy.inc b/config/haproxy-dev/haproxy.inc index 97a20faa..ed8da06d 100644 --- a/config/haproxy-dev/haproxy.inc +++ b/config/haproxy-dev/haproxy.inc @@ -245,7 +245,7 @@ function haproxy_find_acl($name) { } function write_backend($fd, $name, $pool, $frontend) { - if($pool['status'] != 'active' || !is_array($pool['ha_servers']['item'])) + if(!is_array($pool['ha_servers']['item'])) continue; fwrite ($fd, "backend " . $name . "\n"); diff --git a/config/haproxy-dev/haproxy_pool_edit.php b/config/haproxy-dev/haproxy_pool_edit.php index 6087e9d7..d25f0675 100755 --- a/config/haproxy-dev/haproxy_pool_edit.php +++ b/config/haproxy-dev/haproxy_pool_edit.php @@ -52,7 +52,6 @@ if (isset($id) && $a_pools[$id]) { $pconfig['checkinter'] = $a_pools[$id]['checkinter']; $pconfig['monitor_uri'] = $a_pools[$id]['monitor_uri']; $pconfig['cookie'] = $a_pools[$id]['cookie']; - $pconfig['status'] = $a_pools[$id]['status']; $pconfig['advanced'] = base64_decode($a_pools[$id]['advanced']); $pconfig['a_servers']=&$a_pools[$id]['ha_servers']['item']; } @@ -145,7 +144,6 @@ if ($_POST) { $pool['ha_servers']['item']=$a_servers; update_if_changed("name", $pool['name'], $_POST['name']); - update_if_changed("status", $pool['status'], $_POST['status']); update_if_changed("cookie", $pool['cookie'], $_POST['cookie']); update_if_changed("advanced", $pool['advanced'], base64_encode($_POST['advanced'])); update_if_changed("checkinter", $pool['checkinter'], $_POST['checkinter']); @@ -230,15 +228,6 @@ function clearcombo(){ size="16" maxlength="16">
Status - -
Cookie diff --git a/config/haproxy-dev/haproxy_pools.php b/config/haproxy-dev/haproxy_pools.php index 78a1fdff..c5adc70b 100755 --- a/config/haproxy-dev/haproxy_pools.php +++ b/config/haproxy-dev/haproxy_pools.php @@ -103,38 +103,41 @@ include("head.inc"); - - + + "; $textse = ""; } + if (is_array($pool['ha_servers']['item'])) + $count = count($pool['ha_servers']['item']); + else + $count = 0; ?> - +
NameStatusListenerServersListener
- + - + -- cgit v1.2.3 From e0953a42d46724313fdc072a16756d8909ddad77 Mon Sep 17 00:00:00 2001 From: thompsa Date: Fri, 12 Mar 2010 18:03:09 +1300 Subject: Make unique pools if svrport is set. --- config/haproxy-dev/haproxy.inc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'config') diff --git a/config/haproxy-dev/haproxy.inc b/config/haproxy-dev/haproxy.inc index ed8da06d..84a927c7 100644 --- a/config/haproxy-dev/haproxy.inc +++ b/config/haproxy-dev/haproxy.inc @@ -383,7 +383,6 @@ function haproxy_writeconf() { $a_bind[$bname]['config'] = array(); // Settings which are constant for a merged frontend $a_bind[$bname]['name'] = $backend['name']; - $a_bind[$bname]['defaultpool'] = $backend['pool'] . "_" . strtolower($backend['type']); $a_bind[$bname]['extaddr'] = $backend['extaddr']; $a_bind[$bname]['port'] = $backend['port']; } @@ -465,9 +464,9 @@ function haproxy_writeconf() { if($bind['client_timeout']) fwrite ($fd, "\tclitimeout\t\t" . $bind['client_timeout'] . "\n"); - fwrite ($fd, "\tdefault_backend\t\t" . $bind['defaultpool'] . "\n"); // Combine the rest of the listener configs + $default_once = 0; $i = 0; foreach ($bind['config'] as $bconfig) { $a_acl=&$bconfig['ha_acls']['item']; @@ -475,6 +474,17 @@ function haproxy_writeconf() { $a_acl=array(); $poolname = $bconfig['pool'] . "_" . strtolower($bconfig['type']); + + // Create different pools if the svrport is set + if ($bconfig['svrport'] > 0) + $poolname .= "_" . $bconfig['svrport']; + + // Write this out once, and must be before any backend config text + if ($default_once == 0) { + fwrite ($fd, "\tdefault_backend\t\t" . $poolname . "\n"); + $default_once++; + } + if (!isset($a_pendingpl[$poolname])) { $a_pendingpl[$poolname] = array(); $a_pendingpl[$poolname]['name'] = $poolname; @@ -573,7 +583,7 @@ function haproxy_check_run($reload) { } log_error("Starting haproxy on CARP master."); /* fallthrough */ - } else if ($reload == 0)) + } else if ($reload == 0) return (0); if (haproxy_is_running()) { -- cgit v1.2.3 From 22299b2731a258e67f25b56adf5df10f94f9b75e Mon Sep 17 00:00:00 2001 From: Ermal Date: Fri, 12 Mar 2010 18:52:18 +0000 Subject: : --- config/openospfd/openospfd.inc | 20 +++++++++++++++++++- config/openospfd/openospfd_interfaces.xml | 1 + 2 files changed, 20 insertions(+), 1 deletion(-) (limited to 'config') diff --git a/config/openospfd/openospfd.inc b/config/openospfd/openospfd.inc index e0764031..c131142a 100644 --- a/config/openospfd/openospfd.inc +++ b/config/openospfd/openospfd.inc @@ -27,6 +27,24 @@ POSSIBILITY OF SUCH DAMAGE. */ +function ospfd_display_friendlyiface () { + global $evaledvar, $config, $g; + + if (intval($g['latest_config']) >= 6) + return; + + if ($evaledvar) { + foreach ($evaledvar as $idx => $field) { + if ($field['interface']) { + if (empty($config['interfaces'][$field['interface']]['descr'])) + $evaledvar[$idx]['interface'] = strtoupper($evaledvar[$idx]['interface']); + else + $evaledvar[$idx]['interface'] = $config['interfaces'][$field['interface']]['descr']; + } + } + } +} + function ospfd_install_conf() { global $config, $g, $input_errors; @@ -222,4 +240,4 @@ function is_ospfd_running() { return false; } -?> \ No newline at end of file +?> diff --git a/config/openospfd/openospfd_interfaces.xml b/config/openospfd/openospfd_interfaces.xml index e8b18fcf..445eefea 100644 --- a/config/openospfd/openospfd_interfaces.xml +++ b/config/openospfd/openospfd_interfaces.xml @@ -4,6 +4,7 @@ Services: OpenOSPFd /usr/local/pkg/openospfd.inc pkg.php?xml=openospfd_interfaces.xml + ospfd_display_friendlyiface(); /usr/local/pkg/ 077 -- cgit v1.2.3 From a611f8b7560b30a7c975dce2c12c9651d5452025 Mon Sep 17 00:00:00 2001 From: Ermal Date: Fri, 12 Mar 2010 18:59:58 +0000 Subject: Fix editing of interfaces. --- config/openospfd/openospfd.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'config') diff --git a/config/openospfd/openospfd.inc b/config/openospfd/openospfd.inc index c131142a..d6a3e67d 100644 --- a/config/openospfd/openospfd.inc +++ b/config/openospfd/openospfd.inc @@ -186,13 +186,13 @@ function ospfd_install_conf() { } function ospfd_validate_interface() { - global $config, $g, $input_errors; + global $config, $g, $id, $input_errors; if ($config['installedpackages']['ospfdinterfaces']['config']) { foreach ($config['installedpackages']['ospfdinterfaces']['config'] as $index => $conf) { if ($index == 0) continue; - if ($conf['interface'] == $_POST['interface']) + if ($id != $index && $conf['interface'] == $_POST['interface']) $input_errors[] = "Interface {$_POST['interface']} is already configured."; } } -- cgit v1.2.3 From 448a530be437cfde416c62ccf6460395887af384 Mon Sep 17 00:00:00 2001 From: robiscool Date: Sat, 13 Mar 2010 17:53:57 -0800 Subject: snort-dev, major rewites of startup code started, protected bootup code started --- config/snort-dev/images/footer2.jpg | Bin 0 -> 31879 bytes config/snort-dev/snort.inc | 241 +++++++++++++++++++++++- config/snort-dev/snort.xml | 2 +- config/snort-dev/snort_interfaces.php | 284 +++++++++++++++++++++++------ config/snort-dev/snort_interfaces_edit.php | 15 +- 5 files changed, 471 insertions(+), 71 deletions(-) create mode 100644 config/snort-dev/images/footer2.jpg (limited to 'config') diff --git a/config/snort-dev/images/footer2.jpg b/config/snort-dev/images/footer2.jpg new file mode 100644 index 00000000..37bdb18e Binary files /dev/null and b/config/snort-dev/images/footer2.jpg differ diff --git a/config/snort-dev/snort.inc b/config/snort-dev/snort.inc index 4294966f..513fc626 100644 --- a/config/snort-dev/snort.inc +++ b/config/snort-dev/snort.inc @@ -444,13 +444,14 @@ function sync_snort_package() conf_mount_ro(); } - /* make sure this func on writes to files and does not start snort */ function sync_snort_package_all() { global $config, $g, $id, $if_real, $interface_fake; conf_mount_rw(); + + /* RedDevil suggested code */ /* TODO: more testing needs to be done */ exec("/sbin/sysctl net.bpf.bufsize=8388608"); @@ -458,6 +459,9 @@ exec("/sbin/sysctl net.bpf.maxbufsize=4194304"); exec("/sbin/sysctl net.bpf.maxinsns=512"); exec("/sbin/sysctl net.inet.tcp.rfc1323=1"); +if ($id != '' && $if_real != '') +{ + /* do not start config build if rules is empty */ if (!empty($config['installedpackages']['snortglobal']['rule'])) { @@ -477,6 +481,9 @@ exec("/sbin/sysctl net.inet.tcp.rfc1323=1"); /* create snort configuration file */ create_snort_conf(); + /* create snort bootup file snort.sh */ + create_snort_sh(); + /* if rules exist cp rules to each iface */ create_rules_iface(); @@ -492,6 +499,8 @@ exec("/sbin/sysctl net.inet.tcp.rfc1323=1"); /* create snort configuration file */ create_snort_conf(); + /* create snort bootup file snort.sh */ + create_snort_sh(); /* if rules exist cp rules to each iface */ create_rules_iface(); @@ -554,11 +563,218 @@ exec("/sbin/sysctl net.inet.tcp.rfc1323=1"); conf_mount_ro(); } +} /* Start of main config files */ /* Start of main config files */ +////////////////////////// >>>>>>>>>> + + +/* open snort.sh for writing" */ +function create_snort_sh() +{ + # Don not add $id or this will break + + global $config, $g, $if_real, $if_real_wan; + conf_mount_rw(); + + $snortbarnyardlog_info_chk = $config['installedpackages']['snortglobal']['rule'][$id]['barnyard_enable']; + + /* define snortbarnyardlog_chk */ + if ($snortbarnyardlog_info_chk == on) { + + $start_barnyard2 = "sleep 4/n/usr/local/bin/barnyard2 -u snort -g snort -c /usr/local/etc/snort/snort_$id$if_real/barnyard2.conf -d /var/log/snort -f snort.u2_$id$if_real -w /usr/local/etc/snort/snort_$id$if_real/barnyard2.waldo -D -q"; + +} + + /* do not start config build if rules is empty */ + if (!empty($config['installedpackages']['snortglobal']['rule'])) + { + if ($id == "") + { + + $rule_array = $config['installedpackages']['snortglobal']['rule']; + $id = -1; + foreach ($rule_array as $value) + { + + $id += 1; + + $result_lan = $config['installedpackages']['snortglobal']['rule'][$id]['interface']; + $if_real = convert_friendly_interface_to_real_interface_name($result_lan); + + /* Get all interface startup commands ready */ + +$snort_sh_text2[] = << /tmp/snort.sh.pid + + # Start snort and barnyard2 + /bin/rm /var/run/snort_$if_real$id$if_real.pid + /bin/rm /var/run/snort_$if_real$id$if_real.pid.lck + + /usr/local/bin/snort -u snort -g snort -R $id$if_real -D -q -l /var/log/snort -G $id -c /usr/local/etc/snort/snort_$id$if_real/snort.conf -i $if_real + $start_barnyard2 + + /usr/bin/logger -p daemon.info -i -t SnortStartup "Snort HARD Reload For $id$if_real..." + + fi +EOD; + +$snort_sh_text3[] = << /tmp/snort.sh.pid + /usr/bin/logger -p daemon.info -i -t SnortStartup "Snort HARD STOP For $id$if_real..." + + /bin/kill \${pid_s} + sleep 3 + /bin/kill \${pid_b} + + /bin/rm /var/run/snort_$if_real$id$if_real.pid.lck + /bin/rm /var/run/snort_$if_real$id$if_real.pid + + fi +EOF; + + } + } + } + +$start_snort_iface_start = implode("\n\n", $snort_sh_text2); + +$start_snort_iface_restart = implode("\n\n", $snort_sh_text3); + +$start_snort_iface_stop = implode("\n\n", $snort_sh_text4); + +/* open snort.sh for writing" */ +conf_mount_rw(); + +$snort_sh_text = << /dev/null ; then + + /usr/bin/logger -p daemon.info -i -t SnortStartup "Error: snort.sh IS running" + exit 0 + + fi + + /bin/echo "snort.sh run" > /tmp/snort.sh.pid + +$start_snort_iface_restart + + /bin/rm /tmp/snort.sh.pid + + #### If on Fake start snort is NOT running DO a real start. + if [ "`/bin/ps -auwx | grep -v grep | grep "R $id$if_real" | awk '{print $2;}'`" = "" ]; then + + rc_start_real + + fi +} + +rc_start_real() { + + #### Check for double starts, Pfsense has problems with that + if /bin/ls /tmp/snort.sh.pid > /dev/null ; then + /usr/bin/logger -p daemon.info -i -t SnortStartup "Error: snort.sh IS running" + exit 0 + fi + +$start_snort_iface_start + + /bin/rm /tmp/snort.sh.pid + +} + +rc_stop() { + + #### Check for double starts, Pfsense has problems with that + if /bin/ls /tmp/snort.sh.pid > /dev/null ; then + /usr/bin/logger -p daemon.info -i -t SnortStartup "Error: snort.sh IS running" + exit 0 + fi + +$start_snort_iface_stop + + /bin/rm /tmp/snort.sh.pid + /bin/rm /var/run/snort* + +} + +case $1 in + start) + rc_start + ;; + start_real) + rc_start_real + ;; + stop) + rc_stop + ;; + restart) + rc_stop + rc_start_real + ;; +esac + +EOD; + + /* write out snort.sh */ + $bconf = fopen("/usr/local/etc/rc.d/snort.sh", "w"); + if(!$bconf) { + log_error("Could not open /usr/local/etc/rc.d/snort.sh for writing."); + exit; + } + /* write snort.sh */ + fwrite($bconf, $snort_sh_text); + fclose($bconf); + +} + + +///////////////////////// >>>>>>>>>>>> /* if rules exist copy to new interfaces */ function create_rules_iface() @@ -566,16 +782,19 @@ function create_rules_iface() global $config, $g, $id, $if_real; conf_mount_rw(); - - $if_rule_dir = "/usr/local/etc/snort/snort_$id$if_real/rules"; - $folder_chk = (count(glob("$if_rule_dir/*")) === 0) ? 'empty' : 'full'; - - if ($folder_chk == "empty") + + if ($id != '' || $if_real != '') { - exec("/bin/cp -R /usr/local/etc/snort/rules /usr/local/etc/snort/snort_$id$if_real"); - if (file_exists("/usr/local/etc/snort/custom_rules/local_$id$if_real.rules")) + $if_rule_dir = "/usr/local/etc/snort/snort_$id$if_real/rules"; + $folder_chk = (count(glob("$if_rule_dir/*")) === 0) ? 'empty' : 'full'; + + if ($folder_chk == "empty") { - exec("/bin/cp /usr/local/etc/snort/custom_rules/local_$id$if_real.rules /usr/local/etc/snort/snort_$id$if_real/rules/local_$id$if_real.rules"); + exec("/bin/cp -R /usr/local/etc/snort/rules /usr/local/etc/snort/snort_$id$if_real"); + if (file_exists("/usr/local/etc/snort/custom_rules/local_$id$if_real.rules")) + { + exec("/bin/cp /usr/local/etc/snort/custom_rules/local_$id$if_real.rules /usr/local/etc/snort/snort_$id$if_real/rules/local_$id$if_real.rules"); + } } } } @@ -795,6 +1014,9 @@ function generate_snort_conf() global $config, $g, $if_real, $id; conf_mount_rw(); +if ($id != '' && $if_real != '') +{ + /* obtain external interface */ /* XXX: make multi wan friendly */ $snort_ext_int = $config['installedpackages']['snortglobal']['rule'][$id]['interface']; @@ -820,6 +1042,7 @@ function generate_snort_conf() exec("/bin/mkdir -p /usr/local/etc/snort/snort_$id$if_real/rules"); } } +} /* define snortalertlogtype */ $snortalertlogtype = $config['installedpackages']['snortglobal']['snortalertlogtype']; diff --git a/config/snort-dev/snort.xml b/config/snort-dev/snort.xml index 6a46cf7e..6ab6ee7a 100644 --- a/config/snort-dev/snort.xml +++ b/config/snort-dev/snort.xml @@ -141,7 +141,7 @@ /usr/local/www/snort/ 077 - http://www.pfsense.com/packages/config/snort-dev/help_and_info.php + http://www.pfsense.com/packages/config/snort-dev/help_and_info.html /usr/local/www/snort/ diff --git a/config/snort-dev/snort_interfaces.php b/config/snort-dev/snort_interfaces.php index e5b42e4d..996ff83b 100644 --- a/config/snort-dev/snort_interfaces.php +++ b/config/snort-dev/snort_interfaces.php @@ -31,7 +31,7 @@ require("guiconfig.inc"); require("/usr/local/pkg/snort/snort_gui.inc"); -require("/usr/local/pkg/snort/snort.inc"); +include_once("/usr/local/pkg/snort/snort.inc"); $id = $_GET['id']; if (isset($_POST['id'])) @@ -78,35 +78,84 @@ if (isset($_POST['del_x'])) { /* delete selected rules */ if (is_array($_POST['rule']) && count($_POST['rule'])) { foreach ($_POST['rule'] as $rulei) { - - - /* dont flood the syslog code */ - exec("/bin/cp /var/log/system.log /var/log/system.log.bk"); - exec("/bin/sh /usr/local/etc/rc.d/snort.sh stop $rulei"); - - /* stop syslog flood code */ - $if_real_wan_rulei = $a_nat[$rulei]['interface']; - $if_real_wan_rulei2 = convert_friendly_interface_to_real_interface_name2($if_real_wan_rulei); - exec("/bin/cp /var/log/system.log /var/log/snort/snort_sys_$rulei$if_real.log"); - exec("/usr/bin/killall syslogd"); - exec("/usr/sbin/clog -i -s 262144 /var/log/system.log"); - exec("/usr/sbin/syslogd -c -ss -f /var/etc/syslog.conf"); - sleep(2); - exec("/bin/cp /var/log/system.log.bk /var/log/system.log"); - $after_mem = exec("/usr/bin/top | /usr/bin/grep Wired | /usr/bin/awk '{ print $2 }'"); - exec("/usr/bin/logger -p daemon.info -i -t SnortStartup 'MEM after {$rulei}{$if_real} STOP {$after_mem}'"); - exec("/usr/bin/logger -p daemon.info -i -t SnortStartup 'Interface Rule removed for {$rulei}{$if_real}...'"); - - unset($a_nat[$rulei]); - + + /* convert fake interfaces to real */ + $if_real = convert_friendly_interface_to_real_interface_name($a_nat[$rulei]['interface']); + + $snort_pid = exec("/bin/ps -auwx | grep -v grep | grep \"$if_real -c\" | awk '{print $2;}'"); + + if ($snort_pid != "") + { + + $start_up_pre = exec("/bin/cat /var/run/snort_{$if_real}{$rulei}{$if_real}.pid"); + $start_up_s = exec("/usr/bin/top -U snort -u | grep snort | grep {$start_up_pre} | awk '{ print $1; }'"); + $start_up_r = exec("/usr/bin/top -U root -u | grep snort | grep {$start_up_pre} | awk '{ print $1; }'"); + + $start2_upb_pre = exec("/bin/cat /var/run/barnyard2_{$rulei}{$if_real}.pid"); + $start2_upb_s = exec("/usr/bin/top -U snort -u | grep barnyard2 | grep {$start2_upb_pre} | awk '{ print $1; }'"); + $start2_upb_r = exec("/usr/bin/top -U root -u | grep barnyard2 | grep {$start2_upb_pre} | awk '{ print $1; }'"); + + + if ($start_up_s != "" || $start_up_r != "" || $start2_upb_s != "" || $start2_upb_r != "") + { + + /* dont flood the syslog code */ + exec("/bin/cp /var/log/system.log /var/log/system.log.bk"); + sleep(3); + + + /* remove only running instances */ + if ($start_up_s != "") + { + exec("/bin/kill {$start_up_s}"); + exec("/bin/rm /var/run/snort_$if_real$rulei$if_real*"); + } + + if ($start2_upb_s != "") + { + exec("/bin/kill {$start2_upb_s}"); + exec("/bin/rm /var/run/barnyard2_$rulei$if_real*"); + } + + if ($start_up_r != "") + { + exec("/bin/kill {$start_up_r}"); + exec("/bin/rm /var/run/snort_$if_real$rulei$if_real*"); + } + + if ($start2_upb_r != "") + { + exec("/bin/kill {$start2_upb_r}"); + exec("/bin/rm /var/run/barnyard2_$rulei$if_real*"); + } + + /* stop syslog flood code */ + $if_real_wan_rulei = $a_nat[$rulei]['interface']; + $if_real_wan_rulei2 = convert_friendly_interface_to_real_interface_name2($if_real_wan_rulei); + exec("/sbin/ifconfig $if_real_wan_rulei2 -promisc"); + exec("/bin/cp /var/log/system.log /var/log/snort/snort_sys_$rulei$if_real.log"); + exec("/usr/bin/killall syslogd"); + exec("/usr/sbin/clog -i -s 262144 /var/log/system.log"); + exec("/usr/sbin/syslogd -c -ss -f /var/etc/syslog.conf"); + sleep(2); + exec("/bin/cp /var/log/system.log.bk /var/log/system.log"); + $after_mem = exec("/usr/bin/top | /usr/bin/grep Wired | /usr/bin/awk '{ print $2 }'"); + exec("/usr/bin/logger -p daemon.info -i -t SnortStartup 'MEM after {$rulei}{$if_real} STOP {$after_mem}'"); + exec("/usr/bin/logger -p daemon.info -i -t SnortStartup 'Interface Rule removed for {$rulei}{$if_real}...'"); + + } + + } + + unset($a_nat[$rulei]); + } - - - - conf_mount_rw(); - exec("/bin/rm -r /usr/local/etc/snort/snort_$rulei$if_real"); - exec("/bin/rm /var/log/snort/snort.u2_$rulei$if_real*"); - conf_mount_ro(); + + conf_mount_rw(); + exec("/bin/rm -r /usr/local/etc/snort/snort_$rulei$if_real"); + exec("/bin/rm /usr/local/etc/rc.d/snort_$rulei$if_real.sh"); + exec("/bin/rm /var/log/snort/snort.u2_$rulei$if_real*"); + conf_mount_ro(); write_config(); // touch($d_natconfdirty_path); @@ -166,19 +215,88 @@ if ($_GET['act'] == "toggle" && $_GET['id'] != "") { $if_real2 = convert_friendly_interface_to_real_interface_name($a_nat[$id]['interface']); - $name = "{$id}{$if_real2}"; - $snort_pid = exec("pgrep -F /var/run/snort_{$if_real2}{$name}.pid snort"); - if ($snort_pid != "") { - exec("/bin/sh /usr/local/etc/rc.d/snort.sh stop $name"); + $start_up_pre = exec("/usr/bin/top -a -U snort -u | grep -v grep | grep \"R {$id}{$if_real2}\" | awk '{print \$1;}'"); + $start_up_s = exec("/usr/bin/top -U snort -u | grep snort | grep {$start_up_pre} | awk '{ print $1; }'"); + $start_up_r = exec("/usr/bin/top -U root -u | grep snort | grep {$start_up_pre} | awk '{ print $1; }'"); + + //$start2_upb_pre = exec("/bin/cat /var/run/barnyard2_{$id}{$if_real2}.pid"); + //$start2_upb_s = exec("/usr/bin/top -U snort -u | grep barnyard2 | grep {$start2_upb_pre} | awk '{ print $1; }'"); + //$start2_upb_r = exec("/usr/bin/top -U root -u | grep barnyard2 | grep {$start2_upb_pre} | awk '{ print $1; }'"); + + + if ($start_up_s != "" || $start_up_r != "" || $start2_upb_s != "" || $start2_upb_r != "") + { + + /* stop syslog flood code */ + //exec("/bin/cp /var/log/system.log /var/log/system.log.bk"); + //sleep(3); + + if ($start_up_s != "") + { + exec("/bin/kill {$start_up_s}"); + exec("/bin/rm /var/run/snort_$if_real2$id$if_real2*"); + } + + //if ($start2_upb_s != "") + //{ + //exec("/bin/kill {$start2_upb_s}"); + //exec("/bin/rm /var/run/barnyard2_$id$if_real2*"); + //} + + if ($start_up_r != "") + { + exec("/bin/kill {$start_up_r}"); + exec("/bin/rm /var/run/snort_$if_real2$id$if_real2*"); + } + + //if ($start2_upb_r != "") + //{ + //exec("/bin/kill {$start2_upb_r}"); + //exec("/bin/rm /var/run/barnyard2_$id$if_real2*"); + //} + + /* stop syslog flood code */ + $if_real_wan_id = $a_nat[$id]['interface']; + $if_real_wan_id2 = convert_friendly_interface_to_real_interface_name2($if_real_wan_id); + exec("/sbin/ifconfig $if_real_wan_id2 -promisc"); + //exec("/bin/cp /var/log/system.log /var/log/snort/snort_sys_$id$if_real2.log"); + //exec("/usr/bin/killall syslogd"); + //exec("/usr/sbin/clog -i -s 262144 /var/log/system.log"); + //exec("/usr/sbin/syslogd -c -ss -f /var/etc/syslog.conf"); + //sleep(2); + //exec("/bin/cp /var/log/system.log.bk /var/log/system.log"); + //$after_mem2 = exec("/usr/bin/top | /usr/bin/grep Wired | /usr/bin/awk '{ print $2 }'"); + //exec("/usr/bin/logger -p daemon.info -i -t SnortStartup 'MEM after {$id}{$if_real2} STOP {$after_mem2}'"); + //exec("/usr/bin/logger -p daemon.info -i -t SnortStartup 'Interface Rule STOP for {$id}{$if_real2}...'"); + + + 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' ); + header( 'Cache-Control: post-check=0, pre-check=0', false ); + header( 'Pragma: no-cache' ); + sleep(2); + header("Location: /snort/snort_interfaces.php"); + }else{ sync_snort_package_all(); - exec("/bin/sh /usr/local/etc/rc.d/snort.sh start $name"); + + exec("/usr/local/bin/snort -u snort -g snort -R \"$id$if_real2\" -D -q -l /var/log/snort -G $id -c /usr/local/etc/snort/snort_$id$if_real2/snort.conf -i $if_real2"); + //print_r("$id $if_real2"); + + 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' ); + header( 'Cache-Control: post-check=0, pre-check=0', false ); + header( 'Pragma: no-cache' ); + sleep(2); + header("Location: /snort/snort_interfaces.php"); } - header("Location: snort_interfaces.php"); + } -$pgtitle = "Services: Snort 2.8.5.3 pkg v. 1.10 Alpha"; +$pgtitle = "Services: Snort 2.8.5.3 pkg v. 1.10 alpha"; include("head.inc"); ?> @@ -186,6 +304,7 @@ include("head.inc");

@@ -237,18 +371,18 @@ padding: 15px 10px 50% 50px;
- - + - - - + +
+
@@ -264,30 +398,47 @@ padding: 15px 10px 50% 50px;
- - + +
"> Note:
- This is the Snort Menu, displaying an overview of all interface settings. + This is the Snort Menu where you can see an over view of all your interface settings.
- Please edit the Global Settings tab before adding an interface. + Please edit the Global Settings tab befor adding an interface.

- Click on the icon to add an interface.                           Click on the icon to start snort and barnyard. + Click on the icon to add a interface.                           Click on the icon to start snort and barnyard.
- Click on the icon to edit an interface and settings.      Click on the icon to stop snort and barnyard. + Click on the icon to edit a interface and settings.      Click on the icon to stop snort and barnyard.
- Click on the icon to delete an interface and settings. + Click on the icon to delete a interface and settings.
@@ -410,6 +564,24 @@ if ($pkg['tabs'] <> "") { ?> - + + + +
+ Apps + Snort® is a registered trademark of Sourcefire, Inc., Barnyard2® is a registered trademark of securixlive.com., Orion® copyright Robert Zelaya., + Emergingthreats is a registered trademark of emergingthreats.net., Mysql® is a registered trademark of Mysql.com. +
+ + + + + diff --git a/config/snort-dev/snort_interfaces_edit.php b/config/snort-dev/snort_interfaces_edit.php index 9d2301f0..6bdb0dc7 100644 --- a/config/snort-dev/snort_interfaces_edit.php +++ b/config/snort-dev/snort_interfaces_edit.php @@ -121,7 +121,7 @@ if (isset($_GET['dup'])) /* convert fake interfaces to real */ $if_real = convert_friendly_interface_to_real_interface_name($pconfig['interface']); -if ($_POST["Submit"]) { +if ($_POST['Submit']) { /* input validation */ // if(strtoupper($_POST['proto']) == "TCP" or strtoupper($_POST['proto']) == "UDP" or strtoupper($_POST['proto']) == "TCP/UDP") { @@ -277,24 +277,29 @@ if ($_POST["Submit"]) { write_config(); // stop_service("snort"); - if ($pconfig['interface'] != "") { + if ($pconfig['interface'] != '' && $id != '') { sync_snort_package_all(); + } - if ($pconfig['interface'] != "") { + if ($pconfig['interface'] != '' && $id != '') { header("Location: /snort/snort_interfaces_edit.php?id=$id"); }else{ touch($d_natconfdirty_path); header("Location: /snort/snort_interfaces.php"); + } exit; } } if ($_POST["Submit2"]) { - sync_snort_package_all(); + if ($id != '') + { + sync_snort_package_all(); + } sleep(1); - exec("/bin/sh /usr/local/etc/rc.d/snort.sh restart {$id}{$if_real}"); + exec("/bin/sh /usr/local/etc/rc.d/snort.sh start {$id}{$if_real}"); header("Location: /snort/snort_interfaces_edit.php?id=$id"); exit; } -- cgit v1.2.3 From cba67e58d3caa74ea187744d9775dc2aafe0f4cf Mon Sep 17 00:00:00 2001 From: thompsa Date: Tue, 16 Mar 2010 09:00:31 +1300 Subject: Copy the haproxy-dev package before the carp checks to haproxy-stable --- config/haproxy-stable/haproxy.inc | 581 +++++++++++++++++ config/haproxy-stable/haproxy.xml | 110 ++++ config/haproxy-stable/haproxy_global.php | 378 +++++++++++ config/haproxy-stable/haproxy_listeners.php | 172 +++++ config/haproxy-stable/haproxy_listeners_edit.php | 771 +++++++++++++++++++++++ config/haproxy-stable/haproxy_pool_edit.php | 505 +++++++++++++++ config/haproxy-stable/haproxy_pools.php | 166 +++++ 7 files changed, 2683 insertions(+) create mode 100644 config/haproxy-stable/haproxy.inc create mode 100644 config/haproxy-stable/haproxy.xml create mode 100755 config/haproxy-stable/haproxy_global.php create mode 100755 config/haproxy-stable/haproxy_listeners.php create mode 100755 config/haproxy-stable/haproxy_listeners_edit.php create mode 100755 config/haproxy-stable/haproxy_pool_edit.php create mode 100755 config/haproxy-stable/haproxy_pools.php (limited to 'config') diff --git a/config/haproxy-stable/haproxy.inc b/config/haproxy-stable/haproxy.inc new file mode 100644 index 00000000..455638a1 --- /dev/null +++ b/config/haproxy-stable/haproxy.inc @@ -0,0 +1,581 @@ + + Copyright (C) 2008 Remco Hoef + 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. +*/ + +/* include all configuration functions */ +require_once("functions.inc"); +require_once("pkg-utils.inc"); +require_once("notices.inc"); + +$d_haproxyconfdirty_path = $g['varrun_path'] . "/haproxy.conf.dirty"; + +$a_acltypes = array(); +$a_acltypes[] = array('name' => 'host_starts_with', 'descr' => 'Host starts with', + 'mode' => 'http', 'syntax' => 'hdr_beg(host) -i'); +$a_acltypes[] = array('name' => 'host_ends_with', 'descr' => 'Host ends with', + 'mode' =>'http', 'syntax' => 'hdr_end(host) -i'); +$a_acltypes[] = array('name' => 'host_matches', 'descr' => 'Host matches', + 'mode' =>'http', 'syntax' => 'hdr(host) -i'); +$a_acltypes[] = array('name' => 'host_regex', 'descr' => 'Host regex', + 'mode' =>'http', 'syntax' => 'hdr_reg(host) -i'); +$a_acltypes[] = array('name' => 'host_contains', 'descr' => 'Host contains', + 'mode' => 'http', 'syntax' => 'hdr_dir(host) -i'); +$a_acltypes[] = array('name' => 'path_starts_with', 'descr' => 'Path starts with', + 'mode' => 'http', 'syntax' => 'path_beg -i'); +$a_acltypes[] = array('name' => 'path_ends_with', 'descr' => 'Path ends with', + 'mode' => 'http', 'syntax' => 'path_end -i'); +$a_acltypes[] = array('name' => 'path_matches', 'descr' => 'Path matches', + 'mode' => 'http', 'syntax' => 'path -i'); +$a_acltypes[] = array('name' => 'path_regex', 'descr' => 'Path regex', + 'mode' => 'http', 'syntax' => 'path_reg -i'); +$a_acltypes[] = array('name' => 'path_contains', 'descr' => 'Path contains', + 'mode' => 'http', 'syntax' => 'path_dir -i'); +$a_acltypes[] = array('name' => 'source_ip', 'descr' => 'Source IP', + 'mode' => '', 'syntax' => 'src'); + +function haproxy_custom_php_deinstall_command() { + exec("rm /usr/local/sbin/haproxy"); + exec("rm /usr/local/pkg/haproxy.inc"); + exec("rm /usr/local/www/haproxy*"); +} + +function haproxy_custom_php_install_command() { + global $g, $config; + conf_mount_rw(); + + $haproxy = << +ENDOFF +} + +haproxy_stop () { + echo "Stopping haproxy." + killall haproxy +} + +run_rc_command "\$1" + +EOD; + + $fd = fopen("/usr/local/etc/rc.d/haproxy.sh", "w"); + fwrite($fd, $haproxy); + fclose($fd); + exec("chmod a+rx /usr/local/etc/rc.d/haproxy.sh"); + + conf_mount_ro(); + + exec("/usr/local/etc/rc.d/haproxy.sh start"); +} + +function haproxy_find_acl($name) { + global $a_acltypes; + + /* XXX why is this broken from xmlsync? */ + if (!$a_acltypes) { + $a_acltypes = array(); + $a_acltypes[] = array('name' => 'host_starts_with', 'descr' => 'Host starts with', + 'mode' => 'http', 'syntax' => 'hdr_beg(host) -i'); + $a_acltypes[] = array('name' => 'host_ends_with', 'descr' => 'Host ends with', + 'mode' =>'http', 'syntax' => 'hdr_end(host) -i'); + $a_acltypes[] = array('name' => 'host_matches', 'descr' => 'Host matches', + 'mode' =>'http', 'syntax' => 'hdr(host) -i'); + $a_acltypes[] = array('name' => 'host_regex', 'descr' => 'Host regex', + 'mode' =>'http', 'syntax' => 'hdr_reg(host) -i'); + $a_acltypes[] = array('name' => 'host_contains', 'descr' => 'Host contains', + 'mode' => 'http', 'syntax' => 'hdr_dir(host) -i'); + $a_acltypes[] = array('name' => 'path_starts_with', 'descr' => 'Path starts with', + 'mode' => 'http', 'syntax' => 'path_beg -i'); + $a_acltypes[] = array('name' => 'path_ends_with', 'descr' => 'Path ends with', + 'mode' => 'http', 'syntax' => 'path_end -i'); + $a_acltypes[] = array('name' => 'path_matches', 'descr' => 'Path matches', + 'mode' => 'http', 'syntax' => 'path -i'); + $a_acltypes[] = array('name' => 'path_regex', 'descr' => 'Path regex', + 'mode' => 'http', 'syntax' => 'path_reg -i'); + $a_acltypes[] = array('name' => 'path_contains', 'descr' => 'Path contains', + 'mode' => 'http', 'syntax' => 'path_dir -i'); + $a_acltypes[] = array('name' => 'source_ip', 'descr' => 'Source IP', + 'mode' => '', 'syntax' => 'src'); + } + + if($a_acltypes) { + foreach ($a_acltypes as $acl) { + if ($acl['name'] == $name) + return $acl; + } + } +} + +function write_backend($fd, $name, $pool, $frontend) { + if($pool['status'] != 'active' || !is_array($pool['ha_servers']['item'])) + continue; + + fwrite ($fd, "backend " . $name . "\n"); + if($pool['cookie_name'] && strtolower($frontend['type']) == "http") + fwrite ($fd, "\tcookie\t\t\t" . $pool['cookie_name'] . " insert indirect\n"); + + // https is an alias for tcp for clarity purpouses + if(strtolower($frontend['type']) == "https") { + $backend_type = "tcp"; + $httpchk = "ssl-hello-chk"; + } else { + $backend_type = $frontend['type']; + $httpchk = "httpchk"; + } + + fwrite ($fd, "\tmode\t\t\t" . $backend_type . "\n"); + + if($frontend['balance']) + fwrite ($fd, "\tbalance\t\t\t" . $frontend['balance'] . "\n"); + + if($frontend['connection_timeout']) + fwrite ($fd, "\tcontimeout\t\t" . $frontend['connection_timeout'] . "\n"); + + if($frontend['server_timeout']) + fwrite ($fd, "\tsrvtimeout\t\t" . $frontend['server_timeout'] . "\n"); + + if($frontend['retries']) + fwrite ($fd, "\tretries\t\t\t" . $frontend['retries'] . "\n"); + + if($frontend['stats_enabled']=='yes') { + fwrite ($fd, "\tstats\t\t\tenable\n"); + if($frontend['stats_uri']) + fwrite ($fd, "\tstats\t\t\turi ".$frontend['stats_uri']."\n"); + if($frontend['stats_realm']) + fwrite ($fd, "\tstats\t\t\trealm " . $frontend['stats_realm'] . "\n"); + else + fwrite ($fd, "\tstats\t\t\trealm .\n"); + fwrite ($fd, "\tstats\t\t\tauth " . $frontend['stats_username'].":". $frontend['stats_password']."\n"); + } + + $uri = $pool['monitor_uri']; + if ($pool['monitor_uri']) + $uri = $pool['monitor_uri']; + else + $uri = "/"; + fwrite ($fd, "\toption\t\t\t{$httpchk} HEAD " . $uri . " HTTP/1.0\n"); + + if($pool['cookie'] && strtolower($frontend['type']) == "http") + $cookie = " cookie {$pool['cookie']} "; + else + $cookie = ""; + if($pool['advanced']) { + $advanced = base64_decode($pool['advanced']); + $advanced_txt = " " . $advanced; + } else { + $advanced_txt = ""; + } + if($pool['checkinter']) + $checkinter = "check inter {$pool['checkinter']}"; + else if (strtolower($frontend['type']) != "tcp") + $checkinter = "check inter 1000"; + else + $checkinter = ""; + + $a_servers = &$pool['ha_servers']['item']; + foreach($a_servers as $be) { + if(!$be['port']) { + // the listener can specify a default port + $be['port'] = $frontend['svrport']; + } + if(!$be['port']) { + // last resort, use the frontend port + $ports = split(",", "{$frontend['port']},"); + $be['port'] = $ports[0]; + } + if (!$be['name']) + $be['name'] = $be['address']; + if($be['backup']) { + $isbackup = "backup"; + } else { + $isbackup = ""; + } + fwrite ($fd, "\tserver\t\t\t" . $be['name'] . " " . $be['address'].":" . $be['port'] . " $cookie " . " $checkinter $isbackup weight " . $be['weight'] . "{$advanced_txt}\n"); + } + fwrite ($fd, "\n"); +} + +function haproxy_configure() { + global $config, $g; + + $a_global = &$config['installedpackages']['haproxy']; + $a_backends = &$config['installedpackages']['haproxy']['ha_backends']['item']; + $a_pools = &$config['installedpackages']['haproxy']['ha_pools']['item']; + + $fd = fopen("{$g['varetc_path']}/haproxy.cfg", "w"); + + if(is_array($a_global)) { + fwrite ($fd, "global\n"); + if($a_global['advanced']) + fwrite ($fd, "\t" . base64deode($a_global['advanced']) . "\n"); + fwrite ($fd, "\tmaxconn\t\t\t".$a_global['maxconn']."\n"); + if($a_global['remotesyslog']) + fwrite ($fd, "\tlog\t\t\t{$a_global['remotesyslog']}\t{$a_global['logfacility']}\t{$a_global['loglevel']}\n"); + fwrite ($fd, "\tuid\t\t\t80\n"); + fwrite ($fd, "\tgid\t\t\t80\n"); + // Set numprocs if defined or use system default (#cores) + if($a_global['nbproc']) + $numprocs = $a_global['nbproc']; + else + $numprocs = trim(`/sbin/sysctl kern.smp.cpus | cut -d" " -f2`); + fwrite ($fd, "\tnbproc\t\t\t$numprocs\n"); + fwrite ($fd, "\tchroot\t\t\t/var/empty\n"); + fwrite ($fd, "\tdaemon\n"); + fwrite ($fd, "\n"); + } + + // Try and get a unique array for address:port as frontends can duplicate + $a_bind = array(); + if(is_array($a_backends)) { + foreach ($a_backends as $backend) { + if($backend['status'] != 'active') + continue; + if(!$backend['pool']) + continue; + + $bname = $backend['extaddr'] . ":" . $backend['port']; + if (!is_array($a_bind[$bname])) { + $a_bind[$bname] = array(); + $a_bind[$bname]['config'] = array(); + // Settings which are constant for a merged frontend + $a_bind[$bname]['name'] = $backend['name']; + $a_bind[$bname]['defaultpool'] = $backend['pool'] . "_" . strtolower($backend['type']); + $a_bind[$bname]['extaddr'] = $backend['extaddr']; + $a_bind[$bname]['port'] = $backend['port']; + } + $b = &$a_bind[$bname]; + + // Overwrite ? + $b['type'] = $backend['type']; + $b['forwardfor'] = $backend['forwardfor']; + $b['httpclose'] = $backend['httpclose']; + $b['max_connections'] = $backend['max_connections']; + $b['client_timeout'] = $backend['client_timeout']; + $b['advanced'] = $backend['advanced']; + + // pointer to each backend + $b['config'][] = $backend; + } + } + + $a_pendingpl = array(); + + // Construct and write out configuration file + if(is_array($a_bind)) { + foreach ($a_bind as $bind) { + if (count($bind['config']) > 1) + $frontendinfo = "frontend {$bind['name']}-merged\n"; + else + $frontendinfo = "frontend {$bind['name']}\n"; + + // Prepare ports for processing by splitting + $portss = "{$bind['port']},"; + $ports = split(",", $portss); + + // Initialize variable + $listenip = ""; + + // Process and add bind directives for ports + foreach($ports as $port) { + if($port) { + if($bind['extaddr'] == "any") + $listenip .= "\tbind\t\t\t0.0.0.0:{$port}\n"; + elseif($bind['extaddr']) + $listenip .= "\tbind\t\t\t{$bind['extaddr']}:{$port}\n"; + else + $listenip .= "\tbind\t\t\t" . get_current_wan_address('wan') . ":{$port}\n"; + } + } + + fwrite ($fd, "{$frontendinfo}"); + fwrite ($fd, "{$listenip}"); + + // Advanced pass thru + if($bind['advanced']) { + $advanced = base64_decode($bind['advanced']); + fwrite($fd, "\t" . $advanced . "\n"); + } + + // https is an alias for tcp for clarity purpouses + if(strtolower($bind['type']) == "https") { + $backend_type = "tcp"; + $httpchk = "ssl-hello-chk"; + } else { + $backend_type = $bind['type']; + $httpchk = "httpchk"; + } + + fwrite ($fd, "\tmode\t\t\t" . $backend_type . "\n"); + fwrite ($fd, "\tlog\t\t\tglobal\n"); + fwrite ($fd, "\toption\t\t\tdontlognull\n"); + + if($bind['httpclose']) + fwrite ($fd, "\toption\t\t\thttpclose\n"); + + if($bind['forwardfor']) + fwrite ($fd, "\toption\t\t\tforwardfor\n"); + + if($bind['max_connections']) + fwrite ($fd, "\tmaxconn\t\t\t" . $bind['max_connections'] . "\n"); + + if($bind['client_timeout']) + fwrite ($fd, "\tclitimeout\t\t" . $bind['client_timeout'] . "\n"); + + fwrite ($fd, "\tdefault_backend\t\t" . $bind['defaultpool'] . "\n"); + + // Combine the rest of the listener configs + $i = 0; + foreach ($bind['config'] as $bconfig) { + $a_acl=&$bconfig['ha_acls']['item']; + if(!is_array($a_acl)) + $a_acl=array(); + + $poolname = $bconfig['pool'] . "_" . strtolower($bconfig['type']); + if (!isset($a_pendingpl[$poolname])) { + $a_pendingpl[$poolname] = array(); + $a_pendingpl[$poolname]['name'] = $poolname; + $a_pendingpl[$poolname]['frontend'] = $bconfig; + } + + foreach ($a_acl as $entry) { + $acl = haproxy_find_acl($entry['expression']); + if (!$acl) + continue; + + // Filter out acls for different modes + if ($acl['mode'] != '' && $acl['mode'] != strtolower($bind['type'])) + continue; + + if ($acl['syntax'] != '') + $expr = $acl['syntax'] . " " . $entry['value']; + else + $expr = $entry['expression'] . " " . $entry['value']; + + $aclname = $i . "_" . $entry['name']; + fwrite ($fd, "\tacl\t\t\t" . $aclname . "\t" . $expr . "\n"); + fwrite ($fd, "\tuse_backend\t\t" . $poolname . " if " . $aclname . "\n"); + $i++; + } + + } + fwrite ($fd, "\n"); + } + } + if (is_array($a_pendingpl) && is_array($a_pools)) { + foreach ($a_pendingpl as $pending) { + foreach ($a_pools as $pool) { + if ($pending['frontend']['pool'] == $pool['name']) { + write_backend($fd, $pending['name'], $pool, $pending['frontend']); + } + } + } + } + fwrite ($fd, "\n"); + + // Sync HAProxy configuration (if enabled) + if(isset($config['installedpackages']['haproxy']['enablesync'])) { + if($config['installedpackages']['haproxy']['synchost1']) { + haproxy_do_xmlrpc_sync($config['installedpackages']['haproxy']['synchost1'], + $config['installedpackages']['haproxy']['syncpassword']); + } + if($config['installedpackages']['haproxy']['synchost2']) { + haproxy_do_xmlrpc_sync($config['installedpackages']['haproxy']['synchost2'], + $config['installedpackages']['haproxy']['syncpassword']); + } + if($config['installedpackages']['haproxy']['synchost3']) { + haproxy_do_xmlrpc_sync($config['installedpackages']['haproxy']['synchost3'], + $config['installedpackages']['haproxy']['syncpassword']); + } + } + + // create config file + fclose($fd); + + $freebsd_version = substr(trim(`uname -r`), 0, 1); + if(!file_exists("/usr/bin/limits")) { + exec("fetch -q -o /usr/bin/limits http://files.pfsense.org/extras/{$freebsd_version}/limits"); + exec("chmod a+rx /usr/bin/limits"); + } + + exec("/usr/bin/limits -n 300014"); + + // reload haproxy + if(isset($a_global['enable'])) { + if(is_process_running('haproxy')) { + exec("/usr/local/sbin/haproxy -f /var/etc/haproxy.cfg -p /var/run/haproxy.pid -st `cat /var/run/haproxy.pid`"); + } else { + exec("/usr/local/sbin/haproxy -f /var/etc/haproxy.cfg -p /var/run/haproxy.pid -D"); + } + return (0); + } else { + return (1); + } +} + +function haproxy_do_xmlrpc_sync($sync_to_ip, $password) { + global $config, $g; + + if(!$password) + return; + + if(!$sync_to_ip) + return; + + // Do not allow syncing to self. + $donotsync = false; + $lanip = find_interface_ip($config['interfaces']['lan']['if']); + if($lanip == $sync_to_ip) + $donotsync = true; + $wanip = find_interface_ip($config['interfaces']['wan']['if']); + if($wanip == $sync_to_ip) + $donotsync = true; + for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++) { + $optip = find_interface_ip($config['interfaces']['opt' . $j]['if']); + if($optip == $sync_to_ip) + $donotsync = true; + } + if($donotsync) { + log_error("Disallowing sync loop for HAProxy sync."); + return; + } + + $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['haproxy'] = $config['installedpackages']['haproxy']; + + // Prevent sync loops + unset($xml['synchost1']); + unset($xml['synchost2']); + unset($xml['synchost3']); + unset($xml['syncpassword']); + + /* 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("Beginning HAProxy 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('admin', $password); + if($g['debug']) + $cli->setDebug(1); + /* send our XMLRPC message and timeout after 250 seconds */ + $resp = $cli->send($msg, "250"); + if(!$resp) { + $error = "A communications error occurred while attempting HAProxy XMLRPC sync with {$url}:{$port}."; + log_error($error); + file_notice("sync_settings", $error, "HAProxy Settings Sync", ""); + } elseif($resp->faultCode()) { + $cli->setDebug(1); + $resp = $cli->send($msg, "250"); + $error = "An error code was received while attempting HAProxy XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString(); + log_error($error); + file_notice("sync_settings", $error, "HAProxy Settings Sync", ""); + } else { + log_error("HAProxy XMLRPC sync successfully completed with {$url}:{$port}."); + } + + /* tell haproxy to reload our settings on the destionation sync host. */ + $method = 'pfsense.exec_php'; + $execcmd = "require_once('/usr/local/pkg/haproxy.inc');\n"; + $execcmd .= "haproxy_configure();\n"; + + /* assemble xmlrpc payload */ + $params = array( + XML_RPC_encode($password), + XML_RPC_encode($execcmd) + ); + + log_error("HAProxy XMLRPC reload data {$url}:{$port}."); + $msg = new XML_RPC_Message($method, $params); + $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port); + $cli->setCredentials('admin', $password); + $resp = $cli->send($msg, "250"); + if(!$resp) { + $error = "A communications error occurred while attempting HAProxy XMLRPC sync with {$url}:{$port} (pfsense.exec_php)."; + log_error($error); + file_notice("sync_settings", $error, "HAProxy Settings Reload", ""); + } elseif($resp->faultCode()) { + $cli->setDebug(1); + $resp = $cli->send($msg, "250"); + $error = "An error code was received while attempting HAProxy XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString(); + log_error($error); + file_notice("sync_settings", $error, "HAProxy Settings Sync", ""); + } else { + log_error("HAProxy XMLRPC reload data success with {$url}:{$port} (pfsense.exec_php)."); + } +} + +?> diff --git a/config/haproxy-stable/haproxy.xml b/config/haproxy-stable/haproxy.xml new file mode 100644 index 00000000..3a0be0ec --- /dev/null +++ b/config/haproxy-stable/haproxy.xml @@ -0,0 +1,110 @@ + + + + + + + + Describe your package here + Describe your package requirements here + Currently there are no FAQ items provided. + haproxy + 1.0 + HAProxy + /pkg_ediwt.php?xml=haproxy_pools.php + /usr/local/pkg/haproxy.inc + + HAProxy + +
Services
+ /haproxy_listeners.php +
+ + HAProxy + haproxy.sh + haproxy + The Reliable, High Performance TCP/HTTP Load Balancer + + installedpackages->haproxy->config + + /usr/local/pkg/ + 077 + http://www.pfsense.com/packages/config/haproxy-stable/haproxy.inc + + + /usr/local/www/ + 077 + http://www.pfsense.com/packages/config/haproxy-stable/haproxy_listeners.php + + + /usr/local/www/ + 077 + http://www.pfsense.com/packages/config/haproxy-stable/haproxy_listeners_edit.php + + + /usr/local/www/ + 077 + http://www.pfsense.com/packages/config/haproxy-stable/haproxy_global.php + + + /usr/local/www/ + 077 + http://www.pfsense.com/packages/config/haproxy-stable/haproxy_pools.php + + + /usr/local/www/ + 077 + http://www.pfsense.com/packages/config/haproxy-stable/haproxy_pool_edit.php + + + + + + + + + $freebsdv=trim(`uname -r | cut -d'.' -f1`); + conf_mount_rw(); + `fetch -q -o /usr/local/sbin/ http://www.pfsense.org/packages/config/haproxy-dev/binaries{$freebsdv}/haproxy`; + exec("chmod a+rx /usr/local/sbin/haproxy"); + haproxy_custom_php_install_command(); + + + haproxy_custom_php_deinstall_command(); + + + +
diff --git a/config/haproxy-stable/haproxy_global.php b/config/haproxy-stable/haproxy_global.php new file mode 100755 index 00000000..f7864a4d --- /dev/null +++ b/config/haproxy-stable/haproxy_global.php @@ -0,0 +1,378 @@ + + Copyright (C) 2008 Remco Hoef + 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("globals.inc"); +require("guiconfig.inc"); +require_once("haproxy.inc"); + +$d_haproxyconfdirty_path = $g['varrun_path'] . "/haproxy.conf.dirty"; + +if (!is_array($config['installedpackages']['haproxy'])) + $config['installedpackages']['haproxy'] = array(); + + +if ($_POST) { + unset($input_errors); + $pconfig = $_POST; + + if ($_POST['apply']) { + $retval = 0; + config_lock(); + $retval = haproxy_configure(); + config_unlock(); + $savemsg = get_std_save_message($retval); + unlink_if_exists($d_haproxyconfdirty_path); + } else { + if ($_POST['enable']) { + $reqdfields = explode(" ", "maxconn"); + $reqdfieldsn = explode(",", "Maximum connections"); + } + + do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); + + if ($_POST['maxconn'] && (!is_numeric($_POST['maxconn']))) + $input_errors[] = "The maximum number of connections should be numeric."; + + if($_POST['synchost1'] && !is_ipaddr($_POST['synchost1'])) + $input_errors[] = "Synchost1 needs to be an IPAddress."; + if($_POST['synchost2'] && !is_ipaddr($_POST['synchost2'])) + $input_errors[] = "Synchost2 needs to be an IPAddress."; + if($_POST['synchost3'] && !is_ipaddr($_POST['synchost3'])) + $input_errors[] = "Synchost3 needs to be an IPAddress."; + + if (!$input_errors) { + $config['installedpackages']['haproxy']['enable'] = $_POST['enable'] ? true : false; + $config['installedpackages']['haproxy']['maxconn'] = $_POST['maxconn'] ? $_POST['maxconn'] : false; + $config['installedpackages']['haproxy']['enablesync'] = $_POST['enablesync'] ? true : false; + $config['installedpackages']['haproxy']['synchost1'] = $_POST['synchost1'] ? $_POST['synchost1'] : false; + $config['installedpackages']['haproxy']['synchost2'] = $_POST['synchost2'] ? $_POST['synchost2'] : false; + $config['installedpackages']['haproxy']['synchost2'] = $_POST['synchost3'] ? $_POST['synchost3'] : false; + $config['installedpackages']['haproxy']['remotesyslog'] = $_POST['remotesyslog'] ? $_POST['remotesyslog'] : false; + $config['installedpackages']['haproxy']['logfacility'] = $_POST['logfacility'] ? $_POST['logfacility'] : false; + $config['installedpackages']['haproxy']['loglevel'] = $_POST['loglevel'] ? $_POST['loglevel'] : false; + $config['installedpackages']['haproxy']['syncpassword'] = $_POST['syncpassword'] ? $_POST['syncpassword'] : false; + $config['installedpackages']['haproxy']['advanced'] = base64_encode($_POST['advanced']) ? $_POST['advanced'] : false; + $config['installedpackages']['haproxy']['nbproc'] = $_POST['nbproc'] ? $_POST['nbproc'] : false; + touch($d_haproxyconfdirty_path); + write_config(); + } + } + +} + +$pconfig['enable'] = isset($config['installedpackages']['haproxy']['enable']); +$pconfig['maxconn'] = $config['installedpackages']['haproxy']['maxconn']; +$pconfig['enablesync'] = isset($config['installedpackages']['haproxy']['enablesync']); +$pconfig['syncpassword'] = $config['installedpackages']['haproxy']['syncpassword']; +$pconfig['synchost1'] = $config['installedpackages']['haproxy']['synchost1']; +$pconfig['synchost2'] = $config['installedpackages']['haproxy']['synchost2']; +$pconfig['synchost3'] = $config['installedpackages']['haproxy']['synchost3']; +$pconfig['remotesyslog'] = $config['installedpackages']['haproxy']['remotesyslog']; +$pconfig['logfacility'] = $config['installedpackages']['haproxy']['logfacility']; +$pconfig['loglevel'] = $config['installedpackages']['haproxy']['loglevel']; +$pconfig['advanced'] = base64_decode($config['installedpackages']['haproxy']['advanced']); +$pconfig['nbproc'] = $config['installedpackages']['haproxy']['nbproc']; + +// defaults +if (!$pconfig['logfacility']) + $pconfig['logfacility'] = 'local0'; +if (!$pconfig['loglevel']) + $pconfig['loglevel'] = 'info'; + +$pfSversion = str_replace("\n", "", file_get_contents("/etc/version")); +if(strstr($pfSversion, "1.2")) + $one_two = true; + +$pgtitle = "Services: HAProxy: Settings"; +include("head.inc"); + +?> + + + + + + +

+ +
+ + +

+You must apply the changes in order for them to take effect.");?>
+ + + + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
General settings
  + onClick="enable_change(false)"> + Enable HAProxy
+ Maximum connections + +
+ + + + +
+ value=""> per Backend. +
+ Sets the maximum per-process number of concurrent connections to X.
+ NOTE: setting this value too high will result in HAProxy not being able to allocate enough memory.
+ Current memory usage {$hascpu}.

"; + ?> +
+ + + + + + + + + + + + + + + + + + + + + + + + +
ConnectionsMemory usage
+
+
9991888K
999998032K
99999950016K
9999999467M
+
+
+ Number of processes to start + + +
+ Defaults to number of cores/processors installed if left blank ( detected). +
+ Remote syslog host + + +
+ Syslog facility + + +
+ Syslog level + + +
+   +
Global Advanced pass thru
  + +
+ NOTE: paste text into this box that you would like to pass thru in the global settings area. +
+   +
Configuration synchronization
  + > + Sync HAProxy configuration to backup CARP members via XMLRPC. +
Synchronization password + +
+ Enter the password that will be used during configuration synchronization. This is generally the remote webConfigurator password. +
Sync host #1 + +
+ Synchronize settings to this hosts IP address. +
Sync host #2 + +
+ Synchronize settings to this hosts IP address. +
Sync host #3 + +
+ Synchronize settings to this hosts IP address. +
+   +
  + +
+
+
+ + +

+

+
+ Show automatically generated configuration. +
+ + +
+ + + + diff --git a/config/haproxy-stable/haproxy_listeners.php b/config/haproxy-stable/haproxy_listeners.php new file mode 100755 index 00000000..ef67108b --- /dev/null +++ b/config/haproxy-stable/haproxy_listeners.php @@ -0,0 +1,172 @@ + + Copyright (C) 2008 Remco Hoef + 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"); + +$d_haproxyconfdirty_path = $g['varrun_path'] . "/haproxy.conf.dirty"; + +require_once("haproxy.inc"); + +if (!is_array($config['installedpackages']['haproxy']['ha_backends']['item'])) { + $config['installedpackages']['haproxy']['ha_backends']['item'] = array(); +} +$a_backend = &$config['installedpackages']['haproxy']['ha_backends']['item']; + +if ($_POST) { + $pconfig = $_POST; + + if ($_POST['apply']) { + $retval = 0; + config_lock(); + $retval = haproxy_configure(); + config_unlock(); + $savemsg = get_std_save_message($retval); + unlink_if_exists($d_haproxyconfdirty_path); + } +} + +if ($_GET['act'] == "del") { + if (isset($a_backend[$_GET['id']])) { + if (!$input_errors) { + unset($a_backend[$_GET['id']]); + write_config(); + touch($d_haproxyconfdirty_path); + } + header("Location: haproxy_listeners.php"); + exit; + } +} + +$pfSversion = str_replace("\n", "", file_get_contents("/etc/version")); +if(strstr($pfSversion, "1.2")) + $one_two = true; + +$pgtitle = "Services: HAProxy: Listener"; +include("head.inc"); + +?> + + +
+ +

+ + + +

+You must apply the changes in order for them to take effect.");?>
+ + + + +
+ +
+
+ + + + + + + + + +"; + $textse = ""; + } +?> + + + + + + + + + + + + + +
NameDescriptionAddressTypeServer pool
+ + + + + + + + + + + + + + + + +
+
+ + + + +
+
+
+
+

+ + + diff --git a/config/haproxy-stable/haproxy_listeners_edit.php b/config/haproxy-stable/haproxy_listeners_edit.php new file mode 100755 index 00000000..21258c9d --- /dev/null +++ b/config/haproxy-stable/haproxy_listeners_edit.php @@ -0,0 +1,771 @@ + + Copyright (C) 2008 Remco Hoef + 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, 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("guiconfig.inc"); +require_once("haproxy.inc"); + +function haproxy_acl_select($mode) { + global $a_acltypes; + + $seltext = ''; + foreach ($a_acltypes as $expr) { + if ($expr['mode'] == '' || $expr['mode'] == $mode) + $seltext .= ""; + } + return $seltext; +} + +$d_haproxyconfdirty_path = $g['varrun_path'] . "/haproxy.conf.dirty"; + +if (!is_array($config['installedpackages']['haproxy']['ha_backends']['item'])) { + $config['installedpackages']['haproxy']['ha_backends']['item'] = array(); +} + +$a_backend = &$config['installedpackages']['haproxy']['ha_backends']['item']; +$a_pools = &$config['installedpackages']['haproxy']['ha_pools']['item']; + + +if (isset($_POST['id'])) + $id = $_POST['id']; +else + $id = $_GET['id']; + +if (isset($_GET['dup'])) + $id = $_GET['dup']; + +if (isset($id) && $a_backend[$id]) { + $pconfig['name'] = $a_backend[$id]['name']; + $pconfig['desc'] = $a_backend[$id]['desc']; + $pconfig['status'] = $a_backend[$id]['status']; + $pconfig['connection_timeout'] = $a_backend[$id]['connection_timeout']; + $pconfig['server_timeout'] = $a_backend[$id]['server_timeout']; + $pconfig['retries'] = $a_backend[$id]['retries']; + + $pconfig['type'] = $a_backend[$id]['type']; + $pconfig['balance'] = $a_backend[$id]['balance']; + + $pconfig['forwardfor'] = $a_backend[$id]['forwardfor']; + $pconfig['httpclose'] = $a_backend[$id]['httpclose']; + + $pconfig['stats_enabled'] = $a_backend[$id]['stats_enabled']; + $pconfig['stats_username'] = $a_backend[$id]['stats_username']; + $pconfig['stats_password'] = $a_backend[$id]['stats_password']; + $pconfig['stats_uri'] = $a_backend[$id]['stats_uri']; + $pconfig['stats_realm'] = $a_backend[$id]['stats_realm']; + + $pconfig['type'] = $a_backend[$id]['type']; + $pconfig['extaddr'] = $a_backend[$id]['extaddr']; + $pconfig['pool'] = $a_backend[$id]['pool']; + $pconfig['max_connections'] = $a_backend[$id]['max_connections']; + $pconfig['client_timeout'] = $a_backend[$id]['client_timeout']; + $pconfig['port'] = $a_backend[$id]['port']; + $pconfig['svrport'] = $a_backend[$id]['svrport']; + $pconfig['a_acl']=&$a_backend[$id]['ha_acls']['item']; + $pconfig['advanced'] = base64_decode($a_backend[$id]['advanced']); + +} + +if (isset($_GET['dup'])) + unset($id); + +$changedesc = "Services: HAProxy: Listener"; +$changecount = 0; + +if ($_POST) { + $changecount++; + + unset($input_errors); + $pconfig = $_POST; + + if ($_POST['stats_enabled']) { + $reqdfields = explode(" ", "name connection_timeout server_timeout stats_username stats_password stats_uri stats_realm"); + $reqdfieldsn = explode(",", "Name,Connection timeout,Server timeout,Stats Username,Stats Password,Stats Uri,Stats Realm"); + } else { + $reqdfields = explode(" ", "name connection_timeout server_timeout"); + $reqdfieldsn = explode(",", "Name,Connection timeout,Server timeout"); + } + + do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); + + $reqdfields = explode(" ", "name type port max_connections client_timeout"); + $reqdfieldsn = explode(",", "Name,Type,Port,Max connections,Client timeout"); + + do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); + + if (preg_match("/[^a-zA-Z0-9\.\-_]/", $_POST['name'])) + $input_errors[] = "The field 'Name' contains invalid characters."; + + if (!is_numeric($_POST['connection_timeout'])) + $input_errors[] = "The field 'Connection timeout' value is not a number."; + + if (!is_numeric($_POST['server_timeout'])) + $input_errors[] = "The field 'Server timeout' value is not a number."; + + if (!$_POST['retries'] && is_numeric($_POST['retries'])) + $input_errors[] = "The field 'Retries' value is not a number."; + + if (preg_match("/[^a-zA-Z0-9\.\-_]/", $_POST['stats_username'])) + $input_errors[] = "The field 'Stats Username' contains invalid characters."; + + if (preg_match("/[^a-zA-Z0-9\.\-_]/", $_POST['stats_password'])) + $input_errors[] = "The field 'Stats Password' contains invalid characters."; + + if (!is_numeric($_POST['max_connections'])) + $input_errors[] = "The field 'Max connections' value is not a number."; + + $ports = split(",", $_POST['port'] . ","); + foreach($ports as $port) + if ($port && !is_numeric($port)) + $input_errors[] = "The field 'Port' value is not a number."; + + if (!is_numeric($_POST['client_timeout'])) + $input_errors[] = "The field 'Client timeout' value is not a number."; + + /* Ensure that our pool names are unique */ + for ($i=0; isset($config['installedpackages']['haproxy']['ha_backends']['item'][$i]); $i++) + if (($_POST['name'] == $config['installedpackages']['haproxy']['ha_backends']['item'][$i]['name']) && ($i != $id)) + $input_errors[] = "This listener name has already been used. Listener names must be unique."; + + $a_acl=array(); + $acl_names=array(); + for($x=0; $x<99; $x++) { + $acl_name=$_POST['acl_name'.$x]; + $acl_expression=$_POST['acl_expression'.$x]; + $acl_value=$_POST['acl_value'.$x]; + + if ($acl_name) { + // check for duplicates + if (in_array($acl_name, $acl_names)) { + $input_errors[] = "The name '$acl_name' is duplicate."; + } + + $acl_names[]=$acl_name; + + $acl=array(); + $acl['name']=$acl_name; + $acl['expression']=$acl_expression; + $acl['value']=$acl_value; + $a_acl[]=$acl; + + if (preg_match("/[^a-zA-Z0-9\.\-_]/", $acl_name)) + $input_errors[] = "The field 'Name' contains invalid characters."; + + if (!preg_match("/.{2,}/", $acl_value)) + $input_errors[] = "The field 'Value' is required."; + + if (!preg_match("/.{2,}/", $acl_name)) + $input_errors[] = "The field 'Name' is required."; + + } + } + + $pconfig['a_acl']=$a_acl; + + if (!$input_errors) { + $backend = array(); + if(isset($id) && $a_backend[$id]) + $backend = $a_backend[$id]; + + if($backend['name'] != "") + $changedesc .= " modified '{$backend['name']}' pool:"; + + + update_if_changed("name", $backend['name'], $_POST['name']); + update_if_changed("description", $backend['desc'], $_POST['desc']); + update_if_changed("status", $backend['status'], $_POST['status']); + update_if_changed("connection_timeout", $backend['connection_timeout'], $_POST['connection_timeout']); + update_if_changed("server_timeout", $backend['server_timeout'], $_POST['server_timeout']); + update_if_changed("retries", $backend['retries'], $_POST['retries']); + update_if_changed("type", $backend['type'], $_POST['type']); + update_if_changed("balance", $backend['balance'], $_POST['balance']); + update_if_changed("cookie_name", $backend['cookie_name'], $_POST['cookie_name']); + update_if_changed("forwardfor", $backend['forwardfor'], $_POST['forwardfor']); + update_if_changed("httpclose", $backend['httpclose'], $_POST['httpclose']); + update_if_changed("stats_enabled", $backend['stats_enabled'], $_POST['stats_enabled']); + update_if_changed("stats_username", $backend['stats_username'], $_POST['stats_username']); + update_if_changed("stats_password", $backend['stats_password'], $_POST['stats_password']); + update_if_changed("stats_uri", $backend['stats_uri'], $_POST['stats_uri']); + update_if_changed("stats_realm", $backend['stats_realm'], $_POST['stats_realm']); + update_if_changed("type", $backend['type'], $_POST['type']); + update_if_changed("port", $backend['port'], $_POST['port']); + update_if_changed("svrport", $backend['svrport'], $_POST['svrport']); + update_if_changed("extaddr", $backend['extaddr'], $_POST['extaddr']); + update_if_changed("pool", $backend['pool'], $_POST['pool']); + update_if_changed("max_connections", $backend['max_connections'], $_POST['max_connections']); + update_if_changed("client_timeout", $backend['client_timeout'], $_POST['client_timeout']); + update_if_changed("advanced", $backend['advanced'], base64_encode($_POST['advanced'])); + + $backend['ha_acls']['item'] = $a_acl; + + if (isset($id) && $a_backend[$id]) { + $a_backend[$id] = $backend; + } else { + $a_backend[] = $backend; + } + + if ($changecount > 0) { + touch($d_haproxyconfdirty_path); + write_config($changedesc); + } + + header("Location: haproxy_listeners.php"); + exit; + } +} + +$pfSversion = str_replace("\n", "", file_get_contents("/etc/version")); +if(strstr($pfSversion, "1.2")) + $one_two = true; + +$pgtitle = "HAProxy: Listener: Edit"; +include("head.inc"); + +?> + + + + + + + + + + +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Edit haproxy listener
Name + size="25" maxlength="25"> +
Description + size="64"> +
Status + +
External address + +
+ + If you want this rule to apply to another IP address than the IP address of the interface chosen above, + select it here (you need to define Virtual IP addresses on the first). + Also note that if you are trying to redirect connections on the LAN select the "any" option. + +
External port + size="10" maxlength="10"> +
The port to listen to. To specify multiple ports, separate with a comma (,). EXAMPLE: 80,443
+
Server pool + +
Server Port + size="10" maxlength="10"> +
The default server port.
+
Type + +
Access Control lists + + + + + + + + + > + + + + + + +
NameExpressionValue
+ + + + +
+ + + +
+
+ + +
+ For more information about ACL's please see HAProxy Documentation Section 7 - Using ACL's +
+ + + + + + + + + + + + + + + + + + + + + + + + + > + + + + > + + + + > + + + + + > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
+ + +
Advanced settings
Connection timeout + size="64"> +
the time (in milliseconds) we give up if the connection does not complete within (30000).
+
Server timeout + size="64"> +
the time (in milliseconds) we accept to wait for data from the server, or for the server to accept data (30000).
+
Retries + size="64"> +
After a connection failure to a server, it is possible to retry, potentially +on another server. This is useful if health-checks are too rare and you don't +want the clients to see the failures. The number of attempts to reconnect is +set by the 'retries' parameter (2).
+
Balance + + + + + + + +
+ >Round robin + + Each server is used in turns, according to their weights. + This is the smoothest and fairest algorithm when the server's + processing time remains equally distributed. This algorithm + is dynamic, which means that server weights may be adjusted + on the fly for slow starts for instance. +
>Source + The source IP address is hashed and divided by the total + weight of the running servers to designate which server will + receive the request. This ensures that the same client IP + address will always reach the same server as long as no + server goes down or up. If the hash result changes due to the + number of running servers changing, many clients will be + directed to a different server. This algorithm is generally + used in TCP mode where no cookie may be inserted. It may also + be used on the Internet to provide a best-effort stickyness + to clients which refuse session cookies. This algorithm is + static, which means that changing a server's weight on the + fly will have no effect. +
+
Stats Enabled + onclick='toggle_stats();'>
+ EXAMPLE: haproxystats +
Stats Realm + size="64"> +
Stats Uri + size="64">
+ EXAMPLE: /haproxy?stats +
Stats Username + size="64"> +
Stats Password + size="64"> +
+
Max connections + size="10" maxlength="10"> +
Client timeout + size="10" maxlength="10"> +
the time (in milliseconds) we accept to wait for data from the client, or for the client to accept data (30000).
+
Use 'forwardfor' option + > +
+ The 'forwardfor' option creates an HTTP 'X-Forwarded-For' header which + contains the client's IP address. This is useful to let the final web server + know what the client address was (eg for statistics on domains) +
Use 'httpclose' option + > +
+ The 'httpclose' option removes any 'Connection' header both ways, and + adds a 'Connection: close' header in each direction. This makes it easier to + disable HTTP keep-alive than the previous 4-rules block. +
Advanced pass thru + +
+ NOTE: paste text into this box that you would like to pass thru. +
  + + + + + +
+ NOTE: You must add a firewall rule permitting access to this frontend! +
+
+
+ + + + diff --git a/config/haproxy-stable/haproxy_pool_edit.php b/config/haproxy-stable/haproxy_pool_edit.php new file mode 100755 index 00000000..6087e9d7 --- /dev/null +++ b/config/haproxy-stable/haproxy_pool_edit.php @@ -0,0 +1,505 @@ + + Copyright (C) 2008 Remco Hoef + 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, 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("guiconfig.inc"); + +$d_haproxyconfdirty_path = $g['varrun_path'] . "/haproxy.conf.dirty"; + +if (!is_array($config['installedpackages']['haproxy']['ha_pools']['item'])) { + $config['installedpackages']['haproxy']['ha_pools']['item'] = array(); +} + +$a_pools = &$config['installedpackages']['haproxy']['ha_pools']['item']; + +if (isset($_POST['id'])) + $id = $_POST['id']; +else + $id = $_GET['id']; + +if (isset($_GET['dup'])) + $id = $_GET['dup']; + +if (isset($id) && $a_pools[$id]) { + $pconfig['name'] = $a_pools[$id]['name']; + $pconfig['checkinter'] = $a_pools[$id]['checkinter']; + $pconfig['monitor_uri'] = $a_pools[$id]['monitor_uri']; + $pconfig['cookie'] = $a_pools[$id]['cookie']; + $pconfig['status'] = $a_pools[$id]['status']; + $pconfig['advanced'] = base64_decode($a_pools[$id]['advanced']); + $pconfig['a_servers']=&$a_pools[$id]['ha_servers']['item']; +} + +if (isset($_GET['dup'])) + unset($id); + +$changedesc = "Services: HAProxy: pools: "; +$changecount = 0; + +if ($_POST) { + $changecount++; + + unset($input_errors); + $pconfig = $_POST; + + $reqdfields = explode(" ", "name"); + $reqdfieldsn = explode(",", "Name"); + + do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); + + if (preg_match("/[^a-zA-Z0-9\.\-_]/", $_POST['name'])) + $input_errors[] = "The field 'Name' contains invalid characters."; + + /* Ensure that our pool names are unique */ + for ($i=0; isset($config['installedpackages']['haproxy']['ha_pools']['item'][$i]); $i++) + if (($_POST['name'] == $config['installedpackages']['haproxy']['ha_pools']['item'][$i]['name']) && ($i != $id)) + $input_errors[] = "This pool name has already been used. Pool names must be unique."; + + $a_servers=array(); + for($x=0; $x<99; $x++) { + $server_name=$_POST['server_name'.$x]; + $server_address=$_POST['server_address'.$x]; + $server_port=$_POST['server_port'.$x]; + $server_weight=$_POST['server_weight'.$x]; + $server_backup=$_POST['server_backup'.$x]; + + if ($server_address) { + + $server=array(); + $server['name']=$server_name; + $server['address']=$server_address; + $server['port']=$server_port; + $server['weight']=$server_weight; + $server['backup']=$server_backup; + $a_servers[]=$server; + + if (preg_match("/[^a-zA-Z0-9\.\-_]/", $server_name)) + $input_errors[] = "The field 'Name' contains invalid characters."; + if (preg_match("/[^a-zA-Z0-9\.\-_]/", $server_address)) + $input_errors[] = "The field 'Address' contains invalid characters."; + + if (!preg_match("/.{2,}/", $server_name)) + $input_errors[] = "The field 'Name' is required."; + + if (!preg_match("/.{2,}/", $server_address)) + $input_errors[] = "The field 'Address' is required."; + + if (!preg_match("/.{2,}/", $server_weight)) + $input_errors[] = "The field 'Weight' is required."; + + if (!is_numeric($server_weight)) + $input_errors[] = "The field 'Weight' value is not a number."; + if ($server_port && !is_numeric($server_port)) + $input_errors[] = "The field 'Port' value is not a number."; + } + } + + if (!$input_errors) { + $pool = array(); + if(isset($id) && $a_pools[$id]) + $pool = $a_pools[$id]; + + if ($pool['name'] != $_POST['name']) { + // name changed: + if (!is_array($config['installedpackages']['haproxy']['ha_backends']['item'])) { + $config['installedpackages']['haproxy']['ha_backends']['item'] = array(); + } + $a_backend = &$config['installedpackages']['haproxy']['ha_backends']['item']; + + for ( $i = 0; $i < count($a_backend); $i++) { + if ($a_backend[$i]['pool'] == $pool['name']) + $a_backend[$i]['pool'] = $_POST['name']; + } + } + + if($pool['name'] != "") + $changedesc .= " modified '{$pool['name']}' pool:"; + + $pool['ha_servers']['item']=$a_servers; + + update_if_changed("name", $pool['name'], $_POST['name']); + update_if_changed("status", $pool['status'], $_POST['status']); + update_if_changed("cookie", $pool['cookie'], $_POST['cookie']); + update_if_changed("advanced", $pool['advanced'], base64_encode($_POST['advanced'])); + update_if_changed("checkinter", $pool['checkinter'], $_POST['checkinter']); + update_if_changed("monitor_uri", $pool['monitor_uri'], $_POST['monitor_uri']); + + if (isset($id) && $a_pools[$id]) { + $a_pools[$id] = $pool; + } else { + $a_pools[] = $pool; + } + + if ($changecount > 0) { + touch($d_haproxyconfdirty_path); + write_config($changedesc); + /* + echo "
";
+			print_r($config);
+			echo "
"; + */ + } + + header("Location: haproxy_pools.php"); + exit; + } + $pconfig['a_servers']=&$a_pools[$id]['ha_servers']['item']; +} + +$pfSversion = str_replace("\n", "", file_get_contents("/etc/version")); +if(strstr($pfSversion, "1.2")) + $one_two = true; + +$pgtitle = "HAProxy: pool: Edit"; +include("head.inc"); + +row_helper(); + +?> + + + + + + + + + + + +

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Edit HAProxy pool
Name + size="16" maxlength="16"> +
Status + +
Cookie + size="64">
+ This value will be checked in incoming requests, and the first + operational pool possessing the same value will be selected. In return, in + cookie insertion or rewrite modes, this value will be assigned to the cookie + sent to the client. There is nothing wrong in having several servers sharing + the same cookie value, and it is in fact somewhat common between normal and + backup servers. See also the "cookie" keyword in backend section. + +
Server list
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameAddressPortWeightBackup
+ + +
+ + + +
+
+ + + +
Check freq + size="20"> milliseconds +
Defaults to 1000 if left blank. +
Health check URI + size="64"> +
Defaults to / if left blank. +
Advanced pass thru + +
+ NOTE: paste text into this box that you would like to pass thru. +
  + + + + + +
+
+
+ + + + + + +// Global Variables +var rowname = new Array(99); +var rowtype = new Array(99); +var newrow = new Array(99); +var rowsize = new Array(99); + +for (i = 0; i < 99; i++) { + rowname[i] = ''; + rowtype[i] = ''; + newrow[i] = ''; + rowsize[i] = '25'; +} + +var field_counter_js = 0; +var loaded = 0; +var is_streaming_progress_bar = 0; +var temp_streaming_text = ""; + +var addRowTo = (function() { + return (function (tableId) { + var d, tbody, tr, td, bgc, i, ii, j; + var btable, btbody, btr, btd; + + d = document; + tbody = d.getElementById(tableId).getElementsByTagName("tbody").item(0); + tr = d.createElement("tr"); + totalrows++; + for (i = 0; i < field_counter_js; i++) { + td = d.createElement("td"); + if(rowtype[i] == 'textbox') { + td.innerHTML=" "; + } else if(rowtype[i] == 'select') { + td.innerHTML=" "; + } else { + td.innerHTML=" "; + } + td.setAttribute("class","vtable"); + tr.appendChild(td); + } + td = d.createElement("td"); + td.rowSpan = "1"; + td.setAttribute("class","list"); + + // Recreate the button table. + btable = document.createElement("table"); + btable.setAttribute("border", "0"); + btable.setAttribute("cellspacing", "0"); + btable.setAttribute("cellpadding", "1"); + btbody = document.createElement("tbody"); + btr = document.createElement("tr"); + btd = document.createElement("td"); + btd.setAttribute("valign", "middle"); + btd.innerHTML = ''; + btr.appendChild(btd); + btd = document.createElement("td"); + btd.setAttribute("valign", "middle"); + btd.innerHTML = '"; + btr.appendChild(btd); + btbody.appendChild(btr); + btable.appendChild(btbody); + + td.appendChild(btable); + tr.appendChild(td); + tbody.appendChild(tr); + }); +})(); + +function dupRow(rowId, tableId) { + var dupEl; + var newEl; + + addRowTo(tableId); + for (i = 0; i < field_counter_js; i++) { + dupEl = document.getElementById(rowname[i] + rowId); + newEl = document.getElementById(rowname[i] + totalrows); + if (dupEl && newEl) + if(rowtype[i] == 'checkbox') + newEl.checked = dupEl.checked; + else + newEl.value = dupEl.value; + } +} + +function removeRow(el) { + var cel; + // Break out of one table first + while (el && el.nodeName.toLowerCase() != "table") + el = el.parentNode; + while (el && el.nodeName.toLowerCase() != "tr") + el = el.parentNode; + + if (el && el.parentNode) { + cel = el.getElementsByTagName("td").item(0); + el.parentNode.removeChild(el); + } +} +function editRow(num) { + var trview = document.getElementById('tr_view_' + num); + var tredit = document.getElementById('tr_edit_' + num); + + trview.style.display='none'; + tredit.style.display=''; +} + +function find_unique_field_name(field_name) { + // loop through field_name and strip off -NUMBER + var last_found_dash = 0; + for (var i = 0; i < field_name.length; i++) { + // is this a dash, if so, update + // last_found_dash + if (field_name.substr(i,1) == "-" ) + last_found_dash = i; + } + if (last_found_dash < 1) + return field_name; + return(field_name.substr(0,last_found_dash)); +} + + +EOF; + +} + +?> diff --git a/config/haproxy-stable/haproxy_pools.php b/config/haproxy-stable/haproxy_pools.php new file mode 100755 index 00000000..78a1fdff --- /dev/null +++ b/config/haproxy-stable/haproxy_pools.php @@ -0,0 +1,166 @@ + + Copyright (C) 2008 Remco Hoef + 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("haproxy.inc"); + +$d_haproxyconfdirty_path = $g['varrun_path'] . "/haproxy.conf.dirty"; + +if (!is_array($config['installedpackages']['haproxy']['ha_pools']['item'])) { + $config['installedpackages']['haproxy']['ha_pools']['item'] = array(); +} +if (!is_array($config['installedpackages']['haproxy']['ha_backends']['item'])) { + $config['installedpackages']['haproxy']['ha_backends']['item'] = array(); +} + +$a_pools = &$config['installedpackages']['haproxy']['ha_pools']['item']; +$a_backends = &$config['installedpackages']['haproxy']['ha_backends']['item']; + +if ($_POST) { + $pconfig = $_POST; + + if ($_POST['apply']) { + $retval = 0; + config_lock(); + $retval = haproxy_configure(); + config_unlock(); + $savemsg = get_std_save_message($retval); + unlink_if_exists($d_haproxyconfdirty_path); + } +} + +if ($_GET['act'] == "del") { + if (isset($a_pools[$_GET['id']])) { + unset($a_pools[$_GET['id']]); + write_config(); + touch($d_haproxyconfdirty_path); + } + header("Location: haproxy_pools.php"); + exit; +} + +$pfSversion = str_replace("\n", "", file_get_contents("/etc/version")); +if(strstr($pfSversion, "1.2")) + $one_two = true; + +$pgtitle = "Services: HAProxy: Server pools"; +include("head.inc"); + +?> + + + +

+ +
+ + +

+You must apply the changes in order for them to take effect.");?>
+ + + + +
+ +
+
+ + + + + + + +"; + $textse = ""; + } +?> + + + + + + + + + + + +
NameStatusListener
+ + + + + + + + + + + + +
+
+ + + + +
+
+
+
+

+ + + -- cgit v1.2.3 From 1d1bcc341636aa93f353908f5ac6433611fe2b65 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Mon, 15 Mar 2010 19:20:46 -0400 Subject: Reload zone correctly on the primary dns server without needing to do an operation twice --- config/tinydns/tinydns.inc | 1 - config/tinydns/tinydns_domains.xml | 19 +++---------------- 2 files changed, 3 insertions(+), 17 deletions(-) (limited to 'config') diff --git a/config/tinydns/tinydns.inc b/config/tinydns/tinydns.inc index 9d0cf2d3..e8500bca 100644 --- a/config/tinydns/tinydns.inc +++ b/config/tinydns/tinydns.inc @@ -359,7 +359,6 @@ function tinydns_create_zone_file() { conf_mount_rw(); if(file_exists("/tmp/config.cache")) unlink("/tmp/config.cache"); - parse_config(true); config_lock(); if(file_exists("/service/tinydns/root/data")) exec("rm -f /service/tinydns/root/data"); diff --git a/config/tinydns/tinydns_domains.xml b/config/tinydns/tinydns_domains.xml index 33647bac..247227d8 100644 --- a/config/tinydns/tinydns_domains.xml +++ b/config/tinydns/tinydns_domains.xml @@ -232,28 +232,15 @@ } - $dnssync = true; - log_error("Begin tinydns add"); + + + log_error("Begin tinydns resync"); tinydns_create_zone_file(); log_error("Zone file done."); tinydns_setup_ping_items(); log_error("Ping items done."); tinydns_sync_on_changes(); log_error("Sync items done."); - - - if(!$dnssync) { - log_error("Begin tinydns resync"); - tinydns_create_zone_file(); - log_error("Zone file done."); - tinydns_setup_ping_items(); - log_error("Ping items done."); - tinydns_sync_on_changes(); - log_error("Sync items done."); - } else { - tinydns_create_zone_file(); - tinydns_setup_ping_items(); - } unset($_POST['temp']); -- cgit v1.2.3 From ba505e58d599c400029815ea765ad0876bb5f5d7 Mon Sep 17 00:00:00 2001 From: robiscool Date: Tue, 16 Mar 2010 19:49:43 -0700 Subject: snort-dev, rewrote the major parts to be file independent, added uuid code, added, added new startup code --- config/snort-dev/NOTES.txt | 58 +---- config/snort-dev/snort.inc | 391 +++++++++++++++++------------ config/snort-dev/snort_barnyard.php | 2 + config/snort-dev/snort_define_servers.php | 2 + config/snort-dev/snort_gui.inc | 59 ++--- config/snort-dev/snort_interfaces.php | 140 +++++------ config/snort-dev/snort_interfaces_edit.php | 160 +++++++----- config/snort-dev/snort_preprocessors.php | 2 + 8 files changed, 422 insertions(+), 392 deletions(-) (limited to 'config') diff --git a/config/snort-dev/NOTES.txt b/config/snort-dev/NOTES.txt index b6c49926..88c80cb2 100644 --- a/config/snort-dev/NOTES.txt +++ b/config/snort-dev/NOTES.txt @@ -1,59 +1,19 @@ -November 18 2009 +March 16 2019 +Snort-dev 2.8.5.3 pk v. 12 Beta -Snort_inline due date is by Dec 1st. (Why ? Scott said so.) +Snort is Stoping/Starting with new UUID. Files are independent of rule order now. Ya me....... -Gui is almost done. just odds and ends left. +TODO: +The snort.sh code needs to be looked at and made sure there is a new file at every enabe/disbale save, +reboot, rule delete. -If you work on this package just comment on every-thing you change or add. +The snort_interfaces.php needs speed inprovments. !inportant. -==================== -Goals -==================== +Make sure I ad a reset button someware the removes all of snort-devs addd to config.xml -Release the New snort GUI as a package for 1.2.3 so that we can work out bugs. +Pierre POMES code needs to be added. -Move the Snort GUI to base of Pfsense. The divert options should be added to firewall_nat.php or firewall_rules.php. -Ask Ermal to add divert out to Pfsense again though, he has kept divert in. - -================================= -Any Devs that would like to help please work on snort_rules_edit.php and snort_rules.php. They work but need cleaning up. -================================= - -To get snort_rules_edit.php and snort_rules.php working - - * Update the rules. - * Add at least on rule to snort_interfaces.php. - -snort_rules_edit.php -Make sure all snort sig options that are in the GUI are written to file. - -snort_rules.php -Change the way the rules get disabled, by removing the x icon image and replacing it with check boxes. -This should improve the users experience. Moreover, check boxes could be added to blocked.php tab to improve performance. -Users always complain that the way were deleting options is slow. - -=========================================== -Misc. -=========================================== - -All further development will be in Freebsd 8. - -ALL further snort and barnyard builds will be mmx sse. - -All further snort builds will have snort_inline code. - -All further builds will have "did I start on a pfsense system" code, if not, exit. - -Adding extra options to the new snort gui for snort_inline should be easy. - -Snort_inline binaries with custom c++ code ready to go. - -Snort_inline works with only one Wan and Lan. Add a Opt onterface and the TCP flow goes into a loop. -This should be easy to fix by the firewall guru by modifying the divert rule I am using. - - - Done. \ No newline at end of file diff --git a/config/snort-dev/snort.inc b/config/snort-dev/snort.inc index 513fc626..b773b231 100644 --- a/config/snort-dev/snort.inc +++ b/config/snort-dev/snort.inc @@ -44,14 +44,40 @@ if ($pfsense_ver_chk == '1.2.3-RELEASE') $pfsense_stable = 'no'; } -/* Get id and realinterfaces */ +/* check if uniq snort proc is running */ +function uniq_snort_proc($id, $if_real) +{ + global $config, $g, $id, $if_real; + +$snort_uuid = $config['installedpackages']['snortglobal']['rule'][$id]['uuid']; +$snort_up_ck = exec("/bin/ps -auwx | /usr/bin/grep -v grep | /usr/bin/grep snort | /usr/bin/awk '{print \$2;}' | sed 1q"); + + if ($snort_up_ck == '') + { + $snort_up == 'false'; + } + + if ($snort_up_ck == '') + { + $snort_up = 'false'; + } + + if ($snort_up_ck != '') + { + $snort_up_pre = exec("/usr/bin/top -a -U snort -u | grep -v grep | grep \"R {$snort_uuid}_{$if_real}\" | awk '{print \$1;}'"); -$id = $_GET['id']; -if (isset($_POST['id'])) - $id = $_POST['id']; + $snort_up_s = exec("/usr/bin/top -U snort -u | grep snort | grep {$snort_up_pre} | /usr/bin/awk '{print \$1;}'"); + $snort_up_r = exec("/usr/bin/top -U root -u | grep snort | grep {$snort_up_pre} | /usr/bin/awk '{print \$1;}'"); -$interface_fake = $config['installedpackages']['snortglobal']['rule'][$id]['interface']; -$if_real = convert_friendly_interface_to_real_interface_name($interface_fake); + if ($snort_up_s != '' || $snort_up_r != '') + { + $snort_up = 'true'; + }else{ + $snort_up = 'false'; + } + return $snort_up; + } +} /* get the real iface name of wan */ function convert_friendly_interface_to_real_interface_name2($interface) @@ -420,6 +446,55 @@ function snort_rules_up_install_cron($should_install) { } } +function sync_snort_package_remove_old() +{ + + global $config, $g; + +$snort_dir_scan = '/usr/local/etc/snort'; + +// scan dirm might have to make this into a funtion +$dh_scan = opendir($snort_dir_scan); +while (false !== ($dir_filename = readdir($dh_scan))) { + $list_dir_files[] = $dir_filename; +} + +// find patern in a array, very cool code +class array_ereg { + function array_ereg($pattern) { $this->pattern = $pattern; } + function ereg($string) { + return ereg($this->pattern, $string); + } +} + + $rule_array2 = $config['installedpackages']['snortglobal']['rule']; + $id2 = -1; + foreach ($rule_array2 as $value) + { + + $id += 1; + + $result_lan = $config['installedpackages']['snortglobal']['rule'][$id]['interface']; + $if_real = convert_friendly_interface_to_real_interface_name($result_lan); + + $snort_rules_list[] = "snort_$id$if_real"; + + } + + +$snort_dir_filter = array_filter($list_dir_files, array(new array_ereg("snort_"), 'ereg')); +$snort_dir_filter_search_result = array_diff($snort_dir_filter, $snort_rules_list); + + foreach ($snort_dir_filter_search_result as $value) + { + exec("rm -r /usr/local/etc/snort/$value"); + exec("echo \"rm -r /usr/local/etc/snort/$value\" >> /root/test.log"); + } + + exec("echo \"Function remove ....\" >> /root/test.log"); + +} + /* make sure this func on writes to files and does not start snort */ function sync_snort_package() { @@ -439,7 +514,9 @@ function sync_snort_package() exec("/usr/sbin/chown -R snort:snort /usr/local/lib/snort"); exec("/bin/chmod -R 755 /var/log/snort"); exec("/bin/chmod -R 755 /usr/local/etc/snort"); - exec("/bin/chmod -R 755 /usr/local/lib/snort"); + exec("/bin/chmod -R 755 /usr/local/lib/snort"); + + exec("echo \"Funtion sync package....\" >> /root/test.log"); conf_mount_ro(); } @@ -447,10 +524,7 @@ function sync_snort_package() /* make sure this func on writes to files and does not start snort */ function sync_snort_package_all() { - global $config, $g, $id, $if_real, $interface_fake; - conf_mount_rw(); - - + global $config, $g, $id, $if_real, $snort_uuid, $interface_fake; /* RedDevil suggested code */ /* TODO: more testing needs to be done */ @@ -459,112 +533,37 @@ exec("/sbin/sysctl net.bpf.maxbufsize=4194304"); exec("/sbin/sysctl net.bpf.maxinsns=512"); exec("/sbin/sysctl net.inet.tcp.rfc1323=1"); -if ($id != '' && $if_real != '') +# Error checking +if ($id != '' && $if_real != '') //new { - /* do not start config build if rules is empty */ if (!empty($config['installedpackages']['snortglobal']['rule'])) { - if ($id == "") - { - $rule_array = $config['installedpackages']['snortglobal']['rule']; - $id = -1; - foreach ($rule_array as $value) - { - - $id += 1; + conf_mount_rw(); + $snort_uuid = $config['installedpackages']['snortglobal']['rule'][$id]['uuid']; $result_lan = $config['installedpackages']['snortglobal']['rule'][$id]['interface']; $if_real = convert_friendly_interface_to_real_interface_name($result_lan); /* create snort configuration file */ - create_snort_conf(); - - /* create snort bootup file snort.sh */ - create_snort_sh(); + create_snort_conf($id, $if_real, $snort_uuid); /* if rules exist cp rules to each iface */ - create_rules_iface(); + create_rules_iface($id, $if_real, $snort_uuid); /* create barnyard2 configuration file */ $snortbarnyardlog_info_chk = $config['installedpackages']['snortglobal']['rule'][$id]['barnyard_enable']; if ($snortbarnyardlog_info_chk == 'on') - create_barnyard2_conf(); - - } - - }else{ + create_barnyard2_conf($id, $if_real, $snort_uuid); - /* create snort configuration file */ - create_snort_conf(); - - /* create snort bootup file snort.sh */ - create_snort_sh(); - - /* if rules exist cp rules to each iface */ - create_rules_iface(); - - /* create barnyard2 configuration file */ - $snortbarnyardlog_info_chk = $config['installedpackages']['snortglobal']['rule'][$id]['barnyard_enable']; - if ($snortbarnyardlog_info_chk == on) - { - create_barnyard2_conf(); - } + exec("echo \"Funtion sync all $id $if_real $snort_uuid....\" >> /root/test.log"); + conf_mount_ro(); } } - - /* all new files are for the user snort nologin */ - if(!file_exists("/var/log/snort")) - { - exec("/bin/mkdir -p /var/log/snort"); - } - - exec("/usr/sbin/chown -R snort:snort /var/log/snort"); - exec("/usr/sbin/chown -R snort:snort /usr/local/etc/snort"); - exec("/usr/sbin/chown -R snort:snort /usr/local/lib/snort"); - exec("/bin/chmod -R 755 /var/log/snort"); - exec("/bin/chmod -R 755 /usr/local/etc/snort"); - exec("/bin/chmod -R 755 /usr/local/lib/snort"); - - /* Generate the snort instance list */ - $rc_snort = ""; - $i = 0; - $rules = &$config['installedpackages']['snortglobal']['rule']; - foreach($rules as $snort) { - $name = "${i}${if_real}"; - $if_real = convert_friendly_interface_to_real_interface_name($snort['interface']); - $rc_snort .= "snort_list=\"\${snort_list} ${name}\"\n"; - $rc_snort .= "snort_${name}_conf=\"/usr/local/etc/snort/snort_${name}/snort.conf\"\n"; - $rc_snort .= "snort_${name}_name=\"${name}\"\n"; - $rc_snort .= "snort_${name}_id=\"${i}\"\n"; - $rc_snort .= "snort_${name}_interface=\"${if_real}\"\n"; - - $snortenable_info_chk = $config['installedpackages']['snortglobal']['rule'][$id]['enable']; - if ($snortenable_info_chk == 'on') - $rc_snort .= "snort_${name}_enable=\"YES\"\n"; - else - $rc_snort .= "snort_${name}_enable=\"NO\"\n"; - - $snortbarnyardlog_info_chk = $config['installedpackages']['snortglobal']['rule'][$id]['barnyard_enable']; - if ($snortbarnyardlog_info_chk == 'on') - $rc_snort .= "snort_${name}_barnyard=\"YES\"\n"; - $i++; - } - $rcconf = fopen("/var/etc/rc.snort", "w"); - if(!$rcconf) { - log_error("Could not open /var/etc/rc.snort for writing."); - exit; - } - fwrite($rcconf, $rc_snort); - fclose($rcconf); - - - conf_mount_ro(); - -} } + /* Start of main config files */ /* Start of main config files */ @@ -576,15 +575,17 @@ function create_snort_sh() { # Don not add $id or this will break - global $config, $g, $if_real, $if_real_wan; + global $config, $g; conf_mount_rw(); +exec("echo \"Craete snort.sh $snort_uuid $if_real $id....\" >> /root/test.log"); + $snortbarnyardlog_info_chk = $config['installedpackages']['snortglobal']['rule'][$id]['barnyard_enable']; /* define snortbarnyardlog_chk */ if ($snortbarnyardlog_info_chk == on) { - $start_barnyard2 = "sleep 4/n/usr/local/bin/barnyard2 -u snort -g snort -c /usr/local/etc/snort/snort_$id$if_real/barnyard2.conf -d /var/log/snort -f snort.u2_$id$if_real -w /usr/local/etc/snort/snort_$id$if_real/barnyard2.waldo -D -q"; + $start_barnyard2 = "sleep 4/n/usr/local/bin/barnyard2 -u snort -g snort -c /usr/local/etc/snort/snort_{$snort_uuid}_{$if_real}/barnyard2.conf -d /var/log/snort -f snort.u2_{$snort_uuid}_{$if_real} -w /usr/local/etc/snort/snort_{$snort_uuid}_{$if_real}/barnyard2.waldo -D -q"; } @@ -600,7 +601,8 @@ function create_snort_sh() { $id += 1; - + + $snort_uuid = $config['installedpackages']['snortglobal']['rule'][$id]['uuid']; $result_lan = $config['installedpackages']['snortglobal']['rule'][$id]['interface']; $if_real = convert_friendly_interface_to_real_interface_name($result_lan); @@ -610,18 +612,18 @@ $snort_sh_text2[] = << /tmp/snort.sh.pid # Start snort and barnyard2 - /bin/rm /var/run/snort_$if_real$id$if_real.pid - /bin/rm /var/run/snort_$if_real$id$if_real.pid.lck + /bin/rm /var/run/snort_{$snort_uuid}_{$if_real}.pid + /bin/rm /var/run/snort_{$snort_uuid}_{$if_real}.pid.lck - /usr/local/bin/snort -u snort -g snort -R $id$if_real -D -q -l /var/log/snort -G $id -c /usr/local/etc/snort/snort_$id$if_real/snort.conf -i $if_real + /usr/local/bin/snort -u snort -g snort -R {$snort_uuid}_{$if_real} -D -q -l /var/log/snort -G {$snort_uuid} -c /usr/local/etc/snort/snort_{$snort_uuid}_{$if_real}/snort.conf -i {$if_real} $start_barnyard2 - /usr/bin/logger -p daemon.info -i -t SnortStartup "Snort HARD Reload For $id$if_real..." + /usr/bin/logger -p daemon.info -i -t SnortStartup "Snort HARD Reload For {$snort_uuid}_{$if_real}..." fi EOD; @@ -632,9 +634,9 @@ $snort_sh_text3[] = << /tmp/snort.sh.pid - /usr/bin/logger -p daemon.info -i -t SnortStartup "Snort HARD STOP For $id$if_real..." + /usr/bin/logger -p daemon.info -i -t SnortStartup "Snort HARD STOP For {$snort_uuid}_{$if_real}..." /bin/kill \${pid_s} sleep 3 /bin/kill \${pid_b} - /bin/rm /var/run/snort_$if_real$id$if_real.pid.lck - /bin/rm /var/run/snort_$if_real$id$if_real.pid + /bin/rm /var/run/snort_{$snort_uuid}_{$if_real}.pid.lck + /bin/rm /var/run/snort_{$snort_uuid}_{$if_real}.pid fi @@ -674,6 +676,7 @@ EOF; } } + $start_snort_iface_start = implode("\n\n", $snort_sh_text2); $start_snort_iface_restart = implode("\n\n", $snort_sh_text3); @@ -707,7 +710,7 @@ $start_snort_iface_restart /bin/rm /tmp/snort.sh.pid #### If on Fake start snort is NOT running DO a real start. - if [ "`/bin/ps -auwx | grep -v grep | grep "R $id$if_real" | awk '{print $2;}'`" = "" ]; then + if [ "`/bin/ps -auwx | grep -v grep | grep "R {$snort_uuid}_{$if_real}" | awk '{print $2;}'`" = "" ]; then rc_start_real @@ -777,26 +780,27 @@ EOD; ///////////////////////// >>>>>>>>>>>> /* if rules exist copy to new interfaces */ -function create_rules_iface() +function create_rules_iface($id, $if_real, $snort_uuid) { - global $config, $g, $id, $if_real; + global $config, $g; conf_mount_rw(); + +exec("echo \"Create rules $snort_uuid $if_real $id ....\" >> /root/test.log"); - if ($id != '' || $if_real != '') - { - $if_rule_dir = "/usr/local/etc/snort/snort_$id$if_real/rules"; + + $if_rule_dir = "/usr/local/etc/snort/snort_{$snort_uuid}_{$if_real}/rules"; $folder_chk = (count(glob("$if_rule_dir/*")) === 0) ? 'empty' : 'full'; if ($folder_chk == "empty") { - exec("/bin/cp -R /usr/local/etc/snort/rules /usr/local/etc/snort/snort_$id$if_real"); - if (file_exists("/usr/local/etc/snort/custom_rules/local_$id$if_real.rules")) + exec("/bin/cp -R /usr/local/etc/snort/rules /usr/local/etc/snort/snort_{$snort_uuid}_{$if_real}"); + if (file_exists("/usr/local/etc/snort/custom_rules/local_{$snort_uuid}_{$if_real}.rules")) { - exec("/bin/cp /usr/local/etc/snort/custom_rules/local_$id$if_real.rules /usr/local/etc/snort/snort_$id$if_real/rules/local_$id$if_real.rules"); + exec("/bin/cp /usr/local/etc/snort/custom_rules/local_{$snort_uuid}_{$if_real}.rules /usr/local/etc/snort/snort_{$snort_uuid}_{$if_real}/rules/local_{$snort_uuid}_{$if_real}.rules"); } } - } + } /* open barnyard2.conf for writing */ @@ -804,15 +808,17 @@ function create_barnyard2_conf() { global $bconfig, $bg, $id, $if_real; /* write out barnyard2_conf */ - if(!file_exists("/usr/local/etc/snort/snort_$id$if_real/barnyard2.conf")) +exec("echo \"Create barnyard.conf $if_real $id....\" >> /root/test.log"); + + if(!file_exists("/usr/local/etc/snort/snort_{$snort_uuid}_{$if_real}/barnyard2.conf")) { - exec("/bin//usr/bin/touch /usr/local/etc/snort/snort_$id$if_real/barnyard2.conf"); + exec("/bin//usr/bin/touch /usr/local/etc/snort/snort_{$snort_uuid}_{$if_real}/barnyard2.conf"); } $barnyard2_conf_text = generate_barnyard2_conf(); - $bconf = fopen("/usr/local/etc/snort/snort_$id$if_real/barnyard2.conf", "w"); + $bconf = fopen("/usr/local/etc/snort/snort_{$snort_uuid}_{$if_real}/barnyard2.conf", "w"); if(!$bconf) { - log_error("Could not open /usr/local/etc/snort/snort_$id$if_real/barnyard2.conf for writing."); + log_error("Could not open /usr/local/etc/snort/snort_{$snort_uuid}_{$if_real}/barnyard2.conf for writing."); exit; } fwrite($bconf, $barnyard2_conf_text); @@ -831,8 +837,6 @@ function generate_barnyard2_conf() { $snortbarnyardlog_database_info_chk = $config['installedpackages']['snortglobal']['rule'][$id]['barnyard_mysql']; $snortbarnyardlog_hostname_info_chk = exec("/bin/hostname"); -$snortbarnyardlog_interface_info_chk = $if_real; - $barnyard2_conf_text = <<> /root/test.log"); + + $snort_conf_text = generate_snort_conf($id, $if_real, $snort_uuid); conf_mount_rw(); - $conf = fopen("/usr/local/etc/snort/snort_$id$if_real/snort.conf", "w"); + $conf = fopen("/usr/local/etc/snort/snort_{$snort_uuid}_{$if_real}/snort.conf", "w"); if(!$conf) { - log_error("Could not open /usr/local/etc/snort/$id$if_real/snort.conf for writing."); + log_error("Could not open /usr/local/etc/snort/snort_{$snort_uuid}_{$if_real}/snort.conf for writing."); exit; } fwrite($conf, $snort_conf_text); fclose($conf); conf_mount_ro(); + + } function snort_deinstall() @@ -905,6 +915,8 @@ function snort_deinstall() global $config, $g, $id, $if_real; conf_mount_rw(); +exec("echo \"Snort Deinstall $if_real $id....\" >> /root/test.log"); + /* remove custom sysctl */ remove_text_from_file("/etc/sysctl.conf", "sysctl net.bpf.bufsize=20480"); /* decrease bpf buffers back to 4096, from 20480 */ @@ -924,12 +936,15 @@ function snort_deinstall() exec("cd /var/db/pkg && pkg_delete `ls | grep snort`"); /* Remove snort cron entries Ugly code needs smoothness*/ - +} + function snort_rm_blocked_deinstall_cron($should_install) { global $config, $g; conf_mount_rw(); +exec("echo \"Deinstall cron block....\" >> /root/test.log"); + $is_installed = false; if(!$config['cron']['item']) @@ -963,10 +978,13 @@ function snort_rm_blocked_deinstall_cron($should_install) } - function snort_rules_up_deinstall_cron($should_install) { + function snort_rules_up_deinstall_cron($should_install) +{ global $config, $g; conf_mount_rw(); +exec("echo \"Deinstall rules up ....\" >> /root/test.log"); + $is_installed = false; if(!$config['cron']['item']) @@ -988,7 +1006,6 @@ function snort_rm_blocked_deinstall_cron($should_install) } configure_cron(); } - } snort_rm_blocked_deinstall_cron(""); snort_rules_up_deinstall_cron(""); @@ -1008,14 +1025,13 @@ snort_rules_up_deinstall_cron(""); } -function generate_snort_conf() +function generate_snort_conf($id, $if_real, $snort_uuid) { - global $config, $g, $if_real, $id; + global $config, $g, $id, $if_real, $snort_uuid; conf_mount_rw(); -if ($id != '' && $if_real != '') -{ +exec("echo \"Generate snort.conf $snort_uuid $if_real $id....\" >> /root/test.log"); /* obtain external interface */ /* XXX: make multi wan friendly */ @@ -1024,25 +1040,24 @@ if ($id != '' && $if_real != '') // $snort_config_pass_thru = $config['installedpackages']['snortglobal']['rule'][$id]['configpassthru']; /* create basic files */ - if(!file_exists("/usr/local/etc/snort/snort/snort_$id$if_real")) + if(!file_exists("/usr/local/etc/snort/snort/snort_{$snort_uuid}_{$if_real}")) { - exec("/bin/mkdir -p /usr/local/etc/snort/snort_$id$if_real/"); - exec("/bin/mkdir -p /usr/local/etc/snort/snort_$id$if_real/rules"); + exec("/bin/mkdir -p /usr/local/etc/snort/snort_{$snort_uuid}_{$if_real}/"); + exec("/bin/mkdir -p /usr/local/etc/snort/snort_{$snort_uuid}_{$if_real}/rules"); - if(!file_exists("/usr/local/etc/snort/snort_$id$if_real/gen-msg.map")) + if(!file_exists("/usr/local/etc/snort/snort_{$snort_uuid}_{$if_real}/gen-msg.map")) { - exec("/bin/cp /usr/local/etc/snort/classification.config /usr/local/etc/snort/snort_$id$if_real/classification.config"); - exec("/bin/cp /usr/local/etc/snort/gen-msg.map /usr/local/etc/snort/snort_$id$if_real/gen-msg.map"); - exec("/bin/cp /usr/local/etc/snort/reference.config /usr/local/etc/snort/snort_$id$if_real/reference.config"); - exec("/bin/cp /usr/local/etc/snort/sid-msg.map /usr/local/etc/snort/snort_$id$if_real/sid-msg.map"); - exec("/bin/cp /usr/local/etc/snort/unicode.map /usr/local/etc/snort/snort_$id$if_real/unicode.map"); - exec("/bin/cp /usr/local/etc/snort/threshold.conf /usr/local/etc/snort/snort_$id$if_real/threshold.conf"); - exec("/bin/cp /usr/local/etc/snort/snort.conf /usr/local/etc/snort/snort_$id$if_real/snort.conf"); - exec("/bin//usr/bin/touch /usr/local/etc/snort/snort_$id$if_real/barnyard2.conf"); - exec("/bin/mkdir -p /usr/local/etc/snort/snort_$id$if_real/rules"); + exec("/bin/cp /usr/local/etc/snort/classification.config /usr/local/etc/snort/snort_{$snort_uuid}_{$if_real}/classification.config"); + exec("/bin/cp /usr/local/etc/snort/gen-msg.map /usr/local/etc/snort/snort_{$snort_uuid}_{$if_real}/gen-msg.map"); + exec("/bin/cp /usr/local/etc/snort/reference.config /usr/local/etc/snort/snort_{$snort_uuid}_{$if_real}/reference.config"); + exec("/bin/cp /usr/local/etc/snort/sid-msg.map /usr/local/etc/snort/snort_{$snort_uuid}_{$if_real}/sid-msg.map"); + exec("/bin/cp /usr/local/etc/snort/unicode.map /usr/local/etc/snort/snort_{$snort_uuid}_{$if_real}/unicode.map"); + exec("/bin/cp /usr/local/etc/snort/threshold.conf /usr/local/etc/snort/snort_{$snort_uuid}_{$if_real}/threshold.conf"); + exec("/bin/cp /usr/local/etc/snort/snort.conf /usr/local/etc/snort/snort_{$snort_uuid}_{$if_real}/snort.conf"); + exec("/bin/cp/usr/bin/touch /usr/local/etc/snort/snort_{$snort_uuid}_{$if_real}/barnyard2.conf"); + exec("/bin/mkdir -p /usr/local/etc/snort/snort_{$snort_uuid}_{$if_real}/rules"); } } -} /* define snortalertlogtype */ $snortalertlogtype = $config['installedpackages']['snortglobal']['snortalertlogtype']; @@ -1064,7 +1079,7 @@ if ($tcpdumplog_info_chk == on) /* define snortunifiedlog */ $snortunifiedlog_info_chk = $config['installedpackages']['snortglobal']['rule'][$id]['snortunifiedlog']; if ($snortunifiedlog_info_chk == on) - $snortunifiedlog_type = "output unified2: filename snort.u2_$id$if_real, limit 128"; + $snortunifiedlog_type = "output unified2: filename snort.u2_{$snort_uuid}_{$if_real}, limit 128"; /* define spoink (DISABLED)*/ $spoink_info_chk = $config['installedpackages']['snortglobal']['rule'][$id]['blockoffenders7']; @@ -1321,7 +1336,7 @@ else if($config['installedpackages']['snortglobal']['rule'][$id]['performance']) $snort_performance = $config['installedpackages']['snortglobal']['rule'][$id]['performance']; else - $snort_performance = "lowmem"; + $snort_performance = "ac-bnfa"; /* open snort's whitelist for writing */ $whitelist = fopen("/var/db/whitelist", "w"); @@ -1452,7 +1467,7 @@ $snort_perform_stat = <<> /root/test.log"); + + } + } + } +} + /* check downloaded text from snort.org to make sure that an error did not occur * for example, if you are not a premium subscriber you can only download rules * so often, etc. TO BE: Removed unneeded. */ + function check_for_common_errors($filename) { global $snort_filename, $snort_filename_md5, $console_mode; - ob_flush(); + +// ob_flush(); $contents = file_get_contents($filename); if(stristr($contents, "You don't have permission")) { if(!$console_mode) { diff --git a/config/snort-dev/snort_barnyard.php b/config/snort-dev/snort_barnyard.php index 10afa183..667de21a 100644 --- a/config/snort-dev/snort_barnyard.php +++ b/config/snort-dev/snort_barnyard.php @@ -105,6 +105,7 @@ if (isset($id) && $a_nat[$id]) { $pconfig['barnyard_enable'] = $a_nat[$id]['barnyard_enable']; $pconfig['barnyard_mysql'] = $a_nat[$id]['barnyard_mysql']; $pconfig['enable'] = $a_nat[$id]['enable']; + $pconfig['uuid'] = $a_nat[$id]['uuid']; $pconfig['interface'] = $a_nat[$id]['interface']; $pconfig['descr'] = $a_nat[$id]['descr']; $pconfig['performance'] = $a_nat[$id]['performance']; @@ -144,6 +145,7 @@ if ($_POST) { if ($pconfig['interface'] != "") { $natent['interface'] = $pconfig['interface']; } if ($pconfig['enable'] != "") { $natent['enable'] = $pconfig['enable']; } + if ($pconfig['uuid'] != "") { $natent['uuid'] = $pconfig['uuid']; } if ($pconfig['descr'] != "") { $natent['descr'] = $pconfig['descr']; } if ($pconfig['performance'] != "") { $natent['performance'] = $pconfig['performance']; } if ($pconfig['blockoffenders7'] != "") { $natent['blockoffenders7'] = $pconfig['blockoffenders7']; } diff --git a/config/snort-dev/snort_define_servers.php b/config/snort-dev/snort_define_servers.php index a2cafc05..550cf153 100644 --- a/config/snort-dev/snort_define_servers.php +++ b/config/snort-dev/snort_define_servers.php @@ -105,6 +105,7 @@ if (isset($id) && $a_nat[$id]) { $pconfig['barnyard_enable'] = $a_nat[$id]['barnyard_enable']; $pconfig['barnyard_mysql'] = $a_nat[$id]['barnyard_mysql']; $pconfig['enable'] = $a_nat[$id]['enable']; + $pconfig['uuid'] = $a_nat[$id]['uuid']; $pconfig['interface'] = $a_nat[$id]['interface']; $pconfig['descr'] = $a_nat[$id]['descr']; $pconfig['performance'] = $a_nat[$id]['performance']; @@ -133,6 +134,7 @@ if ($_POST) { /* repost the options already in conf */ if ($pconfig['interface'] != "") { $natent['interface'] = $pconfig['interface']; } if ($pconfig['enable'] != "") { $natent['enable'] = $pconfig['enable']; } + if ($pconfig['uuid'] != "") { $natent['uuid'] = $pconfig['uuid']; } if ($pconfig['descr'] != "") { $natent['descr'] = $pconfig['descr']; } if ($pconfig['performance'] != "") { $natent['performance'] = $pconfig['performance']; } if ($pconfig['blockoffenders7'] != "") { $natent['blockoffenders7'] = $pconfig['blockoffenders7']; } diff --git a/config/snort-dev/snort_gui.inc b/config/snort-dev/snort_gui.inc index 1746ab54..c485d1ac 100644 --- a/config/snort-dev/snort_gui.inc +++ b/config/snort-dev/snort_gui.inc @@ -29,37 +29,40 @@ POSSIBILITY OF SUCH DAMAGE. */ -function print_info_box_np2($msg) { - global $g; - echo "\n"; - echo " \n"; - echo " \n"; - echo "
\n"; - echo "
\n"; - echo " \n"; - echo " "; - echo "
\n"; - echo "    \n"; - echo " {$msg}\n"; - echo "
\n"; - echo "
\n"; - echo "
\n"; - echo "\n"; - echo "\n
\n"; -} - - - - - - +include_once("/usr/local/pkg/snort/snort.inc"); +function print_info_box_np2($msg) { + global $config, $g; + + echo "\n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo "
\n"; + echo " \n"; + echo " "; + if(stristr($msg, "apply") == true) { + echo " "; + } + echo "
\n"; + echo "    \n"; + echo " {$msg}\n"; + echo " "; + echo " \n"; + echo "
\n"; + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n
\n"; + + exec("echo \"Funtion print info ....\" >> /root/test.log"); +} ?> \ No newline at end of file diff --git a/config/snort-dev/snort_interfaces.php b/config/snort-dev/snort_interfaces.php index 996ff83b..e2cf9fdb 100644 --- a/config/snort-dev/snort_interfaces.php +++ b/config/snort-dev/snort_interfaces.php @@ -42,6 +42,16 @@ if (!is_array($config['installedpackages']['snortglobal']['rule'])) $a_nat = &$config['installedpackages']['snortglobal']['rule']; +/////////// + +if (isset($config['installedpackages']['snortglobal']['rule'])) { +$id_gen = count($config['installedpackages']['snortglobal']['rule']); +}else{ +$id_gen = '0'; +} + +/////////// + /* if a custom message has been passed along, lets process it */ if ($_GET['savemsg']) $savemsg = $_GET['savemsg']; @@ -71,6 +81,8 @@ if ($_POST) { unlink($d_filterconfdirty_path); } + exec("echo \"Sync Empty on POST on interfaces.php....\" >> /root/test.log"); + } } @@ -81,17 +93,19 @@ if (isset($_POST['del_x'])) { /* convert fake interfaces to real */ $if_real = convert_friendly_interface_to_real_interface_name($a_nat[$rulei]['interface']); + $snort_uuid = $a_nat[$rulei]['uuid']; + + /* cool code to check if any snort is up */ + $snort_up_ck = exec("/bin/ps -auwx | /usr/bin/grep -v grep | /usr/bin/grep snort | /usr/bin/awk '{print \$2;}' | sed 1q"); - $snort_pid = exec("/bin/ps -auwx | grep -v grep | grep \"$if_real -c\" | awk '{print $2;}'"); - - if ($snort_pid != "") + if ($snort_up_ck != "") { - $start_up_pre = exec("/bin/cat /var/run/snort_{$if_real}{$rulei}{$if_real}.pid"); + $start_up_pre = exec("/usr/bin/top -a -U snort -u | grep -v grep | grep \"R {$snort_uuid}_{$if_real}\" | awk '{print \$1;}'"); $start_up_s = exec("/usr/bin/top -U snort -u | grep snort | grep {$start_up_pre} | awk '{ print $1; }'"); $start_up_r = exec("/usr/bin/top -U root -u | grep snort | grep {$start_up_pre} | awk '{ print $1; }'"); - $start2_upb_pre = exec("/bin/cat /var/run/barnyard2_{$rulei}{$if_real}.pid"); + $start2_upb_pre = exec("/bin/cat /var/run/barnyard2_{$snort_uuid}_{$if_real}.pid"); $start2_upb_s = exec("/usr/bin/top -U snort -u | grep barnyard2 | grep {$start2_upb_pre} | awk '{ print $1; }'"); $start2_upb_r = exec("/usr/bin/top -U root -u | grep barnyard2 | grep {$start2_upb_pre} | awk '{ print $1; }'"); @@ -100,113 +114,68 @@ if (isset($_POST['del_x'])) { { /* dont flood the syslog code */ - exec("/bin/cp /var/log/system.log /var/log/system.log.bk"); - sleep(3); + //exec("/bin/cp /var/log/system.log /var/log/system.log.bk"); + //sleep(3); /* remove only running instances */ if ($start_up_s != "") { exec("/bin/kill {$start_up_s}"); - exec("/bin/rm /var/run/snort_$if_real$rulei$if_real*"); + exec("/bin/rm /var/run/snort_{$snort_uuid}_{$if_real}*"); } if ($start2_upb_s != "") { exec("/bin/kill {$start2_upb_s}"); - exec("/bin/rm /var/run/barnyard2_$rulei$if_real*"); + exec("/bin/rm /var/run/barnyard2_{$snort_uuid}_{$if_real}*"); } if ($start_up_r != "") { exec("/bin/kill {$start_up_r}"); - exec("/bin/rm /var/run/snort_$if_real$rulei$if_real*"); + exec("/bin/rm /var/run/snort_{$snort_uuid}_{$if_real}*"); } if ($start2_upb_r != "") { exec("/bin/kill {$start2_upb_r}"); - exec("/bin/rm /var/run/barnyard2_$rulei$if_real*"); + exec("/bin/rm /var/run/barnyard2_{$snort_uuid}_{$if_real}*"); } /* stop syslog flood code */ - $if_real_wan_rulei = $a_nat[$rulei]['interface']; - $if_real_wan_rulei2 = convert_friendly_interface_to_real_interface_name2($if_real_wan_rulei); - exec("/sbin/ifconfig $if_real_wan_rulei2 -promisc"); - exec("/bin/cp /var/log/system.log /var/log/snort/snort_sys_$rulei$if_real.log"); - exec("/usr/bin/killall syslogd"); - exec("/usr/sbin/clog -i -s 262144 /var/log/system.log"); - exec("/usr/sbin/syslogd -c -ss -f /var/etc/syslog.conf"); - sleep(2); - exec("/bin/cp /var/log/system.log.bk /var/log/system.log"); - $after_mem = exec("/usr/bin/top | /usr/bin/grep Wired | /usr/bin/awk '{ print $2 }'"); - exec("/usr/bin/logger -p daemon.info -i -t SnortStartup 'MEM after {$rulei}{$if_real} STOP {$after_mem}'"); - exec("/usr/bin/logger -p daemon.info -i -t SnortStartup 'Interface Rule removed for {$rulei}{$if_real}...'"); + //$if_real_wan_rulei = $a_nat[$rulei]['interface']; + //$if_real_wan_rulei2 = convert_friendly_interface_to_real_interface_name2($if_real_wan_rulei); + //exec("/sbin/ifconfig $if_real_wan_rulei2 -promisc"); + //exec("/bin/cp /var/log/system.log /var/log/snort/snort_sys_$rulei$if_real.log"); + //exec("/usr/bin/killall syslogd"); + //exec("/usr/sbin/clog -i -s 262144 /var/log/system.log"); + //exec("/usr/sbin/syslogd -c -ss -f /var/etc/syslog.conf"); + //sleep(2); + //exec("/bin/cp /var/log/system.log.bk /var/log/system.log"); + //$after_mem = exec("/usr/bin/top | /usr/bin/grep Wired | /usr/bin/awk '{ print $2 }'"); + //exec("/usr/bin/logger -p daemon.info -i -t SnortStartup 'MEM after {$rulei}{$if_real} STOP {$after_mem}'"); + //exec("/usr/bin/logger -p daemon.info -i -t SnortStartup 'Interface Rule removed for {$rulei}{$if_real}...'"); } } unset($a_nat[$rulei]); - } + exec("echo \"Removing old files ....\" >> /root/test.log"); conf_mount_rw(); - exec("/bin/rm -r /usr/local/etc/snort/snort_$rulei$if_real"); - exec("/bin/rm /usr/local/etc/rc.d/snort_$rulei$if_real.sh"); - exec("/bin/rm /var/log/snort/snort.u2_$rulei$if_real*"); + exec("/bin/rm /var/log/snort/snort.u2_{$snort_uuid}_{$if_real}*"); + exec("/bin/rm -r /usr/local/etc/snort/snort_{$snort_uuid}_{$if_real}"); conf_mount_ro(); write_config(); - // touch($d_natconfdirty_path); + touch($d_natconfdirty_path); header("Location: /snort/snort_interfaces.php"); exit; } -} else { - - /* yuck - IE won't send value attributes for image buttons, while Mozilla does - so we use .x/.y to find move button clicks instead... */ - unset($movebtn); - foreach ($_POST as $pn => $pd) { - if (preg_match("/move_(\d+)_x/", $pn, $matches)) { - $movebtn = $matches[1]; - break; - } - } - /* move selected rules before this rule */ - if (isset($movebtn) && is_array($_POST['rule']) && count($_POST['rule'])) { - $a_nat_new = array(); - - /* copy all rules < $movebtn and not selected */ - for ($i = 0; $i < $movebtn; $i++) { - if (!in_array($i, $_POST['rule'])) - $a_nat_new[] = $a_nat[$i]; - } - - /* copy all selected rules */ - for ($i = 0; $i < count($a_nat); $i++) { - if ($i == $movebtn) - continue; - if (in_array($i, $_POST['rule'])) - $a_nat_new[] = $a_nat[$i]; - } - - /* copy $movebtn rule */ - if ($movebtn < count($a_nat)) - $a_nat_new[] = $a_nat[$movebtn]; - - /* copy all rules > $movebtn and not selected */ - for ($i = $movebtn+1; $i < count($a_nat); $i++) { - if (!in_array($i, $_POST['rule'])) - $a_nat_new[] = $a_nat[$i]; - } - $a_nat = $a_nat_new; - write_config(); - touch($d_natconfdirty_path); - header("Location: snort_interfaces.php"); - - exit; - } } @@ -215,8 +184,10 @@ if ($_GET['act'] == "toggle" && $_GET['id'] != "") { $if_real2 = convert_friendly_interface_to_real_interface_name($a_nat[$id]['interface']); + + $snort_uuid = $a_nat[$id]['uuid']; - $start_up_pre = exec("/usr/bin/top -a -U snort -u | grep -v grep | grep \"R {$id}{$if_real2}\" | awk '{print \$1;}'"); + $start_up_pre = exec("/usr/bin/top -a -U snort -u | grep -v grep | grep \"R {$snort_uuid}_{$if_real2}\" | awk '{print \$1;}'"); $start_up_s = exec("/usr/bin/top -U snort -u | grep snort | grep {$start_up_pre} | awk '{ print $1; }'"); $start_up_r = exec("/usr/bin/top -U root -u | grep snort | grep {$start_up_pre} | awk '{ print $1; }'"); @@ -235,7 +206,7 @@ if ($_GET['act'] == "toggle" && $_GET['id'] != "") if ($start_up_s != "") { exec("/bin/kill {$start_up_s}"); - exec("/bin/rm /var/run/snort_$if_real2$id$if_real2*"); + exec("/bin/rm /var/run/snort_{$snort_uuid}_{$if_real2}*"); } //if ($start2_upb_s != "") @@ -247,7 +218,7 @@ if ($_GET['act'] == "toggle" && $_GET['id'] != "") if ($start_up_r != "") { exec("/bin/kill {$start_up_r}"); - exec("/bin/rm /var/run/snort_$if_real2$id$if_real2*"); + exec("/bin/rm /var/run/snort_{$snort_uuid}_{$if_real2}*"); } //if ($start2_upb_r != "") @@ -280,9 +251,9 @@ if ($_GET['act'] == "toggle" && $_GET['id'] != "") header("Location: /snort/snort_interfaces.php"); }else{ - sync_snort_package_all(); + //sync_snort_package_all(); - exec("/usr/local/bin/snort -u snort -g snort -R \"$id$if_real2\" -D -q -l /var/log/snort -G $id -c /usr/local/etc/snort/snort_$id$if_real2/snort.conf -i $if_real2"); + exec("/usr/local/bin/snort -u snort -g snort -R \"{$snort_uuid}_{$if_real2}\" -D -q -l /var/log/snort -G {$snort_uuid} -c /usr/local/etc/snort/snort_{$snort_uuid}_{$if_real2}/snort.conf -i {$if_real2}"); //print_r("$id $if_real2"); header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' ); @@ -296,7 +267,7 @@ if ($_GET['act'] == "toggle" && $_GET['id'] != "") } -$pgtitle = "Services: Snort 2.8.5.3 pkg v. 1.10 alpha"; +$pgtitle = "Services: Snort 2.8.5.3 pkg v. 1.12 Beta"; include("head.inc"); ?> @@ -353,12 +324,12 @@ padding: 15px 10px 50% 50px; padding-left: 0px; } - - + + + +
-

+ + + + +
+ +
+
+ + +
+ + + + + + + +
Filter by test:  Inverse filter (NOT):>
Limit:
 
* Add spam trap E-mail address:

+ + + + + + + + + + + + +"; + } + } + } else { + $pkgdb = split("\n", `/usr/local/sbin/spamdb | tail -n {$limit}`); + } + $rows = 0; + $lastseenip = ""; + $srcip = "|"; + foreach($pkgdb as $pkgdb_row) { + + if($rows > $limit) + break; + $dontdisplay = false; + if(!$pkgdb_row) + continue; + $pkgdb_split = split("\|", $pkgdb_row); + + /* + + For TRAPPED entries the format is: + + type|ip|expire + + where type will be TRAPPED, IP will be the IP address blacklisted due to + hitting a spamtrap, and expire will be when the IP is due to be removed + from the blacklist. + + For GREY entries, the format is: + + type|source IP|helo|from|to|first|pass|expire|block|pass + + For WHITE entries, the format is: + + type|source IP|||first|pass|expire|block|pass + + */ + switch($pkgdb_split[0]) { + case "SPAMTRAP": + $recordtype = htmlentities($pkgdb_split[0]); + $srcip = htmlentities($pkgdb_split[1]); + $fromaddress = htmlentities($pkgdb_split[3]); + $toaddress = htmlentities($pkgdb_split[4]); + $attempts = htmlentities($pkgdb_split[8]); + break; + case "TRAPPED": + $recordtype = htmlentities($pkgdb_split[0]); + $srcip = htmlentities($pkgdb_split[1]); + $fromaddress = ""; + $toaddress = ""; + $attempts = ""; + break; + case "GREY": + $recordtype = htmlentities($pkgdb_split[0]); + $srcip = htmlentities($pkgdb_split[1]); + $fromaddress = htmlentities($pkgdb_split[3]); + $toaddress = htmlentities($pkgdb_split[4]); + $attempts = htmlentities($pkgdb_split[8]); + break; + case "WHITE": + $recordtype = htmlentities($pkgdb_split[0]); + $srcip = htmlentities($pkgdb_split[1]); + $fromaddress = ""; + $toaddress = ""; + $attempts = htmlentities($pkgdb_split[8]); + break; + } + if($srcip == "" and $fromaddress == "" and $toaddress == "") + continue; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + $rows++; + } +?>
TypeIPFromToAttempts
{$recordtype}{$srcip}{$fromaddress}{$toaddress}{$attempts}"; + $rowtext = "\"Add "; + $rowtext .= "\"Blacklist\" "; + $rowtext .= "\"Delete\""; + $rowtext .= "\"Spamtrap\" "; + + echo $rowtext; + + echo "
+
+

" . $rows . " rows returned."; ?> +

+ * NOTE: adding an e-mail address to the spamtrap automatically traps any server trying to send e-mail to this address. +

+
+
+ +
+Note: Clicking on the action icons will invoke a AJAX query and the page will not refresh. Click refresh in you're browser if you wish to view the changes in status. +
+

Database totals:

+ "; + echo "{$blacklist_items} total items in the blacklist.
"; + echo "{$spamdb_grey} total items in the greylist.
"; + echo "{$spamdb_items} total items in the SpamDB.
"; + ?> + + + diff --git a/config/spamd/spamd_db_ext.php b/config/spamd/spamd_db_ext.php new file mode 100644 index 00000000..e029f676 --- /dev/null +++ b/config/spamd/spamd_db_ext.php @@ -0,0 +1,239 @@ + $username) { + echo "550. INVALID USERNAME {$username}."; + exit; + } + if($outlook['password'] <> $password) { + echo "550. INVALID PASSWORD {$password}."; + exit; + } +} + +exec("echo {$_GET['action']} > /tmp/tmp"); + +/* handle AJAX operations */ +if($_GET['action'] or $_POST['action']) { + if($_GET['action']) + $action = escapeshellarg(trim($_GET['action'])); + if($_POST['action']) + $action = escapeshellarg(trim($_POST['action'])); + if($_GET['srcip']) + $srcip = escapeshellarg(trim($_GET['srcip'])); + if($_POST['srcip']) + $srcip = escapeshellarg(trim($_POST['srcip'])); + if($_POST['email']) + $email = escapeshellarg(trim($_POST['email'])); + if($_GET['email']) + $email = escapeshellarg(trim($_GET['email'])); + /* execute spamdb command */ + if($action == "whitelist") { + delete_from_spamd_db($srcip); + usleep(100); + exec("/usr/local/sbin/spamdb -a {$srcip}"); + mwexec("/sbin/pfctl -q -t blacklist -T replace -f /var/db/blacklist.txt"); + delete_from_blacklist($srcip); + log_error("spamd: {$srcip} has been whitelisted by {$_SERVER['REMOTE_ADDR']} {$loginname}"); + hup_spamd(); + exit; + } else if($action == "delete") { + delete_from_spamd_db($srcip); + usleep(100); + hup_spamd(); + mwexec("/sbin/pfctl -q -t spamd -T delete $srcip"); + mwexec("/sbin/pfctl -q -t blacklist -T replace -f /var/db/blacklist.txt"); + delete_from_blacklist($srcip); + delete_from_whitelist($srcip); + log_error("spamd: {$srcip} has been deleted by {$_SERVER['REMOTE_ADDR']} {$loginname}"); + exit; + } else if($action == "spamtrap") { + delete_from_spamd_db($email); + delete_from_whitelist($srcip); + usleep(100); + exec("/usr/local/sbin/spamdb -a \"{$email}\" -T"); + hup_spamd(); + mwexec("/sbin/pfctl -q -t blacklist -T add -f /var/db/blacklist.txt"); + log_error("spamd: {$srcip} has been blacklisted by {$_SERVER['REMOTE_ADDR']} {$loginname}"); + exit; + } else if($action == "trapped") { + delete_from_spamd_db($srcip); + delete_from_whitelist($srcip); + usleep(100); + exec("/usr/local/sbin/spamdb -a {$srcip} -t"); + add_to_blacklist($srcip); + log_error("spamd: {$srcip} has been trapped by {$_SERVER['REMOTE_ADDR']} {$loginname}"); + hup_spamd(); + exit; + } + /* signal a reload for real time effect. */ + hup_spamd(); + exit; +} + +/* spam trap e-mail address */ +if($_POST['spamtrapemail'] <> "") { + $spamtrapemail = escapeshellarg($_POST['spamtrapemail']); + exec("/usr/local/sbin/spamdb -d {$spamtrapemail}"); + exec("/usr/local/sbin/spamdb -d -T \"{$spamtrapemail}\""); + exec("/usr/local/sbin/spamdb -d -t \"{$spamtrapemail}\""); + mwexec("/usr/local/sbin/spamdb -T -a \"{$spamtrapemail}\""); + mwexec("killall -HUP spamlogd"); + $savemsg = htmlentities($_POST['spamtrapemail']) . " added to spam trap database."; +} + +if($_GET['getstatus'] <> "") { + $getstatus = escapeshellarg($_GET['getstatus']); + $status = exec("/usr/local/sbin/spamdb | grep \"{$getstatus}\""); + if(stristr($status, "WHITE") == true) { + echo "WHITE"; + } else if(stristr($status, "TRAPPED") == true) { + echo "TRAPPED"; + } else if(stristr($status, "GREY") == true) { + echo "GREY"; + } else if(stristr($status, "SPAMTRAP") == true) { + echo "SPAMTRAP"; + } else { + echo "NOT FOUND"; + } + exit; +} + +/* spam trap e-mail address */ +if($_GET['spamtrapemail'] <> "") { + $spamtrapemail = escapeshellarg($_GET['spamtrapemail']); + $status = exec("spamdb -T -a \"{$spamtrapemail}\""); + mwexec("killall -HUP spamlogd"); + if($status) + echo $status; + else + echo htmlentities($_POST['spamtrapemail']) . " added to spam trap database."; + exit; +} + +/* spam trap e-mail address */ +if($_GET['whitelist'] <> "") { + $spamtrapemail = escapeshellarg($_GET['spamtrapemail']); + $status = exec("spamdb -a \"{$spamtrapemail}\""); + mwexec("killall -HUP spamlogd"); + if($status) + echo $status; + else + echo htmlentities($_POST['spamtrapemail']) . " added to whitelist database."; + exit; +} + +function delete_from_spamd_db($srcip) { + config_lock(); + $fd = fopen("/tmp/execcmds", "w"); + fwrite($fd, "#!/bin/sh\n"); + fwrite($fd, "/usr/local/sbin/spamdb -d {$srcip}\n"); + fwrite($fd, "/usr/local/sbin/spamdb -d {$srcip} -T\n"); + fwrite($fd, "/usr/local/sbin/spamdb -d {$srcip} -t\n"); + fwrite($fd, "/usr/local/sbin/spamdb -d \"{$srcip}\" -t\n"); + fwrite($fd, "/usr/local/sbin/spamdb -d \"{$srcip}\" -T\n"); + fclose($fd); + exec("/bin/chmod a+rx /tmp/execcmds"); + system("/bin/sh /tmp/execcmds"); + mwexec("/usr/bin/killall -HUP spamlogd"); + mwexec("/sbin/pfctl -q -t blacklist -T replace -f /var/db/blacklist.txt"); + config_unlock(); +} + +function basic_auth_prompt(){ + header("WWW-Authenticate: Basic realm=\".\""); + header("HTTP/1.0 401 Unauthorized"); + echo "You must enter valid credentials to access this resource."; + exit; +} + +function add_to_blacklist($srcip) { + config_lock(); + $fd = fopen("/var/db/blacklist.txt", "a"); + fwrite($fd, "{$srcip}\n"); + fclose($fd); + mwexec("/sbin/pfctl -q -t spamd -T add -f /var/db/blacklist.txt"); + mwexec("/sbin/pfctl -q -t blacklist -T add -f /var/db/blacklist.txt"); + config_unlock(); +} + +function delete_from_blacklist($srcip) { + config_lock(); + $blacklist = split("\n", file_get_contents("/var/db/blacklist.txt")); + $fd = fopen("/var/db/blacklist.txt", "w"); + foreach($blacklist as $bl) { + if($bl <> "") + if(!stristr($bl, $srcip)) + fwrite($fd, "{$bl}\n"); + } + fclose($fd); + mwexec("/sbin/pfctl -q -t spamd -T delete $srcip"); + mwexec("/sbin/pfctl -q -t blacklist -T replace -f /var/db/blacklist.txt"); + config_unlock(); +} + +function delete_from_whitelist($srcip) { + config_lock(); + $whitelist = split("\n", file_get_contents("/var/db/whitelist.txt")); + $fd = fopen("/var/db/whitelist.txt", "w"); + foreach($whitelist as $wl) { + if($wl <> "") + if(!stristr($wl, $srcip)) + fwrite($fd, "{$wl}\n"); + } + fclose($fd); + mwexec("/sbin/pfctl -q -t spamd -T delete $srcip"); + mwexec("/sbin/pfctl -q -t whitelist -T replace -f /var/db/whitelist.txt"); + config_unlock(); +} + +function hup_spamd() { + mwexec("killall -HUP spamlogd"); +} + +exit; + +?> \ No newline at end of file diff --git a/config/spamd/spamd_exchexp.asp b/config/spamd/spamd_exchexp.asp new file mode 100644 index 00000000..56b0c629 --- /dev/null +++ b/config/spamd/spamd_exchexp.asp @@ -0,0 +1,50 @@ +<% + +dim server +server = "SERVERNAME" + +Sub ExportUsers(oObject) + Dim oUser + For Each oUser in oObject + Select Case oUser.Class + Case "user" + If oUser.mail <> "" then + + for each email in oUser.proxyAddresses + If (lcase(left(email,4))="smtp") Then + 'userFile.WriteLine Mid(email,6) + document.write Mid(email,6) & vbCrLf + End If + next + End if + Case "organizationalUnit" , "container" + If UsersinOU (oUser) then + ExportUsers(oUser) + End if + End select + Next +End Sub + +Function UsersinOU (oObject) + Dim oUser + UsersinOU = False + for Each oUser in oObject + Select Case oUser.Class + Case "organizationalUnit" , "container" + UsersinOU = UsersinOU(oUser) + Case "user" + UsersinOU = True + + End select + Next +End Function + +Dim rootDSE, domainObject +Set rootDSE=GetObject("LDAP://" & server & "/RootDSE") +domainContainer = rootDSE.Get("defaultNamingContext") +Set domainObject = GetObject("LDAP://" & domainContainer) + +ExportUsers(domainObject) +Set oDomain = Nothing + +%> \ No newline at end of file diff --git a/config/spamd/spamd_gather_stats.php b/config/spamd/spamd_gather_stats.php new file mode 100644 index 00000000..a95e2596 --- /dev/null +++ b/config/spamd/spamd_gather_stats.php @@ -0,0 +1,82 @@ +#!/usr/local/bin/php -q + + \ No newline at end of file diff --git a/config/spamd/spamd_outlook.xml b/config/spamd/spamd_outlook.xml new file mode 100644 index 00000000..5e94701f --- /dev/null +++ b/config/spamd/spamd_outlook.xml @@ -0,0 +1,90 @@ + + + + + + . + 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. + */ +/* ========================================================================== */ + ]]> + + Describe your package here + Describe your package requirements here + Currently there are no FAQ items provided. + spamdoutlook + 0.1.0 + SpamD Outlook + pkg_edit.php?xml=spamd_outlook.xml&id=0 + + + SpamD External Sources + /pkg.php?xml=spamd.xml + + + SpamD Whitelist + /pkg.php?xml=spamd_whitelist.xml + + + SpamD Settings + /pkg_edit.php?xml=spamd_settings.xml&id=0 + + + SpamD Database + /spamd_db.php + + + + ['installedpackages']['spamd']['config'] + + + + Username + username + Enter the username the outlook clients will use to connect with. + input + + + Password + password + Enter the password the outlook clients will use to connect with. + password + + + + \ No newline at end of file diff --git a/config/spamd/spamd_rules.php b/config/spamd/spamd_rules.php new file mode 100644 index 00000000..27ac850a --- /dev/null +++ b/config/spamd/spamd_rules.php @@ -0,0 +1,34 @@ + +/* + spamd_rules.inc + part of pfSense (www.pfSense.com) + Copyright (C) 2004 Scott Ullrich (sullrich@gmail.com) + 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. +*/ +$wanif = get_real_wan_interface(); +$anchor = "natearly"; +$natrules .= "rdr pass on {$wanif} proto tcp from to port smtp -> 127.0.0.1 port spamd\n"; +$natrules .= "rdr pass on {$wanif} proto tcp from ! to port smtp -> 127.0.0.1 port spamd\n"; +$label = "spamd"; +add_rule_to_anchor($anchor, $rule, $label); diff --git a/config/spamd/spamd_settings.xml b/config/spamd/spamd_settings.xml new file mode 100644 index 00000000..95c343d1 --- /dev/null +++ b/config/spamd/spamd_settings.xml @@ -0,0 +1,192 @@ + + + + + + + + Describe your package here + Describe your package requirements here + Currently there are no FAQ items provided. + spamdsettings + 0.1.0 + SpamD Settings + pkg_edit.php?xml=spamd_settings.xml&id=0 + /usr/local/pkg/spamd.inc + +

+ SpamD +
Services
+ spamd.xml +
+ + spamd + spamd.sh + + + + SpamD External Sources + /pkg.php?xml=spamd.xml + + + SpamD Whitelist + /pkg.php?xml=spamd_whitelist.xml + + + SpamD Settings + /pkg_edit.php?xml=spamd_settings.xml&id=0 + + + + SpamD Database + /spamd_db.php + + + + ['installedpackages']['spamd']['config'] + + + + Identifier + identifier + The SMTP version banner that is reported upon initial connection. + input + + + Maximum blacklisted connections + maxblack + The maximum number of concurrent blacklisted connections to allow in greylisting mode. This value may not be greater than maxcon (see below). The default is maxcon - 100. + input + + + Max concurrent connections + maxcon + The maximum number of concurrent connections to allow. The default is 800. + input + 800 + + + Grey listing + greylisting + Connections from addresses not blacklisted on the black lists tab will be considered for greylisting. Such connections will not be stuttered at (though see the stutter secs option) or delayed, and will receive the pleasantly innocuous temporary failure. After passtime if the host returns it will be added to the white list. + checkbox + yes + + + Passtime + passtime + Adjust the three time parameters for greylisting. Passtime defaults to 25 (minutes). After passtime minutes if spamd sees a retried attempt to deliver mail for the same tuple, spamd will whitelist the connecting address by adding it as a whitelist entry. + input + 30 + 25:4:864 + + + Grey Expiration + greyexp + Adjust the three time parameters for greylisting. Grey expiration defaults to 4. SpamD removes connection entries from the database if delivery has not been retried within greyexp hours from the initial time a connection is seen. + input + 30 + 25:4:864 + + + White Exp + whiteexp + Adjust the three time parameters for greylisting. White expiration defaults to 864 (hours, approximately 36 days). SpamD removes whitelist entries from the database if no mail delivery activity has been seen from the whitelisted address within whiteexp hours from the initial time an address is whitelisted. + input + 30 + 25:4:864 + + + Stutter Secs + stuttersecs + Stutter at greylisted connections for the specified amount of seconds, after which the connection is not stuttered at. Defaults to 10. + input + 10 + + + Delay Secs + delaysecs + Delay each character sent to the client by the specified amount of seconds. Defaults to 1. + input + 1 + + + Window Size + window + Set the socket receive buffer to this many bytes, adjusting the window size. + input + + + + + NextMTA + nextmta + Automatically sends messages after being processed by SpamD to IP Address. You may enter an alias if you like, simply prepend $ to the alias name. example: $mailservers. Note, if you have postfix package installed enter 127.0.0.1 here. + input + 1 + + + Enable RRD graphing + enablerrd + Enables the graphing of SpamD connection and disconnection statistics. + checkbox + + + + + spamd_validate_input($_POST, &$input_errors); + + + sync_package_spamd(); + + \ No newline at end of file diff --git a/config/spamd/spamd_verify_to_address.php b/config/spamd/spamd_verify_to_address.php new file mode 100644 index 00000000..56821370 --- /dev/null +++ b/config/spamd/spamd_verify_to_address.php @@ -0,0 +1,144 @@ +#!/usr/local/bin/php -q + from email addresses */ +for($x=0; isset($current_spamtrap[$x]); $x++) { + $current_spamtrap[$x] = str_replace("<", "", $current_spamtrap[$x]); + $current_spamtrap[$x] = str_replace(">", "", $current_spamtrap[$x]); +} + +/* traverse list and find the dictionary attackers, etc */ +foreach($grey_hosts as $grey) { + if(trim($grey) == "") + continue; + /* clean up and further break down values */ + $grey_lower = strtolower($grey); + $grey_lower = str_replace("<","",$grey_lower); + $grey_lower = str_replace(">","",$grey_lower); + $grey_split = split("\|", $grey_lower); + $email_from = strtolower($grey_split[2]); + $email_to = strtolower($grey_split[3]); + $server_ip = strtolower($grey_split[1]); + if(in_array($server_ip, $current_blacklist)) { + if($debug) + echo "$server_ip already in blacklist.\n"; + continue; + } + if(in_array($email_to, $current_spamtrap)) { + if($email_to) + echo "$email_to already in blacklist.\n"; + continue; + } + if($debug) + echo "Testing $email_from | $email_to \n"; + if (in_array($email_to, $valid_list)) { + if($debug) + echo "$email_to is in the valid list\n"; + } else { + /* spammer picked the wrong person to mess with */ + if($server_ip) { + if($debug) + echo "/usr/local/sbin/spamdb -a $server_ip -t\n"; + exec("/usr/local/sbin/spamdb -d {$server_ip} 2>/dev/null"); + exec("/usr/local/sbin/spamdb -d {$server_ip} -T 2>/dev/null"); + exec("/usr/local/sbin/spamdb -d {$server_ip} -t 2>/dev/null"); + if($debug) + echo "/usr/local/sbin/spamdb -a \"<$email_to>\" -T\n"; + exec("/usr/local/sbin/spamdb -a \"<$email_to>\" -T"); + config_lock(); + system("echo $server_ip >> /var/db/blacklist.txt"); + config_unlock(); + $result = mwexec("/usr/local/sbin/spamdb -a $server_ip -t"); + } else { + if($debug) + echo "Could not locate server ip address."; + } + if($debug) + echo "Script result code: {$result}\n"; + } +} + +mwexec("killall -HUP spamlogd"); + +if($debug) { + echo "\nSearch completed.\n\n"; + echo "Items trapped: "; + system("/usr/local/sbin/spamdb | grep TRAPPED | wc -l"); + echo "Items spamtrapped: "; + system("/usr/local/sbin/spamdb | grep SPAMTRAP | wc -l"); + echo "Items in blacklist.txt: "; + system("/sbin/pfctl -t blacklist -T show | wc -l"); +} + +mwexec("/sbin/pfctl -q -t blacklist -T replace -f /var/db/blacklist.txt"); + +?> \ No newline at end of file diff --git a/config/spamd/spamd_whitelist.xml b/config/spamd/spamd_whitelist.xml new file mode 100644 index 00000000..f7b3f4fe --- /dev/null +++ b/config/spamd/spamd_whitelist.xml @@ -0,0 +1,132 @@ + + + + + + . + 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. + */ +/* ========================================================================== */ + ]]> + + Describe your package here + Describe your package requirements here + Currently there are no FAQ items provided. + spamd-whitelist + 0.1.0 + SpamD: Whitelist + + + SpamD Whitelist + +
Services
+ spamd.xml +
+ + + SpamD External Sources + /pkg.php?xml=spamd.xml + + + SpamD Whitelist + /pkg.php?xml=spamd_whitelist.xml + + + + SpamD Settings + /pkg_edit.php?xml=spamd_settings.xml&id=0 + + + SpamD Database + /spamd_db.php + + + + ['installedpackages']['spamdwhitelist']['config'] + + + Exempted IP + ip + + + Description + description + + + + + + Exempted IP + ip + Enter the IP to exempt from blacklisting + input + + + Description + description + Enter the description for this item + input + + + + function sync_package_spamd_whitelist() { + global $config; + conf_mount_rw(); + config_lock(); + /* write out ip to the whitelist db */ + $fd = fopen("/var/db/whitelist.txt","w"); + if($config['installedpackages']['spamdwhitelist']['config'] != "") { + foreach($config['installedpackages']['spamdwhitelist']['config'] as $spamd) { + fwrite($fd, $spamd['ip'] . "\n"); + } + } + fclose($fd); + /* signal a reload of all files */ + mwexec("/usr/bin/killall -HUP spamlogd"); + mwexec("/sbin/pfctl -t spamd-white -T add {$spamd['ip']}"); + conf_mount_ro(); + config_unlock(); + } + + + sync_package_spamd_whitelist(); + + + sync_package_spamd_whitelist(); + +
\ No newline at end of file diff --git a/config/spamd_db.php b/config/spamd_db.php deleted file mode 100644 index 112fdd71..00000000 --- a/config/spamd_db.php +++ /dev/null @@ -1,457 +0,0 @@ -","",$srcip); - $srcip = str_replace(" ","",$srcip); - // Make input safe - $srcip = escapeshellarg($srcip); - /* execute spamdb command */ - if($action == "'whitelist'") { - exec("/usr/local/sbin/spamdb -d {$srcip}"); - exec("/usr/local/sbin/spamdb -d {$srcip} -T"); - exec("/usr/local/sbin/spamdb -d {$srcip} -t"); - delete_from_blacklist($srcip); - mwexec("/sbin/pfctl -q -t blacklist -T replace -f /var/db/blacklist.txt"); - exec("echo spamdb -a {$srcip} > /tmp/tmp"); - exec("/usr/local/sbin/spamdb -a {$srcip}"); - } else if($action == "'delete'") { - exec("/usr/local/sbin/spamdb -d {$srcip}"); - exec("/usr/local/sbin/spamdb -d {$srcip} -T"); - exec("/usr/local/sbin/spamdb -d {$srcip} -t"); - delete_from_blacklist($srcip); - mwexec("/sbin/pfctl -q -t spamd -T delete $srcip"); - mwexec("/sbin/pfctl -q -t blacklist -T replace -f /var/db/blacklist.txt"); - } else if($action == "'spamtrap'") { - exec("/usr/local/sbin/spamdb -d {$srcip}"); - exec("/usr/local/sbin/spamdb -d {$srcip} -T"); - exec("/usr/local/sbin/spamdb -d {$srcip} -t"); - exec("/usr/local/sbin/spamdb -a {$srcip} -T"); - } else if($action == "'trapped'") { - exec("/usr/local/sbin/spamdb -T -d {$toaddress}"); - exec("/usr/local/sbin/spamdb -T -a '{$toaddress}'"); - } - /* signal a reload for real time effect. */ - mwexec("killall -HUP spamlogd"); - exit; -} - -/* spam trap e-mail address */ -if($_POST['spamtrapemail'] <> "") { - $spamtrapemail = escapeshellarg($_POST['spamtrapemail']); - exec("/usr/local/sbin/spamdb -d {$spamtrapemail}"); - exec("/usr/local/sbin/spamdb -d -T {$spamtrapemail}"); - exec("/usr/local/sbin/spamdb -d -t {$spamtrapemail}"); - exec("/usr/local/sbin/spamdb -T -a '{$toaddress}'"); - - mwexec("killall -HUP spamlogd"); - $savemsg = htmlentities($_POST['spamtrapemail']) . " added to spam trap database."; -} - -if($_GET['getstatus'] <> "") { - $status = exec("/usr/local/sbin/spamdb | grep \"{$_GET['getstatus']}\""); - if(stristr($status, "WHITE") == true) { - echo "WHITE"; - } else if(stristr($status, "TRAPPED") == true) { - echo "TRAPPED"; - } else if(stristr($status, "GREY") == true) { - echo "GREY"; - } else if(stristr($status, "SPAMTRAP") == true) { - echo "SPAMTRAP"; - } else { - echo "NOT FOUND"; - } - exit; -} - -/* spam trap e-mail address */ -if($_GET['spamtrapemail'] <> "") { - $spamtrapemail = escapeshellarg($_GET['spamtrapemail']); - $status = exec("spamdb -T -a {$spamtrapemail}"); - mwexec("killall -HUP spamlogd"); - if($status) - echo $status; - else - echo htmlentities($_POST['spamtrapemail']) . " added to spam trap database."; - exit; -} - -/* whitelist e-mail address */ -if($_GET['whitelist'] <> "") { - $spamtrapemail = escapeshellarg($_GET['spamtrapemail']); - $status = exec("spamdb -a {$spamtrapemail}"); - mwexec("killall -HUP spamlogd"); - if($status) - echo $status; - else - echo htmlentities($_POST['spamtrapemail']) . " added to whitelist database."; - exit; -} - -function delete_from_blacklist($srcip) { - config_lock(); - $blacklist = split("\n", file_get_contents("/var/db/blacklist.txt")); - $fd = fopen("/var/db/blacklist.txt", "w"); - foreach($blacklist as $bl) { - if($bl <> "") - if(!stristr($bl, $srcip)) - fwrite($fd, "{$bl}\n"); - } - fclose($fd); - mwexec("/sbin/pfctl -q -t spamd -T delete {$srcip}"); - mwexec("/sbin/pfctl -q -t blacklist -T replace -f /var/db/blacklist.txt"); - config_unlock(); -} - -function delete_from_whitelist($srcip) { - config_lock(); - $whitelist = split("\n", file_get_contents("/var/db/whitelist.txt")); - $fd = fopen("/var/db/whitelist.txt", "w"); - foreach($whitelist as $wl) { - if($wl <> "") - if(!stristr($wl, $srcip)) - fwrite($fd, "{$wl}\n"); - } - fclose($fd); - mwexec("/sbin/pfctl -q -t spamd -T delete $srcip"); - mwexec("/sbin/pfctl -q -t whitelist -T replace -f /var/db/whitelist.txt"); - config_unlock(); -} - -$pgtitle = "SpamD: Database"; -include("head.inc"); - -if(file_exists("/var/db/whitelist.txt")) - $whitelist_items = `cat /var/db/whitelist.txt | wc -l`; -else - $whitelist_items = 0; - -if(file_exists("/var/db/blacklist.txt")) - $blacklist_items = `cat /var/db/blacklist.txt | wc -l`; -else - $blacklist_items = 0; - -// Get an overall count of the database -$spamdb_items = `/usr/local/sbin/spamdb | wc -l`; - -// Get blacklist and whitelist count from database -$spamdb_white = `/usr/local/sbin/spamdb | grep WHITE | wc -l`; -$spamdb_black = `/usr/local/sbin/spamdb | grep BLACK | wc -l`; -$spamdb_grey = `/usr/local/sbin/spamdb | grep GREY | wc -l`; - -// Now count the user contributed whitelist and blacklist count -$whitelist_items = $whitelist_items + $spamdb_white; -$blacklist_items = $blacklist_items + $spamdb_black; - -?> - - -

-
- - - - - - -

- - - - - - -
- -
-
- - -
- - - - - - - -
Filter by test:  Inverse filter (NOT):>
Limit:
 
* Add spam trap E-mail address:

- - - - - - - - - - - - -"; - } - } - } else { - $pkgdb = split("\n", `/usr/local/sbin/spamdb | tail -n {$limit}`); - } - $rows = 0; - $lastseenip = ""; - $srcip = "|"; - foreach($pkgdb as $pkgdb_row) { - - if($rows > $limit) - break; - $dontdisplay = false; - if(!$pkgdb_row) - continue; - $pkgdb_split = split("\|", $pkgdb_row); - - /* - - For TRAPPED entries the format is: - - type|ip|expire - - where type will be TRAPPED, IP will be the IP address blacklisted due to - hitting a spamtrap, and expire will be when the IP is due to be removed - from the blacklist. - - For GREY entries, the format is: - - type|source IP|helo|from|to|first|pass|expire|block|pass - - For WHITE entries, the format is: - - type|source IP|||first|pass|expire|block|pass - - */ - switch($pkgdb_split[0]) { - case "SPAMTRAP": - $recordtype = htmlentities($pkgdb_split[0]); - $srcip = htmlentities($pkgdb_split[1]); - $fromaddress = htmlentities($pkgdb_split[3]); - $toaddress = htmlentities($pkgdb_split[4]); - $attempts = htmlentities($pkgdb_split[8]); - break; - case "TRAPPED": - $recordtype = htmlentities($pkgdb_split[0]); - $srcip = htmlentities($pkgdb_split[1]); - $fromaddress = ""; - $toaddress = ""; - $attempts = ""; - break; - case "GREY": - $recordtype = htmlentities($pkgdb_split[0]); - $srcip = htmlentities($pkgdb_split[1]); - $fromaddress = htmlentities($pkgdb_split[3]); - $toaddress = htmlentities($pkgdb_split[4]); - $attempts = htmlentities($pkgdb_split[8]); - break; - case "WHITE": - $recordtype = htmlentities($pkgdb_split[0]); - $srcip = htmlentities($pkgdb_split[1]); - $fromaddress = ""; - $toaddress = ""; - $attempts = htmlentities($pkgdb_split[8]); - break; - } - if($srcip == "" and $fromaddress == "" and $toaddress == "") - continue; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - - $rows++; - } -?>
TypeIPFromToAttempts
{$recordtype}{$srcip}{$fromaddress}{$toaddress}{$attempts}"; - $rowtext = "\"Add "; - $rowtext .= "\"Blacklist\" "; - $rowtext .= "\"Delete\""; - $rowtext .= "\"Spamtrap\" "; - - echo $rowtext; - - echo "
-
-

" . $rows . " rows returned."; ?> -

- * NOTE: adding an e-mail address to the spamtrap automatically traps any server trying to send e-mail to this address. -

-
-
-

-
-Note: Clicking on the action icons will invoke a AJAX query and the page will not refresh. Click refresh in you're browser if you wish to view the changes in status. -
-

Database totals:

- "; - echo "{$blacklist_items} total items in the blacklist.
"; - echo "{$spamdb_grey} total items in the greylist.
"; - echo "{$spamdb_items} total items in the SpamDB.
"; - ?> - - - diff --git a/config/spamd_db_ext.php b/config/spamd_db_ext.php deleted file mode 100644 index e029f676..00000000 --- a/config/spamd_db_ext.php +++ /dev/null @@ -1,239 +0,0 @@ - $username) { - echo "550. INVALID USERNAME {$username}."; - exit; - } - if($outlook['password'] <> $password) { - echo "550. INVALID PASSWORD {$password}."; - exit; - } -} - -exec("echo {$_GET['action']} > /tmp/tmp"); - -/* handle AJAX operations */ -if($_GET['action'] or $_POST['action']) { - if($_GET['action']) - $action = escapeshellarg(trim($_GET['action'])); - if($_POST['action']) - $action = escapeshellarg(trim($_POST['action'])); - if($_GET['srcip']) - $srcip = escapeshellarg(trim($_GET['srcip'])); - if($_POST['srcip']) - $srcip = escapeshellarg(trim($_POST['srcip'])); - if($_POST['email']) - $email = escapeshellarg(trim($_POST['email'])); - if($_GET['email']) - $email = escapeshellarg(trim($_GET['email'])); - /* execute spamdb command */ - if($action == "whitelist") { - delete_from_spamd_db($srcip); - usleep(100); - exec("/usr/local/sbin/spamdb -a {$srcip}"); - mwexec("/sbin/pfctl -q -t blacklist -T replace -f /var/db/blacklist.txt"); - delete_from_blacklist($srcip); - log_error("spamd: {$srcip} has been whitelisted by {$_SERVER['REMOTE_ADDR']} {$loginname}"); - hup_spamd(); - exit; - } else if($action == "delete") { - delete_from_spamd_db($srcip); - usleep(100); - hup_spamd(); - mwexec("/sbin/pfctl -q -t spamd -T delete $srcip"); - mwexec("/sbin/pfctl -q -t blacklist -T replace -f /var/db/blacklist.txt"); - delete_from_blacklist($srcip); - delete_from_whitelist($srcip); - log_error("spamd: {$srcip} has been deleted by {$_SERVER['REMOTE_ADDR']} {$loginname}"); - exit; - } else if($action == "spamtrap") { - delete_from_spamd_db($email); - delete_from_whitelist($srcip); - usleep(100); - exec("/usr/local/sbin/spamdb -a \"{$email}\" -T"); - hup_spamd(); - mwexec("/sbin/pfctl -q -t blacklist -T add -f /var/db/blacklist.txt"); - log_error("spamd: {$srcip} has been blacklisted by {$_SERVER['REMOTE_ADDR']} {$loginname}"); - exit; - } else if($action == "trapped") { - delete_from_spamd_db($srcip); - delete_from_whitelist($srcip); - usleep(100); - exec("/usr/local/sbin/spamdb -a {$srcip} -t"); - add_to_blacklist($srcip); - log_error("spamd: {$srcip} has been trapped by {$_SERVER['REMOTE_ADDR']} {$loginname}"); - hup_spamd(); - exit; - } - /* signal a reload for real time effect. */ - hup_spamd(); - exit; -} - -/* spam trap e-mail address */ -if($_POST['spamtrapemail'] <> "") { - $spamtrapemail = escapeshellarg($_POST['spamtrapemail']); - exec("/usr/local/sbin/spamdb -d {$spamtrapemail}"); - exec("/usr/local/sbin/spamdb -d -T \"{$spamtrapemail}\""); - exec("/usr/local/sbin/spamdb -d -t \"{$spamtrapemail}\""); - mwexec("/usr/local/sbin/spamdb -T -a \"{$spamtrapemail}\""); - mwexec("killall -HUP spamlogd"); - $savemsg = htmlentities($_POST['spamtrapemail']) . " added to spam trap database."; -} - -if($_GET['getstatus'] <> "") { - $getstatus = escapeshellarg($_GET['getstatus']); - $status = exec("/usr/local/sbin/spamdb | grep \"{$getstatus}\""); - if(stristr($status, "WHITE") == true) { - echo "WHITE"; - } else if(stristr($status, "TRAPPED") == true) { - echo "TRAPPED"; - } else if(stristr($status, "GREY") == true) { - echo "GREY"; - } else if(stristr($status, "SPAMTRAP") == true) { - echo "SPAMTRAP"; - } else { - echo "NOT FOUND"; - } - exit; -} - -/* spam trap e-mail address */ -if($_GET['spamtrapemail'] <> "") { - $spamtrapemail = escapeshellarg($_GET['spamtrapemail']); - $status = exec("spamdb -T -a \"{$spamtrapemail}\""); - mwexec("killall -HUP spamlogd"); - if($status) - echo $status; - else - echo htmlentities($_POST['spamtrapemail']) . " added to spam trap database."; - exit; -} - -/* spam trap e-mail address */ -if($_GET['whitelist'] <> "") { - $spamtrapemail = escapeshellarg($_GET['spamtrapemail']); - $status = exec("spamdb -a \"{$spamtrapemail}\""); - mwexec("killall -HUP spamlogd"); - if($status) - echo $status; - else - echo htmlentities($_POST['spamtrapemail']) . " added to whitelist database."; - exit; -} - -function delete_from_spamd_db($srcip) { - config_lock(); - $fd = fopen("/tmp/execcmds", "w"); - fwrite($fd, "#!/bin/sh\n"); - fwrite($fd, "/usr/local/sbin/spamdb -d {$srcip}\n"); - fwrite($fd, "/usr/local/sbin/spamdb -d {$srcip} -T\n"); - fwrite($fd, "/usr/local/sbin/spamdb -d {$srcip} -t\n"); - fwrite($fd, "/usr/local/sbin/spamdb -d \"{$srcip}\" -t\n"); - fwrite($fd, "/usr/local/sbin/spamdb -d \"{$srcip}\" -T\n"); - fclose($fd); - exec("/bin/chmod a+rx /tmp/execcmds"); - system("/bin/sh /tmp/execcmds"); - mwexec("/usr/bin/killall -HUP spamlogd"); - mwexec("/sbin/pfctl -q -t blacklist -T replace -f /var/db/blacklist.txt"); - config_unlock(); -} - -function basic_auth_prompt(){ - header("WWW-Authenticate: Basic realm=\".\""); - header("HTTP/1.0 401 Unauthorized"); - echo "You must enter valid credentials to access this resource."; - exit; -} - -function add_to_blacklist($srcip) { - config_lock(); - $fd = fopen("/var/db/blacklist.txt", "a"); - fwrite($fd, "{$srcip}\n"); - fclose($fd); - mwexec("/sbin/pfctl -q -t spamd -T add -f /var/db/blacklist.txt"); - mwexec("/sbin/pfctl -q -t blacklist -T add -f /var/db/blacklist.txt"); - config_unlock(); -} - -function delete_from_blacklist($srcip) { - config_lock(); - $blacklist = split("\n", file_get_contents("/var/db/blacklist.txt")); - $fd = fopen("/var/db/blacklist.txt", "w"); - foreach($blacklist as $bl) { - if($bl <> "") - if(!stristr($bl, $srcip)) - fwrite($fd, "{$bl}\n"); - } - fclose($fd); - mwexec("/sbin/pfctl -q -t spamd -T delete $srcip"); - mwexec("/sbin/pfctl -q -t blacklist -T replace -f /var/db/blacklist.txt"); - config_unlock(); -} - -function delete_from_whitelist($srcip) { - config_lock(); - $whitelist = split("\n", file_get_contents("/var/db/whitelist.txt")); - $fd = fopen("/var/db/whitelist.txt", "w"); - foreach($whitelist as $wl) { - if($wl <> "") - if(!stristr($wl, $srcip)) - fwrite($fd, "{$wl}\n"); - } - fclose($fd); - mwexec("/sbin/pfctl -q -t spamd -T delete $srcip"); - mwexec("/sbin/pfctl -q -t whitelist -T replace -f /var/db/whitelist.txt"); - config_unlock(); -} - -function hup_spamd() { - mwexec("killall -HUP spamlogd"); -} - -exit; - -?> \ No newline at end of file diff --git a/config/spamd_exchexp.asp b/config/spamd_exchexp.asp deleted file mode 100644 index 56b0c629..00000000 --- a/config/spamd_exchexp.asp +++ /dev/null @@ -1,50 +0,0 @@ -<% - -dim server -server = "SERVERNAME" - -Sub ExportUsers(oObject) - Dim oUser - For Each oUser in oObject - Select Case oUser.Class - Case "user" - If oUser.mail <> "" then - - for each email in oUser.proxyAddresses - If (lcase(left(email,4))="smtp") Then - 'userFile.WriteLine Mid(email,6) - document.write Mid(email,6) & vbCrLf - End If - next - End if - Case "organizationalUnit" , "container" - If UsersinOU (oUser) then - ExportUsers(oUser) - End if - End select - Next -End Sub - -Function UsersinOU (oObject) - Dim oUser - UsersinOU = False - for Each oUser in oObject - Select Case oUser.Class - Case "organizationalUnit" , "container" - UsersinOU = UsersinOU(oUser) - Case "user" - UsersinOU = True - - End select - Next -End Function - -Dim rootDSE, domainObject -Set rootDSE=GetObject("LDAP://" & server & "/RootDSE") -domainContainer = rootDSE.Get("defaultNamingContext") -Set domainObject = GetObject("LDAP://" & domainContainer) - -ExportUsers(domainObject) -Set oDomain = Nothing - -%> \ No newline at end of file diff --git a/config/spamd_gather_stats.php b/config/spamd_gather_stats.php deleted file mode 100644 index a95e2596..00000000 --- a/config/spamd_gather_stats.php +++ /dev/null @@ -1,82 +0,0 @@ -#!/usr/local/bin/php -q - - \ No newline at end of file diff --git a/config/spamd_outlook.xml b/config/spamd_outlook.xml deleted file mode 100644 index 5e94701f..00000000 --- a/config/spamd_outlook.xml +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - . - 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. - */ -/* ========================================================================== */ - ]]> - - Describe your package here - Describe your package requirements here - Currently there are no FAQ items provided. - spamdoutlook - 0.1.0 - SpamD Outlook - pkg_edit.php?xml=spamd_outlook.xml&id=0 - - - SpamD External Sources - /pkg.php?xml=spamd.xml - - - SpamD Whitelist - /pkg.php?xml=spamd_whitelist.xml - - - SpamD Settings - /pkg_edit.php?xml=spamd_settings.xml&id=0 - - - SpamD Database - /spamd_db.php - - - - ['installedpackages']['spamd']['config'] - - - - Username - username - Enter the username the outlook clients will use to connect with. - input - - - Password - password - Enter the password the outlook clients will use to connect with. - password - - - - \ No newline at end of file diff --git a/config/spamd_rules.php b/config/spamd_rules.php deleted file mode 100644 index 27ac850a..00000000 --- a/config/spamd_rules.php +++ /dev/null @@ -1,34 +0,0 @@ - -/* - spamd_rules.inc - part of pfSense (www.pfSense.com) - Copyright (C) 2004 Scott Ullrich (sullrich@gmail.com) - 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. -*/ -$wanif = get_real_wan_interface(); -$anchor = "natearly"; -$natrules .= "rdr pass on {$wanif} proto tcp from to port smtp -> 127.0.0.1 port spamd\n"; -$natrules .= "rdr pass on {$wanif} proto tcp from ! to port smtp -> 127.0.0.1 port spamd\n"; -$label = "spamd"; -add_rule_to_anchor($anchor, $rule, $label); diff --git a/config/spamd_settings.xml b/config/spamd_settings.xml deleted file mode 100644 index 95c343d1..00000000 --- a/config/spamd_settings.xml +++ /dev/null @@ -1,192 +0,0 @@ - - - - - - - - Describe your package here - Describe your package requirements here - Currently there are no FAQ items provided. - spamdsettings - 0.1.0 - SpamD Settings - pkg_edit.php?xml=spamd_settings.xml&id=0 - /usr/local/pkg/spamd.inc - -

- SpamD -
Services
- spamd.xml -
- - spamd - spamd.sh - - - - SpamD External Sources - /pkg.php?xml=spamd.xml - - - SpamD Whitelist - /pkg.php?xml=spamd_whitelist.xml - - - SpamD Settings - /pkg_edit.php?xml=spamd_settings.xml&id=0 - - - - SpamD Database - /spamd_db.php - - - - ['installedpackages']['spamd']['config'] - - - - Identifier - identifier - The SMTP version banner that is reported upon initial connection. - input - - - Maximum blacklisted connections - maxblack - The maximum number of concurrent blacklisted connections to allow in greylisting mode. This value may not be greater than maxcon (see below). The default is maxcon - 100. - input - - - Max concurrent connections - maxcon - The maximum number of concurrent connections to allow. The default is 800. - input - 800 - - - Grey listing - greylisting - Connections from addresses not blacklisted on the black lists tab will be considered for greylisting. Such connections will not be stuttered at (though see the stutter secs option) or delayed, and will receive the pleasantly innocuous temporary failure. After passtime if the host returns it will be added to the white list. - checkbox - yes - - - Passtime - passtime - Adjust the three time parameters for greylisting. Passtime defaults to 25 (minutes). After passtime minutes if spamd sees a retried attempt to deliver mail for the same tuple, spamd will whitelist the connecting address by adding it as a whitelist entry. - input - 30 - 25:4:864 - - - Grey Expiration - greyexp - Adjust the three time parameters for greylisting. Grey expiration defaults to 4. SpamD removes connection entries from the database if delivery has not been retried within greyexp hours from the initial time a connection is seen. - input - 30 - 25:4:864 - - - White Exp - whiteexp - Adjust the three time parameters for greylisting. White expiration defaults to 864 (hours, approximately 36 days). SpamD removes whitelist entries from the database if no mail delivery activity has been seen from the whitelisted address within whiteexp hours from the initial time an address is whitelisted. - input - 30 - 25:4:864 - - - Stutter Secs - stuttersecs - Stutter at greylisted connections for the specified amount of seconds, after which the connection is not stuttered at. Defaults to 10. - input - 10 - - - Delay Secs - delaysecs - Delay each character sent to the client by the specified amount of seconds. Defaults to 1. - input - 1 - - - Window Size - window - Set the socket receive buffer to this many bytes, adjusting the window size. - input - - - - - NextMTA - nextmta - Automatically sends messages after being processed by SpamD to IP Address. You may enter an alias if you like, simply prepend $ to the alias name. example: $mailservers. Note, if you have postfix package installed enter 127.0.0.1 here. - input - 1 - - - Enable RRD graphing - enablerrd - Enables the graphing of SpamD connection and disconnection statistics. - checkbox - - - - - spamd_validate_input($_POST, &$input_errors); - - - sync_package_spamd(); - - \ No newline at end of file diff --git a/config/spamd_verify_to_address.php b/config/spamd_verify_to_address.php deleted file mode 100644 index 56821370..00000000 --- a/config/spamd_verify_to_address.php +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/local/bin/php -q - from email addresses */ -for($x=0; isset($current_spamtrap[$x]); $x++) { - $current_spamtrap[$x] = str_replace("<", "", $current_spamtrap[$x]); - $current_spamtrap[$x] = str_replace(">", "", $current_spamtrap[$x]); -} - -/* traverse list and find the dictionary attackers, etc */ -foreach($grey_hosts as $grey) { - if(trim($grey) == "") - continue; - /* clean up and further break down values */ - $grey_lower = strtolower($grey); - $grey_lower = str_replace("<","",$grey_lower); - $grey_lower = str_replace(">","",$grey_lower); - $grey_split = split("\|", $grey_lower); - $email_from = strtolower($grey_split[2]); - $email_to = strtolower($grey_split[3]); - $server_ip = strtolower($grey_split[1]); - if(in_array($server_ip, $current_blacklist)) { - if($debug) - echo "$server_ip already in blacklist.\n"; - continue; - } - if(in_array($email_to, $current_spamtrap)) { - if($email_to) - echo "$email_to already in blacklist.\n"; - continue; - } - if($debug) - echo "Testing $email_from | $email_to \n"; - if (in_array($email_to, $valid_list)) { - if($debug) - echo "$email_to is in the valid list\n"; - } else { - /* spammer picked the wrong person to mess with */ - if($server_ip) { - if($debug) - echo "/usr/local/sbin/spamdb -a $server_ip -t\n"; - exec("/usr/local/sbin/spamdb -d {$server_ip} 2>/dev/null"); - exec("/usr/local/sbin/spamdb -d {$server_ip} -T 2>/dev/null"); - exec("/usr/local/sbin/spamdb -d {$server_ip} -t 2>/dev/null"); - if($debug) - echo "/usr/local/sbin/spamdb -a \"<$email_to>\" -T\n"; - exec("/usr/local/sbin/spamdb -a \"<$email_to>\" -T"); - config_lock(); - system("echo $server_ip >> /var/db/blacklist.txt"); - config_unlock(); - $result = mwexec("/usr/local/sbin/spamdb -a $server_ip -t"); - } else { - if($debug) - echo "Could not locate server ip address."; - } - if($debug) - echo "Script result code: {$result}\n"; - } -} - -mwexec("killall -HUP spamlogd"); - -if($debug) { - echo "\nSearch completed.\n\n"; - echo "Items trapped: "; - system("/usr/local/sbin/spamdb | grep TRAPPED | wc -l"); - echo "Items spamtrapped: "; - system("/usr/local/sbin/spamdb | grep SPAMTRAP | wc -l"); - echo "Items in blacklist.txt: "; - system("/sbin/pfctl -t blacklist -T show | wc -l"); -} - -mwexec("/sbin/pfctl -q -t blacklist -T replace -f /var/db/blacklist.txt"); - -?> \ No newline at end of file diff --git a/config/spamd_whitelist.xml b/config/spamd_whitelist.xml deleted file mode 100644 index f7b3f4fe..00000000 --- a/config/spamd_whitelist.xml +++ /dev/null @@ -1,132 +0,0 @@ - - - - - - . - 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. - */ -/* ========================================================================== */ - ]]> - - Describe your package here - Describe your package requirements here - Currently there are no FAQ items provided. - spamd-whitelist - 0.1.0 - SpamD: Whitelist - - - SpamD Whitelist - -
Services
- spamd.xml -
- - - SpamD External Sources - /pkg.php?xml=spamd.xml - - - SpamD Whitelist - /pkg.php?xml=spamd_whitelist.xml - - - - SpamD Settings - /pkg_edit.php?xml=spamd_settings.xml&id=0 - - - SpamD Database - /spamd_db.php - - - - ['installedpackages']['spamdwhitelist']['config'] - - - Exempted IP - ip - - - Description - description - - - - - - Exempted IP - ip - Enter the IP to exempt from blacklisting - input - - - Description - description - Enter the description for this item - input - - - - function sync_package_spamd_whitelist() { - global $config; - conf_mount_rw(); - config_lock(); - /* write out ip to the whitelist db */ - $fd = fopen("/var/db/whitelist.txt","w"); - if($config['installedpackages']['spamdwhitelist']['config'] != "") { - foreach($config['installedpackages']['spamdwhitelist']['config'] as $spamd) { - fwrite($fd, $spamd['ip'] . "\n"); - } - } - fclose($fd); - /* signal a reload of all files */ - mwexec("/usr/bin/killall -HUP spamlogd"); - mwexec("/sbin/pfctl -t spamd-white -T add {$spamd['ip']}"); - conf_mount_ro(); - config_unlock(); - } - - - sync_package_spamd_whitelist(); - - - sync_package_spamd_whitelist(); - -
\ No newline at end of file -- cgit v1.2.3 From a159da66b30e9301982bf5fa2c6b572d043534e8 Mon Sep 17 00:00:00 2001 From: Ermal Date: Tue, 23 Mar 2010 15:06:58 +0000 Subject: Do the right and safe command to allow spamd to modify pf ruleset in 2.0. --- config/spamd/spamd.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'config') diff --git a/config/spamd/spamd.inc b/config/spamd/spamd.inc index 8747df29..6a078682 100644 --- a/config/spamd/spamd.inc +++ b/config/spamd/spamd.inc @@ -245,7 +245,7 @@ function custom_php_install_command() { system("touch /var/db/whitelist.txt"); system("touch /var/db/blacklist.txt"); sync_package_spamd(); - exec("pw user mod_spamd -u 0"); + exec("pw usermod _spamd -g proxy -G _spamd,proxy"); } function custom_php_deinstall_command() { @@ -320,4 +320,4 @@ function spamd_validate_input($post, $input_errors) { } } -?> \ No newline at end of file +?> -- cgit v1.2.3 From bb9049d981971cf03fd39370ba7e14db549634fb Mon Sep 17 00:00:00 2001 From: Ermal Date: Tue, 23 Mar 2010 15:07:38 +0000 Subject: Use full path. --- config/spamd/spamd.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config') diff --git a/config/spamd/spamd.inc b/config/spamd/spamd.inc index 6a078682..c33e589c 100644 --- a/config/spamd/spamd.inc +++ b/config/spamd/spamd.inc @@ -245,7 +245,7 @@ function custom_php_install_command() { system("touch /var/db/whitelist.txt"); system("touch /var/db/blacklist.txt"); sync_package_spamd(); - exec("pw usermod _spamd -g proxy -G _spamd,proxy"); + exec("/usr/sbin/pw usermod _spamd -g proxy -G _spamd,proxy"); } function custom_php_deinstall_command() { -- cgit v1.2.3 From 399ca88cb617836fdbf08fd0288200ec74541c3f Mon Sep 17 00:00:00 2001 From: Ermal Date: Tue, 23 Mar 2010 15:34:21 +0000 Subject: Enable spamd package on 2.0 fix several paths with the move of files to the new directory also unlink the previous configuration file before linking anew one. --- config/spamd/spamd.inc | 4 ++++ config/spamd/spamd.xml | 16 ++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'config') diff --git a/config/spamd/spamd.inc b/config/spamd/spamd.inc index c33e589c..e6b89051 100644 --- a/config/spamd/spamd.inc +++ b/config/spamd/spamd.inc @@ -153,6 +153,7 @@ function sync_package_spamd() { log_error("Restart cron"); mwexec("killall -HUP cron"); log_error("Setting up spamd.conf symlink"); + mwexec("rm -f /usr/local/etc/spamd/spamd.conf"); mwexec("ln -s /etc/spamd.conf /usr/local/etc/spamd/spamd.conf"); log_error("Stopping spamd"); mwexec("/usr/local/etc/rc.d/spamd.sh stop"); @@ -245,7 +246,10 @@ function custom_php_install_command() { system("touch /var/db/whitelist.txt"); system("touch /var/db/blacklist.txt"); sync_package_spamd(); + conf_mount_rw(); exec("/usr/sbin/pw usermod _spamd -g proxy -G _spamd,proxy"); + exec("/bin/cp /usr/local/etc/spamd/spamd.conf.sample /usr/local/etc/spamd/spamd.conf"); + conf_mount_ro(); } function custom_php_deinstall_command() { diff --git a/config/spamd/spamd.xml b/config/spamd/spamd.xml index 5bbc5d71..b03cd737 100644 --- a/config/spamd/spamd.xml +++ b/config/spamd/spamd.xml @@ -95,42 +95,42 @@ /usr/local/www/ 0755 - http://www.pfsense.com/packages/config/spamd_rules.php + http://www.pfsense.com/packages/config/spamd/spamd_rules.php /usr/local/pkg/ 0755 - http://www.pfsense.com/packages/config/spamd_whitelist.xml + http://www.pfsense.com/packages/config/spamd/spamd_whitelist.xml /usr/local/pkg/ 0755 - http://www.pfsense.com/packages/config/spamd_outlook.xml + http://www.pfsense.com/packages/config/spamd/spamd_outlook.xml /usr/local/pkg/ 0755 - http://www.pfsense.com/packages/config/spamd.inc + http://www.pfsense.com/packages/config/spamd/spamd.inc /usr/local/pkg/ 0755 - http://www.pfsense.com/packages/config/spamd_settings.xml + http://www.pfsense.com/packages/config/spamd/spamd_settings.xml /usr/local/www/ 0755 - http://www.pfsense.com/packages/config/spamd_db.php + http://www.pfsense.com/packages/config/spamd/spamd_db.php /usr/local/www/ 0755 - http://www.pfsense.com/packages/config/spamd_db_ext.php + http://www.pfsense.com/packages/config/spamd/spamd_db_ext.php /usr/local/bin/ 0755 - http://www.pfsense.com/packages/config/spamd_gather_stats.php + http://www.pfsense.com/packages/config/spamd/spamd_gather_stats.php - - +. + 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"); + +header("snort_help_info.php"); +header( "Expires: Mon, 20 Dec 1998 01:00:00 GMT" ); +header( "Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT" ); +header( "Cache-Control: no-cache, must-revalidate" ); +header( "Pragma: no-cache" ); + +$pgtitle = "Snort: Services: Help and Info"; +include('head.inc'); +?> + + + + + + + + +
+ +
+
+ +
+
+ Snort is a registered trademark of Sourcefire, Inc., Barnyard2 is a registered trademark of securixlive.com, Orion copyright Robert Zelaya, + Emergingthreats is a registered trademark of emergingthreats.net, Mysql is a registered trademark of Mysql.com. +
+ + + + + diff --git a/config/snort-dev/snort_interfaces.php b/config/snort-dev/snort_interfaces.php index b5bb7781..aebaba00 100644 --- a/config/snort-dev/snort_interfaces.php +++ b/config/snort-dev/snort_interfaces.php @@ -29,29 +29,37 @@ POSSIBILITY OF SUCH DAMAGE. */ -require("guiconfig.inc"); -require("/usr/local/pkg/snort/snort_gui.inc"); -include_once("/usr/local/pkg/snort/snort.inc"); +require_once("guiconfig.inc"); +require_once("/usr/local/pkg/snort/snort_gui.inc"); +require_once("/usr/local/pkg/snort/snort.inc"); + +/* firephp */ +require_once('../FirePHPCore/FirePHP.class.php4'); +require_once('../FirePHPCore/fb.php4'); +ob_start(); +$firephp =& FirePHP::getInstance(true); +$firephp->setEnabled(true); + +fb('Hello, world', FirePHP); +/* firephp end */ + $id = $_GET['id']; if (isset($_POST['id'])) $id = $_POST['id']; + if (!is_array($config['installedpackages']['snortglobal']['rule'])) $config['installedpackages']['snortglobal']['rule'] = array(); $a_nat = &$config['installedpackages']['snortglobal']['rule']; -/////////// - if (isset($config['installedpackages']['snortglobal']['rule'])) { $id_gen = count($config['installedpackages']['snortglobal']['rule']); }else{ $id_gen = '0'; } -/////////// - /* if a custom message has been passed along, lets process it */ if ($_GET['savemsg']) $savemsg = $_GET['savemsg']; @@ -180,67 +188,23 @@ if (isset($_POST['del_x'])) { /* start/stop snort */ -if ($_GET['act'] == "toggle" && $_GET['id'] != "") +if ($_GET['act'] == 'toggle' && $_GET['id'] != '') { - $if_real2 = convert_friendly_interface_to_real_interface_name($a_nat[$id]['interface']); + $if_real = convert_friendly_interface_to_real_interface_name($config['installedpackages']['snortglobal']['rule'][$id]['interface']); + $snort_uuid = $config['installedpackages']['snortglobal']['rule'][$id]['uuid']; - $snort_uuid = $a_nat[$id]['uuid']; + /* Log Iface stop */ + exec("/usr/bin/logger -p daemon.info -i -t SnortStartup 'Toggle for {$snort_uuid}_{$if_real}...'"); - $start_up_pre = exec("/usr/bin/top -a -U snort -u | grep -v grep | grep \"R {$snort_uuid}_{$if_real2}\" | awk '{print \$1;}'"); - $start_up_s = exec("/usr/bin/top -U snort -u | grep snort | grep {$start_up_pre} | awk '{ print $1; }'"); - $start_up_r = exec("/usr/bin/top -U root -u | grep snort | grep {$start_up_pre} | awk '{ print $1; }'"); - - //$start2_upb_pre = exec("/bin/cat /var/run/barnyard2_{$id}{$if_real2}.pid"); - //$start2_upb_s = exec("/usr/bin/top -U snort -u | grep barnyard2 | grep {$start2_upb_pre} | awk '{ print $1; }'"); - //$start2_upb_r = exec("/usr/bin/top -U root -u | grep barnyard2 | grep {$start2_upb_pre} | awk '{ print $1; }'"); - - - if ($start_up_s != "" || $start_up_r != "" || $start2_upb_s != "" || $start2_upb_r != "") - { + $tester2 = Running_Ck($snort_uuid, $if_real, $id); - /* stop syslog flood code */ - //exec("/bin/cp /var/log/system.log /var/log/system.log.bk"); - //sleep(3); - - if ($start_up_s != "") - { - exec("/bin/kill {$start_up_s}"); - exec("/bin/rm /var/run/snort_{$snort_uuid}_{$if_real2}*"); - } - - //if ($start2_upb_s != "") - //{ - //exec("/bin/kill {$start2_upb_s}"); - //exec("/bin/rm /var/run/barnyard2_$id$if_real2*"); - //} - - if ($start_up_r != "") - { - exec("/bin/kill {$start_up_r}"); - exec("/bin/rm /var/run/snort_{$snort_uuid}_{$if_real2}*"); - } - - //if ($start2_upb_r != "") - //{ - //exec("/bin/kill {$start2_upb_r}"); - //exec("/bin/rm /var/run/barnyard2_$id$if_real2*"); - //} - - /* stop syslog flood code */ - $if_real_wan_id = $a_nat[$id]['interface']; - $if_real_wan_id2 = convert_friendly_interface_to_real_interface_name2($if_real_wan_id); - exec("/sbin/ifconfig $if_real_wan_id2 -promisc"); - //exec("/bin/cp /var/log/system.log /var/log/snort/snort_sys_$id$if_real2.log"); - //exec("/usr/bin/killall syslogd"); - //exec("/usr/sbin/clog -i -s 262144 /var/log/system.log"); - //exec("/usr/sbin/syslogd -c -ss -f /var/etc/syslog.conf"); - //sleep(2); - //exec("/bin/cp /var/log/system.log.bk /var/log/system.log"); - //$after_mem2 = exec("/usr/bin/top | /usr/bin/grep Wired | /usr/bin/awk '{ print $2 }'"); - //exec("/usr/bin/logger -p daemon.info -i -t SnortStartup 'MEM after {$id}{$if_real2} STOP {$after_mem2}'"); - //exec("/usr/bin/logger -p daemon.info -i -t SnortStartup 'Interface Rule STOP for {$id}{$if_real2}...'"); + if ($tester2 == 'yes') { + /* Log Iface stop */ + exec("/usr/bin/logger -p daemon.info -i -t SnortStartup '{$tester2} yn for {$snort_uuid}_{$if_real}...'"); + + Running_Stop($snort_uuid, $if_real, $id); header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' ); header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); @@ -251,11 +215,12 @@ if ($_GET['act'] == "toggle" && $_GET['id'] != "") header("Location: /snort/snort_interfaces.php"); }else{ - //sync_snort_package_all(); - - exec("/usr/local/bin/snort -u snort -g snort -R \"{$snort_uuid}_{$if_real2}\" -D -q -l /var/log/snort -G {$snort_uuid} -c /usr/local/etc/snort/snort_{$snort_uuid}_{$if_real2}/snort.conf -i {$if_real2}"); - //print_r("$id $if_real2"); - + + sync_snort_package_all($id, $if_real); + sync_snort_package(); + + Running_Start($snort_uuid, $if_real, $id); + 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' ); @@ -264,10 +229,11 @@ if ($_GET['act'] == "toggle" && $_GET['id'] != "") sleep(2); header("Location: /snort/snort_interfaces.php"); } +} + -} -$pgtitle = "Services: Snort 2.8.5.3 pkg v. 1.15 Beta"; +$pgtitle = "Services: Snort 2.8.5.3 pkg v. 1.17 RC Final"; include("head.inc"); ?> @@ -309,30 +275,13 @@ padding: 15px 10px 50% 50px; padding-top: 4px; padding-bottom: 4px; } -#footer2 -{ - position: relative; - //top: 135px; - top: -17px; - background-color: #cccccc; - background-image: none; - background-repeat: repeat; - background-attachment: scroll; - background-position: 0% 0%; - padding-top: 0px; - padding-right: 0px; - padding-bottom: 0px; - padding-left: 10px; - //padding-left: 0px; - clear: both; -} -
+

@@ -464,15 +399,13 @@ padding: 15px 10px 50% 50px;

Log to a Tcpdump file onClick="enable_change(false)">
- Snort will log packets to a tcpdump-formatted file. The file then can be analyzed by an application such as Wireshark which understands pcap file formats. WARNING: File may become large.
Log Alerts to a snort unified2 file
Associate events on Blocked tab - onClick="enable_change(false)">
- Checking this option will automatically associate the blocked reason from the snort alerts file.
  - +
Enable
FTP & Telnet Normalizer
Enable
FTP and Telnet Normalizer
onClick="enable_change(false)">
- Normalize/Decode FTP & Telnet traffic and protocol anomalies.
Enable
SMTP Normalizer
@@ -590,7 +591,8 @@ function popup(url) $textss\n"; ?> - onClick="enable_change(false)"> + + @@ -662,7 +664,8 @@ function popup(url)
- + +
	
- - - -
-
- - - - - -
- -
- : - /> - - /> - -
- - - - -
-
- - -
-
- - - - -
-
- - -
-
- -
-
- - - - - - - - - - - - - - - - - +#!/usr/local/bin/php + "") { + if($_POST['highlight'] == "yes" or + $_POST['highlight'] == "enabled") { + $highlight = "yes"; + } else { + $highlight = "no"; + } +} else { + $highlight = "no"; +} + +if($_POST['rows'] <> "") + $rows = $_POST['rows']; +else + $rows = 1; + +if($_POST['cols'] <> "") + $cols = $_POST['cols']; +else + $cols = 66; + +if ($_POST) +{ + if ($_POST['save']) { + + /* get the changes */ + $rule_content2 = $_POST['code']; + + //copy string into file array for writing + $splitcontents[$lineid] = $rule_content2; + + //write the new .rules file + write_rule_file($splitcontents, $file); + + header("Location: /snort/snort_rules_edit.php?id=$id&openruleset=$file&ids=$ids"); + + } +} + +$pgtitle = array(gettext("Advanced"), gettext("File Editor")); + +// +?> + + + + + + + + +
+
+ + + + + +
+ +
+ : + /> + + /> + +
+ + + + +
+
+ + +
+
+ + + + +
+
+ + +
+
+ +
+
+ + + + + + + + + + + + + + + + + diff --git a/config/snort-dev/snort_rulesets.php b/config/snort-dev/snort_rulesets.php index dc3320fe..da8f6646 100644 --- a/config/snort-dev/snort_rulesets.php +++ b/config/snort-dev/snort_rulesets.php @@ -33,7 +33,15 @@ require_once("filter.inc"); require_once("service-utils.inc"); include_once("/usr/local/pkg/snort/snort.inc"); +/* firephp*/ +require_once('../FirePHPCore/FirePHP.class.php'); +require_once('../FirePHPCore/fb.php'); +ob_start(); +$firephp =& FirePHP::getInstance(true); +$firephp->setEnabled(true); +fb('Hello, world', FirePHP); +/* firephp end */ if (!is_array($config['installedpackages']['snortglobal']['rule'])) { $config['installedpackages']['snortglobal']['rule'] = array(); @@ -57,16 +65,12 @@ if (isset($id) && $a_nat[$id]) { /* convert fake interfaces to real */ $if_real = convert_friendly_interface_to_real_interface_name($pconfig['interface']); -//if(!is_dir("/usr/local/etc/snort/rules")) -// exec('mkdir /usr/local/etc/snort/rules/'); $iface_uuid = $a_nat[$id]['uuid']; $pgtitle = "Snort: Interface $id $iface_uuid $if_real Categories"; - - /* Check if the rules dir is empy if so warn the user */ /* TODO give the user the option to delete the installed rules rules */ $isrulesfolderempty = exec("ls -A /usr/local/etc/snort/snort_{$iface_uuid}_{$if_real}/rules/*.rules"); @@ -77,12 +81,12 @@ include("fbegin.inc"); echo "

"; if($pfsense_stable == 'yes'){echo $pgtitle;} +fb($pfsense_stable, FirePHP); echo "

\n"; echo ""; -echo "\n -\n +echo " \n \n - -
\n"; @@ -143,10 +147,15 @@ if($_POST) { } $a_nat[$id]['rulesets'] = $enabled_items; write_config(); -// stop_service("snort"); -// create_snort_conf(); -// sleep(2); -// start_service("snort"); + 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' ); + header( 'Cache-Control: post-check=0, pre-check=0', false ); + header( 'Pragma: no-cache' ); + sleep(2); + sync_snort_package_all(); + fb("$id, $if_real", FirePHP); + header("Location: /snort/snort_rulesets.php?id=$id"); $savemsg = "The snort ruleset selections have been saved."; } @@ -160,15 +169,13 @@ include("head.inc"); -

+

"; ?> - - @@ -221,7 +228,7 @@ echo ""; echo ""; echo ""; //echo "", "
"; - echo "{$file}"; + echo "{$file}"; echo ""; //echo "description"; -- cgit v1.2.3 From e964dde401ede7b68a07333d01ff80b45b684aba Mon Sep 17 00:00:00 2001 From: Ermal Date: Thu, 25 Mar 2010 19:29:03 +0000 Subject: Fix typo --- config/openospfd/openospfd.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config') diff --git a/config/openospfd/openospfd.inc b/config/openospfd/openospfd.inc index 3e3c42cb..0a5ef351 100644 --- a/config/openospfd/openospfd.inc +++ b/config/openospfd/openospfd.inc @@ -178,7 +178,7 @@ function ospfd_install_conf() { // ospfd process running? if so reload, elsewise start. $oarray = array(); $rval = 0; - exec("/usr/local/sbin/ospfctl reload", , $oarray, $rval); + exec("/usr/local/sbin/ospfctl reload", $oarray, $rval); if ($rval != 0) { /* * ospfd isnt actually running as nothing accepted a connection -- cgit v1.2.3 From 0628f8885994494ff5823e688ced8bffcf909375 Mon Sep 17 00:00:00 2001 From: robiscool Date: Thu, 25 Mar 2010 13:26:39 -0700 Subject: snort-dev, remove firephp trace code --- config/snort-dev/snort.xml | 2 +- config/snort-dev/snort_interfaces.php | 10 ---------- config/snort-dev/snort_interfaces_edit.php | 13 ------------- config/snort-dev/snort_rulesets.php | 11 ----------- 4 files changed, 1 insertion(+), 35 deletions(-) (limited to 'config') diff --git a/config/snort-dev/snort.xml b/config/snort-dev/snort.xml index 36659a11..06b0b7de 100644 --- a/config/snort-dev/snort.xml +++ b/config/snort-dev/snort.xml @@ -71,7 +71,7 @@ /usr/local/bin/ 077 - http://www.pfsense.com/packages/config/snort-dev/bin/7.2.x86/barnyard2 + http://www.pfsense.com/packages/config/snort-dev/bin/8.0.x86/barnyard2 /usr/local/bin/ diff --git a/config/snort-dev/snort_interfaces.php b/config/snort-dev/snort_interfaces.php index aebaba00..f4a73f16 100644 --- a/config/snort-dev/snort_interfaces.php +++ b/config/snort-dev/snort_interfaces.php @@ -33,16 +33,6 @@ require_once("guiconfig.inc"); require_once("/usr/local/pkg/snort/snort_gui.inc"); require_once("/usr/local/pkg/snort/snort.inc"); -/* firephp */ -require_once('../FirePHPCore/FirePHP.class.php4'); -require_once('../FirePHPCore/fb.php4'); -ob_start(); -$firephp =& FirePHP::getInstance(true); -$firephp->setEnabled(true); - -fb('Hello, world', FirePHP); -/* firephp end */ - $id = $_GET['id']; if (isset($_POST['id'])) diff --git a/config/snort-dev/snort_interfaces_edit.php b/config/snort-dev/snort_interfaces_edit.php index 0a5ce90d..416b4a8e 100644 --- a/config/snort-dev/snort_interfaces_edit.php +++ b/config/snort-dev/snort_interfaces_edit.php @@ -33,18 +33,6 @@ require_once("guiconfig.inc"); require_once("/usr/local/pkg/snort/snort.inc"); -/* firephp*/ -require_once('../FirePHPCore/FirePHP.class.php'); -require_once('../FirePHPCore/fb.php'); -ob_start(); -$firephp =& FirePHP::getInstance(true); -$firephp->setEnabled(true); - -fb('Hello, world', FirePHP); -/* firephp end */ - - - if (!is_array($config['installedpackages']['snortglobal']['rule'])) { $config['installedpackages']['snortglobal']['rule'] = array(); } @@ -79,7 +67,6 @@ $snort_uuid = 0; while ($snort_uuid > 65535 || $snort_uuid == 0) { $snort_uuid = mt_rand(1, 65535); $pconfig['uuid'] = $snort_uuid; - fb($snort_uuid, LOG); } } diff --git a/config/snort-dev/snort_rulesets.php b/config/snort-dev/snort_rulesets.php index da8f6646..172780b6 100644 --- a/config/snort-dev/snort_rulesets.php +++ b/config/snort-dev/snort_rulesets.php @@ -33,15 +33,6 @@ require_once("filter.inc"); require_once("service-utils.inc"); include_once("/usr/local/pkg/snort/snort.inc"); -/* firephp*/ -require_once('../FirePHPCore/FirePHP.class.php'); -require_once('../FirePHPCore/fb.php'); -ob_start(); -$firephp =& FirePHP::getInstance(true); -$firephp->setEnabled(true); - -fb('Hello, world', FirePHP); -/* firephp end */ if (!is_array($config['installedpackages']['snortglobal']['rule'])) { $config['installedpackages']['snortglobal']['rule'] = array(); @@ -81,7 +72,6 @@ include("fbegin.inc"); echo "

"; if($pfsense_stable == 'yes'){echo $pgtitle;} -fb($pfsense_stable, FirePHP); echo "

\n"; echo ""; @@ -154,7 +144,6 @@ if($_POST) { header( 'Pragma: no-cache' ); sleep(2); sync_snort_package_all(); - fb("$id, $if_real", FirePHP); header("Location: /snort/snort_rulesets.php?id=$id"); $savemsg = "The snort ruleset selections have been saved."; } -- cgit v1.2.3 From 1fd19a93e04e47fda72abf7246d061221e6b173a Mon Sep 17 00:00:00 2001 From: Eugene Date: Fri, 26 Mar 2010 03:24:35 +0000 Subject: NRPE2. It's impossible to stop/start/restart service from Services page. --- config/nrpe2/nrpe2.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config') diff --git a/config/nrpe2/nrpe2.xml b/config/nrpe2/nrpe2.xml index 61fadcaa..55f96319 100644 --- a/config/nrpe2/nrpe2.xml +++ b/config/nrpe2/nrpe2.xml @@ -14,7 +14,7 @@ /pkg_edit.php?xml=nrpe2.xml&id=0 - NRPEv2 + nrpe2 nrpe2 nrpe2 Nagios NRPE Daemon -- cgit v1.2.3 From 99f575d42eed225405233af5cc0231ca874dce50 Mon Sep 17 00:00:00 2001 From: robiscool Date: Fri, 26 Mar 2010 18:15:02 -0700 Subject: snort-dev, fixed link logo, fixed barnyard 7.2 8.0 download, see notes.txt --- config/snort-dev/NOTES.txt | 18 +- config/snort-dev/snort.xml | 6 +- config/snort-dev/snort_alerts.php | 2 +- config/snort-dev/snort_barnyard.php | 2 +- config/snort-dev/snort_blocked.php | 2 +- config/snort-dev/snort_define_servers.php | 2 +- config/snort-dev/snort_download_rules.php | 4 +- config/snort-dev/snort_fbegin.inc | 288 +++++++++++++++++++++++++++ config/snort-dev/snort_help_info.php | 2 +- config/snort-dev/snort_interfaces.php | 11 +- config/snort-dev/snort_interfaces_edit.php | 37 +++- config/snort-dev/snort_interfaces_global.php | 133 ++++++++++++- config/snort-dev/snort_preprocessors.php | 2 +- config/snort-dev/snort_rules.php | 4 +- config/snort-dev/snort_rulesets.php | 4 +- 15 files changed, 482 insertions(+), 35 deletions(-) create mode 100755 config/snort-dev/snort_fbegin.inc (limited to 'config') diff --git a/config/snort-dev/NOTES.txt b/config/snort-dev/NOTES.txt index 88c80cb2..b8c61c39 100644 --- a/config/snort-dev/NOTES.txt +++ b/config/snort-dev/NOTES.txt @@ -1,19 +1,17 @@ -March 16 2019 -Snort-dev 2.8.5.3 pk v. 12 Beta +March 26 2019 +Snort-dev 2.8.5.3 pk v. 18 final -Snort is Stoping/Starting with new UUID. Files are independent of rule order now. Ya me....... +Final day. -TODO: -The snort.sh code needs to be looked at and made sure there is a new file at every enabe/disbale save, -reboot, rule delete. +Odds and ends left. -The snort_interfaces.php needs speed inprovments. !inportant. - -Make sure I ad a reset button someware the removes all of snort-devs addd to config.xml +2.0 group snort gets lost on reboot. Pierre POMES code needs to be added. +Threshold tab needs to be added. + -Done. \ No newline at end of file +Done. diff --git a/config/snort-dev/snort.xml b/config/snort-dev/snort.xml index 06b0b7de..37ce9967 100644 --- a/config/snort-dev/snort.xml +++ b/config/snort-dev/snort.xml @@ -47,7 +47,7 @@ Currently there are no FAQ items provided. Snort 2.8.5.3 - Services: Snort 2.8.5.2 pkg v. 1.12 + Services: Snort 2.8.5.2 pkg v. 1.18 /usr/local/pkg/snort/snort.inc Snort @@ -69,9 +69,9 @@ http://www.pfsense.com/packages/config/snort-dev/snort.inc - /usr/local/bin/ + /usr/local/www/snort/ 077 - http://www.pfsense.com/packages/config/snort-dev/bin/8.0.x86/barnyard2 + http://www.pfsense.com/packages/config/snort-dev/snort_fbegin.inc /usr/local/bin/ diff --git a/config/snort-dev/snort_alerts.php b/config/snort-dev/snort_alerts.php index e2784974..4f0ddb03 100644 --- a/config/snort-dev/snort_alerts.php +++ b/config/snort-dev/snort_alerts.php @@ -311,7 +311,7 @@ include("head.inc"); "; if($pfsense_stable == 'yes'){echo $pgtitle;} diff --git a/config/snort-dev/snort_barnyard.php b/config/snort-dev/snort_barnyard.php index 94217ba9..8189e414 100644 --- a/config/snort-dev/snort_barnyard.php +++ b/config/snort-dev/snort_barnyard.php @@ -233,7 +233,7 @@ include("head.inc"); ?>

- + diff --git a/config/snort-dev/snort_interfaces.php b/config/snort-dev/snort_interfaces.php index f4a73f16..44e8aa3d 100644 --- a/config/snort-dev/snort_interfaces.php +++ b/config/snort-dev/snort_interfaces.php @@ -169,7 +169,7 @@ if (isset($_POST['del_x'])) { conf_mount_ro(); write_config(); - touch($d_natconfdirty_path); + //touch($d_natconfdirty_path); header("Location: /snort/snort_interfaces.php"); exit; } @@ -223,12 +223,12 @@ if ($_GET['act'] == 'toggle' && $_GET['id'] != '') -$pgtitle = "Services: Snort 2.8.5.3 pkg v. 1.17 RC Final"; +$pgtitle = "Services: Snort 2.8.5.3 pkg v. 1.18 RC Final"; include("head.inc"); ?> - +

+ +
+ \"Apps\" + Snort is a registered trademark of Sourcefire, Inc, Barnyard2 is a registered trademark of securixlive.com, Orion copyright Robert Zelaya, + Emergingthreats is a registered trademark of emergingthreats.net, Mysql is a registered trademark of Mysql.com +
\n"; +} + +if ($pfsense_stable != 'yes') { +$footer3 = " + + + +
+ Snort is a registered trademark of Sourcefire, Inc, Barnyard2 is a registered trademark of securixlive.com, Orion copyright Robert Zelaya, + Emergingthreats is a registered trademark of emergingthreats.net, Mysql is a registered trademark of Mysql.com +
\n"; +} +?> + +
-
- Snort is a registered trademark of Sourcefire, Inc., Barnyard2 is a registered trademark of securixlive.com, Orion copyright Robert Zelaya, - Emergingthreats is a registered trademark of emergingthreats.net, Mysql is a registered trademark of Mysql.com. -
+ + + + + +
matched above - (!tags.indexOf("", "
- + diff --git a/config/snort-dev/snort_interfaces_edit.php b/config/snort-dev/snort_interfaces_edit.php index 960da061..164f154a 100644 --- a/config/snort-dev/snort_interfaces_edit.php +++ b/config/snort-dev/snort_interfaces_edit.php @@ -32,6 +32,8 @@ require_once("guiconfig.inc"); require_once("/usr/local/pkg/snort/snort.inc"); +require_once("/usr/local/pkg/snort/snort_gui.inc"); + if (!is_array($config['installedpackages']['snortglobal']['rule'])) { $config['installedpackages']['snortglobal']['rule'] = array(); @@ -48,6 +50,7 @@ if (isset($_GET['dup'])) { $after = $_GET['dup']; } + /* always have a limit of (65535) numbers only or snort will not start do to id limits */ /* TODO: When inline gets added make the uuid the port number lisstening */ //function gen_snort_uuid($fileline) @@ -149,10 +152,40 @@ if (isset($id) && $a_nat[$id]) { if (isset($_GET['dup'])) unset($id); +/* alert file */ +$d_snortconfdirty_path = "/var/run/snort_conf_{$snort_uuid}_{$if_real}.dirty"; + + /* this will exec when alert says apply */ + if ($_POST['apply']) { + + if (file_exists("/var/run/snort_conf_{$snort_uuid}_.dirty")) { + + write_config(); + + sync_snort_package_empty(); + sync_snort_package(); + + unlink("/var/run/snort_conf_{$snort_uuid}_.dirty"); + + } + + if (file_exists($d_snortconfdirty_path)) { + + write_config(); + + sync_snort_package_all(); + sync_snort_package(); + + unlink($d_snortconfdirty_path); + + } + + } if ($_POST["Submit"]) { - + + // if ($config['installedpackages']['snortglobal']['rule']) { if ($_POST['descr'] == '' && $pconfig['descr'] == '') { $input_errors[] = "Please enter a description for your reference."; @@ -264,12 +297,9 @@ if ($_POST["Submit"]) { } write_config(); - - if ($pconfig['interface'] != "") { - sync_snort_package_all(); - } - //touch($d_natconfdirty_path); + touch("$d_snortconfdirty_path"); + 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' ); @@ -281,20 +311,6 @@ if ($_POST["Submit"]) { exit; } } - - if (isset($config['installedpackages']['snortglobal']['rule'][$id]['interface'])) - { - $snort_up_ck2_info = Running_Ck($snort_uuid, $if_real, $id); - if ($snort_up_ck2_info == 'no') - { - $snort_up_ck = ''; - }else{ - $snort_up_ck = ''; - } - }else{ - $snort_up_ck = ''; - } - if ($_POST["Submit2"]) { @@ -327,34 +343,22 @@ if ($_POST["Submit"]) { header("Location: /snort/snort_interfaces_edit.php?id=$id"); } - - if ($_POST["Reset"]) - { - conf_mount_rw(); + /* This code needs to be below headers */ + if (isset($config['installedpackages']['snortglobal']['rule'][$id]['interface'])) + { + + $snort_up_ck2_info = Running_Ck($snort_uuid, $if_real, $id); - Running_Stop($snort_uuid, $if_real, $id); - sleep(2); - - /* remove all snort iface dir */ - exec('rm -r /usr/local/etc/snort/snort_*'); - exec('rm /var/log/snort/*'); - - unset($config['installedpackages']['snortglobal']['rule'][$id]); - write_config(); - - 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' ); - header( 'Cache-Control: post-check=0, pre-check=0', false ); - header( 'Pragma: no-cache' ); - sleep(2); - header("Location: /snort/snort_interfaces_edit.php?id=$id"); + if ($snort_up_ck2_info == 'no') { + $snort_up_ck = ''; + }else{ + $snort_up_ck = ''; + } - conf_mount_ro(); - - } - + }else{ + $snort_up_ck = ''; + } $pgtitle = "Snort: Interface Edit: $id $snort_uuid $if_real"; @@ -407,9 +411,37 @@ echo "

- - + " method="post" enctype="multipart/form-data" name="iform" id="iform"> + +'; + + if($savemsg) { + print_info_box_np2("{$savemsg}"); + }else{ + print_info_box_np2(' + The Snort configuration has changed and snort needs to be restarted on this interface.
+ You must apply the changes in order for them to take effect.
+ '); + } + } + +?> +
     If Snort
- + ", "
 WARNING:
- This will reset this interface.
 
diff --git a/config/snort-dev/snort_interfaces_global.php b/config/snort-dev/snort_interfaces_global.php index e3d0daf5..ff3620a3 100644 --- a/config/snort-dev/snort_interfaces_global.php +++ b/config/snort-dev/snort_interfaces_global.php @@ -111,7 +111,11 @@ if ($_POST) { $savemsg = get_std_save_message($retval); } - } + + sync_snort_package_all(); + sync_snort_package(); + +} if ($_POST["Reset"]) { diff --git a/config/snort-dev/snort_preprocessors.php b/config/snort-dev/snort_preprocessors.php index 6e634891..c522a643 100644 --- a/config/snort-dev/snort_preprocessors.php +++ b/config/snort-dev/snort_preprocessors.php @@ -33,6 +33,7 @@ require_once("guiconfig.inc"); require_once("/usr/local/pkg/snort/snort.inc"); +require_once("/usr/local/pkg/snort/snort_gui.inc"); if (!is_array($config['installedpackages']['snortglobal']['rule'])) { $config['installedpackages']['snortglobal']['rule'] = array(); @@ -120,7 +121,29 @@ if (isset($_GET['dup'])) /* convert fake interfaces to real */ $if_real = convert_friendly_interface_to_real_interface_name($pconfig['interface']); -if ($_POST) { + + + /* alert file */ +$d_snortconfdirty_path = "/var/run/snort_conf_{$pconfig['uuid']}_{$if_real}.dirty"; + + /* this will exec when alert says apply */ + if ($_POST['apply']) { + + if (file_exists($d_snortconfdirty_path)) { + + write_config(); + + sync_snort_package_all(); + sync_snort_package(); + + unlink($d_snortconfdirty_path); + + } + + } + + + if ($_POST["Submit"]) { /* check for overlaps */ @@ -198,13 +221,16 @@ if ($_POST) { $a_nat[] = $natent; } - /* enable this if you want the user to aprove changes */ - // touch($d_natconfdirty_path); - sync_snort_package_all(); - write_config(); /* after click go to this page */ + touch($d_snortconfdirty_path); + 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' ); + header( 'Cache-Control: post-check=0, pre-check=0', false ); + header( 'Pragma: no-cache' ); + sleep(2); header("Location: snort_preprocessors.php?id=$id"); exit; } @@ -235,9 +261,35 @@ padding: 15px 10px 85% 50px; - - + +'; + + if($savemsg) { + print_info_box_np2("{$savemsg}"); + }else{ + print_info_box_np2(' + The Snort configuration has changed and snort needs to be restarted on this interface.
+ You must apply the changes in order for them to take effect.
+ '); + } + } + +?> + -- cgit v1.2.3 From bcbacd97b4c890c7d51352c43c4c8488d47b1619 Mon Sep 17 00:00:00 2001 From: jim-p Date: Wed, 31 Mar 2010 10:26:44 -0400 Subject: Fix squid for pfSense 2.0 on FreeBSD 8. There may still be a couple bugs hanging out there, but it installs, it runs, it caches, etc. --- config/squid-8/proxy_monitor.sh | 72 ++ config/squid-8/squid.inc | 1319 +++++++++++++++++++++++++++++++++++++ config/squid-8/squid.xml | 334 ++++++++++ config/squid-8/squid_auth.inc | 446 +++++++++++++ config/squid-8/squid_auth.xml | 225 +++++++ config/squid-8/squid_cache.xml | 224 +++++++ config/squid-8/squid_extauth.xml | 106 +++ config/squid-8/squid_nac.xml | 143 ++++ config/squid-8/squid_ng.inc | 1070 ++++++++++++++++++++++++++++++ config/squid-8/squid_ng.xml | 267 ++++++++ config/squid-8/squid_traffic.xml | 177 +++++ config/squid-8/squid_upstream.xml | 133 ++++ config/squid-8/squid_users.xml | 120 ++++ 13 files changed, 4636 insertions(+) create mode 100644 config/squid-8/proxy_monitor.sh create mode 100644 config/squid-8/squid.inc create mode 100644 config/squid-8/squid.xml create mode 100644 config/squid-8/squid_auth.inc create mode 100644 config/squid-8/squid_auth.xml create mode 100644 config/squid-8/squid_cache.xml create mode 100644 config/squid-8/squid_extauth.xml create mode 100644 config/squid-8/squid_nac.xml create mode 100644 config/squid-8/squid_ng.inc create mode 100644 config/squid-8/squid_ng.xml create mode 100644 config/squid-8/squid_traffic.xml create mode 100644 config/squid-8/squid_upstream.xml create mode 100644 config/squid-8/squid_users.xml (limited to 'config') diff --git a/config/squid-8/proxy_monitor.sh b/config/squid-8/proxy_monitor.sh new file mode 100644 index 00000000..fab2ee54 --- /dev/null +++ b/config/squid-8/proxy_monitor.sh @@ -0,0 +1,72 @@ +#!/bin/sh +# $Id$ */ +# +# proxy_monitor.sh +# Copyright (C) 2006 Scott Ullrich +# 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. +# + +set -e + +LOOP_SLEEP=55 + +if [ -f /var/run/squid_alarm ]; then + rm /var/run/squid_alarm +fi + +# Sleep 5 seconds on startup not to mangle with existing boot scripts. +sleep 5 + +# Squid monitor 1.2 +while [ /bin/true ]; do + if [ ! -f /var/run/squid_alarm ]; then + NUM_PROCS=`ps auxw | grep "[s]quid -D"|awk '{print $2}'| wc -l | awk '{ print $1 }'` + if [ $NUM_PROCS -lt 1 ]; then + # squid is down + echo "Squid has exited. Reconfiguring filter." | \ + logger -p daemon.info -i -t Squid_Alarm + echo "Attempting restart..." | logger -p daemon.info -i -t Squid_Alarm + /usr/local/etc/rc.d/squid.sh start + sleep 3 + echo "Reconfiguring filter..." | logger -p daemon.info -i -t Squid_Alarm + /etc/rc.filter_configure_sync + touch /var/run/squid_alarm + fi + fi + NUM_PROCS=`ps auxw | grep "[s]quid -D"|awk '{print $2}'| wc -l | awk '{ print $1 }'` + if [ $NUM_PROCS -gt 0 ]; then + if [ -f /var/run/squid_alarm ]; then + echo "Squid has resumed. Reconfiguring filter." | \ + logger -p daemon.info -i -t Squid_Alarm + /etc/rc.filter_configure_sync + rm /var/run/squid_alarm + fi + fi + sleep $LOOP_SLEEP +done + +if [ -f /var/run/squid_alarm ]; then + rm /var/run/squid_alarm +fi + diff --git a/config/squid-8/squid.inc b/config/squid-8/squid.inc new file mode 100644 index 00000000..1f264a64 --- /dev/null +++ b/config/squid-8/squid.inc @@ -0,0 +1,1319 @@ +/dev/null +killall pinger 2>/dev/null + +EOD; + $rc['restart'] = << $names[$i], 'value' => $values[$i]); +} + +function squid_validate_general($post, $input_errors) { + global $config; + $settings = $config['installedpackages']['squid']['config'][0]; + $port = ($settings['proxy_port'] ? $settings['proxy_port'] : 3128); + $port = $post['proxy_port'] ? $post['proxy_port'] : $port; + + $icp_port = trim($post['icp_port']); + if (!empty($icp_port) && !is_port($icp_port)) + $input_errors[] = 'You must enter a valid port number in the \'ICP port\' field'; + + if (substr($post['log_dir'], -1, 1) == '/') + $input_errors[] = 'You may not end log location with an / mark'; + + if ($post['log_dir']{0} != '/') + $input_errors[] = 'You must start log location with a / mark'; + if (strlen($post['log_dir']) <= 3) + $input_errors[] = "That is not a valid log location dir"; + + $log_rotate = trim($post['log_rotate']); + if (!empty($log_rotate) && (!is_numeric($log_rotate) or ($log_rotate < 1))) + $input_errors[] = 'You must enter a valid number of days \'Log rotate\' field'; + + $webgui_port = $config['system']['webgui']['port']; + if(($config['system']['webgui']['port'] == "") && ($config['system']['webgui']['protocol'] == "http")) { + $webgui_port = 80; + } + if(($config['system']['webgui']['port'] == "") && ($config['system']['webgui']['protocol'] == "https")) { + $webgui_port = 443; + } + + if (($post['transparent_proxy'] != 'on') && ($port == $webgui_port)) { + $input_errors[] = "You can not run squid on the same port as the webgui"; + } + + if (($post['transparent_proxy'] != 'on') && ($post['private_subnet_proxy_off'] == 'on')) { + $input_errors[] = "You can not bypass traffic to private subnets without using the transparent proxy."; + } + + if (($post['transparent_proxy'] != 'on') && !empty($post['defined_ip_proxy_off'])) { + $input_errors[] = "You can not bypass traffic from specific IPs without using the transparent proxy."; + } + + foreach (array('defined_ip_proxy_off') as $hosts) { + foreach (explode(";", $post[$hosts]) as $host) { + $host = trim($host); + if (!empty($host) && !is_ipaddr($host)) + $input_errors[] = "The entry '$host' is not a valid IP address"; + } + } + + if(!empty($post['dns_nameservers'])) { + $altdns = explode(";", ($post['dns_nameservers'])); + foreach ($altdns as $dnssrv) { + if (!is_ipaddr($dnssrv)) + $input_errors[] = 'You must enter a valid IP address in the \'Alternate DNS servers\' field'; + }} +} + +function squid_validate_upstream($post, $input_errors) { + if ($post['proxy_forwarding'] == 'on') { + $addr = trim($post['proxy_addr']); + if (empty($addr)) + $input_errors[] = 'The field \'Hostname\' is required'; + else { + if (!is_ipaddr($addr) && !is_domain($addr)) + $input_errors[] = 'You must enter a valid IP address or host name in the \'Proxy hostname\' field'; + } + + foreach (array('proxy_port' => 'TCP port', 'icp_port' => 'ICP port') as $field => $name) { + $port = trim($post[$field]); + if (empty($port)) + $input_errors[] = "The field '$name' is required"; + else { + if (!is_port($port)) + $input_errors[] = "The field '$name' must contain a valid port number, between 0 and 65535"; + } + } + } +} + +function squid_validate_cache($post, $input_errors) { + $num_fields = array( 'harddisk_cache_size' => 'Hard disk cache size', + 'memory_cache_size' => 'Memory cache size', + 'maximum_object_size' => 'Maximum object size', + ); + foreach ($num_fields as $field => $name) { + $value = trim($post[$field]); + if (!is_numeric($value) || ($value < 0)) + $input_errors[] = "You must enter a valid value for '$field'"; + } + + $value = trim($post['minimum_object_size']); + if (!is_numeric($value) || ($value < 0)) + $input_errors[] = 'You must enter a valid value for \'Minimum object size\''; + + if (!empty($post['cache_swap_low'])) { + $value = trim($post['cache_swap_low']); + if (!is_numeric($value) || ($value > 100)) + $input_errors[] = 'You must enter a valid value for \'Low-water-mark\''; + } + + if (!empty($post['cache_swap_high'])) { + $value = trim($post['cache_swap_high']); + if (!is_numeric($value) || ($value > 100)) + $input_errors[] = 'You must enter a valid value for \'High-water-mark\''; + } + + if ($post['donotcache'] != "") { + foreach (split("\n", $post['donotcache']) as $host) { + $host = trim($host); + if (!is_ipaddr($host) && !is_domain($host)) + $input_errors[] = "The host '$host' is not a valid IP or host name"; + } + } + + squid_dash_z(); + +} + +function squid_validate_nac($post, $input_errors) { + $allowed_subnets = explode("\n", $post['allowed_subnets']); + foreach ($allowed_subnets as $subnet) { + $subnet = trim($subnet); + if (!empty($subnet) && !is_subnet($subnet)) + $input_errors[] = "The subnet '$subnet' is not a valid CIDR range"; + } + + foreach (array( 'unrestricted_hosts', 'banned_hosts') as $hosts) { + foreach (explode("\n", $post[$hosts]) as $host) { + $host = trim($host); + if (!empty($host) && !is_ipaddr($host)) + $input_errors[] = "The host '$host' is not a valid IP address"; + } + } + + foreach (array('unrestricted_macs', 'banned_macs') as $macs) { + foreach (explode("\n", $post[$macs]) as $mac) { + $mac = trim($mac); + if (!empty($mac) && !is_macaddr($mac)) + $input_errors[] = "The mac '$mac' is not a valid MAC address"; + } + } + + foreach (explode(",", $post['timelist']) as $time) { + $time = trim($time); + if (!empty($time) && !squid_is_timerange($time)) + $input_errors[] = "The time range '$time' is not a valid time range"; + } + + if(!empty($post['ext_cachemanager'])) { + $extmgr = explode(";", ($post['ext_cachemanager'])); + foreach ($extmgr as $mgr) { + if (!is_ipaddr($mgr)) + $input_errors[] = 'You must enter a valid IP address in the \'External Cache Manager\' field'; + }} +} + +function squid_validate_traffic($post, $input_errors) { + $num_fields = array( 'max_download_size' => 'Maximum download size', + 'max_upload_size' => 'Maximum upload size', + 'perhost_throttling' => 'Per-host bandwidth throttling', + 'overall_throttling' => 'Overall bandwidth throttling', + ); + foreach ($num_fields as $field => $name) { + $value = trim($post[$field]); + if (!is_numeric($value) || ($value < 0)) + $input_errors[] = "The field '$name' must contain a positive number"; + } + + if (!empty($post['quick_abort_min'])) { + $value = trim($post['quick_abort_min']); + if (!is_numeric($value)) + $input_errors[] = "The field 'Finish when remaining KB' must contain a positive number"; + } + + if (!empty($post['quick_abort_max'])) { + $value = trim($post['quick_abort_max']); + if (!is_numeric($value)) + $input_errors[] = "The field 'Abort when remaining KB' must contain a positive number"; + } + + if (!empty($post['quick_abort_pct'])) { + $value = trim($post['quick_abort_pct']); + if (!is_numeric($value) || ($value > 100)) + $input_errors[] = "The field 'Finish when remaining %' must contain a percentaged value"; + } + +} + +function squid_validate_auth($post, $input_errors) { + $num_fields = array( array('auth_processes', 'Authentication processes', 1), + array('auth_ttl', 'Authentication TTL', 0), + ); + foreach ($num_fields as $field) { + $value = trim($post[$field[0]]); + if (!empty($value) && (!is_numeric($value) || ($value < $field[2]))) + $input_errors[] = "The field '{$field[1]}' must contain a valid number greater than {$field[2]}"; + } + + $auth_method = $post['auth_method']; + if (($auth_method != 'none') && ($auth_method != 'local')) { + $server = trim($post['auth_server']); + if (empty($server)) + $input_errors[] = 'The field \'Authentication server\' is required'; + else if (!is_ipaddr($server) && !is_domain($server)) + $input_errors[] = 'The field \'Authentication server\' must contain a valid IP address or domain name'; + + $port = trim($post['auth_server_port']); + if (!empty($port) && !is_port($port)) + $input_errors[] = 'The field \'Authentication server port\' must contain a valid port number'; + + switch ($auth_method) { + case 'ldap': + $user = trim($post['ldap_user']); + if (empty($user)) + $input_errors[] = 'The field \'LDAP server user DN\' is required'; + else if (!$user) + $input_errors[] = 'The field \'LDAP server user DN\' must be a valid domain name'; + break; + case 'radius': + $secret = trim($post['radius_secret']); + if (empty($secret)) + $input_errors[] = 'The field \'RADIUS secret\' is required'; + break; + case 'msnt': + foreach (explode(",", trim($post['msnt_secondary'])) as $server) { + if (!empty($server) && !is_ipaddr($server) && !is_domain($server)) + $input_errors[] = "The host '$server' is not a valid IP address or domain name"; + } + break; + } + + $no_auth = explode("\n", $post['no_auth_hosts']); + foreach ($no_auth as $host) { + $host = trim($host); + if (!empty($host) && !is_subnet($host)) + $input_errors[] = "The host '$host' is not a valid CIDR range"; + } + } +} + +function squid_install_cron($should_install) { + global $config, $g; + if($g['booting']==true) + return; + $is_installed = false; + if(!$config['cron']['item']) + return; + $x=0; + foreach($config['cron']['item'] as $item) { + if(strstr($item['command'], "/usr/local/sbin/squid")) { + $is_installed = true; + break; + } + $x++; + } + switch($should_install) { + case true: + if(!$is_installed) { + $cron_item = array(); + $cron_item['minute'] = "0"; + $cron_item['hour'] = "0"; + $cron_item['mday'] = "*"; + $cron_item['month'] = "*"; + $cron_item['wday'] = "*"; + $cron_item['who'] = "root"; + $cron_item['command'] = "/usr/local/sbin/squid -k rotate"; + $config['cron']['item'][] = $cron_item; + parse_config(true); + write_config("Squid Log Rotation"); + configure_cron(); + } + break; + case false: + if($is_installed == true) { + if($x > 0) { + unset($config['cron']['item'][$x]); + parse_config(true); + write_config(); + } + configure_cron(); + } + break; + } +} + +function squid_resync_general() { + global $g, $config, $valid_acls; + + $settings = $config['installedpackages']['squid']['config'][0]; + $conf = "# This file is automatically generated by pfSense\n"; + $conf = "# Do not edit manually !\n"; + + $port = ($settings['proxy_port'] ? $settings['proxy_port'] : 3128); + $ifaces = ($settings['active_interface'] ? $settings['active_interface'] : 'lan'); + $real_ifaces = array(); + foreach (explode(",", $ifaces) as $i => $iface) { + $real_ifaces[] = squid_get_real_interface_address($iface); + if($real_ifaces[$i][0]) { + $conf .= "http_port {$real_ifaces[$i][0]}:$port\n"; + } + } + if (($settings['transparent_proxy'] == 'on')) { + $conf .= "http_port 127.0.0.1:80 transparent\n"; + } + $icp_port = ($settings['icp_port'] ? $settings['icp_port'] : 0); + + $pidfile = "{$g['varrun_path']}/squid.pid"; + $language = ($settings['error_language'] ? $settings['error_language'] : 'English'); + $errordir = SQUID_CONFBASE . '/errors/' . $language; + $icondir = SQUID_CONFBASE . '/icons'; + $hostname = ($settings['visible_hostname'] ? $settings['visible_hostname'] : 'localhost'); + $email = ($settings['admin_email'] ? $settings['admin_email'] : 'admin@localhost'); + + $logdir = ($settings['log_dir'] ? $settings['log_dir'] : '/var/squid/log'); + + $logdir_cache = $logdir . '/cache.log'; + $logdir_access = ($settings['log_enabled'] == 'on' ? $logdir . '/access.log' : '/dev/null'); + + $conf .= << 'src', + 'banned_hosts' => 'src', + 'whitelist' => 'dstdom_regex -i', + 'blacklist' => 'dstdom_regex -i', + ); + foreach ($options as $option => $directive) { + $contents = base64_decode($settings[$option]); + if (!empty($contents)) { + file_put_contents(SQUID_ACLDIR . "/$option.acl", $contents); + $conf .= "acl $option $directive \"" . SQUID_ACLDIR . "/$option.acl\"\n"; + $valid_acls[] = $option; + } + elseif (file_exists(SQUID_ACLDIR . "/$option.acl")) { + unlink(SQUID_ACLDIR . "/$option.acl"); + } + } + + $conf .= << $binaries, + 'throttle_cdimages' => $cdimages, + 'throttle_multimedia' => $multimedia) as $field => $set) { + if ($settings[$field] == 'on') + $exts = array_merge($exts, explode(",", $set)); + } + + foreach (explode(",", $settings['throttle_others']) as $ext) { + if (!empty($ext)) $exts[] = $ext; + } + + $contents = ''; + foreach ($exts as $ext) + $contents .= "\.$ext\$\n"; + file_put_contents(SQUID_ACLDIR . '/throttle_exts.acl', $contents); + + $conf .= "# Throttle extensions matched in the url\n"; + $conf .= "acl throttle_exts urlpath_regex -i \"" . SQUID_ACLDIR . "/throttle_exts.acl\"\n"; + $conf .= "delay_access 1 allow throttle_exts\n"; + $conf .= "delay_access 1 deny all\n"; + } + else + $conf .= "delay_access 1 allow all\n"; + + return $conf; +} + +function squid_resync_auth() { + global $config, $valid_acls; + + $settings = $config['installedpackages']['squidauth']['config'][0]; + $settingsnac = $config['installedpackages']['squidnac']['config'][0]; + $settingsconfig = $config['installedpackages']['squid']['config'][0]; + $conf = ''; + + // Deny the banned guys before allowing the good guys + if(! empty($settingsnac['banned_hosts'])) { + if (squid_is_valid_acl('banned_hosts')) { + $conf .= "# These hosts are banned\n"; + $conf .= "http_access deny banned_hosts\n"; + } + } + if(! empty($settingsnac['banned_macs'])) { + if (squid_is_valid_acl('banned_macs')) { + $conf .= "# These macs are banned\n"; + $conf .= "http_access deny banned_macs\n"; + } + } + + // Unrestricted hosts take precendence over blacklist + if(! empty($settingsnac['unrestricted_hosts'])) { + if (squid_is_valid_acl('unrestricted_hosts')) { + $conf .= "# These hosts do not have any restrictions\n"; + $conf .= "http_access allow unrestricted_hosts\n"; + } + } + if(! empty($settingsnac['unrestricted_macs'])) { + if (squid_is_valid_acl('unrestricted_macs')) { + $conf .= "# These hosts do not have any restrictions\n"; + $conf .= "http_access allow unrestricted_macs\n"; + } + } + + // Whitelist and blacklist also take precendence over other allow rules + if(! empty($settingsnac['whitelist'])) { + if (squid_is_valid_acl('whitelist')) { + $conf .= "# Always allow access to whitelist domains\n"; + $conf .= "http_access allow whitelist\n"; + } + } + if(! empty($settingsnac['blacklist'])) { + if (squid_is_valid_acl('blacklist')) { + $conf .= "# Block access to blacklist domains\n"; + $conf .= "http_access deny blacklist\n"; + } + } + + $transparent_proxy = ($settingsconfig['transparent_proxy'] == 'on'); + $auth_method = (($settings['auth_method'] && !$transparent_proxy) ? $settings['auth_method'] : 'none'); + // Allow the remaining ACLs if no authentication is set + if ($auth_method == 'none') { + if ($settingsconfig['allow_interface'] == 'on') { + $conf .= "# Allow local network(s) on interface(s)\n"; + $allowed = array('localnet', 'allowed_subnets'); + $allowed = array_filter($allowed, 'squid_is_valid_acl'); + foreach ($allowed as $acl) + $conf .= "http_access allow $acl\n"; + } + } + else { + $noauth = implode(' ', explode("\n", base64_decode($settings['no_auth_hosts']))); + if (!empty($noauth)) { + $conf .= "acl noauth src $noauth\n"; + $valid_acls[] = 'noauth'; + } + + // Set up the external authentication programs + $auth_ttl = ($settings['auth_ttl'] ? $settings['auth_ttl'] : 60); + $processes = ($settings['auth_processes'] ? $settings['auth_processes'] : 5); + $prompt = ($settings['auth_prompt'] ? $settings['auth_prompt'] : 'Please enter your credentials to access the proxy'); + switch ($auth_method) { + case 'local': + $conf .= 'auth_param basic program /usr/local/libexec/squid/ncsa_auth ' . SQUID_PASSWD . "\n"; + break; + case 'ldap': + $port = (isset($settings['auth_port']) ? ":{$settings['auth_port']}" : ''); + $password = (isset($settings['ldap_pass']) ? "-w {$settings['ldap_pass']}" : ''); + $conf .= "auth_param basic program /usr/local/libexec/squid/squid_ldap_auth -v {$settings['ldap_version']} -b {$settings['ldap_basedomain']} -D {$settings['ldap_user']} $password -f \"{$settings['ldap_filter']}\" -u uid -P {$settings['auth_server']}$port\n"; + break; + case 'radius': + $port = (isset($settings['auth_port']) ? "-p {$settings['auth_server_port']}" : ''); + $conf .= "auth_param basic program /usr/local/libexec/squid/squid_radius_auth -w {$settings['radius_secret']} -h {$settings['auth_server']} $port\n"; + break; + case 'msnt': + $conf .= "auth_param basic program /usr/local/libexec/squid/msnt_auth\n"; + break; + } + $conf .= << + + + +EOD; + } + else { + $javascript = << + + + +EOD; + } + + print($javascript); +} + +function squid_print_javascript_auth2() { + print("\n"); +} + +function squid_generate_rules($type) { + global $config; + + $squid_conf = $config['installedpackages']['squid']['config'][0]; + if (!is_service_running('squid')) { + log_error("SQUID is installed but not started. Not installing redirect rules."); + return; + } + + if (($squid_conf['transparent_proxy'] != 'on') || ($squid_conf['allow_interface'] != 'on')) { + return; + } + + $ifaces = explode(",", $squid_conf['active_interface']); + $ifaces = array_map('convert_friendly_interface_to_real_interface_name', $ifaces); + $port = ($squid_conf['proxy_port'] ? $squid_conf['proxy_port'] : 3128); + + $fw_aliases = filter_generate_aliases(); + if(strstr($fw_aliases, "pptp =")) + $PPTP_ALIAS = "\$pptp"; + else + $PPTP_ALIAS = "\$PPTP"; + if(strstr($fw_aliases, "PPPoE =")) + $PPPOE_ALIAS = "\$PPPoE"; + else + $PPPOE_ALIAS = "\$pppoe"; + + switch($type) { + case 'nat': + $rules .= "\n# Setup Squid proxy redirect\n"; + if ($squid_conf['private_subnet_proxy_off'] == 'on') { + foreach ($ifaces as $iface) { + $rules .= "no rdr on $iface proto tcp from any to { 192.168.0.0/16, 172.16.0.0/12, 10.0.0.0/8 } port 80\n"; + } + } + if (!empty($squid_conf['defined_ip_proxy_off'])) { + $defined_ip_proxy_off = explode(";", $squid_conf['defined_ip_proxy_off']); + $exempt_ip = ""; + foreach ($defined_ip_proxy_off as $ip_proxy_off) { + if(!empty($ip_proxy_off)) { + $ip_proxy_off = trim($ip_proxy_off); + $exempt_ip .= ", $ip_proxy_off"; + } + } + $exempt_ip = substr($exempt_ip,2); + foreach ($ifaces as $iface) { + $rules .= "no rdr on $iface proto tcp from { $exempt_ip } to any port 80\n"; + } + } + foreach ($ifaces as $iface) { + $rules .= "rdr on $iface proto tcp from any to !($iface) port 80 -> 127.0.0.1 port 80\n"; + } + /* Handle PPPOE case */ + if($config['pppoe']['mode'] == "server" && $config['pppoe']['localip']) { + $rules .= "rdr on $PPPOE_ALIAS proto tcp from any to !127.0.0.1 port 80 -> 127.0.0.1 port 80\n"; + } + /* Handle PPTP case */ + if($config['pptpd']['mode'] == "server" && $config['pptpd']['localip']) { + $rules .= "rdr on $PPTP_ALIAS proto tcp from any to !127.0.0.1 port 80 -> 127.0.0.1 port 80\n"; + } + $rules .= "\n"; + break; + case 'filter': + case 'rule': + foreach ($ifaces as $iface) { + $rules .= "# Setup squid pass rules for proxy\n"; + $rules .= "pass in quick on $iface proto tcp from any to !($iface) port 80 flags S/SA keep state\n"; + $rules .= "pass in quick on $iface proto tcp from any to !($iface) port $port flags S/SA keep state\n"; + $rules .= "\n"; + }; + if($config['pppoe']['mode'] == "server" && $config['pppoe']['localip']) { + $rules .= "pass in quick on $PPPOE_ALIAS proto tcp from any to !127.0.0.1 port $port flags S/SA keep state\n"; + } + if($config['pptpd']['mode'] == "server" && $config['pptpd']['localip']) { + $rules .= "pass in quick on $PPTP_ALIAS proto tcp from any to !127.0.0.1 port $port flags S/SA keep state\n"; + } + break; + default: + break; + } + + return $rules; +} + +?> diff --git a/config/squid-8/squid.xml b/config/squid-8/squid.xml new file mode 100644 index 00000000..f79cc8d2 --- /dev/null +++ b/config/squid-8/squid.xml @@ -0,0 +1,334 @@ + + + + + + . + 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. + */ +/* ========================================================================== */ + ]]> + + Describe your package here + Describe your package requirements here + Currently there are no FAQ items provided. + squid + 2.6.STABLE18 + Proxy server: General settings + /usr/local/pkg/squid.inc + + Proxy server + Modify the proxy server's settings +
Services
+ /pkg_edit.php?xml=squid.xml&id=0 +
+ + squid + squid.sh + squid + Proxy server Service + + + + General + /pkg_edit.php?xml=squid.xml&id=0 + + + + Upstream Proxy + /pkg_edit.php?xml=squid_upstream.xml&id=0 + + + Cache Mgmt + /pkg_edit.php?xml=squid_cache.xml&id=0 + + + Access Control + /pkg_edit.php?xml=squid_nac.xml&id=0 + + + Traffic Mgmt + /pkg_edit.php?xml=squid_traffic.xml&id=0 + + + Auth Settings + /pkg_edit.php?xml=squid_auth.xml&id=0 + + + Local Users + /pkg.php?xml=squid_users.xml + + + + + /usr/local/pkg/ + 0755 + http://www.pfsense.org/packages/config/squid-8/squid.inc + + + /usr/local/pkg/ + 0755 + http://www.pfsense.org/packages/config/squid-8/squid_cache.xml + + + /usr/local/pkg/ + 0755 + http://www.pfsense.org/packages/config/squid-8/squid_nac.xml + + + /usr/local/pkg/ + 0755 + http://www.pfsense.org/packages/config/squid-8/squid_ng.xml + + + /usr/local/pkg/ + 0755 + http://www.pfsense.org/packages/config/squid-8/squid_traffic.xml + + + /usr/local/pkg/ + 0755 + http://www.pfsense.org/packages/config/squid-8/squid_upstream.xml + + + /usr/local/pkg/ + 0755 + http://www.pfsense.org/packages/config/squid-8/squid_auth.xml + + + /usr/local/pkg/ + 0755 + http://www.pfsense.org/packages/config/squid-8/squid_users.xml + + + /usr/local/etc/rc.d/ + 0755 + http://www.pfsense.org/packages/config/squid-8/proxy_monitor.sh + + + /usr/local/pkg/ + 0755 + http://www.pfsense.org/packages/config/squid-8/squid_cache.xml + + + + Proxy interface + active_interface + The interface(s) the proxy server will bind to. + interfaces_selection + + lan + + + + Allow users on interface + allow_interface + If this field is checked, the users connected to the interface selected in the 'Proxy interface' field will be allowed to use the proxy, i.e., there will be no need to add the interface's subnet to the list of allowed subnets. This is just a shortcut. + checkbox + + on + + + Transparent proxy + transparent_proxy + If transparent mode is enabled, all requests for destination port 80 will be forwarded to the proxy server without any additional configuration necessary. + checkbox + + + + Bypass proxy for Private Address Space (RFC 1918) destination + private_subnet_proxy_off + Do not forward traffic to Private Address Space (RFC 1918) <b>destination</b> through the proxy server but directly through the firewall. + checkbox + + + Bypass proxy for these source IPs + defined_ip_proxy_off + Do not forward traffic from these <b>source</b> IPs through the proxy server but directly through the firewall. Separate by semi-colons (;). + input + 80 + + + Enabled logging + log_enabled + This will enable the access log. Don't switch this on if you don't have much disk space left. + checkbox + log_query_terms,log_user_agents + + + Log store directory + log_dir + The directory where the log will be stored (note: do not end with a / mark) + input + 60 + + /var/squid/log + + + Log rotate + log_rotate + Defines how many days of logfiles will be kept. Rotation is disabled if left empty. + input + 5 + + + Proxy port + proxy_port + This is the port the proxy server will listen on. + input + 5 + + 3128 + + + ICP port + icp_port + This is the port the Proxy Server will send and receive ICP queries to and from neighbor caches. Leave this blank if you don't want the proxy server to communicate with neighbor caches through ICP. + input + 5 + + + Visible hostname + visible_hostname + This is the URL to be displayed in proxy server error messages. + input + 60 + localhost + + + Administrator email + admin_email + This is the email address displayed in error messages to the users. + input + 60 + admin@localhost + + + Language + error_language + Select the language in which the proxy server will display error messages to users. + select + English + + + Disable X-Forward + disable_xforward + If not set, Squid will include your system's IP address or name in the HTTP requests it forwards. + checkbox + + + Disable VIA + disable_via + If not set, Squid will include a Via header in requests and replies as required by RFC2616. + checkbox + + + What to do with requests that have whitespace characters in the URI + uri_whitespace + <b> strip:</b> The whitespace characters are stripped out of the URL. This is the behavior recommended by RFC2396. <p> <b> deny:</b> The request is denied. The user receives an "Invalid Request" message.<p> <b> allow:</b> The request is allowed and the URI is not changed. The whitespace characters remain in the URI.<p> <b> encode:</b> The request is allowed and the whitespace characters are encoded according to RFC1738.<p> <b> chop:</b> The request is allowed and the URI is chopped at the first whitespace. + select + strip + + + + + + + + + + Use alternate DNS-servers for the proxy-server + dns_nameservers + If you want to use other DNS-servers than the DNS-forwarder, enter the IPs here, separated by semi-colons (;). + input + 60 + + + Suppress Squid Version + disable_squidversion + If set, suppress Squid version string info in HTTP headers and HTML error pages. + checkbox + + + Custom Options + custom_options + You can put your own custom options here, separated by semi-colons (;). They'll be added to the configuration. They need to be squid.conf native options, otherwise squid will NOT work. + textarea + 65 + 5 + + + + squid_before_form_general(&$pkg); + + + squid_resync(); + + + squid_validate_general($_POST, &$input_errors); + + + squid_resync(); + exec("/bin/rm -f /usr/local/etc/rc.d/squid"); + + + update_status("Checking Squid cache... One moment please..."); + update_output_window("This operation may take quite some time, please be patient. Do not press stop or attempt to navigate away from this page during this process."); + squid_install_command(); + squid_resync(); + exec("/bin/rm -f /usr/local/etc/rc.d/squid"); + + + squid_deinstall_command(); + exec("/bin/rm -f /usr/local/etc/rc.d/squid*"); + + squid_generate_rules +
diff --git a/config/squid-8/squid_auth.inc b/config/squid-8/squid_auth.inc new file mode 100644 index 00000000..7c99a01b --- /dev/null +++ b/config/squid-8/squid_auth.inc @@ -0,0 +1,446 @@ + + 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. + +*/ + +function global_eval_auth_options() +{ + global $config; + conf_mount_rw(); + config_lock(); + + switch ($config['installedpackages']['squidauth']['config'][0]['auth_method']) { + case "none": + dynamic_auth_content("pkg_edit"); + dynamic_no_auth(); + break; + case "local_auth": + dynamic_auth_content("pkg"); + /* create empty passwd file to prevent stat error with squid reload */ + touch ("/usr/local/etc/squid/advanced/ncsa/passwd"); + dynamic_local_auth(); + break; + case "ldap_bind": + dynamic_auth_content("pkg_edit"); + dynamic_ldap_auth(); + break; + case "domain_auth": + $filecontents = file("/usr/local/pkg/squid_auth.xml"); + dynamic_auth_content("pkg_edit"); + dynamic_domain_auth(); + break; + case "radius_auth": + $filecontents = file("/usr/local/pkg/squid_auth.xml"); + dynamic_auth_content("pkg_edit"); + dynamic_radius_auth(); + break; + default: + $filecontents = file("/usr/local/pkg/squid_auth.xml"); + dynamic_auth_content("pkg_edit"); + dynamic_no_auth(); + break; + } + + config_unlock(); + conf_mount_ro(); + +} /* end function global_eval_auth_options */ + +function dynamic_no_auth() { + global $config; + conf_mount_rw(); + $fout = fopen("/usr/local/pkg/squid_extauth.xml", "w"); + fwrite($fout, "\n"); + fwrite($fout, "\n"); + fwrite($fout, " squidextnoauth\n"); + fwrite($fout, " Services: Proxy Server -> Extended Authentication Settings\n"); + fwrite($fout, " installedpackages->package->squidextnoauth->configuration->settings\n"); + fwrite($fout, "\n"); + fwrite($fout, " /pkg_edit.php?xml=squid_extauth.xml&id=0\n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, " \n"); + fwrite($fout, " General Settings\n"); + fwrite($fout, " /pkg_edit.php?xml=squid_ng.xml&id=0\n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, " Upstream Proxy\n"); + fwrite($fout, " /pkg_edit.php?xml=squid_upstream.xml&id=0\n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, " Cache Mgmt\n"); + fwrite($fout, " /pkg_edit.php?xml=squid_cache.xml&id=0\n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, " Network Access Control\n"); + fwrite($fout, " /pkg_edit.php?xml=squid_nac.xml&id=0\n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, " Traffic Mgmt\n"); + fwrite($fout, " /pkg_edit.php?xml=squid_traffic.xml&id=0\n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, " Auth Settings\n"); + fwrite($fout, " /pkg_edit.php?xml=squid_auth.xml&id=0\n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, " Extended Auth Settings\n"); + fwrite($fout, " /pkg_edit.php?xml=squid_extauth.xml&id=0\n"); + fwrite($fout, " \n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, " \n"); + fwrite($fout, " No Authentication Defined\n"); + fwrite($fout, " no_auth\n"); + fwrite($fout, " \n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, " require_once(\"/usr/local/pkg/squid_ng.inc\");"); + fwrite($fout, "\n"); + fwrite($fout, " global_write_squid_config();\n"); + fwrite($fout, " mwexec(\"/usr/local/sbin/squid -k reconfigure\");\n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, "\n"); + fclose($fout); + + /* mount filesystem read-only */ + conf_mount_ro(); +} + +function dynamic_local_auth() { + global $config; + conf_mount_rw(); + + $fout = fopen("/usr/local/pkg/squid_extauth.xml", "w"); + + fwrite($fout, "\n"); + fwrite($fout, "\n"); + fwrite($fout, "\n"); + fwrite($fout, " squidextlocalauth\n"); + fwrite($fout, " Services: Proxy Server -> Extended Auth Settings\n"); + fwrite($fout, " 2.5.10_4\n"); + fwrite($fout, " installedpackages->package->squidextlocalauth->configuration->settings\n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " /pkg.php?xml=squid_extauth.xml&id=0\n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, " \n"); + fwrite($fout, " General Settings\n"); + fwrite($fout, " /pkg_edit.php?xml=squid_ng.xml&id=0\n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, " Upstream Proxy\n"); + fwrite($fout, " /pkg_edit.php?xml=squid_upstream.xml&id=0\n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, " Cache Mgmt\n"); + fwrite($fout, " /pkg_edit.php?xml=squid_cache.xml&id=0\n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, " Network Access Control\n"); + fwrite($fout, " /pkg_edit.php?xml=squid_nac.xml&id=0\n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, " Traffic Mgmt\n"); + fwrite($fout, " /pkg_edit.php?xml=squid_traffic.xml&id=0\n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, " Auth Settings\n"); + fwrite($fout, " /pkg_edit.php?xml=squid_auth.xml&id=0\n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, " Extended Auth Settings\n"); + fwrite($fout, " /pkg.php?xml=squid_extauth.xml&id=0\n"); + fwrite($fout, " \n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, " \n"); + fwrite($fout, " Username\n"); + fwrite($fout, " username\n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, " Description\n"); + fwrite($fout, " description\n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, " Restriction Group\n"); + fwrite($fout, " group\n"); + fwrite($fout, " \n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, " \n"); + fwrite($fout, " Username\n"); + fwrite($fout, " username\n"); + fwrite($fout, " input\n"); + fwrite($fout, " 15\n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, " Password\n"); + fwrite($fout, " password\n"); + fwrite($fout, " password\n"); + fwrite($fout, " 8\n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, " Description (Optional)\n"); + fwrite($fout, " description\n"); + fwrite($fout, " input\n"); + fwrite($fout, " 30\n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, " Restriction Group\n"); + fwrite($fout, " group\n"); + fwrite($fout, " select\n"); + fwrite($fout, " \n"); + fwrite($fout, " \n"); + fwrite($fout, " \n"); + fwrite($fout, " \n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, " require_once(\"/usr/local/pkg/squid_ng.inc\");\n"); + fwrite($fout, "\n"); + fwrite($fout, " mod_htpasswd();\n"); + fwrite($fout, " global_write_squid_config();\n"); + fwrite($fout, " mwexec(\"/usr/local/sbin/squid -k reconfigure\");\n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, "\n"); + + fclose($fout); + + /* mount filesystem read-only */ + conf_mount_ro(); +} + +function dynamic_ldap_auth() { + global $config; + conf_mount_rw(); + + $fout = fopen("/usr/local/pkg/squid_extauth.xml", "w"); + + fwrite($fout, "\n"); + fwrite($fout, "\n"); + fwrite($fout, "\n"); + fwrite($fout, " squidextldapauth\n"); + fwrite($fout, " Services: Proxy Server -> Extended Auth Settings\n"); + fwrite($fout, " 2.5.11\n"); + fwrite($fout, " installedpackages->package->squidextldapauth->configuration->settings\n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " /pkg_edit.php?xml=squid_extauth.xml&id=0\n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, " \n"); + fwrite($fout, " General Settings\n"); + fwrite($fout, " /pkg_edit.php?xml=squid_ng.xml&id=0\n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, " Upstream Proxy\n"); + fwrite($fout, " /pkg_edit.php?xml=squid_upstream.xml&id=0\n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, " Cache Mgmt\n"); + fwrite($fout, " /pkg_edit.php?xml=squid_cache.xml&id=0\n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, " Network Access Control\n"); + fwrite($fout, " /pkg_edit.php?xml=squid_nac.xml&id=0\n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, " Traffic Mgmt\n"); + fwrite($fout, " /pkg_edit.php?xml=squid_traffic.xml&id=0\n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, " Auth Settings\n"); + fwrite($fout, " /pkg_edit.php?xml=squid_auth.xml&id=0\n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, " Extended Auth Settings\n"); + fwrite($fout, " /pkg_edit.php?xml=squid_extauth.xml&id=0\n"); + fwrite($fout, " \n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, " \n"); + fwrite($fout, " Base DN\n"); + fwrite($fout, " ldap_basedn\n"); + fwrite($fout, " This is the base where the LDAP search starts. All subsequent organizational units (OUs)will be included. Example: \"ou=users,o=company\" will search for users in and under the specified company.\n"); + fwrite($fout, " input\n"); + fwrite($fout, " 50\n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, " LDAP Server\n"); + fwrite($fout, " ldap_server\n"); + fwrite($fout, " This is the LDAP server that the bind will be attempted against.\n"); + fwrite($fout, " input\n"); + fwrite($fout, " 20\n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, " LDAP Type\n"); + fwrite($fout, " ldap_type\n"); + fwrite($fout, " This specifies the supported LDAP types.\n"); + fwrite($fout, " select\n"); + fwrite($fout, " \n"); + fwrite($fout, " \n"); + fwrite($fout, " \n"); + fwrite($fout, " \n"); + fwrite($fout, " \n"); + fwrite($fout, " \n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, " LDAP Port\n"); + fwrite($fout, " ldap_port\n"); + fwrite($fout, " This is the port that LDAP bind will attempt on. The default is \"389\".\n"); + fwrite($fout, " input\n"); + fwrite($fout, " 5\n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, " Bind DN Username\n"); + fwrite($fout, " bind_dn_username\n"); + fwrite($fout, " If \"anonymous bind\" is not supported, please specify the bind username that can access the Base DN hierarchy.\n"); + fwrite($fout, " input\n"); + fwrite($fout, " 30\n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, " Bind DN Password\n"); + fwrite($fout, " bind_dn_password\n"); + fwrite($fout, " This is the associated password with the Bind DN Username previously specified.\n"); + fwrite($fout, " password\n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, " \n"); + fwrite($fout, " require_once(\"/usr/local/pkg/squid_ng.inc\");\n"); + fwrite($fout, "\n"); + fwrite($fout, " mod_htpasswd();\n"); + fwrite($fout, "\n"); + fwrite($fout, " global_write_squid_config();\n"); + fwrite($fout, " mwexec(\"/usr/local/sbin/squid -k reconfigure\");\n"); + fwrite($fout, " \n"); + fwrite($fout, "\n"); + fwrite($fout, "\n"); + + fclose($fout); + + /* mount filesystem read-only */ + conf_mount_ro(); +} + +/* dynamically re-writes all squid xml files to handle adddeletecolumnitems properly */ +function dynamic_auth_content($pkgvar) { + + switch ($pkgvar) { + case "pkg": + if ($handle = opendir("/usr/local/pkg")) { + while (($file = readdir($handle)) != false) { + if (stristr($file, "squid_") && stristr($file, ".xml")) { + $filecontents = file("/usr/local/pkg/" . $file); + $fout = fopen("/usr/local/pkg/" . $file, "w"); + foreach($filecontents as $line) { + if (stristr($line, "/pkg_edit.php?xml=squid_extauth.xml&id=0")) { + fwrite($fout, " /pkg.php?xml=squid_extauth.xml&id=0\n"); + } else { + fwrite($fout, $line); + } + } + } + } + } + break; + + case "pkg_edit": + if ($handle = opendir("/usr/local/pkg")) { + while (($file = readdir($handle)) != false) { + if (stristr($file, "squid_") && stristr($file, ".xml")) { + $filecontents = file("/usr/local/pkg/" . $file); + $fout = fopen("/usr/local/pkg/" . $file,"w"); + foreach($filecontents as $line) { + if (stristr($line, "/pkg.php?xml=squid_extauth.xml&id=0")) { + fwrite($fout, " /pkg_edit.php?xml=squid_extauth.xml&id=0\n"); + } else { + fwrite($fout, $line); + } + } + } + } + } + break; + } + +} /* end function dynamic_auth_content */ +?> \ No newline at end of file diff --git a/config/squid-8/squid_auth.xml b/config/squid-8/squid_auth.xml new file mode 100644 index 00000000..33317d4a --- /dev/null +++ b/config/squid-8/squid_auth.xml @@ -0,0 +1,225 @@ + + + + + + . + 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. + */ +/* ========================================================================== */ + ]]> + + Describe your package here + Describe your package requirements here + Currently there are no FAQ items provided. + squidauth + none + Proxy server: Authentication + squid.inc + + + General + /pkg_edit.php?xml=squid.xml&id=0 + + + Upstream Proxy + /pkg_edit.php?xml=squid_upstream.xml&id=0 + + + Cache Mgmt + /pkg_edit.php?xml=squid_cache.xml&id=0 + + + Access Control + /pkg_edit.php?xml=squid_nac.xml&id=0 + + + Traffic Mgmt + /pkg_edit.php?xml=squid_traffic.xml&id=0 + + + Auth Settings + /pkg_edit.php?xml=squid_auth.xml&id=0 + + + + Local Users + /pkg.php?xml=squid_users.xml + + + + + Authentication method + auth_method + Select an authentication method. This will allow users to be authenticated by local or external services. + select + + none + + + + + + + + on_auth_method_changed() + + + LDAP version + ldap_version + Enter LDAP protocol version (2 or 3). + select + 2 + + + + + + + Authentication server + auth_server + Enter here the IP or hostname of the server that will perform the authentication. + input + 60 + + + Authentication server port + auth_server_port + Enter here the port to use to connect to the authentication server. Leave this field blank to use the authentication method's default port. + input + 60 + + + LDAP server user DN + ldap_user + Enter here the user DN to use to connect to the LDAP server. + input + 60 + + + LDAP password + ldap_pass + Enter here the password to use to connect to the LDAP server. + password + 60 + + + LDAP base domain + ldap_basedomain + For LDAP authentication, enter here the base domain in the LDAP server. + input + 60 + + + LDAP search filter + ldap_filter + Enter LDAP search filter. + input + 60 + (&(objectClass=person)(uid=%s)) + + + RADIUS secret + radius_secret + The RADIUS secret for RADIUS authentication. + password + 60 + + + Secondary NT servers + msnt_secondary + Comma-separated list of secondary servers to be used for NT domain authentication. + input + 60 + + + Authentication prompt + auth_prompt + This string will be displayed at the top of the authentication request window. + input + Please enter your credentials to access the proxy + + + Authentication processes + auth_processes + The number of authenticator processes to spawn. If many authentications are expected within a short timeframe, increase this number accordingly. + input + 60 + 5 + + + Authentication TTL + auth_ttl + This specifies for how long (in minutes) the proxy server assumes an externally validated username and password combination is valid (Time To Live). When the TTL expires, the user will be prompted for credentials again. + input + 60 + 60 + + + Requiere authentication for unrestricted hosts + unrestricted_auth + If this option is enabled, even users tagged as unrestricted through access control are required to authenticate to use the proxy. + checkbox + + + Subnets that don't need authentication + no_auth_hosts + Enter each subnet or IP address on a new line (in CIDR format, e.g.: 10.5.0.0/16, 192.168.1.50/32) that should not be asked for authentication to access the proxy. + textarea + 50 + 5 + base64 + + + + squid_validate_auth($_POST, &$input_errors); + + + squid_print_javascript_auth2(); + + + squid_resync(); + + + squid_print_javascript_auth2(); + + + $transparent_proxy = ($config['installedpackages']['squid']['config'][0]['transparent_proxy'] == 'on'); + if($transparent_proxy) + $input_errors[] = "Authentication cannot be enabled while transparent proxy mode is enabled"; + squid_print_javascript_auth(); + + diff --git a/config/squid-8/squid_cache.xml b/config/squid-8/squid_cache.xml new file mode 100644 index 00000000..2a4b7e3d --- /dev/null +++ b/config/squid-8/squid_cache.xml @@ -0,0 +1,224 @@ + + + + + + . + 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. + */ +/* ========================================================================== */ + ]]> + + Describe your package here + Describe your package requirements here + Currently there are no FAQ items provided. + squidcache + none + Proxy server: Cache management + squid.inc + + + General + /pkg_edit.php?xml=squid.xml&id=0 + + + Upstream Proxy + /pkg_edit.php?xml=squid_upstream.xml&id=0 + + + Cache Mgmt + /pkg_edit.php?xml=squid_cache.xml&id=0 + + + + Access Control + /pkg_edit.php?xml=squid_nac.xml&id=0 + + + Traffic Mgmt + /pkg_edit.php?xml=squid_traffic.xml&id=0 + + + Auth Settings + /pkg_edit.php?xml=squid_auth.xml&id=0 + + + Local Users + /pkg.php?xml=squid_users.xml + + + + + Hard disk cache size + harddisk_cache_size + This is the amount of disk space (in megabytes) to use for cached objects. + input + + 100 + + + Hard disk cache system + harddisk_cache_system + This specifies the kind of storage system to use. <p> <b> ufs </b> is the old well-known Squid storage format that has always been there. <p> <b> aufs </b> uses POSIX-threads to avoid blocking the main Squid process on disk-I/O. (Formerly known as async-io.) <p> <b> diskd </b> uses a separate process to avoid blocking the main Squid process on disk-I/O. <p> <b> null </b> Does not use any storage. + select + aufs + + + + + + + + + Hard disk cache location + harddisk_cache_location + This is the directory where the cache will be stored. (note: do not end with a /). If you change this location, squid needs to make a new cache, this could take a while + input + 60 + + /var/squid/cache + + + Memory cache size + memory_cache_size + This is the amount of physical RAM (in megabytes) to be used for negative cache and in-transit objects. This value should not exceed more than 50% of the installed RAM. The minimum value is 1MB. + input + + 8 + + + Minimum object size + minimum_object_size + Objects smaller than the size specified (in kilobytes) will not be saved on disk. The default value is 0, meaning there is no minimum. + input + + 0 + + + Maximum object size + maximum_object_size + Objects larger than the size specified (in kilobytes) will not be saved on disk. If you wish to increase speed more than you want to save bandwidth, this should be set to a low value. + input + + 4 + + + Level 1 subdirectories + level1_subdirs + Each level-1 directory contains 256 subdirectories, so a value of 256 level-1 directories will use a total of 65536 directories for the hard disk cache. This will significantly slow down the startup process of the proxy service, but can speed up the caching under certain conditions. + select + 16 + + + + + + + + + + + + Memory replacement policy + memory_replacement_policy + The memory replacement policy determines which objects are purged from memory when space is needed. The default policy for memory replacement is GDSF. <p> <b> LRU: Last Recently Used Policy </b> - The LRU policies keep recently referenced objects. i.e., it replaces the object that has not been accessed for the longest time. <p> <b> Heap GDSF: Greedy-Dual Size Frequency </b> - The Heap GDSF policy optimizes object-hit rate by keeping smaller, popular objects in cache. It achieves a lower byte hit rate than LFUDA though, since it evicts larger (possibly popular) objects. <p> <b> Heap LFUDA: Least Frequently Used with Dynamic Aging </b> - The Heap LFUDA policy keeps popular objects in cache regardless of their size and thus optimizes byte hit rate at the expense of hit rate since one large, popular object will prevent many smaller, slightly less popular objects from being cached. <p> <b> Heap LRU: Last Recently Used </b> - Works like LRU, but uses a heap instead. <p> Note: If using the LFUDA replacement policy, the value of Maximum Object Size should be increased above its default of 12KB to maximize the potential byte hit rate improvement of LFUDA. + select + heap GDSF + + + + + + + + + Cache replacement policy + cache_replacement_policy + The cache replacement policy decides which objects will remain in cache and which objects are replaced to create space for the new objects. The default policy for cache replacement is LFUDA. Please see the type descriptions specified in the memory replacement policy for additional detail. + select + heap LFUDA + + + + + + + + + Low-water-mark in % + cache_swap_low + Cache replacement begins when the swap usage is above the low-low-water mark and attempts to maintain utilisation near the low-water-mark. + input + 90 + + + High-water-mark in % + cache_swap_high + As swap utilisation gets close to the high-water-mark object eviction becomes more aggressive. + input + 95 + + + Do not cache + donotcache + Enter each domain or IP address on a new line that should never be cached. + textarea + 50 + 5 + base64 + + + Enable offline mode + enable_offline + Enable this option and the proxy server will never try to validate cached objects. The offline mode gives access to more cached information than the proposed feature would allow (stale cached versions, where the origin server should have been contacted). + checkbox + + + + + if($_POST['harddisk_cache_size'] != $config['installedpackages']['squidcache']['config'][0]['harddisk_cache_size']) { + $needs_dash_z = true; + } + + + squid_validate_cache($_POST, &$input_errors); + + + squid_resync(); + if($needs_dash_z) + squid_dash_z(); + + diff --git a/config/squid-8/squid_extauth.xml b/config/squid-8/squid_extauth.xml new file mode 100644 index 00000000..41d9f633 --- /dev/null +++ b/config/squid-8/squid_extauth.xml @@ -0,0 +1,106 @@ + + + + + + . + 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. + */ +/* ========================================================================== */ + ]]> + + Describe your package here + Describe your package requirements here + Currently there are no FAQ items provided. + squidextnoauth + none + Services: Proxy Server -> Extended Authentication Settings + /pkg_edit.php?xml=squid_extauth.xml&id=0 + + + General + /pkg_edit.php?xml=squid_ng.xml&id=0 + + + + Upstream Proxy + /pkg_edit.php?xml=squid_upstream.xml&id=0 + + + + Cache Mgmt + /pkg_edit.php?xml=squid_cache.xml&id=0 + + + + Access Control + /pkg_edit.php?xml=squid_nac.xml&id=0 + + + + Traffic Mgmt + /pkg_edit.php?xml=squid_traffic.xml&id=0 + + + + Auth + /pkg_edit.php?xml=squid_auth.xml&id=0 + + + + Extended Auth + /pkg_edit.php?xml=squid_extauth.xml&id=0 + + + + + installedpackages->package->squidextnoauth->configuration->settings + + + No Authentication Defined + no_auth + text + + + + + require_once("/usr/local/pkg/squid_ng.inc"); + + global_write_squid_config(); + mwexec("/usr/local/sbin/squid -k reconfigure"); + + + diff --git a/config/squid-8/squid_nac.xml b/config/squid-8/squid_nac.xml new file mode 100644 index 00000000..193a89c6 --- /dev/null +++ b/config/squid-8/squid_nac.xml @@ -0,0 +1,143 @@ + + + + + + . + 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. + */ +/* ========================================================================== */ + ]]> + + Describe your package here + Describe your package requirements here + Currently there are no FAQ items provided. + squidnac + none + Proxy server: Access control + squid.inc + + + General + /pkg_edit.php?xml=squid.xml&id=0 + + + Upstream Proxy + /pkg_edit.php?xml=squid_upstream.xml&id=0 + + + Cache Mgmt + /pkg_edit.php?xml=squid_cache.xml&id=0 + + + Access Control + /pkg_edit.php?xml=squid_nac.xml&id=0 + + + + Traffic Mgmt + /pkg_edit.php?xml=squid_traffic.xml&id=0 + + + Auth Settings + /pkg_edit.php?xml=squid_auth.xml&id=0 + + + Local Users + /pkg.php?xml=squid_users.xml + + + + + Allowed subnets + allowed_subnets + Enter each subnet on a new line that is allowed to use the proxy. The subnets must be expressed as CIDR ranges (e.g.: 192.168.1.0/24). Note that the proxy interface subnet is already an allowed subnet. All the other subnets won't be able to use the proxy. + textarea + 50 + 5 + base64 + + + Unrestricted IPs + unrestricted_hosts + Enter each unrestricted IP address on a new line that is not to be filtered out by the other access control directives set in this page. + textarea + 50 + 5 + base64 + + + Banned host addresses + banned_hosts + Enter each IP address on a new line that is not to be allowed to use the proxy. + textarea + 50 + 5 + base64 + + + Whitelist + whitelist + Enter each destination domain on a new line that will be accessable to the users that are allowed to use the proxy. You also can use regular expressions. + textarea + 50 + 5 + base64 + + + Blacklist + blacklist + Enter each destination domain on a new line that will be blocked to the users that are allowed to use the proxy. You also can use regular expressions. + textarea + 50 + 5 + base64 + + + External Cache-Managers + ext_cachemanager + Enter the IPs for the external Cache Managers to be allowed here, separated by semi-colons (;). + input + 60 + + + + squid_validate_nac($_POST, &$input_errors); + + + squid_resync(); + + diff --git a/config/squid-8/squid_ng.inc b/config/squid-8/squid_ng.inc new file mode 100644 index 00000000..03f6d48c --- /dev/null +++ b/config/squid-8/squid_ng.inc @@ -0,0 +1,1070 @@ + + 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. + +*/ + +if(!function_exists("filter_configure")) + require_once("filter.inc"); + +function global_write_squid_config() +{ + global $config; + conf_mount_rw(); + config_lock(); + + /* define squid configuration file in variable for replace function */ + $squidconfig = "/usr/local/etc/squid/squid.conf"; + + /* squid.xml values */ + $active_interface = $config['installedpackages']['squid']['config'][0]['active_interface']; + $transparent_proxy = $config['installedpackages']['squid']['config'][0]['transparent_proxy']; + $log_enabled = $config['installedpackages']['squid']['config'][0]['log_enabled']; + $urlfier_enable = $config['installedpackages']['squid']['config'][0]['urlfilter_enable']; + $accesslog_disabled = $config['installedpackages']['squid']['config'][0]['accesslog_disabled']; + $log_query_terms = $config['installedpackages']['squid']['config'][0]['log_query_terms']; + $log_user_agents = $config['installedpackages']['squid']['config'][0]['log_user_agents']; + $proxy_port = $config['installedpackages']['squid']['config'][0]['proxy_port']; + $visible_hostname = $config['installedpackages']['squid']['config'][0]['visible_hostname']; + $cache_admin_email = $config['installedpackages']['squid']['config'][0]['cache_admin_email']; + $error_language = $config['installedpackages']['squid']['config'][0]['error_language']; + $cachemgr_enabled = $config['installedpackages']['squid']['config'][0]['cachemgr_enabled']; + + /* squid_upstream.xml values */ + $proxy_forwarding = $config['installedpackages']['squidupstream']['config'][0]['proxy_forwarding']; + $client_ip_forwarding = $config['installedpackages']['squidupstream']['config'][0]['client_ip_forwarding']; + $user_forwarding = $config['installedpackages']['squidupstream']['config'][0]['user_forwarding']; + $upstream_proxy = $config['installedpackages']['squidupstream']['config'][0]['upstream_proxy']; + $upstream_proxy_port = $config['installedpackages']['squidupstream']['config'][0]['upstream_proxy_port']; + $upstream_username = $config['installedpackages']['squidupstream']['config'][0]['upstream_username']; + $upstream_password = $config['installedpackages']['squidupstream']['config'][0]['upstream_psasword']; + + /* squid_cache.xml values */ + $memory_cache_size = $config['installedpackages']['squidcache']['config'][0]['memory_cache_size']; + $harddisk_cache_size = $config['installedpackages']['squidcache']['config'][0]['harddisk_cache_size']; + $minimum_object_size = $config['installedpackages']['squidcache']['config'][0]['minimum_object_size']; + $maximum_object_size = $config['installedpackages']['squidcache']['config'][0]['maximum_object_size']; + $level_subdirs = $config['installedpackages']['squidcache']['config'][0]['level_subdirs']; + $memory_replacement = $config['installedpackages']['squidcache']['config'][0]['memory_replacement']; + $cache_replacement = $config['installedpackages']['squidcache']['config'][0]['cache_replacement']; + $domain = $config['installedpackages']['squidcache']['config'][0]['domain']; + $enable_offline = $config['installedpackages']['squidcache']['config'][0]['enable_offline']; + + /* squid_nac.xml values */ + $allowed_subnets = $config['installedpackages']['squidnac']['config'][0]['allowed_subnets']; + $unrestricted_ip_addr = $config['installedpackages']['squidnac']['config'][0]['unrestricted_ip_address']; + $unrestricted_mac_addr = $config['installedpackages']['squidnac']['config'][0]['unrestricted_mac_addresses']; + $banned_ip_addr = $config['installedpackages']['squidnac']['config'][0]['banned_ip_addresses']; + $banned_mac_addr = $config['installedpackages']['squidnac']['config'][0]['banned_mac_addresses']; + $override_hosts = $config['installedpackages']['squidnac']['config'][0]['override_hosts']; + + /* squid_traffic.xml values */ + $max_download_size = $config['installedpackages']['squidtraffic']['config'][0]['max_download_size']; + $max_upload_size = $config['installedpackages']['squidtraffic']['config'][0]['max_upload_size']; + $dl_overall = $config['installedpackages']['squidtraffic']['config'][0]['dl_overall']; + $dl_per_host = $config['installedpackages']['squidtraffic']['config'][0]['dl_per_host']; + $throttle_binary_files = $config['installedpackages']['squidtraffic']['config'][0]['throttle_binary_files']; + $throttle_cd_images = $config['installedpackages']['squidtraffic']['config'][0]['throttle_cd_images']; + $throttle_multimedia = $config['installedpackages']['squidtraffic']['config'][0]['throttle_multimedia']; + + /* squid_auth.xml values */ + $auth_method = $config['installedpackages']['squidauth']['config'][0]['auth_method']; + $auth_processes = $config['installedpackages']['squidauth']['config'][0]['auth_processes']; + $auth_cache_ttl = $config['installedpackages']['squidauth']['config'][0]['auth_cache_ttl']; + $limit_ip_addr = $config['installedpackages']['squidauth']['config'][0]['limit_ip_addr']; + $user_ip_cache_ttl = $config['installedpackages']['squidauth']['config'][0]['user_ip_cache_ttl']; + $req_unrestricted_auth = $config['installedpackages']['squidauth']['config'][0]['req_unrestricted_auth']; + $auth_realm_prompt = $config['installedpackages']['squidauth']['config'][0]['auth_realm_prompt']; + $no_domain_auth = $config['installedpackages']['squidauth']['config'][0]['no_domain_auth']; + $min_pass_length = $config['installedpackages']['squidauth']['config'][0]['min_pass_length']; + $bypass_extended = $config['installedpackages']['squidauth']['config'][0]['bypass_extended']; + + /* squid_extauth.xml (ldap) values */ + $ldap_basedn = $config['installedpackages']['squidextldapauth']['config'][0]['ldap_basedn']; + $ldap_server = $config['installedpackages']['squidextldapauth']['config'][0]['ldap_server']; + $ldap_type = $config['installedpackages']['squidextldapauth']['config'][0]['ldap_type']; + $ldap_port = $config['installedpackages']['squidextldapauth']['config'][0]['ldap_port']; + $bind_dn_username = $config['installedpackages']['squidextldapauth']['config'][0]['bind_dn_username']; + $bind_dn_password = $config['installedpackages']['squidextldapauth']['config'][0]['bind_dn_password']; + + /* squid_extauth.xml (radius) values */ + $radius_server = $config['installedpackages']['squidextradiusauth']['config'][0]['radius_server']; + $radius_port = $config['installedpackages']['squidextradiusauth']['config'][0]['radius_port']; + $radius_identifier = $config['installedpackages']['squidextradiusauth']['config'][0]['radius_identifier']; + $radius_secret = $config['installedpackages']['squidextradiusauth']['config'][0]['radius_secret']; + + /* static variable assignments for directory mapping */ + $acldir = "/usr/local/etc/squid/advanced/acls"; + $ncsadir = "/usr/local/etc/squid/advanced/ncsa"; + $ntlmdir = "/usr/local/etc/squid/advanced/ntlm"; + $radiusdir = "/usr/local/etc/squid/advanced/radius"; + + $fout = fopen($squidconfig, "w"); + + $config_array = array('shutdown_lifetime 5 seconds' . "\n\n"); + + if (isset($cachemgr_enabled) && ($cachemgr_enabled == "on")) { + mwexec("cp /usr/local/libexec/squid/cachemgr.cgi /usr/local/www/cachemgr.cgi"); + mwexec("chmod a+rx /usr/local/www/cachemgr.cgi"); + } else { + mwexec("rm -f /usr/local/www/cachemgr.cgi"); + } + unset($cachemgr_enabled); + + if (!isset($icp_port) or ($icp_port == "")) { + $icp_port = "3130"; + } + $config_array[] = 'icp_port ' . $icp_port . "\n"; + unset($icp_port); + + if(!isset($proxy_port) or ($proxy_port == "")) { + $proxy_port = "3128"; + } + + if (isset($transparent_proxy) && ($transparent_proxy != "on")) { + $int = convert_friendly_interface_to_real_interface_name($active_interface); + $listen_ip = find_interface_ip($int); + + $config_array[] = 'http_port ' . $listen_ip . ':' . $proxy_port . "\n\n"; + $config_array[] = 'acl QUERY urlpath_regex cgi-bin \?' . "\n"; + $config_array[] = 'no_cache deny QUERY' . "\n\n"; + } + $config_array[] = 'http_port 127.0.0.1:' . $proxy_port . "\n\n"; + unset($proxy_port); + + if (isset($domain) && ($domain !== "")) { + if (!file_exists($acldir)) { + mwexec("/bin/mkdir -p " . $acldir); + } + + $aclout = fopen($acldir . "/dst_nocache.acl","w"); + + $domain_array = split("; ",$domain); + foreach ($domain_array as $no_cache_domain) { + fwrite($aclout, $no_cache_domain . "\n"); + } + + fclose($aclout); + + $config_array[] = 'acl no_cache_domains dstdomain "' . $acldir . '/dst_nocache.acl"' . "\n"; + $config_array[] = 'no_cache deny no_cache_domains' . "\n\n"; + } + unset($no_cache_domain); + unset($domain_array); + unset($domain); + + $config_array[] = 'cache_effective_user squid' . "\n"; + $config_array[] = 'cache_effective_group squid' . "\n\n"; + $config_array[] = 'pid_filename /var/run/squid.pid' . "\n\n"; + + if (!isset($memory_cache_size) or ($memory_cache_size == "")) { + $memory_cache_size = "8"; + } + $config_array[] = 'cache_mem ' . $memory_cache_size . ' MB' . "\n"; + unset($memory_cache_size); + + if (!isset($harddisk_cache_size) or ($harddisk_cache_size == "")) { + $harddisk_cache_size = "500"; + } + + if (!isset($level_subdirs) or ($level_subdirs == "")) { + $level_subdirs = "16"; + } + + $config_array[] = 'cache_dir diskd /var/squid/cache ' . $harddisk_cache_size . ' ' . $level_subdirs . ' 256' . "\n\n"; + unset($harddisk_cache_size); + unset($level_subdirs); + + if (!isset($error_language) or ($error_language == "")) { + $error_language = "English"; + } + $config_array[] = 'error_directory /usr/local/etc/squid/errors/' . $error_language . "\n\n"; + unset($error_language); + + if (isset($offline_mode) && ($offline_mode == "on")) { + $config_array[] = 'offline_mode on' . "\n\n"; + } else { + $config_array[] = 'offline_mode off' . "\n\n"; + } + + if (!isset($memory_replacement) or ($memory_replacement == "")) { + $memory_replacement = "heap GDSF"; + } + $config_array[] = 'memory_replacement_policy ' . $memory_replacement . "\n"; + unset($memory_replacement); + + if (!isset($cache_replacement) or ($cache_replacement == "")) { + $cache_replacement="heap GDSF"; + } + $config_array[] = 'cache_replacement_policy ' . $cache_replacement . "\n\n"; + unset($cache_replacement); + + if (isset($accesslog_disabled) && ($accesslog_disabled == "on")) { + $config_array[] = 'cache_access_log none' . "\n"; + } else { + $config_array[] = 'cache_access_log /var/log/access.log' . "\n"; + } + $config_array[] = 'cache_log /var/log/cache.log' . "\n"; + $config_array[] = 'cache_store_log none' . "\n"; + unset($accesslog_disabled); + unset($log_enabled); + + if (isset($log_query_terms) && ($log_query_terms == "on")) { + $config_array[] = 'strip_query_terms off' . "\n"; + } else { + $config_array[] = 'strip_query_terms on' . "\n"; + } + unset($log_query_terms); + + $config_array[] = 'useragent_log /var/log/useragent.log' . "\n\n"; + unset($log_user_agents); + + $config_array[] = 'log_mime_hdrs off' . "\n"; + $config_array[] = 'emulate_httpd_log on' . "\n"; + + switch ($user_forwarding) { + case "on": + $config_array[] = 'forwarded_for on' . "\n\n"; + break; + case "off": + $config_array[] = 'forwarded_for off' . "\n\n"; + break; + default: + $config_array[] = 'forwarded_for off' . "\n\n"; + break; + } + unset($user_forwarding); + + switch ($auth_method) { + case "none": + break; + case "local_auth": + $config_array[] = 'auth_param basic program /usr/local/libexec/squid/ncsa_auth /usr/local/etc/squid/advanced/ncsa/passwd' . "\n"; + if (!isset($auth_processes) or ($auth_processes == "")) { + $auth_processes = "5"; + } + $config_array[] = 'auth_param basic children ' . $auth_processes . "\n"; + + if (!isset($auth_realm_prompt) or ($auth_realm_prompt == "")) { + $auth_realm_prompt = "pfSense Advanced Proxy"; + } + $config_array[] = 'auth_param basic realm ' . $auth_realm_prompt . "\n"; + + if (!isset($auth_cache_ttl) or ($auth_cache_ttl == "")) { + $auth_cache_ttl = "60"; + } + $config_array[] = 'auth_param basic credentialsttl ' . $auth_cache_ttl . ' minutes' . "\n\n"; + $config_array[] = 'acl for_inetusers proxy_auth REQUIRED' . "\n\n"; + + unset($auth_realm_prompt); + unset($auth_processes); + unset($auth_cache_ttl); + + break; + case "radius_auth"; + $config_array[] = 'auth_param basic program /usr/local/libexec/squid/squid_rad_auth -h ' . $radius_server . ' -p ' . $radius_port . ' -i ' . $radius_identifier . ' -w ' . $radius_secret . "\n"; + if (!isset($auth_processes) or ($auth_processes == "")) { + $auth_processes = "5"; + } + $config_array[] = 'auth_param basic children ' . $auth_processes . "\n"; + + if (!isset($auth_realm_prompt) or ($auth_realm_prompt == "")) { + $auth_realm_prompt = "pfSense Advanced Proxy"; + } + $config_array[] = 'auth_param basic realm ' . $auth_realm_prompt . "\n"; + + if (!isset($auth_cache_ttl) or ($auth_cache_ttl == "")) { + $auth_cache_ttl = "60"; + } + $config_array[] = 'auth_param basic credentialsttl ' . $auth_cache_ttl . ' minutes' . "\n\n"; + $config_array[] = 'acl for_inetusers proxy_auth REQUIRED' . "\n\n"; + + unset($auth_realm_prompt); + unset($auth_processes); + unset($auth_cache_ttl); + + break; + case "ldap_bind"; + $config_array[] = 'auth_param basic program /usr/local/libexec/squid_ldap_auth -b "' . $ldap_basedn . '" -D "' . $bind_dn_username . '" -w "' . $bind_dn_password . '" -f "(&(objectClass=person)(cn=%s))" -u -cn -P "' . $ldap_server . ":" . $ldap_port . "\n"; + $config_array[] = 'auth_param basic program /usr/local/libexec/squid/squid_ldap_auth'; + $config_array[] = ' -b "' . $ldap_basedn . '"'; + $config_array[] = ' -D "' . $bind_dn_username . '"'; + $config_array[] = " -w " . $bind_dn_password; + $config_array[] = ' -f "(&(objectClass=person)(cn=%s))"'; + $config_array[] = " -u cn -P " . $ldap_server . ":" . $ldap_port . "\n"; + + if (!isset($auth_processes) or ($auth_processes == "")) { + $auth_processes = "5"; + } + $config_array[] = 'auth_param basic children ' . $auth_processes . "\n"; + + if (!isset($auth_realm_prompt) or ($auth_realm_prompt == "")) { + $auth_realm_prompt = "pfSense Advanced Proxy"; + } + $config_array[] = 'auth_param basic realm ' . $auth_realm_prompt . "\n"; + + if (!isset($auth_cache_ttl) or ($auth_cache_ttl == "")) { + $auth_cache_ttl = "60"; + } + $config_array[] = 'auth_param basic credentialsttl ' . $auth_cache_ttl . ' minutes' . "\n\n"; + $config_array[] = 'acl for_inetusers proxy_auth REQUIRED' . "\n\n"; + + unset($auth_realm_prompt); + unset($auth_processes); + unset($auth_cache_ttl); + + break; + case "windows_auth"; + break; + } + + if (isset($throttle_binary_files) && ($throttle_binary_files == "on")) { + if (!file_exists($acldir)) { + mwexec("/bin/mkdir -p " . $acldir); + } + + $binary_out = "\.bin$\n\.cab$\n\.gz$\n\.rar$\n\.sea$\n\.tar$\n\.tgz$\n\.zip$\n"; + + $throttle_out = fopen($acldir . "/dst_throttle_binary.acl", "w"); + fwrite($throttle_out, $binary_out); + fclose($throttle_out); + $config_array[] = 'acl for_throttled_binary url_regex -i "' . $acldir . '/dst_throttle_binary.acl"' . "\n"; + } else { + if (file_exists($acldir . "/dst_throttle_binary.acl")) unlink($acldir . "/dst_throttle_binary.acl"); + } + unset($throttle_binary_files); + unset($throttle_out); + unset($binary_out); + + if (isset($throttle_cd_images) && ($throttle_cd_images == "on")) { + if (!file_exists($acldir)) { + mwexec("/bin/mkdir -p " . $acldir); + } + + $cd_out = "\.b5t$\n\.bin$\n\.bwt$\n\.cdi$\n\.cue$\n\.gho$\n\.img$\n\.iso$\n\.mds$\n\.nrg$\n\.pqi$\n"; + + $throttle_out = fopen($acldir . "/dst_throttle_cd.acl","w"); + fwrite($throttle_out, $cd_out); + fclose($throttle_out); + $config_array[] = 'acl for_throttled_cd url_regex -i "' . $acldir . '/dst_throttle_cd.acl"' . "\n"; + } else { + if (file_exists($acldir . "/dst_throttle_cd.acl")) { + unlink($acldir . "/dst_throttle_cd.acl"); + } + } + unset($throttle_cd_images); + unset($throttle_out); + unset($cd_out); + + if (isset($throttle_multimedia) && ($throttle_multimedia == "on")) { + if (!file_exists($acldir)) { + mwexec("/bin/mkdir -p " . $acldir); + } + + $multimedia_out = "\.aiff?$\n\.asf$\n\.avi$\n\.divx$\n\.mov$\n\.mp3$\n\.mpe?g$\n\.qt$\n\.ra?m$\n"; + + $throttle_out = fopen($acldir . "/dst_throttle_multimedia.acl","w"); + fwrite($throttle_out, $multimedia_out); + fclose($throttle_out); + $config_array[] = 'acl for_throttled_multimedia url_regex -i "' . $acldir . '/dst_throttle_multimedia.acl"' . "\n"; + } else { + if (file_exists($acldir . "/dst_throttle_multimedia.acl")) { + unlink($acldir . "/dst_throttle_multimedia.acl"); + } + } + unset($throttle_multimedia); + unset($multimedia_out); + unset($throttle_out); + + $config_array[] = 'acl within_timeframe time MTWHFAS 00:00-24:00' . "\n\n"; + + /* obtain interface subnet and address for Squid rules */ + $lactive_interface = strtolower($active_interface); + + $lancfg = $config['interfaces'][$lactive_interface]; + $lanif = $lancfg['if']; + $lanip = $lancfg['ipaddr']; + $lansa = gen_subnet($lancfg['ipaddr'], $lancfg['subnet']); + $lansn = $lancfg['subnet']; + + $config_array[] = 'acl all src 0.0.0.0/0.0.0.0' . "\n"; + $config_array[] = 'acl localnet src ' . $lansa . '/' . $lansn . "\n"; + $config_array[] = 'acl localhost src 127.0.0.1/255.255.255.255' . "\n"; + $config_array[] = 'acl SSL_ports port 443 563 873 # https, snews, rsync' . "\n"; + $config_array[] = 'acl Safe_ports port 80 # http' . "\n"; + $config_array[] = 'acl Safe_ports port 21 # ftp' . "\n"; + $config_array[] = 'acl Safe_ports port 443 563 873 # https, snews, rsync' . "\n"; + $config_array[] = 'acl Safe_ports port 70 # gopher' . "\n"; + $config_array[] = 'acl Safe_ports port 210 # wais' . "\n"; + $config_array[] = 'acl Safe_ports port 1025-65535 # unregistered ports' . "\n"; + $config_array[] = 'acl Safe_ports port 280 # http-mgmt' . "\n"; + $config_array[] = 'acl Safe_ports port 488 # gss-http' . "\n"; + $config_array[] = 'acl Safe_ports port 591 # filemaker' . "\n"; + $config_array[] = 'acl Safe_ports port 777 # multiling http' . "\n"; + $config_array[] = 'acl Safe_ports port 800 # Squids port (for icons)' . "\n\n"; + + /* allow access through proxy for custom admin port */ + $custom_port = $config['system']['webgui']['port']; + if (isset($custom_port) && ($custom_port !== "")) { + $config_array[] = 'acl pf_admin_port port ' . $custom_port . "\n"; + unset($custom_port); + } else { + $admin_protocol = $config['system']['webgui']['protocol']; + switch ($admin_protocol) { + case "http"; + $config_array[] = 'acl pf_admin_port port 80' ."\n"; + break; + case "https"; + $config_array[] = 'acl pf_admin_port port 443' . "\n"; + break; + default; + $config_array[] = 'acl pf_admin_port port 80' . "\n"; + break; + } + unset($admin_protocol); + } + + /* define override hosts as specified in squid_nac.xml */ + if (isset($override_hosts) && ($override_hosts !== "")) { + if (!file_exists($acldir)) { + mwexec("/bin/mkdir -p " . $acldir); + } + + $aclout = fopen($acldir . "/src_override_hosts.acl", "w"); + + $override_hosts_array = split("; ", $override_hosts); + foreach ($override_hosts_array as $ind_override_host) { + fwrite($aclout, $ind_override_host . "\n"); + } + + fclose($aclout); + + $config_array[] = 'acl override_hosts src "/usr/local/etc/squid/advanced/acls/src_override_hosts.acl"' . "\n"; + } + /* clear variables */ + unset($override_hosts_array); + unset($ind_override_host); + unset($override_hosts); + + /* define subnets allowed to utilize proxy service */ + if (isset($allowed_subnets) && ($allowed_subnets !== "")) { + if (!file_exists($acldir)) { + mwexec("/bin/mkdir -p " . $acldir); + mwexec("touch {$acldir}/src_subnets.acl"); + } + + $aclout = fopen($acldir . "/src_subnets.acl","w"); + + $allowed_subnets_array = split("; ",$allowed_subnets); + foreach ($allowed_subnets_array as $ind_allowed_subnets) { + fwrite($aclout, $ind_allowed_subnets . "\n"); + } + + fclose($aclout); + } else { + + $aclout = fopen($acldir . "/src_subnets.acl","w"); + fwrite($aclout, $lansa . "/" . $lansn . "\n"); + fclose($aclout); + } + + $config_array[] = 'acl pf_networks src "/usr/local/etc/squid/advanced/acls/src_subnets.acl"' . "\n"; + + unset($allowed_subnets_array); + unset($ind_allowed_subnets); + unset($allowed_subnets); + + /* define ip addresses that have 'unrestricted' access */ + if (isset($unrestricted_ip_addr) && ($unrestricted_ip_addr !== "")) { + if (!file_exists($acldir)) { + mwexec("/bin/mkdir -p " . $acldir); + } + + $aclout = fopen($acldir . "/src_unrestricted_ip.acl","w"); + + $unrestricted_ip_array = split("; ",$unrestricted_ip_addr); + foreach ($unrestricted_ip_array as $ind_unrestricted_ip) { + fwrite($aclout, $ind_unrestricted_ip . "\n"); + } + + fclose($aclout); + + $config_array[] = 'acl pf_unrestricted_ip src "/usr/local/etc/squid/advanced/acls/src_unrestricted_ip.acl"' . "\n"; + } + unset($unrestricted_ip_array); + unset($unrestricted_ip_addr); + unset($ind_unrestricted_ip); + + /* define mac addresses that have 'unrestricted' access */ + if (isset($unrestricted_mac_addr) && ($unrestricted_mac_addr !== "")) { + if (!file_exists($acldir)) { + mwexec("/bin/mkdir -p " . $acldir); + } + + $aclout = fopen($acldir . "/src_unrestricted_mac.acl","w"); + + $unrestricted_mac_array = split("; ",$unrestricted_mac_addr); + foreach ($unrestricted_mac_array as $ind_unrestricted_mac) { + fwrite($aclout, $ind_unrestricted_mac . "\n"); + } + + fclose($aclout); + + $config_array[] = 'acl pf_unrestricted_mac src "/usr/local/etc/squid/advanced/acls/src_unrestricted_mac.acl"' . "\n"; + } + unset($unrestricted_mac_array); + unset($unrestricted_mac_addr); + unset($ind_unrestricted_mac); + + /* define ip addresses that are banned from using the proxy service */ + if (isset($banned_ip_addr) && ($banned_ip_addr !== "")) { + if (!file_exists($acldir)) { + mwexec("/bin/mkdir -p " . $acldir); + } + + $aclout = fopen($acldir . "/src_banned_ip.acl","w"); + + $banned_ip_array = split("; ",$banned_ip_addr); + foreach ($banned_ip_array as $ind_banned_ip) { + fwrite($aclout, $ind_banned_ip . "\n"); + } + + fclose($aclout); + + $config_array[] = 'acl pf_banned_ip src "/usr/local/etc/squid/advanced/acls/src_banned_ip.acl"' . "\n"; + } + unset($banned_ip_addr); + unset($banned_ip_addr); + unset($ind_banned_ip); + + /* define mac addresses that are banned from using the proxy service */ + if (isset($banned_mac_addr) && ($banned_mac_addr !== "")) { + if (!file_exists($acldir)) { + mwexec("/bin/mkdir -p " . $acldir); + } + + $aclout = fopen($acldir . "/src_banned_mac.acl","w"); + + $banned_mac_array = split("; ",$banned_mac_addr); + foreach ($banned_mac_array as $ind_banned_mac) { + fwrite($aclout, $ind_banned_mac . "\n"); + } + + fclose($aclout); + + $config_array[] = 'acl pf_banned_mac src "/usr/local/etc/squid/advanced/acls/src_banned_mac.acl"' . "\n"; + } + unset($banned_mac_array); + unset($banned_mac_addr); + unset($ind_banned_mac); + + $config_array[] = 'acl pf_ips dst ' . $lanip . "\n"; + $config_array[] = 'acl CONNECT method CONNECT' . "\n\n"; + + if (isset($auth_method) && ($auth_method == "none")) { + $config_array[] = 'http_access allow localnet' . "\n"; + } + $config_array[] = 'http_access allow localhost' . "\n"; + + if (isset($override_hosts) && ($override_hosts !== "")) { + $config_array[] = 'http_access allow override_hosts' . "\n"; + } + $config_array[] = "\n"; + + switch ($config['system']['webgui']['protocol']) { + case "http": + $config_array[] = 'http_access allow pf_ips' . "\n"; + $config_array[] = 'http_access allow pf_admin_port' . "\n"; + $config_array[] = 'http_access deny !pf_networks' . "\n\n"; + break; + case "https": + $config_array[] = 'http_access allow CONNECT pf_ips' . "\n"; + $config_array[] = 'http_access allow CONNECT pf_admin_port' . "\n"; + $config_array[] = 'http_access deny CONNECT !pf_networks' . "\n\n"; + break; + } + + $config_array[] = 'http_access deny !Safe_ports' . "\n"; + $config_array[] = 'http_access deny CONNECT !SSL_ports' . "\n\n"; + + if (isset($auth_method) && ($auth_method != "none")) { + $config_array[] = 'http_access allow pf_networks for_inetusers within_timeframe' . "\n"; + } + + $config_array[] = 'http_access deny all' . "\n\n"; + + if (isset($dl_overall) && ($dl_overall !== "") and isset($dl_per_host) && ($dl_per_host == "")) { + $config_array[] = 'delay_pools 1' . "\n"; + $config_array[] = 'delay_class 1 3' . "\n"; + + if ($dl_overall == "unlimited") { + $config_array[] = 'delay_parameters 1 -1/-1 -1/-1 ' . ($dl_overall * 125) . '/' . ($dl_overall * 250) . "\n"; + } else { + $config_array[] = 'delay_parameters 1 ' . ($dl_overall * 125) . '/' . ($dl_overall * 250) . ' -1/-1 -1/-1' . "\n"; + } + + /* if no unrestricted ip addresses are defined; this line is ignored */ + if (isset($unrestricted_ip_addr) && ($unrestricted_ip_addr == "")) $config_array[] = 'delay_access 1 deny pf_unrestricted_ip' . "\n"; + + /* this will define bandwidth delay restrictions for specified throttles */ + if (isset($throttle_binary_files) && ($throttle_binary_files == "on")) { + $config_array[] = 'delay_access 1 allow all for_throttled_binary' . "\n"; + } + if (isset($throttle_cd_images) && ($throttle_cd_images == "on")) { + $config_array[] = 'delay_access 1 allow all for_throttled_cd' . "\n"; + } + if (isset($throttle_multimedia) && ($throttle_multimedia == "on")) { + $config_array[] = 'delay_access 1 allow all for_throttled_multimedia' . "\n"; + } else { + $config_array[] = 'delay_access 1 allow all' . "\n"; + } + $config_array[] = 'delay_initial_bucket_level 100%' . "\n\n"; + } + + if (isset($dl_per_host) && ($dl_per_host !== "") and isset($dl_overall) && ($dl_overall == "")) { + $config_array[] = 'delay_pools 1' . "\n"; + $config_array[] = 'delay_class 1 3' . "\n"; + + if ($dl_per_host == "unlimited") { + $config_array[] = 'delay_parameters 1 ' . ($dl_per_host * 125) . '/' . ($dl_per_host * 250) . '-1/-1 -1/-1' . "\n"; + } else { + $config_array[] = 'delay_parameters 1 -1/-1 -1/-1 ' . ($dl_per_host * 125) . '/' . ($dl_per_host * 250) . "\n"; + } + + /* if no unrestricted ip addresses are defined; this line is ignored */ + if (isset($unrestricted_ip_addr) && ($unrestricted_ip_addr !== "")) $config_array[] = 'delay_access 1 deny pf_unrestricted_ip' . "\n"; + + /* this will define bandwidth delay restrictions for specified throttles */ + if ($throttle_binary_files == "on") { + $config_array[] = 'delay_access 1 allow all for_throttled_binary' . "\n"; + } + if ($throttle_cd_images == "on") { + $config_array[] = 'delay_access 1 allow all for_throttled_cd' . "\n"; + } + if ($throttle_multimedia == "on") { + $config_array[] = 'delay_access 1 allow all for_throttled_multimedia' ."\n"; + } else { + $config_array[] = 'delay_access 1 allow all' . "\n"; + } + $config_array[] = 'delay_initial_bucket_level 100%' . "\n\n\n"; + } + + if (isset($dl_overall) && ($dl_overall !== "") and isset($dl_per_host) && ($dl_per_host !== "")) { + /* if no bandwidth restrictions are specified, then these parameters are not necessary */ + if ($dl_overall !== "unlimited" and $dl_per_host !== "unlimited") { + + if ((isset($dl_overall) && ($dl_overall == "unlimited")) and (isset($dl_per_host) && ($dl_per_host !== ""))) { + $config_array[] = 'delay_pools 1' . "\n"; + $config_array[] = 'delay_class 1 3' . "\n"; + $config_array[] = 'delay_parameters 1 -1/-1 -1/-1 ' . ($dl_per_host * 125) . '/' . ($dl_overall * 250) . "\n"; + } elseif (isset($dl_overall) && ($dl_overall !== "") and isset($dl_per_host) && ($dl_per_host == "unlimited")) { + $config_array[] = 'delay_pools 1' . "\n"; + $config_array[] = 'delay_class 1 3' . "\n"; + $config_array[] = 'delay_parameters 1 ' . ($dl_overall * 125) . '/' . ($dl_overall * 250) . ' -1/-1 -1/-1' . "\n"; + } + } + + if ($dl_overall !== "unlimited" and $dl_per_host !== "unlimited") { + + /* if no unrestricted ip addresses are defined; this line is ignored */ + if (isset($unrestricted_ip_addr) && ($unrestricted_ip_addr !== "")) $config_array[] = 'delay_access 1 deny pf_unrestricted_ip' . "\n"; + + /* this will define bandwidth delay restrictions for specified throttles */ + if ($throttle_binary_files == "on") { + $config_array[] = 'delay_access 1 allow all for_throttled_binary' . "\n"; + } + if ($throttle_cd_images == "on") { + $config_array[] = 'delay_access 1 allow all for_throttled_cd' . "\n"; + } + if ($throttle_multimedia == "on") { + $config_array[] = 'delay_access 1 allow all for_throttled_multimedia' . "\n"; + } else { + $config_array[] = 'delay_access 1 allow all' . "\n"; + } + $config_array[] = 'delay_initial_bucket_level 100%' . "\n\n"; + } + } + + $config_array[] = 'header_access X-Forwarded-For deny all' . "\n"; + $config_array[] = 'header_access Via deny all' . "\n\n"; + + /* TODO: acl customization for snmp support */ + /* fwrite($fout, "\n"); */ + + if (isset($urlfilter_enable) && ($urlfilter_enable == "on")) { + $config_array[] = 'redirect_program /usr/sbin/squidGuard' . "\n"; + $config_array[] = 'redirect_children 5' . "\n\n"; + } + + if (isset($max_upload_size) && ($max_upload_size != "")) { + $config_array[] = 'request_body_max_size ' . $max_download_size . 'KB' . "\n"; + } + + if (isset($max_download_size) && ($max_download_size != "")) { + if (isset($unrestricted_ip_addr) && ($unrestricted_ip_addr !== "")) $config_array[] = 'reply_body_max_size 0 allow pf_unrestricted_ip' . "\n"; + /* fwrite($fout, "#reply_body_max_size 0 allow for_extended_users\n"); */ + $config_array[] = 'reply_body_max_size ' . $max_download_size * 1024 . ' allow all' . "\n\n"; + } + + /* set default value for maximum_object_size */ + if (!isset($maximum_object_size) or ($maximum_object_size == "")) { + $maximum_object_size = "4096"; + } + + /* set default value for minimum_object_size */ + if (!isset($minimum_object_size) or ($minimum_object_size == "")) { + $minimum_object_size = "0"; + } + $config_array[] = 'maximum_object_size ' . $maximum_object_size . ' KB' . "\n"; + $config_array[] = 'minimum_object_size ' . $minimum_object_size . ' KB' . "\n\n"; + + if (isset($proxy_forwarding) && ($proxy_forwarding == "on")) { + $config_array[] = 'cache_peer ' . $upstream_proxy . ' parent ' . $upstream_proxy_port . ' 3130 login=' . upstream_username . ':' . upstream_password . ' default no-query' . "\n"; + $config_array[] = 'never_direct allow all' . "\n"; + } + unset($proxy_forwarding); + + + /* define default ruleset for transparent proxy operation */ + if (isset($transparent_proxy) && ($transparent_proxy == "on")) { + $config_array[] = 'httpd_accel_host virtual' . "\n"; + $config_array[] = 'httpd_accel_port 80' . "\n"; + $config_array[] = 'httpd_accel_with_proxy on' . "\n"; + $config_array[] = 'httpd_accel_uses_host_header on' . "\n\n"; + } + unset($transparent_proxy); + + + /* define visible hostname */ + if (isset($visible_hostname) && ($visible_hostname !== "")) { + $config_array[] = 'visible_hostname ' . $visible_hostname . "\n"; + } + unset($visible_hostname); + + /* define cache administrators email address within error messages */ + if (isset($cache_admin_email) && ($cache_admin_email !== "")) { + $config_array[] = 'cache_mgr ' . $cache_admin_email . "\n\n"; + } + unset($cache_admin_email); + + /* write configuration file */ + foreach ($config_array as $config_item) + { + fwrite($fout, trim($config_item)); + + if (stristr($config_item, "\n")) + { + for ($i = 1; $i < count(explode("\n", $config_item)); $i++) + { + fwrite($fout, "\n"); + } + } + + } + fclose($fout); + + conf_mount_ro(); + config_unlock(); + + touch($squidconfig); +} /* end function write_squid_config */ + +function custom_php_install_command() { + /* write initial static config for transparent proxy */ + write_static_squid_config(); + + touch("/tmp/custom_php_install_command"); + + /* make sure this all exists, see: + * http://forum.pfsense.org/index.php?topic=23.msg2391#msg2391 + */ + update_output_window("Setting up Squid environment..."); + mwexec("mkdir -p /var/squid"); + mwexec("chown squid:squid /var/squid"); + mwexec("mkdir -p /var/squid/logs"); + mwexec("chown squid:squid /var/squid/logs"); + mwexec("mkdir -p /var/squid/cache"); + mwexec("chown squid:squid /var/squid/cache"); + mwexec("mkdir -p /usr/local/etc/squid/advanced"); + mwexec("chown squid:squid /usr/local/etc/squid/advanced"); + mwexec("mkdir -p /usr/local/etc/squid/advanced/acls"); + mwexec("chown squid:squid /usr/local/etc/squid/advanced/acls"); + mwexec("touch /usr/local/etc/squid/advanced/acls/src_subnets.acl"); + mwexec("chown squid:squid /usr/local/etc/squid/advanced/acls/src_subnets.acl"); + mwexec("touch /usr/local/etc/squid/advanced/acls/src_unrestricted_ip.acl"); + mwexec("chown squid:squid /usr/local/etc/squid/advanced/acls/src_unrestricted_ip.acl"); + mwexec("cp /usr/local/etc/squid/mime.conf.default /usr/local/etc/squid/mime.conf"); + + + /* set a few extra items noted by regan */ + update_output_window("Creating logs and setting user information..."); + $fdsquid = fopen("/usr/local/etc/rc.d/aSquid.sh", "w"); + fwrite($fdsquid, "#/bin/sh\n"); + fwrite($fdsquid, "# \n"); + fwrite($fdsquid, "# This file was created by the pfSense package system\n"); + fwrite($fdsquid, "# Sets up squid option on each bootup that are not persistent\n"); + fwrite($fdsquid, "# \n\n"); + fwrite($fdsquid, "chown squid:wheel /dev/pf\n"); + fwrite($fdsquid, "chmod ug+rw /dev/pf\n"); + fwrite($fdsquid, "touch /var/log/useragent.log\n"); + fwrite($fdsquid, "touch /var/log/access.log\n"); + fwrite($fdsquid, "touch /var/log/cache.log\n"); + fwrite($fdsquid, "chown squid:wheel /var/log/cache.log\n"); + fwrite($fdsquid, "chown squid:wheel /var/log/access.log\n"); + fwrite($fdsquid, "chown squid:wheel /var/log/useragent.log\n"); + fwrite($fdsquid, "\n"); + fclose($fdsquid); + mwexec("chmod a+rx /usr/local/etc/rc.d/aSquid.sh"); + mwexec("/usr/local/etc/rc.d/aSquid.sh"); + + update_output_window("Creating Proxy Server initialization scripts..."); + $start = "touch /tmp/ro_root_mount; /usr/local/sbin/squid -D; touch /tmp/filter_dirty"; + $stop = "/usr/local/sbin/squid -k shutdown"; + write_rcfile(array( + "file" => "squid.sh", + "start" => $start, + "stop" => $stop + ) + ); + + mwexec("chmod 755 /usr/local/etc/rc.d/squid.sh"); + + /* create log directory hierarchies if they don't exist */ + update_output_window("Creating required directory hierarchies..."); + + if (!file_exists("/var/squid/logs")) { + mwexec("mkdir -p /var/squid/logs"); + } + mwexec("/usr/sbin/chown squid:squid /var/squid/logs"); + + + if (!file_exists("/var/squid/cache")) { + mwexec("mkdir -p /var/squid/cache"); + } + mwexec("/usr/sbin/chown squid:squid /var/squid/cache"); + + if (!file_exists("/usr/local/etc/squid/advanced/acls")) { + mwexec("mkdir -p /usr/local/etc/squid/advanced/acls"); + } + mwexec("/usr/sbin/chown squid:squid /usr/local/etc/squid/advanced/acls"); + + if (!file_exists("/usr/local/etc/squid/advanced/ncsa")) { + mwexec("mkdir -p /usr/local/etc/squid/advanced/ncsa"); + } + mwexec("/usr/sbin/chown squid:squid /usr/local/etc/squid/advanced/ncsa"); + + if (!file_exists("/usr/local/etc/squid/advanced/ntlm")) { + mwexec("mkdir -p /usr/local/etc/squid/advanced/ntlm"); + } + mwexec("/usr/sbin/chown squid:squid /usr/local/etc/squid/advanced/ntlm"); + + if (!file_exists("/usr/local/etc/squid/advanced/radius")) { + mwexec("mkdir -p /usr/local/etc/squid/advanced/radius"); + } + mwexec("/usr/sbin/chown squid:squid /usr/local/etc/squid/advanced/radius"); + + $devfs_file = fopen("/etc/devfs.conf", "a"); + fwrite($devfs_file, "\n# Allow squid to query the packet filter bymaking is group-accessable. "); + fwrite($devfs_file, "own pf root:squid"); + fwrite($devfs_file, "perm pf 0640"); + fclose($devfs_file); + + update_output_window("Initializing Cache... This may take a moment..."); + mwexec("/usr/local/sbin/squid -z"); + + update_output_window("Starting Proxy Server..."); + start_service("squid"); +} + +function custom_php_deinstall_command() { + update_output_window("Stopping proxy service..."); + stop_service("squid"); + sleep(1); + /* brute force any remaining squid processes out */ + mwexec("/usr/bin/killall squid"); + mwexec("/usr/bin/killall pinger"); + update_output_window("Recursively removing directories hierarchies. If existant, log files in /var/squid/logs will remain..."); + mwexec("rm -rf /var/squid/cache"); + update_output_window("Removing configuration files..."); + unlink_if_exists("/usr/local/etc/rc.d/squid.sh"); + unlink_if_exists("/usr/local/libexec/squid"); + unlink_if_exists("/usr/local/etc/rc.d/aSquid.sh"); + mwexec("rm -f /usr/local/etc/rc.d/squid*"); + mwexec("rm -f /usr/local/www/cachemgr.cgi"); + filter_configure(); +} + +function write_static_squid_config() { + touch("/tmp/write_static_squid_config"); + global $config; + $lancfg = $config['interfaces']['lan']; + $lanif = $lancfg['if']; + $lanip = $lancfg['ipaddr']; + $lansa = gen_subnet($lancfg['ipaddr'], $lancfg['subnet']); + $lansn = $lancfg['subnet']; + + $fout = fopen("/usr/local/etc/squid/squid.conf","w"); + fwrite($fout, "#\n"); + fwrite($fout, "# This file was automatically generated by the pfSense package manager.\n"); + fwrite($fout, "# This default policy enables transparent proxy with no local disk logging.\n"); + fwrite($fout, "#\n"); + + /* set # of dns children */ + fwrite($fout, "dns_children 15\n"); + + fwrite($fout, "shutdown_lifetime 5 seconds\n"); + fwrite($fout, "icp_port 0\n"); + fwrite($fout, "\n"); + + fwrite($fout, "acl QUERY urlpath_regex cgi-bin \?\n"); + fwrite($fout, "no_cache deny QUERY\n"); + fwrite($fout, "\n"); + + fwrite($fout, "pid_filename /var/run/squid.pid\n"); + fwrite($fout, "\n"); + + fwrite($fout, "cache_mem 24 MB\n"); + fwrite($fout, "cache_dir diskd /var/squid/cache 500 16 256\n"); + fwrite($fout, "\n"); + + fwrite($fout, "error_directory /usr/local/etc/squid/errors/English\n"); + fwrite($fout, "\n"); + + fwrite($fout, "memory_replacement_policy heap GDSF\n"); + fwrite($fout, "cache_replacement_policy heap GDSF\n"); + fwrite($fout, "\n"); + + fwrite($fout, "cache_access_log none\n"); + fwrite($fout, "cache_log none\n"); + fwrite($fout, "cache_store_log none\n"); + fwrite($fout, "\n"); + + fwrite($fout, "log_mime_hdrs off\n"); + fwrite($fout, "emulate_httpd_log on\n"); + fwrite($fout, "forwarded_for off\n"); + fwrite($fout, "\n"); + + fwrite($fout, "acl within_timeframe time MTWHFAS 00:00-24:00\n"); + fwrite($fout, "\n"); + + fwrite($fout, "acl all src 0.0.0.0/0.0.0.0\n"); + fwrite($fout, "acl localnet src " . $lansa . "/" . $lansn . "\n"); + fwrite($fout, "acl localhost src 127.0.0.1/255.255.255.255\n"); + fwrite($fout, "acl SSL_ports port 443 563 873 # https, snews, rsync\n"); + fwrite($fout, "acl Safe_ports port 80 # http\n"); + fwrite($fout, "acl Safe_ports port 21 # ftp\n"); + fwrite($fout, "acl Safe_ports port 443 563 873 # https, snews, rsync\n"); + fwrite($fout, "acl Safe_ports port 70 # gopher\n"); + fwrite($fout, "acl Safe_ports port 210 # wais\n"); + fwrite($fout, "acl Safe_ports port 1025-65535 # unregistered ports\n"); + fwrite($fout, "acl Safe_ports port 280 # http-mgmt\n"); + fwrite($fout, "acl Safe_ports port 488 # gss-http\n"); + fwrite($fout, "acl Safe_ports port 591 # filemaker\n"); + fwrite($fout, "acl Safe_ports port 777 # multiling http\n"); + fwrite($fout, "acl Safe_ports port 800 # Squids port (for icons)\n"); + fwrite($fout, "\n"); + + fwrite($fout, "acl CONNECT method CONNECT\n"); + fwrite($fout, "\n"); + + fwrite($fout, "#access to squid; local machine; no restrictions\n"); + fwrite($fout, "http_access allow localnet\n"); + fwrite($fout, "http_access allow localhost\n"); + fwrite($fout, "\n"); + + fwrite($fout, "#Deny non web services\n"); + fwrite($fout, "http_access deny !Safe_ports\n"); + fwrite($fout, "http_access deny CONNECT !SSL_ports\n"); + fwrite($fout, "\n"); + + fwrite($fout, "#Set custom configured ACLs\n"); + fwrite($fout, "http_access deny all\n"); + fwrite($fout, "visible_hostname pfSense\n"); + fwrite($fout, "\n"); + + fwrite($fout, "cache_effective_user squid\n"); + fwrite($fout, "cache_effective_group squid\n"); + fwrite($fout, "\n"); + + fwrite($fout, "maximum_object_size 4096 KB\n"); + fwrite($fout, "minimum_object_size 0 KB\n"); + fwrite($fout, "\n"); + + fwrite($fout, "request_body_max_size 0 KB\n"); + fwrite($fout, "reply_body_max_size 0 allow all\n"); + fwrite($fout, "\n"); + + fwrite($fout, "httpd_accel_host virtual\n"); + fwrite($fout, "httpd_accel_port 80\n"); + fwrite($fout, "httpd_accel_with_proxy on\n"); + fwrite($fout, "httpd_accel_uses_host_header on\n"); + + fclose($fout); +} + +function mod_htpasswd() { + global $config; + conf_mount_rw(); + config_lock(); + + if (!file_exists("/usr/local/etc/squid/advanced/ncsa")) mwexec("mkdir -p /usr/local/etc/squid/advanced/ncsa"); + + $passfile = fopen("/usr/local/etc/squid/advanced/ncsa/passwd", "w+"); + + if (isset($config['installedpackages']['squidextlocalauth']['config']) && $config['installedpackages']['squidextlocalauth']['config'] != "") { + foreach($config['installedpackages']['squidextlocalauth']['config'] as $rowhelper) { + $encpass = generate_htpasswd($rowhelper['username'], $rowhelper['password']); + fwrite($passfile, $rowhelper['username'] . ":" . $encpass . "\n"); + } + } + + fclose($passfile); + + conf_mount_ro(); + config_unlock(); +} + +function generate_htpasswd($username, $password) { + $all = explode( " ", + "a b c d e f g h i j k l m n o p q r s t u v w x y z " + . "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z " + . "0 1 2 3 4 5 6 7 8 9"); + + for ($i = 0; $i < 9; $i++) { + srand((double)microtime()*1000000); + $randy = rand(0,61); + $seed .= $all[$randy]; + } + + $crypt = crypt($password, "$1$$seed"); + return $crypt; +} + +?> diff --git a/config/squid-8/squid_ng.xml b/config/squid-8/squid_ng.xml new file mode 100644 index 00000000..5d956387 --- /dev/null +++ b/config/squid-8/squid_ng.xml @@ -0,0 +1,267 @@ + + + + + + . + 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. + */ +/* ========================================================================== */ + ]]> + + Describe your package here + Describe your package requirements here + Currently there are no FAQ items provided. + squid + 2.5.12_4 + Services: Proxy Server + Security + /pkg_edit.php?xml=squid_ng.xml&id=0 + /usr/local/pkg/squid_ng.inc + + Squid + Modify settings for Proxy Server +
Services
+ /pkg_edit.php?xml=squid_ng.xml&id=0 +
+ + Squid stats + Show Squid statistics +
Services
+ /cachemgr.cgi +
+ + squid + squid.sh + + + + General Settings + /pkg_edit.php?xml=squid.xml&id=0 + + + + Upstream Proxy + /pkg_edit.php?xml=squid_upstream.xml&id=0 + + + Cache Mgmt + /pkg_edit.php?xml=squid_cache.xml&id=0 + + + Network Access Control + /pkg_edit.php?xml=squid_nac.xml&id=0 + + + Traffic Mgmt + /pkg_edit.php?xml=squid_traffic.xml&id=0 + + + Auth + /pkg_edit.php?xml=squid_auth.xml&id=0 + + + Extended Auth + /pkg_edit.php?xml=squid_extauth.xml&id=0 + + + installedpackages->package->squidng->configuration->settings + + /usr/local/pkg/ + 0755 + http://www.pfsense.com/packages/config/squid/squid_cache.xml + + + /usr/local/pkg/ + 0755 + http://www.pfsense.com/packages/config/squid/squid_nac.xml + + + /usr/local/pkg/ + 0755 + http://www.pfsense.com/packages/config/squid/squid_ng.inc + + + /usr/local/pkg/ + 0755 + http://www.pfsense.com/packages/config/squid/squid_traffic.xml + + + /usr/local/pkg/ + 0755 + http://www.pfsense.com/packages/config/squid/squid_upstream.xml + + + /usr/local/pkg/ + 0755 + http://www.pfsense.com/packages/config/squid/squid_auth.xml + + + /usr/local/pkg/ + 0755 + http://www.pfsense.com/packages/config/squid/squid_auth.inc + + + /usr/local/pkg/ + 0755 + http://www.pfsense.com/packages/config/squid/squid_extauth.xml + + + + Proxy Listening Interface + active_interface + This defines the active listening interface to which the proxy server will listen for its requests. + interfaces_selection + + + Transparent Proxy + transparent_proxy + If transparent mode is enabled; all requests for destination port 80 will be forwarded to the proxy server without any additional configuration necessary. + checkbox + + + URL Filtering Enabled + urlfilter_enable + This enables the advanced functionality in conjunction with squidGuard to provide an array of URL filtering options. This squidGuard functionality can be additionally configured from Services -> Advanced Proxy Filtering + checkbox + + + Disable Access Log + accesslog_disabled + Disable the access log entirely. By default, Squid keeps a log of all requests it processes in /var/log/access.log. This can grow to be fairly large. If you do not require this logging, check this box to disable. + checkbox + + + Log Query Terms + log_query_terms + This will log the complete URL rather than the part of the URL containing dynamic queries. + checkbox + + + Log User Agents + log_user_agents + This will enable the useragent string to be written to a separate log. The results are not shown in the GUI and should only be used for debugging purposes. + checkbox + + + Proxy Port + proxy_port + This is the port the Proxy Server will listen for client requests on. The default is 3128. + input + 4 + true + + + ICP Port + icp_port + This is the port the Proxy Server will send and receive ICP queries to and from neighbor caches. The default value is 0, which means this function is disabled. + input + 4 + + + Visible Hostname + visible_hostname + This URL is displayed on the Proxy Server error messages. + input + 35 + + + Cache Administrator E-Mail + cache_admin_email + This E-Mail address is displayed on the Proxy Server error messages. + input + 35 + + + Error Messages Language + error_language + Select the language in which the Proxy Server shall display error messages to users. + select + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Enable cachemgr + cachemgr_enabled + Enable Squid's cachemgr.cgi to provide stats. Once enabled you can access this from the pfSense menus. <b>Note:</b> This page is not secured by pfSense, any user with access to the pfSense admin port can view the stats. The page prompts for a password but it only required for shutting down Squid. + checkbox + + + + + global_write_squid_config(); + mwexec("/usr/local/sbin/squid -k reconfigure"); + start_service("squid"); + + + custom_php_install_command(); + write_static_squid_config(); + mwexec("/usr/local/sbin/squid -k reconfigure"); + start_service("squid"); + + + custom_php_deinstall_command(); + stop_service("squid"); + +
diff --git a/config/squid-8/squid_traffic.xml b/config/squid-8/squid_traffic.xml new file mode 100644 index 00000000..d560a7ad --- /dev/null +++ b/config/squid-8/squid_traffic.xml @@ -0,0 +1,177 @@ + + + + + + . + 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. + */ +/* ========================================================================== */ + ]]> + + Describe your package here + Describe your package requirements here + Currently there are no FAQ items provided. + squidtraffic + none + Proxy server: Traffic management + squid.inc + + + General + /pkg_edit.php?xml=squid.xml&id=0 + + + Upstream Proxy + /pkg_edit.php?xml=squid_upstream.xml&id=0 + + + Cache Mgmt + /pkg_edit.php?xml=squid_cache.xml&id=0 + + + Access Control + /pkg_edit.php?xml=squid_nac.xml&id=0 + + + Traffic Mgmt + /pkg_edit.php?xml=squid_traffic.xml&id=0 + + + + Auth Settings + /pkg_edit.php?xml=squid_auth.xml&id=0 + + + Local Users + /pkg.php?xml=squid_users.xml + + + + + Maximum download size + max_download_size + Limit the maximum total download size to the size specified here (in kilobytes). Set to 0 to disable. + input + + 0 + + + Maximum upload size + max_upload_size + Limit the maximum total upload size to the size specified here (in kilobytes). Set to 0 to disable. + input + + 0 + + + Overall bandwidth throttling + overall_throttling + This value specifies (in kilobytes per second) the bandwidth throttle for downloads. Users will gradually have their download speed increased according to this value. Set to 0 to disable bandwidth throttling. + input + + 0 + + + Per-host throttling + perhost_throttling + This value specifies the download throttling per host. Set to 0 to disable this. + input + + 0 + + + Throttle only specific extensions + throttle_specific + Leave this checked to be able to choose the extensions that throttling will be applied to. Otherwise, all files will be throttled. + checkbox + throttle_binaries,throttle_cdimages,throttle_multimedia,throttle_others + on + + + Throttle binary files + throttle_binaries + Check this to apply bandwidth throttle to binary files. This includes compressed archives and executables. + checkbox + + + Throttle CD images + throttle_cdimages + Check this to apply bandwidth throttle to CD image files. + checkbox + + + Throttle multimedia files + throttle_multimedia + Check this to apply bandwidth throttle to multimedia files, such as movies or songs. + checkbox + + + Throttle other extensions + throttle_others + Comma-separated list of extensions to apply bandwidth throttle to. + input + 60 + + + Finish transfer if less than x KB remaining + quick_abort_min + If the transfer has less than x KB remaining, it will finish the retrieval. Set to 0 to abort the transfer immediately. + input + 0 + + + Abort transfer if more than x KB remaining + quick_abort_max + If the transfer has more than x KB remaining, it will abort the retrieval. Set to 0 to abort the transfer immediately. + input + 0 + + + Finish transfer if more than x % finished + quick_abort_pct + If more than x % of the transfer has completed, it will finish the retrieval. + input + 0 + + + + squid_validate_traffic($_POST, &$input_errors); + + + squid_resync(); + + diff --git a/config/squid-8/squid_upstream.xml b/config/squid-8/squid_upstream.xml new file mode 100644 index 00000000..ad494524 --- /dev/null +++ b/config/squid-8/squid_upstream.xml @@ -0,0 +1,133 @@ + + + + + + . + 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. + */ +/* ========================================================================== */ + ]]> + + Describe your package here + Describe your package requirements here + Currently there are no FAQ items provided. + squidupstream + none + Proxy server: Upstream proxy settings + squid.inc + + + General + /pkg_edit.php?xml=squid.xml&id=0 + + + Upstream Proxy + /pkg_edit.php?xml=squid_upstream.xml&id=0 + + + + Cache Mgmt + /pkg_edit.php?xml=squid_cache.xml&id=0 + + + Access Control + /pkg_edit.php?xml=squid_nac.xml&id=0 + + + Traffic Mgmt + /pkg_edit.php?xml=squid_traffic.xml&id=0 + + + Auth Settings + /pkg_edit.php?xml=squid_auth.xml&id=0 + + + Local Users + /pkg.php?xml=squid_users.xml + + + + + Enable forwarding + proxy_forwarding + This option enables the proxy server to forward requests to an upstream server. + checkbox + proxy_addr,proxy_port,icp_port,username,password + + + + Hostname + proxy_addr + Enter here the IP address or host name of the upstream proxy. + input + + + TCP port + proxy_port + Enter the port to use to connect to the upstream proxy. + input + 5 + 3128 + + + ICP port + icp_port + Enter the port to connect to the upstream proxy for the ICP protocol. Use port number 7 to disable ICP communication between the proxies. + input + 5 + 7 + + + Username + username + If the upstream proxy requires a username, specify it here. + input + + + Password + password + If the upstream proxy requires a password, specify it here. + password + + + + squid_validate_upstream($_POST, &$input_errors); + + + squid_resync(); + + diff --git a/config/squid-8/squid_users.xml b/config/squid-8/squid_users.xml new file mode 100644 index 00000000..eef6389f --- /dev/null +++ b/config/squid-8/squid_users.xml @@ -0,0 +1,120 @@ + + + + + + . + 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. + */ +/* ========================================================================== */ + ]]> + + Describe your package here + Describe your package requirements here + Currently there are no FAQ items provided. + squidusers + none + Proxy server: Local users + squid.inc + A proxy server user has been deleted. + A proxy server user has been created/modified. + + + General + /pkg_edit.php?xml=squid.xml&id=0 + + + Upstream Proxy + /pkg_edit.php?xml=squid_upstream.xml&id=0 + + + Cache Mgmt + /pkg_edit.php?xml=squid_cache.xml&id=0 + + + Access Control + /pkg_edit.php?xml=squid_nac.xml&id=0 + + + Traffic Mgmt + /pkg_edit.php?xml=squid_traffic.xml&id=0 + + + Auth Settings + /pkg_edit.php?xml=squid_auth.xml&id=0 + + + Local Users + /pkg.php?xml=squid_users.xml + + + + + + Username + username + + + Description + description + + + + + Username + username + Enter the username here. + input + + + + Password + password + Enter the password here. + password + + + + Description + description + You may enter a description here for your reference (not parsed). + input + + + + squid_resync_users(); + + -- cgit v1.2.3 From a5b2c004fac5d074f3f3366f4ecad32b11d2a27a Mon Sep 17 00:00:00 2001 From: Martin Date: Wed, 31 Mar 2010 22:49:27 +0200 Subject: add open-vm-tools for pfSense 2.0 --- config/open-vm-tools_2/open-vm-tools.inc | 156 +++++++++++++++++++++++++++++++ config/open-vm-tools_2/open-vm-tools.xml | 69 ++++++++++++++ 2 files changed, 225 insertions(+) create mode 100644 config/open-vm-tools_2/open-vm-tools.inc create mode 100644 config/open-vm-tools_2/open-vm-tools.xml (limited to 'config') diff --git a/config/open-vm-tools_2/open-vm-tools.inc b/config/open-vm-tools_2/open-vm-tools.inc new file mode 100644 index 00000000..f1dc17fb --- /dev/null +++ b/config/open-vm-tools_2/open-vm-tools.inc @@ -0,0 +1,156 @@ + /dev/null" + +# VMware guest daemon +name="vmware_guestd" +rcvar=`set_rcvar` +start_precmd="\${checkvm_cmd}" +unset start_cmd +stop_precmd="\${checkvm_cmd}" +unset stop_cmd +command="/usr/local/bin/vmtoolsd" +command_args="-c /usr/local/share/vmware-tools/tools.conf -p /usr/local/lib/open-vm-tools/plugins/vmsvc" +pidfile="/var/run/\${name}.pid" + +load_rc_config \$name +vmware_guestd_enable="YES" +vmware_guestd_flags="--background \${pidfile}" +run_rc_command "\$1" + +EOF; + + $vmware_kmod = <</dev/null 2>&1 +} +vmware_guest_vmxnet_start() +{ + echo 'Loading vmxnet kernel module.' + kldload /usr/local/lib/vmware-tools/modules/drivers/vmxnet.ko >/dev/null 2>&1 +} +vmware_guest_vmblock_start() +{ + echo 'Loading vmblock kernel module.' + kldload /usr/local/lib/vmware-tools/modules/drivers/vmblock.ko >/dev/null 2>&1 +} +vmware_guest_vmhgfs_start() +{ + echo 'Loading vmhgfs kernel module.' + kldload /usr/local/lib/vmware-tools/modules/drivers/vmhgfs.ko >/dev/null 2>&1 +} + +# VMware kernel module: vmmemctl +name="vmware_guest_vmmemctl" +rcvar=`set_rcvar` +start_precmd="\${checkvm_cmd}" +start_cmd="vmware_guest_vmmemctl_start" +stop_precmd="\${checkvm_cmd}" +stop_cmd=":" + +load_rc_config \$name +vmware_guest_vmmemctl_enable="YES" +run_rc_command "\$1" + +# VMware kernel module: vmxnet +name="vmware_guest_vmxnet" +rcvar=`set_rcvar` +start_precmd="\${checkvm_cmd}" +start_cmd="vmware_guest_vmxnet_start" +stop_precmd="\${checkvm_cmd}" +stop_cmd=":" + +load_rc_config \$name +vmware_guest_vmxnet_enable="YES" +run_rc_command "\$1" + +# VMware kernel module: vmblock +name="vmware_guest_vmblock" +rcvar=`set_rcvar` +start_precmd="\${checkvm_cmd}" +start_cmd="vmware_guest_vmblock_start" +stop_precmd="\${checkvm_cmd}" +stop_cmd=":" + +load_rc_config \$name +vmware_guest_vmblock_enable="YES" +run_rc_command "\$1" + +# VMware kernel module: vmhgfs +name="vmware_guest_vmhgfs" +rcvar=`set_rcvar` +start_precmd="\${checkvm_cmd}" +start_cmd="vmware_guest_vmhgfs_start" +stop_precmd="\${checkvm_cmd}" +stop_cmd=":" + +load_rc_config \$name +vmware_guest_vmhgfs_enable="YES" +run_rc_command "\$1" + +EOF; + + // Write out conf files. + $fd = fopen("/usr/local/etc/rc.d/vmware-guestd.sh", "w"); + if(!$fd) + die("Could not open /usr/local/etc/rc.d/vmware-guestd.sh for writing"); + fwrite($fd, $vmware_guestd); + fclose($fd); + $fd = fopen("/usr/local/etc/rc.d/vmware-kmod.sh", "w"); + if(!$fd) + die("Could not open /usr/local/etc/rc.d/vmware-kmod.sh for writing"); + fwrite($fd, $vmware_kmod); + fclose($fd); + + // Remove non used files + unlink_if_exists("/usr/local/etc/rc.d/vmware-kmod"); + unlink_if_exists("/usr/local/etc/rc.d/vmware-guestd"); + + // Make sure files are executable. + exec("chmod a+rx /usr/local/etc/rc.d/*.sh"); + +} + +?> \ No newline at end of file diff --git a/config/open-vm-tools_2/open-vm-tools.xml b/config/open-vm-tools_2/open-vm-tools.xml new file mode 100644 index 00000000..c2a74f16 --- /dev/null +++ b/config/open-vm-tools_2/open-vm-tools.xml @@ -0,0 +1,69 @@ + + + + + + . + 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. + */ +/* ========================================================================== */ + ]]> + + open-vm-tools + 217847 + Open VM Tools + + /usr/local/pkg/ + 0644 + http://www.pfsense.com/packages/config/open-vm-tools_2/open-vm-tools.inc + + + + + conf_mount_rw(); + open_vm_tools_install(); + exec("/usr/local/etc/rc.d/vmware-guestd.sh start"); + exec("/usr/local/etc/rc.d/vmware-kmod.sh start"); + conf_mount_ro(); + + + conf_mount_rw(); + exec("/usr/local/etc/rc.d/vmware-guestd.sh stop"); + exec("/usr/local/etc/rc.d/vmware-kmod.sh stop"); + open_vm_tools_deinstall(); + conf_mount_ro(); + + /usr/local/pkg/open-vm-tools.inc + \ No newline at end of file -- cgit v1.2.3 From 844fbe052e814a4662dedcf3a09fbfcdb814801a Mon Sep 17 00:00:00 2001 From: robiscool Date: Wed, 31 Mar 2010 19:02:32 -0700 Subject: snort-dev to snort, snort to snort-old, Release --- config/snort-dev/NOTES.txt | 17 - config/snort-dev/bin/7.2.x86/barnyard2 | Bin 715041 -> 0 bytes config/snort-dev/bin/8.0.x86/barnyard2 | Bin 849388 -> 0 bytes config/snort-dev/bin/8.0.x86/md5_files | 9 - config/snort-dev/bin/8.0.x86/md5_files~ | 9 - config/snort-dev/bin/barnyard2 | Bin 641791 -> 0 bytes .../bin/oinkmaster_contrib/README.contrib | 84 - config/snort-dev/bin/oinkmaster_contrib/addmsg.pl | 299 -- config/snort-dev/bin/oinkmaster_contrib/addsid.pl | 382 -- .../bin/oinkmaster_contrib/create-sidmap.pl | 280 -- .../snort-dev/bin/oinkmaster_contrib/makesidex.pl | 261 -- config/snort-dev/bin/oinkmaster_contrib/oinkgui.pl | 1046 ----- .../snort-dev/bin/oinkmaster_contrib/oinkmaster.pl | 2754 ------------ .../bin/oinkmaster_contrib/snort_rename.pl | 100 - config/snort-dev/bin/snort2c | Bin 13508 -> 0 bytes config/snort-dev/css/style.css | 153 - config/snort-dev/css/style2.css | 111 - config/snort-dev/help_and_info.php | 196 - config/snort-dev/images/alert.jpg | Bin 13730 -> 0 bytes config/snort-dev/images/down.gif | Bin 54 -> 0 bytes config/snort-dev/images/down2.gif | Bin 60 -> 0 bytes config/snort-dev/images/footer.jpg | Bin 57411 -> 0 bytes config/snort-dev/images/footer2.jpg | Bin 31878 -> 0 bytes config/snort-dev/images/icon-table-sort-asc.png | Bin 2906 -> 0 bytes config/snort-dev/images/icon-table-sort-desc.png | Bin 2913 -> 0 bytes config/snort-dev/images/icon-table-sort.png | Bin 3025 -> 0 bytes config/snort-dev/images/icon_excli.png | Bin 5280 -> 0 bytes config/snort-dev/images/logo.jpg | Bin 74306 -> 0 bytes config/snort-dev/images/up.gif | Bin 54 -> 0 bytes config/snort-dev/images/up2.gif | Bin 60 -> 0 bytes config/snort-dev/javascript/jquery-1.3.2.js | 4376 -------------------- config/snort-dev/javascript/jquery.blockUI.js | 463 --- config/snort-dev/javascript/mootools.js | 3 - config/snort-dev/javascript/sortableTable.js | 288 -- config/snort-dev/javascript/tabs.js | 123 - config/snort-dev/pfsense_rules/local.rules | 7 - .../pfsense_rules/pfsense_rules.tar.gz.md5 | 1 - .../pfsense_rules/rules/pfsense-voip.rules | 10 - config/snort-dev/snort.inc | 2306 ----------- config/snort-dev/snort.sh | 99 - config/snort-dev/snort.xml | 199 - config/snort-dev/snort_alerts.php | 630 --- config/snort-dev/snort_barnyard.php | 441 -- config/snort-dev/snort_blocked.php | 445 -- config/snort-dev/snort_check_for_rule_updates.php | 769 ---- config/snort-dev/snort_define_servers.php | 581 --- config/snort-dev/snort_download_rules.php | 1211 ------ config/snort-dev/snort_dynamic_ip_reload.php | 50 - config/snort-dev/snort_fbegin.inc | 288 -- config/snort-dev/snort_gui.inc | 66 - config/snort-dev/snort_help_info.php | 191 - config/snort-dev/snort_interfaces.php | 581 --- config/snort-dev/snort_interfaces_edit.php | 607 --- config/snort-dev/snort_interfaces_global.php | 380 -- config/snort-dev/snort_preprocessors.php | 438 -- config/snort-dev/snort_rules.php | 687 --- config/snort-dev/snort_rules_edit.php | 243 -- config/snort-dev/snort_rulesets.php | 307 -- config/snort-dev/snort_whitelist.xml | 117 - config/snort-old/bin/barnyard2 | Bin 0 -> 641791 bytes .../bin/oinkmaster_contrib/README.contrib | 84 + config/snort-old/bin/oinkmaster_contrib/addmsg.pl | 299 ++ config/snort-old/bin/oinkmaster_contrib/addsid.pl | 382 ++ .../bin/oinkmaster_contrib/create-sidmap.pl | 280 ++ .../snort-old/bin/oinkmaster_contrib/makesidex.pl | 261 ++ config/snort-old/bin/oinkmaster_contrib/oinkgui.pl | 1046 +++++ .../snort-old/bin/oinkmaster_contrib/oinkmaster.pl | 2754 ++++++++++++ config/snort-old/bin/snort2c | Bin 0 -> 13508 bytes config/snort-old/pfsense_rules/local.rules | 7 + .../pfsense_rules/pfsense_rules.tar.gz.md5 | 1 + .../pfsense_rules/rules/pfsense-voip.rules | 10 + config/snort-old/snort.inc | 1632 ++++++++ config/snort-old/snort.xml | 378 ++ config/snort-old/snort_advanced.xml | 196 + config/snort-old/snort_alerts.php | 124 + config/snort-old/snort_blocked.php | 174 + config/snort-old/snort_check_for_rule_updates.php | 634 +++ config/snort-old/snort_define_servers.xml | 364 ++ config/snort-old/snort_download_rules.php | 790 ++++ config/snort-old/snort_dynamic_ip_reload.php | 49 + config/snort-old/snort_rules.php | 626 +++ config/snort-old/snort_rules_edit.php | 207 + config/snort-old/snort_rulesets.php | 230 + config/snort-old/snort_threshold.xml | 129 + config/snort-old/snort_whitelist.xml | 129 + config/snort-old/snort_xmlrpc_sync.php | 114 + config/snort/NOTES.txt | 17 + config/snort/bin/7.2.x86/barnyard2 | Bin 0 -> 715041 bytes config/snort/bin/8.0.x86/barnyard2 | Bin 0 -> 849388 bytes config/snort/bin/8.0.x86/md5_files | 9 + config/snort/bin/8.0.x86/md5_files~ | 9 + .../snort/bin/oinkmaster_contrib/snort_rename.pl | 100 + config/snort/bin/snort2c | Bin config/snort/css/style.css | 153 + config/snort/css/style2.css | 111 + config/snort/help_and_info.php | 196 + config/snort/images/alert.jpg | Bin 0 -> 13730 bytes config/snort/images/down.gif | Bin 0 -> 54 bytes config/snort/images/down2.gif | Bin 0 -> 60 bytes config/snort/images/footer.jpg | Bin 0 -> 57411 bytes config/snort/images/footer2.jpg | Bin 0 -> 31878 bytes config/snort/images/icon-table-sort-asc.png | Bin 0 -> 2906 bytes config/snort/images/icon-table-sort-desc.png | Bin 0 -> 2913 bytes config/snort/images/icon-table-sort.png | Bin 0 -> 3025 bytes config/snort/images/icon_excli.png | Bin 0 -> 5280 bytes config/snort/images/logo.jpg | Bin 0 -> 74306 bytes config/snort/images/up.gif | Bin 0 -> 54 bytes config/snort/images/up2.gif | Bin 0 -> 60 bytes config/snort/javascript/jquery-1.3.2.js | 4376 ++++++++++++++++++++ config/snort/javascript/jquery.blockUI.js | 463 +++ config/snort/javascript/mootools.js | 3 + config/snort/javascript/sortableTable.js | 288 ++ config/snort/javascript/tabs.js | 123 + .../snort/pfsense_rules/pfsense_rules.tar.gz.md5 | 2 +- config/snort/snort.inc | 2203 ++++++---- config/snort/snort.sh | 99 + config/snort/snort.xml | 333 +- config/snort/snort_advanced.xml | 196 - config/snort/snort_alerts.php | 624 ++- config/snort/snort_barnyard.php | 441 ++ config/snort/snort_blocked.php | 453 +- config/snort/snort_check_for_rule_updates.php | 529 ++- config/snort/snort_define_servers.php | 582 +++ config/snort/snort_define_servers.xml | 364 -- config/snort/snort_download_rules.php | 1221 ++++-- config/snort/snort_dynamic_ip_reload.php | 27 +- config/snort/snort_fbegin.inc | 288 ++ config/snort/snort_gui.inc | 66 + config/snort/snort_help_info.php | 191 + config/snort/snort_interfaces.php | 584 +++ config/snort/snort_interfaces_edit.php | 609 +++ config/snort/snort_interfaces_edit_bkup.php | 609 +++ config/snort/snort_interfaces_global.php | 380 ++ config/snort/snort_preprocessors.php | 438 ++ config/snort/snort_rules.php | 331 +- config/snort/snort_rules_edit.php | 366 +- config/snort/snort_rulesets.php | 207 +- config/snort/snort_threshold.xml | 129 - config/snort/snort_whitelist.xml | 44 +- config/snort/snort_xmlrpc_sync.php | 114 - 140 files changed, 25201 insertions(+), 24585 deletions(-) delete mode 100644 config/snort-dev/NOTES.txt delete mode 100644 config/snort-dev/bin/7.2.x86/barnyard2 delete mode 100755 config/snort-dev/bin/8.0.x86/barnyard2 delete mode 100644 config/snort-dev/bin/8.0.x86/md5_files delete mode 100644 config/snort-dev/bin/8.0.x86/md5_files~ delete mode 100644 config/snort-dev/bin/barnyard2 delete mode 100644 config/snort-dev/bin/oinkmaster_contrib/README.contrib delete mode 100644 config/snort-dev/bin/oinkmaster_contrib/addmsg.pl delete mode 100644 config/snort-dev/bin/oinkmaster_contrib/addsid.pl delete mode 100644 config/snort-dev/bin/oinkmaster_contrib/create-sidmap.pl delete mode 100644 config/snort-dev/bin/oinkmaster_contrib/makesidex.pl delete mode 100644 config/snort-dev/bin/oinkmaster_contrib/oinkgui.pl delete mode 100644 config/snort-dev/bin/oinkmaster_contrib/oinkmaster.pl delete mode 100644 config/snort-dev/bin/oinkmaster_contrib/snort_rename.pl delete mode 100644 config/snort-dev/bin/snort2c delete mode 100644 config/snort-dev/css/style.css delete mode 100644 config/snort-dev/css/style2.css delete mode 100644 config/snort-dev/help_and_info.php delete mode 100644 config/snort-dev/images/alert.jpg delete mode 100644 config/snort-dev/images/down.gif delete mode 100644 config/snort-dev/images/down2.gif delete mode 100644 config/snort-dev/images/footer.jpg delete mode 100644 config/snort-dev/images/footer2.jpg delete mode 100644 config/snort-dev/images/icon-table-sort-asc.png delete mode 100644 config/snort-dev/images/icon-table-sort-desc.png delete mode 100644 config/snort-dev/images/icon-table-sort.png delete mode 100644 config/snort-dev/images/icon_excli.png delete mode 100644 config/snort-dev/images/logo.jpg delete mode 100644 config/snort-dev/images/up.gif delete mode 100644 config/snort-dev/images/up2.gif delete mode 100644 config/snort-dev/javascript/jquery-1.3.2.js delete mode 100644 config/snort-dev/javascript/jquery.blockUI.js delete mode 100644 config/snort-dev/javascript/mootools.js delete mode 100644 config/snort-dev/javascript/sortableTable.js delete mode 100644 config/snort-dev/javascript/tabs.js delete mode 100644 config/snort-dev/pfsense_rules/local.rules delete mode 100644 config/snort-dev/pfsense_rules/pfsense_rules.tar.gz.md5 delete mode 100644 config/snort-dev/pfsense_rules/rules/pfsense-voip.rules delete mode 100644 config/snort-dev/snort.inc delete mode 100644 config/snort-dev/snort.sh delete mode 100644 config/snort-dev/snort.xml delete mode 100644 config/snort-dev/snort_alerts.php delete mode 100644 config/snort-dev/snort_barnyard.php delete mode 100644 config/snort-dev/snort_blocked.php delete mode 100644 config/snort-dev/snort_check_for_rule_updates.php delete mode 100644 config/snort-dev/snort_define_servers.php delete mode 100644 config/snort-dev/snort_download_rules.php delete mode 100644 config/snort-dev/snort_dynamic_ip_reload.php delete mode 100644 config/snort-dev/snort_fbegin.inc delete mode 100644 config/snort-dev/snort_gui.inc delete mode 100644 config/snort-dev/snort_help_info.php delete mode 100644 config/snort-dev/snort_interfaces.php delete mode 100644 config/snort-dev/snort_interfaces_edit.php delete mode 100644 config/snort-dev/snort_interfaces_global.php delete mode 100644 config/snort-dev/snort_preprocessors.php delete mode 100644 config/snort-dev/snort_rules.php delete mode 100644 config/snort-dev/snort_rules_edit.php delete mode 100644 config/snort-dev/snort_rulesets.php delete mode 100644 config/snort-dev/snort_whitelist.xml create mode 100644 config/snort-old/bin/barnyard2 create mode 100644 config/snort-old/bin/oinkmaster_contrib/README.contrib create mode 100644 config/snort-old/bin/oinkmaster_contrib/addmsg.pl create mode 100644 config/snort-old/bin/oinkmaster_contrib/addsid.pl create mode 100644 config/snort-old/bin/oinkmaster_contrib/create-sidmap.pl create mode 100644 config/snort-old/bin/oinkmaster_contrib/makesidex.pl create mode 100644 config/snort-old/bin/oinkmaster_contrib/oinkgui.pl create mode 100644 config/snort-old/bin/oinkmaster_contrib/oinkmaster.pl create mode 100755 config/snort-old/bin/snort2c create mode 100644 config/snort-old/pfsense_rules/local.rules create mode 100644 config/snort-old/pfsense_rules/pfsense_rules.tar.gz.md5 create mode 100644 config/snort-old/pfsense_rules/rules/pfsense-voip.rules create mode 100755 config/snort-old/snort.inc create mode 100644 config/snort-old/snort.xml create mode 100644 config/snort-old/snort_advanced.xml create mode 100644 config/snort-old/snort_alerts.php create mode 100644 config/snort-old/snort_blocked.php create mode 100644 config/snort-old/snort_check_for_rule_updates.php create mode 100644 config/snort-old/snort_define_servers.xml create mode 100644 config/snort-old/snort_download_rules.php create mode 100644 config/snort-old/snort_dynamic_ip_reload.php create mode 100644 config/snort-old/snort_rules.php create mode 100644 config/snort-old/snort_rules_edit.php create mode 100644 config/snort-old/snort_rulesets.php create mode 100644 config/snort-old/snort_threshold.xml create mode 100644 config/snort-old/snort_whitelist.xml create mode 100644 config/snort-old/snort_xmlrpc_sync.php create mode 100644 config/snort/NOTES.txt create mode 100644 config/snort/bin/7.2.x86/barnyard2 create mode 100755 config/snort/bin/8.0.x86/barnyard2 create mode 100644 config/snort/bin/8.0.x86/md5_files create mode 100644 config/snort/bin/8.0.x86/md5_files~ create mode 100644 config/snort/bin/oinkmaster_contrib/snort_rename.pl mode change 100755 => 100644 config/snort/bin/snort2c create mode 100644 config/snort/css/style.css create mode 100644 config/snort/css/style2.css create mode 100644 config/snort/help_and_info.php create mode 100644 config/snort/images/alert.jpg create mode 100644 config/snort/images/down.gif create mode 100644 config/snort/images/down2.gif create mode 100644 config/snort/images/footer.jpg create mode 100644 config/snort/images/footer2.jpg create mode 100644 config/snort/images/icon-table-sort-asc.png create mode 100644 config/snort/images/icon-table-sort-desc.png create mode 100644 config/snort/images/icon-table-sort.png create mode 100644 config/snort/images/icon_excli.png create mode 100644 config/snort/images/logo.jpg create mode 100644 config/snort/images/up.gif create mode 100644 config/snort/images/up2.gif create mode 100644 config/snort/javascript/jquery-1.3.2.js create mode 100644 config/snort/javascript/jquery.blockUI.js create mode 100644 config/snort/javascript/mootools.js create mode 100644 config/snort/javascript/sortableTable.js create mode 100644 config/snort/javascript/tabs.js mode change 100755 => 100644 config/snort/snort.inc create mode 100644 config/snort/snort.sh delete mode 100644 config/snort/snort_advanced.xml create mode 100644 config/snort/snort_barnyard.php create mode 100644 config/snort/snort_define_servers.php delete mode 100644 config/snort/snort_define_servers.xml create mode 100644 config/snort/snort_fbegin.inc create mode 100644 config/snort/snort_gui.inc create mode 100644 config/snort/snort_help_info.php create mode 100644 config/snort/snort_interfaces.php create mode 100644 config/snort/snort_interfaces_edit.php create mode 100644 config/snort/snort_interfaces_edit_bkup.php create mode 100644 config/snort/snort_interfaces_global.php create mode 100644 config/snort/snort_preprocessors.php delete mode 100644 config/snort/snort_threshold.xml delete mode 100644 config/snort/snort_xmlrpc_sync.php (limited to 'config') diff --git a/config/snort-dev/NOTES.txt b/config/snort-dev/NOTES.txt deleted file mode 100644 index b8c61c39..00000000 --- a/config/snort-dev/NOTES.txt +++ /dev/null @@ -1,17 +0,0 @@ - - -March 26 2019 -Snort-dev 2.8.5.3 pk v. 18 final - -Final day. - -Odds and ends left. - -2.0 group snort gets lost on reboot. - -Pierre POMES code needs to be added. - -Threshold tab needs to be added. - - -Done. diff --git a/config/snort-dev/bin/7.2.x86/barnyard2 b/config/snort-dev/bin/7.2.x86/barnyard2 deleted file mode 100644 index 9266051c..00000000 Binary files a/config/snort-dev/bin/7.2.x86/barnyard2 and /dev/null differ diff --git a/config/snort-dev/bin/8.0.x86/barnyard2 b/config/snort-dev/bin/8.0.x86/barnyard2 deleted file mode 100755 index 43476338..00000000 Binary files a/config/snort-dev/bin/8.0.x86/barnyard2 and /dev/null differ diff --git a/config/snort-dev/bin/8.0.x86/md5_files b/config/snort-dev/bin/8.0.x86/md5_files deleted file mode 100644 index 3b283d80..00000000 --- a/config/snort-dev/bin/8.0.x86/md5_files +++ /dev/null @@ -1,9 +0,0 @@ -#For Freebsd 8.0 - - -MD5 (pcre-8.00.tbz) = 8a1ac82500efccefc6418856e27b6cc1 -MD5 (snort-2.8.5.3.tbz) = 826c15872c6d19bcbe2408fb34d165b9 -MD5 (perl-5.10.1.tbz) = f71020a8bd0f197c9bf70eb6d03b92af -MD5 (mysql-client-5.1.45.tbz) = 9cb5878ae922c3d4d0e31efe5712a90a -MD5 (barnyard2) = 4dbff13291a2b8c5018b7ab62f574bc8 - diff --git a/config/snort-dev/bin/8.0.x86/md5_files~ b/config/snort-dev/bin/8.0.x86/md5_files~ deleted file mode 100644 index 3b283d80..00000000 --- a/config/snort-dev/bin/8.0.x86/md5_files~ +++ /dev/null @@ -1,9 +0,0 @@ -#For Freebsd 8.0 - - -MD5 (pcre-8.00.tbz) = 8a1ac82500efccefc6418856e27b6cc1 -MD5 (snort-2.8.5.3.tbz) = 826c15872c6d19bcbe2408fb34d165b9 -MD5 (perl-5.10.1.tbz) = f71020a8bd0f197c9bf70eb6d03b92af -MD5 (mysql-client-5.1.45.tbz) = 9cb5878ae922c3d4d0e31efe5712a90a -MD5 (barnyard2) = 4dbff13291a2b8c5018b7ab62f574bc8 - diff --git a/config/snort-dev/bin/barnyard2 b/config/snort-dev/bin/barnyard2 deleted file mode 100644 index b942e87f..00000000 Binary files a/config/snort-dev/bin/barnyard2 and /dev/null differ diff --git a/config/snort-dev/bin/oinkmaster_contrib/README.contrib b/config/snort-dev/bin/oinkmaster_contrib/README.contrib deleted file mode 100644 index 6923fa26..00000000 --- a/config/snort-dev/bin/oinkmaster_contrib/README.contrib +++ /dev/null @@ -1,84 +0,0 @@ -# $Id: README.contrib,v 1.21 2005/10/18 10:41:20 andreas_o Exp $ # - -------------------------------------------------------------------------------- -* oinkgui.pl by Andreas Östling - - A graphical front-end to Oinkmaster written in Perl/Tk. - See README.gui for complete documentation. -------------------------------------------------------------------------------- - - - -------------------------------------------------------------------------------- -* addsid.pl by Andreas Östling - - A script that parses *.rules in all specified directories and adds a - SID to (active) rules that don't have any. (Actually, rev and classtype - are also added if missing, unless you edit addsid.pl and tune this.) The - script first looks for the current highest SID (even in inactive rules) - and starts at the next one, unless this value is below MIN_SID (defined - inside addsid.pl). By default, this value is set to 1000001 since this - is the lowest SID assigned for local usage. Handles multi-line rules. -------------------------------------------------------------------------------- - - - -------------------------------------------------------------------------------- -* create-sidmap.pl by Andreas Östling - - A script that parses all active rules in *.rules in all specified - directories and creates a SID map. (Like Snort's regen-sidmap, but this - one handles multi-line rules.) Result goes to standard output which can - be redirected to a sid-msg.map file. -------------------------------------------------------------------------------- - - - -------------------------------------------------------------------------------- -* makesidex.pl, originally by Jerry Applebaum but later rewritten by - Andreas Östling to handle multi-line rules and - multiple rules directories. - - It reads *.rules in all specified directories, looks for all disabled - rules and prints a "disablesid # " line for each disabled rule. - The output can be appended to oinkmaster.conf. - Useful to new Oinkmaster users. -------------------------------------------------------------------------------- - - - -------------------------------------------------------------------------------- -* addmsg.pl by Andreas Östling : - - A script that will parse your oinkmaster.conf for - localsid/enablesid/disablesid lines and add their rule message as a #comment. - If your oinkmaster.conf looks like this before addmsg.pl has been run: - - disablesid 286 - disablesid 287 - disablesid 288 - - It will look something like this afterward: - - disablesid 286 # POP3 EXPLOIT x86 bsd overflow - disablesid 287 # POP3 EXPLOIT x86 bsd overflow - disablesid 288 # POP3 EXPLOIT x86 linux overflow - - addmsg.pl will not touch lines that already has a comment in them. - It's not able to handle SID lists when written like this: - disablesid 1,2,3, ... - But it should handle them if written like this: - disablesid \ - 1, \ - 2, \ - 3 - - The new config file will be printed to standard output, so you - probably want to redirect the output to a file, for example: - - ./addmsg.pl oinkmaster.conf rules/ > oinkmaster.conf.new - - If oinkmaster.conf.new looks ok, simply rename it to oinkmaster.conf. - Do NOT redirect to the same file you read from, as this will destroy - that file. -------------------------------------------------------------------------------- diff --git a/config/snort-dev/bin/oinkmaster_contrib/addmsg.pl b/config/snort-dev/bin/oinkmaster_contrib/addmsg.pl deleted file mode 100644 index e5866d6f..00000000 --- a/config/snort-dev/bin/oinkmaster_contrib/addmsg.pl +++ /dev/null @@ -1,299 +0,0 @@ -#!/usr/bin/perl -w - -# $Id: addmsg.pl,v 1.19 2005/12/31 13:42:46 andreas_o Exp $ # - -# Copyright (c) 2004-2006 Andreas Östling -# 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. -# -# 3. Neither the name of the author nor the names of its -# contributors may be used to endorse or promote products -# derived from this software without specific prior written -# permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -# CONTRIBUTORS "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 COPYRIGHT OWNER OR -# CONTRIBUTORS 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. - - -use strict; - -sub get_next_entry($ $ $ $ $ $); -sub parse_singleline_rule($ $ $); - - -my $USAGE = << "RTFM"; - -Parse Oinkmaster configuration file and add the rule's "msg" string as a -#comment for each disablesid/enablesid line. - -Usage: $0 [rulesdir2, ...] - -The new config file will be printed to standard output, so you -probably want to redirect the output to a new file (*NOT* the same -file you used as input, because that will destroy the file!). -For example: - -$0 /etc/oinkmaster.conf /etc/rules/ > oinkmaster.conf.new - -If oinkmaster.conf.new looks ok, simply rename it to /etc/oinkmaster.conf. - -RTFM - - -# Regexp to match the start of a multi-line rule. -# %ACTIONS% will be replaced with content of $config{actions} later. -my $MULTILINE_RULE_REGEXP = '^\s*#*\s*(?:%ACTIONS%)'. - '\s.*\\\\\s*\n$'; # '; - -# Regexp to match a single-line rule. -my $SINGLELINE_RULE_REGEXP = '^\s*#*\s*(?:%ACTIONS%)'. - '\s.+;\s*\)\s*$'; # '; - - -my $config = shift || die($USAGE); - -my @rulesdirs = @ARGV; -die($USAGE) unless ($#rulesdirs > -1); - -my $verbose = 1; -my (%sidmsgmap, %config); - -$config{rule_actions} = "alert|drop|log|pass|reject|sdrop|activate|dynamic"; - -$SINGLELINE_RULE_REGEXP =~ s/%ACTIONS%/$config{rule_actions}/; -$MULTILINE_RULE_REGEXP =~ s/%ACTIONS%/$config{rule_actions}/; - - - -# Read in oinkmaster.conf. -open(CONFIG, "<" , "$config") or die("could not open \"$config\" for reading: $!\n"); -my @config = ; -close(CONFIG); - - -# Read in *.rules in all rulesdirs and create %sidmsgmap ($sidmsgmap{sid} = msg). -foreach my $rulesdir (@rulesdirs) { - opendir(RULESDIR, "$rulesdir") or die("could not open \"$rulesdir\": $!\n"); - - while (my $file = readdir(RULESDIR)) { - next unless ($file =~ /\.rules$/); - - open(FILE, "<", "$rulesdir/$file") or die("could not open \"$rulesdir/$file\": $!\n"); - my @file = ; - close(FILE); - - my ($single, $multi, $nonrule, $msg, $sid); - - while (get_next_entry(\@file, \$single, \$multi, \$nonrule, \$msg, \$sid)) { - $sidmsgmap{$sid} = $msg - if (defined($single)); - } - } -} - - -# Print new oinkmaster.conf. -while ($_ = shift(@config)) { - if (/^\s*(?:disable|enable|local)sid\s+(\d+)\s*$/ || /^\s*(\d+)\s*,\s*\\$/ || /^\s*(\d+)\s*$/) { - my $sid = $1; - my $is_multiline = 0; - chomp; - - if (/\\$/) { - $is_multiline = 1; - s/\\$//; - } - - $_ = sprintf("%-25s", $_); - if (exists($sidmsgmap{$sid})) { - print "$_ # $sidmsgmap{$sid}"; - } else { - print "$_"; - } - print " \\" if ($is_multiline); - print "\n"; - } else { - print; - } -} - - - -# From oinkmaster.pl. -sub get_next_entry($ $ $ $ $ $) -{ - my $arr_ref = shift; - my $single_ref = shift; - my $multi_ref = shift; - my $nonrule_ref = shift; - my $msg_ref = shift; - my $sid_ref = shift; - - undef($$single_ref); - undef($$multi_ref); - undef($$nonrule_ref); - undef($$msg_ref); - undef($$sid_ref); - - my $line = shift(@$arr_ref) || return(0); - my $disabled = 0; - my $broken = 0; - - # Possible beginning of multi-line rule? - if ($line =~ /$MULTILINE_RULE_REGEXP/oi) { - $$single_ref = $line; - $$multi_ref = $line; - - $disabled = 1 if ($line =~ /^\s*#/); - - # Keep on reading as long as line ends with "\". - while (!$broken && $line =~ /\\\s*\n$/) { - - # Remove trailing "\" and newline for single-line version. - $$single_ref =~ s/\\\s*\n//; - - # If there are no more lines, this can not be a valid multi-line rule. - if (!($line = shift(@$arr_ref))) { - - warn("\nWARNING: got EOF while parsing multi-line rule: $$multi_ref\n") - if ($config{verbose}); - - @_ = split(/\n/, $$multi_ref); - - undef($$multi_ref); - undef($$single_ref); - - # First line of broken multi-line rule will be returned as a non-rule line. - $$nonrule_ref = shift(@_) . "\n"; - $$nonrule_ref =~ s/\s*\n$/\n/; # remove trailing whitespaces - - # The rest is put back to the array again. - foreach $_ (reverse((@_))) { - unshift(@$arr_ref, "$_\n"); - } - - return (1); # return non-rule - } - - # Multi-line continuation. - $$multi_ref .= $line; - - # If there are non-comment lines in the middle of a disabled rule, - # mark the rule as broken to return as non-rule lines. - if ($line !~ /^\s*#/ && $disabled) { - $broken = 1; - } elsif ($line =~ /^\s*#/ && !$disabled) { - # comment line (with trailing slash) in the middle of an active rule - ignore it - } else { - $line =~ s/^\s*#*\s*//; # remove leading # in single-line version - $$single_ref .= $line; - } - - } # while line ends with "\" - - # Single-line version should now be a valid rule. - # If not, it wasn't a valid multi-line rule after all. - if (!$broken && parse_singleline_rule($$single_ref, $msg_ref, $sid_ref)) { - - $$single_ref =~ s/^\s*//; # remove leading whitespaces - $$single_ref =~ s/^#+\s*/#/; # remove whitespaces next to leading # - $$single_ref =~ s/\s*\n$/\n/; # remove trailing whitespaces - - $$multi_ref =~ s/^\s*//; - $$multi_ref =~ s/\s*\n$/\n/; - $$multi_ref =~ s/^#+\s*/#/; - - return (1); # return multi - } else { - warn("\nWARNING: invalid multi-line rule: $$single_ref\n") - if ($config{verbose} && $$multi_ref !~ /^\s*#/); - - @_ = split(/\n/, $$multi_ref); - - undef($$multi_ref); - undef($$single_ref); - - # First line of broken multi-line rule will be returned as a non-rule line. - $$nonrule_ref = shift(@_) . "\n"; - $$nonrule_ref =~ s/\s*\n$/\n/; # remove trailing whitespaces - - # The rest is put back to the array again. - foreach $_ (reverse((@_))) { - unshift(@$arr_ref, "$_\n"); - } - - return (1); # return non-rule - } - } elsif (parse_singleline_rule($line, $msg_ref, $sid_ref)) { - $$single_ref = $line; - $$single_ref =~ s/^\s*//; - $$single_ref =~ s/^#+\s*/#/; - $$single_ref =~ s/\s*\n$/\n/; - - return (1); # return single - } else { # non-rule line - - # Do extra check and warn if it *might* be a rule anyway, - # but that we just couldn't parse for some reason. - warn("\nWARNING: line may be a rule but it could not be parsed ". - "(missing sid or msg?): $line\n") - if ($config{verbose} && $line =~ /^\s*alert .+msg\s*:\s*".+"\s*;/); - - $$nonrule_ref = $line; - $$nonrule_ref =~ s/\s*\n$/\n/; - - return (1); # return non-rule - } -} - - - -# From oinkmaster.pl. -sub parse_singleline_rule($ $ $) -{ - my $line = shift; - my $msg_ref = shift; - my $sid_ref = shift; - - if ($line =~ /$SINGLELINE_RULE_REGEXP/oi) { - - if ($line =~ /\bmsg\s*:\s*"(.+?)"\s*;/i) { - $$msg_ref = $1; - } else { - return (0); - } - - if ($line =~ /\bsid\s*:\s*(\d+)\s*;/i) { - $$sid_ref = $1; - } else { - return (0); - } - - return (1); - } - - return (0); -} diff --git a/config/snort-dev/bin/oinkmaster_contrib/addsid.pl b/config/snort-dev/bin/oinkmaster_contrib/addsid.pl deleted file mode 100644 index 64255d22..00000000 --- a/config/snort-dev/bin/oinkmaster_contrib/addsid.pl +++ /dev/null @@ -1,382 +0,0 @@ -#!/usr/bin/perl -w - -# $Id: addsid.pl,v 1.30 2005/12/31 13:42:46 andreas_o Exp $ # - -# Copyright (c) 2004-2006 Andreas Östling -# 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. -# -# 3. Neither the name of the author nor the names of its -# contributors may be used to endorse or promote products -# derived from this software without specific prior written -# permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -# CONTRIBUTORS "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 COPYRIGHT OWNER OR -# CONTRIBUTORS 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. - - -use strict; - - -sub get_next_entry($ $ $ $ $ $); -sub parse_singleline_rule($ $ $); -sub get_next_available_sid(@); - - -# Set this to the default classtype you want to add, if missing. -# Set to 0 or "" if you don't want to add a classtype. -my $CLASSTYPE = "misc-attack"; - -# If ADD_REV is set to 1, "rev: 1;" will be added to rule if it has no rev. -# Set to 0 if you don't want to add it. -my $ADD_REV = 1; - -# Minimum SID to add. Normally, the next available SID will be used, -# unless it's below this value. Only SIDs >= 1000000 are reserved for -# personal use. -my $MIN_SID = 1000001; - -# Regexp to match the start of a multi-line rule. -# %ACTIONS% will be replaced with content of $config{actions} later. -my $MULTILINE_RULE_REGEXP = '^\s*#*\s*(?:%ACTIONS%)'. - '\s.*\\\\\s*\n$'; # '; - -# Regexp to match a single-line rule. -my $SINGLELINE_RULE_REGEXP = '^\s*#*\s*(?:%ACTIONS%)'. - '\s.+;\s*\)\s*$'; # '; - - -my $USAGE = << "RTFM"; - -Parse *.rules in one or more directories and add "sid:;" to -active rules that don't have any "sid" entry, starting with the next -available SID after parsing all rules files (but $MIN_SID at minumum). -Also, "rev:1;" is added to rules without a "rev" entry, and -"classtype:misc-attack;" is added to rules without a "classtype" entry -(edit options at the top of $0 if you want to change this). - -Usage: $0 [rulesdir2, ...] - -RTFM - - -# Start in verbose mode. -my $verbose = 1; - -my (%all_sids, %active_sids, %config); - -my @rulesdirs = @ARGV; - -die($USAGE) unless ($#rulesdirs > -1); - -$config{rule_actions} = "alert|drop|log|pass|reject|sdrop|activate|dynamic"; - -$SINGLELINE_RULE_REGEXP =~ s/%ACTIONS%/$config{rule_actions}/; -$MULTILINE_RULE_REGEXP =~ s/%ACTIONS%/$config{rule_actions}/; - - -# Find out the next available SID. -my $next_sid = get_next_available_sid(@rulesdirs); - -# Avoid seeing possible warnings about broken rules twice. -$verbose = 0; - -# Add sid/rev/classtype to active rules that don't have any. -foreach my $dir (@rulesdirs) { - opendir(RULESDIR, "$dir") or die("could not open \"$dir\": $!\n"); - - while (my $file = readdir(RULESDIR)) { - next unless ($file =~ /\.rules$/); - - open(OLDFILE, "$dir/$file") - or die("could not open \"$dir/$file\": $!\n"); - my @file = ; - close(OLDFILE); - - open(NEWFILE, ">", "$dir/$file") - or die("could not open \"$dir/$file\" for writing: $!\n"); - - my ($single, $multi, $nonrule, $msg, $sid); - while (get_next_entry(\@file, \$single, \$multi, \$nonrule, \$msg, \$sid)) { - - if (defined($nonrule)) { - print NEWFILE "$nonrule"; - next; - } - - $multi = $single unless (defined($multi)); - - # Don't care about inactive rules. - if ($single =~ /^\s*#/) { - print NEWFILE "$multi"; - next; - } - - my $added; - - # Add SID. - if ($single !~ /sid\s*:\s*\d+\s*;/) { - $added .= "SID $next_sid,"; - $multi =~ s/\)\s*\n/sid:$next_sid;)\n/; - $next_sid++; - } - - # Add revision. - if ($ADD_REV && $single !~ /rev\s*:\s*\d+\s*;/) { - $added .= "rev,"; - $multi =~ s/\)\s*\n/rev:1;)\n/; - } - - # Add classtype. - if ($CLASSTYPE && $single !~ /classtype\s*:\s*.+\s*;/) { - $added .= "classtype $CLASSTYPE,"; - $multi =~ s/\)\s*\n/classtype:$CLASSTYPE;)\n/; - } - - if (defined($added)) { - $added =~ s/,$//; - print "Adding $added to rule \"$msg\"\n" - if (defined($added)); - } - - print NEWFILE "$multi"; - } - - close(NEWFILE); - } - - closedir(RULESDIR); -} - - - -# Read in *.rules in given directory and return highest SID. -sub get_next_available_sid(@) -{ - my @dirs = @_; - - foreach my $dir (@dirs) { - opendir(RULESDIR, "$dir") or die("could not open \"$dir\": $!\n"); - - # Only care about *.rules. - while (my $file = readdir(RULESDIR)) { - next unless ($file =~ /\.rules$/); - - open(OLDFILE, "<$dir/$file") or die("could not open \"$dir/$file\": $!\n"); - my @file = ; - close(OLDFILE); - - my ($single, $multi, $nonrule, $msg, $sid); - - while (get_next_entry(\@file, \$single, \$multi, \$nonrule, \$msg, \$sid)) { - if (defined($single) && defined($sid)) { - $all_sids{$sid}++; - - # If this is an active rule add to %active_sids and - # warn if it already exists. - if ($single =~ /^\s*alert/) { - print STDERR "WARNING: duplicate SID: $sid\n" - if (exists($active_sids{$sid})); - $active_sids{$sid}++ - } - } - } - } - } - - # Sort sids and use highest one + 1, unless it's below MIN_SID. - @_ = sort {$a <=> $b} keys(%all_sids); - my $sid = pop(@_); - - if (!defined($sid)) { - $sid = $MIN_SID - } else { - $sid++; - } - - # If it's below MIN_SID, use MIN_SID instead. - $sid = $MIN_SID if ($sid < $MIN_SID); - - return ($sid) -} - - - -sub get_next_entry($ $ $ $ $ $) -{ - my $arr_ref = shift; - my $single_ref = shift; - my $multi_ref = shift; - my $nonrule_ref = shift; - my $msg_ref = shift; - my $sid_ref = shift; - - undef($$single_ref); - undef($$multi_ref); - undef($$nonrule_ref); - undef($$msg_ref); - undef($$sid_ref); - - my $line = shift(@$arr_ref) || return(0); - my $disabled = 0; - my $broken = 0; - - # Possible beginning of multi-line rule? - if ($line =~ /$MULTILINE_RULE_REGEXP/oi) { - $$single_ref = $line; - $$multi_ref = $line; - - $disabled = 1 if ($line =~ /^\s*#/); - - # Keep on reading as long as line ends with "\". - while (!$broken && $line =~ /\\\s*\n$/) { - - # Remove trailing "\" and newline for single-line version. - $$single_ref =~ s/\\\s*\n//; - - # If there are no more lines, this can not be a valid multi-line rule. - if (!($line = shift(@$arr_ref))) { - - warn("\nWARNING: got EOF while parsing multi-line rule: $$multi_ref\n") - if ($config{verbose}); - - @_ = split(/\n/, $$multi_ref); - - undef($$multi_ref); - undef($$single_ref); - - # First line of broken multi-line rule will be returned as a non-rule line. - $$nonrule_ref = shift(@_) . "\n"; - $$nonrule_ref =~ s/\s*\n$/\n/; # remove trailing whitespaces - - # The rest is put back to the array again. - foreach $_ (reverse((@_))) { - unshift(@$arr_ref, "$_\n"); - } - - return (1); # return non-rule - } - - # Multi-line continuation. - $$multi_ref .= $line; - - # If there are non-comment lines in the middle of a disabled rule, - # mark the rule as broken to return as non-rule lines. - if ($line !~ /^\s*#/ && $disabled) { - $broken = 1; - } elsif ($line =~ /^\s*#/ && !$disabled) { - # comment line (with trailing slash) in the middle of an active rule - ignore it - } else { - $line =~ s/^\s*#*\s*//; # remove leading # in single-line version - $$single_ref .= $line; - } - - } # while line ends with "\" - - # Single-line version should now be a valid rule. - # If not, it wasn't a valid multi-line rule after all. - if (!$broken && parse_singleline_rule($$single_ref, $msg_ref, $sid_ref)) { - - $$single_ref =~ s/^\s*//; # remove leading whitespaces - $$single_ref =~ s/^#+\s*/#/; # remove whitespaces next to leading # - $$single_ref =~ s/\s*\n$/\n/; # remove trailing whitespaces - - $$multi_ref =~ s/^\s*//; - $$multi_ref =~ s/\s*\n$/\n/; - $$multi_ref =~ s/^#+\s*/#/; - - return (1); # return multi - } else { - warn("\nWARNING: invalid multi-line rule: $$single_ref\n") - if ($config{verbose} && $$multi_ref !~ /^\s*#/); - - @_ = split(/\n/, $$multi_ref); - - undef($$multi_ref); - undef($$single_ref); - - # First line of broken multi-line rule will be returned as a non-rule line. - $$nonrule_ref = shift(@_) . "\n"; - $$nonrule_ref =~ s/\s*\n$/\n/; # remove trailing whitespaces - - # The rest is put back to the array again. - foreach $_ (reverse((@_))) { - unshift(@$arr_ref, "$_\n"); - } - - return (1); # return non-rule - } - } elsif (parse_singleline_rule($line, $msg_ref, $sid_ref)) { - $$single_ref = $line; - $$single_ref =~ s/^\s*//; - $$single_ref =~ s/^#+\s*/#/; - $$single_ref =~ s/\s*\n$/\n/; - - return (1); # return single - } else { # non-rule line - - # Do extra check and warn if it *might* be a rule anyway, - # but that we just couldn't parse for some reason. - warn("\nWARNING: line may be a rule but it could not be parsed ". - "(missing sid or msg?): $line\n") - if ($config{verbose} && $line =~ /^\s*alert .+msg\s*:\s*".+"\s*;/); - - $$nonrule_ref = $line; - $$nonrule_ref =~ s/\s*\n$/\n/; - - return (1); # return non-rule - } -} - - - -# From oinkmaster.pl except that this version -# has been modified so that the sid is *optional*. -sub parse_singleline_rule($ $ $) -{ - my $line = shift; - my $msg_ref = shift; - my $sid_ref = shift; - - if ($line =~ /$SINGLELINE_RULE_REGEXP/oi) { - - if ($line =~ /\bmsg\s*:\s*"(.+?)"\s*;/i) { - $$msg_ref = $1; - } else { - return (0); - } - - if ($line =~ /\bsid\s*:\s*(\d+)\s*;/i) { - $$sid_ref = $1; -# } else { -# return (0); - } - - return (1); - } - - return (0); -} diff --git a/config/snort-dev/bin/oinkmaster_contrib/create-sidmap.pl b/config/snort-dev/bin/oinkmaster_contrib/create-sidmap.pl deleted file mode 100644 index 26a9040c..00000000 --- a/config/snort-dev/bin/oinkmaster_contrib/create-sidmap.pl +++ /dev/null @@ -1,280 +0,0 @@ -#!/usr/local/bin/perl -w - -# $Id: create-sidmap.pl,v 1.21 2005/12/31 13:42:46 andreas_o Exp $ # - -# Copyright (c) 2004-2006 Andreas Östling -# 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. -# -# 3. Neither the name of the author nor the names of its -# contributors may be used to endorse or promote products -# derived from this software without specific prior written -# permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -# CONTRIBUTORS "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 COPYRIGHT OWNER OR -# CONTRIBUTORS 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. - - -use strict; - -sub get_next_entry($ $ $ $ $ $); -sub parse_singleline_rule($ $ $); - -# Files to ignore. -my %skipfiles = ( - 'deleted.rules' => 1, -); - -# Regexp to match the start of a multi-line rule. -# %ACTIONS% will be replaced with content of $config{actions} later. -my $MULTILINE_RULE_REGEXP = '^\s*#*\s*(?:%ACTIONS%)'. - '\s.*\\\\\s*\n$'; # '; - -# Regexp to match a single-line rule. -my $SINGLELINE_RULE_REGEXP = '^\s*#*\s*(?:%ACTIONS%)'. - '\s.+;\s*\)\s*$'; # '; - -my $USAGE = << "RTFM"; - -Parse active rules in *.rules in one or more directories and create a SID -map. Result is sent to standard output, which can be redirected to a -sid-msg.map file. - -Usage: $0 [rulesdir2, ...] - -RTFM - -my $verbose = 1; - -my (%sidmap, %config); - -my @rulesdirs = @ARGV; - -die($USAGE) unless ($#rulesdirs > -1); - -$config{rule_actions} = "alert|drop|log|pass|reject|sdrop|activate|dynamic"; - -$SINGLELINE_RULE_REGEXP =~ s/%ACTIONS%/$config{rule_actions}/; -$MULTILINE_RULE_REGEXP =~ s/%ACTIONS%/$config{rule_actions}/; - - -# Read in all rules from each rules file (*.rules) in each rules dir. -# into %sidmap. -foreach my $rulesdir (@rulesdirs) { - opendir(RULESDIR, "$rulesdir") or die("could not open \"$rulesdir\": $!\n"); - - while (my $file = readdir(RULESDIR)) { - next unless ($file =~ /\.rules$/); - next if ($skipfiles{$file}); - - open(FILE, "$rulesdir/$file") or die("could not open \"$rulesdir/$file\": $!\n"); - my @file = ; - close(FILE); - - my ($single, $multi, $nonrule, $msg, $sid); - - while (get_next_entry(\@file, \$single, \$multi, \$nonrule, \$msg, \$sid)) { - if (defined($single)) { - - warn("WARNING: duplicate SID: $sid (discarding old)\n") - if (exists($sidmap{$sid})); - - $sidmap{$sid} = "$sid || $msg"; - - # Print all references. Borrowed from Brian Caswell's regen-sidmap script. - my $ref = $single; - while ($ref =~ s/(.*)reference\s*:\s*([^\;]+)(.*)$/$1 $3/) { - $sidmap{$sid} .= " || $2" - } - - $sidmap{$sid} .= "\n"; - } - } - } -} - -# Print results. -foreach my $sid (sort { $a <=> $b } keys(%sidmap)) { - print "$sidmap{$sid}"; -} - - - -# Same as in oinkmaster.pl. -sub get_next_entry($ $ $ $ $ $) -{ - my $arr_ref = shift; - my $single_ref = shift; - my $multi_ref = shift; - my $nonrule_ref = shift; - my $msg_ref = shift; - my $sid_ref = shift; - - undef($$single_ref); - undef($$multi_ref); - undef($$nonrule_ref); - undef($$msg_ref); - undef($$sid_ref); - - my $line = shift(@$arr_ref) || return(0); - my $disabled = 0; - my $broken = 0; - - # Possible beginning of multi-line rule? - if ($line =~ /$MULTILINE_RULE_REGEXP/oi) { - $$single_ref = $line; - $$multi_ref = $line; - - $disabled = 1 if ($line =~ /^\s*#/); - - # Keep on reading as long as line ends with "\". - while (!$broken && $line =~ /\\\s*\n$/) { - - # Remove trailing "\" and newline for single-line version. - $$single_ref =~ s/\\\s*\n//; - - # If there are no more lines, this can not be a valid multi-line rule. - if (!($line = shift(@$arr_ref))) { - - warn("\nWARNING: got EOF while parsing multi-line rule: $$multi_ref\n") - if ($config{verbose}); - - @_ = split(/\n/, $$multi_ref); - - undef($$multi_ref); - undef($$single_ref); - - # First line of broken multi-line rule will be returned as a non-rule line. - $$nonrule_ref = shift(@_) . "\n"; - $$nonrule_ref =~ s/\s*\n$/\n/; # remove trailing whitespaces - - # The rest is put back to the array again. - foreach $_ (reverse((@_))) { - unshift(@$arr_ref, "$_\n"); - } - - return (1); # return non-rule - } - - # Multi-line continuation. - $$multi_ref .= $line; - - # If there are non-comment lines in the middle of a disabled rule, - # mark the rule as broken to return as non-rule lines. - if ($line !~ /^\s*#/ && $disabled) { - $broken = 1; - } elsif ($line =~ /^\s*#/ && !$disabled) { - # comment line (with trailing slash) in the middle of an active rule - ignore it - } else { - $line =~ s/^\s*#*\s*//; # remove leading # in single-line version - $$single_ref .= $line; - } - - } # while line ends with "\" - - # Single-line version should now be a valid rule. - # If not, it wasn't a valid multi-line rule after all. - if (!$broken && parse_singleline_rule($$single_ref, $msg_ref, $sid_ref)) { - - $$single_ref =~ s/^\s*//; # remove leading whitespaces - $$single_ref =~ s/^#+\s*/#/; # remove whitespaces next to leading # - $$single_ref =~ s/\s*\n$/\n/; # remove trailing whitespaces - - $$multi_ref =~ s/^\s*//; - $$multi_ref =~ s/\s*\n$/\n/; - $$multi_ref =~ s/^#+\s*/#/; - - return (1); # return multi - } else { - warn("\nWARNING: invalid multi-line rule: $$single_ref\n") - if ($config{verbose} && $$multi_ref !~ /^\s*#/); - - @_ = split(/\n/, $$multi_ref); - - undef($$multi_ref); - undef($$single_ref); - - # First line of broken multi-line rule will be returned as a non-rule line. - $$nonrule_ref = shift(@_) . "\n"; - $$nonrule_ref =~ s/\s*\n$/\n/; # remove trailing whitespaces - - # The rest is put back to the array again. - foreach $_ (reverse((@_))) { - unshift(@$arr_ref, "$_\n"); - } - - return (1); # return non-rule - } - } elsif (parse_singleline_rule($line, $msg_ref, $sid_ref)) { - $$single_ref = $line; - $$single_ref =~ s/^\s*//; - $$single_ref =~ s/^#+\s*/#/; - $$single_ref =~ s/\s*\n$/\n/; - - return (1); # return single - } else { # non-rule line - - # Do extra check and warn if it *might* be a rule anyway, - # but that we just couldn't parse for some reason. - warn("\nWARNING: line may be a rule but it could not be parsed ". - "(missing sid or msg?): $line\n") - if ($config{verbose} && $line =~ /^\s*alert .+msg\s*:\s*".+"\s*;/); - - $$nonrule_ref = $line; - $$nonrule_ref =~ s/\s*\n$/\n/; - - return (1); # return non-rule - } -} - - - -# Same as in oinkmaster.pl. -sub parse_singleline_rule($ $ $) -{ - my $line = shift; - my $msg_ref = shift; - my $sid_ref = shift; - - if ($line =~ /$SINGLELINE_RULE_REGEXP/oi) { - - if ($line =~ /\bmsg\s*:\s*"(.+?)"\s*;/i) { - $$msg_ref = $1; - } else { - return (0); - } - - if ($line =~ /\bsid\s*:\s*(\d+)\s*;/i) { - $$sid_ref = $1; - } else { - return (0); - } - - return (1); - } - - return (0); -} diff --git a/config/snort-dev/bin/oinkmaster_contrib/makesidex.pl b/config/snort-dev/bin/oinkmaster_contrib/makesidex.pl deleted file mode 100644 index 80354735..00000000 --- a/config/snort-dev/bin/oinkmaster_contrib/makesidex.pl +++ /dev/null @@ -1,261 +0,0 @@ -#!/usr/bin/perl -w - -# $Id: makesidex.pl,v 1.11 2005/12/31 13:42:46 andreas_o Exp $ # - -# Copyright (c) 2004-2006 Andreas Östling -# 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. -# -# 3. Neither the name of the author nor the names of its -# contributors may be used to endorse or promote products -# derived from this software without specific prior written -# permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -# CONTRIBUTORS "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 COPYRIGHT OWNER OR -# CONTRIBUTORS 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. - - -use strict; - -sub get_next_entry($ $ $ $ $ $); -sub parse_singleline_rule($ $ $); - - -# Regexp to match the start of a multi-line rule. -# %ACTIONS% will be replaced with content of $config{actions} later. -my $MULTILINE_RULE_REGEXP = '^\s*#*\s*(?:%ACTIONS%)'. - '\s.*\\\\\s*\n$'; # '; - -# Regexp to match a single-line rule. -my $SINGLELINE_RULE_REGEXP = '^\s*#*\s*(?:%ACTIONS%)'. - '\s.+;\s*\)\s*$'; # '; - -my $USAGE = << "RTFM"; - -Parse *.rules in one or more directories and look for all rules that are -disabled (i.e. begin with "#") and print "disablesid # " to -standard output for all those rules. This output can be redirected to a -file, which will be understood by Oinkmaster. - -Usage: $0 [rulesdir2, ...] - -RTFM - -my $verbose = 1; - -my (%disabled, %config); - -my @rulesdirs = @ARGV; - -die($USAGE) unless ($#rulesdirs > -1); - -$config{rule_actions} = "alert|drop|log|pass|reject|sdrop|activate|dynamic"; - -$SINGLELINE_RULE_REGEXP =~ s/%ACTIONS%/$config{rule_actions}/; -$MULTILINE_RULE_REGEXP =~ s/%ACTIONS%/$config{rule_actions}/; - -foreach my $rulesdir (@rulesdirs) { - opendir(RULESDIR, "$rulesdir") or die("could not open \"$rulesdir\": $!\n"); - - while (my $file = readdir(RULESDIR)) { - next unless ($file =~ /\.rules$/); - - open(FILE, "$rulesdir/$file") or die("could not open \"$rulesdir/$file\": $!\n"); - my @file = ; - close(FILE); - - my ($single, $multi, $nonrule, $msg, $sid); - - while (get_next_entry(\@file, \$single, \$multi, \$nonrule, \$msg, \$sid)) { - $single = $multi if (defined($multi)); - $disabled{$sid} = $msg - if (defined($single) && $single =~ /^\s*#/); - } - } -} - -# Print results. -foreach my $sid (sort { $a <=> $b } keys(%disabled)) { - printf("%-25s # %s\n", "disablesid $sid", $disabled{$sid}); -} - - - -# Same as in oinkmaster.pl. -sub get_next_entry($ $ $ $ $ $) -{ - my $arr_ref = shift; - my $single_ref = shift; - my $multi_ref = shift; - my $nonrule_ref = shift; - my $msg_ref = shift; - my $sid_ref = shift; - - undef($$single_ref); - undef($$multi_ref); - undef($$nonrule_ref); - undef($$msg_ref); - undef($$sid_ref); - - my $line = shift(@$arr_ref) || return(0); - my $disabled = 0; - my $broken = 0; - - # Possible beginning of multi-line rule? - if ($line =~ /$MULTILINE_RULE_REGEXP/oi) { - $$single_ref = $line; - $$multi_ref = $line; - - $disabled = 1 if ($line =~ /^\s*#/); - - # Keep on reading as long as line ends with "\". - while (!$broken && $line =~ /\\\s*\n$/) { - - # Remove trailing "\" and newline for single-line version. - $$single_ref =~ s/\\\s*\n//; - - # If there are no more lines, this can not be a valid multi-line rule. - if (!($line = shift(@$arr_ref))) { - - warn("\nWARNING: got EOF while parsing multi-line rule: $$multi_ref\n") - if ($config{verbose}); - - @_ = split(/\n/, $$multi_ref); - - undef($$multi_ref); - undef($$single_ref); - - # First line of broken multi-line rule will be returned as a non-rule line. - $$nonrule_ref = shift(@_) . "\n"; - $$nonrule_ref =~ s/\s*\n$/\n/; # remove trailing whitespaces - - # The rest is put back to the array again. - foreach $_ (reverse((@_))) { - unshift(@$arr_ref, "$_\n"); - } - - return (1); # return non-rule - } - - # Multi-line continuation. - $$multi_ref .= $line; - - # If there are non-comment lines in the middle of a disabled rule, - # mark the rule as broken to return as non-rule lines. - if ($line !~ /^\s*#/ && $disabled) { - $broken = 1; - } elsif ($line =~ /^\s*#/ && !$disabled) { - # comment line (with trailing slash) in the middle of an active rule - ignore it - } else { - $line =~ s/^\s*#*\s*//; # remove leading # in single-line version - $$single_ref .= $line; - } - - } # while line ends with "\" - - # Single-line version should now be a valid rule. - # If not, it wasn't a valid multi-line rule after all. - if (!$broken && parse_singleline_rule($$single_ref, $msg_ref, $sid_ref)) { - - $$single_ref =~ s/^\s*//; # remove leading whitespaces - $$single_ref =~ s/^#+\s*/#/; # remove whitespaces next to leading # - $$single_ref =~ s/\s*\n$/\n/; # remove trailing whitespaces - - $$multi_ref =~ s/^\s*//; - $$multi_ref =~ s/\s*\n$/\n/; - $$multi_ref =~ s/^#+\s*/#/; - - return (1); # return multi - } else { - warn("\nWARNING: invalid multi-line rule: $$single_ref\n") - if ($config{verbose} && $$multi_ref !~ /^\s*#/); - - @_ = split(/\n/, $$multi_ref); - - undef($$multi_ref); - undef($$single_ref); - - # First line of broken multi-line rule will be returned as a non-rule line. - $$nonrule_ref = shift(@_) . "\n"; - $$nonrule_ref =~ s/\s*\n$/\n/; # remove trailing whitespaces - - # The rest is put back to the array again. - foreach $_ (reverse((@_))) { - unshift(@$arr_ref, "$_\n"); - } - - return (1); # return non-rule - } - } elsif (parse_singleline_rule($line, $msg_ref, $sid_ref)) { - $$single_ref = $line; - $$single_ref =~ s/^\s*//; - $$single_ref =~ s/^#+\s*/#/; - $$single_ref =~ s/\s*\n$/\n/; - - return (1); # return single - } else { # non-rule line - - # Do extra check and warn if it *might* be a rule anyway, - # but that we just couldn't parse for some reason. - warn("\nWARNING: line may be a rule but it could not be parsed ". - "(missing sid or msg?): $line\n") - if ($config{verbose} && $line =~ /^\s*alert .+msg\s*:\s*".+"\s*;/); - - $$nonrule_ref = $line; - $$nonrule_ref =~ s/\s*\n$/\n/; - - return (1); # return non-rule - } -} - - - -# Same as in oinkmaster.pl. -sub parse_singleline_rule($ $ $) -{ - my $line = shift; - my $msg_ref = shift; - my $sid_ref = shift; - - if ($line =~ /$SINGLELINE_RULE_REGEXP/oi) { - - if ($line =~ /\bmsg\s*:\s*"(.+?)"\s*;/i) { - $$msg_ref = $1; - } else { - return (0); - } - - if ($line =~ /\bsid\s*:\s*(\d+)\s*;/i) { - $$sid_ref = $1; - } else { - return (0); - } - - return (1); - } - - return (0); -} diff --git a/config/snort-dev/bin/oinkmaster_contrib/oinkgui.pl b/config/snort-dev/bin/oinkmaster_contrib/oinkgui.pl deleted file mode 100644 index 4e96f7db..00000000 --- a/config/snort-dev/bin/oinkmaster_contrib/oinkgui.pl +++ /dev/null @@ -1,1046 +0,0 @@ -#!/usr/bin/perl -w - -# $Id: oinkgui.pl,v 1.52 2005/12/31 13:42:46 andreas_o Exp $ # - -# Copyright (c) 2004-2006 Andreas Östling -# 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. -# -# 3. Neither the name of the author nor the names of its -# contributors may be used to endorse or promote products -# derived from this software without specific prior written -# permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -# CONTRIBUTORS "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 COPYRIGHT OWNER OR -# CONTRIBUTORS 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. - - -use 5.006001; - -use strict; -use File::Spec; -use Tk; -use Tk::Balloon; -use Tk::BrowseEntry; -use Tk::FileSelect; -use Tk::NoteBook; -use Tk::ROText; - -use constant CSIDL_DRIVES => 17; - -sub update_rules(); -sub clear_messages(); -sub create_cmdline($); -sub fileDialog($ $ $ $); -sub load_config(); -sub save_config(); -sub save_messages(); -sub update_file_label_color($ $ $); -sub create_fileSelectFrame($ $ $ $ $ $); -sub create_checkbutton($ $ $); -sub create_radiobutton($ $ $); -sub create_actionbutton($ $ $); -sub execute_oinkmaster(@); -sub logmsg($ $); - - -my $version = 'Oinkmaster GUI v1.1'; - -my @oinkmaster_conf = qw( - /etc/oinkmaster.conf - /usr/local/etc/oinkmaster.conf -); - -# List of URLs that will show up in the URL BrowseEntry. -my @urls = qw( - http://www.bleedingsnort.com/bleeding.rules.tar.gz - http://www.snort.org/pub-bin/downloads.cgi/Download/comm_rules/Community-Rules.tar.gz - http://www.snort.org/pub-bin/oinkmaster.cgi//snortrules-snapshot-CURRENT.tar.gz - http://www.snort.org/pub-bin/oinkmaster.cgi//snortrules-snapshot-2.3.tar.gz -); - -my %color = ( - background => 'Bisque3', - button => 'Bisque2', - label => 'Bisque1', - notebook_bg => 'Bisque2', - notebook_inact => 'Bisque3', - file_label_ok => '#00e000', - file_label_not_ok => 'red', - out_frame_fg => 'white', - out_frame_bg => 'black', - entry_bg => 'white', - button_active => 'white', - button_bg => 'Bisque4', -); - -my %config = ( - animate => 1, - careful => 0, - enable_all => 0, - check_removed => 0, - output_mode => 'normal', - diff_mode => 'detailed', - perl => $^X, - oinkmaster => "", - oinkmaster_conf => "", - outdir => "", - url => "", - varfile => "", - backupdir => "", - editor => "", -); - -my %help = ( - - # File locations. - oinkscript => 'Location of the executable Oinkmaster script (oinkmaster.pl).', - oinkconf => 'The Oinkmaster configuration file to use.', - outdir => 'Where to put the new rules. This should be the directory where you '. - 'store your current rules.', - - url => 'Alternate location of rules archive to download/copy. '. - 'Leave empty to use the location set in oinkmaster.conf.', - varfile => 'Variables that exist in downloaded snort.conf but not in '. - 'this file will be added to it. Leave empty to skip.', - backupdir => 'Directory to put tarball of old rules before overwriting them. '. - 'Leave empty to skip backup.', - editor => 'Full path to editor to execute when pressing the "edit" button '. - '(wordpad is recommended on Windows). ', - - # Checkbuttons. - careful => 'In careful mode, Oinkmaster will just check for changes, '. - 'not update anything.', - enable => 'Some rules may be commented out by default (for a reason!). '. - 'This option will make Oinkmaster enable those.', - removed => 'Check for rules files that exist in the output directory but not '. - 'in the downloaded rules archive.', - - # Action buttons. - clear => 'Clear current output messages.', - save => 'Save current output messages to file.', - exit => 'Exit the GUI.', - update => 'Execute Oinkmaster to update the rules.', - test => 'Test current Oinkmaster configuration. ' . - 'If there are no fatal errors, you are ready to update the rules.', - version => 'Request version information from Oinkmaster.', -); - - -my $gui_config_file = ""; -my $use_fileop = 0; - - -#### MAIN #### - -select STDERR; -$| = 1; -select STDOUT; -$| = 1; - -# Find out if can use Win32::FileOp. -if ($^O eq 'MSWin32') { - BEGIN { $^W = 0 } - $use_fileop = 1 if (eval "require Win32::FileOp"); -} - -# Find out which oinkmaster.pl file to default to. -foreach my $dir (File::Spec->path()) { - my $file = "$dir/oinkmaster"; - if (-f "$file" && (-x "$file" || $^O eq 'MSWin32')) { - $config{oinkmaster} = $file; - last; - } elsif (-f "$file.pl" && (-x "$file" || $^O eq 'MSWin32')) { - $config{oinkmaster} = "$file.pl"; - last; - } -} - -# Find out which oinkmaster config file to default to. -foreach my $file (@oinkmaster_conf) { - if (-e "$file") { - $config{oinkmaster_conf} = $file; - last; - } -} - -# Find out where the GUI config file is (it's not required). -if ($ENV{HOME}) { - $gui_config_file = "$ENV{HOME}/.oinkguirc" -} elsif ($ENV{HOMEDRIVE} && $ENV{HOMEPATH}) { - $gui_config_file = "$ENV{HOMEDRIVE}$ENV{HOMEPATH}\\.oinkguirc"; -} - - -# Create main window. -my $main = MainWindow->new( - -background => "$color{background}", - -title => "$version", -); - - -# Create scrolled frame with output messages. -my $out_frame = $main->Scrolled('ROText', - -setgrid => 'true', - -scrollbars => 'e', - -background => $color{out_frame_bg}, - -foreground => $color{out_frame_fg}, -); - - -my $help_label = $main->Label( - -relief => 'groove', - -background => "$color{label}", -); - -my $balloon = $main->Balloon( - -statusbar => $help_label, -); - - -# Create notebook. -my $notebook = $main->NoteBook( - -ipadx => 6, - -ipady => 6, - -background => $color{notebook_bg}, - -inactivebackground => $color{notebook_inact}, - -backpagecolor => $color{background}, -); - - -# Create tab with required files/dirs. -my $req_tab = $notebook->add("required", - -label => "Required files and directories", - -underline => 0, -); - -$req_tab->configure(-bg => "$color{notebook_inact}"); - - -# Create frame with oinkmaster.pl location. -my $filetypes = [ - ['Oinkmaster script', 'oinkmaster.pl'], - ['All files', '*' ] -]; - -my $oinkscript_frame = - create_fileSelectFrame($req_tab, "oinkmaster.pl", 'EXECFILE', - \$config{oinkmaster}, 'NOEDIT', $filetypes); - -$balloon->attach($oinkscript_frame, -statusmsg => $help{oinkscript}); - - -# Create frame with oinkmaster.conf location. -$filetypes = [ - ['configuration files', '.conf'], - ['All files', '*' ] -]; - -my $oinkconf_frame = - create_fileSelectFrame($req_tab, "oinkmaster.conf", 'ROFILE', - \$config{oinkmaster_conf}, 'EDIT', $filetypes); - -$balloon->attach($oinkconf_frame, -statusmsg => $help{oinkconf}); - - -# Create frame with output directory. -my $outdir_frame = - create_fileSelectFrame($req_tab, "output directory", 'WRDIR', - \$config{outdir}, 'NOEDIT', undef); - -$balloon->attach($outdir_frame, -statusmsg => $help{outdir}); - - - -# Create tab with optional files/dirs. -my $opt_tab = $notebook->add("optional", - -label => "Optional files and directories", - -underline => 0, -); - -$opt_tab->configure(-bg => "$color{notebook_inact}"); - -# Create frame with alternate URL location. -$filetypes = [ - ['compressed tar files', '.tar.gz'] -]; - -my $url_frame = - create_fileSelectFrame($opt_tab, "Alternate URL", 'URL', - \$config{url}, 'NOEDIT', $filetypes); - -$balloon->attach($url_frame, -statusmsg => $help{url}); - - -# Create frame with variable file. -$filetypes = [ - ['Snort configuration files', ['.conf', '.config']], - ['All files', '*' ] -]; - -my $varfile_frame = - create_fileSelectFrame($opt_tab, "Variable file", 'WRFILE', - \$config{varfile}, 'EDIT', $filetypes); - -$balloon->attach($varfile_frame, -statusmsg => $help{varfile}); - - -# Create frame with backup dir location. -my $backupdir_frame = - create_fileSelectFrame($opt_tab, "Backup directory", 'WRDIR', - \$config{backupdir}, 'NOEDIT', undef); - -$balloon->attach($backupdir_frame, -statusmsg => $help{backupdir}); - - -# Create frame with editor location. -$filetypes = [ - ['executable files', ['.exe']], - ['All files', '*' ] -]; - -my $editor_frame = - create_fileSelectFrame($opt_tab, "Editor", 'EXECFILE', - \$config{editor}, 'NOEDIT', $filetypes); - -$balloon->attach($editor_frame, -statusmsg => $help{editor}); - - - -$notebook->pack( - -expand => 'no', - -fill => 'x', - -padx => '5', - -pady => '5', - -side => 'top' -); - - -# Create the frame to the left. -my $left_frame = $main->Frame( - -background => "$color{label}", - -border => '2', -)->pack( - -side => 'left', - -fill => 'y', -); - - -# Create "GUI settings" label. -$left_frame->Label( - -text => "GUI settings:", - -background => "$color{label}", -)->pack( - -side => 'top', - -fill => 'x', -); - - -create_actionbutton($left_frame, "Load saved settings", \&load_config); -create_actionbutton($left_frame, "Save current settings", \&save_config); - - -# Create "options" label at the top of the left frame. -$left_frame->Label( - -text => "Options:", - -background => "$color{label}", -)->pack(-side => 'top', - -fill => 'x', -); - - -# Create checkbuttons in the left frame. -$balloon->attach( - create_checkbutton($left_frame, "Careful mode", \$config{careful}), - -statusmsg => $help{careful} -); - -$balloon->attach( - create_checkbutton($left_frame, "Enable all", \$config{enable_all}), - -statusmsg => $help{enable} -); - -$balloon->attach( - create_checkbutton($left_frame, "Check for removed files", \$config{check_removed}), - -statusmsg => $help{removed} -); - - -# Create "mode" label. -$left_frame->Label( - -text => "Output mode:", - -background => "$color{label}", -)->pack( - -side => 'top', - -fill => 'x', -); - -# Create mode radiobuttons in the left frame. -create_radiobutton($left_frame, "super-quiet", \$config{output_mode}); -create_radiobutton($left_frame, "quiet", \$config{output_mode}); -create_radiobutton($left_frame, "normal", \$config{output_mode}); -create_radiobutton($left_frame, "verbose", \$config{output_mode}); - -# Create "Diff mode" label. -$left_frame->Label( - -text => "Diff mode:", - -background => "$color{label}", -)->pack( - -side => 'top', - -fill => 'x', -); - -create_radiobutton($left_frame, "detailed", \$config{diff_mode}); -create_radiobutton($left_frame, "summarized", \$config{diff_mode}); -create_radiobutton($left_frame, "remove common", \$config{diff_mode}); - - -# Create "activity messages" label. -$main->Label( - -text => "Output messages:", - -width => '130', - -background => "$color{label}", -)->pack( - -side => 'top', - -fill => 'x', -); - - - -# Pack output frame. -$out_frame->pack( - -expand => 'yes', - -fill => 'both', -); - - -# Pack help label below output window. -$help_label->pack( - -fill => 'x', -); - - -# Create "actions" label. -$left_frame->Label( - -text => "Actions:", - -background => "$color{label}", -)->pack( - -side => 'top', - -fill => 'x', -); - - -# Create action buttons. - -$balloon->attach( - create_actionbutton($left_frame, "Update rules!", \&update_rules), - -statusmsg => $help{update} -); - -$balloon->attach( - create_actionbutton($left_frame, "Clear output messages", \&clear_messages), - -statusmsg => $help{clear} -); - -$balloon->attach( - create_actionbutton($left_frame, "Save output messages", \&save_messages), - -statusmsg => $help{save} -); - -$balloon->attach( - create_actionbutton($left_frame, "Exit", \&exit), - -statusmsg => $help{exit} -); - - - -# Make the mousewheel scroll the output window. Taken from Mastering Perl/Tk. -if ($^O eq 'MSWin32') { - $out_frame->bind('' => - [ sub { $_[0]->yview('scroll', -($_[1] / 120) * 3, 'units')}, - Ev('D') ] - ); -} else { - $out_frame->bind('<4>' => sub { - $_[0]->yview('scroll', -3, 'units') unless $Tk::strictMotif; - }); - - $out_frame->bind('<5>' => sub { - $_[0]->yview('scroll', +3, 'units') unless $Tk::strictMotif; - }); -} - - - -# Now the fun begins. -if ($config{animate}) { - foreach (split(//, "Welcome to $version")) { - logmsg("$_", 'MISC'); - $out_frame->after(5); - } -} else { - logmsg("Welcome to $version", 'MISC'); -} - -logmsg("\n\n", 'MISC'); - -# Load gui settings into %config. -load_config(); - - -# Warn if any required file/directory is not set. -logmsg("No oinkmaster.pl set, please select one above!\n\n", 'ERROR') - if ($config{oinkmaster} !~ /\S/); - -logmsg("No oinkmaster configuration file set, please select one above!\n\n", 'ERROR') - if ($config{oinkmaster_conf} !~ /\S/); - -logmsg("Output directory is not set, please select one above!\n\n", 'ERROR') - if ($config{outdir} !~ /\S/); - - -MainLoop; - - - -#### END #### - - - -sub fileDialog($ $ $ $) -{ - my $var_ref = shift; - my $title = shift; - my $type = shift; - my $filetypes = shift; - my $dirname; - - if ($type eq 'WRDIR') { - if ($use_fileop) { - $dirname = Win32::FileOp::BrowseForFolder("title", CSIDL_DRIVES); - } else { - my $fs = $main->FileSelect(); - $fs->configure(-verify => ['-d', '-w'], -title => $title); - $dirname = $fs->Show; - } - $$var_ref = $dirname if ($dirname); - } elsif ($type eq 'EXECFILE' || $type eq 'ROFILE' || $type eq 'WRFILE' || $type eq 'URL') { - my $filename = $main->getOpenFile(-title => $title, -filetypes => $filetypes); - $$var_ref = $filename if ($filename); - } elsif ($type eq 'SAVEFILE') { - my $filename = $main->getSaveFile(-title => $title, -filetypes => $filetypes); - $$var_ref = $filename if ($filename); - } else { - logmsg("Unknown type ($type)\n", 'ERROR'); - } -} - - - -sub update_file_label_color($ $ $) -{ - my $label = shift; - my $filename = shift; - my $type = shift; - - $filename =~ s/^\s+//; - $filename =~ s/\s+$//; - - unless ($filename) { - $label->configure(-background => $color{file_label_not_ok}); - return (1); - } - - if ($type eq "URL") { - if ($filename =~ /^(?:http|ftp|scp):\/\/.+\.tar\.gz$/) { - $label->configure(-background => $color{file_label_ok}); - } elsif ($filename =~ /^(?:file:\/\/)*(.+\.tar\.gz)$/) { - my $file = $1; - if (-f "$file" && -r "$file") { - $label->configure(-background => $color{file_label_ok}); - } else { - $label->configure(-background => $color{file_label_not_ok}); - } - } else { - $label->configure(-background => $color{file_label_not_ok}); - } - } elsif ($type eq "ROFILE") { - if (-f "$filename" && -r "$filename") { - $label->configure(-background => $color{file_label_ok}); - } else { - $label->configure(-background => $color{file_label_not_ok}); - } - } elsif ($type eq "EXECFILE") { - if (-f "$filename" && (-x "$filename" || $^O eq 'MSWin32')) { - $label->configure(-background => $color{file_label_ok}); - } else { - $label->configure(-background => $color{file_label_not_ok}); - } - } elsif ($type eq "WRFILE") { - if (-f "$filename" && -w "$filename") { - $label->configure(-background => $color{file_label_ok}); - } else { - $label->configure(-background => $color{file_label_not_ok}); - } - } elsif ($type eq "WRDIR") { - if (-d "$filename" && -w "$filename") { - $label->configure(-background => $color{file_label_ok}); - } else { - $label->configure(-background => $color{file_label_not_ok}); - } - } else { - print STDERR "incorrect type ($type)\n"; - exit; - } - - return (1); -} - - - -sub create_checkbutton($ $ $) -{ - my $frame = shift; - my $name = shift; - my $var_ref = shift; - - my $button = $frame->Checkbutton( - -text => $name, - -background => $color{button}, - -activebackground => $color{button_active}, - -highlightbackground => $color{button_bg}, - -variable => $var_ref, - -relief => 'raise', - -anchor => 'w', - )->pack( - -fill => 'x', - -side => 'top', - -pady => '1', - ); - - return ($button); -} - - - -sub create_actionbutton($ $ $) -{ - my $frame = shift; - my $name = shift; - my $func_ref = shift; - - my $button = $frame->Button( - -text => $name, - -command => sub { - &$func_ref; - $out_frame->focus; - }, - -background => $color{button}, - -activebackground => $color{button_active}, - -highlightbackground => $color{button_bg}, - )->pack( - -fill => 'x', - ); - - return ($button); -} - - - -sub create_radiobutton($ $ $) -{ - my $frame = shift; - my $name = shift; - my $mode_ref = shift; - - my $button = $frame->Radiobutton( - -text => $name, - -highlightbackground => $color{button_bg}, - -background => $color{button}, - -activebackground => $color{button_active}, - -variable => $mode_ref, - -relief => 'raised', - -anchor => 'w', - -value => $name, - )->pack( - -side => 'top', - -pady => '1', - -fill => 'x', - ); - - return ($button); -} - - - -# Create
- +'; + + if($savemsg) { + print_info_box_np2("{$savemsg}"); + }else{ + print_info_box_np2(' + The Snort configuration has changed and snort needs to be restarted on this interface.
+ You must apply the changes in order for them to take effect.
+ '); + } + } + +?> + - +
@@ -231,7 +281,7 @@ echo " 
Check the rulesets that you would like Snort to load at startup.
 
", "
" ] || - - !tags.indexOf("
" ] || - - //
" ] || - - !tags.indexOf("
" ] || - - // IE can't serialize and "; -} - -/* ensure downloaded file looks sane */ -function verify_downloaded_file($filename) { - global $snort_filename, $snort_filename_md5, $console_mode; - ob_flush(); - if(filesize($filename)<9500) { - if(!$console_mode) { - update_all_status("Checking {$filename}..."); - check_for_common_errors($filename); - } - } - update_all_status("Verifying {$filename}..."); - if(!file_exists($filename)) { - if(!$console_mode) { - update_all_status("Could not fetch snort rules ({$filename}). Check oinkid key and dns and try again."); - hide_progress_bar_status(); - } else { - log_error("Could not fetch snort rules ({$filename}). Check oinkid key and dns and try again."); - echo "Could not fetch snort rules ({$filename}). Check oinkid key and dns and try again."; - } - exit; - } - update_all_status("Verified {$filename}."); -} - -/* extract rules */ -function extract_snort_rules_md5($tmpfname) { - global $snort_filename, $snort_filename_md5, $console_mode; - ob_flush(); - if(!$console_mode) { - $static_output = gettext("Extracting snort rules..."); - update_all_status($static_output); - } - if(!is_dir("/usr/local/etc/snort/rules/")) - mkdir("/usr/local/etc/snort/rules/"); - $cmd = "/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C /usr/local/etc/snort/ rules/"; - $handle = popen("{$cmd} 2>&1", 'r'); - while(!feof($handle)) { - $buffer = fgets($handle); - update_output_window($buffer); - } - pclose($handle); - - if(!$console_mode) { - $static_output = gettext("Snort rules extracted."); - update_all_status($static_output); - } else { - log_error("Snort rules extracted."); - echo "Snort rules extracted."; - } -} - -/* verify MD5 against downloaded item */ -function verify_snort_rules_md5($tmpfname) { - global $snort_filename, $snort_filename_md5, $console_mode; - ob_flush(); - if(!$console_mode) { - $static_output = gettext("Verifying md5 signature..."); - update_all_status($static_output); - } - - $md555 = file_get_contents("{$tmpfname}/{$snort_filename_md5}"); - $md5 = `echo "{$md555}" | /usr/bin/awk '{ print $4 }'`; - $file_md5_ondisk = `/sbin/md5 {$tmpfname}/{$snort_filename} | /usr/bin/awk '{ print $4 }'`; - if($md5 == $file_md5_ondisk) { - if(!$console_mode) { - $static_output = gettext("snort rules: md5 signature of rules mismatch."); - update_all_status($static_output); - hide_progress_bar_status(); - } else { - log_error("snort rules: md5 signature of rules mismatch."); - echo "snort rules: md5 signature of rules mismatch."; - } - exit; - } -} - -/* hide progress bar */ -function hide_progress_bar_status() { - global $snort_filename, $snort_filename_md5, $console_mode; - ob_flush(); - if(!$console_mode) - echo "\n"; -} - -/* unhide progress bar */ -function unhide_progress_bar_status() { - global $snort_filename, $snort_filename_md5, $console_mode; - ob_flush(); - if(!$console_mode) - echo "\n"; -} - -/* update both top and bottom text box during an operation */ -function update_all_status($status) { - global $snort_filename, $snort_filename_md5, $console_mode; - ob_flush(); - if(!$console_mode) { - update_status($status); - update_output_window($status); - } -} - -/* obtain alert description for an ip address */ -function get_snort_alert($ip) { - global $snort_alert_file_split, $snort_config; - if(!file_exists("/var/log/snort/alert")) - return; - if(!$snort_config) - $snort_config = read_snort_config_cache(); - if($snort_config[$ip]) - return $snort_config[$ip]; - if(!$snort_alert_file_split) - $snort_alert_file_split = split("\n", file_get_contents("/var/log/snort/alert")); - foreach($snort_alert_file_split as $fileline) { - if (preg_match("/\[\*\*\] (\[.*\]) (.*) (\[\*\*\])/", $fileline, $matches)) - $alert_title = $matches[2]; - if (preg_match("/(\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b)/", $fileline, $matches)) - $alert_ip = $matches[$id]; - if($alert_ip == $ip) { - if(!$snort_config[$ip]) - $snort_config[$ip] = $alert_title; - return $alert_title; - } - } - return "n/a"; -} - -function make_clickable($buffer) { - global $config, $g; - /* if clickable urls is disabled, simply return buffer back to caller */ - $clickablalerteurls = $config['installedpackages']['snort']['config'][$id]['oinkmastercode']; - if(!$clickablalerteurls) - return $buffer; - $buffer = eregi_replace("(^|[ \n\r\t])((http(s?)://)(www\.)?([a-z0-9_-]+(\.[a-z0-9_-]+)+)(/[^/ \n\r]*)*)","\\1\\2", $buffer); - $buffer = eregi_replace("(^|[ \n\r\t])((ftp://)(www\.)?([a-z0-9_-]+(\.[a-z0-9_-]+)+)(/[^/ \n\r]*)*)","\\1\\2", $buffer); - $buffer = eregi_replace("([a-z_-][a-z0-9\._-]*@[a-z0-9_-]+(\.[a-z0-9_-]+)+)","\\1", $buffer); - $buffer = eregi_replace("(^|[ \n\r\t])(www\.([a-z0-9_-]+(\.[a-z0-9_-]+)+)(/[^/ \n\r]*)*)","\\1\\2", $buffer); - $buffer = eregi_replace("(^|[ \n\r\t])(ftp\.([a-z0-9_-]+(\.[a-z0-9_-]+)+)(/[^/ \n\r]*)*)","\\1\\2", $buffer); - - return $buffer; -} - -function read_snort_config_cache() { - global $g, $config, $snort_config; - if($snort_config) - return $snort_config; - if(file_exists($g['tmp_path'] . '/snort_config.cache')) { - $snort_config = unserialize(file_get_contents($g['tmp_path'] . '/snort_config.cache')); - return $snort_config; - } - return; -} - -function write_snort_config_cache($snort_config) { - global $g, $config; - conf_mount_rw(); - $configcache = fopen($g['tmp_path'] . '/snort_config.cache', "w"); - if(!$configcache) { - log_error("Could not open {$g['tmp_path']}/snort_config.cache for writing."); - return false; - } - fwrite($configcache, serialize($snort_config)); - fclose($configcache); - conf_mount_ro(); - return true; -} - -function snort_advanced() { - global $g, $config; - sync_package_snort(); -} - -function snort_define_servers() { - global $g, $config; - sync_package_snort(); -} - -?> diff --git a/config/snort-dev/snort.sh b/config/snort-dev/snort.sh deleted file mode 100644 index 5b725cfe..00000000 --- a/config/snort-dev/snort.sh +++ /dev/null @@ -1,99 +0,0 @@ -#!/bin/sh -# $FreeBSD: ports/security/snort/files/snort.sh.in,v 1.4 2009/10/29 01:27:53 clsung Exp $ - -# PROVIDE: snort -# REQUIRE: DAEMON -# BEFORE: LOGIN -# KEYWORD: shutdown - -. /etc/rc.subr -. /var/etc/rc.snort - -name="snort" -rcvar=`set_rcvar` -start_cmd="snort_start" -stop_cmd="snort_stop" - -snort_bin="/usr/local/bin/snort" -barnyard_bin="/usr/local/bin/barnyard2" - -[ -z "$snort_enable" ] && snort_enable="YES" -[ -z "$snort_flags" ] && snort_flags="-u snort -g snort -D -q -l /var/log/snort" -[ -z "$barnyard_flags" ] && barnyard_flags="-u snort -g snort -d /var/log/snort" - -snort_start() -{ - echo -n 'Starting snort:' - for _s in ${snort_list} - do - echo -n " ${_s}" - - eval _conf=\"\$snort_${_s}_conf\" - eval _name=\"\$snort_${_s}_name\" - eval _id=\"\$snort_${_s}_id\" - eval _iface=\"\$snort_${_s}_interface\" - eval _enable=\"\$snort_${_s}_enable\" - eval _barnyard=\"\$snort_${_s}_barnyard\" - _confdir=${_conf%/*} - - _enable="${_enable:-YES}" - if ! checkyesno _enable; then - continue; - fi - - if [ -f /var/run/snort_${_iface}${_name}.pid ]; then - if pgrep -F /var/run/snort_${_iface}${_name}.pid snort; then - echo -n " [snort ${_s} already running]" - continue; - fi - fi - ${snort_bin} ${snort_flags} -G ${_id} -R ${_name} -c ${_conf} -i ${_iface} - - _barnyard="${_barnyard:-NO}" - if checkyesno _barnyard; then - ${barnyard_bin} ${snort_flags} -R ${_name} -c ${_confdir}/barnyard2.conf \ - -f snort.u2_${_name} -w ${_confdir}/barnyard2.waldo - fi - done - echo -} - -snort_stop() -{ - echo -n 'Stopping snort:' - _pidlist='' - for _s in ${snort_list} - do - echo -n " ${_s}" - - eval _conf=\"\$snort_${_s}_conf\" - eval _name=\"\$snort_${_s}_name\" - eval _iface=\"\$snort_${_s}_interface\" - - if [ -f /var/run/snort_${_iface}${_name}.pid ]; then - _pid=$(pgrep -F /var/run/snort_${_iface}${_name}.pid snort) - if [ -n "${_pid}" ]; then - kill ${_pid} - _pidlist="${_pidlist} ${_pid}" - fi - fi - if [ -f /var/run/barnyard_${_iface}${_name}.pid ]; then - _pid=$(pgrep -F /var/run/barnyard_${_iface}${_name}.pid barnyard2) - if [ -n "${_pid}" ]; then - kill ${_pid} - _pidlist="${_pidlist} ${_pid}" - fi - fi - done - echo - wait_for_pids ${_pidlist} -} - -cmd="$1" -if [ $# -gt 0 ]; then - shift -fi -if [ -n "$*" ]; then - snort_list="$*" -fi -run_rc_command "${cmd}" diff --git a/config/snort-dev/snort.xml b/config/snort-dev/snort.xml deleted file mode 100644 index 37ce9967..00000000 --- a/config/snort-dev/snort.xml +++ /dev/null @@ -1,199 +0,0 @@ - - - - - - . - 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. - */ -/* ========================================================================== */ - ]]> - - Describe your package here - Describe your package requirements here - Currently there are no FAQ items provided. - Snort - 2.8.5.3 - Services: Snort 2.8.5.2 pkg v. 1.18 - /usr/local/pkg/snort/snort.inc - - Snort - Setup snort specific settings -
Services
- /snort/snort_interfaces.php -
- - snort - - snort - Snort is the most widely deployed IDS/IPS technology worldwide. - - - - - /usr/local/pkg/snort/ - 077 - http://www.pfsense.com/packages/config/snort-dev/snort.inc - - - /usr/local/www/snort/ - 077 - http://www.pfsense.com/packages/config/snort-dev/snort_fbegin.inc - - - /usr/local/bin/ - 077 - http://www.pfsense.com/packages/config/snort-dev/bin/oinkmaster_contrib/create-sidmap.pl - - - /usr/local/bin/ - 077 - http://www.pfsense.com/packages/config/snort-dev/bin/oinkmaster_contrib/oinkmaster.pl - - - /usr/local/bin/ - 077 - http://www.pfsense.com/packages/config/snort-dev/bin/oinkmaster_contrib/snort_rename.pl - - - /usr/local/pkg/snort/ - 077 - http://www.pfsense.com/packages/config/snort-dev/snort_gui.inc - - - /usr/local/pkg/pf/ - 077 - http://www.pfsense.com/packages/config/snort-dev/snort_dynamic_ip_reload.php - - - /usr/local/pkg/snort/ - 077 - http://www.pfsense.com/packages/config/snort-dev/snort_whitelist.xml - - - /usr/local/www/snort/ - 077 - http://www.pfsense.com/packages/config/snort-dev/snort_alerts.php - - - /usr/local/www/snort/ - 077 - http://www.pfsense.com/packages/config/snort-dev/snort_barnyard.php - - - /usr/local/www/snort/ - 077 - http://www.pfsense.com/packages/config/snort-dev/snort_blocked.php - - - /usr/local/www/snort/ - 077 - http://www.pfsense.com/packages/config/snort-dev/snort_define_servers.php - - - /usr/local/www/snort/ - 077 - http://www.pfsense.com/packages/config/snort-dev/snort_download_rules.php - - - /usr/local/pkg/snort/ - 077 - http://www.pfsense.com/packages/config/snort-dev/snort_check_for_rule_updates.php - - - /usr/local/www/snort/ - 077 - http://www.pfsense.com/packages/config/snort-dev/snort_help_info.php - - - /usr/local/www/snort/ - 077 - http://www.pfsense.com/packages/config/snort-dev/help_and_info.php - - - /usr/local/www/snort/ - 077 - http://www.pfsense.com/packages/config/snort-dev/snort_interfaces.php - - - /usr/local/www/snort/ - 077 - http://www.pfsense.com/packages/config/snort-dev/snort_interfaces_edit.php - - - /usr/local/www/snort/ - 077 - http://www.pfsense.com/packages/config/snort-dev/snort_interfaces_global.php - - - /usr/local/www/snort/ - 077 - http://www.pfsense.com/packages/config/snort-dev/snort_rules.php - - - /usr/local/www/snort/ - 077 - http://www.pfsense.com/packages/config/snort-dev/snort_rules_edit.php - - - /usr/local/www/snort/ - 077 - http://www.pfsense.com/packages/config/snort-dev/snort_rulesets.php - - - /usr/local/www/snort/ - 077 - http://www.pfsense.com/packages/config/snort-dev/snort_preprocessors.php - - - /usr/local/etc/rc.d/ - 755 - http://www.pfsense.com/packages/config/snort-dev/snort.sh - - - - - - - sync_snort_package(); - - - snort_postinstall(); - - - snort_deinstall(); - -
diff --git a/config/snort-dev/snort_alerts.php b/config/snort-dev/snort_alerts.php deleted file mode 100644 index 4f0ddb03..00000000 --- a/config/snort-dev/snort_alerts.php +++ /dev/null @@ -1,630 +0,0 @@ -. - Copyright (C) 2003-2004 Manuel Kasper . - Copyright (C) 2006 Scott Ullrich - All rights reserved. - - Modified for the Pfsense snort package v. 1.8+ - Copyright (C) 2009 Robert Zelaya Sr. Developer - - 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("globals.inc"); -require_once("guiconfig.inc"); -require_once("/usr/local/pkg/snort/snort.inc"); - -$snortalertlogt = $config['installedpackages']['snortglobal']['snortalertlogtype']; -$snort_logfile = '/var/log/snort/alert'; - -$pconfig['arefresh'] = $config['installedpackages']['snortglobal']['alertsblocks']['arefresh']; -$pconfig['alertnumber'] = $config['installedpackages']['snortglobal']['alertsblocks']['alertnumber']; - -if ($pconfig['alertnumber'] == '' || $pconfig['alertnumber'] == '0') -{ - $anentries = '250'; -}else{ - $anentries = $pconfig['alertnumber']; -} - -if ($_POST['save']) -{ - - //unset($input_errors); - //$pconfig = $_POST; - - /* input validation */ - if ($_POST['save']) - { - - // if (($_POST['radiusacctport'] && !is_port($_POST['radiusacctport']))) { - // $input_errors[] = "A valid port number must be specified. [".$_POST['radiusacctport']."]"; - // } - - } - - /* no errors */ - if (!$input_errors) - { - - $config['installedpackages']['snortglobal']['alertsblocks']['arefresh'] = $_POST['arefresh'] ? on : off; - $config['installedpackages']['snortglobal']['alertsblocks']['alertnumber'] = $_POST['alertnumber']; - - conf_mount_rw(); - write_config(); - //conf_mount_ro(); - sleep(2); - - header("Location: /snort/snort_alerts.php"); - - } - -} - - -if ($_POST['delete']) -{ - - exec("killall syslogd"); - conf_mount_rw(); - if(file_exists("/var/log/snort/alert")) - { - exec('/bin/rm /var/log/snort/*'); - exec('/usr/bin/touch /var/log/snort/alert'); - } - conf_mount_ro(); - system_syslogd_start(); - //exec("/usr/bin/killall -HUP snort"); - -} - -if ($_POST['download']) -{ - - ob_start(); //importanr or other post will fail - $save_date = exec('/bin/date "+%Y-%m-%d-%H-%M-%S"'); - $file_name = "snort_logs_{$save_date}.tar.gz"; - exec("/usr/bin/tar cfz /tmp/snort_logs_{$save_date}.tar.gz /var/log/snort"); - - if(file_exists("/tmp/snort_logs_{$save_date}.tar.gz")) - { - $file = "/tmp/snort_logs_{$save_date}.tar.gz"; - header("Expires: Mon, 26 Jul 1997 05:00:00 GMT\n"); - header("Pragma: private"); // needed for IE - header("Cache-Control: private, must-revalidate"); // needed for IE - header('Content-type: application/force-download'); - header('Content-Transfer-Encoding: Binary'); - header("Content-length: ".filesize($file)); - header("Content-disposition: attachment; filename = {$file_name}"); - readfile("$file"); - exec("/bin/rm /tmp/snort_logs_{$save_date}.tar.gz"); - od_end_clean(); //importanr or other post will fail - }else{ - echo 'Error no saved file.'; - } - -} - - -/* WARNING: took me forever to figure reg expression, dont lose */ -// $fileline = '12/09-18:12:02.086733 [**] [122:6:0] (portscan) TCP Filtered Decoy Portscan [**] [Priority: 3] {PROTO:255} 125.135.214.166 -> 70.61.243.50'; - -function get_snort_alert_date($fileline) -{ - /* date full date \d+\/\d+-\d+:\d+:\d+\.\d+\s */ - if (preg_match("/\d+\/\d+-\d+:\d+:\d\d/", $fileline, $matches1)) - { - $alert_date = "$matches1[0]"; - } - -return $alert_date; - -} - -function get_snort_alert_disc($fileline) -{ - /* disc */ - if (preg_match("/\[\*\*\] (\[.*\]) (.*) (\[\*\*\])/", $fileline, $matches)) - { - $alert_disc = "$matches[2]"; - } - -return $alert_disc; - -} - -function get_snort_alert_class($fileline) -{ - /* class */ - if (preg_match('/\[Classification:\s.+[^\d]\]/', $fileline, $matches2)) - { - $alert_class = "$matches2[0]"; - } - -return $alert_class; - -} - -function get_snort_alert_priority($fileline) -{ - /* Priority */ - if (preg_match('/Priority:\s\d/', $fileline, $matches3)) - { - $alert_priority = "$matches3[0]"; - } - -return $alert_priority; - -} - -function get_snort_alert_proto($fileline) -{ - /* Priority */ - if (preg_match('/\{.+\}/', $fileline, $matches3)) - { - $alert_proto = "$matches3[0]"; - } - -return $alert_proto; - -} - -function get_snort_alert_proto_full($fileline) -{ - /* Protocal full */ - if (preg_match('/.+\sTTL/', $fileline, $matches2)) - { - $alert_proto_full = "$matches2[0]"; - } - -return $alert_proto_full; - -} - -function get_snort_alert_ip_src($fileline) -{ - /* SRC IP */ - $re1='.*?'; # Non-greedy match on filler - $re2='((?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))(?![\\d])'; # IPv4 IP Address 1 - - if ($c=preg_match_all ("/".$re1.$re2."/is", $fileline, $matches4)) - { - $alert_ip_src = $matches4[1][0]; - } - -return $alert_ip_src; - -} - -function get_snort_alert_src_p($fileline) -{ - /* source port */ - if (preg_match('/:\d+\s-/', $fileline, $matches5)) - { - $alert_src_p = "$matches5[0]"; - } - -return $alert_src_p; - -} - -function get_snort_alert_flow($fileline) -{ - /* source port */ - if (preg_match('/(->|<-)/', $fileline, $matches5)) - { - $alert_flow = "$matches5[0]"; - } - -return $alert_flow; - -} - -function get_snort_alert_ip_dst($fileline) -{ - /* DST IP */ - $re1dp='.*?'; # Non-greedy match on filler - $re2dp='(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(?![\\d])'; # Uninteresting: ipaddress - $re3dp='.*?'; # Non-greedy match on filler - $re4dp='((?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))(?![\\d])'; # IPv4 IP Address 1 - - if ($c=preg_match_all ("/".$re1dp.$re2dp.$re3dp.$re4dp."/is", $fileline, $matches6)) - { - $alert_ip_dst = $matches6[1][0]; - } - -return $alert_ip_dst; - -} - -function get_snort_alert_dst_p($fileline) -{ - /* dst port */ - if (preg_match('/:\d+$/', $fileline, $matches7)) - { - $alert_dst_p = "$matches7[0]"; - } - -return $alert_dst_p; - -} - -function get_snort_alert_dst_p_full($fileline) -{ - /* dst port full */ - if (preg_match('/:\d+\n[A-Z]+\sTTL/', $fileline, $matches7)) - { - $alert_dst_p = "$matches7[0]"; - } - -return $alert_dst_p; - -} - -function get_snort_alert_sid($fileline) -{ - /* SID */ - if (preg_match('/\[\d+:\d+:\d+\]/', $fileline, $matches8)) - { - $alert_sid = "$matches8[0]"; - } - -return $alert_sid; - -} - -// - -$pgtitle = "Services: Snort: Snort Alerts"; -include("head.inc"); - -?> - - - - - - -"; -if($pfsense_stable == 'yes'){echo $pgtitle;} -echo "

\n"; - -/* refresh every 60 secs */ -if ($pconfig['arefresh'] == 'on' || $pconfig['arefresh'] == '') -{ - echo "\n"; -} -?> - - - - - - -
- -
-
- - - - - - - - - - - - - -
- Last Alert Entries. - - Latest Alert Entries Are Listed First. -
Save or Remove Logs - - - All log files will be saved. - - Warning: all log files will be deleted. - -
Auto Refresh and Log View -
- - Refresh - > - Default is ON. - - Enter the number of log entries to view. Default is 250. -
-
-
-
- - -
-
-
-
Filter: - - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n"; - } - -// - - } -} - -?> - -
#PRIPROTODESCRIPTIONCLASSSRCSPORTFLOWDSTDPORTSIDDate
{$counter}{$alert_priority}{$alert_proto}{$alert_disc}{$alert_class}{$alert_ip_src}{$alert_src_p}{$alert_flow}{$alert_ip_dst}{$alert_dst_p}{$alert_sid}{$alert_date}
-
- - - - - - - diff --git a/config/snort-dev/snort_barnyard.php b/config/snort-dev/snort_barnyard.php deleted file mode 100644 index b8f05c47..00000000 --- a/config/snort-dev/snort_barnyard.php +++ /dev/null @@ -1,441 +0,0 @@ -. - Copyright (C) 2008-2009 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. -*/ - -/* - -TODO: Nov 12 09 -Clean this code up its ugly -Important add error checking - -*/ - -require_once("globals.inc"); -require_once("guiconfig.inc"); -require_once("/usr/local/pkg/snort/snort.inc"); -require_once("/usr/local/pkg/snort/snort_gui.inc"); - -if (!is_array($config['installedpackages']['snortglobal']['rule'])) { - $config['installedpackages']['snortglobal']['rule'] = array(); -} -//nat_rules_sort(); -$a_nat = &$config['installedpackages']['snortglobal']['rule']; - -$id = $_GET['id']; -if (isset($_POST['id'])) - $id = $_POST['id']; - -if (isset($_GET['dup'])) { - $id = $_GET['dup']; - $after = $_GET['dup']; -} - -if (isset($id) && $a_nat[$id]) { - - /* old options */ - $pconfig['def_ssl_ports_ignore'] = $a_nat[$id]['def_ssl_ports_ignore']; - $pconfig['flow_depth'] = $a_nat[$id]['flow_depth']; - $pconfig['perform_stat'] = $a_nat[$id]['perform_stat']; - $pconfig['http_inspect'] = $a_nat[$id]['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['dce_rpc_2'] = $a_nat[$id]['dce_rpc_2']; - $pconfig['dns_preprocessor'] = $a_nat[$id]['dns_preprocessor']; - $pconfig['def_dns_servers'] = $a_nat[$id]['def_dns_servers']; - $pconfig['def_dns_ports'] = $a_nat[$id]['def_dns_ports']; - $pconfig['def_smtp_servers'] = $a_nat[$id]['def_smtp_servers']; - $pconfig['def_smtp_ports'] = $a_nat[$id]['def_smtp_ports']; - $pconfig['def_mail_ports'] = $a_nat[$id]['def_mail_ports']; - $pconfig['def_http_servers'] = $a_nat[$id]['def_http_servers']; - $pconfig['def_www_servers'] = $a_nat[$id]['def_www_servers']; - $pconfig['def_http_ports'] = $a_nat[$id]['def_http_ports']; - $pconfig['def_sql_servers'] = $a_nat[$id]['def_sql_servers']; - $pconfig['def_oracle_ports'] = $a_nat[$id]['def_oracle_ports']; - $pconfig['def_mssql_ports'] = $a_nat[$id]['def_mssql_ports']; - $pconfig['def_telnet_servers'] = $a_nat[$id]['def_telnet_servers']; - $pconfig['def_telnet_ports'] = $a_nat[$id]['def_telnet_ports']; - $pconfig['def_snmp_servers'] = $a_nat[$id]['def_snmp_servers']; - $pconfig['def_snmp_ports'] = $a_nat[$id]['def_snmp_ports']; - $pconfig['def_ftp_servers'] = $a_nat[$id]['def_ftp_servers']; - $pconfig['def_ftp_ports'] = $a_nat[$id]['def_ftp_ports']; - $pconfig['def_ssh_servers'] = $a_nat[$id]['def_ssh_servers']; - $pconfig['def_ssh_ports'] = $a_nat[$id]['def_ssh_ports']; - $pconfig['def_pop_servers'] = $a_nat[$id]['def_pop_servers']; - $pconfig['def_pop2_ports'] = $a_nat[$id]['def_pop2_ports']; - $pconfig['def_pop3_ports'] = $a_nat[$id]['def_pop3_ports']; - $pconfig['def_imap_servers'] = $a_nat[$id]['def_imap_servers']; - $pconfig['def_imap_ports'] = $a_nat[$id]['def_imap_ports']; - $pconfig['def_sip_proxy_ip'] = $a_nat[$id]['def_sip_proxy_ip']; - $pconfig['def_sip_proxy_ports'] = $a_nat[$id]['def_sip_proxy_ports']; - $pconfig['def_auth_ports'] = $a_nat[$id]['def_auth_ports']; - $pconfig['def_finger_ports'] = $a_nat[$id]['def_finger_ports']; - $pconfig['def_irc_ports'] = $a_nat[$id]['def_irc_ports']; - $pconfig['def_nntp_ports'] = $a_nat[$id]['def_nntp_ports']; - $pconfig['def_rlogin_ports'] = $a_nat[$id]['def_rlogin_ports']; - $pconfig['def_rsh_ports'] = $a_nat[$id]['def_rsh_ports']; - $pconfig['def_ssl_ports'] = $a_nat[$id]['def_ssl_ports']; - $pconfig['barnyard_enable'] = $a_nat[$id]['barnyard_enable']; - $pconfig['barnyard_mysql'] = $a_nat[$id]['barnyard_mysql']; - $pconfig['enable'] = $a_nat[$id]['enable']; - $pconfig['uuid'] = $a_nat[$id]['uuid']; - $pconfig['interface'] = $a_nat[$id]['interface']; - $pconfig['descr'] = $a_nat[$id]['descr']; - $pconfig['performance'] = $a_nat[$id]['performance']; - $pconfig['blockoffenders7'] = $a_nat[$id]['blockoffenders7']; - $pconfig['alertsystemlog'] = $a_nat[$id]['alertsystemlog']; - $pconfig['tcpdumplog'] = $a_nat[$id]['tcpdumplog']; - $pconfig['snortunifiedlog'] = $a_nat[$id]['snortunifiedlog']; - $pconfig['rulesets'] = $a_nat[$id]['rulesets']; - $pconfig['rule_sid_off'] = $a_nat[$id]['rule_sid_off']; - $pconfig['rule_sid_on'] = $a_nat[$id]['rule_sid_on']; - - if (!$pconfig['interface']) - $pconfig['interface'] = "wan"; -} else { - $pconfig['interface'] = "wan"; -} - -if (isset($_GET['dup'])) - unset($id); - -$if_real = convert_friendly_interface_to_real_interface_name($pconfig['interface']); -$snort_uuid = $config['installedpackages']['snortglobal']['rule'][$id]['uuid']; - - - /* alert file */ -$d_snortconfdirty_path = "/var/run/snort_conf_{$snort_uuid}_{$if_real}.dirty"; - - /* this will exec when alert says apply */ - if ($_POST['apply']) { - - if (file_exists($d_snortconfdirty_path)) { - - write_config(); - - sync_snort_package_all(); - sync_snort_package(); - - unlink($d_snortconfdirty_path); - - } - - } - - - if ($_POST["Submit"]) { - - /* check for overlaps */ - foreach ($a_nat as $natent) { - if (isset($id) && ($a_nat[$id]) && ($a_nat[$id] === $natent)) - continue; - if ($natent['interface'] != $_POST['interface']) - continue; - } - -/* if no errors write to conf */ - if (!$input_errors) { - $natent = array(); - /* repost the options already in conf */ - - if ($pconfig['interface'] != "") { $natent['interface'] = $pconfig['interface']; } - if ($pconfig['enable'] != "") { $natent['enable'] = $pconfig['enable']; } - if ($pconfig['uuid'] != "") { $natent['uuid'] = $pconfig['uuid']; } - if ($pconfig['descr'] != "") { $natent['descr'] = $pconfig['descr']; } - if ($pconfig['performance'] != "") { $natent['performance'] = $pconfig['performance']; } - if ($pconfig['blockoffenders7'] != "") { $natent['blockoffenders7'] = $pconfig['blockoffenders7']; } - if ($pconfig['alertsystemlog'] != "") { $natent['alertsystemlog'] = $pconfig['alertsystemlog']; } - if ($pconfig['tcpdumplog'] != "") { $natent['tcpdumplog'] = $pconfig['tcpdumplog']; } - if ($pconfig['snortunifiedlog'] != "") { $natent['snortunifiedlog'] = $pconfig['snortunifiedlog']; } - if ($pconfig['def_ssl_ports_ignore'] != "") { $natent['def_ssl_ports_ignore'] = $pconfig['def_ssl_ports_ignore']; } - if ($pconfig['flow_depth'] != "") { $natent['flow_depth'] = $pconfig['flow_depth']; } - if ($pconfig['perform_stat'] != "") { $natent['perform_stat'] = $pconfig['perform_stat']; } - if ($pconfig['http_inspect'] != "") { $natent['http_inspect'] = $pconfig['http_inspect']; } - if ($pconfig['other_preprocs'] != "") { $natent['other_preprocs'] = $pconfig['other_preprocs']; } - if ($pconfig['ftp_preprocessor'] != "") { $natent['ftp_preprocessor'] = $pconfig['ftp_preprocessor']; } - if ($pconfig['smtp_preprocessor'] != "") { $natent['smtp_preprocessor'] = $pconfig['smtp_preprocessor']; } - if ($pconfig['sf_portscan'] != "") { $natent['sf_portscan'] = $pconfig['sf_portscan']; } - if ($pconfig['dce_rpc_2'] != "") { $natent['dce_rpc_2'] = $pconfig['dce_rpc_2']; } - if ($pconfig['dns_preprocessor'] != "") { $natent['dns_preprocessor'] = $pconfig['dns_preprocessor']; } - if ($pconfig['def_dns_servers'] != "") { $natent['def_dns_servers'] = $pconfig['def_dns_servers']; } - if ($pconfig['def_dns_ports'] != "") { $natent['def_dns_ports'] = $pconfig['def_dns_ports']; } - if ($pconfig['def_smtp_servers'] != "") { $natent['def_smtp_servers'] = $pconfig['def_smtp_servers']; } - if ($pconfig['def_smtp_ports'] != "") { $natent['def_smtp_ports'] = $pconfig['def_smtp_ports']; } - if ($pconfig['def_mail_ports'] != "") { $natent['def_mail_ports'] = $pconfig['def_mail_ports']; } - if ($pconfig['def_http_servers'] != "") { $natent['def_http_servers'] = $pconfig['def_http_servers']; } - if ($pconfig['def_www_servers'] != "") { $natent['def_www_servers'] = $pconfig['def_www_servers']; } - if ($pconfig['def_http_ports'] != "") { $natent['def_http_ports'] = $pconfig['def_http_ports']; } - if ($pconfig['def_sql_servers'] != "") { $natent['def_sql_servers'] = $pconfig['def_sql_servers']; } - if ($pconfig['def_oracle_ports'] != "") { $natent['def_oracle_ports'] = $pconfig['def_oracle_ports']; } - if ($pconfig['def_mssql_ports'] != "") { $natent['def_mssql_ports'] = $pconfig['def_mssql_ports']; } - if ($pconfig['def_telnet_servers'] != "") { $natent['def_telnet_servers'] = $pconfig['def_telnet_servers']; } - if ($pconfig['def_telnet_ports'] != "") { $natent['def_telnet_ports'] = $pconfig['def_telnet_ports']; } - if ($pconfig['def_snmp_servers'] != "") { $natent['def_snmp_servers'] = $pconfig['def_snmp_servers']; } - if ($pconfig['def_snmp_ports'] != "") { $natent['def_snmp_ports'] = $pconfig['def_snmp_ports']; } - if ($pconfig['def_ftp_servers'] != "") { $natent['def_ftp_servers'] = $pconfig['def_ftp_servers']; } - if ($pconfig['def_ftp_ports'] != "") { $natent['def_ftp_ports'] = $pconfig['def_ftp_ports']; } - if ($pconfig['def_ssh_servers'] != "") { $natent['def_ssh_servers'] = $pconfig['def_ssh_servers']; } - if ($pconfig['def_ssh_ports'] != "") { $natent['def_ssh_ports'] = $pconfig['def_ssh_ports']; } - if ($pconfig['def_pop_servers'] != "") { $natent['def_pop_servers'] = $pconfig['def_pop_servers']; } - if ($pconfig['def_pop2_ports'] != "") { $natent['def_pop2_ports'] = $pconfig['def_pop2_ports']; } - if ($pconfig['def_pop3_ports'] != "") { $natent['def_pop3_ports'] = $pconfig['def_pop3_ports']; } - if ($pconfig['def_imap_servers'] != "") { $natent['def_imap_servers'] = $pconfig['def_imap_servers']; } - if ($pconfig['def_imap_ports'] != "") { $natent['def_imap_ports'] = $pconfig['def_imap_ports']; } - if ($pconfig['def_sip_proxy_ip'] != "") { $natent['def_sip_proxy_ip'] = $pconfig['def_sip_proxy_ip']; } - if ($pconfig['def_sip_proxy_ports'] != "") { $natent['def_sip_proxy_ports'] = $pconfig['def_sip_proxy_ports']; } - if ($pconfig['def_auth_ports'] != "") { $natent['def_auth_ports'] = $pconfig['def_auth_ports']; } - if ($pconfig['def_finger_ports'] != "") { $natent['def_finger_ports'] = $pconfig['def_finger_ports']; } - if ($pconfig['def_irc_ports'] != "") { $natent['def_irc_ports'] = $pconfig['def_irc_ports']; } - if ($pconfig['def_nntp_ports'] != "") { $natent['def_nntp_ports'] = $pconfig['def_nntp_ports']; } - if ($pconfig['def_rlogin_ports'] != "") { $natent['def_rlogin_ports'] = $pconfig['def_rlogin_ports']; } - if ($pconfig['def_rsh_ports'] != "") { $natent['def_rsh_ports'] = $pconfig['def_rsh_ports']; } - if ($pconfig['def_ssl_ports'] != "") { $natent['def_ssl_ports'] = $pconfig['def_ssl_ports']; } - if ($pconfig['rulesets'] != "") { $natent['rulesets'] = $pconfig['rulesets']; } - if ($pconfig['rule_sid_off'] != "") { $natent['rule_sid_off'] = $pconfig['rule_sid_off']; } - if ($pconfig['rule_sid_on'] != "") { $natent['rule_sid_on'] = $pconfig['rule_sid_on']; } - - /* post new options */ - $natent['barnyard_enable'] = $_POST['barnyard_enable'] ? on : off; - $natent['barnyard_mysql'] = $_POST['barnyard_mysql'] ? $_POST['barnyard_mysql'] : $pconfig['barnyard_mysql']; - if ($_POST['barnyard_enable'] == "on") { $natent['snortunifiedlog'] = on; }else{ $natent['snortunifiedlog'] = off; } if ($_POST['barnyard_enable'] == "") { $natent['snortunifiedlog'] = off; } - - if (isset($id) && $a_nat[$id]) - $a_nat[$id] = $natent; - else { - if (is_numeric($after)) - array_splice($a_nat, $after+1, 0, array($natent)); - else - $a_nat[] = $natent; - } - - write_config(); - - /* after click go to this page */ - touch($d_snortconfdirty_path); - 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' ); - header( 'Cache-Control: post-check=0, pre-check=0', false ); - header( 'Pragma: no-cache' ); - sleep(2); - header("Location: snort_barnyard.php?id=$id"); - exit; - } -} - -$pgtitle = "Snort: Interface: $id$if_real Barnyard2 Edit"; -include("head.inc"); - -?> - - -

- - - - -
- -'; - - if($savemsg) { - print_info_box_np2("{$savemsg}"); - }else{ - print_info_box_np2(' - The Snort configuration has changed and snort needs to be restarted on this interface.
- You must apply the changes in order for them to take effect.
- '); - } - } - -?> - - - - - -
- -
- - - .noid { - position:absolute; - top:10px; - left:0px; - width:94%; - background:#FCE9C0; - background-position: 15px; - border-top:2px solid #DBAC48; - border-bottom:2px solid #DBAC48; - padding: 15px 10px 85% 50px; - } - -
You can not edit options without an interface ID.
\n"; - - } - ?> - - - \n\n"; - ?> - - - - - - - - - - - - - - - - - -
  - - // care with spaces - if ($pconfig['barnyard_enable'] == "on") - $checked = checked; - if($id != "") - { - $onclick_enable = "onClick=\"enable_change(false)\">"; - } - echo " - Enable Barnyard2 on this Interface
- This will enable barnyard2 for this interface. You will also have to set the database credentials.
Interface -
- Choose which interface this rule applies to.
- Hint: in most cases, you'll want to use WAN here.
Log to a Mysql Database - -
Example: output database: log, mysql, dbname=snort user=snort host=localhost password=xyz
  - - - - -
 Note: -
- Please save your settings befor you click start.
-
-
- - - - - diff --git a/config/snort-dev/snort_blocked.php b/config/snort-dev/snort_blocked.php deleted file mode 100644 index 293679d9..00000000 --- a/config/snort-dev/snort_blocked.php +++ /dev/null @@ -1,445 +0,0 @@ - /tmp/snort_block.pf'); - - $blocked_ips_array_save = str_replace(' ', '', array_filter(explode("\n", file_get_contents('/tmp/snort_block.pf')))); - - if ($blocked_ips_array_save[0] != '') - { - - /* build the list */ - $counter = 0; - foreach($blocked_ips_array_save as $fileline3) - { - - $counter++; - - exec("/bin/echo $fileline3 >> /tmp/snort_blocked/snort_block.pf"); - - } - } - - exec("/usr/bin/tar cfz /tmp/snort_blocked_{$save_date}.tar.gz /tmp/snort_blocked"); - - if(file_exists("/tmp/snort_blocked_{$save_date}.tar.gz")) - { - $file = "/tmp/snort_blocked_{$save_date}.tar.gz"; - header("Expires: Mon, 26 Jul 1997 05:00:00 GMT\n"); - header("Pragma: private"); // needed for IE - header("Cache-Control: private, must-revalidate"); // needed for IE - header('Content-type: application/force-download'); - header('Content-Transfer-Encoding: Binary'); - header("Content-length: ".filesize($file)); - header("Content-disposition: attachment; filename = {$file_name}"); - readfile("$file"); - exec("/bin/rm /tmp/snort_blocked_{$save_date}.tar.gz"); - exec("/bin/rm /tmp/snort_block.pf"); - exec("/bin/rm /tmp/snort_blocked/snort_block.pf"); - od_end_clean(); //importanr or other post will fail - }else{ - echo 'Error no saved file.'; - } - -} - -if ($_POST['save']) -{ - - /* input validation */ - if ($_POST['save']) - { - - - } - - /* no errors */ - if (!$input_errors) - { - - $config['installedpackages']['snortglobal']['alertsblocks']['brefresh'] = $_POST['brefresh'] ? on : off; - $config['installedpackages']['snortglobal']['alertsblocks']['blertnumber'] = $_POST['blertnumber']; - - conf_mount_rw(); - write_config(); - //conf_mount_ro(); - sleep(2); - - header("Location: /snort/snort_blocked.php"); - - } - -} - -/* build filter funcs */ -function get_snort_alert_ip_src($fileline) -{ - /* SRC IP */ - $re1='.*?'; # Non-greedy match on filler - $re2='((?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))(?![\\d])'; # IPv4 IP Address 1 - - if ($c=preg_match_all ("/".$re1.$re2."/is", $fileline, $matches4)) - { - $alert_ip_src = $matches4[1][0]; - } - -return $alert_ip_src; - -} - -function get_snort_alert_disc($fileline) -{ - /* disc */ - if (preg_match("/\[\*\*\] (\[.*\]) (.*) (\[\*\*\])/", $fileline, $matches)) - { - $alert_disc = "$matches[2]"; - } - -return $alert_disc; - -} - -/* build sec filters */ -function get_snort_block_ip($fileline) -{ - /* ip */ - if (preg_match("/\[\d+\.\d+\.\d+\.\d+\]/", $fileline, $matches)) - { - $alert_block_ip = "$matches[0]"; - } - -return $alert_block_ip; - -} - -function get_snort_block_disc($fileline) -{ - /* disc */ - if (preg_match("/\]\s\[.+\]$/", $fileline, $matches)) - { - $alert_block_disc = "$matches[0]"; - } - -return $alert_block_disc; - -} - -/* tell the user what settings they have */ -$blockedtab_msg_chk = $config['installedpackages']['snortglobal']['rm_blocked']; - if ($blockedtab_msg_chk == "1h_b") { - $blocked_msg = "hour"; - } - if ($blockedtab_msg_chk == "3h_b") { - $blocked_msg = "3 hours"; - } - if ($blockedtab_msg_chk == "6h_b") { - $blocked_msg = "6 hours"; - } - if ($blockedtab_msg_chk == "12h_b") { - $blocked_msg = "12 hours"; - } - if ($blockedtab_msg_chk == "1d_b") { - $blocked_msg = "day"; - } - if ($blockedtab_msg_chk == "4d_b") { - $blocked_msg = "4 days"; - } - if ($blockedtab_msg_chk == "7d_b") { - $blocked_msg = "7 days"; - } - if ($blockedtab_msg_chk == "28d_b") { - $blocked_msg = "28 days"; - } - -if ($blockedtab_msg_chk != "never_b") -{ -$blocked_msg_txt = "Hosts are removed every $blocked_msg."; -}else{ -$blocked_msg_txt = "Settings are set to never remove hosts."; -} - -$pgtitle = "Services: Snort Blocked Hosts"; -include("head.inc"); - -?> - - -"; -if($pfsense_stable == 'yes'){echo $pgtitle;} -echo "

\n"; - -/* refresh every 60 secs */ -if ($pconfig['brefresh'] == 'on' || $pconfig['brefresh'] == '') -{ - echo "\n"; -} -?> - - - - - - - - - - - - -
- -
-
- - - - - - - - - - - - - - -
- Last Blocked. - - This page lists hosts that have been blocked by Snort.   -
Save or Remove Hosts -
- - All blocked hosts will be saved. - - Warning: all hosts will be removed. -
-
Auto Refresh and Log View -
- - Refresh - > - Default is ON. - - Enter the number of blocked entries to view. Default is 500. -
-
- -
-
- - - -
- - - - - - - - /tmp/snort_block.cache'); -$alerts_array = array_reverse(array_filter(explode("\n\n", file_get_contents('/var/log/snort/alert')))); -$blocked_ips_array = str_replace(' ', '', array_filter(explode("\n", file_get_contents('/tmp/snort_block.cache')))); - -$logent = $bnentries; - -if ($blocked_ips_array[0] != '' && $alerts_array[0] != '') -{ - - /* build the list and compare blocks to alerts */ - $counter = 0; - foreach($alerts_array as $fileline) - { - - $counter++; - - $alert_ip_src = get_snort_alert_ip_src($fileline); - $alert_ip_disc = get_snort_alert_disc($fileline); - $alert_ip_src_array[] = get_snort_alert_ip_src($fileline); - - if (in_array("$alert_ip_src", $blocked_ips_array)) - { - $input[] = "[$alert_ip_src] " . "[$alert_ip_disc]\n"; - } - } - - foreach($blocked_ips_array as $alert_block_ip) - { - - if (!in_array($alert_block_ip, $alert_ip_src_array)) - { - $input[] = "[$alert_block_ip] " . "[N\A]\n"; - } - } - - /* reduce double occurrences */ - $result = array_unique($input); - - /* buil final list, preg_match, buld html */ - $counter2 = 0; - - foreach($result as $fileline2) - { - if($logent <= $counter2) - continue; - - $counter2++; - - $alert_block_ip_str = get_snort_block_ip($fileline2); - - if($alert_block_ip_str != '') - { - $alert_block_ip_match = array('[',']'); - $alert_block_ip = str_replace($alert_block_ip_match, '', "$alert_block_ip_str"); - }else{ - $alert_block_ip = 'empty'; - } - - $alert_block_disc_str = get_snort_block_disc($fileline2); - - if($alert_block_disc_str != '') - { - $alert_block_disc_match = array('] [',']'); - $alert_block_disc = str_replace($alert_block_disc_match, '', "$alert_block_disc_str"); - }else{ - $alert_block_disc = 'empty'; - } - - /* use one echo to do the magic*/ - echo " - - - - - \n"; - - } - -}else{ - - /* if alerts file is empty and blocked table is not empty */ - $counter2 = 0; - - foreach($blocked_ips_array as $alert_block_ip) - { - if($logent <= $counter2) - continue; - - $counter2++; - - $alert_block_disc = 'N/A'; - - /* use one echo to do the magic*/ - echo " - - - - - \n"; - } -} - -if ($blocked_ips_array[0] == '') -{ - echo "\n"; -}else{ - echo "\n"; -} - -?> -
Remove#IPAlert Description
- \"Delete\" {$counter2} {$alert_block_ip} {$alert_block_disc}
- \"Delete\" {$counter2} {$alert_block_ip} {$alert_block_disc}

There are currently no items being blocked by snort.
{$counter2} items listed.
-
-
- - - diff --git a/config/snort-dev/snort_check_for_rule_updates.php b/config/snort-dev/snort_check_for_rule_updates.php deleted file mode 100644 index 6f95b101..00000000 --- a/config/snort-dev/snort_check_for_rule_updates.php +++ /dev/null @@ -1,769 +0,0 @@ - filesize("{$tmpfname}/$snort_filename")){ - echo "Error with the snort rules download...\n"; - echo "Snort rules file downloaded failed...\n"; - exit(0); - } - } -} - -/* download emergingthreats rules file */ -if ($emergingthreats_url_chk == on) { -if ($emerg_md5_check_chk_ok != on) { -if (file_exists("{$tmpfname}/{$emergingthreats_filename}")) { - echo "Emergingthreats tar file exists...\n"; -} else { - echo "There is a new set of Emergingthreats rules posted. Downloading...\n"; - echo "May take 4 to 10 min...\n"; - ini_set('user_agent','Mozilla/4.0 (compatible; MSIE 6.0)'); - $image = @file_get_contents("http://www.emergingthreats.net/rules/emerging.rules.tar.gz"); -// $image = @file_get_contents("http://www.emergingthreats.net/rules/emerging.rules.tar.gz"); - $f = fopen("{$tmpfname}/emerging.rules.tar.gz", 'w'); - fwrite($f, $image); - fclose($f); - echo "Done downloading Emergingthreats rules file.\n"; - } - } - } - -/* download pfsense rules file */ -if ($pfsense_md5_check_ok != on) { -if (file_exists("{$tmpfname}/{$pfsense_rules_filename}")) { - echo "Snortrule tar file exists...\n"; -} else { - - echo "There is a new set of Pfsense rules posted. Downloading...\n"; - echo "May take 4 to 10 min...\n"; - ini_set('user_agent','Mozilla/4.0 (compatible; MSIE 6.0)'); - $image = @file_get_contents("http://www.pfsense.com/packages/config/snort/pfsense_rules/pfsense_rules.tar.gz"); -// $image = @file_get_contents("http://www.mtest.local/pub-bin/oinkmaster.cgi/{$oinkid}/pfsense_rules.tar.gz"); - $f = fopen("{$tmpfname}/pfsense_rules.tar.gz", 'w'); - fwrite($f, $image); - fclose($f); - echo "Done downloading rules file.\n"; - } -} - -/* Compair md5 sig to file sig */ - -//$premium_url_chk = $config['installedpackages']['snort']['config'][0]['subscriber']; -//if ($premium_url_chk == on) { -//$md5 = file_get_contents("{$tmpfname}/{$snort_filename_md5}"); -//$file_md5_ondisk = `/sbin/md5 {$tmpfname}/{$snort_filename} | /usr/bin/awk '{ print $4 }'`; -// if ($md5 == $file_md5_ondisk) { -// update_status(gettext("Valid md5 checksum pass...")); -//} else { -// update_status(gettext("The downloaded file does not match the md5 file...P is ON")); -// update_output_window(gettext("Error md5 Mismatch...")); -// exit(0); -// } -//} - -//$premium_url_chk = $config['installedpackages']['snort']['config'][0]['subscriber']; -//if ($premium_url_chk != on) { -//$md55 = `/bin/cat {$tmpfname}/{$snort_filename_md5} | /usr/bin/awk '{ print $4 }'`; -//$file_md5_ondisk2 = `/sbin/md5 {$tmpfname}/{$snort_filename} | /usr/bin/awk '{ print $4 }'`; -// if ($md55 == $file_md5_ondisk2) { -// update_status(gettext("Valid md5 checksum pass...")); -//} else { -// update_status(gettext("The downloaded file does not match the md5 file...Not P")); -// update_output_window(gettext("Error md5 Mismatch...")); -// exit(0); -// } -//} - -/* Untar snort rules file individually to help people with low system specs */ -if ($snort_md5_check_ok != on) { -if (file_exists("{$tmpfname}/{$snort_filename}")) { - echo "Extracting rules...\n"; - echo "May take a while...\n"; - exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} rules/" . - " etc/" . - " so_rules/precompiled/FreeBSD-7.0/i386/2.8.4" . - " so_rules/bad-traffic.rules/" . - " so_rules/chat.rules/" . - " so_rules/dos.rules/" . - " so_rules/exploit.rules/" . - " so_rules/imap.rules/" . - " so_rules/misc.rules/" . - " so_rules/multimedia.rules/" . - " so_rules/netbios.rules/" . - " so_rules/nntp.rules/" . - " so_rules/p2p.rules/" . - " so_rules/smtp.rules/" . - " so_rules/sql.rules/" . - " so_rules/web-client.rules/" . - " so_rules/web-misc.rules/"); - echo "Done extracting Rules.\n"; -} else { - echo "The Download rules file missing...\n"; - echo "Error rules extracting failed...\n"; - exit(0); - } -} - -/* Untar emergingthreats rules to tmp */ -if ($emergingthreats_url_chk == on) { -if ($emerg_md5_check_chk_ok != on) { -if (file_exists("{$tmpfname}/{$emergingthreats_filename}")) { - echo "Extracting rules...\n"; - echo "May take a while...\n"; - exec("/usr/bin/tar xzf {$tmpfname}/{$emergingthreats_filename} -C {$snortdir} rules/"); - } - } -} - -/* Untar Pfsense rules to tmp */ -if ($pfsense_md5_check_ok != on) { -if (file_exists("{$tmpfname}/{$pfsense_rules_filename}")) { - echo "Extracting Pfsense rules...\n"; - echo "May take a while...\n"; - exec("/usr/bin/tar xzf {$tmpfname}/{$pfsense_rules_filename} -C {$snortdir} rules/"); - } -} - -/* Untar snort signatures */ -if ($snort_md5_check_ok != on) { -if (file_exists("{$tmpfname}/{$snort_filename}")) { -$signature_info_chk = $config['installedpackages']['snortglobal']['signatureinfo']; -if ($premium_url_chk == on) { - echo "Extracting Signatures...\n"; - echo "May take a while...\n"; - exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} doc/signatures/"); - echo "Done extracting Signatures.\n"; - } - } -} - -/* Make Clean Snort Directory */ -//if ($snort_md5_check_ok != on && $emerg_md5_check_chk_ok != on && $pfsense_md5_check_ok != on) { -//if (file_exists("{$snortdir}/rules")) { -// update_status(gettext("Cleaning the snort Directory...")); -// update_output_window(gettext("removing...")); -// exec("/bin/mkdir -p {$snortdir}"); -// exec("/bin/mkdir -p {$snortdir}/rules"); -// exec("/bin/mkdir -p {$snortdir}/signatures"); -// exec("/bin/rm {$snortdir}/*"); -// exec("/bin/rm {$snortdir}/rules/*"); -// exec("/bin/rm {$snortdir_wan}/*"); -// exec("/bin/rm {$snortdir_wan}/rules/*"); - -// exec("/bin/rm /usr/local/lib/snort/dynamicrules/*"); -//} else { -// update_status(gettext("Making Snort Directory...")); -// update_output_window(gettext("should be fast...")); -// exec("/bin/mkdir -p {$snortdir}"); -// exec("/bin/mkdir -p {$snortdir}/rules"); -// exec("/bin/rm {$snortdir_wan}/*"); -// exec("/bin/rm {$snortdir_wan}/rules/*"); -// exec("/bin/rm /usr/local/lib/snort/dynamicrules/\*"); -// update_status(gettext("Done making snort direcory.")); -// } -//} - -/* Copy so_rules dir to snort lib dir */ -/* Disabled untill I figure out why there is a segment falut core dump on 2.8.5.3 */ -//if ($snort_md5_check_ok != on) { -//if (file_exists("{$snortdir}/so_rules/precompiled/FreeBSD-7.0/i386/2.8.4/")) { -// echo "Copying so_rules...\n"; -// echo "May take a while...\n"; -// exec("`/bin/cp -f {$snortdir}/so_rules/precompiled/FreeBSD-7.0/i386/2.8.4/* /usr/local/lib/snort/dynamicrules/`"); -// exec("/bin/cp {$snortdir}/so_rules/bad-traffic.rules {$snortdir}/rules/bad-traffic.so.rules"); -// exec("/bin/cp {$snortdir}/so_rules/chat.rules {$snortdir}/rules/chat.so.rules"); -// exec("/bin/cp {$snortdir}/so_rules/dos.rules {$snortdir}/rules/dos.so.rules"); -// exec("/bin/cp {$snortdir}/so_rules/exploit.rules {$snortdir}/rules/exploit.so.rules"); -// exec("/bin/cp {$snortdir}/so_rules/imap.rules {$snortdir}/rules/imap.so.rules"); -// exec("/bin/cp {$snortdir}/so_rules/misc.rules {$snortdir}/rules/misc.so.rules"); -// exec("/bin/cp {$snortdir}/so_rules/multimedia.rules {$snortdir}/rules/multimedia.so.rules"); -// exec("/bin/cp {$snortdir}/so_rules/netbios.rules {$snortdir}/rules/netbios.so.rules"); -// exec("/bin/cp {$snortdir}/so_rules/nntp.rules {$snortdir}/rules/nntp.so.rules"); -// exec("/bin/cp {$snortdir}/so_rules/p2p.rules {$snortdir}/rules/p2p.so.rules"); -// exec("/bin/cp {$snortdir}/so_rules/smtp.rules {$snortdir}/rules/smtp.so.rules"); -// exec("/bin/cp {$snortdir}/so_rules/sql.rules {$snortdir}/rules/sql.so.rules"); -// exec("/bin/cp {$snortdir}/so_rules/web-client.rules {$snortdir}/rules/web-client.so.rules"); -// exec("/bin/cp {$snortdir}/so_rules/web.misc.rules {$snortdir}/rules/web.misc.so.rules"); -// exec("/bin/rm -r {$snortdir}/so_rules"); -// echo "Done copying so_rules.\n"; -//} else { -// echo "Directory so_rules does not exist...\n"; -// echo "Error copying so_rules...\n"; -// exit(0); -// } -//} - -/* Copy configs to snort dir */ -if ($snort_md5_check_ok != on) { -if (file_exists("{$snortdir}/etc/Makefile.am")) { - echo "Copying configs to snort directory...\n"; - exec("/bin/cp {$snortdir}/etc/* {$snortdir}"); - exec("/bin/rm -r {$snortdir}/etc"); - -} else { - echo "The snort config does not exist...\n"; - echo "Error copying config...\n"; - exit(0); - } -} - -/* Copy md5 sig to snort dir */ -if ($snort_md5_check_ok != on) { -if (file_exists("{$tmpfname}/$snort_filename_md5")) { - echo "Copying md5 sig to snort directory...\n"; - exec("/bin/cp {$tmpfname}/$snort_filename_md5 {$snortdir}/$snort_filename_md5"); -} else { - echo "The md5 file does not exist...\n"; - echo "Error copying config...\n"; - exit(0); - } -} - -/* Copy emergingthreats md5 sig to snort dir */ -if ($emergingthreats_url_chk == on) { -if ($emerg_md5_check_chk_ok != on) { -if (file_exists("{$tmpfname}/$emergingthreats_filename_md5")) { - echo "Copying md5 sig to snort directory...\n"; - exec("/bin/cp {$tmpfname}/$emergingthreats_filename_md5 {$snortdir}/$emergingthreats_filename_md5"); -} else { - echo "The emergingthreats md5 file does not exist...\n"; - echo "Error copying config...\n"; - exit(0); - } - } -} - -/* Copy Pfsense md5 sig to snort dir */ -if ($pfsense_md5_check_ok != on) { -if (file_exists("{$tmpfname}/$pfsense_rules_filename_md5")) { - echo "Copying Pfsense md5 sig to snort directory...\n"; - exec("/bin/cp {$tmpfname}/$pfsense_rules_filename_md5 {$snortdir}/$pfsense_rules_filename_md5"); -} else { - echo "The Pfsense md5 file does not exist...\n"; - echo "Error copying config...\n"; - exit(0); - } -} - -/* Copy signatures dir to snort dir */ -if ($snort_md5_check_ok != on) { -$signature_info_chk = $config['installedpackages']['snortglobal']['signatureinfo']; -if ($premium_url_chk == on) { -if (file_exists("{$snortdir}/doc/signatures")) { - echo "Copying signatures...\n"; - echo "May take a while...\n"; - exec("/bin/mv -f {$snortdir}/doc/signatures {$snortdir}/signatures"); - exec("/bin/rm -r {$snortdir}/doc/signatures"); - echo "Done copying signatures.\n"; -} else { - echo "Directory signatures exist...\n"; - echo "Error copying signature...\n"; - exit(0); - } - } -} - -/* double make shure cleanup emerg rules that dont belong */ -if (file_exists("/usr/local/etc/snort/rules/emerging-botcc-BLOCK.rules")) { - apc_clear_cache(); - exec("/bin/rm /usr/local/etc/snort/rules/emerging-botcc-BLOCK.rules"); - exec("/bin/rm /usr/local/etc/snort/rules/emerging-botcc.rules"); - exec("/bin/rm /usr/local/etc/snort/rules/emerging-compromised-BLOCK.rules"); - exec("/bin/rm /usr/local/etc/snort/rules/emerging-drop-BLOCK.rules"); - exec("/bin/rm /usr/local/etc/snort/rules/emerging-dshield-BLOCK.rules"); - exec("/bin/rm /usr/local/etc/snort/rules/emerging-rbn-BLOCK.rules"); - exec("/bin/rm /usr/local/etc/snort/rules/emerging-tor-BLOCK.rules"); -} - -if (file_exists("/usr/local/lib/snort/dynamicrules/lib_sfdynamic_example_rule.so")) { - exec("/bin/rm /usr/local/lib/snort/dynamicrules/lib_sfdynamic_example_rule.so"); - exec("/bin/rm /usr/local/lib/snort/dynamicrules/lib_sfdynamic_example\*"); -} - -/* make shure default rules are in the right format */ -exec("/usr/local/bin/perl -pi -e 's/#alert/# alert/g' /usr/local/etc/snort/rules/*.rules"); -exec("/usr/local/bin/perl -pi -e 's/##alert/# alert/g' /usr/local/etc/snort/rules/*.rules"); -exec("/usr/local/bin/perl -pi -e 's/## alert/# alert/g' /usr/local/etc/snort/rules/*.rules"); - -/* create a msg-map for snort */ -echo "Updating Alert Messages...\n"; -echo "Please Wait...\n"; -exec("/usr/local/bin/perl /usr/local/bin/create-sidmap.pl /usr/local/etc/snort/rules > /usr/local/etc/snort/sid-msg.map"); - - -////////////////// - -/* Start the proccess for every interface rule */ -/* TODO: try to make the code smother */ - -if (!empty($config['installedpackages']['snortglobal']['rule'])) { - -$rule_array = $config['installedpackages']['snortglobal']['rule']; -$id = -1; -foreach ($rule_array as $value) { - -$id += 1; - -$result_lan = $config['installedpackages']['snortglobal']['rule'][$id]['interface']; -$if_real = convert_friendly_interface_to_real_interface_name($result_lan); - - /* make oinkmaster.conf for each interface rule */ - oinkmaster_conf(); - - /* run oinkmaster for each interface rule */ - oinkmaster_run(); - - } -} - -/* open oinkmaster_conf for writing" function */ -function oinkmaster_conf() { - - global $config, $g, $id, $if_real, $snortdir_wan, $snortdir, $snort_md5_check_ok, $emerg_md5_check_chk_ok, $pfsense_md5_check_ok; - -/* enable disable setting will carry over with updates */ -/* TODO carry signature changes with the updates */ -if ($snort_md5_check_ok != on || $emerg_md5_check_chk_ok != on || $pfsense_md5_check_ok != on) { - -if (!empty($config['installedpackages']['snortglobal']['rule'][$id]['rule_sid_on'])) { -$enabled_sid_on = $config['installedpackages']['snortglobal']['rule'][$id]['rule_sid_on']; -$enabled_sid_on_array = split('\|\|', $enabled_sid_on); -foreach($enabled_sid_on_array as $enabled_item_on) -$selected_sid_on_sections .= "$enabled_item_on\n"; - } - -if (!empty($config['installedpackages']['snortglobal']['rule'][$id]['rule_sid_off'])) { -$enabled_sid_off = $config['installedpackages']['snortglobal']['rule'][$id]['rule_sid_off']; -$enabled_sid_off_array = split('\|\|', $enabled_sid_off); -foreach($enabled_sid_off_array as $enabled_item_off) -$selected_sid_off_sections .= "$enabled_item_off\n"; - } - -$snort_sid_text = <<> /root/debug"); - exec("/bin/cp {$snortdir}/rules/* {$snortdir_wan}/snort_$id$if_real/rules/"); - exec("/bin/cp {$snortdir}/classification.config {$snortdir_wan}/snort_$id$if_real"); - exec("/bin/cp {$snortdir}/gen-msg.map {$snortdir_wan}/snort_$id$if_real"); - exec("/bin/cp {$snortdir}/generators {$snortdir_wan}/snort_$id$if_real"); - exec("/bin/cp {$snortdir}/reference.config {$snortdir_wan}/snort_$id$if_real"); - exec("/bin/cp {$snortdir}/sid {$snortdir_wan}/snort_$id$if_real"); - exec("/bin/cp {$snortdir}/sid-msg.map {$snortdir_wan}/snort_$id$if_real"); - exec("/bin/cp {$snortdir}/unicode.map {$snortdir_wan}/snort_$id$if_real"); - -} else { - echo "Your enable and disable changes are being applied to your fresh set of rules...\n"; - echo "May take a while...\n"; - exec("/bin/echo \"test2 {$snortdir} {$snortdir_wan} $id$if_real\" > /root/debug"); - exec("/bin/cp {$snortdir}/rules/* {$snortdir_wan}/snort_$id$if_real/rules/"); - exec("/bin/cp {$snortdir}/classification.config {$snortdir_wan}/snort_$id$if_real"); - exec("/bin/cp {$snortdir}/gen-msg.map {$snortdir_wan}/snort_$id$if_real"); - exec("/bin/cp {$snortdir}/generators {$snortdir_wan}/snort_$id$if_real"); - exec("/bin/cp {$snortdir}/reference.config {$snortdir_wan}/snort_$id$if_real"); - exec("/bin/cp {$snortdir}/sid {$snortdir_wan}/snort_$id$if_real"); - exec("/bin/cp {$snortdir}/sid-msg.map {$snortdir_wan}/snort_$id$if_real"); - exec("/bin/cp {$snortdir}/unicode.map {$snortdir_wan}/snort_$id$if_real"); - - /* oinkmaster.pl will convert saved changes for the new updates then we have to change #alert to # alert for the gui */ - /* might have to add a sleep for 3sec for flash drives or old drives */ - exec("/usr/local/bin/perl /usr/local/bin/oinkmaster.pl -C /usr/local/etc/snort/oinkmaster_$id$if_real.conf -o /usr/local/etc/snort/snort_$id$if_real/rules > /usr/local/etc/snort/oinkmaster_$id$if_real.log"); - - } - } -} - -////////////// - -/* mark the time update finnished */ -$config['installedpackages']['snortglobal']['last_rules_install'] = date("Y-M-jS-h:i-A"); - -/* remove old $tmpfname files */ -if (file_exists("{$tmpfname}")) { - echo "Cleaning up...\n"; - exec("/bin/rm -r /tmp/snort_rules_up"); -// apc_clear_cache(); -} - -/* php code to flush out cache some people are reportting missing files this might help */ -sleep(2); -apc_clear_cache(); -exec("/bin/sync ;/bin/sync ;/bin/sync ;/bin/sync ;/bin/sync ;/bin/sync ;/bin/sync ;/bin/sync"); - - /* make snort the owner */ - exec("/usr/sbin/chown -R snort:snort /var/log/snort"); - exec("/usr/sbin/chown -R snort:snort /usr/local/etc/snort"); - exec("/usr/sbin/chown -R snort:snort /usr/local/lib/snort"); - exec("/bin/chmod -R 755 /var/log/snort"); - exec("/bin/chmod -R 755 /usr/local/etc/snort"); - exec("/bin/chmod -R 755 /usr/local/lib/snort"); - -/* if snort is running hardrestart, if snort is not running do nothing */ -if (file_exists("/tmp/snort_download_halt.pid")) { - exec("/bin/sh /usr/local/etc/rc.d/snort.sh start"); - echo "The Rules update finished...\n"; - echo "Snort has restarted with your new set of rules...\n"; - exec("/usr/bin/logger -p daemon.info -i -t SnortStartup 'SNORT RULE UPDATE FINNISHED...'"); - exec("/bin/rm /tmp/snort_download_halt.pid"); -} else { - echo "The Rules update finished...\n"; - exec("/usr/bin/logger -p daemon.info -i -t SnortStartup 'SNORT RULE UPDATE FINNISHED...'"); -} - -conf_mount_ro(); - -?> diff --git a/config/snort-dev/snort_define_servers.php b/config/snort-dev/snort_define_servers.php deleted file mode 100644 index dfda630b..00000000 --- a/config/snort-dev/snort_define_servers.php +++ /dev/null @@ -1,581 +0,0 @@ -. - Copyright (C) 2008-2009 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. -*/ - -/* - -TODO: Nov 12 09 -Clean this code up its ugly -Important add error checking - -*/ - -require_once("globals.inc"); -require_once("guiconfig.inc"); -require_once("/usr/local/pkg/snort/snort.inc"); -require_once("/usr/local/pkg/snort/snort_gui.inc"); - -if (!is_array($config['installedpackages']['snortglobal']['rule'])) { - $config['installedpackages']['snortglobal']['rule'] = array(); -} - -//nat_rules_sort(); -$a_nat = &$config['installedpackages']['snortglobal']['rule']; - -$id = $_GET['id']; -if (isset($_POST['id'])) - $id = $_POST['id']; - -if (isset($_GET['dup'])) { - $id = $_GET['dup']; - $after = $_GET['dup']; -} - - -if (isset($id) && $a_nat[$id]) { - - /* old options */ - $pconfig['def_ssl_ports_ignore'] = $a_nat[$id]['def_ssl_ports_ignore']; - $pconfig['flow_depth'] = $a_nat[$id]['flow_depth']; - $pconfig['perform_stat'] = $a_nat[$id]['perform_stat']; - $pconfig['http_inspect'] = $a_nat[$id]['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['dce_rpc_2'] = $a_nat[$id]['dce_rpc_2']; - $pconfig['dns_preprocessor'] = $a_nat[$id]['dns_preprocessor']; - $pconfig['def_dns_servers'] = $a_nat[$id]['def_dns_servers']; - $pconfig['def_dns_ports'] = $a_nat[$id]['def_dns_ports']; - $pconfig['def_smtp_servers'] = $a_nat[$id]['def_smtp_servers']; - $pconfig['def_smtp_ports'] = $a_nat[$id]['def_smtp_ports']; - $pconfig['def_mail_ports'] = $a_nat[$id]['def_mail_ports']; - $pconfig['def_http_servers'] = $a_nat[$id]['def_http_servers']; - $pconfig['def_www_servers'] = $a_nat[$id]['def_www_servers']; - $pconfig['def_http_ports'] = $a_nat[$id]['def_http_ports']; - $pconfig['def_sql_servers'] = $a_nat[$id]['def_sql_servers']; - $pconfig['def_oracle_ports'] = $a_nat[$id]['def_oracle_ports']; - $pconfig['def_mssql_ports'] = $a_nat[$id]['def_mssql_ports']; - $pconfig['def_telnet_servers'] = $a_nat[$id]['def_telnet_servers']; - $pconfig['def_telnet_ports'] = $a_nat[$id]['def_telnet_ports']; - $pconfig['def_snmp_servers'] = $a_nat[$id]['def_snmp_servers']; - $pconfig['def_snmp_ports'] = $a_nat[$id]['def_snmp_ports']; - $pconfig['def_ftp_servers'] = $a_nat[$id]['def_ftp_servers']; - $pconfig['def_ftp_ports'] = $a_nat[$id]['def_ftp_ports']; - $pconfig['def_ssh_servers'] = $a_nat[$id]['def_ssh_servers']; - $pconfig['def_ssh_ports'] = $a_nat[$id]['def_ssh_ports']; - $pconfig['def_pop_servers'] = $a_nat[$id]['def_pop_servers']; - $pconfig['def_pop2_ports'] = $a_nat[$id]['def_pop2_ports']; - $pconfig['def_pop3_ports'] = $a_nat[$id]['def_pop3_ports']; - $pconfig['def_imap_servers'] = $a_nat[$id]['def_imap_servers']; - $pconfig['def_imap_ports'] = $a_nat[$id]['def_imap_ports']; - $pconfig['def_sip_proxy_ip'] = $a_nat[$id]['def_sip_proxy_ip']; - $pconfig['def_sip_proxy_ports'] = $a_nat[$id]['def_sip_proxy_ports']; - $pconfig['def_auth_ports'] = $a_nat[$id]['def_auth_ports']; - $pconfig['def_finger_ports'] = $a_nat[$id]['def_finger_ports']; - $pconfig['def_irc_ports'] = $a_nat[$id]['def_irc_ports']; - $pconfig['def_nntp_ports'] = $a_nat[$id]['def_nntp_ports']; - $pconfig['def_rlogin_ports'] = $a_nat[$id]['def_rlogin_ports']; - $pconfig['def_rsh_ports'] = $a_nat[$id]['def_rsh_ports']; - $pconfig['def_ssl_ports'] = $a_nat[$id]['def_ssl_ports']; - $pconfig['barnyard_enable'] = $a_nat[$id]['barnyard_enable']; - $pconfig['barnyard_mysql'] = $a_nat[$id]['barnyard_mysql']; - $pconfig['enable'] = $a_nat[$id]['enable']; - $pconfig['uuid'] = $a_nat[$id]['uuid']; - $pconfig['interface'] = $a_nat[$id]['interface']; - $pconfig['descr'] = $a_nat[$id]['descr']; - $pconfig['performance'] = $a_nat[$id]['performance']; - $pconfig['blockoffenders7'] = $a_nat[$id]['blockoffenders7']; - $pconfig['alertsystemlog'] = $a_nat[$id]['alertsystemlog']; - $pconfig['tcpdumplog'] = $a_nat[$id]['tcpdumplog']; - $pconfig['snortunifiedlog'] = $a_nat[$id]['snortunifiedlog']; - $pconfig['rulesets'] = $a_nat[$id]['rulesets']; - $pconfig['rule_sid_off'] = $a_nat[$id]['rule_sid_off']; - $pconfig['rule_sid_on'] = $a_nat[$id]['rule_sid_on']; - -if (isset($_GET['dup'])) - unset($id); -} - -/* convert fake interfaces to real */ -$if_real = convert_friendly_interface_to_real_interface_name($pconfig['interface']); - - - if ($_POST["Submit"]) { - - /* check for overlaps */ - -/* if no errors write to conf */ - if (!$input_errors) { - $natent = array(); - /* repost the options already in conf */ - if ($pconfig['interface'] != "") { $natent['interface'] = $pconfig['interface']; } - if ($pconfig['enable'] != "") { $natent['enable'] = $pconfig['enable']; } - if ($pconfig['uuid'] != "") { $natent['uuid'] = $pconfig['uuid']; } - if ($pconfig['descr'] != "") { $natent['descr'] = $pconfig['descr']; } - if ($pconfig['performance'] != "") { $natent['performance'] = $pconfig['performance']; } - if ($pconfig['blockoffenders7'] != "") { $natent['blockoffenders7'] = $pconfig['blockoffenders7']; } - if ($pconfig['alertsystemlog'] != "") { $natent['alertsystemlog'] = $pconfig['alertsystemlog']; } - if ($pconfig['tcpdumplog'] != "") { $natent['tcpdumplog'] = $pconfig['tcpdumplog']; } - if ($pconfig['snortunifiedlog'] != "") { $natent['snortunifiedlog'] = $pconfig['snortunifiedlog']; } - if ($pconfig['def_ssl_ports_ignore'] != "") { $natent['def_ssl_ports_ignore'] = $pconfig['def_ssl_ports_ignore']; } - if ($pconfig['flow_depth'] != "") { $natent['flow_depth'] = $pconfig['flow_depth']; } - if ($pconfig['perform_stat'] != "") { $natent['perform_stat'] = $pconfig['perform_stat']; } - if ($pconfig['http_inspect'] != "") { $natent['http_inspect'] = $pconfig['http_inspect']; } - if ($pconfig['other_preprocs'] != "") { $natent['other_preprocs'] = $pconfig['other_preprocs']; } - if ($pconfig['ftp_preprocessor'] != "") { $natent['ftp_preprocessor'] = $pconfig['ftp_preprocessor']; } - if ($pconfig['smtp_preprocessor'] != "") { $natent['smtp_preprocessor'] = $pconfig['smtp_preprocessor']; } - if ($pconfig['sf_portscan'] != "") { $natent['sf_portscan'] = $pconfig['sf_portscan']; } - if ($pconfig['dce_rpc_2'] != "") { $natent['dce_rpc_2'] = $pconfig['dce_rpc_2']; } - if ($pconfig['dns_preprocessor'] != "") { $natent['dns_preprocessor'] = $pconfig['dns_preprocessor']; } - if ($pconfig['barnyard_enable'] != "") { $natent['barnyard_enable'] = $pconfig['barnyard_enable']; } - if ($pconfig['barnyard_mysql'] != "") { $natent['barnyard_mysql'] = $pconfig['barnyard_mysql']; } - if ($pconfig['rulesets'] != "") { $natent['rulesets'] = $pconfig['rulesets']; } - if ($pconfig['rule_sid_off'] != "") { $natent['rule_sid_off'] = $pconfig['rule_sid_off']; } - if ($pconfig['rule_sid_on'] != "") { $natent['rule_sid_on'] = $pconfig['rule_sid_on']; } - - - /* post new options */ - if ($_POST['def_dns_servers'] != "") { $natent['def_dns_servers'] = $_POST['def_dns_servers']; }else{ $natent['def_dns_servers'] = ""; } - if ($_POST['def_dns_ports'] != "") { $natent['def_dns_ports'] = $_POST['def_dns_ports']; }else{ $natent['def_dns_ports'] = ""; } - if ($_POST['def_smtp_servers'] != "") { $natent['def_smtp_servers'] = $_POST['def_smtp_servers']; }else{ $natent['def_smtp_servers'] = ""; } - if ($_POST['def_smtp_ports'] != "") { $natent['def_smtp_ports'] = $_POST['def_smtp_ports']; }else{ $natent['def_smtp_ports'] = ""; } - if ($_POST['def_mail_ports'] != "") { $natent['def_mail_ports'] = $_POST['def_mail_ports']; }else{ $natent['def_mail_ports'] = ""; } - if ($_POST['def_http_servers'] != "") { $natent['def_http_servers'] = $_POST['def_http_servers']; }else{ $natent['def_http_servers'] = ""; } - if ($_POST['def_www_servers'] != "") { $natent['def_www_servers'] = $_POST['def_www_servers']; }else{ $natent['def_www_servers'] = ""; } - if ($_POST['def_http_ports'] != "") { $natent['def_http_ports'] = $_POST['def_http_ports']; }else{ $natent['def_http_ports'] = ""; } - if ($_POST['def_sql_servers'] != "") { $natent['def_sql_servers'] = $_POST['def_sql_servers']; }else{ $natent['def_sql_servers'] = ""; } - if ($_POST['def_oracle_ports'] != "") { $natent['def_oracle_ports'] = $_POST['def_oracle_ports']; }else{ $natent['def_oracle_ports'] = ""; } - if ($_POST['def_mssql_ports'] != "") { $natent['def_mssql_ports'] = $_POST['def_mssql_ports']; }else{ $natent['def_mssql_ports'] = ""; } - if ($_POST['def_telnet_servers'] != "") { $natent['def_telnet_servers'] = $_POST['def_telnet_servers']; }else{ $natent['def_telnet_servers'] = ""; } - if ($_POST['def_telnet_ports'] != "") { $natent['def_telnet_ports'] = $_POST['def_telnet_ports']; }else{ $natent['def_telnet_ports'] = ""; } - if ($_POST['def_snmp_servers'] != "") { $natent['def_snmp_servers'] = $_POST['def_snmp_servers']; }else{ $natent['def_snmp_servers'] = ""; } - if ($_POST['def_snmp_ports'] != "") { $natent['def_snmp_ports'] = $_POST['def_snmp_ports']; }else{ $natent['def_snmp_ports'] = ""; } - if ($_POST['def_ftp_servers'] != "") { $natent['def_ftp_servers'] = $_POST['def_ftp_servers']; }else{ $natent['def_ftp_servers'] = ""; } - if ($_POST['def_ftp_ports'] != "") { $natent['def_ftp_ports'] = $_POST['def_ftp_ports']; }else{ $natent['def_ftp_ports'] = ""; } - if ($_POST['def_ssh_servers'] != "") { $natent['def_ssh_servers'] = $_POST['def_ssh_servers']; }else{ $natent['def_ssh_servers'] = ""; } - if ($_POST['def_ssh_ports'] != "") { $natent['def_ssh_ports'] = $_POST['def_ssh_ports']; }else{ $natent['def_ssh_ports'] = ""; } - if ($_POST['def_pop_servers'] != "") { $natent['def_pop_servers'] = $_POST['def_pop_servers']; }else{ $natent['def_pop_servers'] = ""; } - if ($_POST['def_pop2_ports'] != "") { $natent['def_pop2_ports'] = $_POST['def_pop2_ports']; }else{ $natent['def_pop2_ports'] = ""; } - if ($_POST['def_pop3_ports'] != "") { $natent['def_pop3_ports'] = $_POST['def_pop3_ports']; }else{ $natent['def_pop3_ports'] = ""; } - if ($_POST['def_imap_servers'] != "") { $natent['def_imap_servers'] = $_POST['def_imap_servers']; }else{ $natent['def_imap_servers'] = ""; } - if ($_POST['def_imap_ports'] != "") { $natent['def_imap_ports'] = $_POST['def_imap_ports']; }else{ $natent['def_imap_ports'] = ""; } - if ($_POST['def_sip_proxy_ip'] != "") { $natent['def_sip_proxy_ip'] = $_POST['def_sip_proxy_ip']; }else{ $natent['def_sip_proxy_ip'] = ""; } - if ($_POST['def_sip_proxy_ports'] != "") { $natent['def_sip_proxy_ports'] = $_POST['def_sip_proxy_ports']; }else{ $natent['def_sip_proxy_ports'] = ""; } - if ($_POST['def_auth_ports'] != "") { $natent['def_auth_ports'] = $_POST['def_auth_ports']; }else{ $natent['def_auth_ports'] = ""; } - if ($_POST['def_finger_ports'] != "") { $natent['def_finger_ports'] = $_POST['def_finger_ports']; }else{ $natent['def_finger_ports'] = ""; } - if ($_POST['def_irc_ports'] != "") { $natent['def_irc_ports'] = $_POST['def_irc_ports']; }else{ $natent['def_irc_ports'] = ""; } - if ($_POST['def_nntp_ports'] != "") { $natent['def_nntp_ports'] = $_POST['def_nntp_ports']; }else{ $natent['def_nntp_ports'] = ""; } - if ($_POST['def_rlogin_ports'] != "") { $natent['def_rlogin_ports'] = $_POST['def_rlogin_ports']; }else{ $natent['def_rlogin_ports'] = ""; } - if ($_POST['def_rsh_ports'] != "") { $natent['def_rsh_ports'] = $_POST['def_rsh_ports']; }else{ $natent['def_rsh_ports'] = ""; } - if ($_POST['def_ssl_ports'] != "") { $natent['def_ssl_ports'] = $_POST['def_ssl_ports']; }else{ $natent['def_ssl_ports'] = ""; } - - - if (isset($id) && $a_nat[$id]) - $a_nat[$id] = $natent; - else { - if (is_numeric($after)) - array_splice($a_nat, $after+1, 0, array($natent)); - else - $a_nat[] = $natent; - } - - write_config(); - - /* after click go to this page */ - - touch($d_snortconfdirty_path); - - 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' ); - header( 'Cache-Control: post-check=0, pre-check=0', false ); - header( 'Pragma: no-cache' ); - sleep(2); - - header("Location: snort_define_servers.php?id=$id"); - - exit; - } -} - - - /* alert file */ -$d_snortconfdirty_path = "/var/run/snort_conf_{$pconfig['uuid']}_{$if_real}.dirty"; - - /* this will exec when alert says apply */ - if ($_POST['apply']) { - - if (file_exists($d_snortconfdirty_path)) { - - write_config(); - - sync_snort_package_all(); - sync_snort_package(); - - unlink($d_snortconfdirty_path); - - } - - } - -$pgtitle = "Snort: Interface $id$if_real Define Servers"; -include("head.inc"); - -?> - - -

- - - - - -
- -'; - - if($savemsg) { - print_info_box_np2("{$savemsg}"); - }else{ - print_info_box_np2(' - The Snort configuration has changed and snort needs to be restarted on this interface.
- You must apply the changes in order for them to take effect.
- '); - } - } - -?> - - - - - -
- -
- - - .noid { - position:absolute; - top:10px; - left:0px; - width:94%; - background:#FCE9C0; - background-position: 15px; - border-top:2px solid #DBAC48; - border-bottom:2px solid #DBAC48; - padding: 15px 10px 85% 50px; - } - -
You can not edit options without an interface ID.
\n"; - - } - ?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 Note:
- Please save your settings before you click start.
- Please make sure there are no spaces in your definitions. -
Define DNS_SERVERS - -
Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks.
Define DNS_PORTS - -
Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 53.
Define SMTP_SERVERS - -
Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks.
Define SMTP_PORTS - -
Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 25.
Define Mail_Ports - -
Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 25,143,465,691.
Define HTTP_SERVERS - -
Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks.
Define WWW_SERVERS - -
Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks.
Define HTTP_PORTS - -
Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 80.
Define SQL_SERVERS - -
Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks.
Define ORACLE_PORTS - -
Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 1521.
Define MSSQL_PORTS - -
Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 1433.
Define TELNET_SERVERS - -
Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks.
Define TELNET_PORTS - -
Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 23.
Define SNMP_SERVERS - -
Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks.
Define SNMP_PORTS - -
Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 161.
Define FTP_SERVERS - -
Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks.
Define FTP_PORTS - -
Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 21.
Define SSH_SERVERS - -
Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks.
Define SSH_PORTS - -
Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is Pfsense SSH port.
Define POP_SERVERS - -
Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks.
Define POP2_PORTS - -
Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 109.
Define POP3_PORTS - -
Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 110.
Define IMAP_SERVERS - -
Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks.
Define IMAP_PORTS - -
Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 143.
Define SIP_PROXY_IP - -
Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks.
Define SIP_PROXY_PORTS - -
Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 5060:5090,16384:32768.
Define AUTH_PORTS - -
Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 113.
Define FINGER_PORTS - -
Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 79.
Define IRC_PORTS - -
Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 6665,6666,6667,6668,6669,7000.
Define NNTP_PORTS - -
Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 119.
Define RLOGIN_PORTS - -
Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 513.
Define RSH_PORTS - -
Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 514.
Define SSL_PORTS - -
Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 25,443,465,636,993,995.
  - - - - -
 Note: -
- Please save your settings before you click start.
-
-
- - - - - diff --git a/config/snort-dev/snort_download_rules.php b/config/snort-dev/snort_download_rules.php deleted file mode 100644 index b2bcb748..00000000 --- a/config/snort-dev/snort_download_rules.php +++ /dev/null @@ -1,1211 +0,0 @@ -"; -if($pfsense_stable == 'yes'){echo $pgtitle;} -echo "

\n"; - - echo "\n"; - echo " \n"; - echo " \n"; - echo "
\n"; - echo "
\n"; - echo " \n"; - echo " "; - echo "
\n"; - echo "    \n"; - echo " NOTE:  Snort.org and Emergingthreats.net will go down from time to time. Please be patient.\n"; - echo "
\n"; - echo "
\n"; - echo "
\n"; - echo "\n"; - echo "\n
\n"; - -/* make sure user has javascript on */ -echo " -\n"; -echo "\n"; - -echo "\n -\n -\n - \n - \n - \n - \n - \n - \n -
\n"; - - $tab_array = array(); - $tab_array[] = array("Snort Interfaces", false, "/snort/snort_interfaces.php"); - $tab_array[] = array("Global Settings", false, "/snort/snort_interfaces_global.php"); - $tab_array[] = array("Rule Updates", true, "/snort/snort_download_rules.php"); - $tab_array[] = array("Alerts", false, "/snort/snort_alerts.php"); - $tab_array[] = array("Blocked", false, "/snort/snort_blocked.php"); - $tab_array[] = array("Whitelists", false, "/pkg.php?xml=/snort/snort_whitelist.xml"); - $tab_array[] = array("Help & Info", false, "/snort/snort_help_info.php"); - display_top_tabs($tab_array); - -if ($snort_emrging_info == "stop" && $snort_oinkid_info == "stop") { -$disable_enable_button = 'onclick="this.disabled=true"'; -}else{ -$disable_enable_button = "onClick=\"parent.location='/snort/snort_download_rules.php?id_d=up'\""; -} -echo "
\n -
\n - \n - \n - \n - \n -
\n -

\n"; - -if ($mfolder_chk == "empty") -{ -echo "WARNING:   The main rules directory is empty. /usr/local/etc/snort/rules

\n"; -} - -if ($snort_emrging_info == "stop") { -echo "WARNING:   Click on the \"Global Settings\" tab and select ether snort.org or enmergingthreats.net rules to download.

\n"; -} - -if ($snort_oinkid_info == "stop") { -echo "WARNING:   Click on the \"Global Settings\" tab and enter a oinkmaster code.

\n"; -} - -if ($snort_dirty_d == "stop") { -echo "WARNING: CHANGES HAVE NOT BEEN APPLIED   Click on the \"Apply Settings\" button at the main interface tab.

\n"; -} - -echo "
\n -
\n -
\n -\n -\n -\n -

\n\n"; - -if ($id_d == "") -echo "Click on the \"Update Rules\" button to start the updates.

\n"; - -if ($config['installedpackages']['snortglobal']['last_md5_download'] != "") -echo "The last time the updates were started $last_md5_download.

\n"; - -if ($config['installedpackages']['snortglobal']['last_rules_install'] != "") -echo "The last time the updates were installed $last_rules_install.

\n"; - -include("fend.inc"); - -echo ""; -echo ""; - -exit(0); - -} - -$pgtitle = "Services: Snort: Update Rules"; - -include("/usr/local/www/head.inc"); - -?> - - - - - - - - -

- -
-
- - - - - -
- - - -
- - - - -
-
- - - - -
- - - - - -
- /images/misc/progress_bar.gif' width='280' height='23' name='progressbar' id='progressbar' alt='' /> -
-
- - - - -
-
-
-
- - - 0) { - update_status(gettext("snort.org md5 temp file exists...")); - } else { - update_status(gettext("Downloading snort.org md5 file...")); - ini_set('user_agent','Mozilla/4.0 (compatible; MSIE 6.0)'); - $image = @file_get_contents("http://dl.snort.org/{$premium_url}/snortrules-snapshot-2.8{$premium_subscriber}.tar.gz.md5?oink_code={$oinkid}"); -// $image = @file_get_contents("http://www.mtest.local/pub-bin/oinkmaster.cgi/{$oinkid}/snortrules-snapshot-2.8{$premium_subscriber}.tar.gz.md5"); - $f = fopen("{$tmpfname}/snortrules-snapshot-2.8.tar.gz.md5", 'w'); - fwrite($f, $image); - fclose($f); - update_status(gettext("Done downloading snort.org md5")); - } -} - -/* download md5 sig from emergingthreats.net */ -if ($emergingthreats == "on") -{ - update_status(gettext("Downloading emergingthreats md5 file...")); - ini_set('user_agent','Mozilla/4.0 (compatible; MSIE 6.0)'); - $image = @file_get_contents("http://www.emergingthreats.net/version.txt"); -// $image = @file_get_contents("http://www.mtest.local/pub-bin/oinkmaster.cgi/{$oinkid}/version.txt"); - $f = fopen("{$tmpfname}/version.txt", 'w'); - fwrite($f, $image); - fclose($f); - update_status(gettext("Done downloading emergingthreats md5")); -} - -/* download md5 sig from pfsense.org */ -if (file_exists("{$tmpfname}/{$pfsense_rules_filename_md5}")) { - update_status(gettext("pfsense md5 temp file exists...")); -} else { - update_status(gettext("Downloading pfsense md5 file...")); - ini_set('user_agent','Mozilla/4.0 (compatible; MSIE 6.0)'); - $image = @file_get_contents("http://www.pfsense.com/packages/config/snort/pfsense_rules/pfsense_rules.tar.gz.md5"); -// $image = @file_get_contents("http://www.mtest.local/pub-bin/oinkmaster.cgi/{$oinkid}/pfsense_rules.tar.gz.md5"); - $f = fopen("{$tmpfname}/pfsense_rules.tar.gz.md5", 'w'); - fwrite($f, $image); - fclose($f); - update_status(gettext("Done downloading pfsense md5.")); -} - -/* If md5 file is empty wait 15min exit */ -if ($snortdownload != "off") -{ - if (0 == filesize("{$tmpfname}/snortrules-snapshot-2.8.tar.gz.md5")) - { - update_status(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.")); - hide_progress_bar_status(); - /* Display last time of sucsessful md5 check from cache */ - echo "\n\n\n\n"; - echo ' -'; -echo ""; -echo ""; -conf_mount_ro(); - exit(0); - } -} - -/* If emergingthreats md5 file is empty wait 15min exit not needed */ - -/* If pfsense md5 file is empty wait 15min exit */ -if (0 == filesize("{$tmpfname}/$pfsense_rules_filename_md5")){ - update_status(gettext("Please wait... You may only check for New Pfsense Rules every 15 minutes...")); - update_output_window(gettext("Rules are released to support Pfsense packages.")); - hide_progress_bar_status(); - /* Display last time of sucsessful md5 check from cache */ - echo "\n\n\n\n"; - echo ' -'; -echo ""; -echo ""; -conf_mount_ro(); - exit(0); -} - -/* Check if were up to date snort.org */ -if ($snortdownload != "off") -{ - if (file_exists("{$snortdir}/snortrules-snapshot-2.8.tar.gz.md5")) - { - $md5_check_new_parse = file_get_contents("{$tmpfname}/{$snort_filename_md5}"); - $md5_check_new = `/bin/echo "{$md5_check_new_parse}" | /usr/bin/awk '{ print $1 }'`; - $md5_check_old_parse = file_get_contents("{$snortdir}/{$snort_filename_md5}"); - $md5_check_old = `/bin/echo "{$md5_check_old_parse}" | /usr/bin/awk '{ print $1 }'`; - /* Write out time of last sucsessful md5 to cache */ - write_config(); // Will cause switch back to read-only on nanobsd - conf_mount_rw(); - if ($md5_check_new == $md5_check_old) - { - update_status(gettext("Your rules are up to date...")); - update_output_window(gettext("You may start Snort now, check update.")); - hide_progress_bar_status(); - echo "\n\n\n\n"; - $snort_md5_check_ok = on; - } - } -} - -/* Check if were up to date emergingthreats.net */ -if ($emergingthreats == "on") -{ - if (file_exists("{$snortdir}/version.txt")) - { - $emerg_md5_check_new_parse = file_get_contents("{$tmpfname}/version.txt"); - $emerg_md5_check_new = `/bin/echo "{$emerg_md5_check_new_parse}" | /usr/bin/awk '{ print $1 }'`; - $emerg_md5_check_old_parse = file_get_contents("{$snortdir}/version.txt"); - $emerg_md5_check_old = `/bin/echo "{$emerg_md5_check_old_parse}" | /usr/bin/awk '{ print $1 }'`; - /* Write out time of last sucsessful md5 to cache */ - // Will cause switch back to read-only on nanobsd - write_config(); - conf_mount_rw(); - if ($emerg_md5_check_new == $emerg_md5_check_old) - { - hide_progress_bar_status(); - $emerg_md5_check_ok = on; - } - } -} - -/* Check if were up to date pfsense.org */ - if (file_exists("{$snortdir}/pfsense_rules.tar.gz.md5")) - { - $pfsense_check_new_parse = file_get_contents("{$tmpfname}/pfsense_rules.tar.gz.md5"); - $pfsense_md5_check_new = `/bin/echo "{$pfsense_md5_check_new_parse}" | /usr/bin/awk '{ print $1 }'`; - $pfsense_md5_check_old_parse = file_get_contents("{$snortdir}/pfsense_rules.tar.gz.md5"); - $pfsense_md5_check_old = `/bin/echo "{$pfsense_md5_check_old_parse}" | /usr/bin/awk '{ print $1 }'`; - /* Write out time of last sucsessful md5 to cache */ - // Will cause switch back to read-only on nanobsd - write_config(); - conf_mount_rw(); - if ($pfsense_md5_check_new == $pfsense_md5_check_old) - { - hide_progress_bar_status(); - $pfsense_md5_check_ok = on; - } - } - -/* Check if were up to date is so, exit */ -/* WARNING This code needs constant checks */ -if ($snortdownload != "off" && $emergingthreats != "off") -{ - if ($snort_md5_check_ok == "on" && $emerg_md5_check_ok == "on") - { - update_status(gettext("All your rules are up to date...")); - update_output_window(gettext("You may start Snort now...")); - echo ' - '; - echo ""; - echo ""; - conf_mount_ro(); - exit(0); - } -} - -if ($snortdownload == "on" && $emergingthreats == "off") -{ - if ($snort_md5_check_ok == "on") - { - update_status(gettext("Your snort.org rules are up to date...")); - update_output_window(gettext("You may start Snort now...")); - echo ' - '; - echo ""; - echo ""; - conf_mount_ro(); - exit(0); - } -} - -if ($snortdownload == "off" && $emergingthreats == "on") -{ - if ($emerg_md5_check_ok == "on") - { - update_status(gettext("Your Emergingthreats rules are up to date...")); - update_output_window(gettext("You may start Snort now...")); - echo ' - '; - echo ""; - echo ""; - conf_mount_ro(); - exit(0); - } -} - -/* You are Not Up to date, always stop snort when updating rules for low end machines */; -update_status(gettext("You are NOT up to date...")); -update_output_window(gettext("Stopping Snort service...")); -$chk_if_snort_up = exec("pgrep -x snort"); -if ($chk_if_snort_up != "") { - exec("/usr/bin/touch /tmp/snort_download_halt.pid"); - exec("/bin/sh /usr/local/etc/rc.d/snort.sh stop"); - sleep(2); -} - -/* download snortrules file */ -if ($snortdownload != "off") -{ - if ($snort_md5_check_ok != on) { - if (file_exists("{$tmpfname}/{$snort_filename}")) { - update_status(gettext("Snortrule tar file exists...")); - } else { - unhide_progress_bar_status(); - update_status(gettext("There is a new set of Snort rules posted. Downloading...")); - update_output_window(gettext("May take 4 to 10 min...")); -// download_file_with_progress_bar("http://www.mtest.local/pub-bin/oinkmaster.cgi/{$oinkid}/snortrules-snapshot-2.8{$premium_subscriber}.tar.gz", $tmpfname . "/{$snort_filename}", "read_body_firmware"); - download_file_with_progress_bar("http://dl.snort.org/{$premium_url}/snortrules-snapshot-2.8{$premium_subscriber}.tar.gz?oink_code={$oinkid}", $tmpfname . "/{$snort_filename}", "read_body_firmware"); - update_all_status($static_output); - update_status(gettext("Done downloading rules file.")); - if (150000 > filesize("{$tmpfname}/$snort_filename")){ - update_status(gettext("Error with the snort rules download...")); - update_output_window(gettext("Snort rules file downloaded failed...")); - echo ' -'; -echo ""; -echo ""; -conf_mount_ro(); - exit(0); - } - } - } -} - -/* download emergingthreats rules file */ -if ($emergingthreats == "on") -{ - if ($emerg_md5_check_ok != on) - { - if (file_exists("{$tmpfname}/{$emergingthreats_filename}")) - { - update_status(gettext("Emergingthreats tar file exists...")); - }else{ - update_status(gettext("There is a new set of Emergingthreats rules posted. Downloading...")); - update_output_window(gettext("May take 4 to 10 min...")); -// download_file_with_progress_bar("http://www.mtest.local/pub-bin/oinkmaster.cgi/{$oinkid}/emerging.rules.tar.gz", $tmpfname . "/{$emergingthreats_filename}", "read_body_firmware"); - download_file_with_progress_bar("http://www.emergingthreats.net/rules/emerging.rules.tar.gz", $tmpfname . "/{$emergingthreats_filename}", "read_body_firmware"); - update_all_status($static_output); - update_status(gettext("Done downloading Emergingthreats rules file.")); - } - } -} - -/* download pfsense rules file */ -if ($pfsense_md5_check_ok != on) { -if (file_exists("{$tmpfname}/{$pfsense_rules_filename}")) { - update_status(gettext("Snortrule tar file exists...")); -} else { - unhide_progress_bar_status(); - update_status(gettext("There is a new set of Pfsense rules posted. Downloading...")); - update_output_window(gettext("May take 4 to 10 min...")); -// download_file_with_progress_bar("http://www.mtest.local/pub-bin/oinkmaster.cgi/{$oinkid}/pfsense_rules.tar.gz", $tmpfname . "/{$pfsense_rules_filename}", "read_body_firmware"); - download_file_with_progress_bar("http://www.pfsense.com/packages/config/snort/pfsense_rules/pfsense_rules.tar.gz", $tmpfname . "/{$pfsense_rules_filename}", "read_body_firmware"); - update_all_status($static_output); - update_status(gettext("Done downloading rules file.")); - } -} - -/* Compair md5 sig to file sig */ - -//$premium_url_chk = $config['installedpackages']['snort']['config'][0]['subscriber']; -//if ($premium_url_chk == on) { -//$md5 = file_get_contents("{$tmpfname}/{$snort_filename_md5}"); -//$file_md5_ondisk = `/sbin/md5 {$tmpfname}/{$snort_filename} | /usr/bin/awk '{ print $4 }'`; -// if ($md5 == $file_md5_ondisk) { -// update_status(gettext("Valid md5 checksum pass...")); -//} else { -// update_status(gettext("The downloaded file does not match the md5 file...P is ON")); -// update_output_window(gettext("Error md5 Mismatch...")); -// exit(0); -// } -//} - -//$premium_url_chk = $config['installedpackages']['snort']['config'][0]['subscriber']; -//if ($premium_url_chk != on) { -//$md55 = `/bin/cat {$tmpfname}/{$snort_filename_md5} | /usr/bin/awk '{ print $4 }'`; -//$file_md5_ondisk2 = `/sbin/md5 {$tmpfname}/{$snort_filename} | /usr/bin/awk '{ print $4 }'`; -// if ($md55 == $file_md5_ondisk2) { -// update_status(gettext("Valid md5 checksum pass...")); -//} else { -// update_status(gettext("The downloaded file does not match the md5 file...Not P")); -// update_output_window(gettext("Error md5 Mismatch...")); -// exit(0); -// } -//} - -/* Untar snort rules file individually to help people with low system specs */ -if ($snortdownload != "off") -{ - if ($snort_md5_check_ok != on) { - if (file_exists("{$tmpfname}/{$snort_filename}")) { - update_status(gettext("Extracting rules...")); - update_output_window(gettext("May take a while...")); - exec("/bin/mkdir -p {$snortdir}/rules_bk/"); - exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir}/rules_bk rules/"); - exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} etc/" . - " so_rules/precompiled/FreeBSD-7.0/i386/2.8.5.1/" . - " so_rules/bad-traffic.rules/" . - " so_rules/chat.rules/" . - " so_rules/dos.rules/" . - " so_rules/exploit.rules/" . - " so_rules/imap.rules/" . - " so_rules/misc.rules/" . - " so_rules/multimedia.rules/" . - " so_rules/netbios.rules/" . - " so_rules/nntp.rules/" . - " so_rules/p2p.rules/" . - " so_rules/smtp.rules/" . - " so_rules/sql.rules/" . - " so_rules/web-client.rules/" . - " so_rules/web-misc.rules/"); - /* add prefix to all snort.org files */ - /* remove this part and make it all php with the simplst code posible */ - chdir ("/usr/local/etc/snort/rules_bk/rules"); - sleep(2); - exec('/usr/local/bin/perl /usr/local/bin/snort_rename.pl s/^/snort_/ *.rules'); - update_status(gettext("Done extracting Rules.")); - }else{ - update_status(gettext("The Download rules file missing...")); - update_output_window(gettext("Error rules extracting failed...")); - echo ' -'; -echo ""; -echo ""; -conf_mount_ro(); - exit(0); - } - } -} - -/* Untar emergingthreats rules to tmp */ -if ($emergingthreats == "on") -{ - if ($emerg_md5_check_ok != on) - { - if (file_exists("{$tmpfname}/{$emergingthreats_filename}")) - { - update_status(gettext("Extracting rules...")); - update_output_window(gettext("May take a while...")); - exec("/usr/bin/tar xzf {$tmpfname}/{$emergingthreats_filename} -C {$snortdir} rules/"); - } - } -} - -/* Untar Pfsense rules to tmp */ -if ($pfsense_md5_check_ok != on) { -if (file_exists("{$tmpfname}/{$pfsense_rules_filename}")) { - update_status(gettext("Extracting Pfsense rules...")); - update_output_window(gettext("May take a while...")); - exec("/usr/bin/tar xzf {$tmpfname}/{$pfsense_rules_filename} -C {$snortdir} rules/"); - } -} - -/* Untar snort signatures */ -if ($snort_md5_check_ok != on) { -if (file_exists("{$tmpfname}/{$snort_filename}")) { -$signature_info_chk = $config['installedpackages']['snortglobal']['signatureinfo']; -if ($premium_url_chk == on) { - update_status(gettext("Extracting Signatures...")); - update_output_window(gettext("May take a while...")); - exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} doc/signatures/"); - update_status(gettext("Done extracting Signatures.")); - } - } -} - -/* Copy so_rules dir to snort lib dir */ -/* Disabed untill I find out why there is a segment failt coredump when using these rules on 2.8.5.3 */ -if ($snortdownload != "off") -{ - if ($snort_md5_check_ok != on) { - if (file_exists("{$snortdir}/so_rules/precompiled/FreeBSD-7.0/i386/2.8.5.1")) { - update_status(gettext("Copying so_rules...")); - update_output_window(gettext("May take a while...")); - exec("/bin/cp -f {$snortdir}/so_rules/precompiled/FreeBSD-7.0/i386/2.8.5.1/* /usr/local/lib/snort/dynamicrules/"); - exec("/bin/cp {$snortdir}/so_rules/bad-traffic.rules {$snortdir}/rules/snort_bad-traffic.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/chat.rules {$snortdir}/rules/snort_chat.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/dos.rules {$snortdir}/rules/snort_dos.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/exploit.rules {$snortdir}/rules/snort_exploit.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/imap.rules {$snortdir}/rules/snort_imap.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/misc.rules {$snortdir}/rules/snort_misc.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/multimedia.rules {$snortdir}/rules/snort_multimedia.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/netbios.rules {$snortdir}/rules/snort_netbios.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/nntp.rules {$snortdir}/rules/snort_nntp.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/p2p.rules {$snortdir}/rules/snort_p2p.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/smtp.rules {$snortdir}/rules/snort_smtp.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/sql.rules {$snortdir}/rules/snort_sql.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/web-activex.rules {$snortdir}/rules/snort_web-activex.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/web-client.rules {$snortdir}/rules/snort_web-client.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/web-iis.rules {$snortdir}/rules/snort_web-iis.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/web.misc.rules {$snortdir}/rules/snort_web.misc.so.rules"); - exec("/bin/rm -r {$snortdir}/so_rules"); - update_status(gettext("Done copying so_rules.")); - }else{ - update_status(gettext("Directory so_rules does not exist...")); - update_output_window(gettext("Error copying so_rules...")); - echo ' -'; - echo ""; - echo ""; - conf_mount_ro(); - exit(0); - } - } -} - -/* Copy renamed snort.org rules to snort dir */ -if ($snortdownload != "off") -{ - if ($snort_md5_check_ok != on) - { - if (file_exists("{$snortdir}/rules_bk/rules/Makefile.am")) - { - update_status(gettext("Copying renamed snort.org rules to snort directory...")); - exec("/bin/cp {$snortdir}/rules_bk/rules/* {$snortdir}/rules/"); - }else{ - update_status(gettext("The renamed snort.org rules do not exist...")); - update_output_window(gettext("Error copying config...")); - echo ' -'; - echo ""; - echo ""; - conf_mount_ro(); - exit(0); - } - } -} - -/* Copy configs to snort dir */ -if ($snortdownload != "off") -{ - if ($snort_md5_check_ok != on) - { - if (file_exists("{$snortdir}/etc/Makefile.am")) { - update_status(gettext("Copying configs to snort directory...")); - exec("/bin/cp {$snortdir}/etc/* {$snortdir}"); - exec("/bin/rm -r {$snortdir}/etc"); - }else{ - update_status(gettext("The snort config does not exist...")); - update_output_window(gettext("Error copying config...")); - echo ' -'; -echo ""; -echo ""; -conf_mount_ro(); - exit(0); - } - } -} - - -/* Copy md5 sig to snort dir */ -if ($snortdownload != "off") -{ - if ($snort_md5_check_ok != on) { - if (file_exists("{$tmpfname}/$snort_filename_md5")) { - update_status(gettext("Copying md5 sig to snort directory...")); - exec("/bin/cp {$tmpfname}/$snort_filename_md5 {$snortdir}/$snort_filename_md5"); - }else{ - update_status(gettext("The md5 file does not exist...")); - update_output_window(gettext("Error copying config...")); - echo ' -'; - echo ""; - echo ""; - conf_mount_ro(); - exit(0); - } - } -} - -/* Copy emergingthreats md5 sig to snort dir */ -if ($emergingthreats == "on") -{ - if ($emerg_md5_check_ok != on) - { - if (file_exists("{$tmpfname}/$emergingthreats_filename_md5")) - { - update_status(gettext("Copying md5 sig to snort directory...")); - exec("/bin/cp {$tmpfname}/$emergingthreats_filename_md5 {$snortdir}/$emergingthreats_filename_md5"); - }else{ - update_status(gettext("The emergingthreats md5 file does not exist...")); - update_output_window(gettext("Error copying config...")); - echo ""; - echo ""; - conf_mount_ro(); - exit(0); - } - } -} - -/* Copy Pfsense md5 sig to snort dir */ -if ($pfsense_md5_check_ok != on) { -if (file_exists("{$tmpfname}/$pfsense_rules_filename_md5")) { - update_status(gettext("Copying Pfsense md5 sig to snort directory...")); - exec("/bin/cp {$tmpfname}/$pfsense_rules_filename_md5 {$snortdir}/$pfsense_rules_filename_md5"); -} else { - update_status(gettext("The Pfsense md5 file does not exist...")); - update_output_window(gettext("Error copying config...")); - echo ' -'; - echo ""; - echo ""; - conf_mount_ro(); - exit(0); - } -} - -/* Copy signatures dir to snort dir */ -if ($snortdownload != "off") -{ - if ($snort_md5_check_ok != on) - { - $signature_info_chk = $config['installedpackages']['snortglobal']['signatureinfo']; - if ($premium_url_chk == on) - { - if (file_exists("{$snortdir}/doc/signatures")) { - update_status(gettext("Copying signatures...")); - update_output_window(gettext("May take a while...")); - exec("/bin/mv -f {$snortdir}/doc/signatures {$snortdir}/signatures"); - exec("/bin/rm -r {$snortdir}/doc/signatures"); - update_status(gettext("Done copying signatures.")); - }else{ - update_status(gettext("Directory signatures exist...")); - update_output_window(gettext("Error copying signature...")); - echo ' -'; -echo ""; -echo ""; -conf_mount_ro(); - exit(0); - } - } - } -} - -/* double make shure cleanup emerg rules that dont belong */ -if (file_exists("/usr/local/etc/snort/rules/emerging-botcc-BLOCK.rules")) { - apc_clear_cache(); - exec("/bin/rm /usr/local/etc/snort/rules/emerging-botcc-BLOCK.rules"); - exec("/bin/rm /usr/local/etc/snort/rules/emerging-botcc.rules"); - exec("/bin/rm /usr/local/etc/snort/rules/emerging-compromised-BLOCK.rules"); - exec("/bin/rm /usr/local/etc/snort/rules/emerging-drop-BLOCK.rules"); - exec("/bin/rm /usr/local/etc/snort/rules/emerging-dshield-BLOCK.rules"); - exec("/bin/rm /usr/local/etc/snort/rules/emerging-rbn-BLOCK.rules"); - exec("/bin/rm /usr/local/etc/snort/rules/emerging-tor-BLOCK.rules"); -} - -if (file_exists("/usr/local/lib/snort/dynamicrules/lib_sfdynamic_example_rule.so")) { - exec("/bin/rm /usr/local/lib/snort/dynamicrules/lib_sfdynamic_example_rule.so"); - exec("/bin/rm /usr/local/lib/snort/dynamicrules/lib_sfdynamic_example\*"); -} - -/* make shure default rules are in the right format */ -exec("/usr/local/bin/perl -pi -e 's/#alert/# alert/g' /usr/local/etc/snort/rules/*.rules"); -exec("/usr/local/bin/perl -pi -e 's/##alert/# alert/g' /usr/local/etc/snort/rules/*.rules"); -exec("/usr/local/bin/perl -pi -e 's/## alert/# alert/g' /usr/local/etc/snort/rules/*.rules"); - -/* create a msg-map for snort */ -update_status(gettext("Updating Alert Messages...")); -update_output_window(gettext("Please Wait...")); -exec("/usr/local/bin/perl /usr/local/bin/create-sidmap.pl /usr/local/etc/snort/rules > /usr/local/etc/snort/sid-msg.map"); - - -////////////////// - -/* open oinkmaster_conf for writing" function */ -function oinkmaster_conf($id, $if_real, $iface_uuid) -{ - - global $config, $g, $id, $if_real, $snortdir_wan, $snortdir, $snort_md5_check_ok, $emerg_md5_check_ok, $pfsense_md5_check_ok; - conf_mount_rw(); - -/* enable disable setting will carry over with updates */ -/* TODO carry signature changes with the updates */ -if ($snort_md5_check_ok != on || $emerg_md5_check_ok != on || $pfsense_md5_check_ok != on) { - -if (!empty($config['installedpackages']['snortglobal']['rule'][$id]['rule_sid_on'])) { -$enabled_sid_on = $config['installedpackages']['snortglobal']['rule'][$id]['rule_sid_on']; -$enabled_sid_on_array = split('\|\|', $enabled_sid_on); -foreach($enabled_sid_on_array as $enabled_item_on) -$selected_sid_on_sections .= "$enabled_item_on\n"; - } - -if (!empty($config['installedpackages']['snortglobal']['rule'][$id]['rule_sid_off'])) { -$enabled_sid_off = $config['installedpackages']['snortglobal']['rule'][$id]['rule_sid_off']; -$enabled_sid_off_array = split('\|\|', $enabled_sid_off); -foreach($enabled_sid_off_array as $enabled_item_off) -$selected_sid_off_sections .= "$enabled_item_off\n"; - } - -$snort_sid_text = << /root/debug"); - exec("/bin/cp {$snortdir}/rules/* {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}/rules/"); - exec("/bin/cp {$snortdir}/classification.config {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}"); - exec("/bin/cp {$snortdir}/gen-msg.map {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}"); - exec("/bin/cp {$snortdir}/generators {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}"); - exec("/bin/cp {$snortdir}/reference.config {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}"); - exec("/bin/cp {$snortdir}/sid {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}"); - exec("/bin/cp {$snortdir}/sid-msg.map {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}"); - exec("/bin/cp {$snortdir}/unicode.map {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}"); - }else{ - update_status(gettext("Your enable and disable changes are being applied to your fresh set of rules...")); - update_output_window(gettext("May take a while...")); - exec("/bin/echo \"test2 {$snortdir} {$snortdir_wan} {$iface_uuid}_{$if_real}\" > /root/debug"); - exec("/bin/cp {$snortdir}/rules/* {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}/rules/"); - exec("/bin/cp {$snortdir}/classification.config {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}"); - exec("/bin/cp {$snortdir}/gen-msg.map {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}"); - exec("/bin/cp {$snortdir}/generators {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}"); - exec("/bin/cp {$snortdir}/reference.config {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}"); - exec("/bin/cp {$snortdir}/sid {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}"); - exec("/bin/cp {$snortdir}/sid-msg.map {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}"); - exec("/bin/cp {$snortdir}/unicode.map {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}"); - - /* might have to add a sleep for 3sec for flash drives or old drives */ - exec("/usr/local/bin/perl /usr/local/bin/oinkmaster.pl -C /usr/local/etc/snort/snort_{$iface_uuid}_{$if_real}/oinkmaster_{$iface_uuid}_{$if_real}.conf -o /usr/local/etc/snort/snort_{$iface_uuid}_{$if_real}/rules > /usr/local/etc/snort/oinkmaster_{$iface_uuid}_{$if_real}.log"); - } - } -} - -/* Start the proccess for every interface rule */ -/* TODO: try to make the code smother */ - -if (!empty($config['installedpackages']['snortglobal']['rule'])) -{ - - $rule_array = $config['installedpackages']['snortglobal']['rule']; - $id = -1; - foreach ($rule_array as $value) { - - $id += 1; - - $result_lan = $config['installedpackages']['snortglobal']['rule'][$id]['interface']; - $if_real = convert_friendly_interface_to_real_interface_name($result_lan); - $iface_uuid = $config['installedpackages']['snortglobal']['rule'][$id]['uuid']; - - /* make oinkmaster.conf for each interface rule */ - oinkmaster_conf($id, $if_real, $iface_uuid); - - /* run oinkmaster for each interface rule */ - oinkmaster_run($id, $if_real, $iface_uuid); - - } -} - -////////////// - -/* mark the time update finnished */ -$config['installedpackages']['snortglobal']['last_rules_install'] = date("Y-M-jS-h:i-A"); - -/* remove old $tmpfname files */ -if (file_exists("{$tmpfname}")) -{ - update_status(gettext("Cleaning up...")); - exec("/bin/rm -r /tmp/snort_rules_up"); - sleep(2); - exec("/bin/rm -r {$snortdir}/rules_bk/rules/"); - apc_clear_cache(); -} - -/* php code to flush out cache some people are reportting missing files this might help */ -sleep(2); -apc_clear_cache(); -exec("/bin/sync ;/bin/sync ;/bin/sync ;/bin/sync ;/bin/sync ;/bin/sync ;/bin/sync ;/bin/sync"); - -/* make all dirs snorts */ -exec("/usr/sbin/chown -R snort:snort /var/log/snort"); -exec("/usr/sbin/chown -R snort:snort /usr/local/etc/snort"); -exec("/usr/sbin/chown -R snort:snort /usr/local/lib/snort"); -exec("/bin/chmod -R 755 /var/log/snort"); -exec("/bin/chmod -R 755 /usr/local/etc/snort"); -exec("/bin/chmod -R 755 /usr/local/lib/snort"); - - -/* if snort is running hardrestart, if snort is not running do nothing */ -if (file_exists("/tmp/snort_download_halt.pid")) { - exec("/bin/sh /usr/local/etc/rc.d/snort.sh start"); - update_status(gettext("The Rules update finished...")); - update_output_window(gettext("Snort has restarted with your new set of rules...")); - exec("/bin/rm /tmp/snort_download_halt.pid"); -} else { - update_status(gettext("The Rules update finished...")); - update_output_window(gettext("You may start snort now...")); -} - -echo ' -'; - -/* hide progress bar and lets end this party */ -hide_progress_bar_status(); -conf_mount_ro(); -?> - - 150) { - update_output_window($text); - update_progress_bar($downloadProgress); - flush(); - $counter = 0; - } - conf_mount_rw(); - fwrite($fout, $string); - conf_mount_ro(); - return $length; -} - -?> - - - diff --git a/config/snort-dev/snort_dynamic_ip_reload.php b/config/snort-dev/snort_dynamic_ip_reload.php deleted file mode 100644 index 98d9bcce..00000000 --- a/config/snort-dev/snort_dynamic_ip_reload.php +++ /dev/null @@ -1,50 +0,0 @@ - \ No newline at end of file diff --git a/config/snort-dev/snort_fbegin.inc b/config/snort-dev/snort_fbegin.inc deleted file mode 100644 index b8faff09..00000000 --- a/config/snort-dev/snort_fbegin.inc +++ /dev/null @@ -1,288 +0,0 @@ - "") { - foreach($config['installedpackages']['menu'] as $menuitem) { - if($menuitem['section'] != $section) continue; - if($menuitem['url'] <> "") { - $addresswithport = getenv("HTTP_HOST"); - $colonpos = strpos($addresswithport, ":"); - if ($colonpos !== False){ - //my url is actually just the IP address of the pfsense box - $myurl = substr($addresswithport, 0, $colonpos); - } - else - { - $myurl = $addresswithport; - } - - $description = str_replace('$myurl', $myurl, $menuitem['url']); - } else { - $description = '/pkg.php?xml=' . $menuitem['configfile']; - } - $htmltext .= '
  • ' . $menuitem['name'] . '
  • ' . "\n"; - } - } - return $htmltext; - } - - - - - /* NOTICE ACKNOWLEDGE CODE by Erik Kristensen */ - if ($_REQUEST['noticeaction'] == 'acknowledge') { - $notice_id = $_REQUEST['noticeid']; - close_notice($notice_id); - } - /**********************************************/ -?> - -
    - - -
    -
    - - -
    - -
    \n"; - echo "
    \n"; - echo " \n"; - echo " "; - if(stristr($msg, "apply") == true) { - echo " "; - } - echo "
    \n"; - echo "    \n"; - echo " {$msg}\n"; - echo " "; - echo " \n"; - echo "
    \n"; - echo "
    \n"; - echo "
    \n"; - echo "\n"; - echo "\n
    \n"; - - -} - - -?> diff --git a/config/snort-dev/snort_help_info.php b/config/snort-dev/snort_help_info.php deleted file mode 100644 index 5355ec77..00000000 --- a/config/snort-dev/snort_help_info.php +++ /dev/null @@ -1,191 +0,0 @@ -. - 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"); - -header("snort_help_info.php"); -header( "Expires: Mon, 20 Dec 1998 01:00:00 GMT" ); -header( "Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT" ); -header( "Cache-Control: no-cache, must-revalidate" ); -header( "Pragma: no-cache" ); - -$pgtitle = "Snort: Services: Help and Info"; -include('head.inc'); -?> - - - - - - - - -
    - -
    - - - -#footer2 -{ - position: relative; - top: 27px; - background-color: #cccccc; - background-image: none; - background-repeat: repeat; - background-attachment: scroll; - background-position: 0% 0%; - width: 810px; - right: 15px; - font-size: 0.8em; - text-align: center; - padding-top: 0px; - padding-right: 0px; - padding-bottom: 0px; - padding-left: 0px; - clear: both; -} - - - -
    - \"Apps\" - Snort is a registered trademark of Sourcefire, Inc, Barnyard2 is a registered trademark of securixlive.com, Orion copyright Robert Zelaya, - Emergingthreats is a registered trademark of emergingthreats.net, Mysql is a registered trademark of Mysql.com -
    \n"; -} - -if ($pfsense_stable != 'yes') { -$footer3 = " - - - -
    - Snort is a registered trademark of Sourcefire, Inc, Barnyard2 is a registered trademark of securixlive.com, Orion copyright Robert Zelaya, - Emergingthreats is a registered trademark of emergingthreats.net, Mysql is a registered trademark of Mysql.com -
    \n"; -} -?> - - -
    - -
    - - - - - - - - - - - diff --git a/config/snort-dev/snort_interfaces.php b/config/snort-dev/snort_interfaces.php deleted file mode 100644 index b2f72aad..00000000 --- a/config/snort-dev/snort_interfaces.php +++ /dev/null @@ -1,581 +0,0 @@ -. - Copyright (C) 2008-2009 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_gui.inc"); -require_once("/usr/local/pkg/snort/snort.inc"); - - -$id = $_GET['id']; -if (isset($_POST['id'])) - $id = $_POST['id']; - - -if (!is_array($config['installedpackages']['snortglobal']['rule'])) - $config['installedpackages']['snortglobal']['rule'] = array(); - -$a_nat = &$config['installedpackages']['snortglobal']['rule']; - -if (isset($config['installedpackages']['snortglobal']['rule'])) { -$id_gen = count($config['installedpackages']['snortglobal']['rule']); -}else{ -$id_gen = '0'; -} - - -/* alert file */ -$d_snortconfdirty_path_ls = exec('/bin/ls /var/run/snort_conf_*.dirty'); - - /* this will exec when alert says apply */ - if ($_POST['apply']) { - - if ($d_snortconfdirty_path_ls != '') { - - write_config(); - - sync_snort_package_empty(); - sync_snort_package(); - - exec('/bin/rm /var/run/snort_conf_*.dirty'); - - 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' ); - header( 'Cache-Control: post-check=0, pre-check=0', false ); - header( 'Pragma: no-cache' ); - sleep(2); - header("Location: /snort/snort_interfaces.php"); - - exit; - - } - - } - - - -if (isset($_POST['del_x'])) { - /* delete selected rules */ - if (is_array($_POST['rule']) && count($_POST['rule'])) { - foreach ($_POST['rule'] as $rulei) { - - /* convert fake interfaces to real */ - $if_real = convert_friendly_interface_to_real_interface_name($a_nat[$rulei]['interface']); - $snort_uuid = $a_nat[$rulei]['uuid']; - - /* cool code to check if any snort is up */ - $snort_up_ck = exec("/bin/ps -auwx | /usr/bin/grep -v grep | /usr/bin/grep snort | /usr/bin/awk '{print \$2;}' | sed 1q"); - - if ($snort_up_ck != "") - { - - $start_up_pre = exec("/usr/bin/top -a -U snort -u | grep -v grep | grep \"R {$snort_uuid}_{$if_real}\" | awk '{print \$1;}'"); - $start_up_s = exec("/usr/bin/top -U snort -u | grep snort | grep {$start_up_pre} | awk '{ print $1; }'"); - $start_up_r = exec("/usr/bin/top -U root -u | grep snort | grep {$start_up_pre} | awk '{ print $1; }'"); - - $start2_upb_pre = exec("/bin/cat /var/run/barnyard2_{$snort_uuid}_{$if_real}.pid"); - $start2_upb_s = exec("/usr/bin/top -U snort -u | grep barnyard2 | grep {$start2_upb_pre} | awk '{ print $1; }'"); - $start2_upb_r = exec("/usr/bin/top -U root -u | grep barnyard2 | grep {$start2_upb_pre} | awk '{ print $1; }'"); - - - if ($start_up_s != "" || $start_up_r != "" || $start2_upb_s != "" || $start2_upb_r != "") - { - - /* dont flood the syslog code */ - //exec("/bin/cp /var/log/system.log /var/log/system.log.bk"); - //sleep(3); - - - /* remove only running instances */ - if ($start_up_s != "") - { - exec("/bin/kill {$start_up_s}"); - exec("/bin/rm /var/run/snort_{$snort_uuid}_{$if_real}*"); - } - - if ($start2_upb_s != "") - { - exec("/bin/kill {$start2_upb_s}"); - exec("/bin/rm /var/run/barnyard2_{$snort_uuid}_{$if_real}*"); - } - - if ($start_up_r != "") - { - exec("/bin/kill {$start_up_r}"); - exec("/bin/rm /var/run/snort_{$snort_uuid}_{$if_real}*"); - } - - if ($start2_upb_r != "") - { - exec("/bin/kill {$start2_upb_r}"); - exec("/bin/rm /var/run/barnyard2_{$snort_uuid}_{$if_real}*"); - } - - /* stop syslog flood code */ - //$if_real_wan_rulei = $a_nat[$rulei]['interface']; - //$if_real_wan_rulei2 = convert_friendly_interface_to_real_interface_name2($if_real_wan_rulei); - //exec("/sbin/ifconfig $if_real_wan_rulei2 -promisc"); - //exec("/bin/cp /var/log/system.log /var/log/snort/snort_sys_$rulei$if_real.log"); - //exec("/usr/bin/killall syslogd"); - //exec("/usr/sbin/clog -i -s 262144 /var/log/system.log"); - //exec("/usr/sbin/syslogd -c -ss -f /var/etc/syslog.conf"); - //sleep(2); - //exec("/bin/cp /var/log/system.log.bk /var/log/system.log"); - //$after_mem = exec("/usr/bin/top | /usr/bin/grep Wired | /usr/bin/awk '{ print $2 }'"); - //exec("/usr/bin/logger -p daemon.info -i -t SnortStartup 'MEM after {$rulei}{$if_real} STOP {$after_mem}'"); - //exec("/usr/bin/logger -p daemon.info -i -t SnortStartup 'Interface Rule removed for {$rulei}{$if_real}...'"); - - } - - } - - unset($a_nat[$rulei]); - } - - conf_mount_rw(); - exec("/bin/rm /var/log/snort/snort.u2_{$snort_uuid}_{$if_real}*"); - exec("/bin/rm -r /usr/local/etc/snort/snort_{$snort_uuid}_{$if_real}"); - conf_mount_ro(); - - write_config(); - - touch("/var/run/snort_conf_delete.dirty"); - - 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' ); - header( 'Cache-Control: post-check=0, pre-check=0', false ); - header( 'Pragma: no-cache' ); - sleep(2); - header("Location: /snort/snort_interfaces.php"); - exit; - } - -} - - -/* start/stop snort */ -if ($_GET['act'] == 'toggle' && $_GET['id'] != '') -{ - - $if_real = convert_friendly_interface_to_real_interface_name($config['installedpackages']['snortglobal']['rule'][$id]['interface']); - $snort_uuid = $config['installedpackages']['snortglobal']['rule'][$id]['uuid']; - - /* Log Iface stop */ - exec("/usr/bin/logger -p daemon.info -i -t SnortStartup 'Toggle for {$snort_uuid}_{$if_real}...'"); - - $tester2 = Running_Ck($snort_uuid, $if_real, $id); - - if ($tester2 == 'yes') { - - /* Log Iface stop */ - exec("/usr/bin/logger -p daemon.info -i -t SnortStartup '{$tester2} yn for {$snort_uuid}_{$if_real}...'"); - - Running_Stop($snort_uuid, $if_real, $id); - - 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' ); - header( 'Cache-Control: post-check=0, pre-check=0', false ); - header( 'Pragma: no-cache' ); - sleep(2); - header("Location: /snort/snort_interfaces.php"); - - }else{ - - sync_snort_package_all($id, $if_real); - sync_snort_package(); - - Running_Start($snort_uuid, $if_real, $id); - - 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' ); - header( 'Cache-Control: post-check=0, pre-check=0', false ); - header( 'Pragma: no-cache' ); - sleep(2); - header("Location: /snort/snort_interfaces.php"); - } -} - - - -$pgtitle = "Services: Snort 2.8.5.3 pkg v. 1.18 RC Final"; -include("head.inc"); - -?> - - -

    - - - - - -
    - -'; - - if($savemsg) { - print_info_box_np2("{$savemsg}"); - }else{ - print_info_box_np2(' - The Snort configuration has changed for one or more interfaces.
    - You must apply the changes in order for them to take effect.
    - '); - } - } - -?> - - - - - - -
    - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      IfSnortPerformanceBlockBarnyard2Description - - - - - -
    -
    - - - - - - - - - - - - - - - -   - - - - - -
    -
    - - - - -
    -
    -
    -
    - -
    - - -
    Note: -
    - This is the Snort Menu where you can see an over view of all your interface settings. -
    - Please edit the Global Settings tab before adding an interface. -

    - Click on the icon to add a interface.Click on the icon to start snort and barnyard. -
    - Click on the icon to edit a interface and settings.Click on the icon to stop snort and barnyard. -
    - Click on the icon to delete a interface and settings. -
    - - "") { - echo "
    "; -} -?> - - - - - -#footer2 -{ - position: relative; - top: -17px; - background-color: #cccccc; - background-image: none; - background-repeat: repeat; - background-attachment: scroll; - background-position: 0% 0%; - font-size: 0.8em; - text-align: center; - padding-top: 0px; - padding-right: 0px; - padding-bottom: 0px; - padding-left: 10px; - clear: both; -} - - - -
    - \"Apps\" - Snort is a registered trademark of Sourcefire, Inc, Barnyard2 is a registered trademark of securixlive.com, Orion copyright Robert Zelaya, - Emergingthreats is a registered trademark of emergingthreats.net, Mysql is a registered trademark of Mysql.com -
    \n"; -} - -if ($pfsense_stable != 'yes') { -$footer3 = " - - - -
    - Snort is a registered trademark of Sourcefire, Inc, Barnyard2 is a registered trademark of securixlive.com, Orion copyright Robert Zelaya, - Emergingthreats is a registered trademark of emergingthreats.net, Mysql is a registered trademark of Mysql.com -
    \n"; -} -?> - - - -
    - - - - - - - - - - diff --git a/config/snort-dev/snort_interfaces_edit.php b/config/snort-dev/snort_interfaces_edit.php deleted file mode 100644 index 164f154a..00000000 --- a/config/snort-dev/snort_interfaces_edit.php +++ /dev/null @@ -1,607 +0,0 @@ -. - Copyright (C) 2008-2009 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"); -require_once("/usr/local/pkg/snort/snort_gui.inc"); - - -if (!is_array($config['installedpackages']['snortglobal']['rule'])) { - $config['installedpackages']['snortglobal']['rule'] = array(); -} -//nat_rules_sort(); -$a_nat = &$config['installedpackages']['snortglobal']['rule']; - -$id = $_GET['id']; -if (isset($_POST['id'])) - $id = $_POST['id']; - -if (isset($_GET['dup'])) { - $id = $_GET['dup']; - $after = $_GET['dup']; -} - - -/* always have a limit of (65535) numbers only or snort will not start do to id limits */ -/* TODO: When inline gets added make the uuid the port number lisstening */ -//function gen_snort_uuid($fileline) -//{ - /* return the first 5 */ - //if (preg_match("/...../", $fileline, $matches1)) - //{ - //$uuid_final = "$matches1[0]"; - //} -//return $uuid_final; -//} - -/* gen uuid for each iface !inportant */ -if ($config['installedpackages']['snortglobal']['rule'][$id]['uuid'] == '') { - //$snort_uuid = gen_snort_uuid(strrev(uniqid(true))); -$snort_uuid = 0; -while ($snort_uuid > 65535 || $snort_uuid == 0) { - $snort_uuid = mt_rand(1, 65535); - $pconfig['uuid'] = $snort_uuid; - } -} - -/* convert fake interfaces to real */ -$if_real = convert_friendly_interface_to_real_interface_name($a_nat[$id]['interface']); - -if ($config['installedpackages']['snortglobal']['rule'][$id]['uuid'] != '') { - $snort_uuid = $config['installedpackages']['snortglobal']['rule'][$id]['uuid']; -} - -if (isset($id) && $a_nat[$id]) { - - /* old options */ - $pconfig['def_ssl_ports_ignore'] = $a_nat[$id]['def_ssl_ports_ignore']; - $pconfig['flow_depth'] = $a_nat[$id]['flow_depth']; - $pconfig['perform_stat'] = $a_nat[$id]['perform_stat']; - $pconfig['http_inspect'] = $a_nat[$id]['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['dce_rpc_2'] = $a_nat[$id]['dce_rpc_2']; - $pconfig['dns_preprocessor'] = $a_nat[$id]['dns_preprocessor']; - $pconfig['def_dns_servers'] = $a_nat[$id]['def_dns_servers']; - $pconfig['def_dns_ports'] = $a_nat[$id]['def_dns_ports']; - $pconfig['def_smtp_servers'] = $a_nat[$id]['def_smtp_servers']; - $pconfig['def_smtp_ports'] = $a_nat[$id]['def_smtp_ports']; - $pconfig['def_mail_ports'] = $a_nat[$id]['def_mail_ports']; - $pconfig['def_http_servers'] = $a_nat[$id]['def_http_servers']; - $pconfig['def_www_servers'] = $a_nat[$id]['def_www_servers']; - $pconfig['def_http_ports'] = $a_nat[$id]['def_http_ports']; - $pconfig['def_sql_servers'] = $a_nat[$id]['def_sql_servers']; - $pconfig['def_oracle_ports'] = $a_nat[$id]['def_oracle_ports']; - $pconfig['def_mssql_ports'] = $a_nat[$id]['def_mssql_ports']; - $pconfig['def_telnet_servers'] = $a_nat[$id]['def_telnet_servers']; - $pconfig['def_telnet_ports'] = $a_nat[$id]['def_telnet_ports']; - $pconfig['def_snmp_servers'] = $a_nat[$id]['def_snmp_servers']; - $pconfig['def_snmp_ports'] = $a_nat[$id]['def_snmp_ports']; - $pconfig['def_ftp_servers'] = $a_nat[$id]['def_ftp_servers']; - $pconfig['def_ftp_ports'] = $a_nat[$id]['def_ftp_ports']; - $pconfig['def_ssh_servers'] = $a_nat[$id]['def_ssh_servers']; - $pconfig['def_ssh_ports'] = $a_nat[$id]['def_ssh_ports']; - $pconfig['def_pop_servers'] = $a_nat[$id]['def_pop_servers']; - $pconfig['def_pop2_ports'] = $a_nat[$id]['def_pop2_ports']; - $pconfig['def_pop3_ports'] = $a_nat[$id]['def_pop3_ports']; - $pconfig['def_imap_servers'] = $a_nat[$id]['def_imap_servers']; - $pconfig['def_imap_ports'] = $a_nat[$id]['def_imap_ports']; - $pconfig['def_sip_proxy_ip'] = $a_nat[$id]['def_sip_proxy_ip']; - $pconfig['def_sip_proxy_ports'] = $a_nat[$id]['def_sip_proxy_ports']; - $pconfig['def_auth_ports'] = $a_nat[$id]['def_auth_ports']; - $pconfig['def_finger_ports'] = $a_nat[$id]['def_finger_ports']; - $pconfig['def_irc_ports'] = $a_nat[$id]['def_irc_ports']; - $pconfig['def_nntp_ports'] = $a_nat[$id]['def_nntp_ports']; - $pconfig['def_rlogin_ports'] = $a_nat[$id]['def_rlogin_ports']; - $pconfig['def_rsh_ports'] = $a_nat[$id]['def_rsh_ports']; - $pconfig['def_ssl_ports'] = $a_nat[$id]['def_ssl_ports']; - $pconfig['barnyard_enable'] = $a_nat[$id]['barnyard_enable']; - $pconfig['barnyard_mysql'] = $a_nat[$id]['barnyard_mysql']; - $pconfig['enable'] = $a_nat[$id]['enable']; - $pconfig['uuid'] = $a_nat[$id]['uuid']; - $pconfig['interface'] = $a_nat[$id]['interface']; - $pconfig['descr'] = $a_nat[$id]['descr']; - $pconfig['performance'] = $a_nat[$id]['performance']; - $pconfig['blockoffenders7'] = $a_nat[$id]['blockoffenders7']; - $pconfig['snortalertlogtype'] = $a_nat[$id]['snortalertlogtype']; - $pconfig['alertsystemlog'] = $a_nat[$id]['alertsystemlog']; - $pconfig['tcpdumplog'] = $a_nat[$id]['tcpdumplog']; - $pconfig['snortunifiedlog'] = $a_nat[$id]['snortunifiedlog']; - $pconfig['rulesets'] = $a_nat[$id]['rulesets']; - $pconfig['rule_sid_off'] = $a_nat[$id]['rule_sid_off']; - $pconfig['rule_sid_on'] = $a_nat[$id]['rule_sid_on']; - - - if (!$pconfig['interface']) - $pconfig['interface'] = "wan"; -} else { - $pconfig['interface'] = "wan"; -} - -if (isset($_GET['dup'])) - unset($id); - -/* alert file */ -$d_snortconfdirty_path = "/var/run/snort_conf_{$snort_uuid}_{$if_real}.dirty"; - - /* this will exec when alert says apply */ - if ($_POST['apply']) { - - if (file_exists("/var/run/snort_conf_{$snort_uuid}_.dirty")) { - - write_config(); - - sync_snort_package_empty(); - sync_snort_package(); - - unlink("/var/run/snort_conf_{$snort_uuid}_.dirty"); - - } - - if (file_exists($d_snortconfdirty_path)) { - - write_config(); - - sync_snort_package_all(); - sync_snort_package(); - - unlink($d_snortconfdirty_path); - - } - - } - -if ($_POST["Submit"]) { - - - - // if ($config['installedpackages']['snortglobal']['rule']) { - if ($_POST['descr'] == '' && $pconfig['descr'] == '') { - $input_errors[] = "Please enter a description for your reference."; - } - - if ($id == "" && $config['installedpackages']['snortglobal']['rule'][0]['interface'] != "") { - - $rule_array = $config['installedpackages']['snortglobal']['rule']; - $id_c = -1; - foreach ($rule_array as $value) { - - $id_c += 1; - - $result_lan = $config['installedpackages']['snortglobal']['rule'][$id_c]['interface']; - $if_real = convert_friendly_interface_to_real_interface_name($result_lan); - - if ($_POST['interface'] == $result_lan) { - $input_errors[] = "Interface $result_lan is in use. Please select another interface."; - } - } - } - - /* check for overlaps */ - foreach ($a_nat as $natent) { - if (isset($id) && ($a_nat[$id]) && ($a_nat[$id] === $natent)) - continue; - if ($natent['interface'] != $_POST['interface']) - continue; - } - - /* if no errors write to conf */ - if (!$input_errors) { - $natent = array(); - - /* write to conf for 1st time or rewrite the answer */ - $natent['interface'] = $_POST['interface'] ? $_POST['interface'] : $pconfig['interface']; - /* if post write to conf or rewite the answer */ - $natent['enable'] = $_POST['enable'] ? on : off; - $natent['uuid'] = $pconfig['uuid']; - $natent['descr'] = $_POST['descr'] ? $_POST['descr'] : $pconfig['descr']; - $natent['performance'] = $_POST['performance'] ? $_POST['performance'] : $pconfig['performance']; - /* if post = on use on off or rewrite the conf */ - if ($_POST['blockoffenders7'] == "on") { $natent['blockoffenders7'] = on; }else{ $natent['blockoffenders7'] = off; } if ($_POST['enable'] == "") { $natent['blockoffenders7'] = $pconfig['blockoffenders7']; } - $natent['snortalertlogtype'] = $_POST['snortalertlogtype'] ? $_POST['snortalertlogtype'] : $pconfig['snortalertlogtype']; - if ($_POST['alertsystemlog'] == "on") { $natent['alertsystemlog'] = on; }else{ $natent['alertsystemlog'] = off; } if ($_POST['enable'] == "") { $natent['alertsystemlog'] = $pconfig['alertsystemlog']; } - if ($_POST['tcpdumplog'] == "on") { $natent['tcpdumplog'] = on; }else{ $natent['tcpdumplog'] = off; } if ($_POST['enable'] == "") { $natent['tcpdumplog'] = $pconfig['tcpdumplog']; } - if ($_POST['snortunifiedlog'] == "on") { $natent['snortunifiedlog'] = on; }else{ $natent['snortunifiedlog'] = off; } if ($_POST['enable'] == "") { $natent['snortunifiedlog'] = $pconfig['snortunifiedlog']; } - /* if optiion = 0 then the old descr way will not work */ - - /* rewrite the options that are not in post */ - /* make shure values are set befor repost or conf.xml will be broken */ - if ($pconfig['def_ssl_ports_ignore'] != "") { $natent['def_ssl_ports_ignore'] = $pconfig['def_ssl_ports_ignore']; } - if ($pconfig['flow_depth'] != "") { $natent['flow_depth'] = $pconfig['flow_depth']; } - if ($pconfig['perform_stat'] != "") { $natent['perform_stat'] = $pconfig['perform_stat']; } - if ($pconfig['http_inspect'] != "") { $natent['http_inspect'] = $pconfig['http_inspect']; } - if ($pconfig['other_preprocs'] != "") { $natent['other_preprocs'] = $pconfig['other_preprocs']; } - if ($pconfig['ftp_preprocessor'] != "") { $natent['ftp_preprocessor'] = $pconfig['ftp_preprocessor']; } - if ($pconfig['smtp_preprocessor'] != "") { $natent['smtp_preprocessor'] = $pconfig['smtp_preprocessor']; } - if ($pconfig['sf_portscan'] != "") { $natent['sf_portscan'] = $pconfig['sf_portscan']; } - if ($pconfig['dce_rpc_2'] != "") { $natent['dce_rpc_2'] = $pconfig['dce_rpc_2']; } - if ($pconfig['dns_preprocessor'] != "") { $natent['dns_preprocessor'] = $pconfig['dns_preprocessor']; } - if ($pconfig['def_dns_servers'] != "") { $natent['def_dns_servers'] = $pconfig['def_dns_servers']; } - if ($pconfig['def_dns_ports'] != "") { $natent['def_dns_ports'] = $pconfig['def_dns_ports']; } - if ($pconfig['def_smtp_servers'] != "") { $natent['def_smtp_servers'] = $pconfig['def_smtp_servers']; } - if ($pconfig['def_smtp_ports'] != "") { $natent['def_smtp_ports'] = $pconfig['def_smtp_ports']; } - if ($pconfig['def_mail_ports'] != "") { $natent['def_mail_ports'] = $pconfig['def_mail_ports']; } - if ($pconfig['def_http_servers'] != "") { $natent['def_http_servers'] = $pconfig['def_http_servers']; } - if ($pconfig['def_www_servers'] != "") { $natent['def_www_servers'] = $pconfig['def_www_servers']; } - if ($pconfig['def_http_ports'] != "") { $natent['def_http_ports'] = $pconfig['def_http_ports']; } - if ($pconfig['def_sql_servers'] != "") { $natent['def_sql_servers'] = $pconfig['def_sql_servers']; } - if ($pconfig['def_oracle_ports'] != "") { $natent['def_oracle_ports'] = $pconfig['def_oracle_ports']; } - if ($pconfig['def_mssql_ports'] != "") { $natent['def_mssql_ports'] = $pconfig['def_mssql_ports']; } - if ($pconfig['def_telnet_servers'] != "") { $natent['def_telnet_servers'] = $pconfig['def_telnet_servers']; } - if ($pconfig['def_telnet_ports'] != "") { $natent['def_telnet_ports'] = $pconfig['def_telnet_ports']; } - if ($pconfig['def_snmp_servers'] != "") { $natent['def_snmp_servers'] = $pconfig['def_snmp_servers']; } - if ($pconfig['def_snmp_ports'] != "") { $natent['def_snmp_ports'] = $pconfig['def_snmp_ports']; } - if ($pconfig['def_ftp_servers'] != "") { $natent['def_ftp_servers'] = $pconfig['def_ftp_servers']; } - if ($pconfig['def_ftp_ports'] != "") { $natent['def_ftp_ports'] = $pconfig['def_ftp_ports']; } - if ($pconfig['def_ssh_servers'] != "") { $natent['def_ssh_servers'] = $pconfig['def_ssh_servers']; } - if ($pconfig['def_ssh_ports'] != "") { $natent['def_ssh_ports'] = $pconfig['def_ssh_ports']; } - if ($pconfig['def_pop_servers'] != "") { $natent['def_pop_servers'] = $pconfig['def_pop_servers']; } - if ($pconfig['def_pop2_ports'] != "") { $natent['def_pop2_ports'] = $pconfig['def_pop2_ports']; } - if ($pconfig['def_pop3_ports'] != "") { $natent['def_pop3_ports'] = $pconfig['def_pop3_ports']; } - if ($pconfig['def_imap_servers'] != "") { $natent['def_imap_servers'] = $pconfig['def_imap_servers']; } - if ($pconfig['def_imap_ports'] != "") { $natent['def_imap_ports'] = $pconfig['def_imap_ports']; } - if ($pconfig['def_sip_proxy_ip'] != "") { $natent['def_sip_proxy_ip'] = $pconfig['def_sip_proxy_ip']; } - if ($pconfig['def_sip_proxy_ports'] != "") { $natent['def_sip_proxy_ports'] = $pconfig['def_sip_proxy_ports']; } - if ($pconfig['def_auth_ports'] != "") { $natent['def_auth_ports'] = $pconfig['def_auth_ports']; } - if ($pconfig['def_finger_ports'] != "") { $natent['def_finger_ports'] = $pconfig['def_finger_ports']; } - if ($pconfig['def_irc_ports'] != "") { $natent['def_irc_ports'] = $pconfig['def_irc_ports']; } - if ($pconfig['def_nntp_ports'] != "") { $natent['def_nntp_ports'] = $pconfig['def_nntp_ports']; } - if ($pconfig['def_rlogin_ports'] != "") { $natent['def_rlogin_ports'] = $pconfig['def_rlogin_ports']; } - if ($pconfig['def_rsh_ports'] != "") { $natent['def_rsh_ports'] = $pconfig['def_rsh_ports']; } - if ($pconfig['def_ssl_ports'] != "") { $natent['def_ssl_ports'] = $pconfig['def_ssl_ports']; } - if ($pconfig['barnyard_enable'] != "") { $natent['barnyard_enable'] = $pconfig['barnyard_enable']; } - if ($pconfig['barnyard_mysql'] != "") { $natent['barnyard_mysql'] = $pconfig['barnyard_mysql']; } - if ($pconfig['rulesets'] != "") { $natent['rulesets'] = $pconfig['rulesets']; } - if ($pconfig['rule_sid_off'] != "") { $natent['rule_sid_off'] = $pconfig['rule_sid_off']; } - if ($pconfig['rule_sid_on'] != "") { $natent['rule_sid_on'] = $pconfig['rule_sid_on']; } - - - if (isset($id) && $a_nat[$id]) - $a_nat[$id] = $natent; - else { - if (is_numeric($after)) - array_splice($a_nat, $after+1, 0, array($natent)); - else - $a_nat[] = $natent; - } - - write_config(); - - touch("$d_snortconfdirty_path"); - - 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' ); - header( 'Cache-Control: post-check=0, pre-check=0', false ); - header( 'Pragma: no-cache' ); - sleep(2); - header("Location: /snort/snort_interfaces_edit.php?id=$id"); - - exit; - } -} - - if ($_POST["Submit2"]) { - - sync_snort_package_all(); - sync_snort_package(); - sleep(1); - - Running_Start($snort_uuid, $if_real, $id); - - 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' ); - header( 'Cache-Control: post-check=0, pre-check=0', false ); - header( 'Pragma: no-cache' ); - sleep(2); - header("Location: /snort/snort_interfaces_edit.php?id=$id"); - } - - if ($_POST["Submit3"]) - { - - Running_Stop($snort_uuid, $if_real, $id); - - 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' ); - header( 'Cache-Control: post-check=0, pre-check=0', false ); - header( 'Pragma: no-cache' ); - sleep(2); - header("Location: /snort/snort_interfaces_edit.php?id=$id"); - - } - - /* This code needs to be below headers */ - if (isset($config['installedpackages']['snortglobal']['rule'][$id]['interface'])) - { - - $snort_up_ck2_info = Running_Ck($snort_uuid, $if_real, $id); - - if ($snort_up_ck2_info == 'no') { - $snort_up_ck = ''; - }else{ - $snort_up_ck = ''; - } - - }else{ - $snort_up_ck = ''; - } - - -$pgtitle = "Snort: Interface Edit: $id $snort_uuid $if_real"; -include("head.inc"); - -?> - - - - - -

    - - -
    " method="post" enctype="multipart/form-data" name="iform" id="iform"> - -'; - - if($savemsg) { - print_info_box_np2("{$savemsg}"); - }else{ - print_info_box_np2(' - The Snort configuration has changed and snort needs to be restarted on this interface.
    - You must apply the changes in order for them to take effect.
    - '); - } - } - -?> - - - - - -
    - -
    - - - - \n\n"; - ?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      - - // care with spaces - if ($pconfig['enable'] == "on") - $checked = checked; - - $onclick_enable = "onClick=\"enable_change(false)\">"; - - echo " - Enable Interface
    Interface -
    - Choose which interface this rule applies to.
    - Hint: in most cases, you'll want to use WAN here.
    Description - -
    You may enter a description here for your reference (not parsed).
    Memory Performance -
    - Lowmem and ac-bnfa are recommended for low end systems, Ac: high memory, best performance, ac-std: moderate memory,high performance, acs: small memory, moderateperformance, ac-banded: small memory,moderate performance, ac-sparsebands: small memory, high performance.
    -
    Block offenders - onClick="enable_change(false)">
    - Checking this option will automatically block hosts that generate a Snort alert.
    Send alerts to main System logs - onClick="enable_change(false)">
    - Snort will send Alerts to the Pfsense system logs.
    Log to a Tcpdump file - onClick="enable_change(false)">
    - Snort will log packets to a tcpdump-formatted file. The file then can be analyzed by an application such as Wireshark which understands pcap file formats. WARNING: File may become large.
    Log Alerts to a snort unified2 file - onClick="enable_change(false)">
    - Snort will log Alerts to a file in the UNIFIED2 format. This is a requirement for barnyard2.
    - - - - -
     Note: -
    - Please save your settings before you click start.
    -
    -
    - - - - - diff --git a/config/snort-dev/snort_interfaces_global.php b/config/snort-dev/snort_interfaces_global.php deleted file mode 100644 index ff3620a3..00000000 --- a/config/snort-dev/snort_interfaces_global.php +++ /dev/null @@ -1,380 +0,0 @@ -. - All rights reserved. - - Copyright (C) 2008-2009 Robert Zelaya - Modified for the Pfsense snort package. - 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. -*/ - -$pgtitle = "Services: Snort: Global Settings"; -require_once("guiconfig.inc"); -require_once("/usr/local/pkg/snort/snort.inc"); - -/* make things short */ -$pconfig['snortdownload'] = $config['installedpackages']['snortglobal']['snortdownload']; -$pconfig['oinkmastercode'] = $config['installedpackages']['snortglobal']['oinkmastercode']; -$pconfig['emergingthreats'] = $config['installedpackages']['snortglobal']['emergingthreats']; -$pconfig['rm_blocked'] = $config['installedpackages']['snortglobal']['rm_blocked']; -$pconfig['autorulesupdate7'] = $config['installedpackages']['snortglobal']['autorulesupdate7']; -$pconfig['whitelistvpns'] = $config['installedpackages']['snortglobal']['whitelistvpns']; -$pconfig['clickablalerteurls'] = $config['installedpackages']['snortglobal']['clickablalerteurls']; -$pconfig['associatealertip'] = $config['installedpackages']['snortglobal']['associatealertip']; -$pconfig['snortalertlogtype'] = $config['installedpackages']['snortglobal']['snortalertlogtype']; - - -if ($_POST) { - - unset($input_errors); - $pconfig = $_POST; - - /* input validation */ - if ($_POST['enable']) - { - -/* TODO:a dd check user input code. */ - - } - - if (!$input_errors) { - - if ($_POST["Submit"]) { - - $config['installedpackages']['snortglobal']['snortdownload'] = $_POST['snortdownload']; - $config['installedpackages']['snortglobal']['oinkmastercode'] = $_POST['oinkmastercode']; - $config['installedpackages']['snortglobal']['emergingthreats'] = $_POST['emergingthreats'] ? on : off; - $config['installedpackages']['snortglobal']['rm_blocked'] = $_POST['rm_blocked']; - $config['installedpackages']['snortglobal']['autorulesupdate7'] = $_POST['autorulesupdate7']; - $config['installedpackages']['snortglobal']['whitelistvpns'] = $_POST['whitelistvpns'] ? on : off; - $config['installedpackages']['snortglobal']['clickablalerteurls'] = $_POST['clickablalerteurls'] ? on : off; - $config['installedpackages']['snortglobal']['associatealertip'] = $_POST['associatealertip'] ? on : off; - $config['installedpackages']['snortglobal']['snortalertlogtype'] = $_POST['snortalertlogtype']; - - write_config(); - sleep(2); - - $retval = 0; - - /* set the snort block hosts time IMPORTANT */ - $snort_rm_blocked_info_ck = $config['installedpackages']['snortglobal']['rm_blocked']; - if ($snort_rm_blocked_info_ck == "never_b") - $snort_rm_blocked_false = ""; - else - $snort_rm_blocked_false = "true"; - - if ($snort_rm_blocked_info_ck != "") - { - snort_rm_blocked_install_cron(""); - snort_rm_blocked_install_cron($snort_rm_blocked_false); - } - - /* set the snort rules update time */ - $snort_rules_up_info_ck = $config['installedpackages']['snortglobal']['autorulesupdate7']; - if ($snort_rules_up_info_ck == "never_up") - $snort_rules_up_false = ""; - else - $snort_rules_up_false = "true"; - - if ($snort_rules_up_info_ck != "") - { - snort_rules_up_install_cron(""); - snort_rules_up_install_cron($snort_rules_up_false); - } - - - - $savemsg = get_std_save_message($retval); - - } - - sync_snort_package_all(); - sync_snort_package(); - -} - - - if ($_POST["Reset"]) { - -//////>>>>>>>>> - - function snort_deinstall_settings() -{ - - global $config, $g, $id, $if_real; - conf_mount_rw(); - - - exec("/usr/usr/bin/killall snort"); - sleep(2); - exec("/usr/usr/bin/killall -9 snort"); - sleep(2); - exec("/usr/usr/bin/killall barnyard2"); - sleep(2); - exec("/usr/usr/bin/killall -9 barnyard2"); - sleep(2); - - /* Remove snort cron entries Ugly code needs smoothness*/ -function snort_rm_blocked_deinstall_cron($should_install) -{ - global $config, $g; - conf_mount_rw(); - - $is_installed = false; - - if(!$config['cron']['item']) - return; - - $x=0; - foreach($config['cron']['item'] as $item) - { - if (strstr($item['command'], "snort2c")) - { - $is_installed = true; - break; - } - - $x++; - - } - if($is_installed == true) - { - if($x > 0) - { - unset($config['cron']['item'][$x]); - write_config(); - conf_mount_rw(); - } - - configure_cron(); - - } - conf_mount_ro(); - -} - - function snort_rules_up_deinstall_cron($should_install) -{ - global $config, $g; - conf_mount_rw(); - - $is_installed = false; - - if(!$config['cron']['item']) - return; - - $x=0; - foreach($config['cron']['item'] as $item) { - if (strstr($item['command'], "snort_check_for_rule_updates.php")) { - $is_installed = true; - break; - } - $x++; - } - if($is_installed == true) { - if($x > 0) { - unset($config['cron']['item'][$x]); - write_config(); - conf_mount_rw(); - } - configure_cron(); - } -} - -snort_rm_blocked_deinstall_cron(""); -snort_rules_up_deinstall_cron(""); - - - /* Unset snort registers in conf.xml IMPORTANT snort will not start with out this */ - /* Keep this as a last step */ - unset($config['installedpackages']['snortglobal']); - write_config(); - conf_mount_rw(); - - /* remove all snort iface dir */ - exec('rm -r /usr/local/etc/snort/snort_*'); - exec('rm /var/log/snort/*'); - - conf_mount_ro(); - -} - - snort_deinstall_settings(); - - 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' ); - header( 'Cache-Control: post-check=0, pre-check=0', false ); - header( 'Pragma: no-cache' ); - sleep(2); - header("Location: /snort/snort_interfaces_global.php"); - - exit; - -//////>>>>>>>>> - } -} - -include("head.inc"); -?> - -

    - - - - -
    - - - - - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Install Snort.org rules - - - - - - - - - - - - - - -
    > - Do NOT install
    > - Premium rules HIGHLY RECOMMENDED
    > - Basic Rules
      
    - - - - - - - -
    Oinkmaster code
    Code
    - Obtain a snort.org Oinkmaster code and paste here.
    -
    Install Emergingthreats rules - onClick="enable_change(false)">
    - Emerging Threats is an open source community that produces fastest moving and diverse Snort Rules.
    Remove blocked hosts every -
    - Please select the amount of time you would like hosts to be blocked for.
    - Hint: in most cases, 1 hour is a good choice.
    Update rules automatically -
    - Please select the update times for rules.
    - Hint: in most cases, every 12 hours is a good choice.
    Whitelist VPNs automatically - onClick="enable_change(false)">
    - Checking this option will install whitelists for all VPNs.
    Alerts file description type -
    - Please choose the type of Alert logging you will like see in your alert file.
    - Hint: Best pratice is to chose full logging.
     WARNING: On change, alert file will be cleared.
     WARNING:
    - This will reset all global and interface settings.
    -
    - -
     Note:
    - 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.
    -
    -
    - - - - diff --git a/config/snort-dev/snort_preprocessors.php b/config/snort-dev/snort_preprocessors.php deleted file mode 100644 index c522a643..00000000 --- a/config/snort-dev/snort_preprocessors.php +++ /dev/null @@ -1,438 +0,0 @@ -. - Copyright (C) 2008-2009 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"); -require_once("/usr/local/pkg/snort/snort_gui.inc"); - -if (!is_array($config['installedpackages']['snortglobal']['rule'])) { - $config['installedpackages']['snortglobal']['rule'] = array(); -} -//nat_rules_sort(); -$a_nat = &$config['installedpackages']['snortglobal']['rule']; - -$id = $_GET['id']; -if (isset($_POST['id'])) - $id = $_POST['id']; - -if (isset($_GET['dup'])) { - $id = $_GET['dup']; - $after = $_GET['dup']; -} - -if (isset($id) && $a_nat[$id]) { - - /* new options */ - $pconfig['def_ssl_ports_ignore'] = $a_nat[$id]['def_ssl_ports_ignore']; - $pconfig['flow_depth'] = $a_nat[$id]['flow_depth']; - $pconfig['perform_stat'] = $a_nat[$id]['perform_stat']; - $pconfig['http_inspect'] = $a_nat[$id]['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['dce_rpc_2'] = $a_nat[$id]['dce_rpc_2']; - $pconfig['dns_preprocessor'] = $a_nat[$id]['dns_preprocessor']; - - /* old options */ - $pconfig['def_dns_servers'] = $a_nat[$id]['def_dns_servers']; - $pconfig['def_dns_ports'] = $a_nat[$id]['def_dns_ports']; - $pconfig['def_smtp_servers'] = $a_nat[$id]['def_smtp_servers']; - $pconfig['def_smtp_ports'] = $a_nat[$id]['def_smtp_ports']; - $pconfig['def_mail_ports'] = $a_nat[$id]['def_mail_ports']; - $pconfig['def_http_servers'] = $a_nat[$id]['def_http_servers']; - $pconfig['def_www_servers'] = $a_nat[$id]['def_www_servers']; - $pconfig['def_http_ports'] = $a_nat[$id]['def_http_ports']; - $pconfig['def_sql_servers'] = $a_nat[$id]['def_sql_servers']; - $pconfig['def_oracle_ports'] = $a_nat[$id]['def_oracle_ports']; - $pconfig['def_mssql_ports'] = $a_nat[$id]['def_mssql_ports']; - $pconfig['def_telnet_servers'] = $a_nat[$id]['def_telnet_servers']; - $pconfig['def_telnet_ports'] = $a_nat[$id]['def_telnet_ports']; - $pconfig['def_snmp_servers'] = $a_nat[$id]['def_snmp_servers']; - $pconfig['def_snmp_ports'] = $a_nat[$id]['def_snmp_ports']; - $pconfig['def_ftp_servers'] = $a_nat[$id]['def_ftp_servers']; - $pconfig['def_ftp_ports'] = $a_nat[$id]['def_ftp_ports']; - $pconfig['def_ssh_servers'] = $a_nat[$id]['def_ssh_servers']; - $pconfig['def_ssh_ports'] = $a_nat[$id]['def_ssh_ports']; - $pconfig['def_pop_servers'] = $a_nat[$id]['def_pop_servers']; - $pconfig['def_pop2_ports'] = $a_nat[$id]['def_pop2_ports']; - $pconfig['def_pop3_ports'] = $a_nat[$id]['def_pop3_ports']; - $pconfig['def_imap_servers'] = $a_nat[$id]['def_imap_servers']; - $pconfig['def_imap_ports'] = $a_nat[$id]['def_imap_ports']; - $pconfig['def_sip_proxy_ip'] = $a_nat[$id]['def_sip_proxy_ip']; - $pconfig['def_sip_proxy_ports'] = $a_nat[$id]['def_sip_proxy_ports']; - $pconfig['def_auth_ports'] = $a_nat[$id]['def_auth_ports']; - $pconfig['def_finger_ports'] = $a_nat[$id]['def_finger_ports']; - $pconfig['def_irc_ports'] = $a_nat[$id]['def_irc_ports']; - $pconfig['def_nntp_ports'] = $a_nat[$id]['def_nntp_ports']; - $pconfig['def_rlogin_ports'] = $a_nat[$id]['def_rlogin_ports']; - $pconfig['def_rsh_ports'] = $a_nat[$id]['def_rsh_ports']; - $pconfig['def_ssl_ports'] = $a_nat[$id]['def_ssl_ports']; - $pconfig['barnyard_enable'] = $a_nat[$id]['barnyard_enable']; - $pconfig['barnyard_mysql'] = $a_nat[$id]['barnyard_mysql']; - $pconfig['enable'] = $a_nat[$id]['enable']; - $pconfig['uuid'] = $a_nat[$id]['uuid']; - $pconfig['interface'] = $a_nat[$id]['interface']; - $pconfig['descr'] = $a_nat[$id]['descr']; - $pconfig['performance'] = $a_nat[$id]['performance']; - $pconfig['blockoffenders7'] = $a_nat[$id]['blockoffenders7']; - $pconfig['alertsystemlog'] = $a_nat[$id]['alertsystemlog']; - $pconfig['tcpdumplog'] = $a_nat[$id]['tcpdumplog']; - $pconfig['snortunifiedlog'] = $a_nat[$id]['snortunifiedlog']; - $pconfig['flow_depth'] = $a_nat[$id]['flow_depth']; - $pconfig['rulesets'] = $a_nat[$id]['rulesets']; - $pconfig['rule_sid_off'] = $a_nat[$id]['rule_sid_off']; - $pconfig['rule_sid_on'] = $a_nat[$id]['rule_sid_on']; - -if (isset($_GET['dup'])) - unset($id); -} - -/* convert fake interfaces to real */ -$if_real = convert_friendly_interface_to_real_interface_name($pconfig['interface']); - - - - /* alert file */ -$d_snortconfdirty_path = "/var/run/snort_conf_{$pconfig['uuid']}_{$if_real}.dirty"; - - /* this will exec when alert says apply */ - if ($_POST['apply']) { - - if (file_exists($d_snortconfdirty_path)) { - - write_config(); - - sync_snort_package_all(); - sync_snort_package(); - - unlink($d_snortconfdirty_path); - - } - - } - - - if ($_POST["Submit"]) { - - /* check for overlaps */ - -/* if no errors write to conf */ - if (!$input_errors) { - $natent = array(); - /* repost the options already in conf */ - if ($pconfig['interface'] != "") { $natent['interface'] = $pconfig['interface']; } - if ($pconfig['enable'] != "") { $natent['enable'] = $pconfig['enable']; } - if ($pconfig['uuid'] != "") { $natent['uuid'] = $pconfig['uuid']; } - if ($pconfig['descr'] != "") { $natent['descr'] = $pconfig['descr']; } - if ($pconfig['performance'] != "") { $natent['performance'] = $pconfig['performance']; } - if ($pconfig['blockoffenders7'] != "") { $natent['blockoffenders7'] = $pconfig['blockoffenders7']; } - if ($pconfig['alertsystemlog'] != "") { $natent['alertsystemlog'] = $pconfig['alertsystemlog']; } - if ($pconfig['tcpdumplog'] != "") { $natent['tcpdumplog'] = $pconfig['tcpdumplog']; } - if ($pconfig['snortunifiedlog'] != "") { $natent['snortunifiedlog'] = $pconfig['snortunifiedlog']; } - if ($pconfig['barnyard_enable'] != "") { $natent['barnyard_enable'] = $pconfig['barnyard_enable']; } - if ($pconfig['barnyard_mysql'] != "") { $natent['barnyard_mysql'] = $pconfig['barnyard_mysql']; } - if ($pconfig['def_dns_servers'] != "") { $natent['def_dns_servers'] = $pconfig['def_dns_servers']; } - if ($pconfig['def_dns_ports'] != "") { $natent['def_dns_ports'] = $pconfig['def_dns_ports']; } - if ($pconfig['def_smtp_servers'] != "") { $natent['def_smtp_servers'] = $pconfig['def_smtp_servers']; } - if ($pconfig['def_smtp_ports'] != "") { $natent['def_smtp_ports'] = $pconfig['def_smtp_ports']; } - if ($pconfig['def_mail_ports'] != "") { $natent['def_mail_ports'] = $pconfig['def_mail_ports']; } - if ($pconfig['def_http_servers'] != "") { $natent['def_http_servers'] = $pconfig['def_http_servers']; } - if ($pconfig['def_www_servers'] != "") { $natent['def_www_servers'] = $pconfig['def_www_servers']; } - if ($pconfig['def_http_ports'] != "") { $natent['def_http_ports'] = $pconfig['def_http_ports']; } - if ($pconfig['def_sql_servers'] != "") { $natent['def_sql_servers'] = $pconfig['def_sql_servers']; } - if ($pconfig['def_oracle_ports'] != "") { $natent['def_oracle_ports'] = $pconfig['def_oracle_ports']; } - if ($pconfig['def_mssql_ports'] != "") { $natent['def_mssql_ports'] = $pconfig['def_mssql_ports']; } - if ($pconfig['def_telnet_servers'] != "") { $natent['def_telnet_servers'] = $pconfig['def_telnet_servers']; } - if ($pconfig['def_telnet_ports'] != "") { $natent['def_telnet_ports'] = $pconfig['def_telnet_ports']; } - if ($pconfig['def_snmp_servers'] != "") { $natent['def_snmp_servers'] = $pconfig['def_snmp_servers']; } - if ($pconfig['def_snmp_ports'] != "") { $natent['def_snmp_ports'] = $pconfig['def_snmp_ports']; } - if ($pconfig['def_ftp_servers'] != "") { $natent['def_ftp_servers'] = $pconfig['def_ftp_servers']; } - if ($pconfig['def_ftp_ports'] != "") { $natent['def_ftp_ports'] = $pconfig['def_ftp_ports']; } - if ($pconfig['def_ssh_servers'] != "") { $natent['def_ssh_servers'] = $pconfig['def_ssh_servers']; } - if ($pconfig['def_ssh_ports'] != "") { $natent['def_ssh_ports'] = $pconfig['def_ssh_ports']; } - if ($pconfig['def_pop_servers'] != "") { $natent['def_pop_servers'] = $pconfig['def_pop_servers']; } - if ($pconfig['def_pop2_ports'] != "") { $natent['def_pop2_ports'] = $pconfig['def_pop2_ports']; } - if ($pconfig['def_pop3_ports'] != "") { $natent['def_pop3_ports'] = $pconfig['def_pop3_ports']; } - if ($pconfig['def_imap_servers'] != "") { $natent['def_imap_servers'] = $pconfig['def_imap_servers']; } - if ($pconfig['def_imap_ports'] != "") { $natent['def_imap_ports'] = $pconfig['def_imap_ports']; } - if ($pconfig['def_sip_proxy_ip'] != "") { $natent['def_sip_proxy_ip'] = $pconfig['def_sip_proxy_ip']; } - if ($pconfig['def_sip_proxy_ports'] != "") { $natent['def_sip_proxy_ports'] = $pconfig['def_sip_proxy_ports']; } - if ($pconfig['def_auth_ports'] != "") { $natent['def_auth_ports'] = $pconfig['def_auth_ports']; } - if ($pconfig['def_finger_ports'] != "") { $natent['def_finger_ports'] = $pconfig['def_finger_ports']; } - if ($pconfig['def_irc_ports'] != "") { $natent['def_irc_ports'] = $pconfig['def_irc_ports']; } - if ($pconfig['def_nntp_ports'] != "") { $natent['def_nntp_ports'] = $pconfig['def_nntp_ports']; } - if ($pconfig['def_rlogin_ports'] != "") { $natent['def_rlogin_ports'] = $pconfig['def_rlogin_ports']; } - if ($pconfig['def_rsh_ports'] != "") { $natent['def_rsh_ports'] = $pconfig['def_rsh_ports']; } - if ($pconfig['def_ssl_ports'] != "") { $natent['def_ssl_ports'] = $pconfig['def_ssl_ports']; } - if ($pconfig['rulesets'] != "") { $natent['rulesets'] = $pconfig['rulesets']; } - if ($pconfig['rule_sid_off'] != "") { $natent['rule_sid_off'] = $pconfig['rule_sid_off']; } - if ($pconfig['rule_sid_on'] != "") { $natent['rule_sid_on'] = $pconfig['rule_sid_on']; } - - /* post new options */ - $natent['perform_stat'] = $_POST['perform_stat']; - if ($_POST['def_ssl_ports_ignore'] != "") { $natent['def_ssl_ports_ignore'] = $_POST['def_ssl_ports_ignore']; }else{ $natent['def_ssl_ports_ignore'] = ""; } - if ($_POST['flow_depth'] != "") { $natent['flow_depth'] = $_POST['flow_depth']; }else{ $natent['flow_depth'] = ""; } - $natent['perform_stat'] = $_POST['perform_stat'] ? on : off; - $natent['http_inspect'] = $_POST['http_inspect'] ? on : off; - $natent['other_preprocs'] = $_POST['other_preprocs'] ? on : off; - $natent['ftp_preprocessor'] = $_POST['ftp_preprocessor'] ? on : off; - $natent['smtp_preprocessor'] = $_POST['smtp_preprocessor'] ? on : off; - $natent['sf_portscan'] = $_POST['sf_portscan'] ? on : off; - $natent['dce_rpc_2'] = $_POST['dce_rpc_2'] ? on : off; - $natent['dns_preprocessor'] = $_POST['dns_preprocessor'] ? on : off; - - if (isset($id) && $a_nat[$id]) - $a_nat[$id] = $natent; - else { - if (is_numeric($after)) - array_splice($a_nat, $after+1, 0, array($natent)); - else - $a_nat[] = $natent; - } - - write_config(); - - /* after click go to this page */ - touch($d_snortconfdirty_path); - 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' ); - header( 'Cache-Control: post-check=0, pre-check=0', false ); - header( 'Pragma: no-cache' ); - sleep(2); - header("Location: snort_preprocessors.php?id=$id"); - exit; - } -} - -$pgtitle = "Snort: Interface $id$if_real Preprocessors and Flow"; -include("head.inc"); - -?> - - -

    - - - - -
    - -'; - - if($savemsg) { - print_info_box_np2("{$savemsg}"); - }else{ - print_info_box_np2(' - The Snort configuration has changed and snort needs to be restarted on this interface.
    - You must apply the changes in order for them to take effect.
    - '); - } - } - -?> - - - - - -
    - -
    - - - .noid { - position:absolute; - top:10px; - left:0px; - width:94%; - background:#FCE9C0; - background-position: 15px; - border-top:2px solid #DBAC48; - border-bottom:2px solid #DBAC48; - padding: 15px 10px 85% 50px; - } - -
    You can not edit options without an interface ID.
    \n"; - - } - ?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     Note:
    - Rules may be dependent on preprocessors!
    - Please save your settings before you click start.
    -
    Enable
    Performance Statistics
    - onClick="enable_change(false)">
    - Performance Statistics for this interface.
    Enable
    HTTP Inspect
    - onClick="enable_change(false)">
    - Normalize/Decode and detect HTTP traffic and protocol anomalies.
    HTTP server flow depth - - - - -
    -1 to 1460 (-1 disables HTTP inspect, 0 enables all HTTP inspect)
    - Amount of HTTP server response payload to inspect. Snort's performance may increase by adjusting this value.
    - Setting this value too low may cause false negatives. Values above 0 are specified in bytes.
    - Default value is 0
    Enable
    RPC Decode and Back Orifice detector
    - onClick="enable_change(false)">
    - Normalize/Decode RPC traffic and detects Back Orifice traffic on the network.
    Enable
    FTP and Telnet Normalizer
    - onClick="enable_change(false)">
    - Normalize/Decode FTP and Telnet traffic and protocol anomalies.
    Enable
    SMTP Normalizer
    - onClick="enable_change(false)">
    - Normalize/Decode SMTP protocol for enforcement and buffer overflows.
    Enable
    Portscan Detection
    - onClick="enable_change(false)">
    - Detects various types of portscans and portsweeps.
    Enable
    DCE/RPC2 Detection
    - onClick="enable_change(false)">
    - The DCE/RPC preprocessor detects and decodes SMB and DCE/RPC traffic.
    Enable
    DNS Detection
    - onClick="enable_change(false)">
    - The DNS preprocessor decodes DNS Response traffic and detects some vulnerabilities.
    Define SSL_IGNORE - -
    Encrypted traffic should be ignored by Snort for both performance reasons and to reduce false positives.
    - Default: "443 465 563 636 989 990 992 993 994 995".
    Please use spaces and not commas.
      - - - - -
     Note: -
    - Please save your settings before you click Start.
    -
    -
    - - - - - diff --git a/config/snort-dev/snort_rules.php b/config/snort-dev/snort_rules.php deleted file mode 100644 index c95d76ca..00000000 --- a/config/snort-dev/snort_rules.php +++ /dev/null @@ -1,687 +0,0 @@ -"; - -echo "\n -\n -\n - \n - \n - \n - \n - \n - \n -
    \n"; - - $tab_array = array(); - $tab_array[] = array("Snort Interfaces", false, "/snort/snort_interfaces.php"); - $tab_array[] = array("If Settings", false, "/snort/snort_interfaces_edit.php?id={$id}"); - $tab_array[] = array("Categories", false, "/snort/snort_rulesets.php?id={$id}"); - $tab_array[] = array("Rules", true, "/snort/snort_rules.php?id={$id}"); - $tab_array[] = array("Servers", false, "/snort/snort_define_servers.php?id={$id}"); - $tab_array[] = array("Preprocessors", false, "/snort/snort_preprocessors.php?id={$id}"); - $tab_array[] = array("Barnyard2", false, "/snort/snort_barnyard.php?id={$id}"); - display_top_tabs($tab_array); - -echo "
    \n -
    \n - \n - \n - \n - \n -
    \n -# The rules directory is empty.\n -
    \n -
    \n -
    \n -\n -\n -\n -

    \n\n"; - -echo "Please click on the Update Rules tab to install your selected rule sets."; -include("fend.inc"); - -echo ""; -echo ""; - -exit(0); - -} - -function get_middle($source, $beginning, $ending, $init_pos) { - $beginning_pos = strpos($source, $beginning, $init_pos); - $middle_pos = $beginning_pos + strlen($beginning); - $ending_pos = strpos($source, $ending, $beginning_pos); - $middle = substr($source, $middle_pos, $ending_pos - $middle_pos); - return $middle; -} - -function write_rule_file($content_changed, $received_file) -{ - //read snort file with writing enabled - $filehandle = fopen($received_file, "w"); - - //delimiter for each new rule is a new line - $delimiter = "\n"; - - //implode the array back into a string for writing purposes - $fullfile = implode($delimiter, $content_changed); - - //write data to file - fwrite($filehandle, $fullfile); - - //close file handle - fclose($filehandle); - -} - -function load_rule_file($incoming_file) -{ - - //read snort file - $filehandle = fopen($incoming_file, "r"); - - //read file into string, and get filesize - $contents = fread($filehandle, filesize($incoming_file)); - - //close handler - fclose ($filehandle); - - - //string for populating category select - $currentruleset = basename($rulefile); - - //delimiter for each new rule is a new line - $delimiter = "\n"; - - //split the contents of the string file into an array using the delimiter - $splitcontents = explode($delimiter, $contents); - - return $splitcontents; - -} - -$ruledir = "/usr/local/etc/snort/snort_{$iface_uuid}_{$if_real}/rules/"; -$dh = opendir($ruledir); - -if ($_GET['openruleset'] != '' && $_GET['ids'] != '') -{ - header("Location: /snort/snort_rules.php?id=$id&openruleset={$_GET['openruleset']}&saved=yes"); -} - -while (false !== ($filename = readdir($dh))) -{ - //only populate this array if its a rule file - $isrulefile = strstr($filename, ".rules"); - if ($isrulefile !== false) - { - $files[] = $filename; - } -} - -sort($files); - -if ($_GET['openruleset']) -{ - $rulefile = $_GET['openruleset']; -} -else -{ - $rulefile = $ruledir.$files[0]; - -} - -//Load the rule file -$splitcontents = load_rule_file($rulefile); - -if ($_POST) -{ - - conf_mount_rw(); - - if (!$_POST['apply']) { - //retrieve POST data - $post_lineid = $_POST['lineid']; - $post_enabled = $_POST['enabled']; - $post_src = $_POST['src']; - $post_srcport = $_POST['srcport']; - $post_dest = $_POST['dest']; - $post_destport = $_POST['destport']; - - //clean up any white spaces insert by accident - $post_src = str_replace(" ", "", $post_src); - $post_srcport = str_replace(" ", "", $post_srcport); - $post_dest = str_replace(" ", "", $post_dest); - $post_destport = str_replace(" ", "", $post_destport); - - //copy rule contents from array into string - $tempstring = $splitcontents[$post_lineid]; - - //search string - $findme = "# alert"; //find string for disabled alerts - - //find if alert is disabled - $disabled = strstr($tempstring, $findme); - - //if find alert is false, then rule is disabled - if ($disabled !== false) - { - //has rule been enabled - if ($post_enabled == "yes") - { - //move counter up 1, so we do not retrieve the # in the rule_content array - $tempstring = str_replace("# alert", "alert", $tempstring); - $counter2 = 1; - } - else - { - //rule is staying disabled - $counter2 = 2; - } - } - else - { - //has rule been disabled - if ($post_enabled != "yes") - { - //move counter up 1, so we do not retrieve the # in the rule_content array - $tempstring = str_replace("alert", "# alert", $tempstring); - $counter2 = 2; - } - else - { - //rule is staying enabled - $counter2 = 1; - } - } - - //explode rule contents into an array, (delimiter is space) - $rule_content = explode(' ', $tempstring); - - //insert new values - $counter2++; - $rule_content[$counter2] = $post_src;//source location - $counter2++; - $rule_content[$counter2] = $post_srcport;//source port location - $counter2 = $counter2+2; - $rule_content[$counter2] = $post_dest;//destination location - $counter2++; - $rule_content[$counter2] = $post_destport;//destination port location - - //implode the array back into string - $tempstring = implode(' ', $rule_content); - - //copy string into file array for writing - $splitcontents[$post_lineid] = $tempstring; - - //write the new .rules file - write_rule_file($splitcontents, $rulefile); - - //once file has been written, reload file - $splitcontents = load_rule_file($rulefile); - - $stopMsg = true; - } -} -else if ($_GET['act'] == "toggle") -{ - - conf_mount_rw(); - - $toggleid = $_GET['ids']; - - //copy rule contents from array into string - $tempstring = $splitcontents[$toggleid]; - - //explode rule contents into an array, (delimiter is space) - $rule_content = explode(' ', $tempstring); - - //search string - $findme = "# alert"; //find string for disabled alerts - - //find if alert is disabled - $disabled = strstr($tempstring, $findme); - - //if find alert is false, then rule is disabled - if ($disabled !== false) - { - //rule has been enabled - //move counter up 1, so we do not retrieve the # in the rule_content array - $tempstring = str_replace("# alert", "alert", $tempstring); - - } - else - { - //has rule been disabled - //move counter up 1, so we do not retrieve the # in the rule_content array - $tempstring = str_replace("alert", "# alert", $tempstring); - - } - - //copy string into array for writing - $splitcontents[$toggleid] = $tempstring; - - //write the new .rules file - write_rule_file($splitcontents, $rulefile); - - //once file has been written, reload file - $splitcontents = load_rule_file($rulefile); - - $stopMsg = true; - - //write disable/enable sid to config.xml - if ($disabled == false) { - $string_sid = strstr($tempstring, 'sid:'); - $sid_pieces = explode(";", $string_sid); - $sid_off_cut = $sid_pieces[0]; - // sid being turned off - $sid_off = str_replace("sid:", "", $sid_off_cut); - // rule_sid_on registers - $sid_on_pieces = $a_nat[$id]['rule_sid_on']; - // if off sid is the same as on sid remove it - $sid_on_old = str_replace("||enablesid $sid_off", "", "$sid_on_pieces"); - // write the replace sid back as empty - $a_nat[$id]['rule_sid_on'] = $sid_on_old; - // rule sid off registers - $sid_off_pieces = $a_nat[$id]['rule_sid_off']; - // if off sid is the same as off sid remove it - $sid_off_old = str_replace("||disablesid $sid_off", "", "$sid_off_pieces"); - // write the replace sid back as empty - $a_nat[$id]['rule_sid_off'] = $sid_off_old; - // add sid off registers to new off sid - $a_nat[$id]['rule_sid_off'] = "||disablesid $sid_off" . $a_nat[$id]['rule_sid_off']; - write_config(); - conf_mount_rw(); - - } - else - { - $string_sid = strstr($tempstring, 'sid:'); - $sid_pieces = explode(";", $string_sid); - $sid_on_cut = $sid_pieces[0]; - // sid being turned off - $sid_on = str_replace("sid:", "", $sid_on_cut); - // rule_sid_off registers - $sid_off_pieces = $a_nat[$id]['rule_sid_off']; - // if off sid is the same as on sid remove it - $sid_off_old = str_replace("||disablesid $sid_on", "", "$sid_off_pieces"); - // write the replace sid back as empty - $a_nat[$id]['rule_sid_off'] = $sid_off_old; - // rule sid on registers - $sid_on_pieces = $a_nat[$id]['rule_sid_on']; - // if on sid is the same as on sid remove it - $sid_on_old = str_replace("||enablesid $sid_on", "", "$sid_on_pieces"); - // write the replace sid back as empty - $a_nat[$id]['rule_sid_on'] = $sid_on_old; - // add sid on registers to new on sid - $a_nat[$id]['rule_sid_on'] = "||enablesid $sid_on" . $a_nat[$id]['rule_sid_on']; - write_config(); - conf_mount_rw(); - } - -} - -if ($_GET['saved'] == 'yes') -{ - $message = "The Snort rule configuration has been changed.
    You must restart this snort interface in order for the changes to take effect."; - -// stop_service("snort"); -// sleep(2); -// start_service("snort"); -// $savemsg = ""; -// $stopMsg = false; -} - -$currentruleset = basename($rulefile); - -$ifname = strtoupper($pconfig['interface']); - -require("guiconfig.inc"); -include("head.inc"); - -$pgtitle = "Snort: $id $iface_uuid $if_real Category: $currentruleset"; - -?> - - - -

    - -"; -?> - - - - - - - - - - - - - - - -
    - -
    -
    - - - - -
    - - - - - - - - - - - - - - Category: "; - - //string for populating category select - $currentruleset = basename($rulefile); - - ?> - - - - - "; - $textse = ""; - $iconb = "icon_block_d.gif"; - } - else - { - $textss = $textse = ""; - $iconb = "icon_block.gif"; - } - - if ($disabled_pos !== false){ - $ischecked = ""; - }else{ - $ischecked = "checked"; - } - - $rule_content = explode(' ', $tempstring); - - $protocol = $rule_content[$counter2];//protocol location - $counter2++; - $source = $rule_content[$counter2];//source location - $counter2++; - $source_port = $rule_content[$counter2];//source port location - $counter2 = $counter2+2; - $destination = $rule_content[$counter2];//destination location - $counter2++; - $destination_port = $rule_content[$counter2];//destination port location - - if (strstr($tempstring, 'msg: "')) - $message = get_middle($tempstring, 'msg: "', '";', 0); - if (strstr($tempstring, 'msg:"')) - $message = get_middle($tempstring, 'msg:"', '";', 0); - - echo " - - - - - "; - ?> - -
    "; - ?> -
     SIDProtoSourcePortDestinationPortMessage
    - $textss\n"; - ?> - - - - - - $textss - $sid - $textse - - $textss - $protocol"; - ?> - - - $textss - $source - $textse - - $textss - $source_port - $textse - - $textss - $destination - $textse - - $textss - $destination_port - $textse - - "; - ?> - - - - - - -
    -
    -
    - - - - - - - - -
    Rule Enabled
    Rule Disabled
    - - - - -
    -
    -

    - -

    -
    -
    - - -
    - diff --git a/config/snort-dev/snort_rules_edit.php b/config/snort-dev/snort_rules_edit.php deleted file mode 100644 index b770867f..00000000 --- a/config/snort-dev/snort_rules_edit.php +++ /dev/null @@ -1,243 +0,0 @@ -#!/usr/local/bin/php - "") { - if($_POST['highlight'] == "yes" or - $_POST['highlight'] == "enabled") { - $highlight = "yes"; - } else { - $highlight = "no"; - } -} else { - $highlight = "no"; -} - -if($_POST['rows'] <> "") - $rows = $_POST['rows']; -else - $rows = 1; - -if($_POST['cols'] <> "") - $cols = $_POST['cols']; -else - $cols = 66; - -if ($_POST) -{ - if ($_POST['save']) { - - /* get the changes */ - $rule_content2 = $_POST['code']; - - //copy string into file array for writing - $splitcontents[$lineid] = $rule_content2; - - //write the new .rules file - write_rule_file($splitcontents, $file); - - header("Location: /snort/snort_rules_edit.php?id=$id&openruleset=$file&ids=$ids"); - - } -} - -$pgtitle = array(gettext("Advanced"), gettext("File Editor")); - -// -?> - - - - - - - - -
    -
    - - - - - -
    - -
    - : - /> - - /> - -
    - - - - -
    -
    - - -
    -
    - - - - -
    -
    - - -
    -
    - -
    -
    - - - - - - - - - - - - - - - - - diff --git a/config/snort-dev/snort_rulesets.php b/config/snort-dev/snort_rulesets.php deleted file mode 100644 index ece409e1..00000000 --- a/config/snort-dev/snort_rulesets.php +++ /dev/null @@ -1,307 +0,0 @@ -"; -if($pfsense_stable == 'yes'){echo $pgtitle;} -echo "

    \n"; - -echo ""; - -echo " -\n - \n - \n - \n - \n - \n - \n -
    \n"; - - $tab_array = array(); - $tab_array[] = array("Snort Interfaces", false, "/snort/snort_interfaces.php"); - $tab_array[] = array("If Settings", false, "/snort/snort_interfaces_edit.php?id={$id}"); - $tab_array[] = array("Categories", true, "/snort/snort_rulesets.php?id={$id}"); - $tab_array[] = array("Rules", false, "/snort/snort_rules.php?id={$id}"); - $tab_array[] = array("Servers", false, "/snort/snort_define_servers.php?id={$id}"); - $tab_array[] = array("Preprocessors", false, "/snort/snort_preprocessors.php?id={$id}"); - $tab_array[] = array("Barnyard2", false, "/snort/snort_barnyard.php?id={$id}"); - display_top_tabs($tab_array); - -echo "
    \n -
    \n - \n - \n - \n - \n -
    \n -# The rules directory is empty. /usr/local/etc/snort/snort_{$iface_uuid}_{$if_real}/rules \n -
    \n -
    \n -
    \n -\n -\n -\n -

    \n\n"; - -echo "Please click on the Update Rules tab to install your selected rule sets. $isrulesfolderempty"; -include("fend.inc"); - -echo ""; -echo ""; - -exit(0); - -} - - /* alert file */ -$d_snortconfdirty_path = "/var/run/snort_conf_{$iface_uuid}_{$if_real}.dirty"; - - /* this will exec when alert says apply */ - if ($_POST['apply']) { - - if (file_exists($d_snortconfdirty_path)) { - - write_config(); - - sync_snort_package_all(); - sync_snort_package(); - - unlink($d_snortconfdirty_path); - - } - - } - - if ($_POST["Submit"]) { - $enabled_items = ""; - $isfirst = true; - if (is_array($_POST['toenable'])) { - foreach($_POST['toenable'] as $toenable) { - if(!$isfirst) - $enabled_items .= "||"; - $enabled_items .= "{$toenable}"; - $isfirst = false; - } - }else{ - $enabled_items = $_POST['toenable']; - } - $a_nat[$id]['rulesets'] = $enabled_items; - - write_config(); - - touch($d_snortconfdirty_path); - - 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' ); - header( 'Cache-Control: post-check=0, pre-check=0', false ); - header( 'Pragma: no-cache' ); - sleep(2); - sync_snort_package_all(); - header("Location: /snort/snort_rulesets.php?id=$id"); - -} - -$enabled_rulesets = $a_nat[$id]['rulesets']; -if($enabled_rulesets) - $enabled_rulesets_array = split("\|\|", $enabled_rulesets); - -include("head.inc"); - -?> - - - -

    -"; - -?> - -'; - - if($savemsg) { - print_info_box_np2("{$savemsg}"); - }else{ - print_info_box_np2(' - The Snort configuration has changed and snort needs to be restarted on this interface.
    - You must apply the changes in order for them to take effect.
    - '); - } - } - -?> - - - - - - - - -
    - -
    -
    - - - - - - - - -
    - - - - - - -"; - echo ""; - echo ""; - //echo ""; - } - -?> -
    EnabledRuleset: Rules that end with "so.rules" are shared object rules.
    "; - if(is_array($enabled_rulesets_array)) - if(in_array($file, $enabled_rulesets_array)) { - $CHECKED = " checked=\"checked\""; - } else { - $CHECKED = ""; - } - else - $CHECKED = ""; - echo " "; - echo ""; - echo "{$file}"; - echo ""; - //echo "description"; - //echo "
    -
     
    Check the rulesets that you would like Snort to load at startup.
     
    -
    -
    - - - -

    NOTE: You can click on a ruleset name to edit the ruleset. - - - - - - - diff --git a/config/snort-dev/snort_whitelist.xml b/config/snort-dev/snort_whitelist.xml deleted file mode 100644 index d98f83fa..00000000 --- a/config/snort-dev/snort_whitelist.xml +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - . - 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. - */ -/* ========================================================================== */ - ]]> - - Describe your package here - Describe your package requirements here - Currently there are no FAQ items provided. - snortglobal - 0.1.0 - Snort: Whitelist - /usr/local/pkg/snort/snort.inc - - - - Snort Interfaces - /snort/snort_interfaces.php - - - Global Settings - /snort/snort_interfaces_global.php - - - Rule Updates - /snort/snort_download_rules.php - - - Alerts - /snort/snort_alerts.php - - - Blocked - /snort/snort_blocked.php - - - Whitelist - /pkg.php?xml=/snort/snort_whitelist.xml - - - - Help Info - /snort/snort_help_info.php - - - - - Whitelisted IP - ip - - - Description - description - - - - - Whitelisted IP - ip - Enter the IP or network to whitelist from snort blocking. Network items should be expressed in CIDR notation. Example: 0.0.0.0/24 or 0.0.0.0/32 - input - 40 - - - Description - description - Enter the description for this item - input - 60 - - - - - - - - sync_snort_package_empty(); - - diff --git a/config/snort-old/bin/barnyard2 b/config/snort-old/bin/barnyard2 new file mode 100644 index 00000000..b942e87f Binary files /dev/null and b/config/snort-old/bin/barnyard2 differ diff --git a/config/snort-old/bin/oinkmaster_contrib/README.contrib b/config/snort-old/bin/oinkmaster_contrib/README.contrib new file mode 100644 index 00000000..6923fa26 --- /dev/null +++ b/config/snort-old/bin/oinkmaster_contrib/README.contrib @@ -0,0 +1,84 @@ +# $Id: README.contrib,v 1.21 2005/10/18 10:41:20 andreas_o Exp $ # + +------------------------------------------------------------------------------- +* oinkgui.pl by Andreas Östling + + A graphical front-end to Oinkmaster written in Perl/Tk. + See README.gui for complete documentation. +------------------------------------------------------------------------------- + + + +------------------------------------------------------------------------------- +* addsid.pl by Andreas Östling + + A script that parses *.rules in all specified directories and adds a + SID to (active) rules that don't have any. (Actually, rev and classtype + are also added if missing, unless you edit addsid.pl and tune this.) The + script first looks for the current highest SID (even in inactive rules) + and starts at the next one, unless this value is below MIN_SID (defined + inside addsid.pl). By default, this value is set to 1000001 since this + is the lowest SID assigned for local usage. Handles multi-line rules. +------------------------------------------------------------------------------- + + + +------------------------------------------------------------------------------- +* create-sidmap.pl by Andreas Östling + + A script that parses all active rules in *.rules in all specified + directories and creates a SID map. (Like Snort's regen-sidmap, but this + one handles multi-line rules.) Result goes to standard output which can + be redirected to a sid-msg.map file. +------------------------------------------------------------------------------- + + + +------------------------------------------------------------------------------- +* makesidex.pl, originally by Jerry Applebaum but later rewritten by + Andreas Östling to handle multi-line rules and + multiple rules directories. + + It reads *.rules in all specified directories, looks for all disabled + rules and prints a "disablesid # " line for each disabled rule. + The output can be appended to oinkmaster.conf. + Useful to new Oinkmaster users. +------------------------------------------------------------------------------- + + + +------------------------------------------------------------------------------- +* addmsg.pl by Andreas Östling : + + A script that will parse your oinkmaster.conf for + localsid/enablesid/disablesid lines and add their rule message as a #comment. + If your oinkmaster.conf looks like this before addmsg.pl has been run: + + disablesid 286 + disablesid 287 + disablesid 288 + + It will look something like this afterward: + + disablesid 286 # POP3 EXPLOIT x86 bsd overflow + disablesid 287 # POP3 EXPLOIT x86 bsd overflow + disablesid 288 # POP3 EXPLOIT x86 linux overflow + + addmsg.pl will not touch lines that already has a comment in them. + It's not able to handle SID lists when written like this: + disablesid 1,2,3, ... + But it should handle them if written like this: + disablesid \ + 1, \ + 2, \ + 3 + + The new config file will be printed to standard output, so you + probably want to redirect the output to a file, for example: + + ./addmsg.pl oinkmaster.conf rules/ > oinkmaster.conf.new + + If oinkmaster.conf.new looks ok, simply rename it to oinkmaster.conf. + Do NOT redirect to the same file you read from, as this will destroy + that file. +------------------------------------------------------------------------------- diff --git a/config/snort-old/bin/oinkmaster_contrib/addmsg.pl b/config/snort-old/bin/oinkmaster_contrib/addmsg.pl new file mode 100644 index 00000000..e5866d6f --- /dev/null +++ b/config/snort-old/bin/oinkmaster_contrib/addmsg.pl @@ -0,0 +1,299 @@ +#!/usr/bin/perl -w + +# $Id: addmsg.pl,v 1.19 2005/12/31 13:42:46 andreas_o Exp $ # + +# Copyright (c) 2004-2006 Andreas Östling +# 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. +# +# 3. Neither the name of the author nor the names of its +# contributors may be used to endorse or promote products +# derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +# CONTRIBUTORS "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 COPYRIGHT OWNER OR +# CONTRIBUTORS 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. + + +use strict; + +sub get_next_entry($ $ $ $ $ $); +sub parse_singleline_rule($ $ $); + + +my $USAGE = << "RTFM"; + +Parse Oinkmaster configuration file and add the rule's "msg" string as a +#comment for each disablesid/enablesid line. + +Usage: $0 [rulesdir2, ...] + +The new config file will be printed to standard output, so you +probably want to redirect the output to a new file (*NOT* the same +file you used as input, because that will destroy the file!). +For example: + +$0 /etc/oinkmaster.conf /etc/rules/ > oinkmaster.conf.new + +If oinkmaster.conf.new looks ok, simply rename it to /etc/oinkmaster.conf. + +RTFM + + +# Regexp to match the start of a multi-line rule. +# %ACTIONS% will be replaced with content of $config{actions} later. +my $MULTILINE_RULE_REGEXP = '^\s*#*\s*(?:%ACTIONS%)'. + '\s.*\\\\\s*\n$'; # '; + +# Regexp to match a single-line rule. +my $SINGLELINE_RULE_REGEXP = '^\s*#*\s*(?:%ACTIONS%)'. + '\s.+;\s*\)\s*$'; # '; + + +my $config = shift || die($USAGE); + +my @rulesdirs = @ARGV; +die($USAGE) unless ($#rulesdirs > -1); + +my $verbose = 1; +my (%sidmsgmap, %config); + +$config{rule_actions} = "alert|drop|log|pass|reject|sdrop|activate|dynamic"; + +$SINGLELINE_RULE_REGEXP =~ s/%ACTIONS%/$config{rule_actions}/; +$MULTILINE_RULE_REGEXP =~ s/%ACTIONS%/$config{rule_actions}/; + + + +# Read in oinkmaster.conf. +open(CONFIG, "<" , "$config") or die("could not open \"$config\" for reading: $!\n"); +my @config = ; +close(CONFIG); + + +# Read in *.rules in all rulesdirs and create %sidmsgmap ($sidmsgmap{sid} = msg). +foreach my $rulesdir (@rulesdirs) { + opendir(RULESDIR, "$rulesdir") or die("could not open \"$rulesdir\": $!\n"); + + while (my $file = readdir(RULESDIR)) { + next unless ($file =~ /\.rules$/); + + open(FILE, "<", "$rulesdir/$file") or die("could not open \"$rulesdir/$file\": $!\n"); + my @file = ; + close(FILE); + + my ($single, $multi, $nonrule, $msg, $sid); + + while (get_next_entry(\@file, \$single, \$multi, \$nonrule, \$msg, \$sid)) { + $sidmsgmap{$sid} = $msg + if (defined($single)); + } + } +} + + +# Print new oinkmaster.conf. +while ($_ = shift(@config)) { + if (/^\s*(?:disable|enable|local)sid\s+(\d+)\s*$/ || /^\s*(\d+)\s*,\s*\\$/ || /^\s*(\d+)\s*$/) { + my $sid = $1; + my $is_multiline = 0; + chomp; + + if (/\\$/) { + $is_multiline = 1; + s/\\$//; + } + + $_ = sprintf("%-25s", $_); + if (exists($sidmsgmap{$sid})) { + print "$_ # $sidmsgmap{$sid}"; + } else { + print "$_"; + } + print " \\" if ($is_multiline); + print "\n"; + } else { + print; + } +} + + + +# From oinkmaster.pl. +sub get_next_entry($ $ $ $ $ $) +{ + my $arr_ref = shift; + my $single_ref = shift; + my $multi_ref = shift; + my $nonrule_ref = shift; + my $msg_ref = shift; + my $sid_ref = shift; + + undef($$single_ref); + undef($$multi_ref); + undef($$nonrule_ref); + undef($$msg_ref); + undef($$sid_ref); + + my $line = shift(@$arr_ref) || return(0); + my $disabled = 0; + my $broken = 0; + + # Possible beginning of multi-line rule? + if ($line =~ /$MULTILINE_RULE_REGEXP/oi) { + $$single_ref = $line; + $$multi_ref = $line; + + $disabled = 1 if ($line =~ /^\s*#/); + + # Keep on reading as long as line ends with "\". + while (!$broken && $line =~ /\\\s*\n$/) { + + # Remove trailing "\" and newline for single-line version. + $$single_ref =~ s/\\\s*\n//; + + # If there are no more lines, this can not be a valid multi-line rule. + if (!($line = shift(@$arr_ref))) { + + warn("\nWARNING: got EOF while parsing multi-line rule: $$multi_ref\n") + if ($config{verbose}); + + @_ = split(/\n/, $$multi_ref); + + undef($$multi_ref); + undef($$single_ref); + + # First line of broken multi-line rule will be returned as a non-rule line. + $$nonrule_ref = shift(@_) . "\n"; + $$nonrule_ref =~ s/\s*\n$/\n/; # remove trailing whitespaces + + # The rest is put back to the array again. + foreach $_ (reverse((@_))) { + unshift(@$arr_ref, "$_\n"); + } + + return (1); # return non-rule + } + + # Multi-line continuation. + $$multi_ref .= $line; + + # If there are non-comment lines in the middle of a disabled rule, + # mark the rule as broken to return as non-rule lines. + if ($line !~ /^\s*#/ && $disabled) { + $broken = 1; + } elsif ($line =~ /^\s*#/ && !$disabled) { + # comment line (with trailing slash) in the middle of an active rule - ignore it + } else { + $line =~ s/^\s*#*\s*//; # remove leading # in single-line version + $$single_ref .= $line; + } + + } # while line ends with "\" + + # Single-line version should now be a valid rule. + # If not, it wasn't a valid multi-line rule after all. + if (!$broken && parse_singleline_rule($$single_ref, $msg_ref, $sid_ref)) { + + $$single_ref =~ s/^\s*//; # remove leading whitespaces + $$single_ref =~ s/^#+\s*/#/; # remove whitespaces next to leading # + $$single_ref =~ s/\s*\n$/\n/; # remove trailing whitespaces + + $$multi_ref =~ s/^\s*//; + $$multi_ref =~ s/\s*\n$/\n/; + $$multi_ref =~ s/^#+\s*/#/; + + return (1); # return multi + } else { + warn("\nWARNING: invalid multi-line rule: $$single_ref\n") + if ($config{verbose} && $$multi_ref !~ /^\s*#/); + + @_ = split(/\n/, $$multi_ref); + + undef($$multi_ref); + undef($$single_ref); + + # First line of broken multi-line rule will be returned as a non-rule line. + $$nonrule_ref = shift(@_) . "\n"; + $$nonrule_ref =~ s/\s*\n$/\n/; # remove trailing whitespaces + + # The rest is put back to the array again. + foreach $_ (reverse((@_))) { + unshift(@$arr_ref, "$_\n"); + } + + return (1); # return non-rule + } + } elsif (parse_singleline_rule($line, $msg_ref, $sid_ref)) { + $$single_ref = $line; + $$single_ref =~ s/^\s*//; + $$single_ref =~ s/^#+\s*/#/; + $$single_ref =~ s/\s*\n$/\n/; + + return (1); # return single + } else { # non-rule line + + # Do extra check and warn if it *might* be a rule anyway, + # but that we just couldn't parse for some reason. + warn("\nWARNING: line may be a rule but it could not be parsed ". + "(missing sid or msg?): $line\n") + if ($config{verbose} && $line =~ /^\s*alert .+msg\s*:\s*".+"\s*;/); + + $$nonrule_ref = $line; + $$nonrule_ref =~ s/\s*\n$/\n/; + + return (1); # return non-rule + } +} + + + +# From oinkmaster.pl. +sub parse_singleline_rule($ $ $) +{ + my $line = shift; + my $msg_ref = shift; + my $sid_ref = shift; + + if ($line =~ /$SINGLELINE_RULE_REGEXP/oi) { + + if ($line =~ /\bmsg\s*:\s*"(.+?)"\s*;/i) { + $$msg_ref = $1; + } else { + return (0); + } + + if ($line =~ /\bsid\s*:\s*(\d+)\s*;/i) { + $$sid_ref = $1; + } else { + return (0); + } + + return (1); + } + + return (0); +} diff --git a/config/snort-old/bin/oinkmaster_contrib/addsid.pl b/config/snort-old/bin/oinkmaster_contrib/addsid.pl new file mode 100644 index 00000000..64255d22 --- /dev/null +++ b/config/snort-old/bin/oinkmaster_contrib/addsid.pl @@ -0,0 +1,382 @@ +#!/usr/bin/perl -w + +# $Id: addsid.pl,v 1.30 2005/12/31 13:42:46 andreas_o Exp $ # + +# Copyright (c) 2004-2006 Andreas Östling +# 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. +# +# 3. Neither the name of the author nor the names of its +# contributors may be used to endorse or promote products +# derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +# CONTRIBUTORS "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 COPYRIGHT OWNER OR +# CONTRIBUTORS 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. + + +use strict; + + +sub get_next_entry($ $ $ $ $ $); +sub parse_singleline_rule($ $ $); +sub get_next_available_sid(@); + + +# Set this to the default classtype you want to add, if missing. +# Set to 0 or "" if you don't want to add a classtype. +my $CLASSTYPE = "misc-attack"; + +# If ADD_REV is set to 1, "rev: 1;" will be added to rule if it has no rev. +# Set to 0 if you don't want to add it. +my $ADD_REV = 1; + +# Minimum SID to add. Normally, the next available SID will be used, +# unless it's below this value. Only SIDs >= 1000000 are reserved for +# personal use. +my $MIN_SID = 1000001; + +# Regexp to match the start of a multi-line rule. +# %ACTIONS% will be replaced with content of $config{actions} later. +my $MULTILINE_RULE_REGEXP = '^\s*#*\s*(?:%ACTIONS%)'. + '\s.*\\\\\s*\n$'; # '; + +# Regexp to match a single-line rule. +my $SINGLELINE_RULE_REGEXP = '^\s*#*\s*(?:%ACTIONS%)'. + '\s.+;\s*\)\s*$'; # '; + + +my $USAGE = << "RTFM"; + +Parse *.rules in one or more directories and add "sid:;" to +active rules that don't have any "sid" entry, starting with the next +available SID after parsing all rules files (but $MIN_SID at minumum). +Also, "rev:1;" is added to rules without a "rev" entry, and +"classtype:misc-attack;" is added to rules without a "classtype" entry +(edit options at the top of $0 if you want to change this). + +Usage: $0 [rulesdir2, ...] + +RTFM + + +# Start in verbose mode. +my $verbose = 1; + +my (%all_sids, %active_sids, %config); + +my @rulesdirs = @ARGV; + +die($USAGE) unless ($#rulesdirs > -1); + +$config{rule_actions} = "alert|drop|log|pass|reject|sdrop|activate|dynamic"; + +$SINGLELINE_RULE_REGEXP =~ s/%ACTIONS%/$config{rule_actions}/; +$MULTILINE_RULE_REGEXP =~ s/%ACTIONS%/$config{rule_actions}/; + + +# Find out the next available SID. +my $next_sid = get_next_available_sid(@rulesdirs); + +# Avoid seeing possible warnings about broken rules twice. +$verbose = 0; + +# Add sid/rev/classtype to active rules that don't have any. +foreach my $dir (@rulesdirs) { + opendir(RULESDIR, "$dir") or die("could not open \"$dir\": $!\n"); + + while (my $file = readdir(RULESDIR)) { + next unless ($file =~ /\.rules$/); + + open(OLDFILE, "$dir/$file") + or die("could not open \"$dir/$file\": $!\n"); + my @file = ; + close(OLDFILE); + + open(NEWFILE, ">", "$dir/$file") + or die("could not open \"$dir/$file\" for writing: $!\n"); + + my ($single, $multi, $nonrule, $msg, $sid); + while (get_next_entry(\@file, \$single, \$multi, \$nonrule, \$msg, \$sid)) { + + if (defined($nonrule)) { + print NEWFILE "$nonrule"; + next; + } + + $multi = $single unless (defined($multi)); + + # Don't care about inactive rules. + if ($single =~ /^\s*#/) { + print NEWFILE "$multi"; + next; + } + + my $added; + + # Add SID. + if ($single !~ /sid\s*:\s*\d+\s*;/) { + $added .= "SID $next_sid,"; + $multi =~ s/\)\s*\n/sid:$next_sid;)\n/; + $next_sid++; + } + + # Add revision. + if ($ADD_REV && $single !~ /rev\s*:\s*\d+\s*;/) { + $added .= "rev,"; + $multi =~ s/\)\s*\n/rev:1;)\n/; + } + + # Add classtype. + if ($CLASSTYPE && $single !~ /classtype\s*:\s*.+\s*;/) { + $added .= "classtype $CLASSTYPE,"; + $multi =~ s/\)\s*\n/classtype:$CLASSTYPE;)\n/; + } + + if (defined($added)) { + $added =~ s/,$//; + print "Adding $added to rule \"$msg\"\n" + if (defined($added)); + } + + print NEWFILE "$multi"; + } + + close(NEWFILE); + } + + closedir(RULESDIR); +} + + + +# Read in *.rules in given directory and return highest SID. +sub get_next_available_sid(@) +{ + my @dirs = @_; + + foreach my $dir (@dirs) { + opendir(RULESDIR, "$dir") or die("could not open \"$dir\": $!\n"); + + # Only care about *.rules. + while (my $file = readdir(RULESDIR)) { + next unless ($file =~ /\.rules$/); + + open(OLDFILE, "<$dir/$file") or die("could not open \"$dir/$file\": $!\n"); + my @file = ; + close(OLDFILE); + + my ($single, $multi, $nonrule, $msg, $sid); + + while (get_next_entry(\@file, \$single, \$multi, \$nonrule, \$msg, \$sid)) { + if (defined($single) && defined($sid)) { + $all_sids{$sid}++; + + # If this is an active rule add to %active_sids and + # warn if it already exists. + if ($single =~ /^\s*alert/) { + print STDERR "WARNING: duplicate SID: $sid\n" + if (exists($active_sids{$sid})); + $active_sids{$sid}++ + } + } + } + } + } + + # Sort sids and use highest one + 1, unless it's below MIN_SID. + @_ = sort {$a <=> $b} keys(%all_sids); + my $sid = pop(@_); + + if (!defined($sid)) { + $sid = $MIN_SID + } else { + $sid++; + } + + # If it's below MIN_SID, use MIN_SID instead. + $sid = $MIN_SID if ($sid < $MIN_SID); + + return ($sid) +} + + + +sub get_next_entry($ $ $ $ $ $) +{ + my $arr_ref = shift; + my $single_ref = shift; + my $multi_ref = shift; + my $nonrule_ref = shift; + my $msg_ref = shift; + my $sid_ref = shift; + + undef($$single_ref); + undef($$multi_ref); + undef($$nonrule_ref); + undef($$msg_ref); + undef($$sid_ref); + + my $line = shift(@$arr_ref) || return(0); + my $disabled = 0; + my $broken = 0; + + # Possible beginning of multi-line rule? + if ($line =~ /$MULTILINE_RULE_REGEXP/oi) { + $$single_ref = $line; + $$multi_ref = $line; + + $disabled = 1 if ($line =~ /^\s*#/); + + # Keep on reading as long as line ends with "\". + while (!$broken && $line =~ /\\\s*\n$/) { + + # Remove trailing "\" and newline for single-line version. + $$single_ref =~ s/\\\s*\n//; + + # If there are no more lines, this can not be a valid multi-line rule. + if (!($line = shift(@$arr_ref))) { + + warn("\nWARNING: got EOF while parsing multi-line rule: $$multi_ref\n") + if ($config{verbose}); + + @_ = split(/\n/, $$multi_ref); + + undef($$multi_ref); + undef($$single_ref); + + # First line of broken multi-line rule will be returned as a non-rule line. + $$nonrule_ref = shift(@_) . "\n"; + $$nonrule_ref =~ s/\s*\n$/\n/; # remove trailing whitespaces + + # The rest is put back to the array again. + foreach $_ (reverse((@_))) { + unshift(@$arr_ref, "$_\n"); + } + + return (1); # return non-rule + } + + # Multi-line continuation. + $$multi_ref .= $line; + + # If there are non-comment lines in the middle of a disabled rule, + # mark the rule as broken to return as non-rule lines. + if ($line !~ /^\s*#/ && $disabled) { + $broken = 1; + } elsif ($line =~ /^\s*#/ && !$disabled) { + # comment line (with trailing slash) in the middle of an active rule - ignore it + } else { + $line =~ s/^\s*#*\s*//; # remove leading # in single-line version + $$single_ref .= $line; + } + + } # while line ends with "\" + + # Single-line version should now be a valid rule. + # If not, it wasn't a valid multi-line rule after all. + if (!$broken && parse_singleline_rule($$single_ref, $msg_ref, $sid_ref)) { + + $$single_ref =~ s/^\s*//; # remove leading whitespaces + $$single_ref =~ s/^#+\s*/#/; # remove whitespaces next to leading # + $$single_ref =~ s/\s*\n$/\n/; # remove trailing whitespaces + + $$multi_ref =~ s/^\s*//; + $$multi_ref =~ s/\s*\n$/\n/; + $$multi_ref =~ s/^#+\s*/#/; + + return (1); # return multi + } else { + warn("\nWARNING: invalid multi-line rule: $$single_ref\n") + if ($config{verbose} && $$multi_ref !~ /^\s*#/); + + @_ = split(/\n/, $$multi_ref); + + undef($$multi_ref); + undef($$single_ref); + + # First line of broken multi-line rule will be returned as a non-rule line. + $$nonrule_ref = shift(@_) . "\n"; + $$nonrule_ref =~ s/\s*\n$/\n/; # remove trailing whitespaces + + # The rest is put back to the array again. + foreach $_ (reverse((@_))) { + unshift(@$arr_ref, "$_\n"); + } + + return (1); # return non-rule + } + } elsif (parse_singleline_rule($line, $msg_ref, $sid_ref)) { + $$single_ref = $line; + $$single_ref =~ s/^\s*//; + $$single_ref =~ s/^#+\s*/#/; + $$single_ref =~ s/\s*\n$/\n/; + + return (1); # return single + } else { # non-rule line + + # Do extra check and warn if it *might* be a rule anyway, + # but that we just couldn't parse for some reason. + warn("\nWARNING: line may be a rule but it could not be parsed ". + "(missing sid or msg?): $line\n") + if ($config{verbose} && $line =~ /^\s*alert .+msg\s*:\s*".+"\s*;/); + + $$nonrule_ref = $line; + $$nonrule_ref =~ s/\s*\n$/\n/; + + return (1); # return non-rule + } +} + + + +# From oinkmaster.pl except that this version +# has been modified so that the sid is *optional*. +sub parse_singleline_rule($ $ $) +{ + my $line = shift; + my $msg_ref = shift; + my $sid_ref = shift; + + if ($line =~ /$SINGLELINE_RULE_REGEXP/oi) { + + if ($line =~ /\bmsg\s*:\s*"(.+?)"\s*;/i) { + $$msg_ref = $1; + } else { + return (0); + } + + if ($line =~ /\bsid\s*:\s*(\d+)\s*;/i) { + $$sid_ref = $1; +# } else { +# return (0); + } + + return (1); + } + + return (0); +} diff --git a/config/snort-old/bin/oinkmaster_contrib/create-sidmap.pl b/config/snort-old/bin/oinkmaster_contrib/create-sidmap.pl new file mode 100644 index 00000000..26a9040c --- /dev/null +++ b/config/snort-old/bin/oinkmaster_contrib/create-sidmap.pl @@ -0,0 +1,280 @@ +#!/usr/local/bin/perl -w + +# $Id: create-sidmap.pl,v 1.21 2005/12/31 13:42:46 andreas_o Exp $ # + +# Copyright (c) 2004-2006 Andreas Östling +# 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. +# +# 3. Neither the name of the author nor the names of its +# contributors may be used to endorse or promote products +# derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +# CONTRIBUTORS "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 COPYRIGHT OWNER OR +# CONTRIBUTORS 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. + + +use strict; + +sub get_next_entry($ $ $ $ $ $); +sub parse_singleline_rule($ $ $); + +# Files to ignore. +my %skipfiles = ( + 'deleted.rules' => 1, +); + +# Regexp to match the start of a multi-line rule. +# %ACTIONS% will be replaced with content of $config{actions} later. +my $MULTILINE_RULE_REGEXP = '^\s*#*\s*(?:%ACTIONS%)'. + '\s.*\\\\\s*\n$'; # '; + +# Regexp to match a single-line rule. +my $SINGLELINE_RULE_REGEXP = '^\s*#*\s*(?:%ACTIONS%)'. + '\s.+;\s*\)\s*$'; # '; + +my $USAGE = << "RTFM"; + +Parse active rules in *.rules in one or more directories and create a SID +map. Result is sent to standard output, which can be redirected to a +sid-msg.map file. + +Usage: $0 [rulesdir2, ...] + +RTFM + +my $verbose = 1; + +my (%sidmap, %config); + +my @rulesdirs = @ARGV; + +die($USAGE) unless ($#rulesdirs > -1); + +$config{rule_actions} = "alert|drop|log|pass|reject|sdrop|activate|dynamic"; + +$SINGLELINE_RULE_REGEXP =~ s/%ACTIONS%/$config{rule_actions}/; +$MULTILINE_RULE_REGEXP =~ s/%ACTIONS%/$config{rule_actions}/; + + +# Read in all rules from each rules file (*.rules) in each rules dir. +# into %sidmap. +foreach my $rulesdir (@rulesdirs) { + opendir(RULESDIR, "$rulesdir") or die("could not open \"$rulesdir\": $!\n"); + + while (my $file = readdir(RULESDIR)) { + next unless ($file =~ /\.rules$/); + next if ($skipfiles{$file}); + + open(FILE, "$rulesdir/$file") or die("could not open \"$rulesdir/$file\": $!\n"); + my @file = ; + close(FILE); + + my ($single, $multi, $nonrule, $msg, $sid); + + while (get_next_entry(\@file, \$single, \$multi, \$nonrule, \$msg, \$sid)) { + if (defined($single)) { + + warn("WARNING: duplicate SID: $sid (discarding old)\n") + if (exists($sidmap{$sid})); + + $sidmap{$sid} = "$sid || $msg"; + + # Print all references. Borrowed from Brian Caswell's regen-sidmap script. + my $ref = $single; + while ($ref =~ s/(.*)reference\s*:\s*([^\;]+)(.*)$/$1 $3/) { + $sidmap{$sid} .= " || $2" + } + + $sidmap{$sid} .= "\n"; + } + } + } +} + +# Print results. +foreach my $sid (sort { $a <=> $b } keys(%sidmap)) { + print "$sidmap{$sid}"; +} + + + +# Same as in oinkmaster.pl. +sub get_next_entry($ $ $ $ $ $) +{ + my $arr_ref = shift; + my $single_ref = shift; + my $multi_ref = shift; + my $nonrule_ref = shift; + my $msg_ref = shift; + my $sid_ref = shift; + + undef($$single_ref); + undef($$multi_ref); + undef($$nonrule_ref); + undef($$msg_ref); + undef($$sid_ref); + + my $line = shift(@$arr_ref) || return(0); + my $disabled = 0; + my $broken = 0; + + # Possible beginning of multi-line rule? + if ($line =~ /$MULTILINE_RULE_REGEXP/oi) { + $$single_ref = $line; + $$multi_ref = $line; + + $disabled = 1 if ($line =~ /^\s*#/); + + # Keep on reading as long as line ends with "\". + while (!$broken && $line =~ /\\\s*\n$/) { + + # Remove trailing "\" and newline for single-line version. + $$single_ref =~ s/\\\s*\n//; + + # If there are no more lines, this can not be a valid multi-line rule. + if (!($line = shift(@$arr_ref))) { + + warn("\nWARNING: got EOF while parsing multi-line rule: $$multi_ref\n") + if ($config{verbose}); + + @_ = split(/\n/, $$multi_ref); + + undef($$multi_ref); + undef($$single_ref); + + # First line of broken multi-line rule will be returned as a non-rule line. + $$nonrule_ref = shift(@_) . "\n"; + $$nonrule_ref =~ s/\s*\n$/\n/; # remove trailing whitespaces + + # The rest is put back to the array again. + foreach $_ (reverse((@_))) { + unshift(@$arr_ref, "$_\n"); + } + + return (1); # return non-rule + } + + # Multi-line continuation. + $$multi_ref .= $line; + + # If there are non-comment lines in the middle of a disabled rule, + # mark the rule as broken to return as non-rule lines. + if ($line !~ /^\s*#/ && $disabled) { + $broken = 1; + } elsif ($line =~ /^\s*#/ && !$disabled) { + # comment line (with trailing slash) in the middle of an active rule - ignore it + } else { + $line =~ s/^\s*#*\s*//; # remove leading # in single-line version + $$single_ref .= $line; + } + + } # while line ends with "\" + + # Single-line version should now be a valid rule. + # If not, it wasn't a valid multi-line rule after all. + if (!$broken && parse_singleline_rule($$single_ref, $msg_ref, $sid_ref)) { + + $$single_ref =~ s/^\s*//; # remove leading whitespaces + $$single_ref =~ s/^#+\s*/#/; # remove whitespaces next to leading # + $$single_ref =~ s/\s*\n$/\n/; # remove trailing whitespaces + + $$multi_ref =~ s/^\s*//; + $$multi_ref =~ s/\s*\n$/\n/; + $$multi_ref =~ s/^#+\s*/#/; + + return (1); # return multi + } else { + warn("\nWARNING: invalid multi-line rule: $$single_ref\n") + if ($config{verbose} && $$multi_ref !~ /^\s*#/); + + @_ = split(/\n/, $$multi_ref); + + undef($$multi_ref); + undef($$single_ref); + + # First line of broken multi-line rule will be returned as a non-rule line. + $$nonrule_ref = shift(@_) . "\n"; + $$nonrule_ref =~ s/\s*\n$/\n/; # remove trailing whitespaces + + # The rest is put back to the array again. + foreach $_ (reverse((@_))) { + unshift(@$arr_ref, "$_\n"); + } + + return (1); # return non-rule + } + } elsif (parse_singleline_rule($line, $msg_ref, $sid_ref)) { + $$single_ref = $line; + $$single_ref =~ s/^\s*//; + $$single_ref =~ s/^#+\s*/#/; + $$single_ref =~ s/\s*\n$/\n/; + + return (1); # return single + } else { # non-rule line + + # Do extra check and warn if it *might* be a rule anyway, + # but that we just couldn't parse for some reason. + warn("\nWARNING: line may be a rule but it could not be parsed ". + "(missing sid or msg?): $line\n") + if ($config{verbose} && $line =~ /^\s*alert .+msg\s*:\s*".+"\s*;/); + + $$nonrule_ref = $line; + $$nonrule_ref =~ s/\s*\n$/\n/; + + return (1); # return non-rule + } +} + + + +# Same as in oinkmaster.pl. +sub parse_singleline_rule($ $ $) +{ + my $line = shift; + my $msg_ref = shift; + my $sid_ref = shift; + + if ($line =~ /$SINGLELINE_RULE_REGEXP/oi) { + + if ($line =~ /\bmsg\s*:\s*"(.+?)"\s*;/i) { + $$msg_ref = $1; + } else { + return (0); + } + + if ($line =~ /\bsid\s*:\s*(\d+)\s*;/i) { + $$sid_ref = $1; + } else { + return (0); + } + + return (1); + } + + return (0); +} diff --git a/config/snort-old/bin/oinkmaster_contrib/makesidex.pl b/config/snort-old/bin/oinkmaster_contrib/makesidex.pl new file mode 100644 index 00000000..80354735 --- /dev/null +++ b/config/snort-old/bin/oinkmaster_contrib/makesidex.pl @@ -0,0 +1,261 @@ +#!/usr/bin/perl -w + +# $Id: makesidex.pl,v 1.11 2005/12/31 13:42:46 andreas_o Exp $ # + +# Copyright (c) 2004-2006 Andreas Östling +# 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. +# +# 3. Neither the name of the author nor the names of its +# contributors may be used to endorse or promote products +# derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +# CONTRIBUTORS "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 COPYRIGHT OWNER OR +# CONTRIBUTORS 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. + + +use strict; + +sub get_next_entry($ $ $ $ $ $); +sub parse_singleline_rule($ $ $); + + +# Regexp to match the start of a multi-line rule. +# %ACTIONS% will be replaced with content of $config{actions} later. +my $MULTILINE_RULE_REGEXP = '^\s*#*\s*(?:%ACTIONS%)'. + '\s.*\\\\\s*\n$'; # '; + +# Regexp to match a single-line rule. +my $SINGLELINE_RULE_REGEXP = '^\s*#*\s*(?:%ACTIONS%)'. + '\s.+;\s*\)\s*$'; # '; + +my $USAGE = << "RTFM"; + +Parse *.rules in one or more directories and look for all rules that are +disabled (i.e. begin with "#") and print "disablesid # " to +standard output for all those rules. This output can be redirected to a +file, which will be understood by Oinkmaster. + +Usage: $0 [rulesdir2, ...] + +RTFM + +my $verbose = 1; + +my (%disabled, %config); + +my @rulesdirs = @ARGV; + +die($USAGE) unless ($#rulesdirs > -1); + +$config{rule_actions} = "alert|drop|log|pass|reject|sdrop|activate|dynamic"; + +$SINGLELINE_RULE_REGEXP =~ s/%ACTIONS%/$config{rule_actions}/; +$MULTILINE_RULE_REGEXP =~ s/%ACTIONS%/$config{rule_actions}/; + +foreach my $rulesdir (@rulesdirs) { + opendir(RULESDIR, "$rulesdir") or die("could not open \"$rulesdir\": $!\n"); + + while (my $file = readdir(RULESDIR)) { + next unless ($file =~ /\.rules$/); + + open(FILE, "$rulesdir/$file") or die("could not open \"$rulesdir/$file\": $!\n"); + my @file = ; + close(FILE); + + my ($single, $multi, $nonrule, $msg, $sid); + + while (get_next_entry(\@file, \$single, \$multi, \$nonrule, \$msg, \$sid)) { + $single = $multi if (defined($multi)); + $disabled{$sid} = $msg + if (defined($single) && $single =~ /^\s*#/); + } + } +} + +# Print results. +foreach my $sid (sort { $a <=> $b } keys(%disabled)) { + printf("%-25s # %s\n", "disablesid $sid", $disabled{$sid}); +} + + + +# Same as in oinkmaster.pl. +sub get_next_entry($ $ $ $ $ $) +{ + my $arr_ref = shift; + my $single_ref = shift; + my $multi_ref = shift; + my $nonrule_ref = shift; + my $msg_ref = shift; + my $sid_ref = shift; + + undef($$single_ref); + undef($$multi_ref); + undef($$nonrule_ref); + undef($$msg_ref); + undef($$sid_ref); + + my $line = shift(@$arr_ref) || return(0); + my $disabled = 0; + my $broken = 0; + + # Possible beginning of multi-line rule? + if ($line =~ /$MULTILINE_RULE_REGEXP/oi) { + $$single_ref = $line; + $$multi_ref = $line; + + $disabled = 1 if ($line =~ /^\s*#/); + + # Keep on reading as long as line ends with "\". + while (!$broken && $line =~ /\\\s*\n$/) { + + # Remove trailing "\" and newline for single-line version. + $$single_ref =~ s/\\\s*\n//; + + # If there are no more lines, this can not be a valid multi-line rule. + if (!($line = shift(@$arr_ref))) { + + warn("\nWARNING: got EOF while parsing multi-line rule: $$multi_ref\n") + if ($config{verbose}); + + @_ = split(/\n/, $$multi_ref); + + undef($$multi_ref); + undef($$single_ref); + + # First line of broken multi-line rule will be returned as a non-rule line. + $$nonrule_ref = shift(@_) . "\n"; + $$nonrule_ref =~ s/\s*\n$/\n/; # remove trailing whitespaces + + # The rest is put back to the array again. + foreach $_ (reverse((@_))) { + unshift(@$arr_ref, "$_\n"); + } + + return (1); # return non-rule + } + + # Multi-line continuation. + $$multi_ref .= $line; + + # If there are non-comment lines in the middle of a disabled rule, + # mark the rule as broken to return as non-rule lines. + if ($line !~ /^\s*#/ && $disabled) { + $broken = 1; + } elsif ($line =~ /^\s*#/ && !$disabled) { + # comment line (with trailing slash) in the middle of an active rule - ignore it + } else { + $line =~ s/^\s*#*\s*//; # remove leading # in single-line version + $$single_ref .= $line; + } + + } # while line ends with "\" + + # Single-line version should now be a valid rule. + # If not, it wasn't a valid multi-line rule after all. + if (!$broken && parse_singleline_rule($$single_ref, $msg_ref, $sid_ref)) { + + $$single_ref =~ s/^\s*//; # remove leading whitespaces + $$single_ref =~ s/^#+\s*/#/; # remove whitespaces next to leading # + $$single_ref =~ s/\s*\n$/\n/; # remove trailing whitespaces + + $$multi_ref =~ s/^\s*//; + $$multi_ref =~ s/\s*\n$/\n/; + $$multi_ref =~ s/^#+\s*/#/; + + return (1); # return multi + } else { + warn("\nWARNING: invalid multi-line rule: $$single_ref\n") + if ($config{verbose} && $$multi_ref !~ /^\s*#/); + + @_ = split(/\n/, $$multi_ref); + + undef($$multi_ref); + undef($$single_ref); + + # First line of broken multi-line rule will be returned as a non-rule line. + $$nonrule_ref = shift(@_) . "\n"; + $$nonrule_ref =~ s/\s*\n$/\n/; # remove trailing whitespaces + + # The rest is put back to the array again. + foreach $_ (reverse((@_))) { + unshift(@$arr_ref, "$_\n"); + } + + return (1); # return non-rule + } + } elsif (parse_singleline_rule($line, $msg_ref, $sid_ref)) { + $$single_ref = $line; + $$single_ref =~ s/^\s*//; + $$single_ref =~ s/^#+\s*/#/; + $$single_ref =~ s/\s*\n$/\n/; + + return (1); # return single + } else { # non-rule line + + # Do extra check and warn if it *might* be a rule anyway, + # but that we just couldn't parse for some reason. + warn("\nWARNING: line may be a rule but it could not be parsed ". + "(missing sid or msg?): $line\n") + if ($config{verbose} && $line =~ /^\s*alert .+msg\s*:\s*".+"\s*;/); + + $$nonrule_ref = $line; + $$nonrule_ref =~ s/\s*\n$/\n/; + + return (1); # return non-rule + } +} + + + +# Same as in oinkmaster.pl. +sub parse_singleline_rule($ $ $) +{ + my $line = shift; + my $msg_ref = shift; + my $sid_ref = shift; + + if ($line =~ /$SINGLELINE_RULE_REGEXP/oi) { + + if ($line =~ /\bmsg\s*:\s*"(.+?)"\s*;/i) { + $$msg_ref = $1; + } else { + return (0); + } + + if ($line =~ /\bsid\s*:\s*(\d+)\s*;/i) { + $$sid_ref = $1; + } else { + return (0); + } + + return (1); + } + + return (0); +} diff --git a/config/snort-old/bin/oinkmaster_contrib/oinkgui.pl b/config/snort-old/bin/oinkmaster_contrib/oinkgui.pl new file mode 100644 index 00000000..4e96f7db --- /dev/null +++ b/config/snort-old/bin/oinkmaster_contrib/oinkgui.pl @@ -0,0 +1,1046 @@ +#!/usr/bin/perl -w + +# $Id: oinkgui.pl,v 1.52 2005/12/31 13:42:46 andreas_o Exp $ # + +# Copyright (c) 2004-2006 Andreas Östling +# 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. +# +# 3. Neither the name of the author nor the names of its +# contributors may be used to endorse or promote products +# derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +# CONTRIBUTORS "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 COPYRIGHT OWNER OR +# CONTRIBUTORS 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. + + +use 5.006001; + +use strict; +use File::Spec; +use Tk; +use Tk::Balloon; +use Tk::BrowseEntry; +use Tk::FileSelect; +use Tk::NoteBook; +use Tk::ROText; + +use constant CSIDL_DRIVES => 17; + +sub update_rules(); +sub clear_messages(); +sub create_cmdline($); +sub fileDialog($ $ $ $); +sub load_config(); +sub save_config(); +sub save_messages(); +sub update_file_label_color($ $ $); +sub create_fileSelectFrame($ $ $ $ $ $); +sub create_checkbutton($ $ $); +sub create_radiobutton($ $ $); +sub create_actionbutton($ $ $); +sub execute_oinkmaster(@); +sub logmsg($ $); + + +my $version = 'Oinkmaster GUI v1.1'; + +my @oinkmaster_conf = qw( + /etc/oinkmaster.conf + /usr/local/etc/oinkmaster.conf +); + +# List of URLs that will show up in the URL BrowseEntry. +my @urls = qw( + http://www.bleedingsnort.com/bleeding.rules.tar.gz + http://www.snort.org/pub-bin/downloads.cgi/Download/comm_rules/Community-Rules.tar.gz + http://www.snort.org/pub-bin/oinkmaster.cgi//snortrules-snapshot-CURRENT.tar.gz + http://www.snort.org/pub-bin/oinkmaster.cgi//snortrules-snapshot-2.3.tar.gz +); + +my %color = ( + background => 'Bisque3', + button => 'Bisque2', + label => 'Bisque1', + notebook_bg => 'Bisque2', + notebook_inact => 'Bisque3', + file_label_ok => '#00e000', + file_label_not_ok => 'red', + out_frame_fg => 'white', + out_frame_bg => 'black', + entry_bg => 'white', + button_active => 'white', + button_bg => 'Bisque4', +); + +my %config = ( + animate => 1, + careful => 0, + enable_all => 0, + check_removed => 0, + output_mode => 'normal', + diff_mode => 'detailed', + perl => $^X, + oinkmaster => "", + oinkmaster_conf => "", + outdir => "", + url => "", + varfile => "", + backupdir => "", + editor => "", +); + +my %help = ( + + # File locations. + oinkscript => 'Location of the executable Oinkmaster script (oinkmaster.pl).', + oinkconf => 'The Oinkmaster configuration file to use.', + outdir => 'Where to put the new rules. This should be the directory where you '. + 'store your current rules.', + + url => 'Alternate location of rules archive to download/copy. '. + 'Leave empty to use the location set in oinkmaster.conf.', + varfile => 'Variables that exist in downloaded snort.conf but not in '. + 'this file will be added to it. Leave empty to skip.', + backupdir => 'Directory to put tarball of old rules before overwriting them. '. + 'Leave empty to skip backup.', + editor => 'Full path to editor to execute when pressing the "edit" button '. + '(wordpad is recommended on Windows). ', + + # Checkbuttons. + careful => 'In careful mode, Oinkmaster will just check for changes, '. + 'not update anything.', + enable => 'Some rules may be commented out by default (for a reason!). '. + 'This option will make Oinkmaster enable those.', + removed => 'Check for rules files that exist in the output directory but not '. + 'in the downloaded rules archive.', + + # Action buttons. + clear => 'Clear current output messages.', + save => 'Save current output messages to file.', + exit => 'Exit the GUI.', + update => 'Execute Oinkmaster to update the rules.', + test => 'Test current Oinkmaster configuration. ' . + 'If there are no fatal errors, you are ready to update the rules.', + version => 'Request version information from Oinkmaster.', +); + + +my $gui_config_file = ""; +my $use_fileop = 0; + + +#### MAIN #### + +select STDERR; +$| = 1; +select STDOUT; +$| = 1; + +# Find out if can use Win32::FileOp. +if ($^O eq 'MSWin32') { + BEGIN { $^W = 0 } + $use_fileop = 1 if (eval "require Win32::FileOp"); +} + +# Find out which oinkmaster.pl file to default to. +foreach my $dir (File::Spec->path()) { + my $file = "$dir/oinkmaster"; + if (-f "$file" && (-x "$file" || $^O eq 'MSWin32')) { + $config{oinkmaster} = $file; + last; + } elsif (-f "$file.pl" && (-x "$file" || $^O eq 'MSWin32')) { + $config{oinkmaster} = "$file.pl"; + last; + } +} + +# Find out which oinkmaster config file to default to. +foreach my $file (@oinkmaster_conf) { + if (-e "$file") { + $config{oinkmaster_conf} = $file; + last; + } +} + +# Find out where the GUI config file is (it's not required). +if ($ENV{HOME}) { + $gui_config_file = "$ENV{HOME}/.oinkguirc" +} elsif ($ENV{HOMEDRIVE} && $ENV{HOMEPATH}) { + $gui_config_file = "$ENV{HOMEDRIVE}$ENV{HOMEPATH}\\.oinkguirc"; +} + + +# Create main window. +my $main = MainWindow->new( + -background => "$color{background}", + -title => "$version", +); + + +# Create scrolled frame with output messages. +my $out_frame = $main->Scrolled('ROText', + -setgrid => 'true', + -scrollbars => 'e', + -background => $color{out_frame_bg}, + -foreground => $color{out_frame_fg}, +); + + +my $help_label = $main->Label( + -relief => 'groove', + -background => "$color{label}", +); + +my $balloon = $main->Balloon( + -statusbar => $help_label, +); + + +# Create notebook. +my $notebook = $main->NoteBook( + -ipadx => 6, + -ipady => 6, + -background => $color{notebook_bg}, + -inactivebackground => $color{notebook_inact}, + -backpagecolor => $color{background}, +); + + +# Create tab with required files/dirs. +my $req_tab = $notebook->add("required", + -label => "Required files and directories", + -underline => 0, +); + +$req_tab->configure(-bg => "$color{notebook_inact}"); + + +# Create frame with oinkmaster.pl location. +my $filetypes = [ + ['Oinkmaster script', 'oinkmaster.pl'], + ['All files', '*' ] +]; + +my $oinkscript_frame = + create_fileSelectFrame($req_tab, "oinkmaster.pl", 'EXECFILE', + \$config{oinkmaster}, 'NOEDIT', $filetypes); + +$balloon->attach($oinkscript_frame, -statusmsg => $help{oinkscript}); + + +# Create frame with oinkmaster.conf location. +$filetypes = [ + ['configuration files', '.conf'], + ['All files', '*' ] +]; + +my $oinkconf_frame = + create_fileSelectFrame($req_tab, "oinkmaster.conf", 'ROFILE', + \$config{oinkmaster_conf}, 'EDIT', $filetypes); + +$balloon->attach($oinkconf_frame, -statusmsg => $help{oinkconf}); + + +# Create frame with output directory. +my $outdir_frame = + create_fileSelectFrame($req_tab, "output directory", 'WRDIR', + \$config{outdir}, 'NOEDIT', undef); + +$balloon->attach($outdir_frame, -statusmsg => $help{outdir}); + + + +# Create tab with optional files/dirs. +my $opt_tab = $notebook->add("optional", + -label => "Optional files and directories", + -underline => 0, +); + +$opt_tab->configure(-bg => "$color{notebook_inact}"); + +# Create frame with alternate URL location. +$filetypes = [ + ['compressed tar files', '.tar.gz'] +]; + +my $url_frame = + create_fileSelectFrame($opt_tab, "Alternate URL", 'URL', + \$config{url}, 'NOEDIT', $filetypes); + +$balloon->attach($url_frame, -statusmsg => $help{url}); + + +# Create frame with variable file. +$filetypes = [ + ['Snort configuration files', ['.conf', '.config']], + ['All files', '*' ] +]; + +my $varfile_frame = + create_fileSelectFrame($opt_tab, "Variable file", 'WRFILE', + \$config{varfile}, 'EDIT', $filetypes); + +$balloon->attach($varfile_frame, -statusmsg => $help{varfile}); + + +# Create frame with backup dir location. +my $backupdir_frame = + create_fileSelectFrame($opt_tab, "Backup directory", 'WRDIR', + \$config{backupdir}, 'NOEDIT', undef); + +$balloon->attach($backupdir_frame, -statusmsg => $help{backupdir}); + + +# Create frame with editor location. +$filetypes = [ + ['executable files', ['.exe']], + ['All files', '*' ] +]; + +my $editor_frame = + create_fileSelectFrame($opt_tab, "Editor", 'EXECFILE', + \$config{editor}, 'NOEDIT', $filetypes); + +$balloon->attach($editor_frame, -statusmsg => $help{editor}); + + + +$notebook->pack( + -expand => 'no', + -fill => 'x', + -padx => '5', + -pady => '5', + -side => 'top' +); + + +# Create the frame to the left. +my $left_frame = $main->Frame( + -background => "$color{label}", + -border => '2', +)->pack( + -side => 'left', + -fill => 'y', +); + + +# Create "GUI settings" label. +$left_frame->Label( + -text => "GUI settings:", + -background => "$color{label}", +)->pack( + -side => 'top', + -fill => 'x', +); + + +create_actionbutton($left_frame, "Load saved settings", \&load_config); +create_actionbutton($left_frame, "Save current settings", \&save_config); + + +# Create "options" label at the top of the left frame. +$left_frame->Label( + -text => "Options:", + -background => "$color{label}", +)->pack(-side => 'top', + -fill => 'x', +); + + +# Create checkbuttons in the left frame. +$balloon->attach( + create_checkbutton($left_frame, "Careful mode", \$config{careful}), + -statusmsg => $help{careful} +); + +$balloon->attach( + create_checkbutton($left_frame, "Enable all", \$config{enable_all}), + -statusmsg => $help{enable} +); + +$balloon->attach( + create_checkbutton($left_frame, "Check for removed files", \$config{check_removed}), + -statusmsg => $help{removed} +); + + +# Create "mode" label. +$left_frame->Label( + -text => "Output mode:", + -background => "$color{label}", +)->pack( + -side => 'top', + -fill => 'x', +); + +# Create mode radiobuttons in the left frame. +create_radiobutton($left_frame, "super-quiet", \$config{output_mode}); +create_radiobutton($left_frame, "quiet", \$config{output_mode}); +create_radiobutton($left_frame, "normal", \$config{output_mode}); +create_radiobutton($left_frame, "verbose", \$config{output_mode}); + +# Create "Diff mode" label. +$left_frame->Label( + -text => "Diff mode:", + -background => "$color{label}", +)->pack( + -side => 'top', + -fill => 'x', +); + +create_radiobutton($left_frame, "detailed", \$config{diff_mode}); +create_radiobutton($left_frame, "summarized", \$config{diff_mode}); +create_radiobutton($left_frame, "remove common", \$config{diff_mode}); + + +# Create "activity messages" label. +$main->Label( + -text => "Output messages:", + -width => '130', + -background => "$color{label}", +)->pack( + -side => 'top', + -fill => 'x', +); + + + +# Pack output frame. +$out_frame->pack( + -expand => 'yes', + -fill => 'both', +); + + +# Pack help label below output window. +$help_label->pack( + -fill => 'x', +); + + +# Create "actions" label. +$left_frame->Label( + -text => "Actions:", + -background => "$color{label}", +)->pack( + -side => 'top', + -fill => 'x', +); + + +# Create action buttons. + +$balloon->attach( + create_actionbutton($left_frame, "Update rules!", \&update_rules), + -statusmsg => $help{update} +); + +$balloon->attach( + create_actionbutton($left_frame, "Clear output messages", \&clear_messages), + -statusmsg => $help{clear} +); + +$balloon->attach( + create_actionbutton($left_frame, "Save output messages", \&save_messages), + -statusmsg => $help{save} +); + +$balloon->attach( + create_actionbutton($left_frame, "Exit", \&exit), + -statusmsg => $help{exit} +); + + + +# Make the mousewheel scroll the output window. Taken from Mastering Perl/Tk. +if ($^O eq 'MSWin32') { + $out_frame->bind('' => + [ sub { $_[0]->yview('scroll', -($_[1] / 120) * 3, 'units')}, + Ev('D') ] + ); +} else { + $out_frame->bind('<4>' => sub { + $_[0]->yview('scroll', -3, 'units') unless $Tk::strictMotif; + }); + + $out_frame->bind('<5>' => sub { + $_[0]->yview('scroll', +3, 'units') unless $Tk::strictMotif; + }); +} + + + +# Now the fun begins. +if ($config{animate}) { + foreach (split(//, "Welcome to $version")) { + logmsg("$_", 'MISC'); + $out_frame->after(5); + } +} else { + logmsg("Welcome to $version", 'MISC'); +} + +logmsg("\n\n", 'MISC'); + +# Load gui settings into %config. +load_config(); + + +# Warn if any required file/directory is not set. +logmsg("No oinkmaster.pl set, please select one above!\n\n", 'ERROR') + if ($config{oinkmaster} !~ /\S/); + +logmsg("No oinkmaster configuration file set, please select one above!\n\n", 'ERROR') + if ($config{oinkmaster_conf} !~ /\S/); + +logmsg("Output directory is not set, please select one above!\n\n", 'ERROR') + if ($config{outdir} !~ /\S/); + + +MainLoop; + + + +#### END #### + + + +sub fileDialog($ $ $ $) +{ + my $var_ref = shift; + my $title = shift; + my $type = shift; + my $filetypes = shift; + my $dirname; + + if ($type eq 'WRDIR') { + if ($use_fileop) { + $dirname = Win32::FileOp::BrowseForFolder("title", CSIDL_DRIVES); + } else { + my $fs = $main->FileSelect(); + $fs->configure(-verify => ['-d', '-w'], -title => $title); + $dirname = $fs->Show; + } + $$var_ref = $dirname if ($dirname); + } elsif ($type eq 'EXECFILE' || $type eq 'ROFILE' || $type eq 'WRFILE' || $type eq 'URL') { + my $filename = $main->getOpenFile(-title => $title, -filetypes => $filetypes); + $$var_ref = $filename if ($filename); + } elsif ($type eq 'SAVEFILE') { + my $filename = $main->getSaveFile(-title => $title, -filetypes => $filetypes); + $$var_ref = $filename if ($filename); + } else { + logmsg("Unknown type ($type)\n", 'ERROR'); + } +} + + + +sub update_file_label_color($ $ $) +{ + my $label = shift; + my $filename = shift; + my $type = shift; + + $filename =~ s/^\s+//; + $filename =~ s/\s+$//; + + unless ($filename) { + $label->configure(-background => $color{file_label_not_ok}); + return (1); + } + + if ($type eq "URL") { + if ($filename =~ /^(?:http|ftp|scp):\/\/.+\.tar\.gz$/) { + $label->configure(-background => $color{file_label_ok}); + } elsif ($filename =~ /^(?:file:\/\/)*(.+\.tar\.gz)$/) { + my $file = $1; + if (-f "$file" && -r "$file") { + $label->configure(-background => $color{file_label_ok}); + } else { + $label->configure(-background => $color{file_label_not_ok}); + } + } else { + $label->configure(-background => $color{file_label_not_ok}); + } + } elsif ($type eq "ROFILE") { + if (-f "$filename" && -r "$filename") { + $label->configure(-background => $color{file_label_ok}); + } else { + $label->configure(-background => $color{file_label_not_ok}); + } + } elsif ($type eq "EXECFILE") { + if (-f "$filename" && (-x "$filename" || $^O eq 'MSWin32')) { + $label->configure(-background => $color{file_label_ok}); + } else { + $label->configure(-background => $color{file_label_not_ok}); + } + } elsif ($type eq "WRFILE") { + if (-f "$filename" && -w "$filename") { + $label->configure(-background => $color{file_label_ok}); + } else { + $label->configure(-background => $color{file_label_not_ok}); + } + } elsif ($type eq "WRDIR") { + if (-d "$filename" && -w "$filename") { + $label->configure(-background => $color{file_label_ok}); + } else { + $label->configure(-background => $color{file_label_not_ok}); + } + } else { + print STDERR "incorrect type ($type)\n"; + exit; + } + + return (1); +} + + + +sub create_checkbutton($ $ $) +{ + my $frame = shift; + my $name = shift; + my $var_ref = shift; + + my $button = $frame->Checkbutton( + -text => $name, + -background => $color{button}, + -activebackground => $color{button_active}, + -highlightbackground => $color{button_bg}, + -variable => $var_ref, + -relief => 'raise', + -anchor => 'w', + )->pack( + -fill => 'x', + -side => 'top', + -pady => '1', + ); + + return ($button); +} + + + +sub create_actionbutton($ $ $) +{ + my $frame = shift; + my $name = shift; + my $func_ref = shift; + + my $button = $frame->Button( + -text => $name, + -command => sub { + &$func_ref; + $out_frame->focus; + }, + -background => $color{button}, + -activebackground => $color{button_active}, + -highlightbackground => $color{button_bg}, + )->pack( + -fill => 'x', + ); + + return ($button); +} + + + +sub create_radiobutton($ $ $) +{ + my $frame = shift; + my $name = shift; + my $mode_ref = shift; + + my $button = $frame->Radiobutton( + -text => $name, + -highlightbackground => $color{button_bg}, + -background => $color{button}, + -activebackground => $color{button_active}, + -variable => $mode_ref, + -relief => 'raised', + -anchor => 'w', + -value => $name, + )->pack( + -side => 'top', + -pady => '1', + -fill => 'x', + ); + + return ($button); +} + + + +# Create

    Backup your old rules into before overwriting them +-c Careful mode (dry run) - check for changes but do not update anything +-C Use this configuration file instead of the default + May be specified multiple times to load multiple files +-e Enable all rules that are disabled by default +-h Show this usage information +-i Interactive mode - you will be asked to approve the changes (if any) +-m Minimize diff when printing result by removing common parts in rules +-q Quiet mode - no output unless changes were found +-Q Super-quiet mode - like -q but even more quiet +-r Check for rules files that exist in the output directory + but not in the downloaded rules archive +-s Leave out details in rules results, just print SID, msg and filename +-S Look for new variables in this file in the downloaded archive instead + of the default (@DEFAULT_DIST_VAR_FILES). Used in conjunction with -U. + May be specified multiple times to search multiple files. +-T Config test - just check configuration file(s) for errors/warnings +-u Download from this URL instead of URL(s) in the configuration file + (http|https|ftp|file|scp:// ... .tar.gz|.gz, or dir://) + May be specified multiple times to grab multiple rules archives +-U Merge new variables from downloaded snort.conf(s) into +-v Verbose mode (debug) +-V Show version and exit + +RTFM + exit; +} + + + +# Parse the command line arguments and exit if we don't like them. +sub parse_cmdline($) +{ + my $cfg_ref = shift; + + Getopt::Long::Configure("bundling"); + + my $cmdline_ok = GetOptions( + "b=s" => \$$cfg_ref{backup_dir}, + "c" => \$$cfg_ref{careful}, + "C=s" => \@{$$cfg_ref{config_files}}, + "e" => \$$cfg_ref{enable_all}, + "h" => \&show_usage, + "i" => \$$cfg_ref{interactive}, + "m" => \$$cfg_ref{minimize_diff}, + "o=s" => \$$cfg_ref{output_dir}, + "q" => \$$cfg_ref{quiet}, + "Q" => \$$cfg_ref{super_quiet}, + "r" => \$$cfg_ref{check_removed}, + "s" => \$$cfg_ref{summary_output}, + "S=s" => \@{$$cfg_ref{dist_var_files}}, + "T" => \$$cfg_ref{config_test_mode}, + "u=s" => \@{$$cfg_ref{url}}, + "U=s" => \$$cfg_ref{varfile}, + "v" => \$$cfg_ref{verbose}, + "V" => sub { + print "$VERSION\n"; + exit(0); + } + ); + + + show_usage unless ($cmdline_ok && $#ARGV == -1); + + $$cfg_ref{quiet} = 1 if ($$cfg_ref{super_quiet}); + $$cfg_ref{update_vars} = 1 if ($$cfg_ref{varfile}); + + if ($$cfg_ref{backup_dir}) { + $$cfg_ref{backup_dir} = File::Spec->canonpath($$cfg_ref{backup_dir}); + $$cfg_ref{make_backup} = 1; + } + + # Cannot specify dist var files without specifying var target file. + if (@{$$cfg_ref{dist_var_files}} && !$$cfg_ref{update_vars}) { + clean_exit("You can not specify distribution variable file(s) without ". + "also specifying local file to merge into"); + } + + # -o is the only required option in normal usage. + if ($$cfg_ref{output_dir}) { + $$cfg_ref{output_dir} = File::Spec->canonpath($$cfg_ref{output_dir}); + } else { + warn("Error: no output directory specified.\n"); + show_usage(); + } + + # Mark that url was set on command line (so we don't override it later). + $$cfg_ref{cmdline_url} = 1 if ($#{$config{url}} > -1); +} + + + +# Read in stuff from the configuration file. +sub read_config($ $) +{ + my $config_file = shift; + my $cfg_ref = shift; + my $linenum = 0; + my $multi; + my %templates; + + $config_file = File::Spec->canonpath(File::Spec->rel2abs($config_file)); + + clean_exit("configuration file \"$config_file\" does not exist.\n") + unless (-e "$config_file"); + + clean_exit("\"$config_file\" is not a file.\n") + unless (-f "$config_file"); + + print STDERR "Loading $config_file\n" + unless ($config{quiet}); + + # Avoid loading the same file multiple times to avoid infinite recursion etc. + if ($^O eq "MSWin32") { + clean_exit("attempt to load \"$config_file\" twice.") + if ($loaded{$config_file}++); + } else { + my ($dev, $ino) = (stat($config_file))[0,1] + or clean_exit("unable to stat $config_file: $!"); + clean_exit("attempt to load \"$config_file\" twice.") + if ($loaded{$dev, $ino}++); + } + + open(CONF, "<", "$config_file") + or clean_exit("could not open configuration file \"$config_file\": $!"); + my @conf = ; + close(CONF); + + LINE:while ($_ = shift(@conf)) { + $linenum++; + + unless ($multi) { + s/^\s*//; + s/^#.*//; + } + + # Multi-line start/continuation. + if (/\\\s*\n$/) { + s/\\\s*\n$//; + s/^\s*#.*//; + + # Be strict about removing #comments in modifysid/define_template statements, as + # they may contain other '#' chars. + if (defined($multi) && ($multi =~ /^modifysid/i || $multi =~ /^define_template/i)) { + s/#.*// if (/^\s*\d+[,\s\d]+#/); + } else { + s/\s*\#.*// unless (/^modifysid/i || /^define_template/i); + } + + $multi .= $_; + next LINE; + } + + # Last line of multi-line directive. + if (defined($multi)) { + $multi .= $_; + $_ = $multi; + undef($multi); + } + + # Remove traling whitespaces (*after* a possible multi-line is rebuilt). + s/\s*$//; + + # Remove comments unless it's a modifysid/define_template line + # (the "#" may be part of the modifysid expression). + s/\s*\#.*// unless (/^modifysid/i || /^define_template/i); + + # Skip blank lines. + next unless (/\S/); + + # Use a template and make $_ a "modifysid" line. + if (/^use_template\s+(\S+)\s+(\S+[^"]*)\s*(".*")*(?:#.*)*/i) { + my ($template_name, $sid, $args) = ($1, $2, $3); + + if (exists($templates{$template_name})) { + my $template = $templates{$template_name}; # so we don't substitute %ARGx% globally + + # Evaluate each "%ARGx%" in the template to the corresponding value. + if (defined($args)) { + my @args = split(/"\s+"/, $args); + foreach my $i (1 .. @args) { + $args[$i - 1] =~ s/^"//; + $args[$i - 1] =~ s/"$//; + $template =~ s/%ARG$i%/$args[$i - 1]/g; + } + } + + # There should be no %ARGx% stuff left now. + if ($template =~ /%ARG\d%/) { + warn("WARNING: too few arguments for template \"$template_name\"\n"); + $_ = "error"; # so it will be reported as an invalid line later + } + + unless ($_ eq "error") { + $_ = "modifysid $sid $template\n"; + print STDERR "Template \"$template_name\" expanded to: $_" + if ($config{verbose}); + } + + } else { + warn("WARNING: template \"$template_name\" has not been defined\n"); + } + } + + # new template definition. + if (/^define_template\s+(\S+)\s+(".+"\s+\|\s+".*")\s*(?:#.*)*$/i) { + my ($template_name, $template) = ($1, $2); + + if (exists($templates{$template_name})) { + warn("WARNING: line $linenum in $config_file: ". + "template \"$template_name\" already defined, keeping old\n"); + } else { + $templates{$template_name} = $template; + } + + # modifysid "substthis" | "withthis" + } elsif (/^modifysids*\s+(\S+.*)\s+"(.+)"\s+\|\s+"(.*)"\s*(?:#.*)*$/i) { + my ($sid_list, $subst, $repl) = ($1, $2, $3); + warn("WARNING: line $linenum in $config_file is invalid, ignoring\n") + unless(parse_mod_expr(\@{$$cfg_ref{sid_modify_list}}, + $sid_list, $subst, $repl)); + + # disablesid + } elsif (/^disablesids*\s+(\d.*)/i) { + my $sid_list = $1; + foreach my $sid (split(/\s*,\s*/, $sid_list)) { + if ($sid =~ /^\d+$/) { + $$cfg_ref{sid_disable_list}{$sid}++; + } else { + warn("WARNING: line $linenum in $config_file: ". + "\"$sid\" is not a valid SID, ignoring\n"); + } + } + + # localsid + } elsif (/^localsids*\s+(\d.*)/i) { + my $sid_list = $1; + foreach my $sid (split(/\s*,\s*/, $sid_list)) { + if ($sid =~ /^\d+$/) { + $$cfg_ref{sid_local_list}{$sid}++; + } else { + warn("WARNING: line $linenum in $config_file: ". + "\"$sid\" is not a valid SID, ignoring\n"); + } + } + + # enablesid + } elsif (/^enablesids*\s+(\d.*)/i) { + my $sid_list = $1; + foreach my $sid (split(/\s*,\s*/, $sid_list)) { + if ($sid =~ /^\d+$/) { + $$cfg_ref{sid_enable_list}{$sid}++; + } else { + warn("WARNING: line $linenum in $config_file: ". + "\"$sid\" is not a valid SID, ignoring\n"); + } + } + + # skipfile + } elsif (/^skipfiles*\s+(.*)/i) { + my $args = $1; + foreach my $file (split(/\s*,\s*/, $args)) { + if ($file =~ /^\S+$/) { + $config{verbose} && print STDERR "Adding file to ignore list: $file.\n"; + $$cfg_ref{file_ignore_list}{$file}++; + } else { + warn("WARNING: line $linenum in $config_file is invalid, ignoring\n"); + } + } + + } elsif (/^url\s*=\s*(.*)/i) { + push(@{$$cfg_ref{url}}, $1) + unless ($$cfg_ref{cmdline_url}); + + } elsif (/^path\s*=\s*(.+)/i) { + $$cfg_ref{path} = $1; + + } elsif (/^update_files\s*=\s*(.+)/i) { + $$cfg_ref{update_files} = $1; + + } elsif (/^rule_actions\s*=\s*(.+)/i) { + $$cfg_ref{rule_actions} = $1; + + } elsif (/^umask\s*=\s*([0-7]{4})$/i) { + $$cfg_ref{umask} = oct($1); + + } elsif (/^min_files\s*=\s*(\d+)/i) { + $$cfg_ref{min_files} = $1; + + } elsif (/^min_rules\s*=\s*(\d+)/i) { + $$cfg_ref{min_rules} = $1; + + } elsif (/^tmpdir\s*=\s*(.+)/i) { + $$cfg_ref{tmp_basedir} = $1; + + } elsif (/^use_external_bins\s*=\s*([01])/i) { + $$cfg_ref{use_external_bins} = $1; + + } elsif (/^scp_key\s*=\s*(.+)/i) { + $$cfg_ref{scp_key} = $1; + + } elsif (/^use_path_checks\s*=\s*([01])/i) { + $$cfg_ref{use_path_checks} = $1; + + } elsif (/^user_agent\s*=\s*(.+)/i) { + $$cfg_ref{user_agent} = $1; + + } elsif (/^include\s+(\S+.*)/i) { + my $include = $1; + read_config($include, $cfg_ref); + } else { + warn("WARNING: line $linenum in $config_file is invalid, ignoring\n"); + } + } +} + + + +# Make a few basic tests to make sure things look ok. +# Will also set a new PATH as defined in the config file. +sub sanity_check() +{ + my @req_params = qw(path update_files); # required parameters in conf + my @req_binaries = qw(gzip tar); # required binaries (unless we use modules) + + # Can't use both quiet mode and verbose mode. + clean_exit("quiet mode and verbose mode at the same time doesn't make sense.") + if ($config{quiet} && $config{verbose}); + + # Can't use multiple output modes. + clean_exit("can't use multiple output modes at the same time.") + if ($config{minimize_diff} && $config{summary_output}); + + # Make sure all required variables are defined in the config file. + foreach my $param (@req_params) { + clean_exit("the required parameter \"$param\" is not defined in the configuration file.") + unless (exists($config{$param})); + } + + # We now know a path was defined in the config, so set it. + # If we're under cygwin and path was specified as msdos style, convert + # it to cygwin style to avoid problems. + if ($^O eq "cygwin" && $config{path} =~ /^[a-zA-Z]:[\/\\]/) { + $ENV{PATH} = ""; + foreach my $path (split(/;/, $config{path})) { + $ENV{PATH} .= "$path:" if (msdos_to_cygwin_path(\$path)); + } + chop($ENV{PATH}); + } else { + $ENV{PATH} = $config{path}; + } + + # Reset environment variables that may cause trouble. + delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'}; + + # Make sure $config{update_files} is a valid regexp. + eval { + "foo" =~ /$config{update_files}/; + }; + + clean_exit("update_files (\"$config{update_files}\") is not a valid regexp: $@") + if ($@); + + # Make sure $config{rule_actions} is a valid regexp. + eval { + "foo" =~ /$config{rule_actions}/; + }; + + clean_exit("rule_actions (\"$config{rule_actions}\") is not a valid regexp: $@") + if ($@); + + # If a variable file (probably local snort.conf) has been specified, + # it must exist. It must also be writable unless we're in careful mode. + if ($config{update_vars}) { + $config{varfile} = untaint_path($config{varfile}); + + clean_exit("variable file \"$config{varfile}\" does not exist.") + unless (-e "$config{varfile}"); + + clean_exit("variable file \"$config{varfile}\" is not a file.") + unless (-f "$config{varfile}"); + + clean_exit("variable file \"$config{varfile}\" is not writable by you.") + if (!$config{careful} && !-w "$config{varfile}"); + + # Make sure dist var files don't contain [back]slashes + # (probably means user confused it with local var file). + my %dist_var_files; + foreach my $dist_var_file (@{${config{dist_var_files}}}) { + clean_exit("variable file \"$dist_var_file\" specified multiple times") + if (exists($dist_var_files{$dist_var_file})); + $dist_var_files{$dist_var_file} = 1; + clean_exit("variable file \"$dist_var_file\" contains slashes or backslashes ". + "but it must be specified as a filename (without path) ". + "that exists in the downloaded rules, e.g. \"snort.conf\"") + if ($dist_var_file =~ /\// || $dist_var_file =~ /\\/); + } + } + + # Make sure all required binaries can be found, unless + # we're used to use Perl modules instead. + # Wget is only required if url is http[s] or ftp. + if ($config{use_external_bins}) { + foreach my $binary (@req_binaries) { + clean_exit("$binary not found in PATH ($ENV{PATH}).") + unless (is_in_path($binary)); + } + } + + # Make sure $url is defined (either by -u or url=... in the conf). + clean_exit("URL not specified. Specify at least one \"url=\" in the \n". + "Oinkmaster configuration file or use the \"-u \" argument") + if ($#{$config{url}} == -1); + + # Make sure all urls look ok, and untaint them. + my @urls = @{$config{url}}; + $#{$config{url}} = -1; + foreach my $url (@urls) { + clean_exit("incorrect URL: \"$url\"") + unless ($url =~ /^((?:https*|ftp|file|scp):\/\/.+\.(?:tar\.gz|tgz))$/ + || $url =~ /^(dir:\/\/.+)/); + my $ok_url = $1; + + if ($ok_url =~ /^dir:\/\/(.+)/) { + my $dir = untaint_path($1); + clean_exit("\"$dir\" does not exist or is not a directory") + unless (-d $dir); + + # Simple check if the output dir is specified as url (probably a mistake). + if (File::Spec->canonpath(File::Spec->rel2abs($dir)) + eq File::Spec->canonpath(File::Spec->rel2abs($config{output_dir}))) { + clean_exit("Download directory can not be same as output directory"); + } + } + push(@{$config{url}}, $ok_url); + } + + # Wget must be found if url is http[s]:// or ftp://. + if ($config{use_external_bins}) { + clean_exit("wget not found in PATH ($ENV{PATH}).") + if ($config{'url'} =~ /^(https*|ftp):/ && !is_in_path("wget")); + } + + # scp must be found if scp://... + clean_exit("scp not found in PATH ($ENV{PATH}).") + if ($config{'url'} =~ /^scp:/ && !is_in_path("scp")); + + # ssh key must exist if specified and url is scp://... + clean_exit("ssh key \"$config{scp_key}\" does not exist.") + if ($config{'url'} =~ /^scp:/ && exists($config{scp_key}) + && !-e $config{scp_key}); + + # Untaint output directory string. + $config{output_dir} = untaint_path($config{output_dir}); + + # Make sure the output directory exists and is readable. + clean_exit("the output directory \"$config{output_dir}\" doesn't exist ". + "or isn't readable by you.") + if (!-d "$config{output_dir}" || !-x "$config{output_dir}"); + + # Make sure the output directory is writable unless running in careful mode. + clean_exit("the output directory \"$config{output_dir}\" isn't writable by you.") + if (!$config{careful} && !-w "$config{output_dir}"); + + # Make sure we have read permission on all rules files in the output dir, + # and also write permission unless we're in careful mode. + # This is to avoid bailing out in the middle of an execution if a copy + # fails because of permission problem. + opendir(OUTDIR, "$config{output_dir}") + or clean_exit("could not open directory $config{output_dir}: $!"); + + while ($_ = readdir(OUTDIR)) { + next if (/^\.\.?$/ || exists($config{file_ignore_list}{$_})); + + if (/$config{update_files}/) { + unless (-r "$config{output_dir}/$_") { + closedir(OUTDIR); + clean_exit("no read permission on \"$config{output_dir}/$_\"\n". + "Read permission is required on all rules files ". + "inside the output directory.\n") + } + + if (!$config{careful} && !-w "$config{output_dir}/$_") { + closedir(OUTDIR); + clean_exit("no write permission on \"$config{output_dir}/$_\"\n". + "Write permission is required on all rules files ". + "inside the output directory.\n") + } + } + } + + closedir(OUTDIR); + + # Make sure the backup directory exists and is writable if running with -b. + if ($config{make_backup}) { + $config{backup_dir} = untaint_path($config{backup_dir}); + clean_exit("the backup directory \"$config{backup_dir}\" doesn't exist or ". + "isn't writable by you.") + if (!-d "$config{backup_dir}" || !-w "$config{backup_dir}"); + } + + # Convert tmp_basedir to cygwin style if running cygwin and msdos style was specified. + if ($^O eq "cygwin" && $config{tmp_basedir} =~ /^[a-zA-Z]:[\/\\]/) { + msdos_to_cygwin_path(\$config{tmp_basedir}) + or clean_exit("could not convert temporary dir to cygwin style"); + } + + # Make sure temporary directory exists. + clean_exit("the temporary directory \"$config{tmp_basedir}\" does not ". + "exist or isn't writable by you.") + if (!-d "$config{tmp_basedir}" || !-w "$config{tmp_basedir}"); + + # Also untaint it. + $config{tmp_basedir} = untaint_path($config{tmp_basedir}); + + # Make sure stdin and stdout are ttys if we're running in interactive mode. + clean_exit("you can not run in interactive mode when STDIN/STDOUT is not a TTY.") + if ($config{interactive} && !(-t STDIN && -t STDOUT)); +} + + + +# Download the rules archive. +sub download_file($ $) +{ + my $url = shift; + my $localfile = shift; + my $log = "$tmpdir/wget.log"; + my $ret; + + # If there seems to be a password in the url, replace it with "*password*" + # and use new string when printing the url to screen. + my $obfuscated_url = $url; + $obfuscated_url = "$1:*password*\@$2" + if ($obfuscated_url =~ /^(\S+:\/\/.+?):.+?@(.+)/); + + # Ofbuscate oinkcode as well. + $obfuscated_url = "$1*oinkcode*$2" + if ($obfuscated_url =~ /^(\S+:\/\/.+\.cgi\/)[0-9a-z]{32,64}(\/.+)/i); + + my @user_agent_opt; + @user_agent_opt = ("-U", $config{user_agent}) if (exists($config{user_agent})); + + # Use wget if URL starts with "http[s]" or "ftp" and we use external binaries. + if ($config{use_external_bins} && $url =~ /^(?:https*|ftp)/) { + print STDERR "Downloading file from $obfuscated_url... " + unless ($config{quiet}); + + if ($config{verbose}) { + print STDERR "\n"; + my @wget_cmd = ("wget", "-v", "-O", $localfile, $url, @user_agent_opt); + clean_exit("could not download from $obfuscated_url") + if (system(@wget_cmd)); + + } else { + my @wget_cmd = ("wget", "-v", "-o", $log, "-O", $localfile, $url, @user_agent_opt); + if (system(@wget_cmd)) { + my $log_output; + open(LOG, "<", "$log") + or clean_exit("could not open $log for reading: $!"); + # Sanitize oinkcode in wget's log (password is automatically sanitized). + while () { + $_ = "$1*oinkcode*$2" + if (/(\S+:\/\/.+\.cgi\/)[0-9a-z]{32,64}(\/.+)/i); + $log_output .= $_; + } + close(LOG); + clean_exit("could not download from $obfuscated_url. ". + "Output from wget follows:\n\n $log_output"); + } + print STDERR "done.\n" unless ($config{quiet}); + } + + # Use LWP if URL starts with "http[s]" or "ftp" and use_external_bins=0. + } elsif (!$config{use_external_bins} && $url =~ /^(?:https*|ftp)/) { + print STDERR "Downloading file from $obfuscated_url... " + unless ($config{quiet}); + + my %lwp_opt; + $lwp_opt{agent} = $config{user_agent} if (exists($config{user_agent})); + + my $ua = LWP::UserAgent->new(%lwp_opt); + $ua->env_proxy; + my $request = HTTP::Request->new(GET => $url); + my $response = $ua->request($request, $localfile); + + clean_exit("could not download from $obfuscated_url: " . $response->status_line) + unless $response->is_success; + + print "done.\n" unless ($config{quiet}); + + # Grab file from local filesystem if file://... + } elsif ($url =~ /^file/) { + $url =~ s/^file:\/\///; + + clean_exit("the file $url does not exist.") + unless (-e "$url"); + + clean_exit("the file $url is empty.") + unless (-s "$url"); + + print STDERR "Copying file from $url... " + unless ($config{quiet}); + + copy("$url", "$localfile") + or clean_exit("unable to copy $url to $localfile: $!"); + + print STDERR "done.\n" + unless ($config{quiet}); + + # Grab file using scp if scp://... + } elsif ($url =~ /^scp/) { + $url =~ s/^scp:\/\///; + + my @cmd; + push(@cmd, "scp"); + push(@cmd, "-i", "$config{scp_key}") if (exists($config{scp_key})); + push(@cmd, "-q") if ($config{quiet}); + push(@cmd, "-v") if ($config{verbose}); + push(@cmd, "$url", "$localfile"); + + print STDERR "Copying file from $url using scp:\n" + unless ($config{quiet}); + + clean_exit("scp returned error when trying to copy $url") + if (system(@cmd)); + + # Unknown download method. + } else { + clean_exit("unknown or unsupported download method\n"); + } + + # Make sure the downloaded file actually exists. + clean_exit("failed to download $url: ". + "local target file $localfile doesn't exist after download.") + unless (-e "$localfile"); + + # Also make sure it's at least non-empty. + clean_exit("failed to download $url: local target file $localfile is empty ". + "after download (perhaps you're out of diskspace or file in url is empty?)") + unless (-s "$localfile"); +} + + + +# Copy all rules files from the tmp dirs (one for each url) +# into a single directory inside the tmp dir, except for files +# matching a 'skipfile' directive'. +# Will exit in case of colliding filenames. +sub join_tmp_rules_dirs($ $ @) +{ + my $rules_dir = shift; + my $new_files_ref = shift; + my @url_tmpdirs = @_; + + my %rules_files; + + clean_exit("failed to create directory \"$rules_dir\": $!") + unless (mkdir($rules_dir)); + + foreach my $url_tmpdir (@url_tmpdirs) { + opendir(URL_TMPDIR, "$url_tmpdir") + or clean_exit("could not open directory \"$url_tmpdir\": $!"); + + while ($_ = readdir(URL_TMPDIR)) { + next if (/^\.\.?$/ || exists($config{file_ignore_list}{$_}) || !/$config{update_files}/); + + if (exists($rules_files{$_})) { + closedir(URL_TMPDIR); + clean_exit("a file called \"$_\" exists in multiple rules archives") + } + + # Make sure it's a regular file. + unless (-f "$url_tmpdir/$_" && !-l "$url_tmpdir/$_") { + closedir(URL_TMPDIR); + clean_exit("downloaded \"$_\" is not a regular file.") + } + + $rules_files{$_} = 1; + $$new_files_ref{"$rules_dir/$_"} = 1; + + my $src_file = untaint_path("$url_tmpdir/$_"); + unless (copy("$src_file", "$rules_dir")) { + closedir(URL_TMPDIR); + clean_exit("could not copy \"$src_file\" to \"$rules_dir\": $!"); + } + } + + closedir(URL_TMPDIR); + } + + return (keys(%$new_files_ref)); +} + + + +# Make a few basic sanity checks on the rules archive and then +# uncompress/untar it if everything looked ok. +sub unpack_rules_archive($ $ $) +{ + my $url = shift; # only used when printing warnings/errors + my $archive = shift; + my $rules_dir = shift; + + my ($tar, @tar_content); + + my $old_dir = untaint_path(File::Spec->rel2abs(File::Spec->curdir())); + + my $dir = dirname($archive); + chdir("$dir") or clean_exit("$url: could not change directory to \"$dir\": $!"); + + if ($config{use_external_bins}) { + + # Run integrity check on the gzip file. + clean_exit("$url: integrity check on gzip file failed (file transfer failed or ". + "file in URL not in gzip format?).") + if (system("gzip", "-t", "$archive")); + + # Decompress it. + system("gzip", "-d", "$archive") + and clean_exit("$url: unable to uncompress $archive."); + + # Suffix has now changed from .tar.gz|.tgz to .tar. + $archive =~ s/\.gz$//; + + # Make sure the .tar file now exists. + # (Gzip may not return an error if it was not a gzipped file...) + clean_exit("$url: failed to unpack gzip file (file transfer failed or ". + "file in URL not in tar'ed gzip format?).") + unless (-e "$archive"); + + my $stdout_file = "$tmpdir/tar_content.out"; + + open(OLDOUT, ">&STDOUT") or clean_exit("could not dup STDOUT: $!"); + open(STDOUT, ">$stdout_file") or clean_exit("could not redirect STDOUT: $!"); + + my $ret = system("tar", "tf", "$archive"); + + close(STDOUT); + open(STDOUT, ">&OLDOUT") or clean_exit("could not dup STDOUT: $!"); + close(OLDOUT); + + clean_exit("$url: could not list files in tar archive (is it broken?)") + if ($ret); + + open(TAR, "$stdout_file") or clean_exit("failed to open $stdout_file: $!"); + @tar_content = ; + close(TAR); + + # use_external_bins=0 + } else { + $tar = Archive::Tar->new($archive, 1); + clean_exit("$url: failed to read $archive (file transfer failed or ". + "file in URL not in tar'ed gzip format?).") + unless (defined($tar)); + @tar_content = $tar->list_files(); + } + + # Make sure we could grab some content from the tarball. + clean_exit("$url: could not list files in tar archive (is it broken?)") + if ($#tar_content < 0); + + # For each filename in the archive, do some basic sanity checks. + foreach my $filename (@tar_content) { + chomp($filename); + + # We don't want absolute filename. + clean_exit("$url: rules archive contains absolute filename. ". + "Offending file/line:\n$filename") + if ($filename =~ /^\//); + + # We don't want to have any weird characters anywhere in the filename. + clean_exit("$url: illegal character in filename in tar archive. Allowed are ". + "$OK_PATH_CHARS\nOffending file/line:\n$filename") + if ($config{use_path_checks} && $filename =~ /[^$OK_PATH_CHARS]/); + + # We don't want to unpack any "../../" junk (check is useless now though). + clean_exit("$url: filename in tar archive contains \"..\".\n". + "Offending file/line:\n$filename") + if ($filename =~ /\.\./); + } + + # Looks good. Now we can untar it. + print STDERR "Archive successfully downloaded, unpacking... " + unless ($config{quiet}); + + if ($config{use_external_bins}) { + clean_exit("failed to untar $archive.") + if system("tar", "xf", "$archive"); + } else { + mkdir("$rules_dir") or clean_exit("could not create \"$rules_dir\" directory: $!\n"); + foreach my $file ($tar->list_files) { + next unless ($file =~ /^$rules_dir\/[^\/]+$/); # only ^rules/$ + + my $content = $tar->get_content($file); + + # Symlinks in the archive will make get_content return undef. + clean_exit("could not get content from file \"$file\" in downloaded archive, ". + "make sure it is a regular file\n") + unless (defined($content)); + + open(RULEFILE, ">", "$file") + or clean_exit("could not open \"$file\" for writing: $!\n"); + print RULEFILE $content; + close(RULEFILE); + } + } + + # Make sure that non-empty rules directory existed in archive. + # We permit empty rules directory if min_files is set to 0 though. + clean_exit("$url: no \"$rules_dir\" directory found in tar file.") + unless (-d "$dir/$rules_dir"); + + my $num_files = 0; + opendir(RULESDIR, "$dir/$rules_dir") + or clean_exit("could not open directory \"$dir/$rules_dir\": $!"); + + while ($_ = readdir(RULESDIR)) { + next if (/^\.\.?$/); + $num_files++; + } + + closedir(RULESDIR); + + clean_exit("$url: directory \"$rules_dir\" in unpacked archive is empty") + if ($num_files == 0 && $config{min_files} != 0); + + chdir($old_dir) + or clean_exit("could not change directory back to $old_dir: $!"); + + print STDERR "done.\n" + unless ($config{quiet}); +} + + + +# Open all rules files in the temporary directory and disable/modify all +# rules/lines as requested in oinkmaster.conf, and then write back to the +# same files. Also clean unwanted whitespaces and duplicate sids from them. +sub process_rules($ $ $ $ $ $) +{ + my $modify_sid_ref = shift; + my $disable_sid_ref = shift; + my $enable_sid_ref = shift; + my $local_sid_ref = shift; + my $rh_tmp_ref = shift; + my $newfiles_ref = shift; + my %sids; + + my %stats = ( + disabled => 0, + enabled => 0, + modified => 0, + total => 0, + ); + + warn("WARNING: all rules that are disabled by default will be enabled\n") + if ($config{enable_all} && !$config{quiet}); + + print STDERR "Processing downloaded rules... " + unless ($config{quiet}); + + print STDERR "\n" + if ($config{verbose}); + + # Phase #1 - process all active rules and store in temporary hash. + # In case of dups, we use the one with the highest rev. + foreach my $file (sort(keys(%$newfiles_ref))) { + + open(INFILE, "<", "$file") + or clean_exit("could not open $file for reading: $!"); + my @infile = ; + close(INFILE); + + my ($single, $multi, $nonrule, $msg, $sid); + + RULELOOP:while (get_next_entry(\@infile, \$single, \$multi, \$nonrule, \$msg, \$sid)) { + + # We don't care about non-rules in this phase. + next RULELOOP if (defined($nonrule)); + + # Even if it was a single-line rule, we want a copy in $multi. + $multi = $single unless (defined($multi)); + + my %rule = ( + single => $single, + multi => $multi, + ); + + # modify/disable/enable this rule as requested unless there is a matching + # localsid statement. Possible verbose messages and warnings will be printed. + unless (exists($$local_sid_ref{$sid})) { + process_rule($modify_sid_ref, $disable_sid_ref, $enable_sid_ref, + \%rule, $sid, \%stats, 1, basename($file)); + } + + $stats{total}++; + + $single = $rule{single}; + $multi = $rule{multi}; + + # Only care about active rules in this phase (the rule may have been + # disabled by a disablesid or a modifysid statement above, so we can't + # do this check earlier). + next RULELOOP if ($multi =~ /^#/); + + # Is it a dup? If so, see if this seems to be more recent (higher rev). + if (exists($sids{$sid})) { + warn("\nWARNING: duplicate SID in downloaded archive, SID=$sid, ". + "only keeping rule with highest 'rev'\n") + unless($config{super_quiet}); + + my ($old_rev) = ($sids{$sid}{single} =~ /\brev\s*:\s*(\d+)\s*;/); + my ($new_rev) = ($single =~ /\brev\s*:\s*(\d+)\s*;/); + + # This is so rules with a rev gets higher prio than + # rules without any rev. + $old_rev = -1 unless (defined($old_rev)); + $new_rev = -1 unless (defined($new_rev)); + + # If this rev is higher than the one in the last stored rule with + # this sid, replace rule with this one. This is also done if the + # revs are equal because we assume the rule appearing last in the + # rules file is the more recent rule. + if ($new_rev >= $old_rev) { + $sids{$sid}{single} = $single; + $sids{$sid}{multi} = $multi; + } + + # No dup. + } else { + $sids{$sid}{single} = $single; + $sids{$sid}{multi} = $multi; + } + } + } + + # Phase #2 - read all rules files again, but when writing active rules + # back to the files, use the one stored in the sid hash (which is free of dups). + foreach my $file (sort(keys(%$newfiles_ref))) { + + open(INFILE, "<", "$file") + or clean_exit("could not open $file for reading: $!"); + my @infile = ; + close(INFILE); + + # Write back to the same file. + open(OUTFILE, ">", "$file") + or clean_exit("could not open $file for writing: $!"); + + my ($single, $multi, $nonrule, $msg, $sid); + + RULELOOP:while (get_next_entry(\@infile, \$single, \$multi, \$nonrule, \$msg, \$sid)) { + if (defined($nonrule)) { + print OUTFILE "$nonrule"; + next RULELOOP; + } + + # Even if it was a single-line rule, we want a copy in $multi. + $multi = $single unless (defined($multi)); + + # If this rule is marked as localized and has not yet been written, + # write the old version to the new rules file. + if (exists($$local_sid_ref{$sid}) && !exists($sids{$sid}{printed})) { + + # Just ignore the rule in the downloaded file if it doesn't + # exist in the same local file. + unless(exists($$rh_tmp_ref{old}{rules}{basename($file)}{$sid})) { + warn("WARNING: SID $sid is marked as local and exists in ". + "downloaded " . basename($file) . " but the SID does not ". + "exist in the local file, ignoring rule\n") + if ($config{verbose}); + + next RULELOOP; + } + + print OUTFILE $$rh_tmp_ref{old}{rules}{basename($file)}{$sid}; + $sids{$sid}{printed} = 1; + + warn("SID $sid is marked as local, keeping your version from ". + basename($file) . ".\n". + "Your version: $$rh_tmp_ref{old}{rules}{basename($file)}{$sid}". + "Downloaded version: $multi\n") + if ($config{verbose}); + + next RULELOOP; + } + + my %rule = ( + single => $single, + multi => $multi, + ); + + # modify/disable/enable this rule. Possible verbose messages and warnings + # will not be printed (again) as this was done in the first phase. + # We send the stats to a dummy var as this was collected on the + # first phase as well. + process_rule($modify_sid_ref, $disable_sid_ref, $enable_sid_ref, + \%rule, $sid, \my %unused_stats, 0, basename($file)); + + $single = $rule{single}; + $multi = $rule{multi}; + + # Disabled rules are printed right back to the file, unless + # there also is an active rule with the same sid. Als o make + # sure we only print the sid once, even though it's disabled. + if ($multi =~ /^#/ && !exists($sids{$sid}) && !exists($sids{$sid}{printed})) { + print OUTFILE $multi; + $sids{$sid}{printed} = 1; + next RULELOOP; + } + + # If this sid has not yet been printed and this is the place where + # the sid with the highest rev was, print the rule to the file. + # (There can be multiple totally different rules with the same sid + # and we don't want to put the wrong rule in the wrong place. + if (!exists($sids{$sid}{printed}) && $single eq $sids{$sid}{single}) { + print OUTFILE $multi; + $sids{$sid}{printed} = 1; + } + } + + close(OUTFILE); + } + + print STDERR "disabled $stats{disabled}, enabled $stats{enabled}, ". + "modified $stats{modified}, total=$stats{total}\n" + unless ($config{quiet}); + + # Print warnings on attempt at enablesid/disablesid/localsid on non-existent + # rule if we're in verbose mode. + if ($config{verbose}) { + foreach my $sid (keys(%$enable_sid_ref)) { + warn("WARNING: attempt to use \"enablesid\" on non-existent SID $sid\n") + unless (exists($sids{$sid})); + } + + foreach my $sid (keys(%$disable_sid_ref)) { + warn("WARNING: attempt to use \"disablesid\" on non-existent SID $sid\n") + unless (exists($sids{$sid})); + } + + foreach my $sid (keys(%$local_sid_ref)) { + warn("WARNING: attempt to use \"localsid\" on non-existent SID $sid\n") + unless (exists($sids{$sid})); + } + } + + # Print warnings on attempt at modifysid'ing non-existent stuff, unless quiet mode. + unless ($config{quiet}) { + my %new_files; + foreach my $file (sort(keys(%$newfiles_ref))) { + $new_files{basename($file)} = 1; + } + + my %mod_tmp; + foreach my $mod_expr (@$modify_sid_ref) { + my ($type, $arg) = ($mod_expr->[2], $mod_expr->[3]); + $mod_tmp{$type}{$arg} = 1; + } + + foreach my $sid (keys(%{$mod_tmp{sid}})) { + warn("WARNING: attempt to use \"modifysid\" on non-existent SID $sid\n") + unless (exists($sids{$sid})); + } + + foreach my $file (keys(%{$mod_tmp{file}})) { + warn("WARNING: attempt to use \"modifysid\" on non-existent file $file\n") + unless(exists($new_files{$file})); + } + } + + # Return total number of valid rules. + return ($stats{total}); +} + + + +# Process (modify/enable/disable) a rule as requested. +sub process_rule($ $ $ $ $ $ $ $) +{ + my $modify_sid_ref = shift; + my $disable_sid_ref = shift; + my $enable_sid_ref = shift; + my $rule_ref = shift; + my $sid = shift; + my $stats_ref = shift; + my $print_messages = shift; + my $filename = shift; + + # Just for easier access. + my $single = $$rule_ref{single}; + my $multi = $$rule_ref{multi}; + + # Some rules may be commented out by default. + # Enable them if -e is specified (both single-line and multi-line, + # version, because we don't know which version one we're going to + # use below. + # Enable them if -e is specified. + if ($multi =~ /^#/ && $config{enable_all}) { + $multi =~ s/^#*//; + $multi =~ s/\n#*/\n/g; + $single =~ s/^#*//; + $$stats_ref{enabled}++; + } + + # Modify rule if requested. For disablesid/enablesid we work + # on the multi-line version of the rule (if exists). For + # modifysid that's no good since we don't know where in the + # rule the trailing backslashes and newlines are going to be + # and we don't want them to affect the regexp. + MOD_EXP:foreach my $mod_expr (@$modify_sid_ref) { + my ($subst, $repl, $type, $arg) = + ($mod_expr->[0], $mod_expr->[1], $mod_expr->[2], $mod_expr->[3]); + + my $print_modify_warnings = 0; + $print_modify_warnings = 1 if (!$config{super_quiet} && $print_messages && $type eq "sid"); + + if ($type eq "wildcard" || ($type eq "sid" && $sid eq $arg) || + ($type eq "file" && $filename eq $arg)) { + + if ($single =~ /$subst/si) { + print STDERR "Modifying rule, SID=$sid, filename=$filename, ". + "match type=$type, subst=$subst, ". + "repl=$repl\nBefore: $single" + if ($print_messages && $config{verbose}); + + + # If user specified a backreference but the regexp did not set $1 - don't modify rule. + if (!defined($1) && ($repl =~ /[^\\]\$\d+/ || $repl =~ /[^\\]\$\{\d+\}/ + || $repl =~ /^qq\/\$\d+/ || $repl =~ /^qq\/\$\{\d+\}/)) { + warn("WARNING: SID $sid matches modifysid expression \"$subst\" but ". + "backreference variable \$1 is undefined after match, ". + "keeping original rule\n") + if ($print_modify_warnings); + next MOD_EXP; + } + + # Do the substitution on the single-line version and put it + # back in $multi. + $single =~ s/$subst/$repl/eei; + $multi = $single; + + print STDERR "After: $single\n" + if ($print_messages && $config{verbose}); + + $$stats_ref{modified}++; + } else { + if ($print_modify_warnings) { + warn("WARNING: SID $sid does not match modifysid ". + "expression \"$subst\", keeping original rule\n"); + } + } + } + } + + # Disable rule if requested and it's not already disabled. + if (exists($$disable_sid_ref{$sid}) && $multi !~ /^\s*#/) { + $multi = "#$multi"; + $multi =~ s/\n([^#].+)/\n#$1/g; + $$stats_ref{disabled}++; + } + + # Enable rule if requested and it's not already enabled. + if (exists($$enable_sid_ref{$sid}) && $multi =~ /^\s*#/) { + $multi =~ s/^#+//; + $multi =~ s/\n#+(.+)/\n$1/g; + $$stats_ref{enabled}++; + } + + $$rule_ref{single} = $single; + $$rule_ref{multi} = $multi; +} + + + +# Setup rules hash. +# Format for rules will be: rh{old|new}{rules{filename}{sid} = single-line rule +# Format for non-rules will be: rh{old|new}{other}{filename} = array of lines +# List of added files will be stored as rh{added_files}{filename} +sub setup_rules_hash($ $) +{ + my $new_files_ref = shift; + my $output_dir = shift; + + my (%rh, %old_sids); + + print STDERR "Setting up rules structures... " + unless ($config{quiet}); + + foreach my $file (sort(keys(%$new_files_ref))) { + warn("\nWARNING: downloaded rules file $file is empty\n") + if (!-s "$file" && $config{verbose}); + + open(NEWFILE, "<", "$file") + or clean_exit("could not open $file for reading: $!"); + my @newfile = ; + close(NEWFILE); + + # From now on we don't care about the path, so remove it. + $file = basename($file); + + my ($single, $multi, $nonrule, $msg, $sid); + + while (get_next_entry(\@newfile, \$single, \$multi, \$nonrule, \$msg, \$sid)) { + if (defined($single)) { + $rh{new}{rules}{"$file"}{"$sid"} = $single; + } else { + push(@{$rh{new}{other}{"$file"}}, $nonrule); + } + } + + # Also read in old (aka local) file if it exists. + # We do a sid dup check in these files. + if (-f "$output_dir/$file") { + open(OLDFILE, "<", "$output_dir/$file") + or clean_exit("could not open $output_dir/$file for reading: $!"); + my @oldfile = ; + close(OLDFILE); + + while (get_next_entry(\@oldfile, \$single, \$multi, \$nonrule, undef, \$sid)) { + if (defined($single)) { + warn("\nWARNING: duplicate SID in your local rules, SID ". + "$sid exists multiple times, you may need to fix this manually!\n") + if (exists($old_sids{$sid})); + + $rh{old}{rules}{"$file"}{"$sid"} = $single; + $old_sids{$sid}++; + } else { + push(@{$rh{old}{other}{"$file"}}, $nonrule); + } + } + } else { + $rh{added_files}{"$file"}++; + } + } + + print STDERR "done.\n" + unless ($config{quiet}); + + return (%rh); +} + + + +# Return lines that exist only in first array but not in second one. +sub get_first_only($ $ $) +{ + my $first_only_ref = shift; + my $first_arr_ref = shift; + my $second_arr_ref = shift; + my %arr_hash; + + @arr_hash{@$second_arr_ref} = (); + + foreach my $line (@$first_arr_ref) { + + # Skip blank lines and CVS Id tags. + next unless ($line =~ /\S/); + next if ($line =~ /^\s*#+\s*\$I\S:.+Exp\s*\$/); + + push(@$first_only_ref, $line) + unless(exists($arr_hash{$line})); + } +} + + + +# Backup files in output dir matching $config{update_files} into the backup dir. +sub make_backup($ $) +{ + my $src_dir = shift; # dir with the rules to be backed up + my $dest_dir = shift; # where to put the backup tarball + + my ($sec, $min, $hour, $mday, $mon, $year) = (localtime)[0 .. 5]; + + my $date = sprintf("%4d%02d%02d-%02d%02d%02d", + $year + 1900, $mon + 1, $mday, $hour, $min, $sec); + + my $backup_tarball = "rules-backup-$date.tar"; + my $backup_tmp_dir = File::Spec->catdir("$tmpdir", "rules-backup-$date"); + my $dest_file = File::Spec->catfile("$dest_dir", "$backup_tarball.gz"); + + print STDERR "Creating backup of old rules..." + unless ($config{quiet}); + + mkdir("$backup_tmp_dir", 0700) + or clean_exit("could not create temporary backup directory $backup_tmp_dir: $!"); + + # Copy all rules files from the rules dir to the temporary backup dir. + opendir(OLDRULES, "$src_dir") + or clean_exit("could not open directory $src_dir: $!"); + + while ($_ = readdir(OLDRULES)) { + next if (/^\.\.?$/); + if (/$config{update_files}/) { + my $src_file = untaint_path("$src_dir/$_"); + copy("$src_file", "$backup_tmp_dir/") + or warn("WARNING: could not copy $src_file to $backup_tmp_dir/: $!"); + } + } + + closedir(OLDRULES); + + # Also backup the -U (as "variable-file.conf") if specified. + if ($config{update_vars}) { + copy("$config{varfile}", "$backup_tmp_dir/variable-file.conf") + or warn("WARNING: could not copy $config{varfile} to $backup_tmp_dir: $!") + } + + my $old_dir = untaint_path(File::Spec->rel2abs(File::Spec->curdir())); + + # Change directory to $tmpdir (so we'll be right below the directory where + # we have our rules to be backed up). + chdir("$tmpdir") or clean_exit("could not change directory to $tmpdir: $!"); + + if ($config{use_external_bins}) { + clean_exit("tar command returned error when archiving backup files.\n") + if (system("tar","cf","$backup_tarball","rules-backup-$date")); + + clean_exit("gzip command returned error when compressing backup file.\n") + if (system("gzip","$backup_tarball")); + + $backup_tarball .= ".gz"; + + } else { + my $tar = Archive::Tar->new; + opendir(RULES, "rules-backup-$date") + or clean_exit("unable to open directory \"rules-backup-$date\": $!"); + + while ($_ = readdir(RULES)) { + next if (/^\.\.?$/); + $tar->add_files("rules-backup-$date/$_"); + } + + closedir(RULES); + + $backup_tarball .= ".gz"; + + # Write tarball. Print stupid error message if it fails as + # we can't use $tar->error or Tar::error on all platforms. + $tar->write("$backup_tarball", 1); + + clean_exit("could not create backup archive: tarball empty after creation\n") + unless (-s "$backup_tarball"); + } + + # Change back to old directory (so it will work with -b as either + # an absolute or a relative path. + chdir("$old_dir") + or clean_exit("could not change directory back to $old_dir: $!"); + + copy("$tmpdir/$backup_tarball", "$dest_file") + or clean_exit("unable to copy $tmpdir/$backup_tarball to $dest_file/: $!\n"); + + print STDERR " saved as $dest_file.\n" + unless ($config{quiet}); +} + + + +# Print the results. +sub print_changes($ $) +{ + my $ch_ref = shift; + my $rh_ref = shift; + + my ($sec, $min, $hour, $mday, $mon, $year) = (localtime)[0 .. 5]; + + my $date = sprintf("%4d%02d%02d %02d:%02d:%02d", + $year + 1900, $mon + 1, $mday, $hour, $min, $sec); + + print "\n[***] Results from Oinkmaster started $date [***]\n"; + + # Print new variables. + if ($config{update_vars}) { + if ($#{$$ch_ref{new_vars}} > -1) { + print "\n[*] New variables: [*]\n"; + foreach my $var (@{$$ch_ref{new_vars}}) { + print " $var"; + } + } else { + print "\n[*] New variables: [*]\n None.\n" + unless ($config{super_quiet}); + } + } + + + # Print rules modifications. + print "\n[*] Rules modifications: [*]\n None.\n" + if (!keys(%{$$ch_ref{rules}}) && !$config{super_quiet}); + + # Print added rules. + if (exists($$ch_ref{rules}{added})) { + print "\n[+++] Added rules: [+++]\n"; + if ($config{summary_output}) { + print_summary_change(\%{$$ch_ref{rules}{added}}, $rh_ref); + } else { + print_changetype($PRINT_NEW, "Added to", + \%{$$ch_ref{rules}{added}}, $rh_ref); + } + } + + # Print enabled rules. + if (exists($$ch_ref{rules}{ena})) { + print "\n[+++] Enabled rules: [+++]\n"; + if ($config{summary_output}) { + print_summary_change(\%{$$ch_ref{rules}{ena}}, $rh_ref); + } else { + print_changetype($PRINT_NEW, "Enabled in", + \%{$$ch_ref{rules}{ena}}, $rh_ref); + } + } + + # Print enabled + modified rules. + if (exists($$ch_ref{rules}{ena_mod})) { + print "\n[+++] Enabled and modified rules: [+++]\n"; + if ($config{summary_output}) { + print_summary_change(\%{$$ch_ref{rules}{ena_mod}}, $rh_ref); + } else { + print_changetype($PRINT_BOTH, "Enabled and modified in", + \%{$$ch_ref{rules}{ena_mod}}, $rh_ref); + } + } + + # Print modified active rules. + if (exists($$ch_ref{rules}{mod_act})) { + print "\n[///] Modified active rules: [///]\n"; + + if ($config{summary_output}) { + print_summary_change(\%{$$ch_ref{rules}{mod_act}}, $rh_ref); + } else { + print_changetype($PRINT_BOTH, "Modified active in", + \%{$$ch_ref{rules}{mod_act}}, $rh_ref); + } + } + + # Print modified inactive rules. + if (exists($$ch_ref{rules}{mod_ina})) { + print "\n[///] Modified inactive rules: [///]\n"; + if ($config{summary_output}) { + print_summary_change(\%{$$ch_ref{rules}{mod_ina}}, $rh_ref); + } else { + print_changetype($PRINT_BOTH, "Modified inactive in", + \%{$$ch_ref{rules}{mod_ina}}, $rh_ref); + } + } + + # Print disabled + modified rules. + if (exists($$ch_ref{rules}{dis_mod})) { + print "\n[---] Disabled and modified rules: [---]\n"; + if ($config{summary_output}) { + print_summary_change(\%{$$ch_ref{rules}{dis_mod}}, $rh_ref); + } else { + print_changetype($PRINT_BOTH, "Disabled and modified in", + \%{$$ch_ref{rules}{dis_mod}}, $rh_ref); + } + } + + # Print disabled rules. + if (exists($$ch_ref{rules}{dis})) { + print "\n[---] Disabled rules: [---]\n"; + if ($config{summary_output}) { + print_summary_change(\%{$$ch_ref{rules}{dis}}, $rh_ref); + } else { + print_changetype($PRINT_NEW, "Disabled in", + \%{$$ch_ref{rules}{dis}}, $rh_ref); + } + } + + # Print removed rules. + if (exists($$ch_ref{rules}{removed})) { + print "\n[---] Removed rules: [---]\n"; + if ($config{summary_output}) { + print_summary_change(\%{$$ch_ref{rules}{removed}}, $rh_ref); + } else { + print_changetype($PRINT_OLD, "Removed from", + \%{$$ch_ref{rules}{removed}}, $rh_ref); + } + } + + + # Print non-rule modifications. + print "\n[*] Non-rule line modifications: [*]\n None.\n" + if (!keys(%{$$ch_ref{other}}) && !$config{super_quiet}); + + # Print added non-rule lines. + if (exists($$ch_ref{other}{added})) { + print "\n[+++] Added non-rule lines: [+++]\n"; + foreach my $file (sort({uc($a) cmp uc($b)} keys(%{$$ch_ref{other}{added}}))) { + my $num = $#{$$ch_ref{other}{added}{$file}} + 1; + print "\n -> Added to $file ($num):\n"; + foreach my $line (@{$$ch_ref{other}{added}{$file}}) { + print " $line"; + } + } + } + + # Print removed non-rule lines. + if (keys(%{$$ch_ref{other}{removed}}) > 0) { + print "\n[---] Removed non-rule lines: [---]\n"; + foreach my $file (sort({uc($a) cmp uc($b)} keys(%{$$ch_ref{other}{removed}}))) { + my $num = $#{$$ch_ref{other}{removed}{$file}} + 1; + print "\n -> Removed from $file ($num):\n"; + foreach my $other (@{$$ch_ref{other}{removed}{$file}}) { + print " $other"; + } + } + } + + + # Print list of added files. + if (keys(%{$$ch_ref{added_files}})) { + print "\n[+] Added files (consider updating your snort.conf to include them if needed): [+]\n\n"; + foreach my $added_file (sort({uc($a) cmp uc($b)} keys(%{$$ch_ref{added_files}}))) { + print " -> $added_file\n"; + } + } else { + print "\n[*] Added files: [*]\n None.\n" + unless ($config{super_quiet} || $config{summary_output}); + } + + # Print list of possibly removed files if requested. + if ($config{check_removed}) { + if (keys(%{$$ch_ref{removed_files}})) { + print "\n[-] Files possibly removed from the archive ". + "(consider removing them from your snort.conf if needed): [-]\n\n"; + foreach my $removed_file (sort({uc($a) cmp uc($b)} keys(%{$$ch_ref{removed_files}}))) { + print " -> $removed_file\n"; + } + } else { + print "\n[*] Files possibly removed from the archive: [*]\n None.\n" + unless ($config{super_quiet} || $config{summary_output}); + } + } + + print "\n"; +} + + + +# Helper for print_changes(). +sub print_changetype($ $ $ $) +{ + my $type = shift; # $PRINT_OLD|$PRINT_NEW|$PRINT_BOTH + my $string = shift; # string to print before filename + my $ch_ref = shift; # reference to an entry in the rules changes hash + my $rh_ref = shift; # reference to rules hash + + foreach my $file (sort({uc($a) cmp uc($b)} keys(%$ch_ref))) { + my $num = keys(%{$$ch_ref{$file}}); + print "\n -> $string $file ($num):\n"; + foreach my $sid (keys(%{$$ch_ref{$file}})) { + if ($type == $PRINT_OLD) { + print " $$rh_ref{old}{rules}{$file}{$sid}" + } elsif ($type == $PRINT_NEW) { + print " $$rh_ref{new}{rules}{$file}{$sid}" + } elsif ($type == $PRINT_BOTH) { + + my $old = $$rh_ref{old}{rules}{$file}{$sid}; + my $new = $$rh_ref{new}{rules}{$file}{$sid}; + + if ($config{minimize_diff}) { + my ($old, $new) = minimize_diff($old, $new); + print "\n old SID $sid: $old"; + print " new SID $sid: $new"; + } else { + print "\n old: $old"; + print " new: $new"; + } + } + } + } +} + + + +# Print changes in bmc style, i.e. only sid and msg, no full details. +sub print_summary_change($ $) +{ + my $ch_ref = shift; # reference to an entry in the rules changes hash + my $rh_ref = shift; # reference to rules hash + + my (@sids, %sidmap); + + print "\n"; + + # First get all the sids (may be spread across multiple files. + foreach my $file (keys(%$ch_ref)) { + foreach my $sid (keys(%{$$ch_ref{$file}})) { + push(@sids, $sid); + if (exists($$rh_ref{new}{rules}{$file}{$sid})) { + $sidmap{$sid}{rule} = $$rh_ref{new}{rules}{$file}{$sid}; + } else { + $sidmap{$sid}{rule} = $$rh_ref{old}{rules}{$file}{$sid}; + } + $sidmap{$sid}{file} = $file; + } + } + + # Print rules, sorted by sid. + foreach my $sid (sort {$a <=> $b} (@sids)) { + my @rule = $sidmap{$sid}{rule}; + my $file = $sidmap{$sid}{file}; + get_next_entry(\@rule, undef, undef, undef, \(my $msg), undef); + printf("%8d - %s (%s)\n", $sid, $msg, $file); + } + + print "\n"; +} + + + +# Compare the new rules to the old ones. +sub get_changes($ $ $) +{ + my $rh_ref = shift; + my $new_files_ref = shift; + my $rules_dir = shift; + my %changes; + + print STDERR "Comparing new files to the old ones... " + unless ($config{quiet}); + + # We have the list of added files (without full path) in $rh_ref{added_files} + # but we'd rather want to have it in $changes{added_files} now. + $changes{added_files} = $$rh_ref{added_files}; + + # New files are also regarded as modified since we want to update + # (i.e. add) those as well. Here we want them with full path. + foreach my $file (keys(%{$changes{added_files}})) { + $changes{modified_files}{"$tmpdir/$rules_dir/$file"}++; + } + + # Add list of possibly removed files if requested. + if ($config{check_removed}) { + opendir(OLDRULES, "$config{output_dir}") + or clean_exit("could not open directory $config{output_dir}: $!"); + + while ($_ = readdir(OLDRULES)) { + next if (/^\.\.?$/); + $changes{removed_files}{"$_"} = 1 + if (/$config{update_files}/ && + !exists($config{file_ignore_list}{$_}) && + !-e "$tmpdir/$rules_dir/$_"); + } + + closedir(OLDRULES); + } + + # For each new rules file... + FILELOOP:foreach my $file_w_path (sort(keys(%$new_files_ref))) { + my $file = basename($file_w_path); + + # Skip comparison if it's an added file. + next FILELOOP if (exists($$rh_ref{added_files}{$file})); + + # For each sid in the new file... + foreach my $sid (keys(%{$$rh_ref{new}{rules}{$file}})) { + my $new_rule = $$rh_ref{new}{rules}{$file}{$sid}; + + # Sid also exists in the old file? + if (exists($$rh_ref{old}{rules}{$file}{$sid})) { + my $old_rule = $$rh_ref{old}{rules}{$file}{$sid}; + + # Are they identical? + unless ($new_rule eq $old_rule) { + $changes{modified_files}{$file_w_path}++; + + # Find out in which way the rules are different. + if ("#$old_rule" eq $new_rule) { + $changes{rules}{dis}{$file}{$sid}++; + } elsif ($old_rule eq "#$new_rule") { + $changes{rules}{ena}{$file}{$sid}++; + } elsif ($old_rule =~ /^\s*#/ && $new_rule !~ /^\s*#/) { + $changes{rules}{ena_mod}{$file}{$sid}++; + } elsif ($old_rule !~ /^\s*#/ && $new_rule =~ /^\s*#/) { + $changes{rules}{dis_mod}{$file}{$sid}++; + } elsif ($old_rule =~ /^\s*#/ && $new_rule =~ /^\s*#/) { + $changes{rules}{mod_ina}{$file}{$sid}++; + } else { + $changes{rules}{mod_act}{$file}{$sid}++; + } + + } + } else { # sid not found in old file, i.e. it's added + $changes{modified_files}{$file_w_path}++; + $changes{rules}{added}{$file}{$sid}++; + } + } # foreach sid + + # Check for removed rules, i.e. sids that exist in the old file but + # not in the new one. + foreach my $sid (keys(%{$$rh_ref{old}{rules}{$file}})) { + unless (exists($$rh_ref{new}{rules}{$file}{$sid})) { + $changes{modified_files}{$file_w_path}++; + $changes{rules}{removed}{$file}{$sid}++; + } + } + + # Check for added non-rule lines. + get_first_only(\my @added, + \@{$$rh_ref{new}{other}{$file}}, + \@{$$rh_ref{old}{other}{$file}}); + + if (scalar(@added)) { + @{$changes{other}{added}{$file}} = @added; + $changes{modified_files}{$file_w_path}++; + } + + # Check for removed non-rule lines. + get_first_only(\my @removed, + \@{$$rh_ref{old}{other}{$file}}, + \@{$$rh_ref{new}{other}{$file}}); + + if (scalar(@removed)) { + @{$changes{other}{removed}{$file}} = @removed; + $changes{modified_files}{$file_w_path}++; + } + + } # foreach new file + + print STDERR "done.\n" unless ($config{quiet}); + + return (%changes); +} + + + +# Simply copy the modified rules files to the output directory. +sub update_rules($ @) +{ + my $dst_dir = shift; + my @modified_files = @_; + + print STDERR "Updating local rules files... " + if (!$config{quiet} || $config{interactive}); + + foreach my $file_w_path (@modified_files) { + copy("$file_w_path", "$dst_dir") + or clean_exit("could not copy $file_w_path to $dst_dir: $!"); + } + + print STDERR "done.\n" + if (!$config{quiet} || $config{interactive}); +} + + +# Simply copy rules files from one dir to another. +# Links are not allowed. +sub copy_rules($ $) +{ + my $src_dir = shift; + my $dst_dir = shift; + + print STDERR "Copying rules from $src_dir... " + if (!$config{quiet} || $config{interactive}); + + opendir(SRC_DIR, $src_dir) + or clean_exit("could not open directory $src_dir: $!"); + + my $num_files = 0; + while ($_ = readdir(SRC_DIR)) { + next if (/^\.\.?$/ || exists($config{file_ignore_list}{$_}) + || !/$config{update_files}/); + + my $src_file = untaint_path("$src_dir/$_"); + + # Make sure it's a regular file. + unless (-f "$src_file" && !-l "$src_file") { + closedir(SRC_DIR); + clean_exit("\"$src_file\" is not a regular file.") + } + + unless (copy($src_file, $dst_dir)) { + closedir(SRC_DIR); + clean_exit("could not copy \"$src_file\" to \"$dst_dir\"/: $!"); + } + $num_files++; + } + + closedir(SRC_DIR); + + print STDERR "$num_files files copied.\n" + if (!$config{quiet} || $config{interactive}); +} + + + +# Return true if file is in PATH and is executable. +sub is_in_path($) +{ + my $file = shift; + + foreach my $dir (File::Spec->path()) { + if ((-f "$dir/$file" && -x "$dir/$file") + || (-f "$dir/$file.exe" && -x "$dir/$file.exe")) { + print STDERR "Found $file binary in $dir\n" + if ($config{verbose}); + return (1); + } + } + + return (0); +} + + + +# get_next_entry() will parse the array referenced in the first arg +# and return the next entry. The array should contain a rules file, +# and the returned entry will be removed from the array. +# An entry is one of: +# - single-line rule (put in 2nd ref) +# - multi-line rule (put in 3rd ref) +# - non-rule line (put in 4th ref) +# If the entry is a multi-line rule, its single-line version is also +# returned (put in the 2nd ref). +# If it's a rule, the msg string will be put in 4th ref and sid in 5th. +sub get_next_entry($ $ $ $ $ $) +{ + my $arr_ref = shift; + my $single_ref = shift; + my $multi_ref = shift; + my $nonrule_ref = shift; + my $msg_ref = shift; + my $sid_ref = shift; + + undef($$single_ref); + undef($$multi_ref); + undef($$nonrule_ref); + undef($$msg_ref); + undef($$sid_ref); + + my $line = shift(@$arr_ref) || return(0); + my $disabled = 0; + my $broken = 0; + + chomp($line); + $line .= "\n"; + + # Possible beginning of multi-line rule? + if ($line =~ /$MULTILINE_RULE_REGEXP/oi) { + $$single_ref = $line; + $$multi_ref = $line; + + $disabled = 1 if ($line =~ /^\s*#/); + + # Keep on reading as long as line ends with "\". + while (!$broken && $line =~ /\\\s*\n$/) { + + # Remove trailing "\" and newline for single-line version. + $$single_ref =~ s/\\\s*\n//; + + # If there are no more lines, this can not be a valid multi-line rule. + if (!($line = shift(@$arr_ref))) { + + warn("\nWARNING: got EOF while parsing multi-line rule: $$multi_ref\n") + if ($config{verbose}); + + @_ = split(/\n/, $$multi_ref); + + undef($$multi_ref); + undef($$single_ref); + + # First line of broken multi-line rule will be returned as a non-rule line. + $$nonrule_ref = shift(@_) . "\n"; + $$nonrule_ref =~ s/\s*\n$/\n/; # remove trailing whitespaces + + # The rest is put back to the array again. + foreach $_ (reverse((@_))) { + unshift(@$arr_ref, "$_\n"); + } + + return (1); # return non-rule + } + + # Multi-line continuation. + $$multi_ref .= $line; + + # If there are non-comment lines in the middle of a disabled rule, + # mark the rule as broken to return as non-rule lines. + if ($line !~ /^\s*#/ && $disabled) { + $broken = 1; + } elsif ($line =~ /^\s*#/ && !$disabled) { + # comment line (with trailing slash) in the middle of an active rule - ignore it + } else { + $line =~ s/^\s*#*\s*//; # remove leading # in single-line version + $$single_ref .= $line; + } + + } # while line ends with "\" + + # Single-line version should now be a valid rule. + # If not, it wasn't a valid multi-line rule after all. + if (!$broken && parse_singleline_rule($$single_ref, $msg_ref, $sid_ref)) { + + $$single_ref =~ s/^\s*//; # remove leading whitespaces + $$single_ref =~ s/^#+\s*/#/; # remove whitespaces next to leading # + $$single_ref =~ s/\s*\n$/\n/; # remove trailing whitespaces + + $$multi_ref =~ s/^\s*//; + $$multi_ref =~ s/\s*\n$/\n/; + $$multi_ref =~ s/^#+\s*/#/; + + return (1); # return multi + + # Invalid multi-line rule. + } else { + warn("\nWARNING: invalid multi-line rule: $$single_ref\n") + if ($config{verbose} && $$multi_ref !~ /^\s*#/); + + @_ = split(/\n/, $$multi_ref); + + undef($$multi_ref); + undef($$single_ref); + + # First line of broken multi-line rule will be returned as a non-rule line. + $$nonrule_ref = shift(@_) . "\n"; + $$nonrule_ref =~ s/\s*\n$/\n/; # remove trailing whitespaces + + # The rest is put back to the array again. + foreach $_ (reverse((@_))) { + unshift(@$arr_ref, "$_\n"); + } + + return (1); # return non-rule + } + + # Check if it's a regular single-line rule. + } elsif (parse_singleline_rule($line, $msg_ref, $sid_ref)) { + $$single_ref = $line; + $$single_ref =~ s/^\s*//; + $$single_ref =~ s/^#+\s*/#/; + $$single_ref =~ s/\s*\n$/\n/; + + return (1); # return single + + # Non-rule line. + } else { + + # Do extra check and warn if it *might* be a rule anyway, + # but that we just couldn't parse for some reason. + warn("\nWARNING: line may be a rule but it could not be parsed ". + "(missing sid?): $line\n") + if ($config{verbose} && $line =~ /^\s*alert .+msg\s*:\s*".+"\s*;/); + + $$nonrule_ref = $line; + $$nonrule_ref =~ s/\s*\n$/\n/; + + return (1); # return non-rule + } +} + + + +# Look for variables that exist in dist var files but not in local var file. +sub get_new_vars($ $ $ $) +{ + my $ch_ref = shift; + my $dist_var_files_ref = shift; + my $local_var_file = shift; + my $url_tmpdirs_ref = shift; + + my %new_vars; + my (%old_vars, %dist_var_files, %found_dist_var_files); + my $confs_found = 0; + + + # Warn in case we can't find a specified dist file. + foreach my $dir (@$url_tmpdirs_ref) { + foreach my $dist_var_file (@$dist_var_files_ref) { + if (-e "$dir/$dist_var_file") { + $found_dist_var_files{$dist_var_file} = 1; + $confs_found++; + } + } + } + + foreach my $dist_var_file (@$dist_var_files_ref) { + unless (exists($found_dist_var_files{$dist_var_file})) { + warn("WARNING: did not find variable file \"$dist_var_file\" in ". + "downloaded archive(s)\n") + unless($config{quiet}); + } + } + + unless ($confs_found) { + unless ($config{quiet}) { + warn("WARNING: no variable files found in downloaded archive(s), ". + "aborting check for new variables\n"); + return; + } + } + + # Read in variable names from old (target) var file. + open(LOCAL_VAR_FILE, "<", "$local_var_file") + or clean_exit("could not open $local_var_file for reading: $!"); + + my @local_var_conf = ; + + foreach $_ (join_multilines(\@local_var_conf)) { + $old_vars{lc($1)}++ if (/$VAR_REGEXP/i); + } + + close(LOCAL_VAR_FILE); + + # Read in variables from new file(s). + foreach my $dir (@$url_tmpdirs_ref) { + foreach my $dist_var_file (@$dist_var_files_ref) { + my $conf = "$dir/$dist_var_file"; + if (-e "$conf") { + my $num_new = 0; + print STDERR "Checking downloaded $dist_var_file for new variables... " + unless ($config{quiet}); + + open(DIST_CONF, "<", "$conf") + or clean_exit("could not open $conf for reading: $!"); + my @dist_var_conf = ; + close(DIST_CONF); + + foreach $_ (join_multilines(\@dist_var_conf)) { + if (/$VAR_REGEXP/i && !exists($old_vars{lc($1)})) { + my ($varname, $varval) = (lc($1), $2); + if (exists($new_vars{$varname})) { + warn("\nWARNING: new variable \"$varname\" is defined multiple ". + "times in downloaded files\n"); + } + s/^\s*//; + push(@{$$ch_ref{new_vars}}, "$_\n"); + $new_vars{$varname} = $varval; + $num_new++; + } + } + + close(DIST_CONF); + print STDERR "$num_new new found.\n" + unless ($config{quiet}); + } + } + } +} + + + +# Add new variables to local snort.conf. +sub add_new_vars($ $) +{ + my $ch_ref = shift; + my $varfile = shift; + my $tmp_varfile = "$tmpdir/tmp_varfile.conf"; + my $new_content; + + return unless ($#{$changes{new_vars}} > -1); + + print STDERR "Adding new variables to $varfile... " + unless ($config{quiet}); + + open(OLD_LOCAL_CONF, "<", "$varfile") + or clean_exit("could not open $varfile for reading: $!"); + my @old_content = ; + close(OLD_LOCAL_CONF); + + open(NEW_LOCAL_CONF, ">", "$tmp_varfile") + or clean_exit("could not open $tmp_varfile for writing: $!"); + + my @old_vars = grep(/$VAR_REGEXP/i, @old_content); + + + # If any vars exist in old file, put new vars right after them. + if ($#old_vars > -1) { + while ($_ = shift(@old_content)) { + print NEW_LOCAL_CONF $_; + last if ($_ eq $old_vars[$#old_vars]); + } + } + + print NEW_LOCAL_CONF @{$changes{new_vars}}; + print NEW_LOCAL_CONF @old_content; + + close(NEW_LOCAL_CONF); + + clean_exit("could not copy $tmp_varfile to $varfile: $!") + unless (copy("$tmp_varfile", "$varfile")); + + print STDERR "done.\n" + unless ($config{quiet}); +} + + + +# Convert msdos style path to cygwin style, e.g. +# c:\foo => /cygdrive/c/foo +sub msdos_to_cygwin_path($) +{ + my $path_ref = shift; + + if ($$path_ref =~ /^([a-zA-Z]):[\/\\](.*)/) { + my ($drive, $dir) = ($1, $2); + $dir =~ s/\\/\//g; + $$path_ref = "/cygdrive/$drive/$dir"; + return (1); + } + + return (0); +} + + + +# Parse and process a modifysid expression. +# Return 1 if valid, or otherwise 0. +sub parse_mod_expr($ $ $ $) +{ + my $mod_list_ref = shift; # where to store valid entries + my $sid_arg_list = shift; # comma-separated list of SIDs/files or wildcard + my $subst = shift; # regexp to look for + my $repl = shift; # regexp to replace it with + + my @tmp_mod_list; + + $sid_arg_list =~ s/\s+$//; + + foreach my $sid_arg (split(/\s*,\s*/, $sid_arg_list)) { + my $type = ""; + + $type = "sid" if ($sid_arg =~ /^\d+$/); + $type = "file" if ($sid_arg =~ /^\S+.*\.\S+$/); + $type = "wildcard" if ($sid_arg eq "*"); + + return (0) unless ($type); + + # Sanity check to make sure user escaped at least all the "$" in $subst. + if ($subst =~ /[^\\]\$./ || $subst =~ /^\$/) { + warn("WARNING: unescaped \$ in expression \"$subst\", all special ". + "characters must be escaped\n"); + return (0); + } + + # Only allow backreference variables. The check should at least catch some user typos. + if (($repl =~ /[^\\]\$(\D.)/ && $1 !~ /{\d/) || $repl =~ /[^\\]\$$/ + || ($repl =~ /^\$(\D.)/ && $1 !~ /{\d/)) { + warn("WARNING: illegal replacement expression \"$repl\": unescaped \$ ". + "that isn't a backreference\n"); + return (0); + } + + # Don't permit unescaped @. + if ($repl =~ /[^\\]\@/ || $repl =~ /^\@/) { + warn("WARNING: illegal replacement expression \"$repl\": unescaped \@\n"); + return (0); + } + + # Make sure the regexp is valid. + my $repl_qq = "qq/$repl/"; + my $dummy = "foo"; + + eval { + $dummy =~ s/$subst/$repl_qq/ee; + }; + + # We should probably check for warnings as well as errors... + if ($@) { + warn("Invalid regexp: $@"); + return (0); + } + + push(@tmp_mod_list, [$subst, $repl_qq, $type, $sid_arg]); + } + + # If we come this far, all sids and the regexp were parsed successfully, so + # append them to real mod list array. + foreach my $mod_entry (@tmp_mod_list) { + push(@$mod_list_ref, $mod_entry); + } + + return (1); +} + + + +# Untaint a path. Die if it contains illegal chars. +sub untaint_path($) +{ + my $path = shift; + my $orig_path = $path; + + return $path unless ($config{use_path_checks}); + + (($path) = $path =~ /^([$OK_PATH_CHARS]+)$/) + or clean_exit("illegal character in path/filename ". + "\"$orig_path\", allowed are $OK_PATH_CHARS\n". + "Fix this or set use_path_checks=0 in oinkmaster.conf ". + "to disable this check completely if it is too strict.\n"); + + return ($path); +} + + + +# Ask user to approve changes. Return 1 for yes, 0 for no. +sub approve_changes() +{ + my $answer = ""; + + while ($answer !~ /^[yn]/i) { + print "Do you approve these changes? [Yn] "; + $answer = ; + $answer = "y" unless ($answer =~ /\S/); + } + + return ($answer =~ /^y/i); +} + + + +# Remove common leading and trailing stuff from two rules. +sub minimize_diff($ $) +{ + my $old_rule = shift; + my $new_rule = shift; + + my $original_old = $old_rule; + my $original_new = $new_rule; + + # Additional chars to print next to the diffing part. + my $additional_chars = 20; + + # Remove the rev keyword from the rules, as it often + # makes the whole diff minimizing useless. + $old_rule =~ s/\s*\b(rev\s*:\s*\d+\s*;)\s*//; + my $old_rev = $1; + + $new_rule =~ s/\s*\b(rev\s*:\s*\d+\s*;)\s*//; + my $new_rev = $1; + + # If rev was the only thing that changed, we want to restore the rev + # before continuing so we don't remove common stuff from rules that + # are identical. + if ($old_rule eq $new_rule) { + $old_rule = $original_old; + $new_rule = $original_new; + } + + # Temporarily remove possible leading # so it works nicely + # with modified rules that are also being either enabled or disabled. + my $old_is_disabled = 0; + my $new_is_disabled = 0; + + $old_is_disabled = 1 if ($old_rule =~ s/^#//); + $new_is_disabled = 1 if ($new_rule =~ s/^#//); + + # Go forward char by char until they aren't equeal. + # $i will bet set to the index where they diff. + my @old = split(//, $old_rule); + my @new = split(//, $new_rule); + + my $i = 0; + while ($i <= $#old && $i <= $#new && $old[$i] eq $new[$i]) { + $i++; + } + + # Now same thing but backwards. + # $j will bet set to the index where they diff. + @old = reverse(split(//, $old_rule)); + @new = reverse(split(//, $new_rule)); + + my $j = 0; + while ($j <= $#old && $j <= $#new && $old[$j] eq $new[$j]) { + $j++; + } + + # Print some additional chars on either side, if there is room for it. + $i -= $additional_chars; + $i = 0 if ($i < 0); + + $j = -$j + $additional_chars; + $j = 0 if ($j > -1); + + my ($old, $new); + + # Print entire rules (i.e. they can not be shortened). + if (!$i && !$j) { + $old = $old_rule; + $new = $new_rule; + + # Leading and trailing stuff can be removed. + } elsif ($i && $j) { + $old = "..." . substr($old_rule, $i, $j) . "..."; + $new = "..." . substr($new_rule, $i, $j) . "..."; + + # Trailing stuff can be removed. + } elsif (!$i && $j) { + $old = substr($old_rule, $i, $j) . "..."; + $new = substr($new_rule, $i, $j) . "..."; + + # Leading stuff can be removed. + } elsif ($i && !$j) { + $old = "..." . substr($old_rule, $i); + $new = "..." . substr($new_rule, $i); + } + + chomp($old, $new); + $old .= "\n"; + $new .= "\n"; + + # Restore possible leading # now. + $old = "#$old" if ($old_is_disabled); + $new = "#$new" if ($new_is_disabled); + + return ($old, $new); +} + + + +# Check a string and return 1 if it's a valid single-line snort rule. +# Msg string is put in second arg, sid in third (those are the only +# required keywords, besides the leading rule actions). +sub parse_singleline_rule($ $ $) +{ + my $line = shift; + my $msg_ref = shift; + my $sid_ref = shift; + + undef($$msg_ref); + undef($$sid_ref); + + if ($line =~ /$SINGLELINE_RULE_REGEXP/oi) { + + if ($line =~ /\bmsg\s*:\s*"(.+?)"\s*;/i) { + $$msg_ref = $1; + } else { + return (0); + } + + if ($line =~ /\bsid\s*:\s*(\d+)\s*;/i) { + $$sid_ref = $1; + } else { + return (0); + } + + return (1); + } + + return (0); +} + + + +# Merge multiline directives in an array by simply removing traling backslashes. +sub join_multilines($) +{ + my $multiline_conf_ref = shift; + my $joined_conf = ""; + + foreach $_ (@$multiline_conf_ref) { + s/\\\s*\n$//; + $joined_conf .= $_; + } + + return (split/\n/, $joined_conf); +} + + + +# Catch SIGINT. +sub catch_sigint() +{ + $SIG{INT} = 'IGNORE'; + print STDERR "\nInterrupted, cleaning up.\n"; + sleep(1); + clean_exit("interrupted by signal"); +} + + + +# Remove temporary directory and exit. +# If a non-empty string is given as argument, it will be regarded +# as an error message and we will use die() with the message instead +# of just exit(0). +sub clean_exit($) +{ + my $err_msg = shift; + + $SIG{INT} = 'DEFAULT'; + + if (defined($tmpdir) && -d "$tmpdir") { + chdir(File::Spec->rootdir()); + rmtree("$tmpdir", 0, 1); + undef($tmpdir); + } + + if (!defined($err_msg) || $err_msg eq "") { + exit(0); + } else { + chomp($err_msg); + die("\n$0: Error: $err_msg\n\nOink, oink. Exiting...\n"); + } +} + + + +#### EOF #### diff --git a/config/snort-old/bin/snort2c b/config/snort-old/bin/snort2c new file mode 100755 index 00000000..fdc91ac8 Binary files /dev/null and b/config/snort-old/bin/snort2c differ diff --git a/config/snort-old/pfsense_rules/local.rules b/config/snort-old/pfsense_rules/local.rules new file mode 100644 index 00000000..83a05f1b --- /dev/null +++ b/config/snort-old/pfsense_rules/local.rules @@ -0,0 +1,7 @@ +# ---------------- +# LOCAL RULES +# ---------------- +# This file intentionally does not come with signatures. Put your local +# additions here. Pfsense first install rule. Rule edit tabe fails with out this file. +# +# \ No newline at end of file diff --git a/config/snort-old/pfsense_rules/pfsense_rules.tar.gz.md5 b/config/snort-old/pfsense_rules/pfsense_rules.tar.gz.md5 new file mode 100644 index 00000000..83d5bdae --- /dev/null +++ b/config/snort-old/pfsense_rules/pfsense_rules.tar.gz.md5 @@ -0,0 +1 @@ +10002 \ No newline at end of file diff --git a/config/snort-old/pfsense_rules/rules/pfsense-voip.rules b/config/snort-old/pfsense_rules/rules/pfsense-voip.rules new file mode 100644 index 00000000..12f2fdf2 --- /dev/null +++ b/config/snort-old/pfsense_rules/rules/pfsense-voip.rules @@ -0,0 +1,10 @@ +alert ip any any -> $HOME_NET $SIP_PROXY_PORTS (msg:"OPTIONS SIP scan"; content:"OPTIONS"; depth:7; threshold: type both , track by_src, count 30, seconds 3; sid:5000001; rev:1;) +# Excessive number of SIP 4xx Responses Does not work +#### alert ip any any -> $SIP_PROXY_IP $SIP_PROXY_PORTS (msg:"Excessive number of SIP 4xx Responses - possible user or password guessing attack"; pcre:"/^SIP\/2.0 4\d{2}"; threshold: type both, track by_src, count 100, seconds 60; sid:5000002; rev:1;) +alert ip any any -> $SIP_PROXY_IP $SIP_PROXY_PORTS (msg:"Ghost call attack"; content:"SIP/2.0 180"; depth:11; threshold: type both, track by_src, count 100, seconds 60; sid:5000003; rev:1;) +# Rule for alerting of INVITE flood attack: +alert ip any any -> $SIP_PROXY_IP $SIP_PROXY_PORTS (msg:"INVITE message flooding"; content:"INVITE"; depth:6; threshold: type both , track by_src, count 100, seconds 60; sid:5000004; rev:1;) +# Rule for alerting of REGISTER flood attack: +alert ip any any -> $SIP_PROXY_IP $SIP_PROXY_PORTS (msg:"REGISTER message flooding"; content:"REGISTER"; depth:8; threshold: type both , track by_src, count 100, seconds 60; sid:5000005; rev:1;) +# Threshold rule for unauthorized responses: +alert ip any any -> $SIP_PROXY_IP $SIP_PROXY_PORTS (msg:"INVITE message flooding"; content:"SIP/2.0 401 Unauthorized"; depth:24; threshold: type both, track by_src, count 100, seconds 60; sid:5000006; rev:1;) diff --git a/config/snort-old/snort.inc b/config/snort-old/snort.inc new file mode 100755 index 00000000..00a86c35 --- /dev/null +++ b/config/snort-old/snort.inc @@ -0,0 +1,1632 @@ + advanced features */ + $bpfbufsize = $config['installedpackages']['snortadvanced']['config'][0]['bpfbufsize']; + $bpfmaxbufsize = $config['installedpackages']['snortadvanced']['config'][0]['bpfmaxbufsize']; + $bpfmaxinsns = $config['installedpackages']['snortadvanced']['config'][0]['bpfmaxinsns']; + + /* set the snort performance model */ + if($config['installedpackages']['snort']['config'][0]['performance']) + $snort_performance = $config['installedpackages']['snort']['config'][0]['performance']; + else + $snort_performance = "ac-bnfa"; + + /* create a few directories and ensure the sample files are in place */ + exec("/bin/mkdir -p /usr/local/etc/snort"); + exec("/bin/mkdir -p /var/log/snort"); + exec("/bin/mkdir -p /usr/local/etc/snort/rules"); + exec("/bin/rm /usr/local/etc/snort/snort.conf-sample"); + exec("/bin/rm /usr/local/etc/snort/threshold.conf-sample"); + exec("/bin/rm /usr/local/etc/snort/sid-msg.map-sample"); + exec("/bin/rm /usr/local/etc/snort/unicode.map-sample"); + exec("/bin/rm /usr/local/etc/snort/classification.config-sample"); + exec("/bin/rm /usr/local/etc/snort/generators-sample"); + exec("/bin/rm /usr/local/etc/snort/reference.config-sample"); + exec("/bin/rm /usr/local/etc/snort/gen-msg.map-sample"); + exec("/bin/rm /usr/local/etc/snort/sid"); + exec("/bin/rm -f /usr/local/etc/rc.d/snort"); + + $first = 0; + $snortInterfaces = array(); /* -gtm */ + + $if_list = $config['installedpackages']['snort']['config'][0]['iface_array']; + $if_array = split(',', $if_list); + //print_r($if_array); + if($if_array) { + foreach($if_array as $iface) { + $if = convert_friendly_interface_to_real_interface_name($iface); + + if($config['interfaces'][$iface]['ipaddr'] == "pppoe") { + $if = "ng0"; + } + + /* build a list of user specified interfaces -gtm */ + if($if){ + array_push($snortInterfaces, $if); + $first = 1; + } + } + + if (count($snortInterfaces) < 1) { + log_error("Snort will not start. You must select an interface for it to listen on."); + return; + } + } + //print_r($snortInterfaces); + + /* create log directory */ + $start = "/bin/mkdir -p /var/log/snort\n"; + + /* snort advanced features - bpf tuning */ + if($bpfbufsize) + $start .= "sysctl net.bpf.bufsize={$bpfbufsize}\n"; + if($bpfmaxbufsize) + $start .= "sysctl net.bpf.maxbufsize={$bpfmaxbufsize}\n"; + if($bpfmaxinsns) + $start .= "sysctl net.bpf.maxinsns={$bpfmaxinsns}\n"; + + /* go ahead and issue bpf changes */ + if($bpfbufsize) + mwexec_bg("sysctl net.bpf.bufsize={$bpfbufsize}"); + if($bpfmaxbufsize) + mwexec_bg("sysctl net.bpf.maxbufsize={$bpfmaxbufsize}"); + if($bpfmaxinsns) + mwexec_bg("sysctl net.bpf.maxinsns={$bpfmaxinsns}"); + + /* always stop barnyard2 before starting snort -gtm */ + $start .= "/usr/bin/killall barnyard2\n"; + + /* start a snort process for each interface -gtm */ + /* Note the sleep delay. Seems to help getting mult interfaces to start -gtm */ + /* snort start options are; config file, log file, demon, interface, packet flow, alert type, quiet */ + /* TODO; get snort to start under nologin shell */ + foreach($snortInterfaces as $snortIf) + { + $start .= "sleep 4\n"; + $start .= "/usr/local/bin/snort -c /usr/local/etc/snort/snort.conf -l /var/log/snort -D -i {$snortIf} -q\n"; + /* define snortbarnyardlog_chk */ + $snortbarnyardlog_info_chk = $config['installedpackages']['snortadvanced']['config'][0]['snortbarnyardlog']; + if ($snortbarnyardlog_info_chk == on) + $start .= "\nsleep 4;/usr/local/bin/barnyard2 -c /usr/local/etc/barnyard2.conf -d /var/log/snort -f snort.u2 -w /usr/local/etc/snort/barnyard2.waldo -D -q\n"; + } + $check_if_snort_runs = "\n\tif [ \"`ls -A /usr/local/etc/snort/rules`\" ] ; then\n\techo \"rules exist\"\n\telse\n\techo \"rules DONT exist\"\n\texit 2\n\tfi \n\n\tif [ \"`pgrep -x snort`\" = \"\" ] ; then\n\t/bin/rm /tmp/snort.sh.pid\n\tfi \n\n\tif [ \"`pgrep -x snort`\" != \"\" ] ; then\n\tlogger -p daemon.info -i -t SnortStartup \"Snort already running...\"\n\t/usr/local/bin/php -f /usr/local/pkg/pf/snort_dynamic_ip_reload.php\n\texit 1\n\tfi\n\n"; + $if_snort_pid = "\nif ls /tmp/snort.sh.pid > /dev/null\nthen\n echo \"snort.sh is running\"\n exit 0\nelse\n echo \"snort.sh is not running\"\nfi\n"; + $echo_snort_sh_pid = "\necho \"snort.sh run\" > /tmp/snort.sh.pid\n"; + $echo_snort_sh_startup_log = "\necho \"snort.sh run\" >> /tmp/snort.sh_startup.log\n"; + $del_old_pids = "\nrm -f /var/run/snort_*\n"; + $sample_before = "BEFORE_MEM=`top | grep Wired | awk '{print \$12}'`\n"; + $sample_after = "\n\tAFTER_MEM=`top | grep Wired | awk '{print \$12}'`\n"; + if ($snort_performance == "ac-bnfa") + $sleep_before_final = "\necho \"Sleeping before final memory sampling...\"\nWAITSECURE=60\n"; + else + $sleep_before_final = "\necho \"Sleeping before final memory sampling...\"\nWAITSECURE=300\n"; + $sleep_before_final .= "while [ \"\$MYSNORTLOG\" = \"\" -a \$WAITSECURE -gt 0 ] ; do\n\tsleep 2\n\tMYSNORTLOG=`/usr/sbin/clog /var/log/system.log | grep snort | tail | grep 'Snort initialization completed successfully'`\n\tWAITSECURE=`expr \$WAITSECURE - 1`\ndone\n"; + $total_used_after = "TOTAL_USAGE=`top | grep snort | grep -v grep | awk '{ print \$6 }'`\n"; + $echo_usage .= $sample_after . "\t" . $total_used_after . "\techo \"Ram free BEFORE starting Snort: \$BEFORE_MEM -- Ram free AFTER starting Snort: \$AFTER_MEM -- Mode " . $snort_performance . " -- Snort memory usage: \$TOTAL_USAGE\" | logger -p daemon.info -i -t SnortStartup\n\n"; + + /* write out rc.d start/stop file */ + write_rcfile(array( + "file" => "snort.sh", + "start" => "{$check_if_snort_runs}{$if_snort_pid}{$echo_snort_sh_pid}{$echo_snort_sh_startup_log}{$del_old_pids}{$sample_before}{$start}{$sleep_before_final}{$echo_usage}", + "stop" => "/usr/bin/killall snort; killall barnyard2" + ) + ); + + /* create snort configuration file */ + create_snort_conf(); + +/* create barnyard2 configuration file */ +$snortbarnyardlog_info_chk = $config['installedpackages']['snortadvanced']['config'][0]['snortbarnyardlog']; +if ($snortbarnyardlog_info_chk == on) + create_barnyard2_conf(); + + /* snort will not start on install untill setting are set */ +if ($config['installedpackages']['snort']['config'][0]['autorulesupdate7'] != "") { + /* start snort service */ + conf_mount_ro(); + start_service("snort"); + } +} + +/* open barnyard2.conf for writing */ +function create_barnyard2_conf() { + global $bconfig, $bg; + /* write out barnyard2_conf */ + conf_mount_rw(); + $barnyard2_conf_text = generate_barnyard2_conf(); + $bconf = fopen("/usr/local/etc/barnyard2.conf", "w"); + if(!$bconf) { + log_error("Could not open /usr/local/etc/barnyard2.conf for writing."); + exit; + } + fwrite($bconf, $barnyard2_conf_text); + fclose($bconf); + conf_mount_ro(); +} +/* open barnyard2.conf for writing" */ +function generate_barnyard2_conf() { + + global $config, $g; + conf_mount_rw(); + +/* define snortbarnyardlog */ +/* TODO add support for the other 5 output plugins */ + +$snortbarnyardlog_database_info_chk = $config['installedpackages']['snortadvanced']['config'][0]['snortbarnyardlog_database']; +$snortbarnyardlog_hostname_info_chk = $config['installedpackages']['snortadvanced']['config'][0]['snortbarnyardlog_hostname']; +$snortbarnyardlog_interface_info_chk = $config['installedpackages']['snortadvanced']['config'][0]['snortbarnyardlog_interface']; + +$barnyard2_conf_text = << 0) { + unset($config['cron']['item'][$x]); + write_config(); + } + configure_cron(); + } + } + + function snort_rules_up_deinstall_cron($should_install) { + global $config, $g; + + $is_installed = false; + + if(!$config['cron']['item']) + return; + + $x=0; + foreach($config['cron']['item'] as $item) { + if (strstr($item['command'], "snort_check_for_rule_updates.php")) { + $is_installed = true; + break; + } + $x++; + } + if($is_installed == true) { + if($x > 0) { + unset($config['cron']['item'][$x]); + write_config(); + } + configure_cron(); + } + } + +snort_rm_blocked_deinstall_cron(""); +snort_rules_up_deinstall_cron(""); + + + /* Unset snort registers in conf.xml IMPORTANT snort will not start with out this */ + /* Keep this as a last step */ + unset($config['installedpackages']['snort']['config'][0]['autorulesupdate7']); + unset($config['installedpackages']['snort']['config'][0]['rm_blocked']); + write_config(); + +} + +function generate_snort_conf() { + + global $config, $g; + conf_mount_rw(); + /* obtain external interface */ + /* XXX: make multi wan friendly */ + $snort_ext_int = $config['installedpackages']['snort']['config'][0]['iface_array'][0]; + + $snort_config_pass_thru = $config['installedpackages']['snortadvanced']['config'][0]['configpassthru']; + +/* define snortalertlogtype */ +$snortalertlogtype = $config['installedpackages']['snortadvanced']['config'][0]['snortalertlogtype']; +if ($snortalertlogtype == fast) + $snortalertlogtype_type = "output alert_fast: alert"; +else + $snortalertlogtype_type = "output alert_full: alert"; + +/* define alertsystemlog */ +$alertsystemlog_info_chk = $config['installedpackages']['snortadvanced']['config'][0]['alertsystemlog']; +if ($alertsystemlog_info_chk == on) + $alertsystemlog_type = "output alert_syslog: log_alert"; + +/* define tcpdumplog */ +$tcpdumplog_info_chk = $config['installedpackages']['snortadvanced']['config'][0]['tcpdumplog']; +if ($tcpdumplog_info_chk == on) + $tcpdumplog_type = "output log_tcpdump: snorttcpd.log"; + +/* define snortbarnyardlog_chk */ +$snortbarnyardlog_info_chk = $config['installedpackages']['snortadvanced']['config'][0]['snortbarnyardlog']; +if ($snortbarnyardlog_info_chk == on) + $snortbarnyardlog_type = "barnyard2 -c /usr/local/etc/barnyard2.conf -d /var/log/snort -f snort.u2 -w /usr/local/etc/snort/barnyard2.waldo -D"; + +/* define snortunifiedlog */ +$snortunifiedlog_info_chk = $config['installedpackages']['snortadvanced']['config'][0]['snortunifiedlog']; +if ($snortunifiedlog_info_chk == on) + $snortunifiedlog_type = "output unified2: filename snort.u2, limit 128"; + +/* define spoink */ +$spoink_info_chk = $config['installedpackages']['snort']['config'][0]['blockoffenders7']; +if ($spoink_info_chk == on) + $spoink_type = "output alert_pf: /var/db/whitelist,snort2c"; + + /* define servers and ports snortdefservers */ + +/* def DNS_SERVSERS */ +$def_dns_servers_info_chk = $config['installedpackages']['snortdefservers']['config'][0]['def_dns_servers']; +if ($def_dns_servers_info_chk == "") + $def_dns_servers_type = "\$HOME_NET"; +else + $def_dns_servers_type = "$def_dns_servers_info_chk"; + +/* def DNS_PORTS */ +$def_dns_ports_info_chk = $config['installedpackages']['snortdefservers']['config'][0]['def_dns_ports']; +if ($def_dns_ports_info_chk == "") + $def_dns_ports_type = "53"; +else + $def_dns_ports_type = "$def_dns_ports_info_chk"; + +/* def SMTP_SERVSERS */ +$def_smtp_servers_info_chk = $config['installedpackages']['snortdefservers']['config'][0]['def_smtp_servers']; +if ($def_smtp_servers_info_chk == "") + $def_smtp_servers_type = "\$HOME_NET"; +else + $def_smtp_servers_type = "$def_smtp_servers_info_chk"; + +/* def SMTP_PORTS */ +$def_smtp_ports_info_chk = $config['installedpackages']['snortdefservers']['config'][0]['def_smtp_ports']; +if ($def_smtp_ports_info_chk == "") + $def_smtp_ports_type = "25"; +else + $def_smtp_ports_type = "$def_smtp_ports_info_chk"; + +/* def MAIL_PORTS */ +$def_mail_ports_info_chk = $config['installedpackages']['snortdefservers']['config'][0]['def_mail_ports']; +if ($def_mail_ports_info_chk == "") + $def_mail_ports_type = "25,143,465,691"; +else + $def_mail_ports_type = "$def_mail_ports_info_chk"; + +/* def HTTP_SERVSERS */ +$def_http_servers_info_chk = $config['installedpackages']['snortdefservers']['config'][0]['def_http_servers']; +if ($def_http_servers_info_chk == "") + $def_http_servers_type = "\$HOME_NET"; +else + $def_http_servers_type = "$def_http_servers_info_chk"; + +/* def WWW_SERVSERS */ +$def_www_servers_info_chk = $config['installedpackages']['snortdefservers']['config'][0]['def_www_servers']; +if ($def_www_servers_info_chk == "") + $def_www_servers_type = "\$HOME_NET"; +else + $def_www_servers_type = "$def_www_servers_info_chk"; + +/* def HTTP_PORTS */ +$def_http_ports_info_chk = $config['installedpackages']['snortdefservers']['config'][0]['def_http_ports']; +if ($def_http_ports_info_chk == "") + $def_http_ports_type = "80"; +else + $def_http_ports_type = "$def_http_ports_info_chk"; + +/* def SQL_SERVSERS */ +$def_sql_servers_info_chk = $config['installedpackages']['snortdefservers']['config'][0]['def_sql_servers']; +if ($def_sql_servers_info_chk == "") + $def_sql_servers_type = "\$HOME_NET"; +else + $def_sql_servers_type = "$def_sql_servers_info_chk"; + +/* def ORACLE_PORTS */ +$def_oracle_ports_info_chk = $config['installedpackages']['snortdefservers']['config'][0]['def_oracle_ports']; +if ($def_oracle_ports_info_chk == "") + $def_oracle_ports_type = "1521"; +else + $def_oracle_ports_type = "$def_oracle_ports_info_chk"; + +/* def MSSQL_PORTS */ +$def_mssql_ports_info_chk = $config['installedpackages']['snortdefservers']['config'][0]['def_mssql_ports']; +if ($def_mssql_ports_info_chk == "") + $def_mssql_ports_type = "1433"; +else + $def_mssql_ports_type = "$def_mssql_ports_info_chk"; + +/* def TELNET_SERVSERS */ +$def_telnet_servers_info_chk = $config['installedpackages']['snortdefservers']['config'][0]['def_telnet_servers']; +if ($def_telnet_servers_info_chk == "") + $def_telnet_servers_type = "\$HOME_NET"; +else + $def_telnet_servers_type = "$def_telnet_servers_info_chk"; + +/* def TELNET_PORTS */ +$def_telnet_ports_info_chk = $config['installedpackages']['snortdefservers']['config'][0]['def_telnet_ports']; +if ($def_telnet_ports_info_chk == "") + $def_telnet_ports_type = "23"; +else + $def_telnet_ports_type = "$def_telnet_ports_info_chk"; + +/* def SNMP_SERVSERS */ +$def_snmp_servers_info_chk = $config['installedpackages']['snortdefservers']['config'][0]['def_snmp_servers']; +if ($def_snmp_servers_info_chk == "") + $def_snmp_servers_type = "\$HOME_NET"; +else + $def_snmp_servers_type = "$def_snmp_servers_info_chk"; + +/* def SNMP_PORTS */ +$def_snmp_ports_info_chk = $config['installedpackages']['snortdefservers']['config'][0]['def_snmp_ports']; +if ($def_snmp_ports_info_chk == "") + $def_snmp_ports_type = "161"; +else + $def_snmp_ports_type = "$def_snmp_ports_info_chk"; + +/* def FTP_SERVSERS */ +$def_ftp_servers_info_chk = $config['installedpackages']['snortdefservers']['config'][0]['def_ftp_servers']; +if ($def_ftp_servers_info_chk == "") + $def_ftp_servers_type = "\$HOME_NET"; +else + $def_ftp_servers_type = "$def_ftp_servers_info_chk"; + +/* def FTP_PORTS */ +$def_ftp_ports_info_chk = $config['installedpackages']['snortdefservers']['config'][0]['def_ftp_ports']; +if ($def_ftp_ports_info_chk == "") + $def_ftp_ports_type = "21"; +else + $def_ftp_ports_type = "$def_ftp_ports_info_chk"; + +/* def SSH_SERVSERS */ +$def_ssh_servers_info_chk = $config['installedpackages']['snortdefservers']['config'][0]['def_ssh_servers']; +if ($def_ssh_servers_info_chk == "") + $def_ssh_servers_type = "\$HOME_NET"; +else + $def_ssh_servers_type = "$def_ssh_servers_info_chk"; + +/* if user has defined a custom ssh port, use it */ +if($config['system']['ssh']['port']) + $ssh_port = $config['system']['ssh']['port']; +else + $ssh_port = "22"; + +/* def SSH_PORTS */ +$def_ssh_ports_info_chk = $config['installedpackages']['snortdefservers']['config'][0]['def_ssh_ports']; +if ($def_ssh_ports_info_chk == "") + $def_ssh_ports_type = "{$ssh_port}"; +else + $def_ssh_ports_type = "$def_ssh_ports_info_chk"; + +/* def POP_SERVSERS */ +$def_pop_servers_info_chk = $config['installedpackages']['snortdefservers']['config'][0]['def_pop_servers']; +if ($def_pop_servers_info_chk == "") + $def_pop_servers_type = "\$HOME_NET"; +else + $def_pop_servers_type = "$def_pop_servers_info_chk"; + +/* def POP2_PORTS */ +$def_pop2_ports_info_chk = $config['installedpackages']['snortdefservers']['config'][0]['def_pop2_ports']; +if ($def_pop2_ports_info_chk == "") + $def_pop2_ports_type = "109"; +else + $def_pop2_ports_type = "$def_pop2_ports_info_chk"; + +/* def POP3_PORTS */ +$def_pop3_ports_info_chk = $config['installedpackages']['snortdefservers']['config'][0]['def_pop3_ports']; +if ($def_pop3_ports_info_chk == "") + $def_pop3_ports_type = "110"; +else + $def_pop3_ports_type = "$def_pop3_ports_info_chk"; + +/* def IMAP_SERVSERS */ +$def_imap_servers_info_chk = $config['installedpackages']['snortdefservers']['config'][0]['def_imap_servers']; +if ($def_imap_servers_info_chk == "") + $def_imap_servers_type = "\$HOME_NET"; +else + $def_imap_servers_type = "$def_imap_servers_info_chk"; + +/* def IMAP_PORTS */ +$def_imap_ports_info_chk = $config['installedpackages']['snortdefservers']['config'][0]['def_imap_ports']; +if ($def_imap_ports_info_chk == "") + $def_imap_ports_type = "143"; +else + $def_imap_ports_type = "$def_imap_ports_info_chk"; + +/* def SIP_PROXY_IP */ +$def_sip_proxy_ip_info_chk = $config['installedpackages']['snortdefservers']['config'][0]['def_sip_proxy_ip']; +if ($def_sip_proxy_ip_info_chk == "") + $def_sip_proxy_ip_type = "\$HOME_NET"; +else + $def_sip_proxy_ip_type = "$def_sip_proxy_ip_info_chk"; + +/* def SIP_PROXY_PORTS */ +$def_sip_proxy_ports_info_chk = $config['installedpackages']['snortdefservers']['config'][0]['def_sip_proxy_ports']; +if ($def_sip_proxy_ports_info_chk == "") + $def_sip_proxy_ports_type = "5060:5090,16384:32768"; +else + $def_sip_proxy_ports_type = "$def_sip_proxy_ports_info_chk"; + +/* def AUTH_PORTS */ +$def_auth_ports_info_chk = $config['installedpackages']['snortdefservers']['config'][0]['def_auth_ports']; +if ($def_auth_ports_info_chk == "") + $def_auth_ports_type = "113"; +else + $def_auth_ports_type = "$def_auth_ports_info_chk"; + +/* def FINGER_PORTS */ +$def_finger_ports_info_chk = $config['installedpackages']['snortdefservers']['config'][0]['def_finger_ports']; +if ($def_finger_ports_info_chk == "") + $def_finger_ports_type = "79"; +else + $def_finger_ports_type = "$def_finger_ports_info_chk"; + +/* def IRC_PORTS */ +$def_irc_ports_info_chk = $config['installedpackages']['snortdefservers']['config'][0]['def_irc_ports']; +if ($def_irc_ports_info_chk == "") + $def_irc_ports_type = "6665,6666,6667,6668,6669,7000"; +else + $def_irc_ports_type = "$def_irc_ports_info_chk"; + +/* def NNTP_PORTS */ +$def_nntp_ports_info_chk = $config['installedpackages']['snortdefservers']['config'][0]['def_nntp_ports']; +if ($def_nntp_ports_info_chk == "") + $def_nntp_ports_type = "119"; +else + $def_nntp_ports_type = "$def_nntp_ports_info_chk"; + +/* def RLOGIN_PORTS */ +$def_rlogin_ports_info_chk = $config['installedpackages']['snortdefservers']['config'][0]['def_rlogin_ports']; +if ($def_rlogin_ports_info_chk == "") + $def_rlogin_ports_type = "513"; +else + $def_rlogin_ports_type = "$def_rlogin_ports_info_chk"; + +/* def RSH_PORTS */ +$def_rsh_ports_info_chk = $config['installedpackages']['snortdefservers']['config'][0]['def_rsh_ports']; +if ($def_rsh_ports_info_chk == "") + $def_rsh_ports_type = "514"; +else + $def_rsh_ports_type = "$def_rsh_ports_info_chk"; + +/* def SSL_PORTS */ +$def_ssl_ports_info_chk = $config['installedpackages']['snortdefservers']['config'][0]['def_ssl_ports']; +if ($def_ssl_ports_info_chk == "") + $def_ssl_ports_type = "25,443,465,636,993,995"; +else + $def_ssl_ports_type = "$def_ssl_ports_info_chk"; + + /* add auto update scripts to /etc/crontab */ +// $text_ww = "*/60\t* \t 1\t *\t *\t root\t /usr/bin/nice -n20 /usr/local/pkg/snort_check_for_rule_updates.php"; +// $filenamea = "/etc/crontab"; +// remove_text_from_file($filenamea, $text_ww); +// add_text_to_file($filenamea, $text_ww); +// exec("killall -HUP cron"); */ + + /* should we install a automatic update crontab entry? */ + $automaticrulesupdate = $config['installedpackages']['snort']['config'][0]['automaticrulesupdate']; + + /* if user is on pppoe, we really want to use ng0 interface */ + if($config['interfaces'][$snort_ext_int]['ipaddr'] == "pppoe") + $snort_ext_int = "ng0"; + + /* set the snort performance model */ + if($config['installedpackages']['snort']['config'][0]['performance']) + $snort_performance = $config['installedpackages']['snort']['config'][0]['performance']; + else + $snort_performance = "ac-bnfa"; + + /* set the snort block hosts time IMPORTANT snort has trouble installing if snort_rm_blocked_info_ck != "" */ + $snort_rm_blocked_info_ck = $config['installedpackages']['snort']['config'][0]['rm_blocked']; + if ($snort_rm_blocked_info_ck == "never_b") + $snort_rm_blocked_false = ""; + else + $snort_rm_blocked_false = "true"; + +if ($snort_rm_blocked_info_ck != "") { +function snort_rm_blocked_install_cron($should_install) { + global $config, $g; + conf_mount_rw(); + if ($g['booting']==true) + return; + + $is_installed = false; + + if(!$config['cron']['item']) + return; + + $x=0; + foreach($config['cron']['item'] as $item) { + if (strstr($item['command'], "snort2c")) { + $is_installed = true; + break; + } + $x++; + } + $snort_rm_blocked_info_ck = $config['installedpackages']['snort']['config'][0]['rm_blocked']; + if ($snort_rm_blocked_info_ck == "1h_b") { + $snort_rm_blocked_min = "*/5"; + $snort_rm_blocked_hr = "*"; + $snort_rm_blocked_mday = "*"; + $snort_rm_blocked_month = "*"; + $snort_rm_blocked_wday = "*"; + $snort_rm_blocked_expire = "3600"; + } + if ($snort_rm_blocked_info_ck == "3h_b") { + $snort_rm_blocked_min = "*/15"; + $snort_rm_blocked_hr = "*"; + $snort_rm_blocked_mday = "*"; + $snort_rm_blocked_month = "*"; + $snort_rm_blocked_wday = "*"; + $snort_rm_blocked_expire = "10800"; + } + if ($snort_rm_blocked_info_ck == "6h_b") { + $snort_rm_blocked_min = "*/30"; + $snort_rm_blocked_hr = "*"; + $snort_rm_blocked_mday = "*"; + $snort_rm_blocked_month = "*"; + $snort_rm_blocked_wday = "*"; + $snort_rm_blocked_expire = "21600"; + } + if ($snort_rm_blocked_info_ck == "12h_b") { + $snort_rm_blocked_min = "2"; + $snort_rm_blocked_hr = "*/1"; + $snort_rm_blocked_mday = "*"; + $snort_rm_blocked_month = "*"; + $snort_rm_blocked_wday = "*"; + $snort_rm_blocked_expire = "43200"; + } + if ($snort_rm_blocked_info_ck == "1d_b") { + $snort_rm_blocked_min = "2"; + $snort_rm_blocked_hr = "*/2"; + $snort_rm_blocked_mday = "*"; + $snort_rm_blocked_month = "*"; + $snort_rm_blocked_wday = "*"; + $snort_rm_blocked_expire = "86400"; + } + if ($snort_rm_blocked_info_ck == "4d_b") { + $snort_rm_blocked_min = "2"; + $snort_rm_blocked_hr = "*/8"; + $snort_rm_blocked_mday = "*"; + $snort_rm_blocked_month = "*"; + $snort_rm_blocked_wday = "*"; + $snort_rm_blocked_expire = "345600"; + } + if ($snort_rm_blocked_info_ck == "7d_b") { + $snort_rm_blocked_min = "2"; + $snort_rm_blocked_hr = "*/14"; + $snort_rm_blocked_mday = "*"; + $snort_rm_blocked_month = "*"; + $snort_rm_blocked_wday = "*"; + $snort_rm_blocked_expire = "604800"; + } + if ($snort_rm_blocked_info_ck == "28d_b") { + $snort_rm_blocked_min = "2"; + $snort_rm_blocked_hr = "0"; + $snort_rm_blocked_mday = "*/2"; + $snort_rm_blocked_month = "*"; + $snort_rm_blocked_wday = "*"; + $snort_rm_blocked_expire = "2419200"; + } + 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"; + $config['cron']['item'][] = $cron_item; + write_config("Installed 15 minute filter reload for Time Based Rules"); + conf_mount_rw(); + configure_cron(); + } + break; + case false: + if($is_installed == true) { + if($x > 0) { + unset($config['cron']['item'][$x]); + write_config(); + conf_mount_rw(); + } + configure_cron(); + } + break; + } + } + snort_rm_blocked_install_cron(""); + snort_rm_blocked_install_cron($snort_rm_blocked_false); +} + + /* set the snort rules update time */ + $snort_rules_up_info_ck = $config['installedpackages']['snort']['config'][0]['autorulesupdate7']; + if ($snort_rules_up_info_ck == "never_up") + $snort_rules_up_false = ""; + else + $snort_rules_up_false = "true"; + +if ($snort_rules_up_info_ck != "") { +function snort_rules_up_install_cron($should_install) { + global $config, $g; + conf_mount_rw(); + if ($g['booting']==true) + return; + + $is_installed = false; + + if(!$config['cron']['item']) + return; + + $x=0; + foreach($config['cron']['item'] as $item) { + if (strstr($item['command'], "snort_check_for_rule_updates.php")) { + $is_installed = true; + break; + } + $x++; + } + $snort_rules_up_info_ck = $config['installedpackages']['snort']['config'][0]['autorulesupdate7']; + if ($snort_rules_up_info_ck == "6h_up") { + $snort_rules_up_min = "3"; + $snort_rules_up_hr = "*/6"; + $snort_rules_up_mday = "*"; + $snort_rules_up_month = "*"; + $snort_rules_up_wday = "*"; + } + if ($snort_rules_up_info_ck == "12h_up") { + $snort_rules_up_min = "3"; + $snort_rules_up_hr = "*/12"; + $snort_rules_up_mday = "*"; + $snort_rules_up_month = "*"; + $snort_rules_up_wday = "*"; + } + if ($snort_rules_up_info_ck == "1d_up") { + $snort_rules_up_min = "3"; + $snort_rules_up_hr = "0"; + $snort_rules_up_mday = "*/1"; + $snort_rules_up_month = "*"; + $snort_rules_up_wday = "*"; + } + if ($snort_rules_up_info_ck == "4d_up") { + $snort_rules_up_min = "3"; + $snort_rules_up_hr = "0"; + $snort_rules_up_mday = "*/4"; + $snort_rules_up_month = "*"; + $snort_rules_up_wday = "*"; + } + if ($snort_rules_up_info_ck == "7d_up") { + $snort_rules_up_min = "3"; + $snort_rules_up_hr = "0"; + $snort_rules_up_mday = "*/7"; + $snort_rules_up_month = "*"; + $snort_rules_up_wday = "*"; + } + if ($snort_rules_up_info_ck == "28d_up") { + $snort_rules_up_min = "3"; + $snort_rules_up_hr = "0"; + $snort_rules_up_mday = "*/28"; + $snort_rules_up_month = "*"; + $snort_rules_up_wday = "*"; + } + 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_check_for_rule_updates.php >> /usr/local/etc/snort_bkup/snort_update.log"; + $config['cron']['item'][] = $cron_item; + write_config("Installed 15 minute filter reload for Time Based Rules"); + conf_mount_rw(); + configure_cron(); + } + break; + case false: + if($is_installed == true) { + if($x > 0) { + unset($config['cron']['item'][$x]); + write_config(); + conf_mount_rw(); + } + configure_cron(); + } + break; + } + } + snort_rules_up_install_cron(""); + snort_rules_up_install_cron($snort_rules_up_false); +} + /* Be sure we're really rw before writing */ + conf_mount_rw(); + /* open snort2c's whitelist for writing */ + $whitelist = fopen("/var/db/whitelist", "w"); + if(!$whitelist) { + log_error("Could not open /var/db/whitelist for writing."); + return; + } + + /* build an interface array list */ + $int_array = array('lan'); + for ($j = 1; isset ($config['interfaces']['opt' . $j]); $j++) + if(isset($config['interfaces']['opt' . $j]['enable'])) + if(!$config['interfaces']['opt' . $j]['gateway']) + $int_array[] = "opt{$j}"; + + /* iterate through interface list and write out whitelist items + * and also compile a home_net list for snort. + */ + foreach($int_array as $int) { + /* calculate interface subnet information */ + $ifcfg = &$config['interfaces'][$int]; + $subnet = gen_subnet($ifcfg['ipaddr'], $ifcfg['subnet']); + $subnetmask = gen_subnet_mask($ifcfg['subnet']); + if($subnet == "pppoe" or $subnet == "dhcp") { + $subnet = find_interface_ip("ng0"); + if($subnet) + $home_net .= "{$subnet} "; + } else { + if ($subnet) + if($ifcfg['subnet']) + $home_net .= "{$subnet}/{$ifcfg['subnet']} "; + } + } + + /* add all WAN ips to the whitelist */ + $wan_if = get_real_wan_interface(); + $ip = find_interface_ip($wan_if); + if($ip) + $home_net .= "{$ip} "; + + /* Add Gateway on WAN interface to whitelist (For RRD graphs) */ + $int = convert_friendly_interface_to_real_interface_name("WAN"); + $gw = get_interface_gateway($int); + if($gw) + $home_net .= "{$gw} "; + + /* Add DNS server for WAN interface to whitelist */ + $dns_servers = get_dns_servers(); + foreach($dns_servers as $dns) { + if($dns) + $home_net .= "{$dns} "; + } + + /* Add loopback to whitelist (ftphelper) */ + $home_net .= "127.0.0.1 "; + + /* iterate all vips and add to whitelist */ + if($config['virtualip']) + foreach($config['virtualip']['vip'] as $vip) + if($vip['subnet']) + $home_net .= $vip['subnet'] . " "; + + if($config['installedpackages']['snortwhitelist']) + foreach($config['installedpackages']['snortwhitelist']['config'] as $snort) + if($snort['ip']) + $home_net .= $snort['ip'] . " "; + + /* write out whitelist, convert spaces to carriage returns */ + $whitelist_home_net = str_replace(" ", " ", $home_net); + $whitelist_home_net = str_replace(" ", "\n", $home_net); + + /* make $home_net presentable to snort */ + $home_net = trim($home_net); + $home_net = str_replace(" ", ",", $home_net); + $home_net = "[{$home_net}]"; + + /* foreach through whitelist, writing out to file */ + $whitelist_split = split("\n", $whitelist_home_net); + foreach($whitelist_split as $wl) + if(trim($wl)) + fwrite($whitelist, trim($wl) . "\n"); + + /* should we whitelist vpns? */ + $whitelistvpns = $config['installedpackages']['snort']['config'][0]['whitelistvpns']; + + /* grab a list of vpns and whitelist if user desires added by nestorfish 954 */ + if($whitelistvpns) { + $vpns_list = get_vpns_list(); + $whitelist_vpns = split(" ", $vpns_list); + foreach($whitelist_vpns as $wl) + if(trim($wl)) + fwrite($whitelist, trim($wl) . "\n"); + } + + /* close file */ + fclose($whitelist); + + /* Be sure we're really rw before writing */ + conf_mount_rw(); + /* open snort's threshold.conf for writing */ + $threshlist = fopen("/usr/local/etc/snort/threshold.conf", "w"); + if(!$threshlist) { + log_error("Could not open /usr/local/etc/snort/threshold.conf for writing."); + return; + } + + /* list all entries to new lines */ + if($config['installedpackages']['snortthreshold']) + foreach($config['installedpackages']['snortthreshold']['config'] as $snortthreshlist) + if($snortthreshlist['threshrule']) + $snortthreshlist_r .= $snortthreshlist['threshrule'] . "\n"; + + + /* foreach through threshlist, writing out to file */ + $threshlist_split = split("\n", $snortthreshlist_r); + foreach($threshlist_split as $wl) + if(trim($wl)) + fwrite($threshlist, trim($wl) . "\n"); + + /* close snort's threshold.conf file */ + fclose($threshlist); + + /* generate rule sections to load */ + $enabled_rulesets = $config['installedpackages']['snort']['rulesets']; + if($enabled_rulesets) { + $selected_rules_sections = ""; + $enabled_rulesets_array = split("\|\|", $enabled_rulesets); + foreach($enabled_rulesets_array as $enabled_item) + $selected_rules_sections .= "include \$RULE_PATH/{$enabled_item}\n"; + } + + conf_mount_ro(); + + /* build snort configuration file */ + /* TODO; feed back from pfsense users to reduce false positives */ + $snort_conf_text = << \ + cmd_validity STRU < char FRP > \ + cmd_validity ALLO < int [ char R int ] > \ + cmd_validity TYPE < { char AE [ char NTC ] | char I | char L [ number ] } > \ + cmd_validity MDTM < [ date nnnnnnnnnnnnnn[.n[n[n]]] ] string > \ + cmd_validity PORT < host_port > + +preprocessor ftp_telnet_protocol: ftp client default \ + max_resp_len 256 \ + bounce yes \ + telnet_cmds yes + +##################### + # +# SMTP preprocessor # + # +##################### + +preprocessor SMTP: \ + ports { 25 465 691 } \ + inspection_type stateful \ + normalize cmds \ + valid_cmds { MAIL RCPT HELP HELO ETRN EHLO EXPN VRFY ATRN SIZE BDAT DEBUG EMAL ESAM ESND ESOM EVFY IDENT NOOP RSET SEND SAML SOML AUTH TURN ETRN PIPELINING \ +CHUNKING DATA DSN RSET QUIT ONEX QUEU STARTTLS TICK TIME TURNME VERB X-EXPS X-LINK2STATE XADR XAUTH XCIR XEXCH50 XGEN XLICENSE XQUEU XSTA XTRN XUSR } \ + normalize_cmds { MAIL RCPT HELP HELO ETRN EHLO EXPN VRFY ATRN SIZE BDAT DEBUG EMAL ESAM ESND ESOM EVFY IDENT NOOP RSET SEND SAML SOML AUTH TURN ETRN \ +PIPELINING CHUNKING DATA DSN RSET QUIT ONEX QUEU STARTTLS TICK TIME TURNME VERB X-EXPS X-LINK2STATE XADR XAUTH XCIR XEXCH50 XGEN XLICENSE XQUEU XSTA XTRN XUSR } \ + max_header_line_len 1000 \ + max_response_line_len 512 \ + alt_max_command_line_len 260 { MAIL } \ + alt_max_command_line_len 300 { RCPT } \ + alt_max_command_line_len 500 { HELP HELO ETRN EHLO } \ + alt_max_command_line_len 255 { EXPN VRFY ATRN SIZE BDAT DEBUG EMAL ESAM ESND ESOM EVFY IDENT NOOP RSET } \ + alt_max_command_line_len 246 { SEND SAML SOML AUTH TURN ETRN PIPELINING CHUNKING DATA DSN RSET QUIT ONEX } \ + alt_max_command_line_len 246 { QUEU STARTTLS TICK TIME TURNME VERB X-EXPS X-LINK2STATE XADR } \ + alt_max_command_line_len 246 { XAUTH XCIR XEXCH50 XGEN XLICENSE XQUEU XSTA XTRN XUSR } \ + xlink2state { enable } + +################ + # +# sf Portscan # + # +################ + +preprocessor sfportscan: scan_type { all } \ + proto { all } \ + memcap { 10000000 } \ + sense_level { medium } \ + ignore_scanners { \$HOME_NET } + +############################ + # +# OLD # +# preprocessor dcerpc: \ # +# autodetect \ # +# max_frag_size 3000 \ # +# memcap 100000 # + # +############################ + +############### + # +# NEW # +# DCE/RPC 2 # + # +############### + +preprocessor dcerpc2: memcap 102400, events [smb, co, cl] +preprocessor dcerpc2_server: default, policy WinXP, \ + detect [smb [139,445], tcp 135, udp 135, rpc-over-http-server 593], \ + autodetect [tcp 1025:, udp 1025:, rpc-over-http-server 1025:], \ + smb_max_chain 3 + +#################### + # +# DNS preprocessor # + # +#################### + +preprocessor dns: \ + ports { 53 } \ + enable_rdata_overflow + +############################## + # +# NEW # +# Ignore SSL and Encryption # + # +############################## + +preprocessor ssl: ports { 443 465 563 636 989 992 993 994 995 }, trustservers, noinspect_encrypted + +##################### + # +# Snort Output Logs # + # +##################### + +$snortalertlogtype_type +$alertsystemlog_type +$tcpdumplog_type +$snortmysqllog_info_chk +$snortunifiedlog_type +$spoink_type + +################# + # +# Misc Includes # + # +################# + +include /usr/local/etc/snort/reference.config +include /usr/local/etc/snort/classification.config +include /usr/local/etc/snort/threshold.conf + +# Snort user pass through configuration +{$snort_config_pass_thru} + +################### + # +# Rules Selection # + # +################### + +{$selected_rules_sections} + +EOD; + conf_mount_ro(); + return $snort_conf_text; +} + +/* check downloaded text from snort.org to make sure that an error did not occur + * for example, if you are not a premium subscriber you can only download rules + * so often, etc. + */ +function check_for_common_errors($filename) { + global $snort_filename, $snort_filename_md5, $console_mode; + ob_flush(); + $contents = file_get_contents($filename); + if(stristr($contents, "You don't have permission")) { + if(!$console_mode) { + update_all_status("An error occured while downloading {$filename}."); + hide_progress_bar_status(); + } else { + log_error("An error occured. Scroll down to inspect it's contents."); + echo "An error occured. Scroll down to inspect it's contents."; + } + if(!$console_mode) { + update_output_window(strip_tags("$contents")); + } else { + $contents = strip_tags($contents); + log_error("Error downloading snort rules: {$contents}"); + echo "Error downloading snort rules: {$contents}"; + } + scroll_down_to_bottom_of_page(); + exit; + } +} + +/* force browser to scroll all the way down */ +function scroll_down_to_bottom_of_page() { + global $snort_filename, $console_mode; + ob_flush(); + if(!$console_mode) + echo "\n"; +} + +/* ensure downloaded file looks sane */ +function verify_downloaded_file($filename) { + global $snort_filename, $snort_filename_md5, $console_mode; + ob_flush(); + if(filesize($filename)<9500) { + if(!$console_mode) { + update_all_status("Checking {$filename}..."); + check_for_common_errors($filename); + } + } + update_all_status("Verifying {$filename}..."); + if(!file_exists($filename)) { + if(!$console_mode) { + update_all_status("Could not fetch snort rules ({$filename}). Check oinkid key and dns and try again."); + hide_progress_bar_status(); + } else { + log_error("Could not fetch snort rules ({$filename}). Check oinkid key and dns and try again."); + echo "Could not fetch snort rules ({$filename}). Check oinkid key and dns and try again."; + } + exit; + } + update_all_status("Verifyied {$filename}."); +} + +/* extract rules */ +function extract_snort_rules_md5($tmpfname) { + global $snort_filename, $snort_filename_md5, $console_mode; + ini_set("memory_limit","64M"); + conf_mount_rw(); + ob_flush(); + if(!$console_mode) { + $static_output = gettext("Extracting snort rules..."); + update_all_status($static_output); + } + if(!is_dir("/usr/local/etc/snort/rules/")) + mkdir("/usr/local/etc/snort/rules/"); + $cmd = "/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C /usr/local/etc/snort/ rules/"; + $handle = popen("{$cmd} 2>&1", 'r'); + while(!feof($handle)) { + $buffer = fgets($handle); + update_output_window($buffer); + } + pclose($handle); + + if(!$console_mode) { + $static_output = gettext("Snort rules extracted."); + update_all_status($static_output); + } else { + log_error("Snort rules extracted."); + echo "Snort rules extracted."; + } + conf_mount_ro(); +} + +/* verify MD5 against downloaded item */ +function verify_snort_rules_md5($tmpfname) { + global $snort_filename, $snort_filename_md5, $console_mode; + ob_flush(); + if(!$console_mode) { + $static_output = gettext("Verifying md5 signature..."); + update_all_status($static_output); + } + + $md555 = file_get_contents("{$tmpfname}/{$snort_filename_md5}"); + $md5 = `/bin/echo "{$md555}" | /usr/bin/awk '{ print $4 }'`; + $file_md5_ondisk = `/sbin/md5 {$tmpfname}/{$snort_filename} | /usr/bin/awk '{ print $4 }'`; + if($md5 == $file_md5_ondisk) { + if(!$console_mode) { + $static_output = gettext("snort rules: md5 signature of rules mismatch."); + update_all_status($static_output); + hide_progress_bar_status(); + } else { + log_error("snort rules: md5 signature of rules mismatch."); + echo "snort rules: md5 signature of rules mismatch."; + } + exit; + } +} + +/* hide progress bar */ +function hide_progress_bar_status() { + global $snort_filename, $snort_filename_md5, $console_mode; + ob_flush(); + if(!$console_mode) + echo "\n"; +} + +/* unhide progress bar */ +function unhide_progress_bar_status() { + global $snort_filename, $snort_filename_md5, $console_mode; + ob_flush(); + if(!$console_mode) + echo "\n"; +} + +/* update both top and bottom text box during an operation */ +function update_all_status($status) { + global $snort_filename, $snort_filename_md5, $console_mode; + ob_flush(); + if(!$console_mode) { + update_status($status); + update_output_window($status); + } +} + +/* obtain alert description for an ip address */ +function get_snort_alert($ip) { + global $snort_alert_file_split, $snort_config; + if(!file_exists("/var/log/snort/alert")) + return; + if(!$snort_config) + $snort_config = read_snort_config_cache(); + if($snort_config[$ip]) + return $snort_config[$ip]; + if(!$snort_alert_file_split) + $snort_alert_file_split = split("\n", file_get_contents("/var/log/snort/alert")); + foreach($snort_alert_file_split as $fileline) { + if (preg_match("/\[\*\*\] (\[.*\]) (.*) (\[\*\*\])/", $fileline, $matches)) + $alert_title = $matches[2]; + if (preg_match("/(\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b)/", $fileline, $matches)) + $alert_ip = $matches[0]; + if($alert_ip == $ip) { + if(!$snort_config[$ip]) + $snort_config[$ip] = $alert_title; + return $alert_title; + } + } + return "n/a"; +} + +function make_clickable($buffer) { + global $config, $g; + /* if clickable urls is disabled, simply return buffer back to caller */ + $clickablalerteurls = $config['installedpackages']['snort']['config'][0]['oinkmastercode']; + if(!$clickablalerteurls) + return $buffer; + $buffer = eregi_replace("(^|[ \n\r\t])((http(s?)://)(www\.)?([a-z0-9_-]+(\.[a-z0-9_-]+)+)(/[^/ \n\r]*)*)","\\1\\2", $buffer); + $buffer = eregi_replace("(^|[ \n\r\t])((ftp://)(www\.)?([a-z0-9_-]+(\.[a-z0-9_-]+)+)(/[^/ \n\r]*)*)","\\1\\2", $buffer); + $buffer = eregi_replace("([a-z_-][a-z0-9\._-]*@[a-z0-9_-]+(\.[a-z0-9_-]+)+)","\\1", $buffer); + $buffer = eregi_replace("(^|[ \n\r\t])(www\.([a-z0-9_-]+(\.[a-z0-9_-]+)+)(/[^/ \n\r]*)*)","\\1\\2", $buffer); + $buffer = eregi_replace("(^|[ \n\r\t])(ftp\.([a-z0-9_-]+(\.[a-z0-9_-]+)+)(/[^/ \n\r]*)*)","\\1\\2", $buffer); + + return $buffer; +} + +function read_snort_config_cache() { + global $g, $config, $snort_config; + if($snort_config) + return $snort_config; + if(file_exists($g['tmp_path'] . '/snort_config.cache')) { + $snort_config = unserialize(file_get_contents($g['tmp_path'] . '/snort_config.cache')); + return $snort_config; + } + return; +} + +function write_snort_config_cache($snort_config) { + global $g, $config; + conf_mount_rw(); + $configcache = fopen($g['tmp_path'] . '/snort_config.cache', "w"); + if(!$configcache) { + log_error("Could not open {$g['tmp_path']}/snort_config.cache for writing."); + return false; + } + fwrite($configcache, serialize($snort_config)); + fclose($configcache); + conf_mount_ro(); + return true; +} + +function snort_advanced() { + global $g, $config; + sync_package_snort(); +} + +function snort_define_servers() { + global $g, $config; + sync_package_snort(); +} + +?> diff --git a/config/snort-old/snort.xml b/config/snort-old/snort.xml new file mode 100644 index 00000000..6f067f2d --- /dev/null +++ b/config/snort-old/snort.xml @@ -0,0 +1,378 @@ + + + + + + . + 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. + */ +/* ========================================================================== */ + ]]> + + Describe your package here + Describe your package requirements here + Currently there are no FAQ items provided. + Snort + 2.8.4.1_5 + Services: Snort 2.8.4.1_5 pkg v. 1.7 + /usr/local/pkg/snort.inc + + Snort + Setup snort specific settings +
    Services
    + /pkg_edit.php?xml=snort.xml&id=0 +
    + + snort + snort.sh + snort + Snort is the most widely deployed IDS/IPS technology worldwide.. + + + + Settings + /pkg_edit.php?xml=snort.xml&id=0 + + + + Update Rules + /snort_download_rules.php + + + Categories + /snort_rulesets.php + + + Rules + /snort_rules.php + + + Servers + /pkg_edit.php?xml=snort_define_servers.xml&id=0 + + + Blocked + /snort_blocked.php + + + Whitelist + /pkg.php?xml=snort_whitelist.xml + + + Threshold + /pkg.php?xml=snort_threshold.xml + + + Alerts + /snort_alerts.php + + + Advanced + /pkg_edit.php?xml=snort_advanced.xml&id=0 + + + + /usr/local/pkg/ + 077 + http://www.pfsense.com/packages/config/snort-old/snort.inc + + + /usr/local/bin/ + 077 + http://www.pfsense.com/packages/config/snort-old/bin/barnyard2 + + + /usr/local/bin/ + 077 + http://www.pfsense.com/packages/config/snort-old/bin/oinkmaster_contrib/create-sidmap.pl + + + /usr/local/bin/ + 077 + http://www.pfsense.com/packages/config/snort-old/bin/oinkmaster_contrib/oinkmaster.pl + + + /usr/local/www/ + 077 + http://www.pfsense.com/packages/config/snort-old/snort_download_rules.php + + + /usr/local/www/ + 077 + http://www.pfsense.com/packages/config/snort-old/snort_rules.php + + + /usr/local/www/ + 077 + http://www.pfsense.com/packages/config/snort-old/snort_rules_edit.php + + + /usr/local/www/ + 077 + http://www.pfsense.com/packages/config/snort-old/snort_rulesets.php + + + /usr/local/pkg/ + 077 + http://www.pfsense.com/packages/config/snort-old/snort_whitelist.xml + + + /usr/local/www/ + 077 + http://www.pfsense.com/packages/config/snort-old/snort_blocked.php + + + /usr/local/pkg/ + 077 + http://www.pfsense.com/packages/config/snort-old/snort_check_for_rule_updates.php + + + /usr/local/www/ + 077 + http://www.pfsense.com/packages/config/snort-old/snort_alerts.php + + + /usr/local/pkg/pf/ + 077 + http://www.pfsense.com/packages/config/snort-old/snort_dynamic_ip_reload.php + + + /usr/local/pkg/ + 077 + http://www.pfsense.com/packages/config/snort-old/snort_advanced.xml + + + /usr/local/pkg/ + 077 + http://www.pfsense.com/packages/config/snort-old/snort_define_servers.xml + + + /usr/local/pkg/ + 077 + http://www.pfsense.com/packages/config/snort-old/snort_threshold.xml + + + /usr/local/pkg/ + 077 + http://www.pfsense.com/packages/config/snort-old/pfsense_rules/local.rules + + + + Interface + iface_array + Select the interface(s) Snort will listen on. + interfaces_selection + 3 + lan + true + + + Memory Performance + performance + Lowmem and ac-bnfa are recommended for low end systems, Ac: high memory, best performance, ac-std: moderate memory,high performance, acs: small memory, moderateperformance, ac-banded: small memory,moderate performance, ac-sparsebands: small memory, high performance. + select + + + + + + + + + + + + Oinkmaster code + oinkmastercode + Obtain a snort.org Oinkmaster code and paste here. + input + 60 + + + + Snort.org subscriber + subscriber + Check this box if you are a Snort.org subscriber (premium rules). + checkbox + 60 + + + Block offenders + blockoffenders7 + Checking this option will automatically block hosts that generate a snort alert. + checkbox + 60 + + + Remove blocked hosts every + rm_blocked + Please select the amount of time hosts are blocked + select + + + + + + + + + + + + + + + + Update rules automatically + autorulesupdate7 + Please select the update times for rules. + select + + + + + + + + + + + + Whitelist VPNs automatically + whitelistvpns + Checking this option will install whitelists for all VPNs. + checkbox + + + Convert Snort alerts urls to clickable links + clickablalerteurls + Checking this option will automatically convert URLs in the Snort alerts tab to clickable links. + checkbox + + + Associate events on Blocked tab + associatealertip + Checking this option will automatically associate the blocked reason from the snort alerts file. + checkbox + + + Install emergingthreats rules. + emergingthreats + Emerging Threats is an open source community that produces fastest moving and diverse Snort Rules. + checkbox + + + + sync_package_snort(); + + + + + sync_package_snort_reinstall(); + + + snort_deinstall(); + +
    diff --git a/config/snort-old/snort_advanced.xml b/config/snort-old/snort_advanced.xml new file mode 100644 index 00000000..1fdddda2 --- /dev/null +++ b/config/snort-old/snort_advanced.xml @@ -0,0 +1,196 @@ + + + + + + . + 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. + */ +/* ========================================================================== */ + ]]> + + Describe your package here + Describe your package requirements here + Currently there are no FAQ items provided. + SnortAdvanced + none + Services: Snort Advanced + /usr/local/pkg/snort.inc + + + Settings + /pkg_edit.php?xml=snort.xml&id=0 + + + Update Rules + /snort_download_rules.php + + + Categories + /snort_rulesets.php + + + Rules + /snort_rules.php + + + Servers + /pkg_edit.php?xml=snort_define_servers.xml&id=0 + + + Blocked + /snort_blocked.php + + + Whitelist + /pkg.php?xml=snort_whitelist.xml + + + Threshold + /pkg.php?xml=snort_threshold.xml + + + Alerts + /snort_alerts.php + + + Advanced + /pkg_edit.php?xml=snort_advanced.xml&id=0 + + + + + + BPF Buffer size + bpfbufsize + Changing this option adjusts the system BPF buffer size. Leave blank if you do not know what this does. Default is 1024. + input + + + Maximum BPF buffer size + bpfmaxbufsize + Changing this option adjusts the system maximum BPF buffer size. Leave blank if you do not know what this does. Default is 524288. This value should never be set above hardware cache size. The best (optimal size) is 50% - 80% of the hardware cache size. + input + + + Maximum BPF inserts + bpfmaxinsns + Changing this option adjusts the system maximum BPF insert size. Leave blank if you do not know what this does. Default is 512. + input + + + Advanced configuration pass through + configpassthru + Add items to here will be automatically inserted into the running snort configuration + textarea + 40 + 5 + + + Snort signature info files. + signatureinfo + Snort signature info files will be installed during updates. At leats 500 mb of memory is needed. + checkbox + + + Alerts Tab logging type. + snortalertlogtype + Please choose the type of Alert logging you will like see in the Alerts Tab. The options are Full descriptions or Fast short descriptions + select + + + + + + + Send alerts to main System logs. + alertsystemlog + Snort will send Alerts to the Pfsense system logs. + checkbox + + + Log to a Tcpdump file. + tcpdumplog + Snort will log packets to a tcpdump-formatted file. The file then can be analyzed by a wireshark type of application. WARNING: File may become large. + checkbox + + + Enable Barnyard2. + snortbarnyardlog + This will enable barnyard2 in the snort package. You will also have to set the database credentials. + checkbox + + + Barnyard2 Log Mysql Database. + snortbarnyardlog_database + Example: output database: log, mysql, dbname=snort user=snort host=localhost password=xyz + input + 101 + + + + Barnyard2 Configure Hostname ID. + snortbarnyardlog_hostname + Example: pfsense.local + input + 25 + + + + Barnyard2 Configure Interface ID + snortbarnyardlog_interface + Example: vr0 + input + 25 + + + + Log Alerts to a snort unified2 file. + snortunifiedlog + Snort will log Alerts to a file in the UNIFIED2 format. This is a requirement for barnyard2. + checkbox + + + + snort_advanced(); + + diff --git a/config/snort-old/snort_alerts.php b/config/snort-old/snort_alerts.php new file mode 100644 index 00000000..e67b9b5f --- /dev/null +++ b/config/snort-old/snort_alerts.php @@ -0,0 +1,124 @@ +. + Copyright (C) 2003-2004 Manuel Kasper . + 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("globals.inc"); +require("guiconfig.inc"); +require("/usr/local/pkg/snort.inc"); + +$snort_logfile = "{$g['varlog_path']}/snort/alert"; + +$nentries = $config['syslog']['nentries']; +if (!$nentries) + $nentries = 50; + +if ($_POST['clear']) { + exec("killall syslogd"); + conf_mount_rw(); + exec("rm {$snort_logfile}; touch {$snort_logfile}"); + conf_mount_ro(); + system_syslogd_start(); + exec("/usr/bin/killall -HUP snort"); + exec("/usr/bin/killall snort2c"); + if ($config['installedpackages']['snort']['config'][0]['blockoffenders'] == 'on') + exec("/usr/local/bin/snort2c -w /var/db/whitelist -a /var/log/snort/alert"); +} + +$pgtitle = "Services: Snort: Snort Alerts"; +include("head.inc"); + +?> + + + +

    "; +?> + + + + + +
    + +
    +
    + + + + + + +
    + Last Snort Alert entries

    +
    +
    + +
    + + + + + + +\n"; + echo "
    " . make_clickable($ww_logent) . " 
    + + + + + + +
    + +
    +
    + + + + +
    + + + + + + +"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + echo "\n"; + if($counter < 1) + echo "\n"; + else + echo "\n"; + +?> + +
    RemoveIPAlert Description
    "; + echo "\n\"Delete\" {$ww_ip} {$alert_description}
     
    There are currently no items being blocked by snort.
    {$counter} items listed.
    +
    +
    +
    + + + +

    + + + + + + + + + \ No newline at end of file diff --git a/config/snort-old/snort_check_for_rule_updates.php b/config/snort-old/snort_check_for_rule_updates.php new file mode 100644 index 00000000..8d308245 --- /dev/null +++ b/config/snort-old/snort_check_for_rule_updates.php @@ -0,0 +1,634 @@ + + + + filesize("{$tmpfname}/$snort_filename")){ + echo "Error with the snort rules download...\n"; + echo "Snort rules file downloaded failed...\n"; + exit(0); + } + } +} + +/* download emergingthreats rules file */ +if ($emergingthreats_url_chk == on) { +if ($emerg_md5_check_chk_ok != on) { +if (file_exists("{$tmpfname}/{$emergingthreats_filename}")) { + echo "Emergingthreats tar file exists...\n"; +} else { + echo "There is a new set of Emergingthreats rules posted. Downloading...\n"; + echo "May take 4 to 10 min...\n"; + ini_set('user_agent','Mozilla/4.0 (compatible; MSIE 6.0)'); + $image = @file_get_contents("http://www.emergingthreats.net/rules/emerging.rules.tar.gz"); +// $image = @file_get_contents("http://www.emergingthreats.net/rules/emerging.rules.tar.gz"); + $f = fopen("{$tmpfname}/emerging.rules.tar.gz", 'w'); + fwrite($f, $image); + fclose($f); + echo "Done downloading Emergingthreats rules file.\n"; + } + } + } + +/* download pfsense rules file */ +if ($pfsense_md5_check_ok != on) { +if (file_exists("{$tmpfname}/{$pfsense_rules_filename}")) { + echo "Snortrule tar file exists...\n"; +} else { + + echo "There is a new set of Pfsense rules posted. Downloading...\n"; + echo "May take 4 to 10 min...\n"; + ini_set('user_agent','Mozilla/4.0 (compatible; MSIE 6.0)'); + $image = @file_get_contents("http://www.pfsense.com/packages/config/snort/pfsense_rules/pfsense_rules.tar.gz"); +// $image = @file_get_contents("http://www.mtest.local/pub-bin/oinkmaster.cgi/{$oinkid}/pfsense_rules.tar.gz"); + $f = fopen("{$tmpfname}/pfsense_rules.tar.gz", 'w'); + fwrite($f, $image); + fclose($f); + echo "Done downloading rules file.\n"; + } +} + +/* Untar snort rules file individually to help people with low system specs */ +if ($snort_md5_check_ok != on) { +if (file_exists("{$tmpfname}/{$snort_filename}")) { + echo "Extracting rules...\n"; + echo "May take a while...\n"; + exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} rules/"); + exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} etc/"); + exec("`/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/precompiled/FreeBSD-7.0/i386/2.8.4/*`"); + exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/bad-traffic.rules/"); + exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/chat.rules/"); + exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/dos.rules/"); + exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/exploit.rules/"); + exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/imap.rules/"); + exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/misc.rules/"); + exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/multimedia.rules/"); + exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/netbios.rules/"); + exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/nntp.rules/"); + exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/p2p.rules/"); + exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/smtp.rules/"); + exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/sql.rules/"); + exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/web-client.rules/"); + exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/web-misc.rules/"); + echo "Done extracting Rules.\n"; +} else { + echo "The Download rules file missing...\n"; + echo "Error rules extracting failed...\n"; + exit(0); + } +} + +/* Untar emergingthreats rules to tmp */ +if ($emergingthreats_url_chk == on) { +if ($emerg_md5_check_chk_ok != on) { +if (file_exists("{$tmpfname}/{$emergingthreats_filename}")) { + echo "Extracting rules...\n"; + echo "May take a while...\n"; + exec("/usr/bin/tar xzf {$tmpfname}/{$emergingthreats_filename} -C {$snortdir} rules/"); + } + } +} + +/* Untar Pfsense rules to tmp */ +if ($pfsense_md5_check_ok != on) { +if (file_exists("{$tmpfname}/{$pfsense_rules_filename}")) { + echo "Extracting Pfsense rules...\n"; + echo "May take a while...\n"; + exec("/usr/bin/tar xzf {$tmpfname}/{$pfsense_rules_filename} -C {$snortdir} rules/"); + } +} + +/* Untar snort signatures */ +if ($snort_md5_check_ok != on) { +if (file_exists("{$tmpfname}/{$snort_filename}")) { +$signature_info_chk = $config['installedpackages']['snortadvanced']['config'][0]['signatureinfo']; +if ($premium_url_chk == on) { + echo "Extracting Signatures...\n"; + echo "May take a while...\n"; + exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} doc/signatures/"); + echo "Done extracting Signatures.\n"; + } + } +} + +/* Make Clean Snort Directory */ +//if ($snort_md5_check_ok != on && $emerg_md5_check_chk_ok != on && $pfsense_md5_check_ok != on) { +//if (file_exists("{$snortdir}/rules")) { +// echo "Cleaning the snort Directory...\n"; +// echo "removing...\n"; +// exec("/bin/mkdir -p {$snortdir}"); +// exec("/bin/mkdir -p {$snortdir}/rules"); +// exec("/bin/mkdir -p {$snortdir}/signatures"); +// exec("/bin/rm {$snortdir}/*"); +// exec("/bin/rm {$snortdir}/rules/*"); +// exec("/bin/rm {$snortdir_wan}/*"); +// exec("/bin/rm {$snortdir_wan}/rules/*"); +// exec("/bin/rm /usr/local/lib/snort/dynamicrules/*"); +//} else { +// echo "Making Snort Directory...\n"; +// echo "should be fast...\n"; +// exec("/bin/mkdir {$snortdir}"); +// exec("/bin/mkdir {$snortdir}/rules"); +// exec("/bin/rm {$snortdir_wan}/\*"); +// exec("/bin/rm {$snortdir_wan}/rules/*"); +// exec("/bin/rm /usr/local/lib/snort/dynamicrules/\*"); +// echo "Done making snort direcory.\n"; +// } +//} + +/* Copy so_rules dir to snort lib dir */ +if ($snort_md5_check_ok != on) { +if (file_exists("{$snortdir}/so_rules/precompiled/FreeBSD-7.0/i386/2.8.4/")) { + echo "Copying so_rules...\n"; + echo "May take a while...\n"; + sleep(2); + exec("`/bin/cp -f {$snortdir}/so_rules/precompiled/FreeBSD-7.0/i386/2.8.4/* /usr/local/lib/snort/dynamicrules/`"); + exec("/bin/cp {$snortdir}/so_rules/bad-traffic.rules {$snortdir}/rules/bad-traffic.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/chat.rules {$snortdir}/rules/chat.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/dos.rules {$snortdir}/rules/dos.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/exploit.rules {$snortdir}/rules/exploit.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/imap.rules {$snortdir}/rules/imap.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/misc.rules {$snortdir}/rules/misc.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/multimedia.rules {$snortdir}/rules/multimedia.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/netbios.rules {$snortdir}/rules/netbios.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/nntp.rules {$snortdir}/rules/nntp.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/p2p.rules {$snortdir}/rules/p2p.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/smtp.rules {$snortdir}/rules/smtp.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/sql.rules {$snortdir}/rules/sql.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/web-client.rules {$snortdir}/rules/web-client.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/web-misc.rules {$snortdir}/rules/web-misc.so.rules"); + exec("/bin/rm -r {$snortdir}/so_rules"); + echo "Done copying so_rules.\n"; +} else { + echo "Directory so_rules does not exist...\n"; + echo "Error copping so_rules...\n"; + exit(0); + } +} + +/* enable disable setting will carry over with updates */ +/* TODO carry signature changes with the updates */ +if ($snort_md5_check_ok != on || $emerg_md5_check_chk_ok != on || $pfsense_md5_check_ok != on) { + +if (!empty($config['installedpackages']['snort']['rule_sid_on'])) { +$enabled_sid_on = $config['installedpackages']['snort']['rule_sid_on']; +$enabled_sid_on_array = split('\|\|', $enabled_sid_on); +foreach($enabled_sid_on_array as $enabled_item_on) +$selected_sid_on_sections .= "$enabled_item_on\n"; + } + +if (!empty($config['installedpackages']['snort']['rule_sid_off'])) { +$enabled_sid_off = $config['installedpackages']['snort']['rule_sid_off']; +$enabled_sid_off_array = split('\|\|', $enabled_sid_off); +foreach($enabled_sid_off_array as $enabled_item_off) +$selected_sid_off_sections .= "$enabled_item_off\n"; + } + +$snort_sid_text = << /usr/local/etc/snort_bkup/sid-msg.map"); + +/* Run oinkmaster to snort_wan and cp configs */ +/* If oinkmaster is not needed cp rules normally */ +/* TODO add per interface settings here */ +if ($snort_md5_check_ok != on || $emerg_md5_check_chk_ok != on || $pfsense_md5_check_ok != on) { + + if (empty($config['installedpackages']['snort']['rule_sid_on']) || empty($config['installedpackages']['snort']['rule_sid_off'])) { +echo "Your first set of rules are being copied...\n"; +echo "May take a while...\n"; + + exec("/bin/cp {$snortdir}/rules/* {$snortdir_wan}/rules/"); + exec("/bin/cp {$snortdir}/classification.config {$snortdir_wan}"); + exec("/bin/cp {$snortdir}/gen-msg.map {$snortdir_wan}"); + exec("/bin/cp {$snortdir}/generators {$snortdir_wan}"); + exec("/bin/cp {$snortdir}/reference.config {$snortdir_wan}"); + exec("/bin/cp {$snortdir}/sid {$snortdir_wan}"); + exec("/bin/cp {$snortdir}/sid-msg.map {$snortdir_wan}"); + exec("/bin/cp {$snortdir}/unicode.map {$snortdir_wan}"); + +} else { + echo "Your enable and disable changes are being applied to your fresh set of rules...\n"; + echo "May take a while...\n"; + exec("/bin/cp {$snortdir}/rules/* {$snortdir_wan}/rules/"); + exec("/bin/cp {$snortdir}/classification.config {$snortdir_wan}"); + exec("/bin/cp {$snortdir}/gen-msg.map {$snortdir_wan}"); + exec("/bin/cp {$snortdir}/generators {$snortdir_wan}"); + exec("/bin/cp {$snortdir}/reference.config {$snortdir_wan}"); + exec("/bin/cp {$snortdir}/sid {$snortdir_wan}"); + exec("/bin/cp {$snortdir}/sid-msg.map {$snortdir_wan}"); + exec("/bin/cp {$snortdir}/unicode.map {$snortdir_wan}"); + + /* oinkmaster.pl will convert saved changes for the new updates then we have to change #alert to # alert for the gui */ + /* might have to add a sleep for 3sec for flash drives or old drives */ + exec("/usr/local/bin/perl /usr/local/bin/oinkmaster.pl -C /usr/local/etc/snort_bkup/oinkmaster.conf -o /usr/local/etc/snort/rules > /usr/local/etc/snort_bkup/oinkmaster.log"); + exec("/usr/local/bin/perl -pi -e 's/#alert/# alert/g' /usr/local/etc/snort/rules/*.rules"); + exec("/usr/local/bin/perl -pi -e 's/##alert/# alert/g' /usr/local/etc/snort/rules/*.rules"); + exec("/usr/local/bin/perl -pi -e 's/## alert/# alert/g' /usr/local/etc/snort/rules/*.rules"); + + } +} + +/* remove old $tmpfname files */ +if (file_exists("{$tmpfname}")) { + echo "Cleaning up...\n"; + exec("/bin/rm -r /root/snort_rules_up"); +} + +/* php code to flush out cache some people are reportting missing files this might help */ +sleep(5); +apc_clear_cache(); +exec("/bin/sync ;/bin/sync ;/bin/sync ;/bin/sync ;/bin/sync ;/bin/sync ;/bin/sync ;/bin/sync"); + +/* if snort is running hardrestart, if snort is not running do nothing */ +if (file_exists("/tmp/snort_download_halt.pid")) { + start_service("snort"); + echo "The Rules update finished...\n"; + echo "Snort has restarted with your new set of rules...\n"; + exec("/bin/rm /tmp/snort_download_halt.pid"); +} else { + echo "The Rules update finished...\n"; + echo "You may start snort now...\n"; +} +conf_mount_ro(); + +?> diff --git a/config/snort-old/snort_define_servers.xml b/config/snort-old/snort_define_servers.xml new file mode 100644 index 00000000..7df880d0 --- /dev/null +++ b/config/snort-old/snort_define_servers.xml @@ -0,0 +1,364 @@ + + + + + + . + 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. + */ +/* ========================================================================== */ + ]]> + + Describe your package here + Describe your package requirements here + Currently there are no FAQ items provided. + SnortDefServers + none + Services: Snort Define Servers + /usr/local/pkg/snort.inc + + + Settings + /pkg_edit.php?xml=snort.xml&id=0 + + + Update Rules + /snort_download_rules.php + + + Categories + /snort_rulesets.php + + + Rules + /snort_rules.php + + + Servers + /pkg_edit.php?xml=snort_define_servers.xml&id=0 + + + + Blocked + /snort_blocked.php + + + Whitelist + /pkg.php?xml=snort_whitelist.xml + + + Threshold + /pkg.php?xml=snort_threshold.xml + + + Alerts + /snort_alerts.php + + + Advanced + /pkg_edit.php?xml=snort_advanced.xml&id=0 + + + + + Define DNS_SERVERS + def_dns_servers + Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks. + input + 101 + + + + Define DNS_PORTS + def_dns_ports + Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 53. + input + 43 + + + + Define SMTP_SERVERS + def_smtp_servers + Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks. + input + 101 + + + + Define SMTP_PORTS + def_smtp_ports + Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 25. + input + 43 + + + + Define Mail_Ports + def_mail_ports + Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 25,143,465,691. + input + 43 + + + + Define HTTP_SERVERS + def_http_servers + Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks. + input + 101 + + + + Define WWW_SERVERS + def_www_servers + Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks. + input + 101 + + + + Define HTTP_PORTS + def_http_ports + Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 80. + input + 43 + + + + Define SQL_SERVERS + def_sql_servers + Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks. + input + 101 + + + + Define ORACLE_PORTS + def_oracle_ports + Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 1521. + input + 43 + + + + Define MSSQL_PORTS + def_mssql_ports + Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 1433. + input + 43 + + + + Define TELNET_SERVERS + def_telnet_servers + Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks. + input + 101 + + + + Define TELNET_PORTS + def_telnet_ports + Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 23. + input + 43 + + + + Define SNMP_SERVERS + def_snmp_servers + Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks. + input + 101 + + + + Define SNMP_PORTS + def_snmp_ports + Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 161. + input + 43 + + + + Define FTP_SERVERS + def_ftp_servers + Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks. + input + 101 + + + + Define FTP_PORTS + def_ftp_ports + Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 21. + input + 43 + + + + Define SSH_SERVERS + def_ssh_servers + Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks. + input + 101 + + + + Define SSH_PORTS + def_ssh_ports + Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is Pfsense SSH port. + input + 43 + + + + Define POP_SERVERS + def_pop_servers + Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks. + input + 101 + + + + Define POP2_PORTS + def_pop2_ports + Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 109. + input + 43 + + + + Define POP3_PORTS + def_pop3_ports + Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 110. + input + 43 + + + + Define IMAP_SERVERS + def_imap_servers + Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks. + input + 101 + + + + Define IMAP_PORTS + def_imap_ports + Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 143. + input + 43 + + + + Define SIP_PROXY_IP + def_sip_proxy_ip + Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks. + input + 101 + + + + Define SIP_PROXY_PORTS + def_sip_proxy_ports + Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 5060:5090,16384:32768. + input + 43 + + + + Define AUTH_PORTS + def_auth_ports + Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 113. + input + 43 + + + + Define FINGER_PORTS + def_finger_ports + Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 79. + input + 43 + + + + Define IRC_PORTS + def_irc_ports + Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 6665,6666,6667,6668,6669,7000. + input + 43 + + + + Define NNTP_PORTS + def_nntp_ports + Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 119. + input + 43 + + + + Define RLOGIN_PORTS + def_rlogin_ports + Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 513. + input + 43 + + + + Define RSH_PORTS + def_rsh_ports + Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 514. + input + 43 + + + + Define SSL_PORTS + def_ssl_ports + Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 25,443,465,636,993,995. + input + 43 + + + + + snort_define_servers(); + + diff --git a/config/snort-old/snort_download_rules.php b/config/snort-old/snort_download_rules.php new file mode 100644 index 00000000..9826ba2a --- /dev/null +++ b/config/snort-old/snort_download_rules.php @@ -0,0 +1,790 @@ + + + + + + + + +

    "; +?> + +
    +
    + + + + + + + + +
    + +
    +
    + + + + +
    + + + + + +
    + /images/misc/progress_bar.gif' width='280' height='23' name='progressbar' id='progressbar' alt='' /> +
    +
    + + + + +
    +
    +
    +
    + + + +You last checked for updates: {$last_md5_download}

    \n"; + echo "\n

    You last installed for rules: {$last_rules_install}

    \n"; + echo "\n\n\n\n"; + exit(0); +} + +/* If emergingthreats md5 file is empty wait 15min exit not needed */ + +/* If pfsense md5 file is empty wait 15min exit */ +if (0 == filesize("{$tmpfname}/$pfsense_rules_filename_md5")){ + update_status(gettext("Please wait... You may only check for New Pfsense Rules every 15 minutes...")); + update_output_window(gettext("Rules are released to support Pfsense packages.")); + hide_progress_bar_status(); + /* Display last time of sucsessful md5 check from cache */ + echo "\n

    You last checked for updates: {$last_md5_download}

    \n"; + echo "\n

    You last installed for rules: {$last_rules_install}

    \n"; + echo "\n\n\n\n"; + exit(0); +} + +/* Check if were up to date snort.org */ +if (file_exists("{$snortdir}/snortrules-snapshot-2.8.tar.gz.md5")){ +$md5_check_new_parse = file_get_contents("{$tmpfname}/{$snort_filename_md5}"); +$md5_check_new = `/bin/echo "{$md5_check_new_parse}" | /usr/bin/awk '{ print $1 }'`; +$md5_check_old_parse = file_get_contents("{$snortdir}/{$snort_filename_md5}"); +$md5_check_old = `/bin/echo "{$md5_check_old_parse}" | /usr/bin/awk '{ print $1 }'`; +/* Write out time of last sucsessful md5 to cache */ +$config['installedpackages']['snort']['last_md5_download'] = date("Y-M-jS-h:i-A"); +write_config(); // Will cause switch back to read-only on nanobsd +conf_mount_rw(); +if ($md5_check_new == $md5_check_old) { + update_status(gettext("Your rules are up to date...")); + update_output_window(gettext("You may start Snort now, check update.")); + hide_progress_bar_status(); + /* Timestamps to html */ + echo "\n

    You last checked for updates: {$last_md5_download}

    \n"; + echo "\n

    You last installed for rules: {$last_rules_install}

    \n"; +// echo "P is this code {$premium_subscriber}"; + echo "\n\n\n\n"; + $snort_md5_check_ok = on; + } +} + +/* Check if were up to date emergingthreats.net */ +$emergingthreats_url_chk = $config['installedpackages']['snort']['config'][0]['emergingthreats']; +if ($emergingthreats_url_chk == on) { +if (file_exists("{$snortdir}/version.txt")){ +$emerg_md5_check_new_parse = file_get_contents("{$tmpfname}/version.txt"); +$emerg_md5_check_new = `/bin/echo "{$emerg_md5_check_new_parse}" | /usr/bin/awk '{ print $1 }'`; +$emerg_md5_check_old_parse = file_get_contents("{$snortdir}/version.txt"); +$emerg_md5_check_old = `/bin/echo "{$emerg_md5_check_old_parse}" | /usr/bin/awk '{ print $1 }'`; +/* Write out time of last sucsessful md5 to cache */ +$config['installedpackages']['snort']['last_md5_download'] = date("Y-M-jS-h:i-A"); +write_config(); // Will cause switch back to read-only on nanobsd +conf_mount_rw(); +if ($emerg_md5_check_new == $emerg_md5_check_old) { + update_status(gettext("Your emergingthreats rules are up to date...")); + update_output_window(gettext("You may start Snort now, check update.")); + hide_progress_bar_status(); + $emerg_md5_check_chk_ok = on; + } + } +} + +/* Check if were up to date pfsense.org */ +if (file_exists("{$snortdir}/$pfsense_rules_filename_md5")){ +$pfsense_md5_check_new_parse = file_get_contents("{$tmpfname}/{$snort_filename_md5}"); +$pfsense_md5_check_new = `/bin/echo "{$pfsense_md5_check_new_parse}" | /usr/bin/awk '{ print $1 }'`; +$pfsense_md5_check_old_parse = file_get_contents("{$snortdir}/{$snort_filename_md5}"); +$pfsense_md5_check_old = `/bin/echo "{$md5_check_old_parse}" | /usr/bin/awk '{ print $1 }'`; +if ($pfsense_md5_check_new == $pfsense_md5_check_old) { + $pfsense_md5_check_ok = on; + } +} + +/* Make Clean Snort Directory emergingthreats not checked */ +if ($snort_md5_check_ok == on && $emergingthreats_url_chk != on) { + update_status(gettext("Cleaning the snort Directory...")); + update_output_window(gettext("removing...")); + exec("/bin/rm {$snortdir}/rules/emerging*"); + exec("/bin/rm {$snortdir}/version.txt"); + exec("/bin/rm {$snortdir_wan}/rules/emerging*"); + exec("/bin/rm {$snortdir_wan}/version.txt"); + update_status(gettext("Done making cleaning emrg direcory.")); +} + +/* Check if were up to date exits */ +if ($snort_md5_check_ok == on && $emerg_md5_check_chk_ok == on && $pfsense_md5_check_ok == on) { + update_status(gettext("Your rules are up to date...")); + update_output_window(gettext("You may start Snort now...")); + exit(0); +} + +if ($snort_md5_check_ok == on && $pfsense_md5_check_ok == on && $emergingthreats_url_chk != on) { + update_status(gettext("Your rules are up to date...")); + update_output_window(gettext("You may start Snort now...")); + exit(0); +} + +/* You are Not Up to date, always stop snort when updating rules for low end machines */; +update_status(gettext("You are NOT up to date...")); +update_output_window(gettext("Stopping Snort service...")); +$chk_if_snort_up = exec("pgrep -x snort"); +if ($chk_if_snort_up != "") { + exec("/usr/bin/touch /tmp/snort_download_halt.pid"); + stop_service("snort"); + sleep(2); +} + +/* download snortrules file */ +if ($snort_md5_check_ok != on) { +if (file_exists("{$tmpfname}/{$snort_filename}")) { + update_status(gettext("Snortrule tar file exists...")); +} else { + unhide_progress_bar_status(); + update_status(gettext("There is a new set of Snort rules posted. Downloading...")); + update_output_window(gettext("May take 4 to 10 min...")); +// download_file_with_progress_bar("http://www.mtest.local/pub-bin/oinkmaster.cgi/{$oinkid}/snortrules-snapshot-2.8{$premium_subscriber}.tar.gz", $tmpfname . "/{$snort_filename}", "read_body_firmware"); + download_file_with_progress_bar("http://dl.snort.org/{$premium_url}/snortrules-snapshot-2.8{$premium_subscriber}.tar.gz?oink_code={$oinkid}", $tmpfname . "/{$snort_filename}", "read_body_firmware"); + update_all_status($static_output); + update_status(gettext("Done downloading rules file.")); + if (150000 > filesize("{$tmpfname}/$snort_filename")){ + update_status(gettext("Error with the snort rules download...")); + update_output_window(gettext("Snort rules file downloaded failed...")); + exit(0); + } + } +} + +/* download emergingthreats rules file */ +if ($emergingthreats_url_chk == on) { +if ($emerg_md5_check_chk_ok != on) { +if (file_exists("{$tmpfname}/{$emergingthreats_filename}")) { + update_status(gettext("Emergingthreats tar file exists...")); +} else { + update_status(gettext("There is a new set of Emergingthreats rules posted. Downloading...")); + update_output_window(gettext("May take 4 to 10 min...")); +// download_file_with_progress_bar("http://www.mtest.local/pub-bin/oinkmaster.cgi/{$oinkid}/emerging.rules.tar.gz", $tmpfname . "/{$emergingthreats_filename}", "read_body_firmware"); + download_file_with_progress_bar("http://www.emergingthreats.net/rules/emerging.rules.tar.gz", $tmpfname . "/{$emergingthreats_filename}", "read_body_firmware"); + update_all_status($static_output); + update_status(gettext("Done downloading Emergingthreats rules file.")); + } + } + } + +/* download pfsense rules file */ +if ($pfsense_md5_check_ok != on) { +if (file_exists("{$tmpfname}/{$pfsense_rules_filename}")) { + update_status(gettext("Snortrule tar file exists...")); +} else { + unhide_progress_bar_status(); + update_status(gettext("There is a new set of Pfsense rules posted. Downloading...")); + update_output_window(gettext("May take 4 to 10 min...")); +// download_file_with_progress_bar("http://www.mtest.local/pub-bin/oinkmaster.cgi/{$oinkid}/pfsense_rules.tar.gz", $tmpfname . "/{$pfsense_rules_filename}", "read_body_firmware"); + download_file_with_progress_bar("http://www.pfsense.com/packages/config/snort/pfsense_rules/pfsense_rules.tar.gz", $tmpfname . "/{$pfsense_rules_filename}", "read_body_firmware"); + update_all_status($static_output); + update_status(gettext("Done downloading rules file.")); + } +} + +/* Compair md5 sig to file sig */ + +//$premium_url_chk = $config['installedpackages']['snort']['config'][0]['subscriber']; +//if ($premium_url_chk == on) { +//$md5 = file_get_contents("{$tmpfname}/{$snort_filename_md5}"); +//$file_md5_ondisk = `/sbin/md5 {$tmpfname}/{$snort_filename} | /usr/bin/awk '{ print $4 }'`; +// if ($md5 == $file_md5_ondisk) { +// update_status(gettext("Valid md5 checksum pass...")); +//} else { +// update_status(gettext("The downloaded file does not match the md5 file...P is ON")); +// update_output_window(gettext("Error md5 Mismatch...")); +// exit(0); +// } +//} + +//$premium_url_chk = $config['installedpackages']['snort']['config'][0]['subscriber']; +//if ($premium_url_chk != on) { +//$md55 = `/bin/cat {$tmpfname}/{$snort_filename_md5} | /usr/bin/awk '{ print $4 }'`; +//$file_md5_ondisk2 = `/sbin/md5 {$tmpfname}/{$snort_filename} | /usr/bin/awk '{ print $4 }'`; +// if ($md55 == $file_md5_ondisk2) { +// update_status(gettext("Valid md5 checksum pass...")); +//} else { +// update_status(gettext("The downloaded file does not match the md5 file...Not P")); +// update_output_window(gettext("Error md5 Mismatch...")); +// exit(0); +// } +//} + +/* Untar snort rules file individually to help people with low system specs */ +if ($snort_md5_check_ok != on) { +if (file_exists("{$tmpfname}/{$snort_filename}")) { + update_status(gettext("Extracting rules...")); + update_output_window(gettext("May take a while...")); + exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} rules/"); + exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} etc/"); + exec("`/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/precompiled/FreeBSD-7.0/i386/2.8.4/*`"); + exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/bad-traffic.rules/"); + exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/chat.rules/"); + exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/dos.rules/"); + exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/exploit.rules/"); + exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/imap.rules/"); + exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/misc.rules/"); + exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/multimedia.rules/"); + exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/netbios.rules/"); + exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/nntp.rules/"); + exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/p2p.rules/"); + exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/smtp.rules/"); + exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/sql.rules/"); + exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/web-client.rules/"); + exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/web-misc.rules/"); + update_status(gettext("Done extracting Rules.")); +} else { + update_status(gettext("The Download rules file missing...")); + update_output_window(gettext("Error rules extracting failed...")); + exit(0); + } +} + +/* Untar emergingthreats rules to tmp */ +if ($emergingthreats_url_chk == on) { +if ($emerg_md5_check_chk_ok != on) { +if (file_exists("{$tmpfname}/{$emergingthreats_filename}")) { + update_status(gettext("Extracting rules...")); + update_output_window(gettext("May take a while...")); + exec("/usr/bin/tar xzf {$tmpfname}/{$emergingthreats_filename} -C {$snortdir} rules/"); + } + } +} + +/* Untar Pfsense rules to tmp */ +if ($pfsense_md5_check_ok != on) { +if (file_exists("{$tmpfname}/{$pfsense_rules_filename}")) { + update_status(gettext("Extracting Pfsense rules...")); + update_output_window(gettext("May take a while...")); + exec("/usr/bin/tar xzf {$tmpfname}/{$pfsense_rules_filename} -C {$snortdir} rules/"); + } +} + +/* Untar snort signatures */ +if ($snort_md5_check_ok != on) { +if (file_exists("{$tmpfname}/{$snort_filename}")) { +$signature_info_chk = $config['installedpackages']['snortadvanced']['config'][0]['signatureinfo']; +if ($premium_url_chk == on) { + update_status(gettext("Extracting Signatures...")); + update_output_window(gettext("May take a while...")); + exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} doc/signatures/"); + update_status(gettext("Done extracting Signatures.")); + } + } +} + +/* Make Clean Snort Directory */ +//if ($snort_md5_check_ok != on && $emerg_md5_check_chk_ok != on && $pfsense_md5_check_ok != on) { +//if (file_exists("{$snortdir}/rules")) { +// update_status(gettext("Cleaning the snort Directory...")); +// update_output_window(gettext("removing...")); +// exec("/bin/mkdir -p {$snortdir}"); +// exec("/bin/mkdir -p {$snortdir}/rules"); +// exec("/bin/mkdir -p {$snortdir}/signatures"); +// exec("/bin/rm {$snortdir}/*"); +// exec("/bin/rm {$snortdir}/rules/*"); +// exec("/bin/rm {$snortdir_wan}/*"); +// exec("/bin/rm {$snortdir_wan}/rules/*"); + +// exec("/bin/rm /usr/local/lib/snort/dynamicrules/*"); +//} else { +// update_status(gettext("Making Snort Directory...")); +// update_output_window(gettext("should be fast...")); +// exec("/bin/mkdir -p {$snortdir}"); +// exec("/bin/mkdir -p {$snortdir}/rules"); +// exec("/bin/rm {$snortdir_wan}/*"); +// exec("/bin/rm {$snortdir_wan}/rules/*"); +// exec("/bin/rm /usr/local/lib/snort/dynamicrules/\*"); +// update_status(gettext("Done making snort direcory.")); +// } +//} + +/* Copy so_rules dir to snort lib dir */ +if ($snort_md5_check_ok != on) { +if (file_exists("{$snortdir}/so_rules/precompiled/FreeBSD-7.0/i386/2.8.4/")) { + update_status(gettext("Copying so_rules...")); + update_output_window(gettext("May take a while...")); + exec("`/bin/cp -f {$snortdir}/so_rules/precompiled/FreeBSD-7.0/i386/2.8.4/* /usr/local/lib/snort/dynamicrules/`"); + exec("/bin/cp {$snortdir}/so_rules/bad-traffic.rules {$snortdir}/rules/bad-traffic.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/chat.rules {$snortdir}/rules/chat.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/dos.rules {$snortdir}/rules/dos.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/exploit.rules {$snortdir}/rules/exploit.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/imap.rules {$snortdir}/rules/imap.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/misc.rules {$snortdir}/rules/misc.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/multimedia.rules {$snortdir}/rules/multimedia.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/netbios.rules {$snortdir}/rules/netbios.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/nntp.rules {$snortdir}/rules/nntp.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/p2p.rules {$snortdir}/rules/p2p.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/smtp.rules {$snortdir}/rules/smtp.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/sql.rules {$snortdir}/rules/sql.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/web-client.rules {$snortdir}/rules/web-client.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/web.misc.rules {$snortdir}/rules/web.misc.so.rules"); + exec("/bin/rm -r {$snortdir}/so_rules"); + update_status(gettext("Done copying so_rules.")); +} else { + update_status(gettext("Directory so_rules does not exist...")); + update_output_window(gettext("Error copying so_rules...")); + exit(0); + } +} + +/* enable disable setting will carry over with updates */ +/* TODO carry signature changes with the updates */ +if ($snort_md5_check_ok != on || $emerg_md5_check_chk_ok != on || $pfsense_md5_check_ok != on) { + +if (!empty($config['installedpackages']['snort']['rule_sid_on'])) { +$enabled_sid_on = $config['installedpackages']['snort']['rule_sid_on']; +$enabled_sid_on_array = split('\|\|', $enabled_sid_on); +foreach($enabled_sid_on_array as $enabled_item_on) +$selected_sid_on_sections .= "$enabled_item_on\n"; + } + +if (!empty($config['installedpackages']['snort']['rule_sid_off'])) { +$enabled_sid_off = $config['installedpackages']['snort']['rule_sid_off']; +$enabled_sid_off_array = split('\|\|', $enabled_sid_off); +foreach($enabled_sid_off_array as $enabled_item_off) +$selected_sid_off_sections .= "$enabled_item_off\n"; + } + +$snort_sid_text = << /usr/local/etc/snort_bkup/sid-msg.map"); + +/* Run oinkmaster to snort_wan and cp configs */ +/* If oinkmaster is not needed cp rules normally */ +/* TODO add per interface settings here */ +if ($snort_md5_check_ok != on || $emerg_md5_check_chk_ok != on || $pfsense_md5_check_ok != on) { + + if (empty($config['installedpackages']['snort']['rule_sid_on']) || empty($config['installedpackages']['snort']['rule_sid_off'])) { + update_status(gettext("Your first set of rules are being copied...")); + update_output_window(gettext("May take a while...")); + exec("/bin/cp {$snortdir}/rules/* {$snortdir_wan}/rules/"); + exec("/bin/cp {$snortdir}/classification.config {$snortdir_wan}"); + exec("/bin/cp {$snortdir}/gen-msg.map {$snortdir_wan}"); + exec("/bin/cp {$snortdir}/generators {$snortdir_wan}"); + exec("/bin/cp {$snortdir}/reference.config {$snortdir_wan}"); + exec("/bin/cp {$snortdir}/sid {$snortdir_wan}"); + exec("/bin/cp {$snortdir}/sid-msg.map {$snortdir_wan}"); + exec("/bin/cp {$snortdir}/unicode.map {$snortdir_wan}"); + +} else { + update_status(gettext("Your enable and disable changes are being applied to your fresh set of rules...")); + update_output_window(gettext("May take a while...")); + exec("/bin/cp {$snortdir}/rules/* {$snortdir_wan}/rules/"); + exec("/bin/cp {$snortdir}/classification.config {$snortdir_wan}"); + exec("/bin/cp {$snortdir}/gen-msg.map {$snortdir_wan}"); + exec("/bin/cp {$snortdir}/generators {$snortdir_wan}"); + exec("/bin/cp {$snortdir}/reference.config {$snortdir_wan}"); + exec("/bin/cp {$snortdir}/sid {$snortdir_wan}"); + exec("/bin/cp {$snortdir}/sid-msg.map {$snortdir_wan}"); + exec("/bin/cp {$snortdir}/unicode.map {$snortdir_wan}"); + + /* oinkmaster.pl will convert saved changes for the new updates then we have to change #alert to # alert for the gui */ + /* might have to add a sleep for 3sec for flash drives or old drives */ + exec("/usr/local/bin/perl /usr/local/bin/oinkmaster.pl -C /usr/local/etc/snort_bkup/oinkmaster.conf -o /usr/local/etc/snort/rules > /usr/local/etc/snort_bkup/oinkmaster.log"); + exec("/usr/local/bin/perl -pi -e 's/#alert/# alert/g' /usr/local/etc/snort/rules/*.rules"); + exec("/usr/local/bin/perl -pi -e 's/##alert/# alert/g' /usr/local/etc/snort/rules/*.rules"); + exec("/usr/local/bin/perl -pi -e 's/## alert/# alert/g' /usr/local/etc/snort/rules/*.rules"); + + + } +} + +/* remove old $tmpfname files */ +if (file_exists("{$tmpfname}")) { + update_status(gettext("Cleaning up...")); + exec("/bin/rm -r /root/snort_rules_up"); +// apc_clear_cache(); +} + +/* php code to flush out cache some people are reportting missing files this might help */ +sleep(2); +apc_clear_cache(); +exec("/bin/sync ;/bin/sync ;/bin/sync ;/bin/sync ;/bin/sync ;/bin/sync ;/bin/sync ;/bin/sync"); + +/* if snort is running hardrestart, if snort is not running do nothing */ +if (file_exists("/tmp/snort_download_halt.pid")) { + start_service("snort"); + update_status(gettext("The Rules update finished...")); + update_output_window(gettext("Snort has restarted with your new set of rules...")); + exec("/bin/rm /tmp/snort_download_halt.pid"); +} else { + update_status(gettext("The Rules update finished...")); + update_output_window(gettext("You may start snort now...")); +} + +/* hide progress bar and lets end this party */ +hide_progress_bar_status(); +conf_mount_ro(); +?> + + 150) { + update_output_window($text); + update_progress_bar($downloadProgress); + flush(); + $counter = 0; + } + conf_mount_rw(); + fwrite($fout, $string); + conf_mount_ro(); + return $length; +} + +?> + + + diff --git a/config/snort-old/snort_dynamic_ip_reload.php b/config/snort-old/snort_dynamic_ip_reload.php new file mode 100644 index 00000000..0fad085b --- /dev/null +++ b/config/snort-old/snort_dynamic_ip_reload.php @@ -0,0 +1,49 @@ + \ No newline at end of file diff --git a/config/snort-old/snort_rules.php b/config/snort-old/snort_rules.php new file mode 100644 index 00000000..94c99f0e --- /dev/null +++ b/config/snort-old/snort_rules.php @@ -0,0 +1,626 @@ +"; + +echo "\n +\n +\n + \n + \n + \n + \n + \n + \n +
    \n"; + + $tab_array = array(); + $tab_array[] = array(gettext("Settings"), false, "/pkg_edit.php?xml=snort.xml&id=0"); + $tab_array[] = array(gettext("Update Rules"), false, "/snort_download_rules.php"); + $tab_array[] = array(gettext("Categories"), false, "/snort_rulesets.php"); + $tab_array[] = array(gettext("Rules"), true, "/snort_rules.php"); + $tab_array[] = array(gettext("Servers"), false, "/pkg_edit.php?xml=snort_define_servers.xml&id=0"); + $tab_array[] = array(gettext("Blocked"), false, "/snort_blocked.php"); + $tab_array[] = array(gettext("Whitelist"), false, "/pkg.php?xml=snort_whitelist.xml"); + $tab_array[] = array(gettext("Threshold"), false, "/pkg.php?xml=snort_threshold.xml"); + $tab_array[] = array(gettext("Alerts"), false, "/snort_alerts.php"); + $tab_array[] = array(gettext("Advanced"), false, "/pkg_edit.php?xml=snort_advanced.xml&id=0"); + display_top_tabs($tab_array); + +echo "
    \n +
    \n + \n + \n + \n + \n +
    \n +# The rules directory is empty.\n +
    \n +
    \n +
    \n +\n +\n +\n +

    \n\n"; + +echo "Please click on the Update Rules tab to install your selected rule sets."; +include("fend.inc"); + +echo ""; +echo ""; + +exit(0); + +} + +function get_middle($source, $beginning, $ending, $init_pos) { + $beginning_pos = strpos($source, $beginning, $init_pos); + $middle_pos = $beginning_pos + strlen($beginning); + $ending_pos = strpos($source, $ending, $beginning_pos); + $middle = substr($source, $middle_pos, $ending_pos - $middle_pos); + return $middle; +} + +function write_rule_file($content_changed, $received_file) +{ + conf_mount_rw(); + + //read snort file with writing enabled + $filehandle = fopen($received_file, "w"); + + //delimiter for each new rule is a new line + $delimiter = "\n"; + + //implode the array back into a string for writing purposes + $fullfile = implode($delimiter, $content_changed); + + //write data to file + fwrite($filehandle, $fullfile); + + //close file handle + fclose($filehandle); + + conf_mount_rw(); +} + +function load_rule_file($incoming_file) +{ + + //read snort file + $filehandle = fopen($incoming_file, "r"); + + //read file into string, and get filesize + $contents = fread($filehandle, filesize($incoming_file)); + + //close handler + fclose ($filehandle); + + //string for populating category select + $currentruleset = substr($file, 27); + + //delimiter for each new rule is a new line + $delimiter = "\n"; + + //split the contents of the string file into an array using the delimiter + $splitcontents = explode($delimiter, $contents); + + return $splitcontents; + +} + +$ruledir = "/usr/local/etc/snort/rules/"; +$dh = opendir($ruledir); + +$message_reload = "The Snort rule configuration has been changed.
    You must apply the changes in order for them to take effect."; + +while (false !== ($filename = readdir($dh))) +{ + //only populate this array if its a rule file + $isrulefile = strstr($filename, ".rules"); + if ($isrulefile !== false) + { + $files[] = $filename; + } +} + +sort($files); + +if ($_GET['openruleset']) +{ + $file = $_GET['openruleset']; +} +else +{ + $file = $ruledir.$files[0]; + +} + +//Load the rule file +$splitcontents = load_rule_file($file); + +if ($_POST) +{ + if (!$_POST['apply']) { + //retrieve POST data + $post_lineid = $_POST['lineid']; + $post_enabled = $_POST['enabled']; + $post_src = $_POST['src']; + $post_srcport = $_POST['srcport']; + $post_dest = $_POST['dest']; + $post_destport = $_POST['destport']; + + //clean up any white spaces insert by accident + $post_src = str_replace(" ", "", $post_src); + $post_srcport = str_replace(" ", "", $post_srcport); + $post_dest = str_replace(" ", "", $post_dest); + $post_destport = str_replace(" ", "", $post_destport); + + //copy rule contents from array into string + $tempstring = $splitcontents[$post_lineid]; + + //search string + $findme = "# alert"; //find string for disabled alerts + + //find if alert is disabled + $disabled = strstr($tempstring, $findme); + + //if find alert is false, then rule is disabled + if ($disabled !== false) + { + //has rule been enabled + if ($post_enabled == "yes") + { + //move counter up 1, so we do not retrieve the # in the rule_content array + $tempstring = str_replace("# alert", "alert", $tempstring); + $counter2 = 1; + } + else + { + //rule is staying disabled + $counter2 = 2; + } + } + else + { + //has rule been disabled + if ($post_enabled != "yes") + { + //move counter up 1, so we do not retrieve the # in the rule_content array + $tempstring = str_replace("alert", "# alert", $tempstring); + $counter2 = 2; + } + else + { + //rule is staying enabled + $counter2 = 1; + } + } + + //explode rule contents into an array, (delimiter is space) + $rule_content = explode(' ', $tempstring); + + //insert new values + $counter2++; + $rule_content[$counter2] = $post_src;//source location + $counter2++; + $rule_content[$counter2] = $post_srcport;//source port location + $counter2 = $counter2+2; + $rule_content[$counter2] = $post_dest;//destination location + $counter2++; + $rule_content[$counter2] = $post_destport;//destination port location + + //implode the array back into string + $tempstring = implode(' ', $rule_content); + + //copy string into file array for writing + $splitcontents[$post_lineid] = $tempstring; + + //write the new .rules file + write_rule_file($splitcontents, $file); + + //once file has been written, reload file + $splitcontents = load_rule_file($file); + + $stopMsg = true; + } + + if ($_POST['apply']) { +// stop_service("snort"); +// sleep(2); +// start_service("snort"); + $savemsg = "The snort rules selections have been saved. Please restart snort by clicking save on the settings tab."; + $stopMsg = false; + } + +} +else if ($_GET['act'] == "toggle") +{ + $toggleid = $_GET['id']; + + //copy rule contents from array into string + $tempstring = $splitcontents[$toggleid]; + + //explode rule contents into an array, (delimiter is space) + $rule_content = explode(' ', $tempstring); + + //search string + $findme = "# alert"; //find string for disabled alerts + + //find if alert is disabled + $disabled = strstr($tempstring, $findme); + + //if find alert is false, then rule is disabled + if ($disabled !== false) + { + //rule has been enabled + //move counter up 1, so we do not retrieve the # in the rule_content array + $tempstring = str_replace("# alert", "alert", $tempstring); + + } + else + { + //has rule been disabled + //move counter up 1, so we do not retrieve the # in the rule_content array + $tempstring = str_replace("alert", "# alert", $tempstring); + + } + + //copy string into array for writing + $splitcontents[$toggleid] = $tempstring; + + //write the new .rules file + write_rule_file($splitcontents, $file); + + //once file has been written, reload file + $splitcontents = load_rule_file($file); + + $stopMsg = true; + + //write disable/enable sid to config.xml + if ($disabled == false) { + $string_sid = strstr($tempstring, 'sid:'); + $sid_pieces = explode(";", $string_sid); + $sid_off_cut = $sid_pieces[0]; + // sid being turned off + $sid_off = str_replace("sid:", "", $sid_off_cut); + // rule_sid_on registers + $sid_on_pieces = $config['installedpackages']['snort']['rule_sid_on']; + // if off sid is the same as on sid remove it + $sid_on_old = str_replace("||enablesid $sid_off", "", "$sid_on_pieces"); + // write the replace sid back as empty + $config['installedpackages']['snort']['rule_sid_on'] = $sid_on_old; + // rule sid off registers + $sid_off_pieces = $config['installedpackages']['snort']['rule_sid_off']; + // if off sid is the same as off sid remove it + $sid_off_old = str_replace("||disablesid $sid_off", "", "$sid_off_pieces"); + // write the replace sid back as empty + $config['installedpackages']['snort']['rule_sid_off'] = $sid_off_old; + // add sid off registers to new off sid + $config['installedpackages']['snort']['rule_sid_off'] = "||disablesid $sid_off" . $config['installedpackages']['snort']['rule_sid_off']; + write_config(); + } + else + { + $string_sid = strstr($tempstring, 'sid:'); + $sid_pieces = explode(";", $string_sid); + $sid_on_cut = $sid_pieces[0]; + // sid being turned off + $sid_on = str_replace("sid:", "", $sid_on_cut); + // rule_sid_off registers + $sid_off_pieces = $config['installedpackages']['snort']['rule_sid_off']; + // if off sid is the same as on sid remove it + $sid_off_old = str_replace("||disablesid $sid_on", "", "$sid_off_pieces"); + // write the replace sid back as empty + $config['installedpackages']['snort']['rule_sid_off'] = $sid_off_old; + // rule sid on registers + $sid_on_pieces = $config['installedpackages']['snort']['rule_sid_on']; + // if on sid is the same as on sid remove it + $sid_on_old = str_replace("||enablesid $sid_on", "", "$sid_on_pieces"); + // write the replace sid back as empty + $config['installedpackages']['snort']['rule_sid_on'] = $sid_on_old; + // add sid on registers to new on sid + $config['installedpackages']['snort']['rule_sid_on'] = "||enablesid $sid_on" . $config['installedpackages']['snort']['rule_sid_on']; + write_config(); + } + +} + + +$pgtitle = "Snort: Rules"; +require("guiconfig.inc"); +include("head.inc"); +?> + + + +

    "; +?> +
    + +
    +
    + + + + + + + + + +
    + +
    +
    + + + + +
    + + + + + + + + + + + + + + Category: "; + + //string for populating category select + $currentruleset = substr($file, 27); + ?> + + + + + "; + $textse = ""; + $iconb = "icon_block_d.gif"; + } + else + { + $textss = $textse = ""; + $iconb = "icon_block.gif"; + } + + $rule_content = explode(' ', $tempstring); + + $protocol = $rule_content[$counter2];//protocol location + $counter2++; + $source = $rule_content[$counter2];//source location + $counter2++; + $source_port = $rule_content[$counter2];//source port location + $counter2 = $counter2+2; + $destination = $rule_content[$counter2];//destination location + $counter2++; + $destination_port = $rule_content[$counter2];//destination port location + + $message = get_middle($tempstring, 'msg:"', '";', 0); + + echo ""; + echo ""; + + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + ?> + +
    "; + ?> +
     SIDProtoSourcePortDestinationPortMessage
    "; + echo $textss; + ?> + + "; + + + echo ""; + echo $textss; + echo $sid; + echo $textse; + echo ""; + echo $textss; + echo $protocol; + $printcounter++; + echo $textse; + echo ""; + echo $textss; + echo $source; + echo $textse; + echo ""; + echo $textss; + echo $source_port; + echo $textse; + echo ""; + echo $textss; + echo $destination; + echo $textse; + echo ""; + echo $textss; + echo $destination_port; + echo $textse; + echo " + "; + ?> + + + + + +
    +
    +
    + + + + + + + + + + + + + +
    Rule Enabled
    Rule Disabled
    +

    + +

    +
    + +
    + + + +
    + \ No newline at end of file diff --git a/config/snort-old/snort_rules_edit.php b/config/snort-old/snort_rules_edit.php new file mode 100644 index 00000000..cbabce73 --- /dev/null +++ b/config/snort-old/snort_rules_edit.php @@ -0,0 +1,207 @@ + + + + + +

    "; +?> + + + + + + + +
    + +
    +
    + + + + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Enabled: >
    SID:
    Protocol:
    Source:
    Source Port:
    Direction:
    Destination:
    Destination Port:
    Message:
    Content:
    Classtype:
    Revision:
     
       
    +
    +
    +
    + + + + \ No newline at end of file diff --git a/config/snort-old/snort_rulesets.php b/config/snort-old/snort_rulesets.php new file mode 100644 index 00000000..d839ae7a --- /dev/null +++ b/config/snort-old/snort_rulesets.php @@ -0,0 +1,230 @@ +"; + +echo "\n +\n +\n + \n + \n + \n + \n + \n + \n +
    \n"; + + $tab_array = array(); + $tab_array[] = array(gettext("Settings"), false, "/pkg_edit.php?xml=snort.xml&id=0"); + $tab_array[] = array(gettext("Update Rules"), false, "/snort_download_rules.php"); + $tab_array[] = array(gettext("Categories"), true, "/snort_rulesets.php"); + $tab_array[] = array(gettext("Rules"), false, "/snort_rules.php"); + $tab_array[] = array(gettext("Servers"), false, "/pkg_edit.php?xml=snort_define_servers.xml&id=0"); + $tab_array[] = array(gettext("Blocked"), false, "/snort_blocked.php"); + $tab_array[] = array(gettext("Whitelist"), false, "/pkg.php?xml=snort_whitelist.xml"); + $tab_array[] = array(gettext("Threshold"), false, "/pkg.php?xml=snort_threshold.xml"); + $tab_array[] = array(gettext("Alerts"), false, "/snort_alerts.php"); + $tab_array[] = array(gettext("Advanced"), false, "/pkg_edit.php?xml=snort_advanced.xml&id=0"); + display_top_tabs($tab_array); + +echo "
    \n +
    \n + \n + \n + \n + \n +
    \n +# The rules directory is empty.\n +
    \n +
    \n +
    \n +\n +\n +\n +

    \n\n"; + +echo "Please click on the Update Rules tab to install your selected rule sets."; +include("fend.inc"); + +echo ""; +echo ""; + +exit(0); + +} + +if($_POST) { + $enabled_items = ""; + $isfirst = true; + foreach($_POST['toenable'] as $toenable) { + if(!$isfirst) + $enabled_items .= "||"; + $enabled_items .= "{$toenable}"; + $isfirst = false; + } + $config['installedpackages']['snort']['rulesets'] = $enabled_items; + write_config(); + stop_service("snort"); + create_snort_conf(); + sleep(2); + start_service("snort"); + $savemsg = "The snort ruleset selections have been saved."; +} + +$enabled_rulesets = $config['installedpackages']['snort']['rulesets']; +if($enabled_rulesets) + $enabled_rulesets_array = split("\|\|", $enabled_rulesets); + +$pgtitle = "Snort: Categories"; +include("head.inc"); + +?> + + + + +

    "; +?> + +
    + + + + + + + + + + +
    + +
    +
    + + + + + + + + +
    + + + + + + +"; + echo ""; + echo ""; + //echo ""; + } + +?> +
    EnabledRuleset: Rules that end with "so.rules" are shared object rules.
    "; + if(is_array($enabled_rulesets_array)) + if(in_array($file, $enabled_rulesets_array)) { + $CHECKED = " checked=\"checked\""; + } else { + $CHECKED = ""; + } + else + $CHECKED = ""; + echo " "; + echo ""; + echo "{$file}"; + echo ""; + //echo "description"; + //echo "
    +
     
    Check the rulesets that you would like Snort to load at startup.
     
    +
    +
    + +
    + +

    NOTE: You can click on a ruleset name to edit the ruleset. + + + + + + + \ No newline at end of file diff --git a/config/snort-old/snort_threshold.xml b/config/snort-old/snort_threshold.xml new file mode 100644 index 00000000..f9075d3d --- /dev/null +++ b/config/snort-old/snort_threshold.xml @@ -0,0 +1,129 @@ + + + + + + . + 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. + */ +/* ========================================================================== */ + ]]> + + Describe your package here + Describe your package requirements here + Currently there are no FAQ items provided. + snort-threshold + 0.1.0 + Snort: Alert Thresholding and Suppression + /usr/local/pkg/snort.inc + + + + Settings + /pkg_edit.php?xml=snort.xml&id=0 + + + Update Rules + /snort_download_rules.php + + + Categories + /snort_rulesets.php + + + Rules + /snort_rules.php + + + Servers + /pkg_edit.php?xml=snort_define_servers.xml&id=0 + + + Blocked + /snort_blocked.php + + + Whitelist + /pkg.php?xml=snort_whitelist.xml + + + Threshold + /pkg.php?xml=snort_threshold.xml + + + + Alerts + /snort_alerts.php + + + Advanced + /pkg_edit.php?xml=snort_advanced.xml&id=0 + + + + + Thresholding or Suppression Rule + threshrule + + + Description + description + + + + + Thresholding or Suppression Rule + threshrule + Enter the Rule. Example; "suppress gen_id 125, sig_id 4" or "threshold gen_id 1, sig_id 1851, type limit, track by_src, count 1, seconds 60" + input + 40 + + + Description + description + Enter the description for this item + input + 60 + + + + + + + + create_snort_conf(); + + \ No newline at end of file diff --git a/config/snort-old/snort_whitelist.xml b/config/snort-old/snort_whitelist.xml new file mode 100644 index 00000000..42769e4e --- /dev/null +++ b/config/snort-old/snort_whitelist.xml @@ -0,0 +1,129 @@ + + + + + + . + 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. + */ +/* ========================================================================== */ + ]]> + + Describe your package here + Describe your package requirements here + Currently there are no FAQ items provided. + snort-whitelist + 0.1.0 + Snort: Whitelist + /usr/local/pkg/snort.inc + + + + Settings + /pkg_edit.php?xml=snort.xml&id=0 + + + Update Rules + /snort_download_rules.php + + + Categories + /snort_rulesets.php + + + Rules + /snort_rules.php + + + Servers + /pkg_edit.php?xml=snort_define_servers.xml&id=0 + + + Blocked + /snort_blocked.php + + + Whitelist + /pkg.php?xml=snort_whitelist.xml + + + + Threshold + /pkg.php?xml=snort_threshold.xml + + + Alerts + /snort_alerts.php + + + Advanced + /pkg_edit.php?xml=snort_advanced.xml&id=0 + + + + + Whitelisted IP + ip + + + Description + description + + + + + Whitelisted IP + ip + Enter the IP or network to whitelist from snort blocking. Network items should be expressed in CIDR notation. Example: 0.0.0.0/24 or 0.0.0.0/32 + input + 40 + + + Description + description + Enter the description for this item + input + 60 + + + + + + + + create_snort_conf(); + + \ No newline at end of file diff --git a/config/snort-old/snort_xmlrpc_sync.php b/config/snort-old/snort_xmlrpc_sync.php new file mode 100644 index 00000000..db8b3f3e --- /dev/null +++ b/config/snort-old/snort_xmlrpc_sync.php @@ -0,0 +1,114 @@ +setCredentials('admin', $password); + if($g['debug']) + $cli->setDebug(1); + /* send our XMLRPC message and timeout after 240 seconds */ + $resp = $cli->send($msg, "999"); + if(!$resp) { + $error = "A communications error occured 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 XMLRPC sync successfully completed with {$url}:{$port}."); + } + log_error("[SNORT] snort_xmlrpc_sync.php is ending."); +} + +?> \ No newline at end of file diff --git a/config/snort/NOTES.txt b/config/snort/NOTES.txt new file mode 100644 index 00000000..b8c61c39 --- /dev/null +++ b/config/snort/NOTES.txt @@ -0,0 +1,17 @@ + + +March 26 2019 +Snort-dev 2.8.5.3 pk v. 18 final + +Final day. + +Odds and ends left. + +2.0 group snort gets lost on reboot. + +Pierre POMES code needs to be added. + +Threshold tab needs to be added. + + +Done. diff --git a/config/snort/bin/7.2.x86/barnyard2 b/config/snort/bin/7.2.x86/barnyard2 new file mode 100644 index 00000000..9266051c Binary files /dev/null and b/config/snort/bin/7.2.x86/barnyard2 differ diff --git a/config/snort/bin/8.0.x86/barnyard2 b/config/snort/bin/8.0.x86/barnyard2 new file mode 100755 index 00000000..43476338 Binary files /dev/null and b/config/snort/bin/8.0.x86/barnyard2 differ diff --git a/config/snort/bin/8.0.x86/md5_files b/config/snort/bin/8.0.x86/md5_files new file mode 100644 index 00000000..3b283d80 --- /dev/null +++ b/config/snort/bin/8.0.x86/md5_files @@ -0,0 +1,9 @@ +#For Freebsd 8.0 + + +MD5 (pcre-8.00.tbz) = 8a1ac82500efccefc6418856e27b6cc1 +MD5 (snort-2.8.5.3.tbz) = 826c15872c6d19bcbe2408fb34d165b9 +MD5 (perl-5.10.1.tbz) = f71020a8bd0f197c9bf70eb6d03b92af +MD5 (mysql-client-5.1.45.tbz) = 9cb5878ae922c3d4d0e31efe5712a90a +MD5 (barnyard2) = 4dbff13291a2b8c5018b7ab62f574bc8 + diff --git a/config/snort/bin/8.0.x86/md5_files~ b/config/snort/bin/8.0.x86/md5_files~ new file mode 100644 index 00000000..3b283d80 --- /dev/null +++ b/config/snort/bin/8.0.x86/md5_files~ @@ -0,0 +1,9 @@ +#For Freebsd 8.0 + + +MD5 (pcre-8.00.tbz) = 8a1ac82500efccefc6418856e27b6cc1 +MD5 (snort-2.8.5.3.tbz) = 826c15872c6d19bcbe2408fb34d165b9 +MD5 (perl-5.10.1.tbz) = f71020a8bd0f197c9bf70eb6d03b92af +MD5 (mysql-client-5.1.45.tbz) = 9cb5878ae922c3d4d0e31efe5712a90a +MD5 (barnyard2) = 4dbff13291a2b8c5018b7ab62f574bc8 + diff --git a/config/snort/bin/oinkmaster_contrib/snort_rename.pl b/config/snort/bin/oinkmaster_contrib/snort_rename.pl new file mode 100644 index 00000000..e5f0d39e --- /dev/null +++ b/config/snort/bin/oinkmaster_contrib/snort_rename.pl @@ -0,0 +1,100 @@ +#!/usr/bin/perl -w + +#usage: rename perl_expression [files] +my $usage = qq{rename [-v] s/pat/repl/ [filenames...]\t (c)2001 hellweg\@snark.de +rename files read from the commandline or stdin + +License to use, modify and redistribute granted to each and every lifeform on +this planet (as long as credit to hellweg\@snark.de remains). No guarantee that +'rename' does or does not perform the way you want... + +} ; +$verbose = 0 ; +$quiet = 0 ; + +$op=shift || 0 ; +if($op eq "-v") { + $verbose++ ; $quiet = 0 ; + $op=shift || 0 ; +} +if($op eq "-q") { + $quiet++ ; $verbose = 0 ; + $op=shift || 0 ; +} +if($op =~ /^-h/) { + print $usage; exit(0) ; +} + +if(! $op) { + print $usage; exit(-1) ; +} + +if (!@ARGV) { + @ARGV = ; +} + +$count=0 ; +my($m, $d, $y, $T) ; +for (@ARGV) { + chomp ; + if(-e $_) { + $was = $_; + if($op =~ /\$[Tdym]/) { + my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime((stat($_))[9]); + $m = sprintf("%0.2i", $mon+1); + $d = sprintf("%0.2i", $mday); + $y = $year + 1900 ; + $T = "$y$m$d" ; + } + eval $op; + die $@ if $@; + if(-f $_) { print("! exists already: $was -> $_ \n") unless $quiet ; } + else { + if(rename($was, $_)) { + print("$was -> $_\n") if $verbose ; + $count++; + } else { + if(/\//) { + # maybe we need to create dirs? + my $createRes = createDirs($_) ; + if($createRes) { + print("! fauled to create $createRes for $_\n") + unless $quiet ; + } + else { # try again + if(rename($was, $_)) { + print("$was -> $_\n") if $verbose ; + $count++; + } else { + print("! failed to rename $was -> $_ \n") + unless $quiet ; + } + } + } + else { + print("! failed to rename $was -> $_ \n") unless $quiet ; + } + } + } + } + else { print("! not found: $_ \n") ; } +} +print("renamed $count files\n") if $verbose ; + + +sub createDirs { # return the dir we failed to create or 0 + my $file = shift ; + my @dirs = split /\//, $file ; + pop @dirs ; # don't try to mkdir the file itself + my $current = "" ; + $current = "/" if ($file =~ /^\//) ; + foreach (@dirs) { + $current .= $_ ; + if(! -d $current) { + mkdir $current, 0700 || return $current ; + print "mkdir $current\n" if ($verbose) ; + } + $current .= "/" ; + } + return 0 ; # success +} diff --git a/config/snort/bin/snort2c b/config/snort/bin/snort2c old mode 100755 new mode 100644 diff --git a/config/snort/css/style.css b/config/snort/css/style.css new file mode 100644 index 00000000..44568873 --- /dev/null +++ b/config/snort/css/style.css @@ -0,0 +1,153 @@ +/* Start of main css Pfsense */ +/* Start of main css Pfsense */ + +@charset "utf-8"; +.textstyle { + font-family: Arial, Helvetica, sans-serif; + font-size: 12px; + font-style: normal; + background-color: #666; + color: #CCC; +} +.textstyle p2 a { + font-family: Arial, Helvetica, sans-serif; + font-size: 12px; + font-style: normal; + color: #CCC; +} + +.textstyle p { + font-family: Arial, Helvetica, sans-serif; + font-size: 24px; + font-weight: bold; + color: #FFF; + text-decoration: underline; +} +.textstyle p2 { + font-family: Arial, Helvetica, sans-serif; + font-size: 12px; + color: #CCC; +} + +/* Start of main css for table sort */ +/* Start of main css for table sort */ + +table { + margin: 0; + padding: 0; + border: 0; + font-weight: inherit; + font-style: inherit; + font-size: 9; + font-family: Arial, Helvetica, sans-serif; + vertical-align: baseline; +} + +/* Tables still need 'cellspacing="0"' in the markup. */ +table { border-collapse: separate; border-spacing: 0; } +caption, th, td { text-align: left; font-weight:400; } + +/* Remove possible quote marks (") from ,

    . */ +blockquote:before, blockquote:after, q:before, q:after { content: ""; } +blockquote, q { quotes: "" ""; } + +#container { + width: auto; + margin: 0px; + padding-top: 10px; + padding-bottom: 10px; +} + + + +/************************************************************** + + Sortable Table + v 1.4 + +**************************************************************/ + + + +th { + background-color: #eee; + background: #eee url(/snort/images/icon-table-sort.png) no-repeat 2px 8px; + padding: 4px 4px 4px 14px; +} + +.allRow { + background-color: #eee; + padding: 4px; +} + +tr.altRow { + background-color: #fff; +} + +.leftAlign { + text-align: left; +} + +.centerAlign { + text-align: center; +} + +.rightAlign { + text-align: right; +} + +.sortedASC { + background: url(/snort/images/icon-table-sort-asc.png) no-repeat 2px 4px #eee; +} + +.sortedDESC { + background: url(/snort/images/icon-table-sort-desc.png) no-repeat 2px 10px #eee; +} + +.tableHeaderOver { + cursor: pointer; + color: #354158; +} + + +tr.selected { + background-color: 9999ff; + color: #000000; +} + +tr.over { + background-color: #993333; + color: #fff; + cursor: pointer; +} + +tr.hide { + display: none; +} +/***************************/ + +.mainTableFilter { + position: absolute; + top: 0; + left: -10px; + width: auto; +} + +.tableFilter { + border: 1px solid #ccc; + padding: 2px; + margin: 5px 0 10px 0; +} + +.tableFilter input { + border: 1px solid #ccc; +} + +.tableFilter select { + border: 1px solid #ccc; +} + + +/*************************************************************/ + + diff --git a/config/snort/css/style2.css b/config/snort/css/style2.css new file mode 100644 index 00000000..d7a1616c --- /dev/null +++ b/config/snort/css/style2.css @@ -0,0 +1,111 @@ +/* ----------------------------------- +general +----------------------------------- */ + +body +{ + margin: 0px; + padding: 0px; + font: 100%/1.4 helvetica, arial, sans-serif; + color: #444; + background: #fff; +} + +h1, h2, h3, h4, h5, h6 +{ + margin: 0 0 1em; + line-height: 1.1; +} + +h2, h3 { color: #003d5d; } +h2 { font-size: 218.75%; } + + +p +{ +margin-top: 35pt; +margin-right: 0pt; +margin-bottom: -25px; +margin-left: 0pt; +text-indent: 25px; +} + +img { border: none; } +a:link { color: #035389; } +a:visited { color: #09619C; } + +/* ----------------------------------- +Play Hide the tab +----------------------------------- */ + +div.items p:not(:target) {display: none} +div.items p:target {display: block} + + +/* ----------------------------------- +layout +----------------------------------- */ + +#container +{ + margin: 0 0px; + background: #fff; +} + +#header +{ + background: #fff; +} + +#header h1 { margin: 0; } + +#navigation +{ + float: left; + width: 100%; + background: #333; +} + +#navigation ul +{ + margin: 0; + padding: 0; +} + +#navigation ul li +{ + list-style-type: none; + display: inline; +} + +#navigation li a +{ + display: block; + float: left; + padding: 5px 10px; + color: #fff; + text-decoration: none; + border-right: 1px solid #fff; +} + +#navigation li a:hover +{ + background-color: #3366cc; + background-image: none; + background-repeat: repeat; + background-attachment: scroll; + background-position: 0% 0%; +} + +#content +{ + clear: left; + padding: 20px; +} + +#content h2 +{ + color: #000; + font-size: 160%; + margin: 0 0 .5em; +} \ No newline at end of file diff --git a/config/snort/help_and_info.php b/config/snort/help_and_info.php new file mode 100644 index 00000000..0f4a0c9f --- /dev/null +++ b/config/snort/help_and_info.php @@ -0,0 +1,196 @@ + + + + +Help & Info + + + + + + + + + +
    + + +
    +
    +

    + Snort Package is a GUI based front-end for Sourcefire\'s Snort ® IDS/IPS software. The Snort Package goal is to be + the best open-source GUI to manage multiple snort sensors and multiple rule snapshots. The project other goal is to be a highly competitive GUI for + network monitoring for both private and enterprise use. Lastly, this project software development should bring programmers and users together to create + software. +

    +

    + What is Snort ? Used by fortune 500 companies and goverments Snort is the most widely deployed IDS/IPS technology worldwide. It features rules based logging and + can perform content searching/matching in addition to being used to detect a variety of other attacks and probes, such as buffer overflows, stealth port + scans, CGI attacks, SMB probes, and much more. +

    +

    + Requirements :
    + Minimum requirement 256 mb ram, 500 MHz CPU.
    + Recommended 500 mb ram, 1 Ghz CPU.
    + The more rules you run the more memory you need.
    + The more interfaces you select the more memory you need.

    + Development is done on a Alix 2D3 system (500 MHz AMD Geode LX800 CPU 256MB DDR DRAM). +

    +
    +
    +

    +About Me

    +Coming soon............ + +

    +
    +
    +

    +Services

    +Coming soon............ +

    +
    +
    +

    +Change Log

    +Coming soon............ +

    +
    +
    +

    +PfSense is brought to you by a dedicated group of developers who are security and network professionals by trade. The following people are active developers of the pfSense project. +Username is listed in parenthesis (generally also the person\'s forum username, IRC nickname, etc.).

    + +Main Snort-dev Package Developer
    +Robert Zelaya

    + +Founders
    +In alphabetical order

    + +Chris Buechler (cmb)
    +Scott Ullrich (sullrich)

    + +Active Developers
    +Listed in order of seniority along with date of first contribution.

    + +Bill Marquette (billm) - February 2005
    +Holger Bauer (hoba) - May 2005
    +Erik Kristensen (ekristen) - August 2005
    +Seth Mos (smos) - November 2005
    +Scott Dale (sdale) - December 2006
    +Martin Fuchs (mfuchs) - June 2007
    +Ermal Luçi (ermal) - January 2008
    +Matthew Grooms (mgrooms) - July 2008
    +Mark Crane (mcrane) - October 2008
    +Jim Pingle (jim-p) - February 2009
    +Rob Zelaya (robiscool) - March 2009
    +Renato Botelho (rbgarga) - May 2009

    + +FreeBSD Developer Assistance
    +We would like to thank the following FreeBSD developers for their assistance.

    + +Max Laier (mlaier)
    +Christian S.J. Peron (csjp)
    +Andrew Thompson (thompsa)
    +Bjoern A. Zeeb (bz)

    + +among many others who help us directly, and everyone who contributes to FreeBSD.

    + +Inactive Developers
    +The following individuals are no longer active contributors, having moved on because of other commitments, or employers forbidding contributions. We thank them for their past contributions.

    + +Daniel Berlin (dberlin)
    +Daniel Haischt (dsh)
    +Espen Johansen (lsf)
    +Scott Kamp (dingo)
    +Bachman Kharazmi (bkw)
    +Fernando Tarlá Cardoso Lemos (fernando)
    +Kyle Mott (kyle)
    +Colin Smith (colin)
    +

    +
    +
    +

    +Heros

    +Coming soon............ +

    +
    +
    +

    +=========================
    + +Q: Do you have a quick install tutorial and tabs explanation.
    + +A: Yes.
    + + http://doc.pfsense.org/index.php/Setup_Snort_Package
    + +=========================
    + +Q: What interfaces can snort listen on ?
    + +A: Right now all WAN interfaces and LAN interfaces. But if you select a LAN interface you may need to adjust the snort rules to use the LAN interface.
    + +==========================
    + +Q: What logs does the snort package keep. ?
    + +A: Most of the snort logs are keept in the /var/log/snort.
    + Snorts syslogs\' are saved to the /var/log/snort/snort_sys_0ng0.
    + +==========================
    + +Q: What is the best Performance setting ? or Snort is using 90% cpu and all my memory.
    + +A: Depends how much memory you have and how many rules you want to run.; lowmem for systems with less than 256 mb memory, ac-bnfa for systems
    + with over 256 mb of memory. The other options are; ac high memory, best performance, ac-std moderate memory, high performance,acs small
    + memory, moderate performance,ac-banded small memory,moderate performance,ac-sparsebands small memory, high performance.
    + + Short version: For most people ac-bnfa is the best setting.
    + +=========================
    + +Q: What is the Oinkmaster code ? How do I get the code ?
    + +A: The Oinkmaster code is your personal password in order to download snort rules.
    + You get a Oinkmaster code when you register with snort.org. It is free to register.
    + Goto https://www.snort.org/signup to get your personal code.
    + +=========================
    + +Q: What is the Snort.org subscriber option? How do I become a Snort.org subscriber?
    + +A: Snort.org subscribers get the the latest rule updates 30 days faster than registered users.
    + Goto http://www.snort.org/vrt/buy-a-subscription/. + It is highly suggested that you get a paid subscription so that you can always have the latest rules.
    + +=========================
    + +Q: When did you start working on the snort package.
    + +A: I started working on the snort package in May 2009.
    +

    +
    +
    + + +'; +?> \ No newline at end of file diff --git a/config/snort/images/alert.jpg b/config/snort/images/alert.jpg new file mode 100644 index 00000000..96c24e35 Binary files /dev/null and b/config/snort/images/alert.jpg differ diff --git a/config/snort/images/down.gif b/config/snort/images/down.gif new file mode 100644 index 00000000..2b3c99fc Binary files /dev/null and b/config/snort/images/down.gif differ diff --git a/config/snort/images/down2.gif b/config/snort/images/down2.gif new file mode 100644 index 00000000..71bf92eb Binary files /dev/null and b/config/snort/images/down2.gif differ diff --git a/config/snort/images/footer.jpg b/config/snort/images/footer.jpg new file mode 100644 index 00000000..4af05707 Binary files /dev/null and b/config/snort/images/footer.jpg differ diff --git a/config/snort/images/footer2.jpg b/config/snort/images/footer2.jpg new file mode 100644 index 00000000..3332e085 Binary files /dev/null and b/config/snort/images/footer2.jpg differ diff --git a/config/snort/images/icon-table-sort-asc.png b/config/snort/images/icon-table-sort-asc.png new file mode 100644 index 00000000..0c127919 Binary files /dev/null and b/config/snort/images/icon-table-sort-asc.png differ diff --git a/config/snort/images/icon-table-sort-desc.png b/config/snort/images/icon-table-sort-desc.png new file mode 100644 index 00000000..5c52f2d0 Binary files /dev/null and b/config/snort/images/icon-table-sort-desc.png differ diff --git a/config/snort/images/icon-table-sort.png b/config/snort/images/icon-table-sort.png new file mode 100644 index 00000000..3cae604b Binary files /dev/null and b/config/snort/images/icon-table-sort.png differ diff --git a/config/snort/images/icon_excli.png b/config/snort/images/icon_excli.png new file mode 100644 index 00000000..4b54fa31 Binary files /dev/null and b/config/snort/images/icon_excli.png differ diff --git a/config/snort/images/logo.jpg b/config/snort/images/logo.jpg new file mode 100644 index 00000000..fa01d818 Binary files /dev/null and b/config/snort/images/logo.jpg differ diff --git a/config/snort/images/up.gif b/config/snort/images/up.gif new file mode 100644 index 00000000..89596771 Binary files /dev/null and b/config/snort/images/up.gif differ diff --git a/config/snort/images/up2.gif b/config/snort/images/up2.gif new file mode 100644 index 00000000..21c5a254 Binary files /dev/null and b/config/snort/images/up2.gif differ diff --git a/config/snort/javascript/jquery-1.3.2.js b/config/snort/javascript/jquery-1.3.2.js new file mode 100644 index 00000000..59b71d25 --- /dev/null +++ b/config/snort/javascript/jquery-1.3.2.js @@ -0,0 +1,4376 @@ +/*! + * jQuery JavaScript Library v1.3.2 + * http://jquery.com/ + * + * Copyright (c) 2009 John Resig + * Dual licensed under the MIT and GPL licenses. + * http://docs.jquery.com/License + * + * Date: 2009-02-19 17:34:21 -0500 (Thu, 19 Feb 2009) + * Revision: 6246 + */ +(function(){ + +var + // Will speed up references to window, and allows munging its name. + window = this, + // Will speed up references to undefined, and allows munging its name. + undefined, + // Map over jQuery in case of overwrite + _jQuery = window.jQuery, + // Map over the $ in case of overwrite + _$ = window.$, + + jQuery = window.jQuery = window.$ = function( selector, context ) { + // The jQuery object is actually just the init constructor 'enhanced' + return new jQuery.fn.init( selector, context ); + }, + + // A simple way to check for HTML strings or ID strings + // (both of which we optimize for) + quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/, + // Is it a simple selector + isSimple = /^.[^:#\[\.,]*$/; + +jQuery.fn = jQuery.prototype = { + init: function( selector, context ) { + // Make sure that a selection was provided + selector = selector || document; + + // Handle $(DOMElement) + if ( selector.nodeType ) { + this[0] = selector; + this.length = 1; + this.context = selector; + return this; + } + // Handle HTML strings + if ( typeof selector === "string" ) { + // Are we dealing with HTML string or an ID? + var match = quickExpr.exec( selector ); + + // Verify a match, and that no context was specified for #id + if ( match && (match[1] || !context) ) { + + // HANDLE: $(html) -> $(array) + if ( match[1] ) + selector = jQuery.clean( [ match[1] ], context ); + + // HANDLE: $("#id") + else { + var elem = document.getElementById( match[3] ); + + // Handle the case where IE and Opera return items + // by name instead of ID + if ( elem && elem.id != match[3] ) + return jQuery().find( selector ); + + // Otherwise, we inject the element directly into the jQuery object + var ret = jQuery( elem || [] ); + ret.context = document; + ret.selector = selector; + return ret; + } + + // HANDLE: $(expr, [context]) + // (which is just equivalent to: $(content).find(expr) + } else + return jQuery( context ).find( selector ); + + // HANDLE: $(function) + // Shortcut for document ready + } else if ( jQuery.isFunction( selector ) ) + return jQuery( document ).ready( selector ); + + // Make sure that old selector state is passed along + if ( selector.selector && selector.context ) { + this.selector = selector.selector; + this.context = selector.context; + } + + return this.setArray(jQuery.isArray( selector ) ? + selector : + jQuery.makeArray(selector)); + }, + + // Start with an empty selector + selector: "", + + // The current version of jQuery being used + jquery: "1.3.2", + + // The number of elements contained in the matched element set + size: function() { + return this.length; + }, + + // Get the Nth element in the matched element set OR + // Get the whole matched element set as a clean array + get: function( num ) { + return num === undefined ? + + // Return a 'clean' array + Array.prototype.slice.call( this ) : + + // Return just the object + this[ num ]; + }, + + // Take an array of elements and push it onto the stack + // (returning the new matched element set) + pushStack: function( elems, name, selector ) { + // Build a new jQuery matched element set + var ret = jQuery( elems ); + + // Add the old object onto the stack (as a reference) + ret.prevObject = this; + + ret.context = this.context; + + if ( name === "find" ) + ret.selector = this.selector + (this.selector ? " " : "") + selector; + else if ( name ) + ret.selector = this.selector + "." + name + "(" + selector + ")"; + + // Return the newly-formed element set + return ret; + }, + + // Force the current matched set of elements to become + // the specified array of elements (destroying the stack in the process) + // You should use pushStack() in order to do this, but maintain the stack + setArray: function( elems ) { + // Resetting the length to 0, then using the native Array push + // is a super-fast way to populate an object with array-like properties + this.length = 0; + Array.prototype.push.apply( this, elems ); + + return this; + }, + + // Execute a callback for every element in the matched set. + // (You can seed the arguments with an array of args, but this is + // only used internally.) + each: function( callback, args ) { + return jQuery.each( this, callback, args ); + }, + + // Determine the position of an element within + // the matched set of elements + index: function( elem ) { + // Locate the position of the desired element + return jQuery.inArray( + // If it receives a jQuery object, the first element is used + elem && elem.jquery ? elem[0] : elem + , this ); + }, + + attr: function( name, value, type ) { + var options = name; + + // Look for the case where we're accessing a style value + if ( typeof name === "string" ) + if ( value === undefined ) + return this[0] && jQuery[ type || "attr" ]( this[0], name ); + + else { + options = {}; + options[ name ] = value; + } + + // Check to see if we're setting style values + return this.each(function(i){ + // Set all the styles + for ( name in options ) + jQuery.attr( + type ? + this.style : + this, + name, jQuery.prop( this, options[ name ], type, i, name ) + ); + }); + }, + + css: function( key, value ) { + // ignore negative width and height values + if ( (key == 'width' || key == 'height') && parseFloat(value) < 0 ) + value = undefined; + return this.attr( key, value, "curCSS" ); + }, + + text: function( text ) { + if ( typeof text !== "object" && text != null ) + return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) ); + + var ret = ""; + + jQuery.each( text || this, function(){ + jQuery.each( this.childNodes, function(){ + if ( this.nodeType != 8 ) + ret += this.nodeType != 1 ? + this.nodeValue : + jQuery.fn.text( [ this ] ); + }); + }); + + return ret; + }, + + wrapAll: function( html ) { + if ( this[0] ) { + // The elements to wrap the target around + var wrap = jQuery( html, this[0].ownerDocument ).clone(); + + if ( this[0].parentNode ) + wrap.insertBefore( this[0] ); + + wrap.map(function(){ + var elem = this; + + while ( elem.firstChild ) + elem = elem.firstChild; + + return elem; + }).append(this); + } + + return this; + }, + + wrapInner: function( html ) { + return this.each(function(){ + jQuery( this ).contents().wrapAll( html ); + }); + }, + + wrap: function( html ) { + return this.each(function(){ + jQuery( this ).wrapAll( html ); + }); + }, + + append: function() { + return this.domManip(arguments, true, function(elem){ + if (this.nodeType == 1) + this.appendChild( elem ); + }); + }, + + prepend: function() { + return this.domManip(arguments, true, function(elem){ + if (this.nodeType == 1) + this.insertBefore( elem, this.firstChild ); + }); + }, + + before: function() { + return this.domManip(arguments, false, function(elem){ + this.parentNode.insertBefore( elem, this ); + }); + }, + + after: function() { + return this.domManip(arguments, false, function(elem){ + this.parentNode.insertBefore( elem, this.nextSibling ); + }); + }, + + end: function() { + return this.prevObject || jQuery( [] ); + }, + + // For internal use only. + // Behaves like an Array's method, not like a jQuery method. + push: [].push, + sort: [].sort, + splice: [].splice, + + find: function( selector ) { + if ( this.length === 1 ) { + var ret = this.pushStack( [], "find", selector ); + ret.length = 0; + jQuery.find( selector, this[0], ret ); + return ret; + } else { + return this.pushStack( jQuery.unique(jQuery.map(this, function(elem){ + return jQuery.find( selector, elem ); + })), "find", selector ); + } + }, + + clone: function( events ) { + // Do the clone + var ret = this.map(function(){ + if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) { + // IE copies events bound via attachEvent when + // using cloneNode. Calling detachEvent on the + // clone will also remove the events from the orignal + // In order to get around this, we use innerHTML. + // Unfortunately, this means some modifications to + // attributes in IE that are actually only stored + // as properties will not be copied (such as the + // the name attribute on an input). + var html = this.outerHTML; + if ( !html ) { + var div = this.ownerDocument.createElement("div"); + div.appendChild( this.cloneNode(true) ); + html = div.innerHTML; + } + + return jQuery.clean([html.replace(/ jQuery\d+="(?:\d+|null)"/g, "").replace(/^\s*/, "")])[0]; + } else + return this.cloneNode(true); + }); + + // Copy the events from the original to the clone + if ( events === true ) { + var orig = this.find("*").andSelf(), i = 0; + + ret.find("*").andSelf().each(function(){ + if ( this.nodeName !== orig[i].nodeName ) + return; + + var events = jQuery.data( orig[i], "events" ); + + for ( var type in events ) { + for ( var handler in events[ type ] ) { + jQuery.event.add( this, type, events[ type ][ handler ], events[ type ][ handler ].data ); + } + } + + i++; + }); + } + + // Return the cloned set + return ret; + }, + + filter: function( selector ) { + return this.pushStack( + jQuery.isFunction( selector ) && + jQuery.grep(this, function(elem, i){ + return selector.call( elem, i ); + }) || + + jQuery.multiFilter( selector, jQuery.grep(this, function(elem){ + return elem.nodeType === 1; + }) ), "filter", selector ); + }, + + closest: function( selector ) { + var pos = jQuery.expr.match.POS.test( selector ) ? jQuery(selector) : null, + closer = 0; + + return this.map(function(){ + var cur = this; + while ( cur && cur.ownerDocument ) { + if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selector) ) { + jQuery.data(cur, "closest", closer); + return cur; + } + cur = cur.parentNode; + closer++; + } + }); + }, + + not: function( selector ) { + if ( typeof selector === "string" ) + // test special case where just one selector is passed in + if ( isSimple.test( selector ) ) + return this.pushStack( jQuery.multiFilter( selector, this, true ), "not", selector ); + else + selector = jQuery.multiFilter( selector, this ); + + var isArrayLike = selector.length && selector[selector.length - 1] !== undefined && !selector.nodeType; + return this.filter(function() { + return isArrayLike ? jQuery.inArray( this, selector ) < 0 : this != selector; + }); + }, + + add: function( selector ) { + return this.pushStack( jQuery.unique( jQuery.merge( + this.get(), + typeof selector === "string" ? + jQuery( selector ) : + jQuery.makeArray( selector ) + ))); + }, + + is: function( selector ) { + return !!selector && jQuery.multiFilter( selector, this ).length > 0; + }, + + hasClass: function( selector ) { + return !!selector && this.is( "." + selector ); + }, + + val: function( value ) { + if ( value === undefined ) { + var elem = this[0]; + + if ( elem ) { + if( jQuery.nodeName( elem, 'option' ) ) + return (elem.attributes.value || {}).specified ? elem.value : elem.text; + + // We need to handle select boxes special + if ( jQuery.nodeName( elem, "select" ) ) { + var index = elem.selectedIndex, + values = [], + options = elem.options, + one = elem.type == "select-one"; + + // Nothing was selected + if ( index < 0 ) + return null; + + // Loop through all the selected options + for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) { + var option = options[ i ]; + + if ( option.selected ) { + // Get the specifc value for the option + value = jQuery(option).val(); + + // We don't need an array for one selects + if ( one ) + return value; + + // Multi-Selects return an array + values.push( value ); + } + } + + return values; + } + + // Everything else, we just grab the value + return (elem.value || "").replace(/\r/g, ""); + + } + + return undefined; + } + + if ( typeof value === "number" ) + value += ''; + + return this.each(function(){ + if ( this.nodeType != 1 ) + return; + + if ( jQuery.isArray(value) && /radio|checkbox/.test( this.type ) ) + this.checked = (jQuery.inArray(this.value, value) >= 0 || + jQuery.inArray(this.name, value) >= 0); + + else if ( jQuery.nodeName( this, "select" ) ) { + var values = jQuery.makeArray(value); + + jQuery( "option", this ).each(function(){ + this.selected = (jQuery.inArray( this.value, values ) >= 0 || + jQuery.inArray( this.text, values ) >= 0); + }); + + if ( !values.length ) + this.selectedIndex = -1; + + } else + this.value = value; + }); + }, + + html: function( value ) { + return value === undefined ? + (this[0] ? + this[0].innerHTML.replace(/ jQuery\d+="(?:\d+|null)"/g, "") : + null) : + this.empty().append( value ); + }, + + replaceWith: function( value ) { + return this.after( value ).remove(); + }, + + eq: function( i ) { + return this.slice( i, +i + 1 ); + }, + + slice: function() { + return this.pushStack( Array.prototype.slice.apply( this, arguments ), + "slice", Array.prototype.slice.call(arguments).join(",") ); + }, + + map: function( callback ) { + return this.pushStack( jQuery.map(this, function(elem, i){ + return callback.call( elem, i, elem ); + })); + }, + + andSelf: function() { + return this.add( this.prevObject ); + }, + + domManip: function( args, table, callback ) { + if ( this[0] ) { + var fragment = (this[0].ownerDocument || this[0]).createDocumentFragment(), + scripts = jQuery.clean( args, (this[0].ownerDocument || this[0]), fragment ), + first = fragment.firstChild; + + if ( first ) + for ( var i = 0, l = this.length; i < l; i++ ) + callback.call( root(this[i], first), this.length > 1 || i > 0 ? + fragment.cloneNode(true) : fragment ); + + if ( scripts ) + jQuery.each( scripts, evalScript ); + } + + return this; + + function root( elem, cur ) { + return table && jQuery.nodeName(elem, "table") && jQuery.nodeName(cur, "tr") ? + (elem.getElementsByTagName("tbody")[0] || + elem.appendChild(elem.ownerDocument.createElement("tbody"))) : + elem; + } + } +}; + +// Give the init function the jQuery prototype for later instantiation +jQuery.fn.init.prototype = jQuery.fn; + +function evalScript( i, elem ) { + if ( elem.src ) + jQuery.ajax({ + url: elem.src, + async: false, + dataType: "script" + }); + + else + jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" ); + + if ( elem.parentNode ) + elem.parentNode.removeChild( elem ); +} + +function now(){ + return +new Date; +} + +jQuery.extend = jQuery.fn.extend = function() { + // copy reference to target object + var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options; + + // Handle a deep copy situation + if ( typeof target === "boolean" ) { + deep = target; + target = arguments[1] || {}; + // skip the boolean and the target + i = 2; + } + + // Handle case when target is a string or something (possible in deep copy) + if ( typeof target !== "object" && !jQuery.isFunction(target) ) + target = {}; + + // extend jQuery itself if only one argument is passed + if ( length == i ) { + target = this; + --i; + } + + for ( ; i < length; i++ ) + // Only deal with non-null/undefined values + if ( (options = arguments[ i ]) != null ) + // Extend the base object + for ( var name in options ) { + var src = target[ name ], copy = options[ name ]; + + // Prevent never-ending loop + if ( target === copy ) + continue; + + // Recurse if we're merging object values + if ( deep && copy && typeof copy === "object" && !copy.nodeType ) + target[ name ] = jQuery.extend( deep, + // Never move original objects, clone them + src || ( copy.length != null ? [ ] : { } ) + , copy ); + + // Don't bring in undefined values + else if ( copy !== undefined ) + target[ name ] = copy; + + } + + // Return the modified object + return target; +}; + +// exclude the following css properties to add px +var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i, + // cache defaultView + defaultView = document.defaultView || {}, + toString = Object.prototype.toString; + +jQuery.extend({ + noConflict: function( deep ) { + window.$ = _$; + + if ( deep ) + window.jQuery = _jQuery; + + return jQuery; + }, + + // See test/unit/core.js for details concerning isFunction. + // Since version 1.3, DOM methods and functions like alert + // aren't supported. They return false on IE (#2968). + isFunction: function( obj ) { + return toString.call(obj) === "[object Function]"; + }, + + isArray: function( obj ) { + return toString.call(obj) === "[object Array]"; + }, + + // check if an element is in a (or is an) XML document + isXMLDoc: function( elem ) { + return elem.nodeType === 9 && elem.documentElement.nodeName !== "HTML" || + !!elem.ownerDocument && jQuery.isXMLDoc( elem.ownerDocument ); + }, + + // Evalulates a script in a global context + globalEval: function( data ) { + if ( data && /\S/.test(data) ) { + // Inspired by code by Andrea Giammarchi + // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html + var head = document.getElementsByTagName("head")[0] || document.documentElement, + script = document.createElement("script"); + + script.type = "text/javascript"; + if ( jQuery.support.scriptEval ) + script.appendChild( document.createTextNode( data ) ); + else + script.text = data; + + // Use insertBefore instead of appendChild to circumvent an IE6 bug. + // This arises when a base node is used (#2709). + head.insertBefore( script, head.firstChild ); + head.removeChild( script ); + } + }, + + nodeName: function( elem, name ) { + return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase(); + }, + + // args is for internal usage only + each: function( object, callback, args ) { + var name, i = 0, length = object.length; + + if ( args ) { + if ( length === undefined ) { + for ( name in object ) + if ( callback.apply( object[ name ], args ) === false ) + break; + } else + for ( ; i < length; ) + if ( callback.apply( object[ i++ ], args ) === false ) + break; + + // A special, fast, case for the most common use of each + } else { + if ( length === undefined ) { + for ( name in object ) + if ( callback.call( object[ name ], name, object[ name ] ) === false ) + break; + } else + for ( var value = object[0]; + i < length && callback.call( value, i, value ) !== false; value = object[++i] ){} + } + + return object; + }, + + prop: function( elem, value, type, i, name ) { + // Handle executable functions + if ( jQuery.isFunction( value ) ) + value = value.call( elem, i ); + + // Handle passing in a number to a CSS property + return typeof value === "number" && type == "curCSS" && !exclude.test( name ) ? + value + "px" : + value; + }, + + className: { + // internal only, use addClass("class") + add: function( elem, classNames ) { + jQuery.each((classNames || "").split(/\s+/), function(i, className){ + if ( elem.nodeType == 1 && !jQuery.className.has( elem.className, className ) ) + elem.className += (elem.className ? " " : "") + className; + }); + }, + + // internal only, use removeClass("class") + remove: function( elem, classNames ) { + if (elem.nodeType == 1) + elem.className = classNames !== undefined ? + jQuery.grep(elem.className.split(/\s+/), function(className){ + return !jQuery.className.has( classNames, className ); + }).join(" ") : + ""; + }, + + // internal only, use hasClass("class") + has: function( elem, className ) { + return elem && jQuery.inArray( className, (elem.className || elem).toString().split(/\s+/) ) > -1; + } + }, + + // A method for quickly swapping in/out CSS properties to get correct calculations + swap: function( elem, options, callback ) { + var old = {}; + // Remember the old values, and insert the new ones + for ( var name in options ) { + old[ name ] = elem.style[ name ]; + elem.style[ name ] = options[ name ]; + } + + callback.call( elem ); + + // Revert the old values + for ( var name in options ) + elem.style[ name ] = old[ name ]; + }, + + css: function( elem, name, force, extra ) { + if ( name == "width" || name == "height" ) { + var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name == "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ]; + + function getWH() { + val = name == "width" ? elem.offsetWidth : elem.offsetHeight; + + if ( extra === "border" ) + return; + + jQuery.each( which, function() { + if ( !extra ) + val -= parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0; + if ( extra === "margin" ) + val += parseFloat(jQuery.curCSS( elem, "margin" + this, true)) || 0; + else + val -= parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0; + }); + } + + if ( elem.offsetWidth !== 0 ) + getWH(); + else + jQuery.swap( elem, props, getWH ); + + return Math.max(0, Math.round(val)); + } + + return jQuery.curCSS( elem, name, force ); + }, + + curCSS: function( elem, name, force ) { + var ret, style = elem.style; + + // We need to handle opacity special in IE + if ( name == "opacity" && !jQuery.support.opacity ) { + ret = jQuery.attr( style, "opacity" ); + + return ret == "" ? + "1" : + ret; + } + + // Make sure we're using the right name for getting the float value + if ( name.match( /float/i ) ) + name = styleFloat; + + if ( !force && style && style[ name ] ) + ret = style[ name ]; + + else if ( defaultView.getComputedStyle ) { + + // Only "float" is needed here + if ( name.match( /float/i ) ) + name = "float"; + + name = name.replace( /([A-Z])/g, "-$1" ).toLowerCase(); + + var computedStyle = defaultView.getComputedStyle( elem, null ); + + if ( computedStyle ) + ret = computedStyle.getPropertyValue( name ); + + // We should always get a number back from opacity + if ( name == "opacity" && ret == "" ) + ret = "1"; + + } else if ( elem.currentStyle ) { + var camelCase = name.replace(/\-(\w)/g, function(all, letter){ + return letter.toUpperCase(); + }); + + ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ]; + + // From the awesome hack by Dean Edwards + // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 + + // If we're not dealing with a regular pixel number + // but a number that has a weird ending, we need to convert it to pixels + if ( !/^\d+(px)?$/i.test( ret ) && /^\d/.test( ret ) ) { + // Remember the original values + var left = style.left, rsLeft = elem.runtimeStyle.left; + + // Put in the new values to get a computed value out + elem.runtimeStyle.left = elem.currentStyle.left; + style.left = ret || 0; + ret = style.pixelLeft + "px"; + + // Revert the changed values + style.left = left; + elem.runtimeStyle.left = rsLeft; + } + } + + return ret; + }, + + clean: function( elems, context, fragment ) { + context = context || document; + + // !context.createElement fails in IE with an error but returns typeof 'object' + if ( typeof context.createElement === "undefined" ) + context = context.ownerDocument || context[0] && context[0].ownerDocument || document; + + // If a single string is passed in and it's a single tag + // just do a createElement and skip the rest + if ( !fragment && elems.length === 1 && typeof elems[0] === "string" ) { + var match = /^<(\w+)\s*\/?>$/.exec(elems[0]); + if ( match ) + return [ context.createElement( match[1] ) ]; + } + + var ret = [], scripts = [], div = context.createElement("div"); + + jQuery.each(elems, function(i, elem){ + if ( typeof elem === "number" ) + elem += ''; + + if ( !elem ) + return; + + // Convert html string into DOM nodes + if ( typeof elem === "string" ) { + // Fix "XHTML"-style tags in all browsers + elem = elem.replace(/(<(\w+)[^>]*?)\/>/g, function(all, front, tag){ + return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i) ? + all : + front + ">"; + }); + + // Trim whitespace, otherwise indexOf won't work as expected + var tags = elem.replace(/^\s+/, "").substring(0, 10).toLowerCase(); + + var wrap = + // option or optgroup + !tags.indexOf("", "" ] || + + !tags.indexOf("", "" ] || + + tags.match(/^<(thead|tbody|tfoot|colg|cap)/) && + [ 1, "", "
    " ] || + + !tags.indexOf("
    " ] || + + //
    " ] || + + !tags.indexOf("", "" ] || + + // IE can't serialize and + + - -

    "; +"; +if($pfsense_stable == 'yes'){echo $pgtitle;} +echo "

    \n"; + +/* refresh every 60 secs */ +if ($pconfig['arefresh'] == 'on' || $pconfig['arefresh'] == '') +{ + echo "\n"; +} ?> - - + + +
    -
    +
    - +
    - + + - - + + + + + + + +
    - Last Snort Alert entries + Last Alert Entries. + + Latest Alert Entries Are Listed First. +

    -
    Save or Remove Logs + + + All log files will be saved. + + Warning: all log files will be deleted. + +
    Auto Refresh and Log View +
    + + Refresh + > + Default is ON. + + Enter the number of log entries to view. Default is 250. +
    +
    -
    + + +
    +
    +
    +
    Filter: + + + + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \n"; + } + +// + + } +} + +?> + +
    #PRIPROTODESCRIPTIONCLASSSRCSPORTFLOWDSTDPORTSIDDate
    {$counter}{$alert_priority}{$alert_proto}{$alert_disc}{$alert_class}{$alert_ip_src}{$alert_src_p}{$alert_flow}{$alert_ip_dst}{$alert_dst_p}{$alert_sid}{$alert_date}
    +
    + - - - - - + var myTable = {}; + window.addEvent('domready', function(){ + myTable = new sortableTable('myTable', {overCls: 'over'}); + }); + -function dump_log_file($logfile, $tail, $withorig = true, $grepfor = "", $grepinvert = "") { - global $g, $config; - $logarr = ""; - exec("cat {$logfile} | /usr/bin/tail -n {$tail}", $logarr); - foreach ($logarr as $logent) { - if(!logent) - continue; - $ww_logent = $logent; - $ww_logent = str_replace("[", " [ ", $ww_logent); - $ww_logent = str_replace("]", " ] ", $ww_logent); - echo "\n"; - echo "" . make_clickable($ww_logent) . " \n"; - echo "\n"; - } -} - -?> \ No newline at end of file + + diff --git a/config/snort/snort_barnyard.php b/config/snort/snort_barnyard.php new file mode 100644 index 00000000..7a587330 --- /dev/null +++ b/config/snort/snort_barnyard.php @@ -0,0 +1,441 @@ +. + Copyright (C) 2008-2009 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. +*/ + +/* + +TODO: Nov 12 09 +Clean this code up its ugly +Important add error checking + +*/ + +require_once("globals.inc"); +require_once("guiconfig.inc"); +require_once("/usr/local/pkg/snort/snort.inc"); +require_once("/usr/local/pkg/snort/snort_gui.inc"); + +if (!is_array($config['installedpackages']['snortglobal']['rule'])) { + $config['installedpackages']['snortglobal']['rule'] = array(); +} +//nat_rules_sort(); +$a_nat = &$config['installedpackages']['snortglobal']['rule']; + +$id = $_GET['id']; +if (isset($_POST['id'])) + $id = $_POST['id']; + +if (isset($_GET['dup'])) { + $id = $_GET['dup']; + $after = $_GET['dup']; +} + +if (isset($id) && $a_nat[$id]) { + + /* old options */ + $pconfig['def_ssl_ports_ignore'] = $a_nat[$id]['def_ssl_ports_ignore']; + $pconfig['flow_depth'] = $a_nat[$id]['flow_depth']; + $pconfig['perform_stat'] = $a_nat[$id]['perform_stat']; + $pconfig['http_inspect'] = $a_nat[$id]['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['dce_rpc_2'] = $a_nat[$id]['dce_rpc_2']; + $pconfig['dns_preprocessor'] = $a_nat[$id]['dns_preprocessor']; + $pconfig['def_dns_servers'] = $a_nat[$id]['def_dns_servers']; + $pconfig['def_dns_ports'] = $a_nat[$id]['def_dns_ports']; + $pconfig['def_smtp_servers'] = $a_nat[$id]['def_smtp_servers']; + $pconfig['def_smtp_ports'] = $a_nat[$id]['def_smtp_ports']; + $pconfig['def_mail_ports'] = $a_nat[$id]['def_mail_ports']; + $pconfig['def_http_servers'] = $a_nat[$id]['def_http_servers']; + $pconfig['def_www_servers'] = $a_nat[$id]['def_www_servers']; + $pconfig['def_http_ports'] = $a_nat[$id]['def_http_ports']; + $pconfig['def_sql_servers'] = $a_nat[$id]['def_sql_servers']; + $pconfig['def_oracle_ports'] = $a_nat[$id]['def_oracle_ports']; + $pconfig['def_mssql_ports'] = $a_nat[$id]['def_mssql_ports']; + $pconfig['def_telnet_servers'] = $a_nat[$id]['def_telnet_servers']; + $pconfig['def_telnet_ports'] = $a_nat[$id]['def_telnet_ports']; + $pconfig['def_snmp_servers'] = $a_nat[$id]['def_snmp_servers']; + $pconfig['def_snmp_ports'] = $a_nat[$id]['def_snmp_ports']; + $pconfig['def_ftp_servers'] = $a_nat[$id]['def_ftp_servers']; + $pconfig['def_ftp_ports'] = $a_nat[$id]['def_ftp_ports']; + $pconfig['def_ssh_servers'] = $a_nat[$id]['def_ssh_servers']; + $pconfig['def_ssh_ports'] = $a_nat[$id]['def_ssh_ports']; + $pconfig['def_pop_servers'] = $a_nat[$id]['def_pop_servers']; + $pconfig['def_pop2_ports'] = $a_nat[$id]['def_pop2_ports']; + $pconfig['def_pop3_ports'] = $a_nat[$id]['def_pop3_ports']; + $pconfig['def_imap_servers'] = $a_nat[$id]['def_imap_servers']; + $pconfig['def_imap_ports'] = $a_nat[$id]['def_imap_ports']; + $pconfig['def_sip_proxy_ip'] = $a_nat[$id]['def_sip_proxy_ip']; + $pconfig['def_sip_proxy_ports'] = $a_nat[$id]['def_sip_proxy_ports']; + $pconfig['def_auth_ports'] = $a_nat[$id]['def_auth_ports']; + $pconfig['def_finger_ports'] = $a_nat[$id]['def_finger_ports']; + $pconfig['def_irc_ports'] = $a_nat[$id]['def_irc_ports']; + $pconfig['def_nntp_ports'] = $a_nat[$id]['def_nntp_ports']; + $pconfig['def_rlogin_ports'] = $a_nat[$id]['def_rlogin_ports']; + $pconfig['def_rsh_ports'] = $a_nat[$id]['def_rsh_ports']; + $pconfig['def_ssl_ports'] = $a_nat[$id]['def_ssl_ports']; + $pconfig['barnyard_enable'] = $a_nat[$id]['barnyard_enable']; + $pconfig['barnyard_mysql'] = $a_nat[$id]['barnyard_mysql']; + $pconfig['enable'] = $a_nat[$id]['enable']; + $pconfig['uuid'] = $a_nat[$id]['uuid']; + $pconfig['interface'] = $a_nat[$id]['interface']; + $pconfig['descr'] = $a_nat[$id]['descr']; + $pconfig['performance'] = $a_nat[$id]['performance']; + $pconfig['blockoffenders7'] = $a_nat[$id]['blockoffenders7']; + $pconfig['alertsystemlog'] = $a_nat[$id]['alertsystemlog']; + $pconfig['tcpdumplog'] = $a_nat[$id]['tcpdumplog']; + $pconfig['snortunifiedlog'] = $a_nat[$id]['snortunifiedlog']; + $pconfig['rulesets'] = $a_nat[$id]['rulesets']; + $pconfig['rule_sid_off'] = $a_nat[$id]['rule_sid_off']; + $pconfig['rule_sid_on'] = $a_nat[$id]['rule_sid_on']; + + if (!$pconfig['interface']) + $pconfig['interface'] = "wan"; +} else { + $pconfig['interface'] = "wan"; +} + +if (isset($_GET['dup'])) + unset($id); + +$if_real = convert_friendly_interface_to_real_interface_name2($pconfig['interface']); +$snort_uuid = $config['installedpackages']['snortglobal']['rule'][$id]['uuid']; + + + /* alert file */ +$d_snortconfdirty_path = "/var/run/snort_conf_{$snort_uuid}_{$if_real}.dirty"; + + /* this will exec when alert says apply */ + if ($_POST['apply']) { + + if (file_exists($d_snortconfdirty_path)) { + + write_config(); + + sync_snort_package_all($id, $if_real, $snort_uuid); + sync_snort_package(); + + unlink($d_snortconfdirty_path); + + } + + } + + + if ($_POST["Submit"]) { + + /* check for overlaps */ + foreach ($a_nat as $natent) { + if (isset($id) && ($a_nat[$id]) && ($a_nat[$id] === $natent)) + continue; + if ($natent['interface'] != $_POST['interface']) + continue; + } + +/* if no errors write to conf */ + if (!$input_errors) { + $natent = array(); + /* repost the options already in conf */ + + if ($pconfig['interface'] != "") { $natent['interface'] = $pconfig['interface']; } + if ($pconfig['enable'] != "") { $natent['enable'] = $pconfig['enable']; } + if ($pconfig['uuid'] != "") { $natent['uuid'] = $pconfig['uuid']; } + if ($pconfig['descr'] != "") { $natent['descr'] = $pconfig['descr']; } + if ($pconfig['performance'] != "") { $natent['performance'] = $pconfig['performance']; } + if ($pconfig['blockoffenders7'] != "") { $natent['blockoffenders7'] = $pconfig['blockoffenders7']; } + if ($pconfig['alertsystemlog'] != "") { $natent['alertsystemlog'] = $pconfig['alertsystemlog']; } + if ($pconfig['tcpdumplog'] != "") { $natent['tcpdumplog'] = $pconfig['tcpdumplog']; } + if ($pconfig['snortunifiedlog'] != "") { $natent['snortunifiedlog'] = $pconfig['snortunifiedlog']; } + if ($pconfig['def_ssl_ports_ignore'] != "") { $natent['def_ssl_ports_ignore'] = $pconfig['def_ssl_ports_ignore']; } + if ($pconfig['flow_depth'] != "") { $natent['flow_depth'] = $pconfig['flow_depth']; } + if ($pconfig['perform_stat'] != "") { $natent['perform_stat'] = $pconfig['perform_stat']; } + if ($pconfig['http_inspect'] != "") { $natent['http_inspect'] = $pconfig['http_inspect']; } + if ($pconfig['other_preprocs'] != "") { $natent['other_preprocs'] = $pconfig['other_preprocs']; } + if ($pconfig['ftp_preprocessor'] != "") { $natent['ftp_preprocessor'] = $pconfig['ftp_preprocessor']; } + if ($pconfig['smtp_preprocessor'] != "") { $natent['smtp_preprocessor'] = $pconfig['smtp_preprocessor']; } + if ($pconfig['sf_portscan'] != "") { $natent['sf_portscan'] = $pconfig['sf_portscan']; } + if ($pconfig['dce_rpc_2'] != "") { $natent['dce_rpc_2'] = $pconfig['dce_rpc_2']; } + if ($pconfig['dns_preprocessor'] != "") { $natent['dns_preprocessor'] = $pconfig['dns_preprocessor']; } + if ($pconfig['def_dns_servers'] != "") { $natent['def_dns_servers'] = $pconfig['def_dns_servers']; } + if ($pconfig['def_dns_ports'] != "") { $natent['def_dns_ports'] = $pconfig['def_dns_ports']; } + if ($pconfig['def_smtp_servers'] != "") { $natent['def_smtp_servers'] = $pconfig['def_smtp_servers']; } + if ($pconfig['def_smtp_ports'] != "") { $natent['def_smtp_ports'] = $pconfig['def_smtp_ports']; } + if ($pconfig['def_mail_ports'] != "") { $natent['def_mail_ports'] = $pconfig['def_mail_ports']; } + if ($pconfig['def_http_servers'] != "") { $natent['def_http_servers'] = $pconfig['def_http_servers']; } + if ($pconfig['def_www_servers'] != "") { $natent['def_www_servers'] = $pconfig['def_www_servers']; } + if ($pconfig['def_http_ports'] != "") { $natent['def_http_ports'] = $pconfig['def_http_ports']; } + if ($pconfig['def_sql_servers'] != "") { $natent['def_sql_servers'] = $pconfig['def_sql_servers']; } + if ($pconfig['def_oracle_ports'] != "") { $natent['def_oracle_ports'] = $pconfig['def_oracle_ports']; } + if ($pconfig['def_mssql_ports'] != "") { $natent['def_mssql_ports'] = $pconfig['def_mssql_ports']; } + if ($pconfig['def_telnet_servers'] != "") { $natent['def_telnet_servers'] = $pconfig['def_telnet_servers']; } + if ($pconfig['def_telnet_ports'] != "") { $natent['def_telnet_ports'] = $pconfig['def_telnet_ports']; } + if ($pconfig['def_snmp_servers'] != "") { $natent['def_snmp_servers'] = $pconfig['def_snmp_servers']; } + if ($pconfig['def_snmp_ports'] != "") { $natent['def_snmp_ports'] = $pconfig['def_snmp_ports']; } + if ($pconfig['def_ftp_servers'] != "") { $natent['def_ftp_servers'] = $pconfig['def_ftp_servers']; } + if ($pconfig['def_ftp_ports'] != "") { $natent['def_ftp_ports'] = $pconfig['def_ftp_ports']; } + if ($pconfig['def_ssh_servers'] != "") { $natent['def_ssh_servers'] = $pconfig['def_ssh_servers']; } + if ($pconfig['def_ssh_ports'] != "") { $natent['def_ssh_ports'] = $pconfig['def_ssh_ports']; } + if ($pconfig['def_pop_servers'] != "") { $natent['def_pop_servers'] = $pconfig['def_pop_servers']; } + if ($pconfig['def_pop2_ports'] != "") { $natent['def_pop2_ports'] = $pconfig['def_pop2_ports']; } + if ($pconfig['def_pop3_ports'] != "") { $natent['def_pop3_ports'] = $pconfig['def_pop3_ports']; } + if ($pconfig['def_imap_servers'] != "") { $natent['def_imap_servers'] = $pconfig['def_imap_servers']; } + if ($pconfig['def_imap_ports'] != "") { $natent['def_imap_ports'] = $pconfig['def_imap_ports']; } + if ($pconfig['def_sip_proxy_ip'] != "") { $natent['def_sip_proxy_ip'] = $pconfig['def_sip_proxy_ip']; } + if ($pconfig['def_sip_proxy_ports'] != "") { $natent['def_sip_proxy_ports'] = $pconfig['def_sip_proxy_ports']; } + if ($pconfig['def_auth_ports'] != "") { $natent['def_auth_ports'] = $pconfig['def_auth_ports']; } + if ($pconfig['def_finger_ports'] != "") { $natent['def_finger_ports'] = $pconfig['def_finger_ports']; } + if ($pconfig['def_irc_ports'] != "") { $natent['def_irc_ports'] = $pconfig['def_irc_ports']; } + if ($pconfig['def_nntp_ports'] != "") { $natent['def_nntp_ports'] = $pconfig['def_nntp_ports']; } + if ($pconfig['def_rlogin_ports'] != "") { $natent['def_rlogin_ports'] = $pconfig['def_rlogin_ports']; } + if ($pconfig['def_rsh_ports'] != "") { $natent['def_rsh_ports'] = $pconfig['def_rsh_ports']; } + if ($pconfig['def_ssl_ports'] != "") { $natent['def_ssl_ports'] = $pconfig['def_ssl_ports']; } + if ($pconfig['rulesets'] != "") { $natent['rulesets'] = $pconfig['rulesets']; } + if ($pconfig['rule_sid_off'] != "") { $natent['rule_sid_off'] = $pconfig['rule_sid_off']; } + if ($pconfig['rule_sid_on'] != "") { $natent['rule_sid_on'] = $pconfig['rule_sid_on']; } + + /* post new options */ + $natent['barnyard_enable'] = $_POST['barnyard_enable'] ? on : off; + $natent['barnyard_mysql'] = $_POST['barnyard_mysql'] ? $_POST['barnyard_mysql'] : $pconfig['barnyard_mysql']; + if ($_POST['barnyard_enable'] == "on") { $natent['snortunifiedlog'] = on; }else{ $natent['snortunifiedlog'] = off; } if ($_POST['barnyard_enable'] == "") { $natent['snortunifiedlog'] = off; } + + if (isset($id) && $a_nat[$id]) + $a_nat[$id] = $natent; + else { + if (is_numeric($after)) + array_splice($a_nat, $after+1, 0, array($natent)); + else + $a_nat[] = $natent; + } + + write_config(); + + /* after click go to this page */ + touch($d_snortconfdirty_path); + 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' ); + header( 'Cache-Control: post-check=0, pre-check=0', false ); + header( 'Pragma: no-cache' ); + sleep(2); + header("Location: snort_barnyard.php?id=$id"); + exit; + } +} + +$pgtitle = "Snort: Interface: $id$if_real Barnyard2 Edit"; +include("head.inc"); + +?> + + +

    + + + + +
    + +'; + + if($savemsg) { + print_info_box_np2("{$savemsg}"); + }else{ + print_info_box_np2(' + The Snort configuration has changed and snort needs to be restarted on this interface.
    + You must apply the changes in order for them to take effect.
    + '); + } + } + +?> + + + + + +
    + +
    + + + .noid { + position:absolute; + top:10px; + left:0px; + width:94%; + background:#FCE9C0; + background-position: 15px; + border-top:2px solid #DBAC48; + border-bottom:2px solid #DBAC48; + padding: 15px 10px 85% 50px; + } + +
    You can not edit options without an interface ID.
    \n"; + + } + ?> + + + \n\n"; + ?> + + + + + + + + + + + + + + + + + +
      + + // care with spaces + if ($pconfig['barnyard_enable'] == "on") + $checked = checked; + if($id != "") + { + $onclick_enable = "onClick=\"enable_change(false)\">"; + } + echo " + Enable Barnyard2 on this Interface
    + This will enable barnyard2 for this interface. You will also have to set the database credentials.
    Interface +
    + Choose which interface this rule applies to.
    + Hint: in most cases, you'll want to use WAN here.
    Log to a Mysql Database + +
    Example: output database: log, mysql, dbname=snort user=snort host=localhost password=xyz
      + + + + +
     Note: +
    + Please save your settings befor you click start.
    +
    +
    + + + + + diff --git a/config/snort/snort_blocked.php b/config/snort/snort_blocked.php index ff158853..293679d9 100644 --- a/config/snort/snort_blocked.php +++ b/config/snort/snort_blocked.php @@ -5,6 +5,9 @@ Copyright (C) 2006 Scott Ullrich All rights reserved. + Modified for the Pfsense snort package v. 1.8+ + Copyright (C) 2009 Robert Zelaya Sr. Developer + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -27,8 +30,19 @@ POSSIBILITY OF SUCH DAMAGE. */ -require("guiconfig.inc"); -require("/usr/local/pkg/snort.inc"); +require_once("globals.inc"); +require_once("guiconfig.inc"); +require_once("/usr/local/pkg/snort/snort.inc"); + +$pconfig['brefresh'] = $config['installedpackages']['snortglobal']['alertsblocks']['brefresh']; +$pconfig['blertnumber'] = $config['installedpackages']['snortglobal']['alertsblocks']['blertnumber']; + +if ($pconfig['blertnumber'] == '' || $pconfig['blertnumber'] == '0') +{ + $bnentries = '500'; +}else{ + $bnentries = $pconfig['blertnumber']; +} if($_POST['todelete'] or $_GET['todelete']) { if($_POST['todelete']) @@ -38,100 +52,147 @@ if($_POST['todelete'] or $_GET['todelete']) { exec("/sbin/pfctl -t snort2c -T delete {$ip}"); } -$pgtitle = "Snort: Snort Blocked"; -include("head.inc"); +if ($_POST['remove']) { -?> +exec("/sbin/pfctl -t snort2c -T flush"); +sleep(1); +header("Location: /snort/snort_blocked.php"); - - +} -

    "; -?> +/* TODO: build a file with block ip and disc */ +if ($_POST['download']) +{ -
    - - - - - - - - - - -
    - -
    -
    - - - - -
    - - - - - - - /tmp/snort_block.pf'); + + $blocked_ips_array_save = str_replace(' ', '', array_filter(explode("\n", file_get_contents('/tmp/snort_block.pf')))); + + if ($blocked_ips_array_save[0] != '') + { - $associatealertip = $config['installedpackages']['snort']['config'][0]['associatealertip']; - $ips = `/sbin/pfctl -t snort2c -T show`; - $ips_array = split("\n", $ips); - $counter = 0; - foreach($ips_array as $ip) { - if(!$ip) - continue; - $ww_ip = str_replace(" ", "", $ip); - $counter++; - if($associatealertip) - $alert_description = get_snort_alert($ww_ip); - else - $alert_description = ""; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; + /* build the list */ + $counter = 0; + foreach($blocked_ips_array_save as $fileline3) + { + + $counter++; + + exec("/bin/echo $fileline3 >> /tmp/snort_blocked/snort_block.pf"); + + } } - echo "\n"; - if($counter < 1) - echo "\n"; - else - echo "\n"; -?> + exec("/usr/bin/tar cfz /tmp/snort_blocked_{$save_date}.tar.gz /tmp/snort_blocked"); -
    RemoveIPAlert Description
    "; - echo "\n\"Delete\" {$ww_ip} {$alert_description}
     
    There are currently no items being blocked by snort.
    {$counter} items listed.
    -
    -
    -
    + if(file_exists("/tmp/snort_blocked_{$save_date}.tar.gz")) + { + $file = "/tmp/snort_blocked_{$save_date}.tar.gz"; + header("Expires: Mon, 26 Jul 1997 05:00:00 GMT\n"); + header("Pragma: private"); // needed for IE + header("Cache-Control: private, must-revalidate"); // needed for IE + header('Content-type: application/force-download'); + header('Content-Transfer-Encoding: Binary'); + header("Content-length: ".filesize($file)); + header("Content-disposition: attachment; filename = {$file_name}"); + readfile("$file"); + exec("/bin/rm /tmp/snort_blocked_{$save_date}.tar.gz"); + exec("/bin/rm /tmp/snort_block.pf"); + exec("/bin/rm /tmp/snort_blocked/snort_block.pf"); + od_end_clean(); //importanr or other post will fail + }else{ + echo 'Error no saved file.'; + } -
    +} -

    +if ($_POST['save']) +{ -$blocked_msg."; +}else{ +$blocked_msg_txt = "Settings are set to never remove hosts."; +} + +$pgtitle = "Services: Snort Blocked Hosts"; +include("head.inc"); ?> - + + - +include("./snort_fbegin.inc"); + +echo "

    "; +if($pfsense_stable == 'yes'){echo $pgtitle;} +echo "

    \n"; + +/* refresh every 60 secs */ +if ($pconfig['brefresh'] == 'on' || $pconfig['brefresh'] == '') +{ + echo "\n"; +} +?> + + + + + + + + + + + +
    + +
    +
    + + + + + + + + + + + + + + +
    + Last Blocked. + + This page lists hosts that have been blocked by Snort.   +
    Save or Remove Hosts +
    + + All blocked hosts will be saved. + + Warning: all hosts will be removed. +
    +
    Auto Refresh and Log View +
    + + Refresh + > + Default is ON. + + Enter the number of blocked entries to view. Default is 500. +
    +
    + +
    +
    + + + +
    + + + + + + + /tmp/snort_block.cache'); +$alerts_array = array_reverse(array_filter(explode("\n\n", file_get_contents('/var/log/snort/alert')))); +$blocked_ips_array = str_replace(' ', '', array_filter(explode("\n", file_get_contents('/tmp/snort_block.cache')))); + +$logent = $bnentries; + +if ($blocked_ips_array[0] != '' && $alerts_array[0] != '') +{ + + /* build the list and compare blocks to alerts */ + $counter = 0; + foreach($alerts_array as $fileline) + { + + $counter++; -?> \ No newline at end of file + $alert_ip_src = get_snort_alert_ip_src($fileline); + $alert_ip_disc = get_snort_alert_disc($fileline); + $alert_ip_src_array[] = get_snort_alert_ip_src($fileline); + + if (in_array("$alert_ip_src", $blocked_ips_array)) + { + $input[] = "[$alert_ip_src] " . "[$alert_ip_disc]\n"; + } + } + + foreach($blocked_ips_array as $alert_block_ip) + { + + if (!in_array($alert_block_ip, $alert_ip_src_array)) + { + $input[] = "[$alert_block_ip] " . "[N\A]\n"; + } + } + + /* reduce double occurrences */ + $result = array_unique($input); + + /* buil final list, preg_match, buld html */ + $counter2 = 0; + + foreach($result as $fileline2) + { + if($logent <= $counter2) + continue; + + $counter2++; + + $alert_block_ip_str = get_snort_block_ip($fileline2); + + if($alert_block_ip_str != '') + { + $alert_block_ip_match = array('[',']'); + $alert_block_ip = str_replace($alert_block_ip_match, '', "$alert_block_ip_str"); + }else{ + $alert_block_ip = 'empty'; + } + + $alert_block_disc_str = get_snort_block_disc($fileline2); + + if($alert_block_disc_str != '') + { + $alert_block_disc_match = array('] [',']'); + $alert_block_disc = str_replace($alert_block_disc_match, '', "$alert_block_disc_str"); + }else{ + $alert_block_disc = 'empty'; + } + + /* use one echo to do the magic*/ + echo " + + + + + \n"; + + } + +}else{ + + /* if alerts file is empty and blocked table is not empty */ + $counter2 = 0; + + foreach($blocked_ips_array as $alert_block_ip) + { + if($logent <= $counter2) + continue; + + $counter2++; + + $alert_block_disc = 'N/A'; + + /* use one echo to do the magic*/ + echo " + + + + + \n"; + } +} + +if ($blocked_ips_array[0] == '') +{ + echo "\n"; +}else{ + echo "\n"; +} + +?> +
    Remove#IPAlert Description
    + \"Delete\" {$counter2} {$alert_block_ip} {$alert_block_disc}
    + \"Delete\" {$counter2} {$alert_block_ip} {$alert_block_disc}

    There are currently no items being blocked by snort.
    {$counter2} items listed.
    +
    + + + + + + diff --git a/config/snort/snort_check_for_rule_updates.php b/config/snort/snort_check_for_rule_updates.php index 8d308245..6f95b101 100644 --- a/config/snort/snort_check_for_rule_updates.php +++ b/config/snort/snort_check_for_rule_updates.php @@ -3,6 +3,7 @@ /* snort_rulesets.php Copyright (C) 2006 Scott Ullrich + Copyright (C) 2009 Robert Zelaya All rights reserved. Redistribution and use in source and binary forms, with or without @@ -28,8 +29,8 @@ */ /* Setup enviroment */ -$tmpfname = "/root/snort_rules_up"; -$snortdir = "/usr/local/etc/snort_bkup"; +$tmpfname = "/tmp/snort_rules_up"; +$snortdir = "/usr/local/etc/snort"; $snortdir_wan = "/usr/local/etc/snort"; $snort_filename_md5 = "snortrules-snapshot-2.8.tar.gz.md5"; $snort_filename = "snortrules-snapshot-2.8.tar.gz"; @@ -38,53 +39,71 @@ $emergingthreats_filename = "emerging.rules.tar.gz"; $pfsense_rules_filename_md5 = "pfsense_rules.tar.gz.md5"; $pfsense_rules_filename = "pfsense_rules.tar.gz"; -require("/usr/local/pkg/snort.inc"); -require_once("config.inc"); +require_once("globals.inc"); +require_once("guiconfig.inc"); +require_once("/usr/local/pkg/snort/snort.inc"); -?> +/* define checks */ +$oinkid = $config['installedpackages']['snortglobal']['oinkmastercode']; +$snortdownload = $config['installedpackages']['snortglobal']['snortdownload']; +$emergingthreats = $config['installedpackages']['snortglobal']['emergingthreats']; +if ($oinkid == "" && $snortdownload != "off") +{ + echo "You must obtain an oinkid from snort.org and set its value in the Snort settings tab.\n"; + exec("/usr/bin/logger -p daemon.info -i -t SnortStartup 'You must obtain an oinkid from snort.org and set its value in the Snort settings tab.'"); + exit; +} - /usr/local/etc/snort_bkup/sid-msg.map"); +exec("/usr/local/bin/perl /usr/local/bin/create-sidmap.pl /usr/local/etc/snort/rules > /usr/local/etc/snort/sid-msg.map"); + + +////////////////// + +/* Start the proccess for every interface rule */ +/* TODO: try to make the code smother */ + +if (!empty($config['installedpackages']['snortglobal']['rule'])) { + +$rule_array = $config['installedpackages']['snortglobal']['rule']; +$id = -1; +foreach ($rule_array as $value) { + +$id += 1; + +$result_lan = $config['installedpackages']['snortglobal']['rule'][$id]['interface']; +$if_real = convert_friendly_interface_to_real_interface_name($result_lan); + + /* make oinkmaster.conf for each interface rule */ + oinkmaster_conf(); + + /* run oinkmaster for each interface rule */ + oinkmaster_run(); + + } +} + +/* open oinkmaster_conf for writing" function */ +function oinkmaster_conf() { + + global $config, $g, $id, $if_real, $snortdir_wan, $snortdir, $snort_md5_check_ok, $emerg_md5_check_chk_ok, $pfsense_md5_check_ok; + +/* enable disable setting will carry over with updates */ +/* TODO carry signature changes with the updates */ +if ($snort_md5_check_ok != on || $emerg_md5_check_chk_ok != on || $pfsense_md5_check_ok != on) { + +if (!empty($config['installedpackages']['snortglobal']['rule'][$id]['rule_sid_on'])) { +$enabled_sid_on = $config['installedpackages']['snortglobal']['rule'][$id]['rule_sid_on']; +$enabled_sid_on_array = split('\|\|', $enabled_sid_on); +foreach($enabled_sid_on_array as $enabled_item_on) +$selected_sid_on_sections .= "$enabled_item_on\n"; + } + +if (!empty($config['installedpackages']['snortglobal']['rule'][$id]['rule_sid_off'])) { +$enabled_sid_off = $config['installedpackages']['snortglobal']['rule'][$id]['rule_sid_off']; +$enabled_sid_off_array = split('\|\|', $enabled_sid_off); +foreach($enabled_sid_off_array as $enabled_item_off) +$selected_sid_off_sections .= "$enabled_item_off\n"; + } + +$snort_sid_text = <<> /root/debug"); + exec("/bin/cp {$snortdir}/rules/* {$snortdir_wan}/snort_$id$if_real/rules/"); + exec("/bin/cp {$snortdir}/classification.config {$snortdir_wan}/snort_$id$if_real"); + exec("/bin/cp {$snortdir}/gen-msg.map {$snortdir_wan}/snort_$id$if_real"); + exec("/bin/cp {$snortdir}/generators {$snortdir_wan}/snort_$id$if_real"); + exec("/bin/cp {$snortdir}/reference.config {$snortdir_wan}/snort_$id$if_real"); + exec("/bin/cp {$snortdir}/sid {$snortdir_wan}/snort_$id$if_real"); + exec("/bin/cp {$snortdir}/sid-msg.map {$snortdir_wan}/snort_$id$if_real"); + exec("/bin/cp {$snortdir}/unicode.map {$snortdir_wan}/snort_$id$if_real"); } else { echo "Your enable and disable changes are being applied to your fresh set of rules...\n"; echo "May take a while...\n"; - exec("/bin/cp {$snortdir}/rules/* {$snortdir_wan}/rules/"); - exec("/bin/cp {$snortdir}/classification.config {$snortdir_wan}"); - exec("/bin/cp {$snortdir}/gen-msg.map {$snortdir_wan}"); - exec("/bin/cp {$snortdir}/generators {$snortdir_wan}"); - exec("/bin/cp {$snortdir}/reference.config {$snortdir_wan}"); - exec("/bin/cp {$snortdir}/sid {$snortdir_wan}"); - exec("/bin/cp {$snortdir}/sid-msg.map {$snortdir_wan}"); - exec("/bin/cp {$snortdir}/unicode.map {$snortdir_wan}"); + exec("/bin/echo \"test2 {$snortdir} {$snortdir_wan} $id$if_real\" > /root/debug"); + exec("/bin/cp {$snortdir}/rules/* {$snortdir_wan}/snort_$id$if_real/rules/"); + exec("/bin/cp {$snortdir}/classification.config {$snortdir_wan}/snort_$id$if_real"); + exec("/bin/cp {$snortdir}/gen-msg.map {$snortdir_wan}/snort_$id$if_real"); + exec("/bin/cp {$snortdir}/generators {$snortdir_wan}/snort_$id$if_real"); + exec("/bin/cp {$snortdir}/reference.config {$snortdir_wan}/snort_$id$if_real"); + exec("/bin/cp {$snortdir}/sid {$snortdir_wan}/snort_$id$if_real"); + exec("/bin/cp {$snortdir}/sid-msg.map {$snortdir_wan}/snort_$id$if_real"); + exec("/bin/cp {$snortdir}/unicode.map {$snortdir_wan}/snort_$id$if_real"); /* oinkmaster.pl will convert saved changes for the new updates then we have to change #alert to # alert for the gui */ /* might have to add a sleep for 3sec for flash drives or old drives */ - exec("/usr/local/bin/perl /usr/local/bin/oinkmaster.pl -C /usr/local/etc/snort_bkup/oinkmaster.conf -o /usr/local/etc/snort/rules > /usr/local/etc/snort_bkup/oinkmaster.log"); - exec("/usr/local/bin/perl -pi -e 's/#alert/# alert/g' /usr/local/etc/snort/rules/*.rules"); - exec("/usr/local/bin/perl -pi -e 's/##alert/# alert/g' /usr/local/etc/snort/rules/*.rules"); - exec("/usr/local/bin/perl -pi -e 's/## alert/# alert/g' /usr/local/etc/snort/rules/*.rules"); - + exec("/usr/local/bin/perl /usr/local/bin/oinkmaster.pl -C /usr/local/etc/snort/oinkmaster_$id$if_real.conf -o /usr/local/etc/snort/snort_$id$if_real/rules > /usr/local/etc/snort/oinkmaster_$id$if_real.log"); + + } } } +////////////// + +/* mark the time update finnished */ +$config['installedpackages']['snortglobal']['last_rules_install'] = date("Y-M-jS-h:i-A"); + /* remove old $tmpfname files */ if (file_exists("{$tmpfname}")) { echo "Cleaning up...\n"; - exec("/bin/rm -r /root/snort_rules_up"); + exec("/bin/rm -r /tmp/snort_rules_up"); +// apc_clear_cache(); } /* php code to flush out cache some people are reportting missing files this might help */ -sleep(5); +sleep(2); apc_clear_cache(); exec("/bin/sync ;/bin/sync ;/bin/sync ;/bin/sync ;/bin/sync ;/bin/sync ;/bin/sync ;/bin/sync"); + /* make snort the owner */ + exec("/usr/sbin/chown -R snort:snort /var/log/snort"); + exec("/usr/sbin/chown -R snort:snort /usr/local/etc/snort"); + exec("/usr/sbin/chown -R snort:snort /usr/local/lib/snort"); + exec("/bin/chmod -R 755 /var/log/snort"); + exec("/bin/chmod -R 755 /usr/local/etc/snort"); + exec("/bin/chmod -R 755 /usr/local/lib/snort"); + /* if snort is running hardrestart, if snort is not running do nothing */ if (file_exists("/tmp/snort_download_halt.pid")) { - start_service("snort"); + exec("/bin/sh /usr/local/etc/rc.d/snort.sh start"); echo "The Rules update finished...\n"; echo "Snort has restarted with your new set of rules...\n"; + exec("/usr/bin/logger -p daemon.info -i -t SnortStartup 'SNORT RULE UPDATE FINNISHED...'"); exec("/bin/rm /tmp/snort_download_halt.pid"); } else { echo "The Rules update finished...\n"; - echo "You may start snort now...\n"; + exec("/usr/bin/logger -p daemon.info -i -t SnortStartup 'SNORT RULE UPDATE FINNISHED...'"); } + conf_mount_ro(); ?> diff --git a/config/snort/snort_define_servers.php b/config/snort/snort_define_servers.php new file mode 100644 index 00000000..04984300 --- /dev/null +++ b/config/snort/snort_define_servers.php @@ -0,0 +1,582 @@ +. + Copyright (C) 2008-2009 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. +*/ + +/* + +TODO: Nov 12 09 +Clean this code up its ugly +Important add error checking + +*/ + +require_once("globals.inc"); +require_once("guiconfig.inc"); +require_once("/usr/local/pkg/snort/snort.inc"); +require_once("/usr/local/pkg/snort/snort_gui.inc"); + +if (!is_array($config['installedpackages']['snortglobal']['rule'])) { + $config['installedpackages']['snortglobal']['rule'] = array(); +} + +//nat_rules_sort(); +$a_nat = &$config['installedpackages']['snortglobal']['rule']; + +$id = $_GET['id']; +if (isset($_POST['id'])) + $id = $_POST['id']; + +if (isset($_GET['dup'])) { + $id = $_GET['dup']; + $after = $_GET['dup']; +} + + +if (isset($id) && $a_nat[$id]) { + + /* old options */ + $pconfig['def_ssl_ports_ignore'] = $a_nat[$id]['def_ssl_ports_ignore']; + $pconfig['flow_depth'] = $a_nat[$id]['flow_depth']; + $pconfig['perform_stat'] = $a_nat[$id]['perform_stat']; + $pconfig['http_inspect'] = $a_nat[$id]['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['dce_rpc_2'] = $a_nat[$id]['dce_rpc_2']; + $pconfig['dns_preprocessor'] = $a_nat[$id]['dns_preprocessor']; + $pconfig['def_dns_servers'] = $a_nat[$id]['def_dns_servers']; + $pconfig['def_dns_ports'] = $a_nat[$id]['def_dns_ports']; + $pconfig['def_smtp_servers'] = $a_nat[$id]['def_smtp_servers']; + $pconfig['def_smtp_ports'] = $a_nat[$id]['def_smtp_ports']; + $pconfig['def_mail_ports'] = $a_nat[$id]['def_mail_ports']; + $pconfig['def_http_servers'] = $a_nat[$id]['def_http_servers']; + $pconfig['def_www_servers'] = $a_nat[$id]['def_www_servers']; + $pconfig['def_http_ports'] = $a_nat[$id]['def_http_ports']; + $pconfig['def_sql_servers'] = $a_nat[$id]['def_sql_servers']; + $pconfig['def_oracle_ports'] = $a_nat[$id]['def_oracle_ports']; + $pconfig['def_mssql_ports'] = $a_nat[$id]['def_mssql_ports']; + $pconfig['def_telnet_servers'] = $a_nat[$id]['def_telnet_servers']; + $pconfig['def_telnet_ports'] = $a_nat[$id]['def_telnet_ports']; + $pconfig['def_snmp_servers'] = $a_nat[$id]['def_snmp_servers']; + $pconfig['def_snmp_ports'] = $a_nat[$id]['def_snmp_ports']; + $pconfig['def_ftp_servers'] = $a_nat[$id]['def_ftp_servers']; + $pconfig['def_ftp_ports'] = $a_nat[$id]['def_ftp_ports']; + $pconfig['def_ssh_servers'] = $a_nat[$id]['def_ssh_servers']; + $pconfig['def_ssh_ports'] = $a_nat[$id]['def_ssh_ports']; + $pconfig['def_pop_servers'] = $a_nat[$id]['def_pop_servers']; + $pconfig['def_pop2_ports'] = $a_nat[$id]['def_pop2_ports']; + $pconfig['def_pop3_ports'] = $a_nat[$id]['def_pop3_ports']; + $pconfig['def_imap_servers'] = $a_nat[$id]['def_imap_servers']; + $pconfig['def_imap_ports'] = $a_nat[$id]['def_imap_ports']; + $pconfig['def_sip_proxy_ip'] = $a_nat[$id]['def_sip_proxy_ip']; + $pconfig['def_sip_proxy_ports'] = $a_nat[$id]['def_sip_proxy_ports']; + $pconfig['def_auth_ports'] = $a_nat[$id]['def_auth_ports']; + $pconfig['def_finger_ports'] = $a_nat[$id]['def_finger_ports']; + $pconfig['def_irc_ports'] = $a_nat[$id]['def_irc_ports']; + $pconfig['def_nntp_ports'] = $a_nat[$id]['def_nntp_ports']; + $pconfig['def_rlogin_ports'] = $a_nat[$id]['def_rlogin_ports']; + $pconfig['def_rsh_ports'] = $a_nat[$id]['def_rsh_ports']; + $pconfig['def_ssl_ports'] = $a_nat[$id]['def_ssl_ports']; + $pconfig['barnyard_enable'] = $a_nat[$id]['barnyard_enable']; + $pconfig['barnyard_mysql'] = $a_nat[$id]['barnyard_mysql']; + $pconfig['enable'] = $a_nat[$id]['enable']; + $pconfig['uuid'] = $a_nat[$id]['uuid']; + $pconfig['interface'] = $a_nat[$id]['interface']; + $pconfig['descr'] = $a_nat[$id]['descr']; + $pconfig['performance'] = $a_nat[$id]['performance']; + $pconfig['blockoffenders7'] = $a_nat[$id]['blockoffenders7']; + $pconfig['alertsystemlog'] = $a_nat[$id]['alertsystemlog']; + $pconfig['tcpdumplog'] = $a_nat[$id]['tcpdumplog']; + $pconfig['snortunifiedlog'] = $a_nat[$id]['snortunifiedlog']; + $pconfig['rulesets'] = $a_nat[$id]['rulesets']; + $pconfig['rule_sid_off'] = $a_nat[$id]['rule_sid_off']; + $pconfig['rule_sid_on'] = $a_nat[$id]['rule_sid_on']; + +if (isset($_GET['dup'])) + unset($id); +} + +/* convert fake interfaces to real */ +$if_real = convert_friendly_interface_to_real_interface_name2($pconfig['interface']); + + + if ($_POST["Submit"]) { + + /* check for overlaps */ + +/* if no errors write to conf */ + if (!$input_errors) { + $natent = array(); + /* repost the options already in conf */ + if ($pconfig['interface'] != "") { $natent['interface'] = $pconfig['interface']; } + if ($pconfig['enable'] != "") { $natent['enable'] = $pconfig['enable']; } + if ($pconfig['uuid'] != "") { $natent['uuid'] = $pconfig['uuid']; } + if ($pconfig['descr'] != "") { $natent['descr'] = $pconfig['descr']; } + if ($pconfig['performance'] != "") { $natent['performance'] = $pconfig['performance']; } + if ($pconfig['blockoffenders7'] != "") { $natent['blockoffenders7'] = $pconfig['blockoffenders7']; } + if ($pconfig['alertsystemlog'] != "") { $natent['alertsystemlog'] = $pconfig['alertsystemlog']; } + if ($pconfig['tcpdumplog'] != "") { $natent['tcpdumplog'] = $pconfig['tcpdumplog']; } + if ($pconfig['snortunifiedlog'] != "") { $natent['snortunifiedlog'] = $pconfig['snortunifiedlog']; } + if ($pconfig['def_ssl_ports_ignore'] != "") { $natent['def_ssl_ports_ignore'] = $pconfig['def_ssl_ports_ignore']; } + if ($pconfig['flow_depth'] != "") { $natent['flow_depth'] = $pconfig['flow_depth']; } + if ($pconfig['perform_stat'] != "") { $natent['perform_stat'] = $pconfig['perform_stat']; } + if ($pconfig['http_inspect'] != "") { $natent['http_inspect'] = $pconfig['http_inspect']; } + if ($pconfig['other_preprocs'] != "") { $natent['other_preprocs'] = $pconfig['other_preprocs']; } + if ($pconfig['ftp_preprocessor'] != "") { $natent['ftp_preprocessor'] = $pconfig['ftp_preprocessor']; } + if ($pconfig['smtp_preprocessor'] != "") { $natent['smtp_preprocessor'] = $pconfig['smtp_preprocessor']; } + if ($pconfig['sf_portscan'] != "") { $natent['sf_portscan'] = $pconfig['sf_portscan']; } + if ($pconfig['dce_rpc_2'] != "") { $natent['dce_rpc_2'] = $pconfig['dce_rpc_2']; } + if ($pconfig['dns_preprocessor'] != "") { $natent['dns_preprocessor'] = $pconfig['dns_preprocessor']; } + if ($pconfig['barnyard_enable'] != "") { $natent['barnyard_enable'] = $pconfig['barnyard_enable']; } + if ($pconfig['barnyard_mysql'] != "") { $natent['barnyard_mysql'] = $pconfig['barnyard_mysql']; } + if ($pconfig['rulesets'] != "") { $natent['rulesets'] = $pconfig['rulesets']; } + if ($pconfig['rule_sid_off'] != "") { $natent['rule_sid_off'] = $pconfig['rule_sid_off']; } + if ($pconfig['rule_sid_on'] != "") { $natent['rule_sid_on'] = $pconfig['rule_sid_on']; } + + + /* post new options */ + if ($_POST['def_dns_servers'] != "") { $natent['def_dns_servers'] = $_POST['def_dns_servers']; }else{ $natent['def_dns_servers'] = ""; } + if ($_POST['def_dns_ports'] != "") { $natent['def_dns_ports'] = $_POST['def_dns_ports']; }else{ $natent['def_dns_ports'] = ""; } + if ($_POST['def_smtp_servers'] != "") { $natent['def_smtp_servers'] = $_POST['def_smtp_servers']; }else{ $natent['def_smtp_servers'] = ""; } + if ($_POST['def_smtp_ports'] != "") { $natent['def_smtp_ports'] = $_POST['def_smtp_ports']; }else{ $natent['def_smtp_ports'] = ""; } + if ($_POST['def_mail_ports'] != "") { $natent['def_mail_ports'] = $_POST['def_mail_ports']; }else{ $natent['def_mail_ports'] = ""; } + if ($_POST['def_http_servers'] != "") { $natent['def_http_servers'] = $_POST['def_http_servers']; }else{ $natent['def_http_servers'] = ""; } + if ($_POST['def_www_servers'] != "") { $natent['def_www_servers'] = $_POST['def_www_servers']; }else{ $natent['def_www_servers'] = ""; } + if ($_POST['def_http_ports'] != "") { $natent['def_http_ports'] = $_POST['def_http_ports']; }else{ $natent['def_http_ports'] = ""; } + if ($_POST['def_sql_servers'] != "") { $natent['def_sql_servers'] = $_POST['def_sql_servers']; }else{ $natent['def_sql_servers'] = ""; } + if ($_POST['def_oracle_ports'] != "") { $natent['def_oracle_ports'] = $_POST['def_oracle_ports']; }else{ $natent['def_oracle_ports'] = ""; } + if ($_POST['def_mssql_ports'] != "") { $natent['def_mssql_ports'] = $_POST['def_mssql_ports']; }else{ $natent['def_mssql_ports'] = ""; } + if ($_POST['def_telnet_servers'] != "") { $natent['def_telnet_servers'] = $_POST['def_telnet_servers']; }else{ $natent['def_telnet_servers'] = ""; } + if ($_POST['def_telnet_ports'] != "") { $natent['def_telnet_ports'] = $_POST['def_telnet_ports']; }else{ $natent['def_telnet_ports'] = ""; } + if ($_POST['def_snmp_servers'] != "") { $natent['def_snmp_servers'] = $_POST['def_snmp_servers']; }else{ $natent['def_snmp_servers'] = ""; } + if ($_POST['def_snmp_ports'] != "") { $natent['def_snmp_ports'] = $_POST['def_snmp_ports']; }else{ $natent['def_snmp_ports'] = ""; } + if ($_POST['def_ftp_servers'] != "") { $natent['def_ftp_servers'] = $_POST['def_ftp_servers']; }else{ $natent['def_ftp_servers'] = ""; } + if ($_POST['def_ftp_ports'] != "") { $natent['def_ftp_ports'] = $_POST['def_ftp_ports']; }else{ $natent['def_ftp_ports'] = ""; } + if ($_POST['def_ssh_servers'] != "") { $natent['def_ssh_servers'] = $_POST['def_ssh_servers']; }else{ $natent['def_ssh_servers'] = ""; } + if ($_POST['def_ssh_ports'] != "") { $natent['def_ssh_ports'] = $_POST['def_ssh_ports']; }else{ $natent['def_ssh_ports'] = ""; } + if ($_POST['def_pop_servers'] != "") { $natent['def_pop_servers'] = $_POST['def_pop_servers']; }else{ $natent['def_pop_servers'] = ""; } + if ($_POST['def_pop2_ports'] != "") { $natent['def_pop2_ports'] = $_POST['def_pop2_ports']; }else{ $natent['def_pop2_ports'] = ""; } + if ($_POST['def_pop3_ports'] != "") { $natent['def_pop3_ports'] = $_POST['def_pop3_ports']; }else{ $natent['def_pop3_ports'] = ""; } + if ($_POST['def_imap_servers'] != "") { $natent['def_imap_servers'] = $_POST['def_imap_servers']; }else{ $natent['def_imap_servers'] = ""; } + if ($_POST['def_imap_ports'] != "") { $natent['def_imap_ports'] = $_POST['def_imap_ports']; }else{ $natent['def_imap_ports'] = ""; } + if ($_POST['def_sip_proxy_ip'] != "") { $natent['def_sip_proxy_ip'] = $_POST['def_sip_proxy_ip']; }else{ $natent['def_sip_proxy_ip'] = ""; } + if ($_POST['def_sip_proxy_ports'] != "") { $natent['def_sip_proxy_ports'] = $_POST['def_sip_proxy_ports']; }else{ $natent['def_sip_proxy_ports'] = ""; } + if ($_POST['def_auth_ports'] != "") { $natent['def_auth_ports'] = $_POST['def_auth_ports']; }else{ $natent['def_auth_ports'] = ""; } + if ($_POST['def_finger_ports'] != "") { $natent['def_finger_ports'] = $_POST['def_finger_ports']; }else{ $natent['def_finger_ports'] = ""; } + if ($_POST['def_irc_ports'] != "") { $natent['def_irc_ports'] = $_POST['def_irc_ports']; }else{ $natent['def_irc_ports'] = ""; } + if ($_POST['def_nntp_ports'] != "") { $natent['def_nntp_ports'] = $_POST['def_nntp_ports']; }else{ $natent['def_nntp_ports'] = ""; } + if ($_POST['def_rlogin_ports'] != "") { $natent['def_rlogin_ports'] = $_POST['def_rlogin_ports']; }else{ $natent['def_rlogin_ports'] = ""; } + if ($_POST['def_rsh_ports'] != "") { $natent['def_rsh_ports'] = $_POST['def_rsh_ports']; }else{ $natent['def_rsh_ports'] = ""; } + if ($_POST['def_ssl_ports'] != "") { $natent['def_ssl_ports'] = $_POST['def_ssl_ports']; }else{ $natent['def_ssl_ports'] = ""; } + + + if (isset($id) && $a_nat[$id]) + $a_nat[$id] = $natent; + else { + if (is_numeric($after)) + array_splice($a_nat, $after+1, 0, array($natent)); + else + $a_nat[] = $natent; + } + + write_config(); + + /* after click go to this page */ + + touch($d_snortconfdirty_path); + + 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' ); + header( 'Cache-Control: post-check=0, pre-check=0', false ); + header( 'Pragma: no-cache' ); + sleep(2); + + header("Location: snort_define_servers.php?id=$id"); + + exit; + } +} + +$snort_uuid = $pconfig['uuid']; + + /* alert file */ +$d_snortconfdirty_path = "/var/run/snort_conf_{$snort_uuid }_{$if_real}.dirty"; + + /* this will exec when alert says apply */ + if ($_POST['apply']) { + + if (file_exists($d_snortconfdirty_path)) { + + write_config(); + + sync_snort_package_all($id, $if_real, $snort_uuid); + sync_snort_package(); + + unlink($d_snortconfdirty_path); + + } + + } + +$pgtitle = "Snort: Interface $id$if_real Define Servers"; +include("head.inc"); + +?> + + +

    + + + + + +
    + +'; + + if($savemsg) { + print_info_box_np2("{$savemsg}"); + }else{ + print_info_box_np2(' + The Snort configuration has changed and snort needs to be restarted on this interface.
    + You must apply the changes in order for them to take effect.
    + '); + } + } + +?> + + + + + +
    + +
    + + + .noid { + position:absolute; + top:10px; + left:0px; + width:94%; + background:#FCE9C0; + background-position: 15px; + border-top:2px solid #DBAC48; + border-bottom:2px solid #DBAC48; + padding: 15px 10px 85% 50px; + } + +
    You can not edit options without an interface ID.
    \n"; + + } + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
     Note:
    + Please save your settings before you click start.
    + Please make sure there are no spaces in your definitions. +
    Define DNS_SERVERS + +
    Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks.
    Define DNS_PORTS + +
    Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 53.
    Define SMTP_SERVERS + +
    Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks.
    Define SMTP_PORTS + +
    Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 25.
    Define Mail_Ports + +
    Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 25,143,465,691.
    Define HTTP_SERVERS + +
    Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks.
    Define WWW_SERVERS + +
    Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks.
    Define HTTP_PORTS + +
    Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 80.
    Define SQL_SERVERS + +
    Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks.
    Define ORACLE_PORTS + +
    Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 1521.
    Define MSSQL_PORTS + +
    Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 1433.
    Define TELNET_SERVERS + +
    Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks.
    Define TELNET_PORTS + +
    Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 23.
    Define SNMP_SERVERS + +
    Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks.
    Define SNMP_PORTS + +
    Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 161.
    Define FTP_SERVERS + +
    Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks.
    Define FTP_PORTS + +
    Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 21.
    Define SSH_SERVERS + +
    Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks.
    Define SSH_PORTS + +
    Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is Pfsense SSH port.
    Define POP_SERVERS + +
    Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks.
    Define POP2_PORTS + +
    Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 109.
    Define POP3_PORTS + +
    Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 110.
    Define IMAP_SERVERS + +
    Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks.
    Define IMAP_PORTS + +
    Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 143.
    Define SIP_PROXY_IP + +
    Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks.
    Define SIP_PROXY_PORTS + +
    Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 5060:5090,16384:32768.
    Define AUTH_PORTS + +
    Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 113.
    Define FINGER_PORTS + +
    Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 79.
    Define IRC_PORTS + +
    Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 6665,6666,6667,6668,6669,7000.
    Define NNTP_PORTS + +
    Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 119.
    Define RLOGIN_PORTS + +
    Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 513.
    Define RSH_PORTS + +
    Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 514.
    Define SSL_PORTS + +
    Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 25,443,465,636,993,995.
      + + + + +
     Note: +
    + Please save your settings before you click start.
    +
    +
    + + + + + diff --git a/config/snort/snort_define_servers.xml b/config/snort/snort_define_servers.xml deleted file mode 100644 index 7df880d0..00000000 --- a/config/snort/snort_define_servers.xml +++ /dev/null @@ -1,364 +0,0 @@ - - - - - - . - 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. - */ -/* ========================================================================== */ - ]]> - - Describe your package here - Describe your package requirements here - Currently there are no FAQ items provided. - SnortDefServers - none - Services: Snort Define Servers - /usr/local/pkg/snort.inc - - - Settings - /pkg_edit.php?xml=snort.xml&id=0 - - - Update Rules - /snort_download_rules.php - - - Categories - /snort_rulesets.php - - - Rules - /snort_rules.php - - - Servers - /pkg_edit.php?xml=snort_define_servers.xml&id=0 - - - - Blocked - /snort_blocked.php - - - Whitelist - /pkg.php?xml=snort_whitelist.xml - - - Threshold - /pkg.php?xml=snort_threshold.xml - - - Alerts - /snort_alerts.php - - - Advanced - /pkg_edit.php?xml=snort_advanced.xml&id=0 - - - - - Define DNS_SERVERS - def_dns_servers - Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks. - input - 101 - - - - Define DNS_PORTS - def_dns_ports - Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 53. - input - 43 - - - - Define SMTP_SERVERS - def_smtp_servers - Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks. - input - 101 - - - - Define SMTP_PORTS - def_smtp_ports - Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 25. - input - 43 - - - - Define Mail_Ports - def_mail_ports - Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 25,143,465,691. - input - 43 - - - - Define HTTP_SERVERS - def_http_servers - Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks. - input - 101 - - - - Define WWW_SERVERS - def_www_servers - Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks. - input - 101 - - - - Define HTTP_PORTS - def_http_ports - Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 80. - input - 43 - - - - Define SQL_SERVERS - def_sql_servers - Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks. - input - 101 - - - - Define ORACLE_PORTS - def_oracle_ports - Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 1521. - input - 43 - - - - Define MSSQL_PORTS - def_mssql_ports - Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 1433. - input - 43 - - - - Define TELNET_SERVERS - def_telnet_servers - Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks. - input - 101 - - - - Define TELNET_PORTS - def_telnet_ports - Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 23. - input - 43 - - - - Define SNMP_SERVERS - def_snmp_servers - Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks. - input - 101 - - - - Define SNMP_PORTS - def_snmp_ports - Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 161. - input - 43 - - - - Define FTP_SERVERS - def_ftp_servers - Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks. - input - 101 - - - - Define FTP_PORTS - def_ftp_ports - Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 21. - input - 43 - - - - Define SSH_SERVERS - def_ssh_servers - Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks. - input - 101 - - - - Define SSH_PORTS - def_ssh_ports - Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is Pfsense SSH port. - input - 43 - - - - Define POP_SERVERS - def_pop_servers - Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks. - input - 101 - - - - Define POP2_PORTS - def_pop2_ports - Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 109. - input - 43 - - - - Define POP3_PORTS - def_pop3_ports - Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 110. - input - 43 - - - - Define IMAP_SERVERS - def_imap_servers - Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks. - input - 101 - - - - Define IMAP_PORTS - def_imap_ports - Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 143. - input - 43 - - - - Define SIP_PROXY_IP - def_sip_proxy_ip - Example: "192.168.1.3/24,192.168.1.4/24". Leave blank to scan all networks. - input - 101 - - - - Define SIP_PROXY_PORTS - def_sip_proxy_ports - Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 5060:5090,16384:32768. - input - 43 - - - - Define AUTH_PORTS - def_auth_ports - Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 113. - input - 43 - - - - Define FINGER_PORTS - def_finger_ports - Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 79. - input - 43 - - - - Define IRC_PORTS - def_irc_ports - Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 6665,6666,6667,6668,6669,7000. - input - 43 - - - - Define NNTP_PORTS - def_nntp_ports - Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 119. - input - 43 - - - - Define RLOGIN_PORTS - def_rlogin_ports - Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 513. - input - 43 - - - - Define RSH_PORTS - def_rsh_ports - Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 514. - input - 43 - - - - Define SSL_PORTS - def_ssl_ports - Example: Specific ports "25,443" or All ports betwen "5060:5090 . Default is 25,443,465,636,993,995. - input - 43 - - - - - snort_define_servers(); - - diff --git a/config/snort/snort_download_rules.php b/config/snort/snort_download_rules.php index 9826ba2a..b2bcb748 100644 --- a/config/snort/snort_download_rules.php +++ b/config/snort/snort_download_rules.php @@ -2,7 +2,8 @@ /* $Id$ */ /* snort_rulesets.php - Copyright (C) 2006 Scott Ullrich and Robert Zelaya + Copyright (C) 2006 Scott Ullrich + Copyright (C) 2009 Robert Zelaya All rights reserved. Redistribution and use in source and binary forms, with or without @@ -28,8 +29,15 @@ */ /* Setup enviroment */ -$tmpfname = "/root/snort_rules_up"; -$snortdir = "/usr/local/etc/snort_bkup"; + +/* TODO: review if include files are needed */ +require_once("guiconfig.inc"); +require_once("functions.inc"); +require_once("service-utils.inc"); +require_once("/usr/local/pkg/snort/snort.inc"); + +$tmpfname = "/tmp/snort_rules_up"; +$snortdir = "/usr/local/etc/snort"; $snortdir_wan = "/usr/local/etc/snort"; $snort_filename_md5 = "snortrules-snapshot-2.8.tar.gz.md5"; $snort_filename = "snortrules-snapshot-2.8.tar.gz"; @@ -38,27 +46,213 @@ $emergingthreats_filename = "emerging.rules.tar.gz"; $pfsense_rules_filename_md5 = "pfsense_rules.tar.gz.md5"; $pfsense_rules_filename = "pfsense_rules.tar.gz"; -require_once("guiconfig.inc"); -require_once("functions.inc"); -require_once("service-utils.inc"); -require("/usr/local/pkg/snort.inc"); +$id_d = $_GET['id_d']; +if (isset($_POST['id_d'])) + $id_d = $_POST['id_d']; + +/* Time stamps define */ +$last_md5_download = $config['installedpackages']['snortglobal']['last_md5_download']; +$last_rules_install = $config['installedpackages']['snortglobal']['last_rules_install']; + +/* define checks */ +$oinkid = $config['installedpackages']['snortglobal']['oinkmastercode']; +$snortdownload = $config['installedpackages']['snortglobal']['snortdownload']; +$emergingthreats = $config['installedpackages']['snortglobal']['emergingthreats']; + + + if ($snortdownload == "off" && $emergingthreats != "on") + { + $snort_emrging_info = "stop"; + } + + if ($oinkid == "" && $snortdownload != "off") + { + $snort_oinkid_info = "stop"; + } + + + /* check if main rule directory is empty */ + $if_mrule_dir = "/usr/local/etc/snort/rules"; + $mfolder_chk = (count(glob("$if_mrule_dir/*")) === 0) ? 'empty' : 'full'; + + +if (file_exists('/var/run/snort.conf.dirty')) { + $snort_dirty_d = 'stop'; +} + + + +/* If no id show the user a button */ +if ($id_d == "" || $snort_emrging_info == "stop" || $snort_oinkid_info == "stop" || $snort_dirty_d == 'stop') { + +$pgtitle = "Services: Snort: Rule Updates"; + +include("head.inc"); +include("./snort_fbegin.inc"); +echo "

    "; +if($pfsense_stable == 'yes'){echo $pgtitle;} +echo "

    \n"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo "
    \n"; + echo "
    \n"; + echo " \n"; + echo " "; + echo "
    \n"; + echo "    \n"; + echo " NOTE:  Snort.org and Emergingthreats.net will go down from time to time. Please be patient.\n"; + echo "
    \n"; + echo "
    \n"; + echo "
    \n"; + echo "\n"; + echo "\n
    \n"; + +/* make sure user has javascript on */ +echo " +\n"; +echo "\n"; + +echo "\n +\n +\n + \n + \n + \n + \n + \n + \n +
    \n"; + + $tab_array = array(); + $tab_array[] = array("Snort Interfaces", false, "/snort/snort_interfaces.php"); + $tab_array[] = array("Global Settings", false, "/snort/snort_interfaces_global.php"); + $tab_array[] = array("Rule Updates", true, "/snort/snort_download_rules.php"); + $tab_array[] = array("Alerts", false, "/snort/snort_alerts.php"); + $tab_array[] = array("Blocked", false, "/snort/snort_blocked.php"); + $tab_array[] = array("Whitelists", false, "/pkg.php?xml=/snort/snort_whitelist.xml"); + $tab_array[] = array("Help & Info", false, "/snort/snort_help_info.php"); + display_top_tabs($tab_array); + +if ($snort_emrging_info == "stop" && $snort_oinkid_info == "stop") { +$disable_enable_button = 'onclick="this.disabled=true"'; +}else{ +$disable_enable_button = "onClick=\"parent.location='/snort/snort_download_rules.php?id_d=up'\""; +} +echo "
    \n +
    \n + \n + \n + \n + \n +
    \n +

    \n"; + +if ($mfolder_chk == "empty") +{ +echo "WARNING:   The main rules directory is empty. /usr/local/etc/snort/rules

    \n"; +} + +if ($snort_emrging_info == "stop") { +echo "WARNING:   Click on the \"Global Settings\" tab and select ether snort.org or enmergingthreats.net rules to download.

    \n"; +} + +if ($snort_oinkid_info == "stop") { +echo "WARNING:   Click on the \"Global Settings\" tab and enter a oinkmaster code.

    \n"; +} + +if ($snort_dirty_d == "stop") { +echo "WARNING: CHANGES HAVE NOT BEEN APPLIED   Click on the \"Apply Settings\" button at the main interface tab.

    \n"; +} + +echo "
    \n +
    \n +
    \n +\n +\n +\n +

    \n\n"; + +if ($id_d == "") +echo "Click on the \"Update Rules\" button to start the updates.

    \n"; + +if ($config['installedpackages']['snortglobal']['last_md5_download'] != "") +echo "The last time the updates were started $last_md5_download.

    \n"; + +if ($config['installedpackages']['snortglobal']['last_rules_install'] != "") +echo "The last time the updates were installed $last_rules_install.

    \n"; + +include("fend.inc"); + +echo ""; +echo ""; + +exit(0); + +} $pgtitle = "Services: Snort: Update Rules"; include("/usr/local/www/head.inc"); ?> - + + + + + + + +

    @@ -67,23 +261,28 @@ if(!$pgtitle_output) - - - - + + + + + +
    + +
    @@ -92,7 +291,7 @@ if(!$pgtitle_output)
    - /images/misc/progress_bar.gif' width='280' height='23' name='progressbar' id='progressbar' alt='' /> + /images/misc/progress_bar.gif' width='280' height='23' name='progressbar' id='progressbar' alt='' />
    @@ -112,47 +311,34 @@ if(!$pgtitle_output) - 0) { + update_status(gettext("snort.org md5 temp file exists...")); + } else { + update_status(gettext("Downloading snort.org md5 file...")); + ini_set('user_agent','Mozilla/4.0 (compatible; MSIE 6.0)'); + $image = @file_get_contents("http://dl.snort.org/{$premium_url}/snortrules-snapshot-2.8{$premium_subscriber}.tar.gz.md5?oink_code={$oinkid}"); // $image = @file_get_contents("http://www.mtest.local/pub-bin/oinkmaster.cgi/{$oinkid}/snortrules-snapshot-2.8{$premium_subscriber}.tar.gz.md5"); - $f = fopen("{$tmpfname}/snortrules-snapshot-2.8.tar.gz.md5", 'w'); - fwrite($f, $image); - fclose($f); - update_status(gettext("Done. downloading md5")); + $f = fopen("{$tmpfname}/snortrules-snapshot-2.8.tar.gz.md5", 'w'); + fwrite($f, $image); + fclose($f); + update_status(gettext("Done downloading snort.org md5")); + } } /* download md5 sig from emergingthreats.net */ -$emergingthreats_url_chk = $config['installedpackages']['snort']['config'][0]['emergingthreats']; -if ($emergingthreats_url_chk == on) { - update_status(gettext("Downloading md5 file...")); - ini_set('user_agent','Mozilla/4.0 (compatible; MSIE 6.0)'); - $image = @file_get_contents("http://www.emergingthreats.net/version.txt"); +if ($emergingthreats == "on") +{ + update_status(gettext("Downloading emergingthreats md5 file...")); + ini_set('user_agent','Mozilla/4.0 (compatible; MSIE 6.0)'); + $image = @file_get_contents("http://www.emergingthreats.net/version.txt"); // $image = @file_get_contents("http://www.mtest.local/pub-bin/oinkmaster.cgi/{$oinkid}/version.txt"); - $f = fopen("{$tmpfname}/version.txt", 'w'); - fwrite($f, $image); - fclose($f); - update_status(gettext("Done. downloading md5")); + $f = fopen("{$tmpfname}/version.txt", 'w'); + fwrite($f, $image); + fclose($f); + update_status(gettext("Done downloading emergingthreats md5")); } /* download md5 sig from pfsense.org */ if (file_exists("{$tmpfname}/{$pfsense_rules_filename_md5}")) { - update_status(gettext("md5 temp file exists...")); + update_status(gettext("pfsense md5 temp file exists...")); } else { update_status(gettext("Downloading pfsense md5 file...")); ini_set('user_agent','Mozilla/4.0 (compatible; MSIE 6.0)'); @@ -229,23 +420,30 @@ if (file_exists("{$tmpfname}/{$pfsense_rules_filename_md5}")) { $f = fopen("{$tmpfname}/pfsense_rules.tar.gz.md5", 'w'); fwrite($f, $image); fclose($f); - update_status(gettext("Done. downloading md5")); + update_status(gettext("Done downloading pfsense md5.")); } -/* Time stamps define */ -$last_md5_download = $config['installedpackages']['snort']['last_md5_download']; -$last_rules_install = $config['installedpackages']['snort']['last_rules_install']; - /* If md5 file is empty wait 15min exit */ -if (0 == filesize("{$tmpfname}/snortrules-snapshot-2.8.tar.gz.md5")){ - update_status(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.")); - hide_progress_bar_status(); - /* Display last time of sucsessful md5 check from cache */ - echo "\n

    You last checked for updates: {$last_md5_download}

    \n"; - echo "\n

    You last installed for rules: {$last_rules_install}

    \n"; - echo "\n\n\n\n"; - exit(0); +if ($snortdownload != "off") +{ + if (0 == filesize("{$tmpfname}/snortrules-snapshot-2.8.tar.gz.md5")) + { + update_status(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.")); + hide_progress_bar_status(); + /* Display last time of sucsessful md5 check from cache */ + echo "\n\n\n\n"; + echo ' +'; +echo ""; +echo ""; +conf_mount_ro(); + exit(0); + } } /* If emergingthreats md5 file is empty wait 15min exit not needed */ @@ -256,89 +454,138 @@ if (0 == filesize("{$tmpfname}/$pfsense_rules_filename_md5")){ update_output_window(gettext("Rules are released to support Pfsense packages.")); hide_progress_bar_status(); /* Display last time of sucsessful md5 check from cache */ - echo "\n

    You last checked for updates: {$last_md5_download}

    \n"; - echo "\n

    You last installed for rules: {$last_rules_install}

    \n"; echo "\n\n\n\n"; + echo ' +'; +echo ""; +echo ""; +conf_mount_ro(); exit(0); } /* Check if were up to date snort.org */ -if (file_exists("{$snortdir}/snortrules-snapshot-2.8.tar.gz.md5")){ -$md5_check_new_parse = file_get_contents("{$tmpfname}/{$snort_filename_md5}"); -$md5_check_new = `/bin/echo "{$md5_check_new_parse}" | /usr/bin/awk '{ print $1 }'`; -$md5_check_old_parse = file_get_contents("{$snortdir}/{$snort_filename_md5}"); -$md5_check_old = `/bin/echo "{$md5_check_old_parse}" | /usr/bin/awk '{ print $1 }'`; -/* Write out time of last sucsessful md5 to cache */ -$config['installedpackages']['snort']['last_md5_download'] = date("Y-M-jS-h:i-A"); -write_config(); // Will cause switch back to read-only on nanobsd -conf_mount_rw(); -if ($md5_check_new == $md5_check_old) { - update_status(gettext("Your rules are up to date...")); - update_output_window(gettext("You may start Snort now, check update.")); - hide_progress_bar_status(); - /* Timestamps to html */ - echo "\n

    You last checked for updates: {$last_md5_download}

    \n"; - echo "\n

    You last installed for rules: {$last_rules_install}

    \n"; -// echo "P is this code {$premium_subscriber}"; +if ($snortdownload != "off") +{ + if (file_exists("{$snortdir}/snortrules-snapshot-2.8.tar.gz.md5")) + { + $md5_check_new_parse = file_get_contents("{$tmpfname}/{$snort_filename_md5}"); + $md5_check_new = `/bin/echo "{$md5_check_new_parse}" | /usr/bin/awk '{ print $1 }'`; + $md5_check_old_parse = file_get_contents("{$snortdir}/{$snort_filename_md5}"); + $md5_check_old = `/bin/echo "{$md5_check_old_parse}" | /usr/bin/awk '{ print $1 }'`; + /* Write out time of last sucsessful md5 to cache */ + write_config(); // Will cause switch back to read-only on nanobsd + conf_mount_rw(); + if ($md5_check_new == $md5_check_old) + { + update_status(gettext("Your rules are up to date...")); + update_output_window(gettext("You may start Snort now, check update.")); + hide_progress_bar_status(); echo "\n\n\n\n"; $snort_md5_check_ok = on; - } + } + } } /* Check if were up to date emergingthreats.net */ -$emergingthreats_url_chk = $config['installedpackages']['snort']['config'][0]['emergingthreats']; -if ($emergingthreats_url_chk == on) { -if (file_exists("{$snortdir}/version.txt")){ -$emerg_md5_check_new_parse = file_get_contents("{$tmpfname}/version.txt"); -$emerg_md5_check_new = `/bin/echo "{$emerg_md5_check_new_parse}" | /usr/bin/awk '{ print $1 }'`; -$emerg_md5_check_old_parse = file_get_contents("{$snortdir}/version.txt"); -$emerg_md5_check_old = `/bin/echo "{$emerg_md5_check_old_parse}" | /usr/bin/awk '{ print $1 }'`; -/* Write out time of last sucsessful md5 to cache */ -$config['installedpackages']['snort']['last_md5_download'] = date("Y-M-jS-h:i-A"); -write_config(); // Will cause switch back to read-only on nanobsd -conf_mount_rw(); -if ($emerg_md5_check_new == $emerg_md5_check_old) { - update_status(gettext("Your emergingthreats rules are up to date...")); - update_output_window(gettext("You may start Snort now, check update.")); +if ($emergingthreats == "on") +{ + if (file_exists("{$snortdir}/version.txt")) + { + $emerg_md5_check_new_parse = file_get_contents("{$tmpfname}/version.txt"); + $emerg_md5_check_new = `/bin/echo "{$emerg_md5_check_new_parse}" | /usr/bin/awk '{ print $1 }'`; + $emerg_md5_check_old_parse = file_get_contents("{$snortdir}/version.txt"); + $emerg_md5_check_old = `/bin/echo "{$emerg_md5_check_old_parse}" | /usr/bin/awk '{ print $1 }'`; + /* Write out time of last sucsessful md5 to cache */ + // Will cause switch back to read-only on nanobsd + write_config(); + conf_mount_rw(); + if ($emerg_md5_check_new == $emerg_md5_check_old) + { hide_progress_bar_status(); - $emerg_md5_check_chk_ok = on; - } - } + $emerg_md5_check_ok = on; + } + } } /* Check if were up to date pfsense.org */ -if (file_exists("{$snortdir}/$pfsense_rules_filename_md5")){ -$pfsense_md5_check_new_parse = file_get_contents("{$tmpfname}/{$snort_filename_md5}"); -$pfsense_md5_check_new = `/bin/echo "{$pfsense_md5_check_new_parse}" | /usr/bin/awk '{ print $1 }'`; -$pfsense_md5_check_old_parse = file_get_contents("{$snortdir}/{$snort_filename_md5}"); -$pfsense_md5_check_old = `/bin/echo "{$md5_check_old_parse}" | /usr/bin/awk '{ print $1 }'`; -if ($pfsense_md5_check_new == $pfsense_md5_check_old) { + if (file_exists("{$snortdir}/pfsense_rules.tar.gz.md5")) + { + $pfsense_check_new_parse = file_get_contents("{$tmpfname}/pfsense_rules.tar.gz.md5"); + $pfsense_md5_check_new = `/bin/echo "{$pfsense_md5_check_new_parse}" | /usr/bin/awk '{ print $1 }'`; + $pfsense_md5_check_old_parse = file_get_contents("{$snortdir}/pfsense_rules.tar.gz.md5"); + $pfsense_md5_check_old = `/bin/echo "{$pfsense_md5_check_old_parse}" | /usr/bin/awk '{ print $1 }'`; + /* Write out time of last sucsessful md5 to cache */ + // Will cause switch back to read-only on nanobsd + write_config(); + conf_mount_rw(); + if ($pfsense_md5_check_new == $pfsense_md5_check_old) + { + hide_progress_bar_status(); $pfsense_md5_check_ok = on; - } -} + } + } -/* Make Clean Snort Directory emergingthreats not checked */ -if ($snort_md5_check_ok == on && $emergingthreats_url_chk != on) { - update_status(gettext("Cleaning the snort Directory...")); - update_output_window(gettext("removing...")); - exec("/bin/rm {$snortdir}/rules/emerging*"); - exec("/bin/rm {$snortdir}/version.txt"); - exec("/bin/rm {$snortdir_wan}/rules/emerging*"); - exec("/bin/rm {$snortdir_wan}/version.txt"); - update_status(gettext("Done making cleaning emrg direcory.")); +/* Check if were up to date is so, exit */ +/* WARNING This code needs constant checks */ +if ($snortdownload != "off" && $emergingthreats != "off") +{ + if ($snort_md5_check_ok == "on" && $emerg_md5_check_ok == "on") + { + update_status(gettext("All your rules are up to date...")); + update_output_window(gettext("You may start Snort now...")); + echo ' + '; + echo ""; + echo ""; + conf_mount_ro(); + exit(0); + } } -/* Check if were up to date exits */ -if ($snort_md5_check_ok == on && $emerg_md5_check_chk_ok == on && $pfsense_md5_check_ok == on) { - update_status(gettext("Your rules are up to date...")); - update_output_window(gettext("You may start Snort now...")); - exit(0); +if ($snortdownload == "on" && $emergingthreats == "off") +{ + if ($snort_md5_check_ok == "on") + { + update_status(gettext("Your snort.org rules are up to date...")); + update_output_window(gettext("You may start Snort now...")); + echo ' + '; + echo ""; + echo ""; + conf_mount_ro(); + exit(0); + } } -if ($snort_md5_check_ok == on && $pfsense_md5_check_ok == on && $emergingthreats_url_chk != on) { - update_status(gettext("Your rules are up to date...")); - update_output_window(gettext("You may start Snort now...")); - exit(0); +if ($snortdownload == "off" && $emergingthreats == "on") +{ + if ($emerg_md5_check_ok == "on") + { + update_status(gettext("Your Emergingthreats rules are up to date...")); + update_output_window(gettext("You may start Snort now...")); + echo ' + '; + echo ""; + echo ""; + conf_mount_ro(); + exit(0); + } } /* You are Not Up to date, always stop snort when updating rules for low end machines */; @@ -347,45 +594,60 @@ update_output_window(gettext("Stopping Snort service...")); $chk_if_snort_up = exec("pgrep -x snort"); if ($chk_if_snort_up != "") { exec("/usr/bin/touch /tmp/snort_download_halt.pid"); - stop_service("snort"); + exec("/bin/sh /usr/local/etc/rc.d/snort.sh stop"); sleep(2); } /* download snortrules file */ -if ($snort_md5_check_ok != on) { -if (file_exists("{$tmpfname}/{$snort_filename}")) { - update_status(gettext("Snortrule tar file exists...")); -} else { - unhide_progress_bar_status(); - update_status(gettext("There is a new set of Snort rules posted. Downloading...")); - update_output_window(gettext("May take 4 to 10 min...")); +if ($snortdownload != "off") +{ + if ($snort_md5_check_ok != on) { + if (file_exists("{$tmpfname}/{$snort_filename}")) { + update_status(gettext("Snortrule tar file exists...")); + } else { + unhide_progress_bar_status(); + update_status(gettext("There is a new set of Snort rules posted. Downloading...")); + update_output_window(gettext("May take 4 to 10 min...")); // download_file_with_progress_bar("http://www.mtest.local/pub-bin/oinkmaster.cgi/{$oinkid}/snortrules-snapshot-2.8{$premium_subscriber}.tar.gz", $tmpfname . "/{$snort_filename}", "read_body_firmware"); - download_file_with_progress_bar("http://dl.snort.org/{$premium_url}/snortrules-snapshot-2.8{$premium_subscriber}.tar.gz?oink_code={$oinkid}", $tmpfname . "/{$snort_filename}", "read_body_firmware"); - update_all_status($static_output); - update_status(gettext("Done downloading rules file.")); - if (150000 > filesize("{$tmpfname}/$snort_filename")){ - update_status(gettext("Error with the snort rules download...")); - update_output_window(gettext("Snort rules file downloaded failed...")); - exit(0); - } - } + download_file_with_progress_bar("http://dl.snort.org/{$premium_url}/snortrules-snapshot-2.8{$premium_subscriber}.tar.gz?oink_code={$oinkid}", $tmpfname . "/{$snort_filename}", "read_body_firmware"); + update_all_status($static_output); + update_status(gettext("Done downloading rules file.")); + if (150000 > filesize("{$tmpfname}/$snort_filename")){ + update_status(gettext("Error with the snort rules download...")); + update_output_window(gettext("Snort rules file downloaded failed...")); + echo ' +'; +echo ""; +echo ""; +conf_mount_ro(); + exit(0); + } + } + } } - + /* download emergingthreats rules file */ -if ($emergingthreats_url_chk == on) { -if ($emerg_md5_check_chk_ok != on) { -if (file_exists("{$tmpfname}/{$emergingthreats_filename}")) { - update_status(gettext("Emergingthreats tar file exists...")); -} else { - update_status(gettext("There is a new set of Emergingthreats rules posted. Downloading...")); - update_output_window(gettext("May take 4 to 10 min...")); +if ($emergingthreats == "on") +{ + if ($emerg_md5_check_ok != on) + { + if (file_exists("{$tmpfname}/{$emergingthreats_filename}")) + { + update_status(gettext("Emergingthreats tar file exists...")); + }else{ + update_status(gettext("There is a new set of Emergingthreats rules posted. Downloading...")); + update_output_window(gettext("May take 4 to 10 min...")); // download_file_with_progress_bar("http://www.mtest.local/pub-bin/oinkmaster.cgi/{$oinkid}/emerging.rules.tar.gz", $tmpfname . "/{$emergingthreats_filename}", "read_body_firmware"); - download_file_with_progress_bar("http://www.emergingthreats.net/rules/emerging.rules.tar.gz", $tmpfname . "/{$emergingthreats_filename}", "read_body_firmware"); - update_all_status($static_output); - update_status(gettext("Done downloading Emergingthreats rules file.")); - } - } - } + download_file_with_progress_bar("http://www.emergingthreats.net/rules/emerging.rules.tar.gz", $tmpfname . "/{$emergingthreats_filename}", "read_body_firmware"); + update_all_status($static_output); + update_status(gettext("Done downloading Emergingthreats rules file.")); + } + } +} /* download pfsense rules file */ if ($pfsense_md5_check_ok != on) { @@ -431,44 +693,65 @@ if (file_exists("{$tmpfname}/{$pfsense_rules_filename}")) { //} /* Untar snort rules file individually to help people with low system specs */ -if ($snort_md5_check_ok != on) { -if (file_exists("{$tmpfname}/{$snort_filename}")) { - update_status(gettext("Extracting rules...")); - update_output_window(gettext("May take a while...")); - exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} rules/"); - exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} etc/"); - exec("`/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/precompiled/FreeBSD-7.0/i386/2.8.4/*`"); - exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/bad-traffic.rules/"); - exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/chat.rules/"); - exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/dos.rules/"); - exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/exploit.rules/"); - exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/imap.rules/"); - exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/misc.rules/"); - exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/multimedia.rules/"); - exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/netbios.rules/"); - exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/nntp.rules/"); - exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/p2p.rules/"); - exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/smtp.rules/"); - exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/sql.rules/"); - exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/web-client.rules/"); - exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} so_rules/web-misc.rules/"); - update_status(gettext("Done extracting Rules.")); -} else { - update_status(gettext("The Download rules file missing...")); - update_output_window(gettext("Error rules extracting failed...")); - exit(0); - } +if ($snortdownload != "off") +{ + if ($snort_md5_check_ok != on) { + if (file_exists("{$tmpfname}/{$snort_filename}")) { + update_status(gettext("Extracting rules...")); + update_output_window(gettext("May take a while...")); + exec("/bin/mkdir -p {$snortdir}/rules_bk/"); + exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir}/rules_bk rules/"); + exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$snortdir} etc/" . + " so_rules/precompiled/FreeBSD-7.0/i386/2.8.5.1/" . + " so_rules/bad-traffic.rules/" . + " so_rules/chat.rules/" . + " so_rules/dos.rules/" . + " so_rules/exploit.rules/" . + " so_rules/imap.rules/" . + " so_rules/misc.rules/" . + " so_rules/multimedia.rules/" . + " so_rules/netbios.rules/" . + " so_rules/nntp.rules/" . + " so_rules/p2p.rules/" . + " so_rules/smtp.rules/" . + " so_rules/sql.rules/" . + " so_rules/web-client.rules/" . + " so_rules/web-misc.rules/"); + /* add prefix to all snort.org files */ + /* remove this part and make it all php with the simplst code posible */ + chdir ("/usr/local/etc/snort/rules_bk/rules"); + sleep(2); + exec('/usr/local/bin/perl /usr/local/bin/snort_rename.pl s/^/snort_/ *.rules'); + update_status(gettext("Done extracting Rules.")); + }else{ + update_status(gettext("The Download rules file missing...")); + update_output_window(gettext("Error rules extracting failed...")); + echo ' +'; +echo ""; +echo ""; +conf_mount_ro(); + exit(0); + } + } } /* Untar emergingthreats rules to tmp */ -if ($emergingthreats_url_chk == on) { -if ($emerg_md5_check_chk_ok != on) { -if (file_exists("{$tmpfname}/{$emergingthreats_filename}")) { - update_status(gettext("Extracting rules...")); - update_output_window(gettext("May take a while...")); - exec("/usr/bin/tar xzf {$tmpfname}/{$emergingthreats_filename} -C {$snortdir} rules/"); - } - } +if ($emergingthreats == "on") +{ + if ($emerg_md5_check_ok != on) + { + if (file_exists("{$tmpfname}/{$emergingthreats_filename}")) + { + update_status(gettext("Extracting rules...")); + update_output_window(gettext("May take a while...")); + exec("/usr/bin/tar xzf {$tmpfname}/{$emergingthreats_filename} -C {$snortdir} rules/"); + } + } } /* Untar Pfsense rules to tmp */ @@ -483,7 +766,7 @@ if (file_exists("{$tmpfname}/{$pfsense_rules_filename}")) { /* Untar snort signatures */ if ($snort_md5_check_ok != on) { if (file_exists("{$tmpfname}/{$snort_filename}")) { -$signature_info_chk = $config['installedpackages']['snortadvanced']['config'][0]['signatureinfo']; +$signature_info_chk = $config['installedpackages']['snortglobal']['signatureinfo']; if ($premium_url_chk == on) { update_status(gettext("Extracting Signatures...")); update_output_window(gettext("May take a while...")); @@ -493,74 +776,250 @@ if ($premium_url_chk == on) { } } -/* Make Clean Snort Directory */ -//if ($snort_md5_check_ok != on && $emerg_md5_check_chk_ok != on && $pfsense_md5_check_ok != on) { -//if (file_exists("{$snortdir}/rules")) { -// update_status(gettext("Cleaning the snort Directory...")); -// update_output_window(gettext("removing...")); -// exec("/bin/mkdir -p {$snortdir}"); -// exec("/bin/mkdir -p {$snortdir}/rules"); -// exec("/bin/mkdir -p {$snortdir}/signatures"); -// exec("/bin/rm {$snortdir}/*"); -// exec("/bin/rm {$snortdir}/rules/*"); -// exec("/bin/rm {$snortdir_wan}/*"); -// exec("/bin/rm {$snortdir_wan}/rules/*"); +/* Copy so_rules dir to snort lib dir */ +/* Disabed untill I find out why there is a segment failt coredump when using these rules on 2.8.5.3 */ +if ($snortdownload != "off") +{ + if ($snort_md5_check_ok != on) { + if (file_exists("{$snortdir}/so_rules/precompiled/FreeBSD-7.0/i386/2.8.5.1")) { + update_status(gettext("Copying so_rules...")); + update_output_window(gettext("May take a while...")); + exec("/bin/cp -f {$snortdir}/so_rules/precompiled/FreeBSD-7.0/i386/2.8.5.1/* /usr/local/lib/snort/dynamicrules/"); + exec("/bin/cp {$snortdir}/so_rules/bad-traffic.rules {$snortdir}/rules/snort_bad-traffic.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/chat.rules {$snortdir}/rules/snort_chat.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/dos.rules {$snortdir}/rules/snort_dos.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/exploit.rules {$snortdir}/rules/snort_exploit.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/imap.rules {$snortdir}/rules/snort_imap.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/misc.rules {$snortdir}/rules/snort_misc.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/multimedia.rules {$snortdir}/rules/snort_multimedia.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/netbios.rules {$snortdir}/rules/snort_netbios.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/nntp.rules {$snortdir}/rules/snort_nntp.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/p2p.rules {$snortdir}/rules/snort_p2p.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/smtp.rules {$snortdir}/rules/snort_smtp.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/sql.rules {$snortdir}/rules/snort_sql.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/web-activex.rules {$snortdir}/rules/snort_web-activex.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/web-client.rules {$snortdir}/rules/snort_web-client.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/web-iis.rules {$snortdir}/rules/snort_web-iis.so.rules"); + exec("/bin/cp {$snortdir}/so_rules/web.misc.rules {$snortdir}/rules/snort_web.misc.so.rules"); + exec("/bin/rm -r {$snortdir}/so_rules"); + update_status(gettext("Done copying so_rules.")); + }else{ + update_status(gettext("Directory so_rules does not exist...")); + update_output_window(gettext("Error copying so_rules...")); + echo ' +'; + echo ""; + echo ""; + conf_mount_ro(); + exit(0); + } + } +} + +/* Copy renamed snort.org rules to snort dir */ +if ($snortdownload != "off") +{ + if ($snort_md5_check_ok != on) + { + if (file_exists("{$snortdir}/rules_bk/rules/Makefile.am")) + { + update_status(gettext("Copying renamed snort.org rules to snort directory...")); + exec("/bin/cp {$snortdir}/rules_bk/rules/* {$snortdir}/rules/"); + }else{ + update_status(gettext("The renamed snort.org rules do not exist...")); + update_output_window(gettext("Error copying config...")); + echo ' +'; + echo ""; + echo ""; + conf_mount_ro(); + exit(0); + } + } +} + +/* Copy configs to snort dir */ +if ($snortdownload != "off") +{ + if ($snort_md5_check_ok != on) + { + if (file_exists("{$snortdir}/etc/Makefile.am")) { + update_status(gettext("Copying configs to snort directory...")); + exec("/bin/cp {$snortdir}/etc/* {$snortdir}"); + exec("/bin/rm -r {$snortdir}/etc"); + }else{ + update_status(gettext("The snort config does not exist...")); + update_output_window(gettext("Error copying config...")); + echo ' +'; +echo ""; +echo ""; +conf_mount_ro(); + exit(0); + } + } +} + + +/* Copy md5 sig to snort dir */ +if ($snortdownload != "off") +{ + if ($snort_md5_check_ok != on) { + if (file_exists("{$tmpfname}/$snort_filename_md5")) { + update_status(gettext("Copying md5 sig to snort directory...")); + exec("/bin/cp {$tmpfname}/$snort_filename_md5 {$snortdir}/$snort_filename_md5"); + }else{ + update_status(gettext("The md5 file does not exist...")); + update_output_window(gettext("Error copying config...")); + echo ' +'; + echo ""; + echo ""; + conf_mount_ro(); + exit(0); + } + } +} -// exec("/bin/rm /usr/local/lib/snort/dynamicrules/*"); -//} else { -// update_status(gettext("Making Snort Directory...")); -// update_output_window(gettext("should be fast...")); -// exec("/bin/mkdir -p {$snortdir}"); -// exec("/bin/mkdir -p {$snortdir}/rules"); -// exec("/bin/rm {$snortdir_wan}/*"); -// exec("/bin/rm {$snortdir_wan}/rules/*"); -// exec("/bin/rm /usr/local/lib/snort/dynamicrules/\*"); -// update_status(gettext("Done making snort direcory.")); -// } -//} +/* Copy emergingthreats md5 sig to snort dir */ +if ($emergingthreats == "on") +{ + if ($emerg_md5_check_ok != on) + { + if (file_exists("{$tmpfname}/$emergingthreats_filename_md5")) + { + update_status(gettext("Copying md5 sig to snort directory...")); + exec("/bin/cp {$tmpfname}/$emergingthreats_filename_md5 {$snortdir}/$emergingthreats_filename_md5"); + }else{ + update_status(gettext("The emergingthreats md5 file does not exist...")); + update_output_window(gettext("Error copying config...")); + echo ""; + echo ""; + conf_mount_ro(); + exit(0); + } + } +} -/* Copy so_rules dir to snort lib dir */ -if ($snort_md5_check_ok != on) { -if (file_exists("{$snortdir}/so_rules/precompiled/FreeBSD-7.0/i386/2.8.4/")) { - update_status(gettext("Copying so_rules...")); - update_output_window(gettext("May take a while...")); - exec("`/bin/cp -f {$snortdir}/so_rules/precompiled/FreeBSD-7.0/i386/2.8.4/* /usr/local/lib/snort/dynamicrules/`"); - exec("/bin/cp {$snortdir}/so_rules/bad-traffic.rules {$snortdir}/rules/bad-traffic.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/chat.rules {$snortdir}/rules/chat.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/dos.rules {$snortdir}/rules/dos.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/exploit.rules {$snortdir}/rules/exploit.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/imap.rules {$snortdir}/rules/imap.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/misc.rules {$snortdir}/rules/misc.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/multimedia.rules {$snortdir}/rules/multimedia.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/netbios.rules {$snortdir}/rules/netbios.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/nntp.rules {$snortdir}/rules/nntp.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/p2p.rules {$snortdir}/rules/p2p.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/smtp.rules {$snortdir}/rules/smtp.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/sql.rules {$snortdir}/rules/sql.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/web-client.rules {$snortdir}/rules/web-client.so.rules"); - exec("/bin/cp {$snortdir}/so_rules/web.misc.rules {$snortdir}/rules/web.misc.so.rules"); - exec("/bin/rm -r {$snortdir}/so_rules"); - update_status(gettext("Done copying so_rules.")); +/* Copy Pfsense md5 sig to snort dir */ +if ($pfsense_md5_check_ok != on) { +if (file_exists("{$tmpfname}/$pfsense_rules_filename_md5")) { + update_status(gettext("Copying Pfsense md5 sig to snort directory...")); + exec("/bin/cp {$tmpfname}/$pfsense_rules_filename_md5 {$snortdir}/$pfsense_rules_filename_md5"); } else { - update_status(gettext("Directory so_rules does not exist...")); - update_output_window(gettext("Error copying so_rules...")); - exit(0); + update_status(gettext("The Pfsense md5 file does not exist...")); + update_output_window(gettext("Error copying config...")); + echo ' +'; + echo ""; + echo ""; + conf_mount_ro(); + exit(0); } } + +/* Copy signatures dir to snort dir */ +if ($snortdownload != "off") +{ + if ($snort_md5_check_ok != on) + { + $signature_info_chk = $config['installedpackages']['snortglobal']['signatureinfo']; + if ($premium_url_chk == on) + { + if (file_exists("{$snortdir}/doc/signatures")) { + update_status(gettext("Copying signatures...")); + update_output_window(gettext("May take a while...")); + exec("/bin/mv -f {$snortdir}/doc/signatures {$snortdir}/signatures"); + exec("/bin/rm -r {$snortdir}/doc/signatures"); + update_status(gettext("Done copying signatures.")); + }else{ + update_status(gettext("Directory signatures exist...")); + update_output_window(gettext("Error copying signature...")); + echo ' +'; +echo ""; +echo ""; +conf_mount_ro(); + exit(0); + } + } + } +} + +/* double make shure cleanup emerg rules that dont belong */ +if (file_exists("/usr/local/etc/snort/rules/emerging-botcc-BLOCK.rules")) { + apc_clear_cache(); + exec("/bin/rm /usr/local/etc/snort/rules/emerging-botcc-BLOCK.rules"); + exec("/bin/rm /usr/local/etc/snort/rules/emerging-botcc.rules"); + exec("/bin/rm /usr/local/etc/snort/rules/emerging-compromised-BLOCK.rules"); + exec("/bin/rm /usr/local/etc/snort/rules/emerging-drop-BLOCK.rules"); + exec("/bin/rm /usr/local/etc/snort/rules/emerging-dshield-BLOCK.rules"); + exec("/bin/rm /usr/local/etc/snort/rules/emerging-rbn-BLOCK.rules"); + exec("/bin/rm /usr/local/etc/snort/rules/emerging-tor-BLOCK.rules"); +} + +if (file_exists("/usr/local/lib/snort/dynamicrules/lib_sfdynamic_example_rule.so")) { + exec("/bin/rm /usr/local/lib/snort/dynamicrules/lib_sfdynamic_example_rule.so"); + exec("/bin/rm /usr/local/lib/snort/dynamicrules/lib_sfdynamic_example\*"); +} + +/* make shure default rules are in the right format */ +exec("/usr/local/bin/perl -pi -e 's/#alert/# alert/g' /usr/local/etc/snort/rules/*.rules"); +exec("/usr/local/bin/perl -pi -e 's/##alert/# alert/g' /usr/local/etc/snort/rules/*.rules"); +exec("/usr/local/bin/perl -pi -e 's/## alert/# alert/g' /usr/local/etc/snort/rules/*.rules"); +/* create a msg-map for snort */ +update_status(gettext("Updating Alert Messages...")); +update_output_window(gettext("Please Wait...")); +exec("/usr/local/bin/perl /usr/local/bin/create-sidmap.pl /usr/local/etc/snort/rules > /usr/local/etc/snort/sid-msg.map"); + + +////////////////// + +/* open oinkmaster_conf for writing" function */ +function oinkmaster_conf($id, $if_real, $iface_uuid) +{ + + global $config, $g, $id, $if_real, $snortdir_wan, $snortdir, $snort_md5_check_ok, $emerg_md5_check_ok, $pfsense_md5_check_ok; + conf_mount_rw(); + /* enable disable setting will carry over with updates */ /* TODO carry signature changes with the updates */ -if ($snort_md5_check_ok != on || $emerg_md5_check_chk_ok != on || $pfsense_md5_check_ok != on) { +if ($snort_md5_check_ok != on || $emerg_md5_check_ok != on || $pfsense_md5_check_ok != on) { -if (!empty($config['installedpackages']['snort']['rule_sid_on'])) { -$enabled_sid_on = $config['installedpackages']['snort']['rule_sid_on']; +if (!empty($config['installedpackages']['snortglobal']['rule'][$id]['rule_sid_on'])) { +$enabled_sid_on = $config['installedpackages']['snortglobal']['rule'][$id]['rule_sid_on']; $enabled_sid_on_array = split('\|\|', $enabled_sid_on); foreach($enabled_sid_on_array as $enabled_item_on) $selected_sid_on_sections .= "$enabled_item_on\n"; } -if (!empty($config['installedpackages']['snort']['rule_sid_off'])) { -$enabled_sid_off = $config['installedpackages']['snort']['rule_sid_off']; +if (!empty($config['installedpackages']['snortglobal']['rule'][$id]['rule_sid_off'])) { +$enabled_sid_off = $config['installedpackages']['snortglobal']['rule'][$id]['rule_sid_off']; $enabled_sid_off_array = split('\|\|', $enabled_sid_off); foreach($enabled_sid_off_array as $enabled_item_off) $selected_sid_off_sections .= "$enabled_item_off\n"; @@ -578,7 +1037,7 @@ path = /bin:/usr/bin:/usr/local/bin update_files = \.rules$|\.config$|\.conf$|\.txt$|\.map$ -url = dir:///usr/local/etc/snort_bkup/rules +url = dir:///usr/local/etc/snort/rules $selected_sid_on_sections @@ -586,153 +1045,99 @@ $selected_sid_off_sections EOD; - /* open snort's threshold.conf for writing */ - $oinkmasterlist = fopen("/usr/local/etc/snort_bkup/oinkmaster.conf", "w"); + /* open snort's oinkmaster.conf for writing */ + $oinkmasterlist = fopen("/usr/local/etc/snort/snort_{$iface_uuid}_{$if_real}/oinkmaster_{$iface_uuid}_{$if_real}.conf", "w"); fwrite($oinkmasterlist, "$snort_sid_text"); - /* close snort's threshold.conf file */ + /* close snort's oinkmaster.conf file */ fclose($oinkmasterlist); + } } -/* Copy configs to snort dir */ -if ($snort_md5_check_ok != on) { -if (file_exists("{$snortdir}/etc/Makefile.am")) { - update_status(gettext("Copying configs to snort directory...")); - exec("/bin/cp {$snortdir}/etc/* {$snortdir}"); - exec("/bin/rm -r {$snortdir}/etc"); - -} else { - update_status(gettext("The snort config does not exist...")); - update_output_window(gettext("Error copying config...")); - exit(0); - } -} +/* Run oinkmaster to snort_wan and cp configs */ +/* If oinkmaster is not needed cp rules normally */ +/* TODO add per interface settings here */ +function oinkmaster_run($id, $if_real, $iface_uuid) +{ -/* Copy md5 sig to snort dir */ -if ($snort_md5_check_ok != on) { -if (file_exists("{$tmpfname}/$snort_filename_md5")) { - update_status(gettext("Copying md5 sig to snort directory...")); - exec("/bin/cp {$tmpfname}/$snort_filename_md5 {$snortdir}/$snort_filename_md5"); -} else { - update_status(gettext("The md5 file does not exist...")); - update_output_window(gettext("Error copying config...")); - exit(0); - } -} + global $config, $g, $id, $if_real, $snortdir_wan, $snortdir, $snort_md5_check_ok, $emerg_md5_check_ok, $pfsense_md5_check_ok; + conf_mount_rw(); -/* Copy emergingthreats md5 sig to snort dir */ -if ($emergingthreats_url_chk == on) { -if ($emerg_md5_check_chk_ok != on) { -if (file_exists("{$tmpfname}/$emergingthreats_filename_md5")) { - update_status(gettext("Copying md5 sig to snort directory...")); - exec("/bin/cp {$tmpfname}/$emergingthreats_filename_md5 {$snortdir}/$emergingthreats_filename_md5"); -} else { - update_status(gettext("The emergingthreats md5 file does not exist...")); - update_output_window(gettext("Error copying config...")); - exit(0); - } - } -} + if ($snort_md5_check_ok != on || $emerg_md5_check_ok != on || $pfsense_md5_check_ok != on) + { -/* Copy Pfsense md5 sig to snort dir */ -if ($pfsense_md5_check_ok != on) { -if (file_exists("{$tmpfname}/$pfsense_rules_filename_md5")) { - update_status(gettext("Copying Pfsense md5 sig to snort directory...")); - exec("/bin/cp {$tmpfname}/$pfsense_rules_filename_md5 {$snortdir}/$pfsense_rules_filename_md5"); -} else { - update_status(gettext("The Pfsense md5 file does not exist...")); - update_output_window(gettext("Error copying config...")); - exit(0); - } -} - -/* Copy signatures dir to snort dir */ -if ($snort_md5_check_ok != on) { -$signature_info_chk = $config['installedpackages']['snort']['config'][0]['signatureinfo']; -if ($premium_url_chk == on) { -if (file_exists("{$snortdir}/doc/signatures")) { - update_status(gettext("Copying signatures...")); - update_output_window(gettext("May take a while...")); - exec("/bin/mv -f {$snortdir}/doc/signatures {$snortdir}/signatures"); - exec("/bin/rm -r {$snortdir}/doc/signatures"); - update_status(gettext("Done copying signatures.")); -} else { - update_status(gettext("Directory signatures exist...")); - update_output_window(gettext("Error copying signature...")); - exit(0); - } - } -} + if ($config['installedpackages']['snortglobal']['rule'][$id]['rule_sid_on'] == '' && $config['installedpackages']['snortglobal']['rule'][$id]['rule_sid_off'] == '') + { + update_status(gettext("Your first set of rules are being copied...")); + update_output_window(gettext("May take a while...")); + exec("/bin/echo \"test {$snortdir} {$snortdir_wan} {$iface_uuid}_{$if_real}\" > /root/debug"); + exec("/bin/cp {$snortdir}/rules/* {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}/rules/"); + exec("/bin/cp {$snortdir}/classification.config {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}"); + exec("/bin/cp {$snortdir}/gen-msg.map {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}"); + exec("/bin/cp {$snortdir}/generators {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}"); + exec("/bin/cp {$snortdir}/reference.config {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}"); + exec("/bin/cp {$snortdir}/sid {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}"); + exec("/bin/cp {$snortdir}/sid-msg.map {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}"); + exec("/bin/cp {$snortdir}/unicode.map {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}"); + }else{ + update_status(gettext("Your enable and disable changes are being applied to your fresh set of rules...")); + update_output_window(gettext("May take a while...")); + exec("/bin/echo \"test2 {$snortdir} {$snortdir_wan} {$iface_uuid}_{$if_real}\" > /root/debug"); + exec("/bin/cp {$snortdir}/rules/* {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}/rules/"); + exec("/bin/cp {$snortdir}/classification.config {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}"); + exec("/bin/cp {$snortdir}/gen-msg.map {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}"); + exec("/bin/cp {$snortdir}/generators {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}"); + exec("/bin/cp {$snortdir}/reference.config {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}"); + exec("/bin/cp {$snortdir}/sid {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}"); + exec("/bin/cp {$snortdir}/sid-msg.map {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}"); + exec("/bin/cp {$snortdir}/unicode.map {$snortdir_wan}/snort_{$iface_uuid}_{$if_real}"); -/* double make shure cleanup emerg rules that dont belong */ -if (file_exists("/usr/local/etc/snort_bkup/rules/emerging-botcc-BLOCK.rules")) { - apc_clear_cache(); - exec("/bin/rm /usr/local/etc/snort_bkup/rules/emerging-botcc-BLOCK.rules"); - exec("/bin/rm /usr/local/etc/snort_bkup/rules/emerging-botcc.rules"); - exec("/bin/rm /usr/local/etc/snort_bkup/rules/emerging-compromised-BLOCK.rules"); - exec("/bin/rm /usr/local/etc/snort_bkup/rules/emerging-drop-BLOCK.rules"); - exec("/bin/rm /usr/local/etc/snort_bkup/rules/emerging-dshield-BLOCK.rules"); - exec("/bin/rm /usr/local/etc/snort_bkup/rules/emerging-rbn-BLOCK.rules"); - exec("/bin/rm /usr/local/etc/snort_bkup/rules/emerging-tor-BLOCK.rules"); + /* might have to add a sleep for 3sec for flash drives or old drives */ + exec("/usr/local/bin/perl /usr/local/bin/oinkmaster.pl -C /usr/local/etc/snort/snort_{$iface_uuid}_{$if_real}/oinkmaster_{$iface_uuid}_{$if_real}.conf -o /usr/local/etc/snort/snort_{$iface_uuid}_{$if_real}/rules > /usr/local/etc/snort/oinkmaster_{$iface_uuid}_{$if_real}.log"); + } + } } -if (file_exists("/usr/local/lib/snort/dynamicrules/lib_sfdynamic_example_rule.so")) { - exec("/bin/rm /usr/local/lib/snort/dynamicrules/lib_sfdynamic_example_rule.so"); - exec("/bin/rm /usr/local/lib/snort/dynamicrules/lib_sfdynamic_example\*"); -} +/* Start the proccess for every interface rule */ +/* TODO: try to make the code smother */ -/* create a msg-map for snort */ -update_status(gettext("Updating Alert Messages...")); -update_output_window(gettext("Please Wait...")); -exec("/usr/local/bin/perl /usr/local/bin/create-sidmap.pl /usr/local/etc/snort_bkup/rules > /usr/local/etc/snort_bkup/sid-msg.map"); +if (!empty($config['installedpackages']['snortglobal']['rule'])) +{ -/* Run oinkmaster to snort_wan and cp configs */ -/* If oinkmaster is not needed cp rules normally */ -/* TODO add per interface settings here */ -if ($snort_md5_check_ok != on || $emerg_md5_check_chk_ok != on || $pfsense_md5_check_ok != on) { + $rule_array = $config['installedpackages']['snortglobal']['rule']; + $id = -1; + foreach ($rule_array as $value) { - if (empty($config['installedpackages']['snort']['rule_sid_on']) || empty($config['installedpackages']['snort']['rule_sid_off'])) { - update_status(gettext("Your first set of rules are being copied...")); - update_output_window(gettext("May take a while...")); - exec("/bin/cp {$snortdir}/rules/* {$snortdir_wan}/rules/"); - exec("/bin/cp {$snortdir}/classification.config {$snortdir_wan}"); - exec("/bin/cp {$snortdir}/gen-msg.map {$snortdir_wan}"); - exec("/bin/cp {$snortdir}/generators {$snortdir_wan}"); - exec("/bin/cp {$snortdir}/reference.config {$snortdir_wan}"); - exec("/bin/cp {$snortdir}/sid {$snortdir_wan}"); - exec("/bin/cp {$snortdir}/sid-msg.map {$snortdir_wan}"); - exec("/bin/cp {$snortdir}/unicode.map {$snortdir_wan}"); + $id += 1; + + $result_lan = $config['installedpackages']['snortglobal']['rule'][$id]['interface']; + $if_real = convert_friendly_interface_to_real_interface_name($result_lan); + $iface_uuid = $config['installedpackages']['snortglobal']['rule'][$id]['uuid']; + + /* make oinkmaster.conf for each interface rule */ + oinkmaster_conf($id, $if_real, $iface_uuid); + + /* run oinkmaster for each interface rule */ + oinkmaster_run($id, $if_real, $iface_uuid); -} else { - update_status(gettext("Your enable and disable changes are being applied to your fresh set of rules...")); - update_output_window(gettext("May take a while...")); - exec("/bin/cp {$snortdir}/rules/* {$snortdir_wan}/rules/"); - exec("/bin/cp {$snortdir}/classification.config {$snortdir_wan}"); - exec("/bin/cp {$snortdir}/gen-msg.map {$snortdir_wan}"); - exec("/bin/cp {$snortdir}/generators {$snortdir_wan}"); - exec("/bin/cp {$snortdir}/reference.config {$snortdir_wan}"); - exec("/bin/cp {$snortdir}/sid {$snortdir_wan}"); - exec("/bin/cp {$snortdir}/sid-msg.map {$snortdir_wan}"); - exec("/bin/cp {$snortdir}/unicode.map {$snortdir_wan}"); - - /* oinkmaster.pl will convert saved changes for the new updates then we have to change #alert to # alert for the gui */ - /* might have to add a sleep for 3sec for flash drives or old drives */ - exec("/usr/local/bin/perl /usr/local/bin/oinkmaster.pl -C /usr/local/etc/snort_bkup/oinkmaster.conf -o /usr/local/etc/snort/rules > /usr/local/etc/snort_bkup/oinkmaster.log"); - exec("/usr/local/bin/perl -pi -e 's/#alert/# alert/g' /usr/local/etc/snort/rules/*.rules"); - exec("/usr/local/bin/perl -pi -e 's/##alert/# alert/g' /usr/local/etc/snort/rules/*.rules"); - exec("/usr/local/bin/perl -pi -e 's/## alert/# alert/g' /usr/local/etc/snort/rules/*.rules"); - - } } +////////////// + +/* mark the time update finnished */ +$config['installedpackages']['snortglobal']['last_rules_install'] = date("Y-M-jS-h:i-A"); + /* remove old $tmpfname files */ -if (file_exists("{$tmpfname}")) { - update_status(gettext("Cleaning up...")); - exec("/bin/rm -r /root/snort_rules_up"); -// apc_clear_cache(); +if (file_exists("{$tmpfname}")) +{ + update_status(gettext("Cleaning up...")); + exec("/bin/rm -r /tmp/snort_rules_up"); + sleep(2); + exec("/bin/rm -r {$snortdir}/rules_bk/rules/"); + apc_clear_cache(); } /* php code to flush out cache some people are reportting missing files this might help */ @@ -740,9 +1145,18 @@ sleep(2); apc_clear_cache(); exec("/bin/sync ;/bin/sync ;/bin/sync ;/bin/sync ;/bin/sync ;/bin/sync ;/bin/sync ;/bin/sync"); +/* make all dirs snorts */ +exec("/usr/sbin/chown -R snort:snort /var/log/snort"); +exec("/usr/sbin/chown -R snort:snort /usr/local/etc/snort"); +exec("/usr/sbin/chown -R snort:snort /usr/local/lib/snort"); +exec("/bin/chmod -R 755 /var/log/snort"); +exec("/bin/chmod -R 755 /usr/local/etc/snort"); +exec("/bin/chmod -R 755 /usr/local/lib/snort"); + + /* if snort is running hardrestart, if snort is not running do nothing */ if (file_exists("/tmp/snort_download_halt.pid")) { - start_service("snort"); + exec("/bin/sh /usr/local/etc/rc.d/snort.sh start"); update_status(gettext("The Rules update finished...")); update_output_window(gettext("Snort has restarted with your new set of rules...")); exec("/bin/rm /tmp/snort_download_halt.pid"); @@ -751,6 +1165,13 @@ if (file_exists("/tmp/snort_download_halt.pid")) { update_output_window(gettext("You may start snort now...")); } +echo ' +'; + /* hide progress bar and lets end this party */ hide_progress_bar_status(); conf_mount_ro(); diff --git a/config/snort/snort_dynamic_ip_reload.php b/config/snort/snort_dynamic_ip_reload.php index 0fad085b..98d9bcce 100644 --- a/config/snort/snort_dynamic_ip_reload.php +++ b/config/snort/snort_dynamic_ip_reload.php @@ -3,7 +3,7 @@ /* $Id$ */ /* snort_dynamic_ip_reload.php - Copyright (C) 2006 Scott Ullrich and Robert Zeleya + Copyright (C) 2009 Robert Zeleya All rights reserved. Redistribution and use in source and binary forms, with or without @@ -31,19 +31,20 @@ /* NOTE: this file gets included from the pfSense filter.inc plugin process */ /* NOTE: file location /usr/local/pkg/pf, all files in pf dir get exec on filter reloads */ -require_once("/usr/local/pkg/snort.inc"); -require_once("service-utils.inc"); -require_once("config.inc"); +require_once("/usr/local/pkg/snort/snort.inc"); +/* get the varibles from the command line */ +/* Note: snort.sh sould only be using this */ +//$id = $_SERVER["argv"][1]; +//$if_real = $_SERVER["argv"][2]; -if($config['interfaces']['wan']['ipaddr'] == "pppoe" or - $config['interfaces']['wan']['ipaddr'] == "dhcp") { - create_snort_conf(); - exec("killall -HUP snort"); - /* define snortbarnyardlog_chk */ - $snortbarnyardlog_info_chk = $config['installedpackages']['snortadvanced']['config'][0]['snortbarnyardlog']; - if ($snortbarnyardlog_info_chk == on) - exec("killall -HUP barnyard2"); -} +//$test_iface = $config['installedpackages']['snortglobal']['rule'][$id]['interface']; + +//if ($id == "" || $if_real == "" || $test_iface == "") { +// exec("/usr/bin/logger -p daemon.info -i -t SnortDynIP \"ERORR starting snort_dynamic_ip_reload.php\""); +// exit; +// } + +sync_snort_package_empty(); ?> \ No newline at end of file diff --git a/config/snort/snort_fbegin.inc b/config/snort/snort_fbegin.inc new file mode 100644 index 00000000..b8faff09 --- /dev/null +++ b/config/snort/snort_fbegin.inc @@ -0,0 +1,288 @@ + "") { + foreach($config['installedpackages']['menu'] as $menuitem) { + if($menuitem['section'] != $section) continue; + if($menuitem['url'] <> "") { + $addresswithport = getenv("HTTP_HOST"); + $colonpos = strpos($addresswithport, ":"); + if ($colonpos !== False){ + //my url is actually just the IP address of the pfsense box + $myurl = substr($addresswithport, 0, $colonpos); + } + else + { + $myurl = $addresswithport; + } + + $description = str_replace('$myurl', $myurl, $menuitem['url']); + } else { + $description = '/pkg.php?xml=' . $menuitem['configfile']; + } + $htmltext .= '
  • ' . $menuitem['name'] . '
  • ' . "\n"; + } + } + return $htmltext; + } + + + + + /* NOTICE ACKNOWLEDGE CODE by Erik Kristensen */ + if ($_REQUEST['noticeaction'] == 'acknowledge') { + $notice_id = $_REQUEST['noticeid']; + close_notice($notice_id); + } + /**********************************************/ +?> + +
    + + +
    +
    + + +
    + + +
    + + + + + + diff --git a/config/snort/snort_interfaces.php b/config/snort/snort_interfaces.php new file mode 100644 index 00000000..cb51df44 --- /dev/null +++ b/config/snort/snort_interfaces.php @@ -0,0 +1,584 @@ +. + Copyright (C) 2008-2009 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_gui.inc"); +require_once("/usr/local/pkg/snort/snort.inc"); + + +$id = $_GET['id']; +if (isset($_POST['id'])) + $id = $_POST['id']; + + +if (!is_array($config['installedpackages']['snortglobal']['rule'])) + $config['installedpackages']['snortglobal']['rule'] = array(); + +$a_nat = &$config['installedpackages']['snortglobal']['rule']; + +if (isset($config['installedpackages']['snortglobal']['rule'])) { +$id_gen = count($config['installedpackages']['snortglobal']['rule']); +}else{ +$id_gen = '0'; +} + + +/* alert file */ +$d_snortconfdirty_path_ls = exec('/bin/ls /var/run/snort_conf_*.dirty'); + + /* this will exec when alert says apply */ + if ($_POST['apply']) { + + if ($d_snortconfdirty_path_ls != '') { + + write_config(); + + sync_snort_package_empty(); + sync_snort_package(); + + exec('/bin/rm /var/run/snort_conf_*.dirty'); + + 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' ); + header( 'Cache-Control: post-check=0, pre-check=0', false ); + header( 'Pragma: no-cache' ); + sleep(2); + header("Location: /snort/snort_interfaces.php"); + + exit; + + } + + } + + + +if (isset($_POST['del_x'])) { + /* delete selected rules */ + if (is_array($_POST['rule']) && count($_POST['rule'])) { + foreach ($_POST['rule'] as $rulei) { + + /* convert fake interfaces to real */ + $if_real = convert_friendly_interface_to_real_interface_name($a_nat[$rulei]['interface']); + $snort_uuid = $a_nat[$rulei]['uuid']; + + /* cool code to check if any snort is up */ + $snort_up_ck = exec("/bin/ps -auwx | /usr/bin/grep -v grep | /usr/bin/grep snort | /usr/bin/awk '{print \$2;}' | sed 1q"); + + if ($snort_up_ck != "") + { + + $start_up_pre = exec("/usr/bin/top -a -U snort -u | grep -v grep | grep \"R {$snort_uuid}_{$if_real}\" | awk '{print \$1;}'"); + $start_up_s = exec("/usr/bin/top -U snort -u | grep snort | grep {$start_up_pre} | awk '{ print $1; }'"); + $start_up_r = exec("/usr/bin/top -U root -u | grep snort | grep {$start_up_pre} | awk '{ print $1; }'"); + + $start2_upb_pre = exec("/bin/cat /var/run/barnyard2_{$snort_uuid}_{$if_real}.pid"); + $start2_upb_s = exec("/usr/bin/top -U snort -u | grep barnyard2 | grep {$start2_upb_pre} | awk '{ print $1; }'"); + $start2_upb_r = exec("/usr/bin/top -U root -u | grep barnyard2 | grep {$start2_upb_pre} | awk '{ print $1; }'"); + + + if ($start_up_s != "" || $start_up_r != "" || $start2_upb_s != "" || $start2_upb_r != "") + { + + /* dont flood the syslog code */ + //exec("/bin/cp /var/log/system.log /var/log/system.log.bk"); + //sleep(3); + + + /* remove only running instances */ + if ($start_up_s != "") + { + exec("/bin/kill {$start_up_s}"); + exec("/bin/rm /var/run/snort_{$snort_uuid}_{$if_real}*"); + } + + if ($start2_upb_s != "") + { + exec("/bin/kill {$start2_upb_s}"); + exec("/bin/rm /var/run/barnyard2_{$snort_uuid}_{$if_real}*"); + } + + if ($start_up_r != "") + { + exec("/bin/kill {$start_up_r}"); + exec("/bin/rm /var/run/snort_{$snort_uuid}_{$if_real}*"); + } + + if ($start2_upb_r != "") + { + exec("/bin/kill {$start2_upb_r}"); + exec("/bin/rm /var/run/barnyard2_{$snort_uuid}_{$if_real}*"); + } + + /* stop syslog flood code */ + //$if_real_wan_rulei = $a_nat[$rulei]['interface']; + //$if_real_wan_rulei2 = convert_friendly_interface_to_real_interface_name($if_real_wan_rulei); + //exec("/sbin/ifconfig $if_real_wan_rulei2 -promisc"); + //exec("/bin/cp /var/log/system.log /var/log/snort/snort_sys_$rulei$if_real.log"); + //exec("/usr/bin/killall syslogd"); + //exec("/usr/sbin/clog -i -s 262144 /var/log/system.log"); + //exec("/usr/sbin/syslogd -c -ss -f /var/etc/syslog.conf"); + //sleep(2); + //exec("/bin/cp /var/log/system.log.bk /var/log/system.log"); + //$after_mem = exec("/usr/bin/top | /usr/bin/grep Wired | /usr/bin/awk '{ print $2 }'"); + //exec("/usr/bin/logger -p daemon.info -i -t SnortStartup 'MEM after {$rulei}{$if_real} STOP {$after_mem}'"); + //exec("/usr/bin/logger -p daemon.info -i -t SnortStartup 'Interface Rule removed for {$rulei}{$if_real}...'"); + + } + + } + + /* for every iface do these steps */ + conf_mount_rw(); + exec("/bin/rm /var/log/snort/snort.u2_{$snort_uuid}_{$if_real}*"); + exec("/bin/rm -r /usr/local/etc/snort/snort_{$snort_uuid}_{$if_real}"); + + conf_mount_ro(); + + unset($a_nat[$rulei]); + + } + + write_config(); + + //touch("/var/run/snort_conf_delete.dirty"); + + 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' ); + header( 'Cache-Control: post-check=0, pre-check=0', false ); + header( 'Pragma: no-cache' ); + sleep(2); + header("Location: /snort/snort_interfaces.php"); + //exit; + } + +} + + +/* start/stop snort */ +if ($_GET['act'] == 'toggle' && $_GET['id'] != '') +{ + + $if_real = convert_friendly_interface_to_real_interface_name($config['installedpackages']['snortglobal']['rule'][$id]['interface']); + $snort_uuid = $config['installedpackages']['snortglobal']['rule'][$id]['uuid']; + + /* Log Iface stop */ + exec("/usr/bin/logger -p daemon.info -i -t SnortStartup 'Toggle for {$snort_uuid}_{$if_real}...'"); + + $tester2 = Running_Ck($snort_uuid, $if_real, $id); + + if ($tester2 == 'yes') { + + /* Log Iface stop */ + exec("/usr/bin/logger -p daemon.info -i -t SnortStartup '{$tester2} yn for {$snort_uuid}_{$if_real}...'"); + + Running_Stop($snort_uuid, $if_real, $id); + + 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' ); + header( 'Cache-Control: post-check=0, pre-check=0', false ); + header( 'Pragma: no-cache' ); + sleep(2); + header("Location: /snort/snort_interfaces.php"); + + }else{ + + sync_snort_package_all($id, $if_real, $snort_uuid); + sync_snort_package(); + + Running_Start($snort_uuid, $if_real, $id); + + 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' ); + header( 'Cache-Control: post-check=0, pre-check=0', false ); + header( 'Pragma: no-cache' ); + sleep(2); + header("Location: /snort/snort_interfaces.php"); + } +} + + + +$pgtitle = "Services: Snort 2.8.5.3 pkg v. 1.19"; +include("head.inc"); + +?> + + +

    + + + + + +
    + +'; + + if($savemsg) { + print_info_box_np2("{$savemsg}"); + }else{ + print_info_box_np2(' + The Snort configuration has changed for one or more interfaces.
    + You must apply the changes in order for them to take effect.
    + '); + } + } + +?> + + + + + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      IfSnortPerformanceBlockBarnyard2Description + + + + + +
    +
    + + + + + + + + + + + + + + + +   + + + + + +
    +
    + + + + +
    +
    +
    +
    + +
    + + +
    Note: +
    + This is the Snort Menu where you can see an over view of all your interface settings. +
    + Please edit the Global Settings tab before adding an interface. +

    + Click on the icon to add a interface.Click on the icon to start snort and barnyard. +
    + Click on the icon to edit a interface and settings.Click on the icon to stop snort and barnyard. +
    + Click on the icon to delete a interface and settings. +
    + + "") { + echo ""; +} +?> + +
    + + + +#footer2 +{ + position: relative; + top: -17px; + background-color: #cccccc; + background-image: none; + background-repeat: repeat; + background-attachment: scroll; + background-position: 0% 0%; + font-size: 0.8em; + text-align: center; + padding-top: 0px; + padding-right: 0px; + padding-bottom: 0px; + padding-left: 10px; + clear: both; +} + + + +
    + \"Apps\" + Snort is a registered trademark of Sourcefire, Inc, Barnyard2 is a registered trademark of securixlive.com, Orion copyright Robert Zelaya, + Emergingthreats is a registered trademark of emergingthreats.net, Mysql is a registered trademark of Mysql.com +
    \n"; +} + +if ($pfsense_stable != 'yes') { +$footer3 = " + + + +
    + Snort is a registered trademark of Sourcefire, Inc, Barnyard2 is a registered trademark of securixlive.com, Orion copyright Robert Zelaya, + Emergingthreats is a registered trademark of emergingthreats.net, Mysql is a registered trademark of Mysql.com +
    \n"; +} +?> + + + +
    +
    + + + + + +
    + + + diff --git a/config/snort/snort_interfaces_edit.php b/config/snort/snort_interfaces_edit.php new file mode 100644 index 00000000..dddca3af --- /dev/null +++ b/config/snort/snort_interfaces_edit.php @@ -0,0 +1,609 @@ +. + Copyright (C) 2008-2009 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"); +require_once("/usr/local/pkg/snort/snort_gui.inc"); + + +if (!is_array($config['installedpackages']['snortglobal']['rule'])) { + $config['installedpackages']['snortglobal']['rule'] = array(); +} +//nat_rules_sort(); +$a_nat = &$config['installedpackages']['snortglobal']['rule']; + +$id = $_GET['id']; +if (isset($_POST['id'])) + $id = $_POST['id']; + +if (isset($_GET['dup'])) { + $id = $_GET['dup']; + $after = $_GET['dup']; +} + + +/* always have a limit of (65535) numbers only or snort will not start do to id limits */ +/* TODO: When inline gets added make the uuid the port number lisstening */ +//function gen_snort_uuid($fileline) +//{ + /* return the first 5 */ + //if (preg_match("/...../", $fileline, $matches1)) + //{ + //$uuid_final = "$matches1[0]"; + //} +//return $uuid_final; +//} + +/* gen uuid for each iface !inportant */ +if ($config['installedpackages']['snortglobal']['rule'][$id]['uuid'] == '') { + //$snort_uuid = gen_snort_uuid(strrev(uniqid(true))); +$snort_uuid = 0; +while ($snort_uuid > 65535 || $snort_uuid == 0) { + $snort_uuid = mt_rand(1, 65535); + $pconfig['uuid'] = $snort_uuid; + } +} + +/* convert fake interfaces to real */ +$if_real = convert_friendly_interface_to_real_interface_name($a_nat[$id]['interface']); + +if ($config['installedpackages']['snortglobal']['rule'][$id]['uuid'] != '') { + $snort_uuid = $config['installedpackages']['snortglobal']['rule'][$id]['uuid']; +} + +if (isset($id) && $a_nat[$id]) { + + /* old options */ + $pconfig['def_ssl_ports_ignore'] = $a_nat[$id]['def_ssl_ports_ignore']; + $pconfig['flow_depth'] = $a_nat[$id]['flow_depth']; + $pconfig['perform_stat'] = $a_nat[$id]['perform_stat']; + $pconfig['http_inspect'] = $a_nat[$id]['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['dce_rpc_2'] = $a_nat[$id]['dce_rpc_2']; + $pconfig['dns_preprocessor'] = $a_nat[$id]['dns_preprocessor']; + $pconfig['def_dns_servers'] = $a_nat[$id]['def_dns_servers']; + $pconfig['def_dns_ports'] = $a_nat[$id]['def_dns_ports']; + $pconfig['def_smtp_servers'] = $a_nat[$id]['def_smtp_servers']; + $pconfig['def_smtp_ports'] = $a_nat[$id]['def_smtp_ports']; + $pconfig['def_mail_ports'] = $a_nat[$id]['def_mail_ports']; + $pconfig['def_http_servers'] = $a_nat[$id]['def_http_servers']; + $pconfig['def_www_servers'] = $a_nat[$id]['def_www_servers']; + $pconfig['def_http_ports'] = $a_nat[$id]['def_http_ports']; + $pconfig['def_sql_servers'] = $a_nat[$id]['def_sql_servers']; + $pconfig['def_oracle_ports'] = $a_nat[$id]['def_oracle_ports']; + $pconfig['def_mssql_ports'] = $a_nat[$id]['def_mssql_ports']; + $pconfig['def_telnet_servers'] = $a_nat[$id]['def_telnet_servers']; + $pconfig['def_telnet_ports'] = $a_nat[$id]['def_telnet_ports']; + $pconfig['def_snmp_servers'] = $a_nat[$id]['def_snmp_servers']; + $pconfig['def_snmp_ports'] = $a_nat[$id]['def_snmp_ports']; + $pconfig['def_ftp_servers'] = $a_nat[$id]['def_ftp_servers']; + $pconfig['def_ftp_ports'] = $a_nat[$id]['def_ftp_ports']; + $pconfig['def_ssh_servers'] = $a_nat[$id]['def_ssh_servers']; + $pconfig['def_ssh_ports'] = $a_nat[$id]['def_ssh_ports']; + $pconfig['def_pop_servers'] = $a_nat[$id]['def_pop_servers']; + $pconfig['def_pop2_ports'] = $a_nat[$id]['def_pop2_ports']; + $pconfig['def_pop3_ports'] = $a_nat[$id]['def_pop3_ports']; + $pconfig['def_imap_servers'] = $a_nat[$id]['def_imap_servers']; + $pconfig['def_imap_ports'] = $a_nat[$id]['def_imap_ports']; + $pconfig['def_sip_proxy_ip'] = $a_nat[$id]['def_sip_proxy_ip']; + $pconfig['def_sip_proxy_ports'] = $a_nat[$id]['def_sip_proxy_ports']; + $pconfig['def_auth_ports'] = $a_nat[$id]['def_auth_ports']; + $pconfig['def_finger_ports'] = $a_nat[$id]['def_finger_ports']; + $pconfig['def_irc_ports'] = $a_nat[$id]['def_irc_ports']; + $pconfig['def_nntp_ports'] = $a_nat[$id]['def_nntp_ports']; + $pconfig['def_rlogin_ports'] = $a_nat[$id]['def_rlogin_ports']; + $pconfig['def_rsh_ports'] = $a_nat[$id]['def_rsh_ports']; + $pconfig['def_ssl_ports'] = $a_nat[$id]['def_ssl_ports']; + $pconfig['barnyard_enable'] = $a_nat[$id]['barnyard_enable']; + $pconfig['barnyard_mysql'] = $a_nat[$id]['barnyard_mysql']; + $pconfig['enable'] = $a_nat[$id]['enable']; + $pconfig['uuid'] = $a_nat[$id]['uuid']; + $pconfig['interface'] = $a_nat[$id]['interface']; + $pconfig['descr'] = $a_nat[$id]['descr']; + $pconfig['performance'] = $a_nat[$id]['performance']; + $pconfig['blockoffenders7'] = $a_nat[$id]['blockoffenders7']; + $pconfig['snortalertlogtype'] = $a_nat[$id]['snortalertlogtype']; + $pconfig['alertsystemlog'] = $a_nat[$id]['alertsystemlog']; + $pconfig['tcpdumplog'] = $a_nat[$id]['tcpdumplog']; + $pconfig['snortunifiedlog'] = $a_nat[$id]['snortunifiedlog']; + $pconfig['rulesets'] = $a_nat[$id]['rulesets']; + $pconfig['rule_sid_off'] = $a_nat[$id]['rule_sid_off']; + $pconfig['rule_sid_on'] = $a_nat[$id]['rule_sid_on']; + + + if (!$pconfig['interface']) + $pconfig['interface'] = "wan"; +} else { + $pconfig['interface'] = "wan"; +} + +if (isset($_GET['dup'])) + unset($id); + +/* alert file */ +$d_snortconfdirty_path = "/var/run/snort_conf_{$snort_uuid}_{$if_real}.dirty"; + + /* this will exec when alert says apply */ + if ($_POST['apply']) { + + if (file_exists("/var/run/snort_conf_{$snort_uuid}_.dirty")) { + + write_config(); + + $if_real = convert_friendly_interface_to_real_interface_name($a_nat[$id]['interface']); + + sync_snort_package_all($id, $if_real, $snort_uuid); + sync_snort_package(); + + unlink("/var/run/snort_conf_{$snort_uuid}_.dirty"); + + } + + if (file_exists($d_snortconfdirty_path)) { + + write_config(); + + sync_snort_package_all($id, $if_real, $snort_uuid); + sync_snort_package(); + + unlink($d_snortconfdirty_path); + + } + + } + +if ($_POST["Submit"]) { + + + + // if ($config['installedpackages']['snortglobal']['rule']) { + if ($_POST['descr'] == '' && $pconfig['descr'] == '') { + $input_errors[] = "Please enter a description for your reference."; + } + + if ($id == "" && $config['installedpackages']['snortglobal']['rule'][0]['interface'] != "") { + + $rule_array = $config['installedpackages']['snortglobal']['rule']; + $id_c = -1; + foreach ($rule_array as $value) { + + $id_c += 1; + + $result_lan = $config['installedpackages']['snortglobal']['rule'][$id_c]['interface']; + $if_real = convert_friendly_interface_to_real_interface_name($result_lan); + + if ($_POST['interface'] == $result_lan) { + $input_errors[] = "Interface $result_lan is in use. Please select another interface."; + } + } + } + + /* check for overlaps */ + foreach ($a_nat as $natent) { + if (isset($id) && ($a_nat[$id]) && ($a_nat[$id] === $natent)) + continue; + if ($natent['interface'] != $_POST['interface']) + continue; + } + + /* if no errors write to conf */ + if (!$input_errors) { + $natent = array(); + + /* write to conf for 1st time or rewrite the answer */ + $natent['interface'] = $_POST['interface'] ? $_POST['interface'] : $pconfig['interface']; + /* if post write to conf or rewite the answer */ + $natent['enable'] = $_POST['enable'] ? on : off; + $natent['uuid'] = $pconfig['uuid']; + $natent['descr'] = $_POST['descr'] ? $_POST['descr'] : $pconfig['descr']; + $natent['performance'] = $_POST['performance'] ? $_POST['performance'] : $pconfig['performance']; + /* if post = on use on off or rewrite the conf */ + if ($_POST['blockoffenders7'] == "on") { $natent['blockoffenders7'] = on; }else{ $natent['blockoffenders7'] = off; } if ($_POST['enable'] == "") { $natent['blockoffenders7'] = $pconfig['blockoffenders7']; } + $natent['snortalertlogtype'] = $_POST['snortalertlogtype'] ? $_POST['snortalertlogtype'] : $pconfig['snortalertlogtype']; + if ($_POST['alertsystemlog'] == "on") { $natent['alertsystemlog'] = on; }else{ $natent['alertsystemlog'] = off; } if ($_POST['enable'] == "") { $natent['alertsystemlog'] = $pconfig['alertsystemlog']; } + if ($_POST['tcpdumplog'] == "on") { $natent['tcpdumplog'] = on; }else{ $natent['tcpdumplog'] = off; } if ($_POST['enable'] == "") { $natent['tcpdumplog'] = $pconfig['tcpdumplog']; } + if ($_POST['snortunifiedlog'] == "on") { $natent['snortunifiedlog'] = on; }else{ $natent['snortunifiedlog'] = off; } if ($_POST['enable'] == "") { $natent['snortunifiedlog'] = $pconfig['snortunifiedlog']; } + /* if optiion = 0 then the old descr way will not work */ + + /* rewrite the options that are not in post */ + /* make shure values are set befor repost or conf.xml will be broken */ + if ($pconfig['def_ssl_ports_ignore'] != "") { $natent['def_ssl_ports_ignore'] = $pconfig['def_ssl_ports_ignore']; } + if ($pconfig['flow_depth'] != "") { $natent['flow_depth'] = $pconfig['flow_depth']; } + if ($pconfig['perform_stat'] != "") { $natent['perform_stat'] = $pconfig['perform_stat']; } + if ($pconfig['http_inspect'] != "") { $natent['http_inspect'] = $pconfig['http_inspect']; } + if ($pconfig['other_preprocs'] != "") { $natent['other_preprocs'] = $pconfig['other_preprocs']; } + if ($pconfig['ftp_preprocessor'] != "") { $natent['ftp_preprocessor'] = $pconfig['ftp_preprocessor']; } + if ($pconfig['smtp_preprocessor'] != "") { $natent['smtp_preprocessor'] = $pconfig['smtp_preprocessor']; } + if ($pconfig['sf_portscan'] != "") { $natent['sf_portscan'] = $pconfig['sf_portscan']; } + if ($pconfig['dce_rpc_2'] != "") { $natent['dce_rpc_2'] = $pconfig['dce_rpc_2']; } + if ($pconfig['dns_preprocessor'] != "") { $natent['dns_preprocessor'] = $pconfig['dns_preprocessor']; } + if ($pconfig['def_dns_servers'] != "") { $natent['def_dns_servers'] = $pconfig['def_dns_servers']; } + if ($pconfig['def_dns_ports'] != "") { $natent['def_dns_ports'] = $pconfig['def_dns_ports']; } + if ($pconfig['def_smtp_servers'] != "") { $natent['def_smtp_servers'] = $pconfig['def_smtp_servers']; } + if ($pconfig['def_smtp_ports'] != "") { $natent['def_smtp_ports'] = $pconfig['def_smtp_ports']; } + if ($pconfig['def_mail_ports'] != "") { $natent['def_mail_ports'] = $pconfig['def_mail_ports']; } + if ($pconfig['def_http_servers'] != "") { $natent['def_http_servers'] = $pconfig['def_http_servers']; } + if ($pconfig['def_www_servers'] != "") { $natent['def_www_servers'] = $pconfig['def_www_servers']; } + if ($pconfig['def_http_ports'] != "") { $natent['def_http_ports'] = $pconfig['def_http_ports']; } + if ($pconfig['def_sql_servers'] != "") { $natent['def_sql_servers'] = $pconfig['def_sql_servers']; } + if ($pconfig['def_oracle_ports'] != "") { $natent['def_oracle_ports'] = $pconfig['def_oracle_ports']; } + if ($pconfig['def_mssql_ports'] != "") { $natent['def_mssql_ports'] = $pconfig['def_mssql_ports']; } + if ($pconfig['def_telnet_servers'] != "") { $natent['def_telnet_servers'] = $pconfig['def_telnet_servers']; } + if ($pconfig['def_telnet_ports'] != "") { $natent['def_telnet_ports'] = $pconfig['def_telnet_ports']; } + if ($pconfig['def_snmp_servers'] != "") { $natent['def_snmp_servers'] = $pconfig['def_snmp_servers']; } + if ($pconfig['def_snmp_ports'] != "") { $natent['def_snmp_ports'] = $pconfig['def_snmp_ports']; } + if ($pconfig['def_ftp_servers'] != "") { $natent['def_ftp_servers'] = $pconfig['def_ftp_servers']; } + if ($pconfig['def_ftp_ports'] != "") { $natent['def_ftp_ports'] = $pconfig['def_ftp_ports']; } + if ($pconfig['def_ssh_servers'] != "") { $natent['def_ssh_servers'] = $pconfig['def_ssh_servers']; } + if ($pconfig['def_ssh_ports'] != "") { $natent['def_ssh_ports'] = $pconfig['def_ssh_ports']; } + if ($pconfig['def_pop_servers'] != "") { $natent['def_pop_servers'] = $pconfig['def_pop_servers']; } + if ($pconfig['def_pop2_ports'] != "") { $natent['def_pop2_ports'] = $pconfig['def_pop2_ports']; } + if ($pconfig['def_pop3_ports'] != "") { $natent['def_pop3_ports'] = $pconfig['def_pop3_ports']; } + if ($pconfig['def_imap_servers'] != "") { $natent['def_imap_servers'] = $pconfig['def_imap_servers']; } + if ($pconfig['def_imap_ports'] != "") { $natent['def_imap_ports'] = $pconfig['def_imap_ports']; } + if ($pconfig['def_sip_proxy_ip'] != "") { $natent['def_sip_proxy_ip'] = $pconfig['def_sip_proxy_ip']; } + if ($pconfig['def_sip_proxy_ports'] != "") { $natent['def_sip_proxy_ports'] = $pconfig['def_sip_proxy_ports']; } + if ($pconfig['def_auth_ports'] != "") { $natent['def_auth_ports'] = $pconfig['def_auth_ports']; } + if ($pconfig['def_finger_ports'] != "") { $natent['def_finger_ports'] = $pconfig['def_finger_ports']; } + if ($pconfig['def_irc_ports'] != "") { $natent['def_irc_ports'] = $pconfig['def_irc_ports']; } + if ($pconfig['def_nntp_ports'] != "") { $natent['def_nntp_ports'] = $pconfig['def_nntp_ports']; } + if ($pconfig['def_rlogin_ports'] != "") { $natent['def_rlogin_ports'] = $pconfig['def_rlogin_ports']; } + if ($pconfig['def_rsh_ports'] != "") { $natent['def_rsh_ports'] = $pconfig['def_rsh_ports']; } + if ($pconfig['def_ssl_ports'] != "") { $natent['def_ssl_ports'] = $pconfig['def_ssl_ports']; } + if ($pconfig['barnyard_enable'] != "") { $natent['barnyard_enable'] = $pconfig['barnyard_enable']; } + if ($pconfig['barnyard_mysql'] != "") { $natent['barnyard_mysql'] = $pconfig['barnyard_mysql']; } + if ($pconfig['rulesets'] != "") { $natent['rulesets'] = $pconfig['rulesets']; } + if ($pconfig['rule_sid_off'] != "") { $natent['rule_sid_off'] = $pconfig['rule_sid_off']; } + if ($pconfig['rule_sid_on'] != "") { $natent['rule_sid_on'] = $pconfig['rule_sid_on']; } + + + if (isset($id) && $a_nat[$id]) + $a_nat[$id] = $natent; + else { + if (is_numeric($after)) + array_splice($a_nat, $after+1, 0, array($natent)); + else + $a_nat[] = $natent; + } + + write_config(); + + touch("$d_snortconfdirty_path"); + + 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' ); + header( 'Cache-Control: post-check=0, pre-check=0', false ); + header( 'Pragma: no-cache' ); + sleep(2); + header("Location: /snort/snort_interfaces_edit.php?id=$id"); + + exit; + } +} + + if ($_POST["Submit2"]) { + + sync_snort_package_all($id, $if_real, $snort_uuid); + sync_snort_package(); + sleep(1); + + Running_Start($snort_uuid, $if_real, $id); + + 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' ); + header( 'Cache-Control: post-check=0, pre-check=0', false ); + header( 'Pragma: no-cache' ); + sleep(2); + header("Location: /snort/snort_interfaces_edit.php?id=$id"); + } + + if ($_POST["Submit3"]) + { + + Running_Stop($snort_uuid, $if_real, $id); + + 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' ); + header( 'Cache-Control: post-check=0, pre-check=0', false ); + header( 'Pragma: no-cache' ); + sleep(2); + header("Location: /snort/snort_interfaces_edit.php?id=$id"); + + } + + /* This code needs to be below headers */ + if (isset($config['installedpackages']['snortglobal']['rule'][$id]['interface'])) + { + + $snort_up_ck2_info = Running_Ck($snort_uuid, $if_real, $id); + + if ($snort_up_ck2_info == 'no') { + $snort_up_ck = ''; + }else{ + $snort_up_ck = ''; + } + + }else{ + $snort_up_ck = ''; + } + + +$pgtitle = "Snort: Interface Edit: $id $snort_uuid $if_real"; +include("head.inc"); + +?> + + + + + +

    + + +
    " method="post" enctype="multipart/form-data" name="iform" id="iform"> + +'; + + if($savemsg) { + print_info_box_np2("{$savemsg}"); + }else{ + print_info_box_np2(' + The Snort configuration has changed and snort needs to be restarted on this interface.
    + You must apply the changes in order for them to take effect.
    + '); + } + } + +?> + + + + + +
    + +
    + + + + \n\n"; + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      + + // care with spaces + if ($pconfig['enable'] == "on") + $checked = checked; + + $onclick_enable = "onClick=\"enable_change(false)\">"; + + echo " + Enable Interface
    Interface +
    + Choose which interface this rule applies to.
    + Hint: in most cases, you'll want to use WAN here.
    Description + +
    You may enter a description here for your reference (not parsed).
    Memory Performance +
    + Lowmem and ac-bnfa are recommended for low end systems, Ac: high memory, best performance, ac-std: moderate memory,high performance, acs: small memory, moderateperformance, ac-banded: small memory,moderate performance, ac-sparsebands: small memory, high performance.
    +
    Block offenders + onClick="enable_change(false)">
    + Checking this option will automatically block hosts that generate a Snort alert.
    Send alerts to main System logs + onClick="enable_change(false)">
    + Snort will send Alerts to the Pfsense system logs.
    Log to a Tcpdump file + onClick="enable_change(false)">
    + Snort will log packets to a tcpdump-formatted file. The file then can be analyzed by an application such as Wireshark which understands pcap file formats. WARNING: File may become large.
    Log Alerts to a snort unified2 file + onClick="enable_change(false)">
    + Snort will log Alerts to a file in the UNIFIED2 format. This is a requirement for barnyard2.
    + + + + +
     Note: +
    + Please save your settings before you click start.
    +
    +
    + + + + + diff --git a/config/snort/snort_interfaces_edit_bkup.php b/config/snort/snort_interfaces_edit_bkup.php new file mode 100644 index 00000000..92bc7c5a --- /dev/null +++ b/config/snort/snort_interfaces_edit_bkup.php @@ -0,0 +1,609 @@ +. + Copyright (C) 2008-2009 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"); +require_once("/usr/local/pkg/snort/snort_gui.inc"); + + +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 (isset($_GET['dup'])) { + $id = $_GET['dup']; + $after = $_GET['dup']; +} + +/* always have a limit of (65535) numbers only or snort will not start do to id limits */ +/* TODO: When inline gets added make the uuid the port number lisstening */ +//function gen_snort_uuid($fileline) +//{ + /* return the first 5 */ + //if (preg_match("/...../", $fileline, $matches1)) + //{ + //$uuid_final = "$matches1[0]"; + //} +//return $uuid_final; +//} + +/* gen uuid for each iface !inportant */ +if ($config['installedpackages']['snortglobal']['rule'][$id]['uuid'] == '') { + //$snort_uuid = gen_snort_uuid(strrev(uniqid(true))); +$snort_uuid = 0; +while ($snort_uuid > 65535 || $snort_uuid == 0) { + $snort_uuid = mt_rand(1, 65535); + $pconfig['uuid'] = $snort_uuid; + } +} + +if ($config['installedpackages']['snortglobal']['rule'][$id]['uuid'] != '') { + $snort_uuid = $config['installedpackages']['snortglobal']['rule'][$id]['uuid']; +} + + +/* convert fake interfaces to real */ +$if_real = convert_friendly_interface_to_real_interface_name2($config['installedpackages']['snortglobal']['rule'][$id]['interface']); + + +if (isset($id) && $a_nat[$id]) { + + /* old options */ + $pconfig['def_ssl_ports_ignore'] = $a_nat[$id]['def_ssl_ports_ignore']; + $pconfig['flow_depth'] = $a_nat[$id]['flow_depth']; + $pconfig['perform_stat'] = $a_nat[$id]['perform_stat']; + $pconfig['http_inspect'] = $a_nat[$id]['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['dce_rpc_2'] = $a_nat[$id]['dce_rpc_2']; + $pconfig['dns_preprocessor'] = $a_nat[$id]['dns_preprocessor']; + $pconfig['def_dns_servers'] = $a_nat[$id]['def_dns_servers']; + $pconfig['def_dns_ports'] = $a_nat[$id]['def_dns_ports']; + $pconfig['def_smtp_servers'] = $a_nat[$id]['def_smtp_servers']; + $pconfig['def_smtp_ports'] = $a_nat[$id]['def_smtp_ports']; + $pconfig['def_mail_ports'] = $a_nat[$id]['def_mail_ports']; + $pconfig['def_http_servers'] = $a_nat[$id]['def_http_servers']; + $pconfig['def_www_servers'] = $a_nat[$id]['def_www_servers']; + $pconfig['def_http_ports'] = $a_nat[$id]['def_http_ports']; + $pconfig['def_sql_servers'] = $a_nat[$id]['def_sql_servers']; + $pconfig['def_oracle_ports'] = $a_nat[$id]['def_oracle_ports']; + $pconfig['def_mssql_ports'] = $a_nat[$id]['def_mssql_ports']; + $pconfig['def_telnet_servers'] = $a_nat[$id]['def_telnet_servers']; + $pconfig['def_telnet_ports'] = $a_nat[$id]['def_telnet_ports']; + $pconfig['def_snmp_servers'] = $a_nat[$id]['def_snmp_servers']; + $pconfig['def_snmp_ports'] = $a_nat[$id]['def_snmp_ports']; + $pconfig['def_ftp_servers'] = $a_nat[$id]['def_ftp_servers']; + $pconfig['def_ftp_ports'] = $a_nat[$id]['def_ftp_ports']; + $pconfig['def_ssh_servers'] = $a_nat[$id]['def_ssh_servers']; + $pconfig['def_ssh_ports'] = $a_nat[$id]['def_ssh_ports']; + $pconfig['def_pop_servers'] = $a_nat[$id]['def_pop_servers']; + $pconfig['def_pop2_ports'] = $a_nat[$id]['def_pop2_ports']; + $pconfig['def_pop3_ports'] = $a_nat[$id]['def_pop3_ports']; + $pconfig['def_imap_servers'] = $a_nat[$id]['def_imap_servers']; + $pconfig['def_imap_ports'] = $a_nat[$id]['def_imap_ports']; + $pconfig['def_sip_proxy_ip'] = $a_nat[$id]['def_sip_proxy_ip']; + $pconfig['def_sip_proxy_ports'] = $a_nat[$id]['def_sip_proxy_ports']; + $pconfig['def_auth_ports'] = $a_nat[$id]['def_auth_ports']; + $pconfig['def_finger_ports'] = $a_nat[$id]['def_finger_ports']; + $pconfig['def_irc_ports'] = $a_nat[$id]['def_irc_ports']; + $pconfig['def_nntp_ports'] = $a_nat[$id]['def_nntp_ports']; + $pconfig['def_rlogin_ports'] = $a_nat[$id]['def_rlogin_ports']; + $pconfig['def_rsh_ports'] = $a_nat[$id]['def_rsh_ports']; + $pconfig['def_ssl_ports'] = $a_nat[$id]['def_ssl_ports']; + $pconfig['barnyard_enable'] = $a_nat[$id]['barnyard_enable']; + $pconfig['barnyard_mysql'] = $a_nat[$id]['barnyard_mysql']; + $pconfig['enable'] = $a_nat[$id]['enable']; + $pconfig['uuid'] = $a_nat[$id]['uuid']; + $pconfig['interface'] = $a_nat[$id]['interface']; + $pconfig['descr'] = $a_nat[$id]['descr']; + $pconfig['performance'] = $a_nat[$id]['performance']; + $pconfig['blockoffenders7'] = $a_nat[$id]['blockoffenders7']; + $pconfig['snortalertlogtype'] = $a_nat[$id]['snortalertlogtype']; + $pconfig['alertsystemlog'] = $a_nat[$id]['alertsystemlog']; + $pconfig['tcpdumplog'] = $a_nat[$id]['tcpdumplog']; + $pconfig['snortunifiedlog'] = $a_nat[$id]['snortunifiedlog']; + $pconfig['rulesets'] = $a_nat[$id]['rulesets']; + $pconfig['rule_sid_off'] = $a_nat[$id]['rule_sid_off']; + $pconfig['rule_sid_on'] = $a_nat[$id]['rule_sid_on']; + + + if (!$pconfig['interface']) { + $pconfig['interface'] = "wan"; + } else { + $pconfig['interface'] = "wan"; + } +} + +if (isset($_GET['dup'])) + unset($id); + +/* alert file */ +$d_snortconfdirty_path = "/var/run/snort_conf_{$snort_uuid}_{$if_real}.dirty"; + + /* this will exec when alert says apply */ + if ($_POST['apply']) { + + if (file_exists("/var/run/snort_conf_{$snort_uuid}_.dirty")) { + + write_config(); + + sync_snort_package_empty(); + sync_snort_package(); + + unlink("/var/run/snort_conf_{$snort_uuid}_.dirty"); + + } + + if (file_exists($d_snortconfdirty_path)) { + + write_config(); + + sync_snort_package_all($id, $if_real, $snort_uuid); + sync_snort_package(); + + unlink($d_snortconfdirty_path); + + } + + } + +if ($_POST["Submit"]) { + + + + // if ($config['installedpackages']['snortglobal']['rule']) { + if ($_POST['descr'] == '' && $pconfig['descr'] == '') { + $input_errors[] = "Please enter a description for your reference."; + } + + if ($id == "" && $config['installedpackages']['snortglobal']['rule'][0]['interface'] != "") { + + $rule_array = $config['installedpackages']['snortglobal']['rule']; + $id_c = -1; + foreach ($rule_array as $value) { + + $id_c += 1; + + $result_lan = $config['installedpackages']['snortglobal']['rule'][$id_c]['interface']; + $if_real = convert_friendly_interface_to_real_interface_name2($result_lan); + + if ($_POST['interface'] == $result_lan) { + $input_errors[] = "Interface $result_lan is in use. Please select another interface."; + } + } + } + + /* check for overlaps */ + foreach ($a_nat as $natent) { + if (isset($id) && ($a_nat[$id]) && ($a_nat[$id] === $natent)) + continue; + if ($natent['interface'] != $_POST['interface']) + continue; + } + + /* if no errors write to conf */ + if (!$input_errors) { + $natent = array(); + + /* write to conf for 1st time or rewrite the answer */ + $natent['interface'] = $_POST['interface'] ? $_POST['interface'] : $pconfig['interface']; + /* if post write to conf or rewite the answer */ + $natent['enable'] = $_POST['enable'] ? on : off; + $natent['uuid'] = $pconfig['uuid']; + $natent['descr'] = $_POST['descr'] ? $_POST['descr'] : $pconfig['descr']; + $natent['performance'] = $_POST['performance'] ? $_POST['performance'] : $pconfig['performance']; + /* if post = on use on off or rewrite the conf */ + if ($_POST['blockoffenders7'] == "on") { $natent['blockoffenders7'] = on; }else{ $natent['blockoffenders7'] = off; } if ($_POST['enable'] == "") { $natent['blockoffenders7'] = $pconfig['blockoffenders7']; } + $natent['snortalertlogtype'] = $_POST['snortalertlogtype'] ? $_POST['snortalertlogtype'] : $pconfig['snortalertlogtype']; + if ($_POST['alertsystemlog'] == "on") { $natent['alertsystemlog'] = on; }else{ $natent['alertsystemlog'] = off; } if ($_POST['enable'] == "") { $natent['alertsystemlog'] = $pconfig['alertsystemlog']; } + if ($_POST['tcpdumplog'] == "on") { $natent['tcpdumplog'] = on; }else{ $natent['tcpdumplog'] = off; } if ($_POST['enable'] == "") { $natent['tcpdumplog'] = $pconfig['tcpdumplog']; } + if ($_POST['snortunifiedlog'] == "on") { $natent['snortunifiedlog'] = on; }else{ $natent['snortunifiedlog'] = off; } if ($_POST['enable'] == "") { $natent['snortunifiedlog'] = $pconfig['snortunifiedlog']; } + /* if optiion = 0 then the old descr way will not work */ + + /* rewrite the options that are not in post */ + /* make shure values are set befor repost or conf.xml will be broken */ + if ($pconfig['def_ssl_ports_ignore'] != "") { $natent['def_ssl_ports_ignore'] = $pconfig['def_ssl_ports_ignore']; } + if ($pconfig['flow_depth'] != "") { $natent['flow_depth'] = $pconfig['flow_depth']; } + if ($pconfig['perform_stat'] != "") { $natent['perform_stat'] = $pconfig['perform_stat']; } + if ($pconfig['http_inspect'] != "") { $natent['http_inspect'] = $pconfig['http_inspect']; } + if ($pconfig['other_preprocs'] != "") { $natent['other_preprocs'] = $pconfig['other_preprocs']; } + if ($pconfig['ftp_preprocessor'] != "") { $natent['ftp_preprocessor'] = $pconfig['ftp_preprocessor']; } + if ($pconfig['smtp_preprocessor'] != "") { $natent['smtp_preprocessor'] = $pconfig['smtp_preprocessor']; } + if ($pconfig['sf_portscan'] != "") { $natent['sf_portscan'] = $pconfig['sf_portscan']; } + if ($pconfig['dce_rpc_2'] != "") { $natent['dce_rpc_2'] = $pconfig['dce_rpc_2']; } + if ($pconfig['dns_preprocessor'] != "") { $natent['dns_preprocessor'] = $pconfig['dns_preprocessor']; } + if ($pconfig['def_dns_servers'] != "") { $natent['def_dns_servers'] = $pconfig['def_dns_servers']; } + if ($pconfig['def_dns_ports'] != "") { $natent['def_dns_ports'] = $pconfig['def_dns_ports']; } + if ($pconfig['def_smtp_servers'] != "") { $natent['def_smtp_servers'] = $pconfig['def_smtp_servers']; } + if ($pconfig['def_smtp_ports'] != "") { $natent['def_smtp_ports'] = $pconfig['def_smtp_ports']; } + if ($pconfig['def_mail_ports'] != "") { $natent['def_mail_ports'] = $pconfig['def_mail_ports']; } + if ($pconfig['def_http_servers'] != "") { $natent['def_http_servers'] = $pconfig['def_http_servers']; } + if ($pconfig['def_www_servers'] != "") { $natent['def_www_servers'] = $pconfig['def_www_servers']; } + if ($pconfig['def_http_ports'] != "") { $natent['def_http_ports'] = $pconfig['def_http_ports']; } + if ($pconfig['def_sql_servers'] != "") { $natent['def_sql_servers'] = $pconfig['def_sql_servers']; } + if ($pconfig['def_oracle_ports'] != "") { $natent['def_oracle_ports'] = $pconfig['def_oracle_ports']; } + if ($pconfig['def_mssql_ports'] != "") { $natent['def_mssql_ports'] = $pconfig['def_mssql_ports']; } + if ($pconfig['def_telnet_servers'] != "") { $natent['def_telnet_servers'] = $pconfig['def_telnet_servers']; } + if ($pconfig['def_telnet_ports'] != "") { $natent['def_telnet_ports'] = $pconfig['def_telnet_ports']; } + if ($pconfig['def_snmp_servers'] != "") { $natent['def_snmp_servers'] = $pconfig['def_snmp_servers']; } + if ($pconfig['def_snmp_ports'] != "") { $natent['def_snmp_ports'] = $pconfig['def_snmp_ports']; } + if ($pconfig['def_ftp_servers'] != "") { $natent['def_ftp_servers'] = $pconfig['def_ftp_servers']; } + if ($pconfig['def_ftp_ports'] != "") { $natent['def_ftp_ports'] = $pconfig['def_ftp_ports']; } + if ($pconfig['def_ssh_servers'] != "") { $natent['def_ssh_servers'] = $pconfig['def_ssh_servers']; } + if ($pconfig['def_ssh_ports'] != "") { $natent['def_ssh_ports'] = $pconfig['def_ssh_ports']; } + if ($pconfig['def_pop_servers'] != "") { $natent['def_pop_servers'] = $pconfig['def_pop_servers']; } + if ($pconfig['def_pop2_ports'] != "") { $natent['def_pop2_ports'] = $pconfig['def_pop2_ports']; } + if ($pconfig['def_pop3_ports'] != "") { $natent['def_pop3_ports'] = $pconfig['def_pop3_ports']; } + if ($pconfig['def_imap_servers'] != "") { $natent['def_imap_servers'] = $pconfig['def_imap_servers']; } + if ($pconfig['def_imap_ports'] != "") { $natent['def_imap_ports'] = $pconfig['def_imap_ports']; } + if ($pconfig['def_sip_proxy_ip'] != "") { $natent['def_sip_proxy_ip'] = $pconfig['def_sip_proxy_ip']; } + if ($pconfig['def_sip_proxy_ports'] != "") { $natent['def_sip_proxy_ports'] = $pconfig['def_sip_proxy_ports']; } + if ($pconfig['def_auth_ports'] != "") { $natent['def_auth_ports'] = $pconfig['def_auth_ports']; } + if ($pconfig['def_finger_ports'] != "") { $natent['def_finger_ports'] = $pconfig['def_finger_ports']; } + if ($pconfig['def_irc_ports'] != "") { $natent['def_irc_ports'] = $pconfig['def_irc_ports']; } + if ($pconfig['def_nntp_ports'] != "") { $natent['def_nntp_ports'] = $pconfig['def_nntp_ports']; } + if ($pconfig['def_rlogin_ports'] != "") { $natent['def_rlogin_ports'] = $pconfig['def_rlogin_ports']; } + if ($pconfig['def_rsh_ports'] != "") { $natent['def_rsh_ports'] = $pconfig['def_rsh_ports']; } + if ($pconfig['def_ssl_ports'] != "") { $natent['def_ssl_ports'] = $pconfig['def_ssl_ports']; } + if ($pconfig['barnyard_enable'] != "") { $natent['barnyard_enable'] = $pconfig['barnyard_enable']; } + if ($pconfig['barnyard_mysql'] != "") { $natent['barnyard_mysql'] = $pconfig['barnyard_mysql']; } + if ($pconfig['rulesets'] != "") { $natent['rulesets'] = $pconfig['rulesets']; } + if ($pconfig['rule_sid_off'] != "") { $natent['rule_sid_off'] = $pconfig['rule_sid_off']; } + if ($pconfig['rule_sid_on'] != "") { $natent['rule_sid_on'] = $pconfig['rule_sid_on']; } + + + if (isset($id) && $a_nat[$id]) + $a_nat[$id] = $natent; + else { + if (is_numeric($after)) + array_splice($a_nat, $after+1, 0, array($natent)); + else + $a_nat[] = $natent; + } + + write_config(); + + touch("$d_snortconfdirty_path"); + + 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' ); + header( 'Cache-Control: post-check=0, pre-check=0', false ); + header( 'Pragma: no-cache' ); + sleep(2); + header("Location: /snort/snort_interfaces_edit.php?id=$id"); + + //exit; + } +} + + if ($_POST["Submit2"]) { + + sync_snort_package_all($id, $if_real, $snort_uuid); + sync_snort_package(); + sleep(1); + + Running_Start($snort_uuid, $if_real, $id); + + 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' ); + header( 'Cache-Control: post-check=0, pre-check=0', false ); + header( 'Pragma: no-cache' ); + sleep(2); + header("Location: /snort/snort_interfaces_edit.php?id=$id"); + } + + if ($_POST["Submit3"]) + { + + Running_Stop($snort_uuid, $if_real, $id); + + 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' ); + header( 'Cache-Control: post-check=0, pre-check=0', false ); + header( 'Pragma: no-cache' ); + sleep(2); + header("Location: /snort/snort_interfaces_edit.php?id=$id"); + + } + + /* This code needs to be below headers */ + if (isset($config['installedpackages']['snortglobal']['rule'][$id]['interface'])) + { + + $snort_up_ck2_info = Running_Ck($snort_uuid, $if_real, $id); + + if ($snort_up_ck2_info == 'no') { + $snort_up_ck = ''; + }else{ + $snort_up_ck = ''; + } + + }else{ + $snort_up_ck = ''; + } + + +$pgtitle = "Snort: Interface Edit: $id $snort_uuid $if_real"; +include("head.inc"); + +?> + + + + + +

    + + +
    " method="post" enctype="multipart/form-data" name="iform" id="iform"> + +'; + + if($savemsg) { + print_info_box_np2("{$savemsg}"); + }else{ + print_info_box_np2(' + The Snort configuration has changed and snort needs to be restarted on this interface.
    + You must apply the changes in order for them to take effect.
    + '); + } + } + +?> + + + + + +
    + +
    + + + + \n\n"; + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      + + // care with spaces + if ($pconfig['enable'] == "on") + $checked = checked; + + $onclick_enable = "onClick=\"enable_change(false)\">"; + + echo " + Enable Interface
    Interface +
    + Choose which interface this rule applies to.
    + Hint: in most cases, you'll want to use WAN here.
    Description + +
    You may enter a description here for your reference (not parsed).
    Memory Performance +
    + Lowmem and ac-bnfa are recommended for low end systems, Ac: high memory, best performance, ac-std: moderate memory,high performance, acs: small memory, moderateperformance, ac-banded: small memory,moderate performance, ac-sparsebands: small memory, high performance.
    +
    Block offenders + onClick="enable_change(false)">
    + Checking this option will automatically block hosts that generate a Snort alert.
    Send alerts to main System logs + onClick="enable_change(false)">
    + Snort will send Alerts to the Pfsense system logs.
    Log to a Tcpdump file + onClick="enable_change(false)">
    + Snort will log packets to a tcpdump-formatted file. The file then can be analyzed by an application such as Wireshark which understands pcap file formats. WARNING: File may become large.
    Log Alerts to a snort unified2 file + onClick="enable_change(false)">
    + Snort will log Alerts to a file in the UNIFIED2 format. This is a requirement for barnyard2.
    + + + + +
     Note: +
    + Please save your settings before you click start.
    +
    +
    + + + + + diff --git a/config/snort/snort_interfaces_global.php b/config/snort/snort_interfaces_global.php new file mode 100644 index 00000000..ff3620a3 --- /dev/null +++ b/config/snort/snort_interfaces_global.php @@ -0,0 +1,380 @@ +. + All rights reserved. + + Copyright (C) 2008-2009 Robert Zelaya + Modified for the Pfsense snort package. + 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. +*/ + +$pgtitle = "Services: Snort: Global Settings"; +require_once("guiconfig.inc"); +require_once("/usr/local/pkg/snort/snort.inc"); + +/* make things short */ +$pconfig['snortdownload'] = $config['installedpackages']['snortglobal']['snortdownload']; +$pconfig['oinkmastercode'] = $config['installedpackages']['snortglobal']['oinkmastercode']; +$pconfig['emergingthreats'] = $config['installedpackages']['snortglobal']['emergingthreats']; +$pconfig['rm_blocked'] = $config['installedpackages']['snortglobal']['rm_blocked']; +$pconfig['autorulesupdate7'] = $config['installedpackages']['snortglobal']['autorulesupdate7']; +$pconfig['whitelistvpns'] = $config['installedpackages']['snortglobal']['whitelistvpns']; +$pconfig['clickablalerteurls'] = $config['installedpackages']['snortglobal']['clickablalerteurls']; +$pconfig['associatealertip'] = $config['installedpackages']['snortglobal']['associatealertip']; +$pconfig['snortalertlogtype'] = $config['installedpackages']['snortglobal']['snortalertlogtype']; + + +if ($_POST) { + + unset($input_errors); + $pconfig = $_POST; + + /* input validation */ + if ($_POST['enable']) + { + +/* TODO:a dd check user input code. */ + + } + + if (!$input_errors) { + + if ($_POST["Submit"]) { + + $config['installedpackages']['snortglobal']['snortdownload'] = $_POST['snortdownload']; + $config['installedpackages']['snortglobal']['oinkmastercode'] = $_POST['oinkmastercode']; + $config['installedpackages']['snortglobal']['emergingthreats'] = $_POST['emergingthreats'] ? on : off; + $config['installedpackages']['snortglobal']['rm_blocked'] = $_POST['rm_blocked']; + $config['installedpackages']['snortglobal']['autorulesupdate7'] = $_POST['autorulesupdate7']; + $config['installedpackages']['snortglobal']['whitelistvpns'] = $_POST['whitelistvpns'] ? on : off; + $config['installedpackages']['snortglobal']['clickablalerteurls'] = $_POST['clickablalerteurls'] ? on : off; + $config['installedpackages']['snortglobal']['associatealertip'] = $_POST['associatealertip'] ? on : off; + $config['installedpackages']['snortglobal']['snortalertlogtype'] = $_POST['snortalertlogtype']; + + write_config(); + sleep(2); + + $retval = 0; + + /* set the snort block hosts time IMPORTANT */ + $snort_rm_blocked_info_ck = $config['installedpackages']['snortglobal']['rm_blocked']; + if ($snort_rm_blocked_info_ck == "never_b") + $snort_rm_blocked_false = ""; + else + $snort_rm_blocked_false = "true"; + + if ($snort_rm_blocked_info_ck != "") + { + snort_rm_blocked_install_cron(""); + snort_rm_blocked_install_cron($snort_rm_blocked_false); + } + + /* set the snort rules update time */ + $snort_rules_up_info_ck = $config['installedpackages']['snortglobal']['autorulesupdate7']; + if ($snort_rules_up_info_ck == "never_up") + $snort_rules_up_false = ""; + else + $snort_rules_up_false = "true"; + + if ($snort_rules_up_info_ck != "") + { + snort_rules_up_install_cron(""); + snort_rules_up_install_cron($snort_rules_up_false); + } + + + + $savemsg = get_std_save_message($retval); + + } + + sync_snort_package_all(); + sync_snort_package(); + +} + + + if ($_POST["Reset"]) { + +//////>>>>>>>>> + + function snort_deinstall_settings() +{ + + global $config, $g, $id, $if_real; + conf_mount_rw(); + + + exec("/usr/usr/bin/killall snort"); + sleep(2); + exec("/usr/usr/bin/killall -9 snort"); + sleep(2); + exec("/usr/usr/bin/killall barnyard2"); + sleep(2); + exec("/usr/usr/bin/killall -9 barnyard2"); + sleep(2); + + /* Remove snort cron entries Ugly code needs smoothness*/ +function snort_rm_blocked_deinstall_cron($should_install) +{ + global $config, $g; + conf_mount_rw(); + + $is_installed = false; + + if(!$config['cron']['item']) + return; + + $x=0; + foreach($config['cron']['item'] as $item) + { + if (strstr($item['command'], "snort2c")) + { + $is_installed = true; + break; + } + + $x++; + + } + if($is_installed == true) + { + if($x > 0) + { + unset($config['cron']['item'][$x]); + write_config(); + conf_mount_rw(); + } + + configure_cron(); + + } + conf_mount_ro(); + +} + + function snort_rules_up_deinstall_cron($should_install) +{ + global $config, $g; + conf_mount_rw(); + + $is_installed = false; + + if(!$config['cron']['item']) + return; + + $x=0; + foreach($config['cron']['item'] as $item) { + if (strstr($item['command'], "snort_check_for_rule_updates.php")) { + $is_installed = true; + break; + } + $x++; + } + if($is_installed == true) { + if($x > 0) { + unset($config['cron']['item'][$x]); + write_config(); + conf_mount_rw(); + } + configure_cron(); + } +} + +snort_rm_blocked_deinstall_cron(""); +snort_rules_up_deinstall_cron(""); + + + /* Unset snort registers in conf.xml IMPORTANT snort will not start with out this */ + /* Keep this as a last step */ + unset($config['installedpackages']['snortglobal']); + write_config(); + conf_mount_rw(); + + /* remove all snort iface dir */ + exec('rm -r /usr/local/etc/snort/snort_*'); + exec('rm /var/log/snort/*'); + + conf_mount_ro(); + +} + + snort_deinstall_settings(); + + 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' ); + header( 'Cache-Control: post-check=0, pre-check=0', false ); + header( 'Pragma: no-cache' ); + sleep(2); + header("Location: /snort/snort_interfaces_global.php"); + + exit; + +//////>>>>>>>>> + } +} + +include("head.inc"); +?> + +

    + + + + +
    + + + + + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Install Snort.org rules + + + + + + + + + + + + + + +
    > + Do NOT install
    > + Premium rules HIGHLY RECOMMENDED
    > + Basic Rules
      
    + + + + + + + +
    Oinkmaster code
    Code
    + Obtain a snort.org Oinkmaster code and paste here.
    +
    Install Emergingthreats rules + onClick="enable_change(false)">
    + Emerging Threats is an open source community that produces fastest moving and diverse Snort Rules.
    Remove blocked hosts every +
    + Please select the amount of time you would like hosts to be blocked for.
    + Hint: in most cases, 1 hour is a good choice.
    Update rules automatically +
    + Please select the update times for rules.
    + Hint: in most cases, every 12 hours is a good choice.
    Whitelist VPNs automatically + onClick="enable_change(false)">
    + Checking this option will install whitelists for all VPNs.
    Alerts file description type +
    + Please choose the type of Alert logging you will like see in your alert file.
    + Hint: Best pratice is to chose full logging.
     WARNING: On change, alert file will be cleared.
     WARNING:
    + This will reset all global and interface settings.
    +
    + +
     Note:
    + 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.
    +
    +
    + + + + diff --git a/config/snort/snort_preprocessors.php b/config/snort/snort_preprocessors.php new file mode 100644 index 00000000..25963cbe --- /dev/null +++ b/config/snort/snort_preprocessors.php @@ -0,0 +1,438 @@ +. + Copyright (C) 2008-2009 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"); +require_once("/usr/local/pkg/snort/snort_gui.inc"); + +if (!is_array($config['installedpackages']['snortglobal']['rule'])) { + $config['installedpackages']['snortglobal']['rule'] = array(); +} +//nat_rules_sort(); +$a_nat = &$config['installedpackages']['snortglobal']['rule']; + +$id = $_GET['id']; +if (isset($_POST['id'])) + $id = $_POST['id']; + +if (isset($_GET['dup'])) { + $id = $_GET['dup']; + $after = $_GET['dup']; +} + +if (isset($id) && $a_nat[$id]) { + + /* new options */ + $pconfig['def_ssl_ports_ignore'] = $a_nat[$id]['def_ssl_ports_ignore']; + $pconfig['flow_depth'] = $a_nat[$id]['flow_depth']; + $pconfig['perform_stat'] = $a_nat[$id]['perform_stat']; + $pconfig['http_inspect'] = $a_nat[$id]['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['dce_rpc_2'] = $a_nat[$id]['dce_rpc_2']; + $pconfig['dns_preprocessor'] = $a_nat[$id]['dns_preprocessor']; + + /* old options */ + $pconfig['def_dns_servers'] = $a_nat[$id]['def_dns_servers']; + $pconfig['def_dns_ports'] = $a_nat[$id]['def_dns_ports']; + $pconfig['def_smtp_servers'] = $a_nat[$id]['def_smtp_servers']; + $pconfig['def_smtp_ports'] = $a_nat[$id]['def_smtp_ports']; + $pconfig['def_mail_ports'] = $a_nat[$id]['def_mail_ports']; + $pconfig['def_http_servers'] = $a_nat[$id]['def_http_servers']; + $pconfig['def_www_servers'] = $a_nat[$id]['def_www_servers']; + $pconfig['def_http_ports'] = $a_nat[$id]['def_http_ports']; + $pconfig['def_sql_servers'] = $a_nat[$id]['def_sql_servers']; + $pconfig['def_oracle_ports'] = $a_nat[$id]['def_oracle_ports']; + $pconfig['def_mssql_ports'] = $a_nat[$id]['def_mssql_ports']; + $pconfig['def_telnet_servers'] = $a_nat[$id]['def_telnet_servers']; + $pconfig['def_telnet_ports'] = $a_nat[$id]['def_telnet_ports']; + $pconfig['def_snmp_servers'] = $a_nat[$id]['def_snmp_servers']; + $pconfig['def_snmp_ports'] = $a_nat[$id]['def_snmp_ports']; + $pconfig['def_ftp_servers'] = $a_nat[$id]['def_ftp_servers']; + $pconfig['def_ftp_ports'] = $a_nat[$id]['def_ftp_ports']; + $pconfig['def_ssh_servers'] = $a_nat[$id]['def_ssh_servers']; + $pconfig['def_ssh_ports'] = $a_nat[$id]['def_ssh_ports']; + $pconfig['def_pop_servers'] = $a_nat[$id]['def_pop_servers']; + $pconfig['def_pop2_ports'] = $a_nat[$id]['def_pop2_ports']; + $pconfig['def_pop3_ports'] = $a_nat[$id]['def_pop3_ports']; + $pconfig['def_imap_servers'] = $a_nat[$id]['def_imap_servers']; + $pconfig['def_imap_ports'] = $a_nat[$id]['def_imap_ports']; + $pconfig['def_sip_proxy_ip'] = $a_nat[$id]['def_sip_proxy_ip']; + $pconfig['def_sip_proxy_ports'] = $a_nat[$id]['def_sip_proxy_ports']; + $pconfig['def_auth_ports'] = $a_nat[$id]['def_auth_ports']; + $pconfig['def_finger_ports'] = $a_nat[$id]['def_finger_ports']; + $pconfig['def_irc_ports'] = $a_nat[$id]['def_irc_ports']; + $pconfig['def_nntp_ports'] = $a_nat[$id]['def_nntp_ports']; + $pconfig['def_rlogin_ports'] = $a_nat[$id]['def_rlogin_ports']; + $pconfig['def_rsh_ports'] = $a_nat[$id]['def_rsh_ports']; + $pconfig['def_ssl_ports'] = $a_nat[$id]['def_ssl_ports']; + $pconfig['barnyard_enable'] = $a_nat[$id]['barnyard_enable']; + $pconfig['barnyard_mysql'] = $a_nat[$id]['barnyard_mysql']; + $pconfig['enable'] = $a_nat[$id]['enable']; + $pconfig['uuid'] = $a_nat[$id]['uuid']; + $pconfig['interface'] = $a_nat[$id]['interface']; + $pconfig['descr'] = $a_nat[$id]['descr']; + $pconfig['performance'] = $a_nat[$id]['performance']; + $pconfig['blockoffenders7'] = $a_nat[$id]['blockoffenders7']; + $pconfig['alertsystemlog'] = $a_nat[$id]['alertsystemlog']; + $pconfig['tcpdumplog'] = $a_nat[$id]['tcpdumplog']; + $pconfig['snortunifiedlog'] = $a_nat[$id]['snortunifiedlog']; + $pconfig['flow_depth'] = $a_nat[$id]['flow_depth']; + $pconfig['rulesets'] = $a_nat[$id]['rulesets']; + $pconfig['rule_sid_off'] = $a_nat[$id]['rule_sid_off']; + $pconfig['rule_sid_on'] = $a_nat[$id]['rule_sid_on']; + +if (isset($_GET['dup'])) + unset($id); +} + +/* convert fake interfaces to real */ +$if_real = convert_friendly_interface_to_real_interface_name2($pconfig['interface']); + +$snort_uuid = $pconfig['uuid']; + + /* alert file */ +$d_snortconfdirty_path = "/var/run/snort_conf_{$snort_uuid}_{$if_real}.dirty"; + + /* this will exec when alert says apply */ + if ($_POST['apply']) { + + if (file_exists($d_snortconfdirty_path)) { + + write_config(); + + sync_snort_package_all($id, $if_real, $snort_uuid); + sync_snort_package(); + + unlink($d_snortconfdirty_path); + + } + + } + + + if ($_POST["Submit"]) { + + /* check for overlaps */ + +/* if no errors write to conf */ + if (!$input_errors) { + $natent = array(); + /* repost the options already in conf */ + if ($pconfig['interface'] != "") { $natent['interface'] = $pconfig['interface']; } + if ($pconfig['enable'] != "") { $natent['enable'] = $pconfig['enable']; } + if ($pconfig['uuid'] != "") { $natent['uuid'] = $pconfig['uuid']; } + if ($pconfig['descr'] != "") { $natent['descr'] = $pconfig['descr']; } + if ($pconfig['performance'] != "") { $natent['performance'] = $pconfig['performance']; } + if ($pconfig['blockoffenders7'] != "") { $natent['blockoffenders7'] = $pconfig['blockoffenders7']; } + if ($pconfig['alertsystemlog'] != "") { $natent['alertsystemlog'] = $pconfig['alertsystemlog']; } + if ($pconfig['tcpdumplog'] != "") { $natent['tcpdumplog'] = $pconfig['tcpdumplog']; } + if ($pconfig['snortunifiedlog'] != "") { $natent['snortunifiedlog'] = $pconfig['snortunifiedlog']; } + if ($pconfig['barnyard_enable'] != "") { $natent['barnyard_enable'] = $pconfig['barnyard_enable']; } + if ($pconfig['barnyard_mysql'] != "") { $natent['barnyard_mysql'] = $pconfig['barnyard_mysql']; } + if ($pconfig['def_dns_servers'] != "") { $natent['def_dns_servers'] = $pconfig['def_dns_servers']; } + if ($pconfig['def_dns_ports'] != "") { $natent['def_dns_ports'] = $pconfig['def_dns_ports']; } + if ($pconfig['def_smtp_servers'] != "") { $natent['def_smtp_servers'] = $pconfig['def_smtp_servers']; } + if ($pconfig['def_smtp_ports'] != "") { $natent['def_smtp_ports'] = $pconfig['def_smtp_ports']; } + if ($pconfig['def_mail_ports'] != "") { $natent['def_mail_ports'] = $pconfig['def_mail_ports']; } + if ($pconfig['def_http_servers'] != "") { $natent['def_http_servers'] = $pconfig['def_http_servers']; } + if ($pconfig['def_www_servers'] != "") { $natent['def_www_servers'] = $pconfig['def_www_servers']; } + if ($pconfig['def_http_ports'] != "") { $natent['def_http_ports'] = $pconfig['def_http_ports']; } + if ($pconfig['def_sql_servers'] != "") { $natent['def_sql_servers'] = $pconfig['def_sql_servers']; } + if ($pconfig['def_oracle_ports'] != "") { $natent['def_oracle_ports'] = $pconfig['def_oracle_ports']; } + if ($pconfig['def_mssql_ports'] != "") { $natent['def_mssql_ports'] = $pconfig['def_mssql_ports']; } + if ($pconfig['def_telnet_servers'] != "") { $natent['def_telnet_servers'] = $pconfig['def_telnet_servers']; } + if ($pconfig['def_telnet_ports'] != "") { $natent['def_telnet_ports'] = $pconfig['def_telnet_ports']; } + if ($pconfig['def_snmp_servers'] != "") { $natent['def_snmp_servers'] = $pconfig['def_snmp_servers']; } + if ($pconfig['def_snmp_ports'] != "") { $natent['def_snmp_ports'] = $pconfig['def_snmp_ports']; } + if ($pconfig['def_ftp_servers'] != "") { $natent['def_ftp_servers'] = $pconfig['def_ftp_servers']; } + if ($pconfig['def_ftp_ports'] != "") { $natent['def_ftp_ports'] = $pconfig['def_ftp_ports']; } + if ($pconfig['def_ssh_servers'] != "") { $natent['def_ssh_servers'] = $pconfig['def_ssh_servers']; } + if ($pconfig['def_ssh_ports'] != "") { $natent['def_ssh_ports'] = $pconfig['def_ssh_ports']; } + if ($pconfig['def_pop_servers'] != "") { $natent['def_pop_servers'] = $pconfig['def_pop_servers']; } + if ($pconfig['def_pop2_ports'] != "") { $natent['def_pop2_ports'] = $pconfig['def_pop2_ports']; } + if ($pconfig['def_pop3_ports'] != "") { $natent['def_pop3_ports'] = $pconfig['def_pop3_ports']; } + if ($pconfig['def_imap_servers'] != "") { $natent['def_imap_servers'] = $pconfig['def_imap_servers']; } + if ($pconfig['def_imap_ports'] != "") { $natent['def_imap_ports'] = $pconfig['def_imap_ports']; } + if ($pconfig['def_sip_proxy_ip'] != "") { $natent['def_sip_proxy_ip'] = $pconfig['def_sip_proxy_ip']; } + if ($pconfig['def_sip_proxy_ports'] != "") { $natent['def_sip_proxy_ports'] = $pconfig['def_sip_proxy_ports']; } + if ($pconfig['def_auth_ports'] != "") { $natent['def_auth_ports'] = $pconfig['def_auth_ports']; } + if ($pconfig['def_finger_ports'] != "") { $natent['def_finger_ports'] = $pconfig['def_finger_ports']; } + if ($pconfig['def_irc_ports'] != "") { $natent['def_irc_ports'] = $pconfig['def_irc_ports']; } + if ($pconfig['def_nntp_ports'] != "") { $natent['def_nntp_ports'] = $pconfig['def_nntp_ports']; } + if ($pconfig['def_rlogin_ports'] != "") { $natent['def_rlogin_ports'] = $pconfig['def_rlogin_ports']; } + if ($pconfig['def_rsh_ports'] != "") { $natent['def_rsh_ports'] = $pconfig['def_rsh_ports']; } + if ($pconfig['def_ssl_ports'] != "") { $natent['def_ssl_ports'] = $pconfig['def_ssl_ports']; } + if ($pconfig['rulesets'] != "") { $natent['rulesets'] = $pconfig['rulesets']; } + if ($pconfig['rule_sid_off'] != "") { $natent['rule_sid_off'] = $pconfig['rule_sid_off']; } + if ($pconfig['rule_sid_on'] != "") { $natent['rule_sid_on'] = $pconfig['rule_sid_on']; } + + /* post new options */ + $natent['perform_stat'] = $_POST['perform_stat']; + if ($_POST['def_ssl_ports_ignore'] != "") { $natent['def_ssl_ports_ignore'] = $_POST['def_ssl_ports_ignore']; }else{ $natent['def_ssl_ports_ignore'] = ""; } + if ($_POST['flow_depth'] != "") { $natent['flow_depth'] = $_POST['flow_depth']; }else{ $natent['flow_depth'] = ""; } + $natent['perform_stat'] = $_POST['perform_stat'] ? on : off; + $natent['http_inspect'] = $_POST['http_inspect'] ? on : off; + $natent['other_preprocs'] = $_POST['other_preprocs'] ? on : off; + $natent['ftp_preprocessor'] = $_POST['ftp_preprocessor'] ? on : off; + $natent['smtp_preprocessor'] = $_POST['smtp_preprocessor'] ? on : off; + $natent['sf_portscan'] = $_POST['sf_portscan'] ? on : off; + $natent['dce_rpc_2'] = $_POST['dce_rpc_2'] ? on : off; + $natent['dns_preprocessor'] = $_POST['dns_preprocessor'] ? on : off; + + if (isset($id) && $a_nat[$id]) + $a_nat[$id] = $natent; + else { + if (is_numeric($after)) + array_splice($a_nat, $after+1, 0, array($natent)); + else + $a_nat[] = $natent; + } + + write_config(); + + /* after click go to this page */ + touch($d_snortconfdirty_path); + 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' ); + header( 'Cache-Control: post-check=0, pre-check=0', false ); + header( 'Pragma: no-cache' ); + sleep(2); + header("Location: snort_preprocessors.php?id=$id"); + exit; + } +} + +$pgtitle = "Snort: Interface $id$if_real Preprocessors and Flow"; +include("head.inc"); + +?> + + +

    + + + + +
    + +'; + + if($savemsg) { + print_info_box_np2("{$savemsg}"); + }else{ + print_info_box_np2(' + The Snort configuration has changed and snort needs to be restarted on this interface.
    + You must apply the changes in order for them to take effect.
    + '); + } + } + +?> + + + + + +
    + +
    + + + .noid { + position:absolute; + top:10px; + left:0px; + width:94%; + background:#FCE9C0; + background-position: 15px; + border-top:2px solid #DBAC48; + border-bottom:2px solid #DBAC48; + padding: 15px 10px 85% 50px; + } + +
    You can not edit options without an interface ID.
    \n"; + + } + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
     Note:
    + Rules may be dependent on preprocessors!
    + Please save your settings before you click start.
    +
    Enable
    Performance Statistics
    + onClick="enable_change(false)">
    + Performance Statistics for this interface.
    Enable
    HTTP Inspect
    + onClick="enable_change(false)">
    + Normalize/Decode and detect HTTP traffic and protocol anomalies.
    HTTP server flow depth + + + + +
    -1 to 1460 (-1 disables HTTP inspect, 0 enables all HTTP inspect)
    + Amount of HTTP server response payload to inspect. Snort's performance may increase by adjusting this value.
    + Setting this value too low may cause false negatives. Values above 0 are specified in bytes.
    + Default value is 0
    Enable
    RPC Decode and Back Orifice detector
    + onClick="enable_change(false)">
    + Normalize/Decode RPC traffic and detects Back Orifice traffic on the network.
    Enable
    FTP and Telnet Normalizer
    + onClick="enable_change(false)">
    + Normalize/Decode FTP and Telnet traffic and protocol anomalies.
    Enable
    SMTP Normalizer
    + onClick="enable_change(false)">
    + Normalize/Decode SMTP protocol for enforcement and buffer overflows.
    Enable
    Portscan Detection
    + onClick="enable_change(false)">
    + Detects various types of portscans and portsweeps.
    Enable
    DCE/RPC2 Detection
    + onClick="enable_change(false)">
    + The DCE/RPC preprocessor detects and decodes SMB and DCE/RPC traffic.
    Enable
    DNS Detection
    + onClick="enable_change(false)">
    + The DNS preprocessor decodes DNS Response traffic and detects some vulnerabilities.
    Define SSL_IGNORE + +
    Encrypted traffic should be ignored by Snort for both performance reasons and to reduce false positives.
    + Default: "443 465 563 636 989 990 992 993 994 995".
    Please use spaces and not commas.
      + + + + +
     Note: +
    + Please save your settings before you click Start.
    +
    +
    + + + + + diff --git a/config/snort/snort_rules.php b/config/snort/snort_rules.php index 94c99f0e..c95d76ca 100644 --- a/config/snort/snort_rules.php +++ b/config/snort/snort_rules.php @@ -2,7 +2,8 @@ /* $Id$ */ /* edit_snortrule.php - Copyright (C) 2004, 2005 Scott Ullrich and Rober Zelaya + Copyright (C) 2004, 2005 Scott Ullrich + Copyright (C) 2008, 2009 Robert Zelaya All rights reserved. Redistribution and use in source and binary forms, with or without @@ -26,22 +27,45 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -require("guiconfig.inc"); -require("config.inc"); -if(!is_dir("/usr/local/etc/snort/rules")) { - conf_mount_rw(); - exec('mkdir /usr/local/etc/snort/rules/'); - conf_mount_ro(); + +require_once("guiconfig.inc"); +require_once("/usr/local/pkg/snort/snort_gui.inc"); +require_once("/usr/local/pkg/snort/snort.inc"); + +if (!is_array($config['installedpackages']['snortglobal']['rule'])) { + $config['installedpackages']['snortglobal']['rule'] = array(); +} + +//nat_rules_sort(); +$a_nat = &$config['installedpackages']['snortglobal']['rule']; + +$id = $_GET['id']; +if (isset($_POST['id'])) + $id = $_POST['id']; + +if (isset($id) && $a_nat[$id]) { + + $pconfig['enable'] = $a_nat[$id]['enable']; + $pconfig['interface'] = $a_nat[$id]['interface']; + $pconfig['rulesets'] = $a_nat[$id]['rulesets']; } +/* convert fake interfaces to real */ +$if_real = convert_friendly_interface_to_real_interface_name($pconfig['interface']); + +$iface_uuid = $a_nat[$id]['uuid']; + +// if(!is_dir("/usr/local/etc/snort/rules")) +// exec('mkdir /usr/local/etc/snort/rules/'); + /* Check if the rules dir is empy if so warn the user */ /* TODO give the user the option to delete the installed rules rules */ -$isrulesfolderempty = exec('ls -A /usr/local/etc/snort/rules/*.rules'); +$isrulesfolderempty = exec("ls -A /usr/local/etc/snort/snort_{$iface_uuid}_{$if_real}/rules/*.rules"); if ($isrulesfolderempty == "") { include("head.inc"); -include("fbegin.inc"); +include("./snort_fbegin.inc"); echo ""; @@ -51,18 +75,15 @@ echo "\n \n \n"; - $tab_array = array(); - $tab_array[] = array(gettext("Settings"), false, "/pkg_edit.php?xml=snort.xml&id=0"); - $tab_array[] = array(gettext("Update Rules"), false, "/snort_download_rules.php"); - $tab_array[] = array(gettext("Categories"), false, "/snort_rulesets.php"); - $tab_array[] = array(gettext("Rules"), true, "/snort_rules.php"); - $tab_array[] = array(gettext("Servers"), false, "/pkg_edit.php?xml=snort_define_servers.xml&id=0"); - $tab_array[] = array(gettext("Blocked"), false, "/snort_blocked.php"); - $tab_array[] = array(gettext("Whitelist"), false, "/pkg.php?xml=snort_whitelist.xml"); - $tab_array[] = array(gettext("Threshold"), false, "/pkg.php?xml=snort_threshold.xml"); - $tab_array[] = array(gettext("Alerts"), false, "/snort_alerts.php"); - $tab_array[] = array(gettext("Advanced"), false, "/pkg_edit.php?xml=snort_advanced.xml&id=0"); - display_top_tabs($tab_array); + $tab_array = array(); + $tab_array[] = array("Snort Interfaces", false, "/snort/snort_interfaces.php"); + $tab_array[] = array("If Settings", false, "/snort/snort_interfaces_edit.php?id={$id}"); + $tab_array[] = array("Categories", false, "/snort/snort_rulesets.php?id={$id}"); + $tab_array[] = array("Rules", true, "/snort/snort_rules.php?id={$id}"); + $tab_array[] = array("Servers", false, "/snort/snort_define_servers.php?id={$id}"); + $tab_array[] = array("Preprocessors", false, "/snort/snort_preprocessors.php?id={$id}"); + $tab_array[] = array("Barnyard2", false, "/snort/snort_barnyard.php?id={$id}"); + display_top_tabs($tab_array); echo "\n \n @@ -105,8 +126,6 @@ function get_middle($source, $beginning, $ending, $init_pos) { function write_rule_file($content_changed, $received_file) { - conf_mount_rw(); - //read snort file with writing enabled $filehandle = fopen($received_file, "w"); @@ -122,7 +141,6 @@ function write_rule_file($content_changed, $received_file) //close file handle fclose($filehandle); - conf_mount_rw(); } function load_rule_file($incoming_file) @@ -137,8 +155,9 @@ function load_rule_file($incoming_file) //close handler fclose ($filehandle); + //string for populating category select - $currentruleset = substr($file, 27); + $currentruleset = basename($rulefile); //delimiter for each new rule is a new line $delimiter = "\n"; @@ -150,10 +169,13 @@ function load_rule_file($incoming_file) } -$ruledir = "/usr/local/etc/snort/rules/"; +$ruledir = "/usr/local/etc/snort/snort_{$iface_uuid}_{$if_real}/rules/"; $dh = opendir($ruledir); -$message_reload = "The Snort rule configuration has been changed.
    You must apply the changes in order for them to take effect."; +if ($_GET['openruleset'] != '' && $_GET['ids'] != '') +{ + header("Location: /snort/snort_rules.php?id=$id&openruleset={$_GET['openruleset']}&saved=yes"); +} while (false !== ($filename = readdir($dh))) { @@ -169,19 +191,22 @@ sort($files); if ($_GET['openruleset']) { - $file = $_GET['openruleset']; + $rulefile = $_GET['openruleset']; } else { - $file = $ruledir.$files[0]; + $rulefile = $ruledir.$files[0]; } //Load the rule file -$splitcontents = load_rule_file($file); +$splitcontents = load_rule_file($rulefile); if ($_POST) { + + conf_mount_rw(); + if (!$_POST['apply']) { //retrieve POST data $post_lineid = $_POST['lineid']; @@ -258,26 +283,20 @@ if ($_POST) $splitcontents[$post_lineid] = $tempstring; //write the new .rules file - write_rule_file($splitcontents, $file); + write_rule_file($splitcontents, $rulefile); //once file has been written, reload file - $splitcontents = load_rule_file($file); + $splitcontents = load_rule_file($rulefile); $stopMsg = true; } - - if ($_POST['apply']) { -// stop_service("snort"); -// sleep(2); -// start_service("snort"); - $savemsg = "The snort rules selections have been saved. Please restart snort by clicking save on the settings tab."; - $stopMsg = false; - } - } else if ($_GET['act'] == "toggle") { - $toggleid = $_GET['id']; + + conf_mount_rw(); + + $toggleid = $_GET['ids']; //copy rule contents from array into string $tempstring = $splitcontents[$toggleid]; @@ -311,10 +330,10 @@ else if ($_GET['act'] == "toggle") $splitcontents[$toggleid] = $tempstring; //write the new .rules file - write_rule_file($splitcontents, $file); + write_rule_file($splitcontents, $rulefile); //once file has been written, reload file - $splitcontents = load_rule_file($file); + $splitcontents = load_rule_file($rulefile); $stopMsg = true; @@ -326,20 +345,22 @@ else if ($_GET['act'] == "toggle") // sid being turned off $sid_off = str_replace("sid:", "", $sid_off_cut); // rule_sid_on registers - $sid_on_pieces = $config['installedpackages']['snort']['rule_sid_on']; + $sid_on_pieces = $a_nat[$id]['rule_sid_on']; // if off sid is the same as on sid remove it $sid_on_old = str_replace("||enablesid $sid_off", "", "$sid_on_pieces"); // write the replace sid back as empty - $config['installedpackages']['snort']['rule_sid_on'] = $sid_on_old; + $a_nat[$id]['rule_sid_on'] = $sid_on_old; // rule sid off registers - $sid_off_pieces = $config['installedpackages']['snort']['rule_sid_off']; + $sid_off_pieces = $a_nat[$id]['rule_sid_off']; // if off sid is the same as off sid remove it $sid_off_old = str_replace("||disablesid $sid_off", "", "$sid_off_pieces"); // write the replace sid back as empty - $config['installedpackages']['snort']['rule_sid_off'] = $sid_off_old; + $a_nat[$id]['rule_sid_off'] = $sid_off_old; // add sid off registers to new off sid - $config['installedpackages']['snort']['rule_sid_off'] = "||disablesid $sid_off" . $config['installedpackages']['snort']['rule_sid_off']; + $a_nat[$id]['rule_sid_off'] = "||disablesid $sid_off" . $a_nat[$id]['rule_sid_off']; write_config(); + conf_mount_rw(); + } else { @@ -349,39 +370,55 @@ else if ($_GET['act'] == "toggle") // sid being turned off $sid_on = str_replace("sid:", "", $sid_on_cut); // rule_sid_off registers - $sid_off_pieces = $config['installedpackages']['snort']['rule_sid_off']; + $sid_off_pieces = $a_nat[$id]['rule_sid_off']; // if off sid is the same as on sid remove it $sid_off_old = str_replace("||disablesid $sid_on", "", "$sid_off_pieces"); // write the replace sid back as empty - $config['installedpackages']['snort']['rule_sid_off'] = $sid_off_old; + $a_nat[$id]['rule_sid_off'] = $sid_off_old; // rule sid on registers - $sid_on_pieces = $config['installedpackages']['snort']['rule_sid_on']; + $sid_on_pieces = $a_nat[$id]['rule_sid_on']; // if on sid is the same as on sid remove it $sid_on_old = str_replace("||enablesid $sid_on", "", "$sid_on_pieces"); // write the replace sid back as empty - $config['installedpackages']['snort']['rule_sid_on'] = $sid_on_old; + $a_nat[$id]['rule_sid_on'] = $sid_on_old; // add sid on registers to new on sid - $config['installedpackages']['snort']['rule_sid_on'] = "||enablesid $sid_on" . $config['installedpackages']['snort']['rule_sid_on']; + $a_nat[$id]['rule_sid_on'] = "||enablesid $sid_on" . $a_nat[$id]['rule_sid_on']; write_config(); + conf_mount_rw(); } } +if ($_GET['saved'] == 'yes') +{ + $message = "The Snort rule configuration has been changed.
    You must restart this snort interface in order for the changes to take effect."; + +// stop_service("snort"); +// sleep(2); +// start_service("snort"); +// $savemsg = ""; +// $stopMsg = false; +} + +$currentruleset = basename($rulefile); + +$ifname = strtoupper($pconfig['interface']); -$pgtitle = "Snort: Rules"; require("guiconfig.inc"); include("head.inc"); + +$pgtitle = "Snort: $id $iface_uuid $if_real Category: $currentruleset"; + ?> - + +

    +

    "; +echo "
    "; ?> - - -
    +
    + - - - + + +
    -
    +
    @@ -447,7 +496,8 @@ function go() echo "
    Category: "; //string for populating category select - $currentruleset = substr($file, 27); + $currentruleset = basename($rulefile); + ?> + "; - - echo " + + "; - echo ""; - echo ""; - echo ""; + echo "$textse + + + + + "; ?> "; ?>
    "; + echo " There are $printcounter rules in this category.

    "; ?>
    "; - echo $textss; + echo "
    + $textss\n"; ?> - + + + "; - - - echo ""; - echo $textss; - echo $sid; - echo $textse; - echo ""; - echo $textss; - echo $protocol; + echo "$textse + + $textss + $sid + $textse + + $textss + $protocol"; + ?> + "; - echo ""; - echo $textss; - echo $source; - echo $textse; - echo ""; - echo $textss; - echo $source_port; - echo $textse; - echo ""; - echo $textss; - echo $destination; - echo $textse; - echo ""; - echo $textss; - echo $destination_port; - echo $textse; - echo " + $textss + $source + $textse + + $textss + $source_port + $textse + + $textss + $destination + $textse + + $textss + $destination_port + $textse + "; + echo "$textss + $message + $textse + - + +
    - + - + - - + +
    Rule Enabled
    Rule Disabled
    + + + +

    @@ -615,12 +677,11 @@ function go() - + - - \ No newline at end of file + diff --git a/config/snort/snort_rules_edit.php b/config/snort/snort_rules_edit.php index cbabce73..b770867f 100644 --- a/config/snort/snort_rules_edit.php +++ b/config/snort/snort_rules_edit.php @@ -1,40 +1,72 @@ +#!/usr/local/bin/php "") { + if($_POST['highlight'] == "yes" or + $_POST['highlight'] == "enabled") { + $highlight = "yes"; + } else { + $highlight = "no"; + } +} else { + $highlight = "no"; } + +if($_POST['rows'] <> "") + $rows = $_POST['rows']; else + $rows = 1; + +if($_POST['cols'] <> "") + $cols = $_POST['cols']; +else + $cols = 66; + +if ($_POST) { - $counter2 = 1; + if ($_POST['save']) { + + /* get the changes */ + $rule_content2 = $_POST['code']; + + //copy string into file array for writing + $splitcontents[$lineid] = $rule_content2; + + //write the new .rules file + write_rule_file($splitcontents, $file); + + header("Location: /snort/snort_rules_edit.php?id=$id&openruleset=$file&ids=$ids"); + + } } +$pgtitle = array(gettext("Advanced"), gettext("File Editor")); -$protocol = $rule_content[$counter2];//protocol location -$counter2++; -$source = $rule_content[$counter2];//source location -$counter2++; -$source_port = $rule_content[$counter2];//source port location -$counter2++; -$direction = $rule_content[$counter2]; -$counter2++; -$destination = $rule_content[$counter2];//destination location -$counter2++; -$destination_port = $rule_content[$counter2];//destination port location -$message = get_middle($tempstring, 'msg:"', '";', 0); - -$content = get_middle($tempstring, 'content:"', '";', 0); -$classtype = get_middle($tempstring, 'classtype:', ';', 0); -$revision = get_middle($tempstring, 'rev:', ';',0); - -$pgtitle = "Snort: Edit Rule"; -require("guiconfig.inc"); -include("head.inc"); +// ?> - - - -

    "; -?> - - - - - - - + + + +
    - -
    -
    - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Enabled: >
    SID:
    Protocol:
    Source:
    Source Port:
    Direction:
    Destination:
    Destination Port:
    Message:
    Content:
    Classtype:
    Revision:
     
       
    - -
    -
    + + +
    +
    + + + + + +
    + +
    + : + /> + + /> + +
    + + + + +
    +
    + + +
    +
    + + + + +
    +
    + + +
    +
    + +
    +
    + + + + + + + + + + + + + + - - - \ No newline at end of file + + diff --git a/config/snort/snort_rulesets.php b/config/snort/snort_rulesets.php index d839ae7a..d232c097 100644 --- a/config/snort/snort_rulesets.php +++ b/config/snort/snort_rulesets.php @@ -3,6 +3,7 @@ /* snort_rulesets.php Copyright (C) 2006 Scott Ullrich + Copyright (C) 2009 Robert Zelaya All rights reserved. Redistribution and use in source and binary forms, with or without @@ -28,43 +29,68 @@ */ require("guiconfig.inc"); -require_once("service-utils.inc"); -require("/usr/local/pkg/snort.inc"); +//require_once("filter.inc"); +//require_once("service-utils.inc"); +include_once("/usr/local/pkg/snort/snort.inc"); +require_once("/usr/local/pkg/snort/snort_gui.inc"); -if(!is_dir("/usr/local/etc/snort/rules")) { - conf_mount_rw(); - exec('mkdir /usr/local/etc/snort/rules/'); - conf_mount_ro(); + +if (!is_array($config['installedpackages']['snortglobal']['rule'])) { + $config['installedpackages']['snortglobal']['rule'] = array(); +} + +//nat_rules_sort(); +$a_nat = &$config['installedpackages']['snortglobal']['rule']; + +$id = $_GET['id']; +if (isset($_POST['id'])) + $id = $_POST['id']; + + +if (isset($id) && $a_nat[$id]) { + + $pconfig['enable'] = $a_nat[$id]['enable']; + $pconfig['interface'] = $a_nat[$id]['interface']; + $pconfig['rulesets'] = $a_nat[$id]['rulesets']; } +/* convert fake interfaces to real */ +$if_real = convert_friendly_interface_to_real_interface_name2($pconfig['interface']); + + +$iface_uuid = $a_nat[$id]['uuid']; + +$pgtitle = "Snort: Interface $id $iface_uuid $if_real Categories"; + + /* Check if the rules dir is empy if so warn the user */ /* TODO give the user the option to delete the installed rules rules */ -$isrulesfolderempty = exec('ls -A /usr/local/etc/snort/rules/*.rules'); +$isrulesfolderempty = exec("ls -A /usr/local/etc/snort/snort_{$iface_uuid}_{$if_real}/rules/*.rules"); if ($isrulesfolderempty == "") { include("head.inc"); -include("fbegin.inc"); +include("./snort_fbegin.inc"); + +echo "

    "; +if($pfsense_stable == 'yes'){echo $pgtitle;} +echo "

    \n"; echo ""; -echo "\n -\n +echo " \n \n \n \n @@ -74,7 +100,7 @@ echo "\n
    \n"; - $tab_array = array(); - $tab_array[] = array(gettext("Settings"), false, "/pkg_edit.php?xml=snort.xml&id=0"); - $tab_array[] = array(gettext("Update Rules"), false, "/snort_download_rules.php"); - $tab_array[] = array(gettext("Categories"), true, "/snort_rulesets.php"); - $tab_array[] = array(gettext("Rules"), false, "/snort_rules.php"); - $tab_array[] = array(gettext("Servers"), false, "/pkg_edit.php?xml=snort_define_servers.xml&id=0"); - $tab_array[] = array(gettext("Blocked"), false, "/snort_blocked.php"); - $tab_array[] = array(gettext("Whitelist"), false, "/pkg.php?xml=snort_whitelist.xml"); - $tab_array[] = array(gettext("Threshold"), false, "/pkg.php?xml=snort_threshold.xml"); - $tab_array[] = array(gettext("Alerts"), false, "/snort_alerts.php"); - $tab_array[] = array(gettext("Advanced"), false, "/pkg_edit.php?xml=snort_advanced.xml&id=0"); - display_top_tabs($tab_array); + $tab_array = array(); + $tab_array[] = array("Snort Interfaces", false, "/snort/snort_interfaces.php"); + $tab_array[] = array("If Settings", false, "/snort/snort_interfaces_edit.php?id={$id}"); + $tab_array[] = array("Categories", true, "/snort/snort_rulesets.php?id={$id}"); + $tab_array[] = array("Rules", false, "/snort/snort_rules.php?id={$id}"); + $tab_array[] = array("Servers", false, "/snort/snort_define_servers.php?id={$id}"); + $tab_array[] = array("Preprocessors", false, "/snort/snort_preprocessors.php?id={$id}"); + $tab_array[] = array("Barnyard2", false, "/snort/snort_barnyard.php?id={$id}"); + display_top_tabs($tab_array); echo "
    \n \n \n \n
    \n -# The rules directory is empty.\n +# The rules directory is empty. /usr/local/etc/snort/snort_{$iface_uuid}_{$if_real}/rules \n
    \n @@ -87,7 +113,7 @@ echo "\n \n

    \n\n"; -echo "Please click on the Update Rules tab to install your selected rule sets."; +echo "Please click on the Update Rules tab to install your selected rule sets. $isrulesfolderempty"; include("fend.inc"); echo ""; @@ -97,66 +123,117 @@ exit(0); } -if($_POST) { + /* alert file */ +$d_snortconfdirty_path = "/var/run/snort_conf_{$iface_uuid}_{$if_real}.dirty"; + + /* this will exec when alert says apply */ + if ($_POST['apply']) { + + if (file_exists($d_snortconfdirty_path)) { + + write_config(); + + sync_snort_package_all($id, $if_real, $iface_uuid); + sync_snort_package(); + + unlink($d_snortconfdirty_path); + + } + + } + + if ($_POST["Submit"]) { $enabled_items = ""; $isfirst = true; + if (is_array($_POST['toenable'])) { foreach($_POST['toenable'] as $toenable) { if(!$isfirst) $enabled_items .= "||"; $enabled_items .= "{$toenable}"; $isfirst = false; } - $config['installedpackages']['snort']['rulesets'] = $enabled_items; + }else{ + $enabled_items = $_POST['toenable']; + } + $a_nat[$id]['rulesets'] = $enabled_items; + write_config(); - stop_service("snort"); - create_snort_conf(); - sleep(2); - start_service("snort"); - $savemsg = "The snort ruleset selections have been saved."; + + touch($d_snortconfdirty_path); + + 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' ); + header( 'Cache-Control: post-check=0, pre-check=0', false ); + header( 'Pragma: no-cache' ); + sleep(2); + sync_snort_package_all($id, $if_real, $iface_uuid); + header("Location: /snort/snort_rulesets.php?id=$id"); + } -$enabled_rulesets = $config['installedpackages']['snort']['rulesets']; +$enabled_rulesets = $a_nat[$id]['rulesets']; if($enabled_rulesets) $enabled_rulesets_array = split("\|\|", $enabled_rulesets); -$pgtitle = "Snort: Categories"; include("head.inc"); ?> - + +

    +"; + +?>

    "; + + /* Display message */ + + if ($input_errors) { + print_input_errors($input_errors); // TODO: add checks + } + + if ($savemsg) { + print_info_box2($savemsg); + } + + if (file_exists($d_snortconfdirty_path)) { + echo '

    '; + + if($savemsg) { + print_info_box_np2("{$savemsg}"); + }else{ + print_info_box_np2(' + The Snort configuration has changed and snort needs to be restarted on this interface.
    + You must apply the changes in order for them to take effect.
    + '); + } + } + ?> -

    - - - - - - + + + @@ -227,4 +304,4 @@ if(!$pgtitle_output) } -?> \ No newline at end of file +?> diff --git a/config/snort/snort_threshold.xml b/config/snort/snort_threshold.xml deleted file mode 100644 index f9075d3d..00000000 --- a/config/snort/snort_threshold.xml +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - . - 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. - */ -/* ========================================================================== */ - ]]> - - Describe your package here - Describe your package requirements here - Currently there are no FAQ items provided. - snort-threshold - 0.1.0 - Snort: Alert Thresholding and Suppression - /usr/local/pkg/snort.inc - - - - Settings - /pkg_edit.php?xml=snort.xml&id=0 - - - Update Rules - /snort_download_rules.php - - - Categories - /snort_rulesets.php - - - Rules - /snort_rules.php - - - Servers - /pkg_edit.php?xml=snort_define_servers.xml&id=0 - - - Blocked - /snort_blocked.php - - - Whitelist - /pkg.php?xml=snort_whitelist.xml - - - Threshold - /pkg.php?xml=snort_threshold.xml - - - - Alerts - /snort_alerts.php - - - Advanced - /pkg_edit.php?xml=snort_advanced.xml&id=0 - - - - - Thresholding or Suppression Rule - threshrule - - - Description - description - - - - - Thresholding or Suppression Rule - threshrule - Enter the Rule. Example; "suppress gen_id 125, sig_id 4" or "threshold gen_id 1, sig_id 1851, type limit, track by_src, count 1, seconds 60" - input - 40 - - - Description - description - Enter the description for this item - input - 60 - - - - - - - - create_snort_conf(); - - \ No newline at end of file diff --git a/config/snort/snort_whitelist.xml b/config/snort/snort_whitelist.xml index 42769e4e..d98f83fa 100644 --- a/config/snort/snort_whitelist.xml +++ b/config/snort/snort_whitelist.xml @@ -45,52 +45,40 @@ Describe your package hereDescribe your package requirements hereCurrently there are no FAQ items provided. - snort-whitelist + snortglobal0.1.0Snort: Whitelist - /usr/local/pkg/snort.inc + /usr/local/pkg/snort/snort.inc - Settings - /pkg_edit.php?xml=snort.xml&id=0 + Snort Interfaces + /snort/snort_interfaces.php - Update Rules - /snort_download_rules.php + Global Settings + /snort/snort_interfaces_global.php - Categories - /snort_rulesets.php + Rule Updates + /snort/snort_download_rules.php - Rules - /snort_rules.php - - - Servers - /pkg_edit.php?xml=snort_define_servers.xml&id=0 + Alerts + /snort/snort_alerts.php Blocked - /snort_blocked.php + /snort/snort_blocked.php Whitelist - /pkg.php?xml=snort_whitelist.xml + /pkg.php?xml=/snort/snort_whitelist.xml - Threshold - /pkg.php?xml=snort_threshold.xml - - - Alerts - /snort_alerts.php - - - Advanced - /pkg_edit.php?xml=snort_advanced.xml&id=0 + Help Info + /snort/snort_help_info.php @@ -124,6 +112,6 @@ - create_snort_conf(); + sync_snort_package_empty(); - \ No newline at end of file + diff --git a/config/snort/snort_xmlrpc_sync.php b/config/snort/snort_xmlrpc_sync.php deleted file mode 100644 index db8b3f3e..00000000 --- a/config/snort/snort_xmlrpc_sync.php +++ /dev/null @@ -1,114 +0,0 @@ -setCredentials('admin', $password); - if($g['debug']) - $cli->setDebug(1); - /* send our XMLRPC message and timeout after 240 seconds */ - $resp = $cli->send($msg, "999"); - if(!$resp) { - $error = "A communications error occured 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 XMLRPC sync successfully completed with {$url}:{$port}."); - } - log_error("[SNORT] snort_xmlrpc_sync.php is ending."); -} - -?> \ No newline at end of file -- cgit v1.2.3 From 3b4a4a1049f29a0d738b8d4c624d59f292c22577 Mon Sep 17 00:00:00 2001 From: robiscool Date: Wed, 31 Mar 2010 19:16:25 -0700 Subject: snort, add misc --- config/snort/snort_interfaces_global.php | 1 - 1 file changed, 1 deletion(-) (limited to 'config') diff --git a/config/snort/snort_interfaces_global.php b/config/snort/snort_interfaces_global.php index ff3620a3..648b5bda 100644 --- a/config/snort/snort_interfaces_global.php +++ b/config/snort/snort_interfaces_global.php @@ -112,7 +112,6 @@ if ($_POST) { } - sync_snort_package_all(); sync_snort_package(); } -- cgit v1.2.3 From 26a2160f92664ed0679eea165d021793771504a8 Mon Sep 17 00:00:00 2001 From: robiscool Date: Mon, 5 Apr 2010 16:38:51 -0700 Subject: snort, add warning change code --- config/snort/snort.inc | 76 +++- config/snort/snort_barnyard.php | 2 +- config/snort/snort_define_servers.php | 19 +- config/snort/snort_dynamic_ip_reload.php | 17 +- config/snort/snort_head.inc | 61 +++ config/snort/snort_interfaces.php | 8 +- config/snort/snort_interfaces_edit_bkup.php | 609 ---------------------------- config/snort/snort_preprocessors.php | 8 +- 8 files changed, 151 insertions(+), 649 deletions(-) create mode 100644 config/snort/snort_head.inc delete mode 100644 config/snort/snort_interfaces_edit_bkup.php (limited to 'config') diff --git a/config/snort/snort.inc b/config/snort/snort.inc index eef238a0..61449c30 100644 --- a/config/snort/snort.inc +++ b/config/snort/snort.inc @@ -37,7 +37,6 @@ require_once("functions.inc"); require_once("filter.inc"); /* find out if were in 1.2.3-RELEASE */ - $pfsense_ver_chk = exec('/bin/cat /etc/version'); if ($pfsense_ver_chk == '1.2.3-RELEASE') { @@ -46,6 +45,9 @@ if ($pfsense_ver_chk == '1.2.3-RELEASE') $pfsense_stable = 'no'; } +/* tell me my theme */ +$pfsense_theme_is = $config['theme']; + /* checks to see if snort is running yes/no and stop/start */ function Running_Ck($snort_uuid, $if_real, $id) { global $config; @@ -588,7 +590,7 @@ class array_ereg { $id += 1; $result_lan = $config['installedpackages']['snortglobal']['rule'][$id]['interface']; - $if_real = convert_friendly_interface_to_real_interface_name2($result_lan); + $if_real = convert_friendly_interface_to_real_interface_name($result_lan); $snort_rules_list[] = "snort_$id$if_real"; @@ -628,7 +630,7 @@ function sync_snort_package() conf_mount_ro(); } -/* make sure this func on writes to files and does not start snort */ +/* only run when a single iface needs to sync */ function sync_snort_package_all($id, $if_real, $snort_uuid) { //global $config, $g, $id, $if_real, $snort_uuid, $interface_fake; @@ -652,7 +654,7 @@ if ($id != '' && $if_real != '') //new $snort_uuid = $config['installedpackages']['snortglobal']['rule'][$id]['uuid']; $result_lan = $config['installedpackages']['snortglobal']['rule'][$id]['interface']; - $if_real = convert_friendly_interface_to_real_interface_name2($result_lan); + $if_real = convert_friendly_interface_to_real_interface_name($result_lan); /* create snort configuration file */ create_snort_conf($id, $if_real, $snort_uuid); @@ -675,7 +677,7 @@ if ($id != '' && $if_real != '') //new } } -/* only be run on new iface create, bootup and ip refresh */ +/* only run when all ifaces needed to sync */ function sync_snort_package_empty() { global $config, $g; @@ -699,7 +701,7 @@ function sync_snort_package_empty() $id += 1; $result_lan = $config['installedpackages']['snortglobal']['rule'][$id]['interface']; - $if_real = convert_friendly_interface_to_real_interface_name2($result_lan); + $if_real = convert_friendly_interface_to_real_interface_name($result_lan); $snort_uuid = $config['installedpackages']['snortglobal']['rule'][$id]['uuid']; if ($if_real != '' && $snort_uuid != '') { @@ -720,11 +722,60 @@ function sync_snort_package_empty() create_snort_sh(); sync_snort_package(); + + conf_mount_ro(); } } } +/* only bootup and ip refresh */ +function sync_snort_package_config() +{ + global $config, $g; + conf_mount_rw(); + + /* do not start config build if rules is empty */ + if (!empty($config['installedpackages']['snortglobal']['rule'])) + { + if ($id == "") + { + + $rule_array = $config['installedpackages']['snortglobal']['rule']; + $id = -1; + foreach ($rule_array as $value) + { + + if ($id == '') { + $id = 0; + } + + $id += 1; + + $result_lan = $config['installedpackages']['snortglobal']['rule'][$id]['interface']; + $if_real = convert_friendly_interface_to_real_interface_name($result_lan); + $snort_uuid = $config['installedpackages']['snortglobal']['rule'][$id]['uuid']; + + if ($if_real != '' && $snort_uuid != '') { + /* create snort configuration file */ + create_snort_conf($id, $if_real, $snort_uuid); + + /* create barnyard2 configuration file */ + $snortbarnyardlog_info_chk = $config['installedpackages']['snortglobal']['rule'][$id]['barnyard_enable']; + if ($snortbarnyardlog_info_chk == 'on') + create_barnyard2_conf($id, $if_real, $snort_uuid); + } + } + + sync_snort_package(); + + conf_mount_ro(); + + } + } +} + + /* Start of main config files */ /* Start of main config files */ @@ -752,7 +803,7 @@ function create_snort_sh() $snort_uuid = $config['installedpackages']['snortglobal']['rule'][$id]['uuid']; $result_lan = $config['installedpackages']['snortglobal']['rule'][$id]['interface']; - $if_real = convert_friendly_interface_to_real_interface_name2($result_lan); + $if_real = convert_friendly_interface_to_real_interface_name($result_lan); /* define snortbarnyardlog_chk */ $snortbarnyardlog_info_chk = $config['installedpackages']['snortglobal']['rule'][$id]['barnyard_enable']; @@ -860,7 +911,7 @@ rc_start() { /bin/echo "snort.sh run" > /tmp/snort.sh.pid #### Remake the configs on boot Important! - /usr/local/bin/php -f /usr/local/pkg/pf/snort_dynamic_ip_reload.php + /usr/local/bin/php -f /usr/local/pkg/pf/snort_dynamic_ip_reload.php & /usr/bin/logger -p daemon.info -i -t SnortStartup "Snort Startup files Sync..." $start_snort_iface_restart @@ -1087,9 +1138,10 @@ function snort_deinstall() exec("rm -rf /usr/local/etc/snort*"); //exec("cd /var/db/pkg && pkg_delete `ls | grep barnyard2`"); exec("cd /var/db/pkg && pkg_delete `ls | grep snort`"); - exec("cd /var/db/pkg && pkg_delete `ls | grep mysql`"); - exec("cd /var/db/pkg && pkg_delete `ls | grep pcre`"); - exec("cd /var/db/pkg && pkg_delete `ls | grep perl`"); + /* TODO: figure out how to detect pfsense packages that use the same freebsd pkckages and not deinstall */ + //exec("cd /var/db/pkg && pkg_delete `ls | grep mysql`"); + //exec("cd /var/db/pkg && pkg_delete `ls | grep pcre`"); + //exec("cd /var/db/pkg && pkg_delete `ls | grep perl`"); /* Remove snort cron entries Ugly code needs smoothness*/ @@ -1528,7 +1580,7 @@ else $home_net .= "{$ip} "; /* Add Gateway on WAN interface to whitelist (For RRD graphs) */ - $int = convert_friendly_interface_to_real_interface_name2("WAN"); + $int = convert_friendly_interface_to_real_interface_name("WAN"); $gw = get_interface_gateway($int); if($gw) $home_net .= "{$gw} "; diff --git a/config/snort/snort_barnyard.php b/config/snort/snort_barnyard.php index 7a587330..db03a2d1 100644 --- a/config/snort/snort_barnyard.php +++ b/config/snort/snort_barnyard.php @@ -128,7 +128,7 @@ if (isset($id) && $a_nat[$id]) { if (isset($_GET['dup'])) unset($id); -$if_real = convert_friendly_interface_to_real_interface_name2($pconfig['interface']); +$if_real = convert_friendly_interface_to_real_interface_name($pconfig['interface']); $snort_uuid = $config['installedpackages']['snortglobal']['rule'][$id]['uuid']; diff --git a/config/snort/snort_define_servers.php b/config/snort/snort_define_servers.php index 04984300..97e6a28b 100644 --- a/config/snort/snort_define_servers.php +++ b/config/snort/snort_define_servers.php @@ -38,7 +38,7 @@ Important add error checking */ -require_once("globals.inc"); +//require_once("globals.inc"); require_once("guiconfig.inc"); require_once("/usr/local/pkg/snort/snort.inc"); require_once("/usr/local/pkg/snort/snort_gui.inc"); @@ -126,7 +126,12 @@ if (isset($_GET['dup'])) } /* convert fake interfaces to real */ -$if_real = convert_friendly_interface_to_real_interface_name2($pconfig['interface']); +$if_real = convert_friendly_interface_to_real_interface_name($pconfig['interface']); + +$snort_uuid = $config['installedpackages']['snortglobal']['rule'][$id]['uuid']; + +/* alert file */ +$d_snortconfdirty_path = "/var/run/snort_conf_{$snort_uuid}_{$if_real}.dirty"; if ($_POST["Submit"]) { @@ -226,11 +231,6 @@ $if_real = convert_friendly_interface_to_real_interface_name2($pconfig['interfac exit; } } - -$snort_uuid = $pconfig['uuid']; - - /* alert file */ -$d_snortconfdirty_path = "/var/run/snort_conf_{$snort_uuid }_{$if_real}.dirty"; /* this will exec when alert says apply */ if ($_POST['apply']) { @@ -278,7 +278,7 @@ padding: 15px 10px 85% 50px; '; if($savemsg) { diff --git a/config/snort/snort_dynamic_ip_reload.php b/config/snort/snort_dynamic_ip_reload.php index 98d9bcce..615302e8 100644 --- a/config/snort/snort_dynamic_ip_reload.php +++ b/config/snort/snort_dynamic_ip_reload.php @@ -33,18 +33,15 @@ require_once("/usr/local/pkg/snort/snort.inc"); -/* get the varibles from the command line */ -/* Note: snort.sh sould only be using this */ -//$id = $_SERVER["argv"][1]; -//$if_real = $_SERVER["argv"][2]; +if (file_exists('/var/run/snort_dynamic_ip_reload.dirty')) { + exit(); +} -//$test_iface = $config['installedpackages']['snortglobal']['rule'][$id]['interface']; +exec('/usr/bin/touch /var/run/snort_dynamic_ip_reload.dirty'); -//if ($id == "" || $if_real == "" || $test_iface == "") { -// exec("/usr/bin/logger -p daemon.info -i -t SnortDynIP \"ERORR starting snort_dynamic_ip_reload.php\""); -// exit; -// } +sync_snort_package_config(); +sync_snort_package(); -sync_snort_package_empty(); +exec('/bin/rm /var/run/snort_dynamic_ip_reload.dirty'); ?> \ No newline at end of file diff --git a/config/snort/snort_head.inc b/config/snort/snort_head.inc new file mode 100644 index 00000000..56a96df2 --- /dev/null +++ b/config/snort/snort_head.inc @@ -0,0 +1,61 @@ + "") + $g['theme'] = $config['theme']; +else + $g['theme'] = "pfsense"; + +$apple_ua = array("iPhone","iPod"); +foreach($apple_ua as $useragent) + if(strstr($_SERVER['HTTP_USER_AGENT'], $useragent)) + $g['theme'] = "pfsense"; +?> + + + + <?=gentitle($pgtitle);?> + + /apple-touch-icon.pngâ€/> + + + + + + + + + +'."\n"; + } + closedir($dh); + } + } + + if ($oSajax): +?> + + + + + + diff --git a/config/snort/snort_interfaces.php b/config/snort/snort_interfaces.php index cb51df44..b83068e1 100644 --- a/config/snort/snort_interfaces.php +++ b/config/snort/snort_interfaces.php @@ -494,7 +494,7 @@ if ($pkg['tabs'] <> "") { \n"; } -if ($pfsense_stable != 'yes') { +if ($pfsense_theme_is == 'pfsense_ng') { $footer3 = " -
    +
    Snort is a registered trademark of Sourcefire, Inc, Barnyard2 is a registered trademark of securixlive.com, Orion copyright Robert Zelaya, Emergingthreats is a registered trademark of emergingthreats.net, Mysql is a registered trademark of Mysql.com
    \n"; diff --git a/config/snort/snort_interfaces_edit_bkup.php b/config/snort/snort_interfaces_edit_bkup.php deleted file mode 100644 index 92bc7c5a..00000000 --- a/config/snort/snort_interfaces_edit_bkup.php +++ /dev/null @@ -1,609 +0,0 @@ -. - Copyright (C) 2008-2009 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"); -require_once("/usr/local/pkg/snort/snort_gui.inc"); - - -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 (isset($_GET['dup'])) { - $id = $_GET['dup']; - $after = $_GET['dup']; -} - -/* always have a limit of (65535) numbers only or snort will not start do to id limits */ -/* TODO: When inline gets added make the uuid the port number lisstening */ -//function gen_snort_uuid($fileline) -//{ - /* return the first 5 */ - //if (preg_match("/...../", $fileline, $matches1)) - //{ - //$uuid_final = "$matches1[0]"; - //} -//return $uuid_final; -//} - -/* gen uuid for each iface !inportant */ -if ($config['installedpackages']['snortglobal']['rule'][$id]['uuid'] == '') { - //$snort_uuid = gen_snort_uuid(strrev(uniqid(true))); -$snort_uuid = 0; -while ($snort_uuid > 65535 || $snort_uuid == 0) { - $snort_uuid = mt_rand(1, 65535); - $pconfig['uuid'] = $snort_uuid; - } -} - -if ($config['installedpackages']['snortglobal']['rule'][$id]['uuid'] != '') { - $snort_uuid = $config['installedpackages']['snortglobal']['rule'][$id]['uuid']; -} - - -/* convert fake interfaces to real */ -$if_real = convert_friendly_interface_to_real_interface_name2($config['installedpackages']['snortglobal']['rule'][$id]['interface']); - - -if (isset($id) && $a_nat[$id]) { - - /* old options */ - $pconfig['def_ssl_ports_ignore'] = $a_nat[$id]['def_ssl_ports_ignore']; - $pconfig['flow_depth'] = $a_nat[$id]['flow_depth']; - $pconfig['perform_stat'] = $a_nat[$id]['perform_stat']; - $pconfig['http_inspect'] = $a_nat[$id]['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['dce_rpc_2'] = $a_nat[$id]['dce_rpc_2']; - $pconfig['dns_preprocessor'] = $a_nat[$id]['dns_preprocessor']; - $pconfig['def_dns_servers'] = $a_nat[$id]['def_dns_servers']; - $pconfig['def_dns_ports'] = $a_nat[$id]['def_dns_ports']; - $pconfig['def_smtp_servers'] = $a_nat[$id]['def_smtp_servers']; - $pconfig['def_smtp_ports'] = $a_nat[$id]['def_smtp_ports']; - $pconfig['def_mail_ports'] = $a_nat[$id]['def_mail_ports']; - $pconfig['def_http_servers'] = $a_nat[$id]['def_http_servers']; - $pconfig['def_www_servers'] = $a_nat[$id]['def_www_servers']; - $pconfig['def_http_ports'] = $a_nat[$id]['def_http_ports']; - $pconfig['def_sql_servers'] = $a_nat[$id]['def_sql_servers']; - $pconfig['def_oracle_ports'] = $a_nat[$id]['def_oracle_ports']; - $pconfig['def_mssql_ports'] = $a_nat[$id]['def_mssql_ports']; - $pconfig['def_telnet_servers'] = $a_nat[$id]['def_telnet_servers']; - $pconfig['def_telnet_ports'] = $a_nat[$id]['def_telnet_ports']; - $pconfig['def_snmp_servers'] = $a_nat[$id]['def_snmp_servers']; - $pconfig['def_snmp_ports'] = $a_nat[$id]['def_snmp_ports']; - $pconfig['def_ftp_servers'] = $a_nat[$id]['def_ftp_servers']; - $pconfig['def_ftp_ports'] = $a_nat[$id]['def_ftp_ports']; - $pconfig['def_ssh_servers'] = $a_nat[$id]['def_ssh_servers']; - $pconfig['def_ssh_ports'] = $a_nat[$id]['def_ssh_ports']; - $pconfig['def_pop_servers'] = $a_nat[$id]['def_pop_servers']; - $pconfig['def_pop2_ports'] = $a_nat[$id]['def_pop2_ports']; - $pconfig['def_pop3_ports'] = $a_nat[$id]['def_pop3_ports']; - $pconfig['def_imap_servers'] = $a_nat[$id]['def_imap_servers']; - $pconfig['def_imap_ports'] = $a_nat[$id]['def_imap_ports']; - $pconfig['def_sip_proxy_ip'] = $a_nat[$id]['def_sip_proxy_ip']; - $pconfig['def_sip_proxy_ports'] = $a_nat[$id]['def_sip_proxy_ports']; - $pconfig['def_auth_ports'] = $a_nat[$id]['def_auth_ports']; - $pconfig['def_finger_ports'] = $a_nat[$id]['def_finger_ports']; - $pconfig['def_irc_ports'] = $a_nat[$id]['def_irc_ports']; - $pconfig['def_nntp_ports'] = $a_nat[$id]['def_nntp_ports']; - $pconfig['def_rlogin_ports'] = $a_nat[$id]['def_rlogin_ports']; - $pconfig['def_rsh_ports'] = $a_nat[$id]['def_rsh_ports']; - $pconfig['def_ssl_ports'] = $a_nat[$id]['def_ssl_ports']; - $pconfig['barnyard_enable'] = $a_nat[$id]['barnyard_enable']; - $pconfig['barnyard_mysql'] = $a_nat[$id]['barnyard_mysql']; - $pconfig['enable'] = $a_nat[$id]['enable']; - $pconfig['uuid'] = $a_nat[$id]['uuid']; - $pconfig['interface'] = $a_nat[$id]['interface']; - $pconfig['descr'] = $a_nat[$id]['descr']; - $pconfig['performance'] = $a_nat[$id]['performance']; - $pconfig['blockoffenders7'] = $a_nat[$id]['blockoffenders7']; - $pconfig['snortalertlogtype'] = $a_nat[$id]['snortalertlogtype']; - $pconfig['alertsystemlog'] = $a_nat[$id]['alertsystemlog']; - $pconfig['tcpdumplog'] = $a_nat[$id]['tcpdumplog']; - $pconfig['snortunifiedlog'] = $a_nat[$id]['snortunifiedlog']; - $pconfig['rulesets'] = $a_nat[$id]['rulesets']; - $pconfig['rule_sid_off'] = $a_nat[$id]['rule_sid_off']; - $pconfig['rule_sid_on'] = $a_nat[$id]['rule_sid_on']; - - - if (!$pconfig['interface']) { - $pconfig['interface'] = "wan"; - } else { - $pconfig['interface'] = "wan"; - } -} - -if (isset($_GET['dup'])) - unset($id); - -/* alert file */ -$d_snortconfdirty_path = "/var/run/snort_conf_{$snort_uuid}_{$if_real}.dirty"; - - /* this will exec when alert says apply */ - if ($_POST['apply']) { - - if (file_exists("/var/run/snort_conf_{$snort_uuid}_.dirty")) { - - write_config(); - - sync_snort_package_empty(); - sync_snort_package(); - - unlink("/var/run/snort_conf_{$snort_uuid}_.dirty"); - - } - - if (file_exists($d_snortconfdirty_path)) { - - write_config(); - - sync_snort_package_all($id, $if_real, $snort_uuid); - sync_snort_package(); - - unlink($d_snortconfdirty_path); - - } - - } - -if ($_POST["Submit"]) { - - - - // if ($config['installedpackages']['snortglobal']['rule']) { - if ($_POST['descr'] == '' && $pconfig['descr'] == '') { - $input_errors[] = "Please enter a description for your reference."; - } - - if ($id == "" && $config['installedpackages']['snortglobal']['rule'][0]['interface'] != "") { - - $rule_array = $config['installedpackages']['snortglobal']['rule']; - $id_c = -1; - foreach ($rule_array as $value) { - - $id_c += 1; - - $result_lan = $config['installedpackages']['snortglobal']['rule'][$id_c]['interface']; - $if_real = convert_friendly_interface_to_real_interface_name2($result_lan); - - if ($_POST['interface'] == $result_lan) { - $input_errors[] = "Interface $result_lan is in use. Please select another interface."; - } - } - } - - /* check for overlaps */ - foreach ($a_nat as $natent) { - if (isset($id) && ($a_nat[$id]) && ($a_nat[$id] === $natent)) - continue; - if ($natent['interface'] != $_POST['interface']) - continue; - } - - /* if no errors write to conf */ - if (!$input_errors) { - $natent = array(); - - /* write to conf for 1st time or rewrite the answer */ - $natent['interface'] = $_POST['interface'] ? $_POST['interface'] : $pconfig['interface']; - /* if post write to conf or rewite the answer */ - $natent['enable'] = $_POST['enable'] ? on : off; - $natent['uuid'] = $pconfig['uuid']; - $natent['descr'] = $_POST['descr'] ? $_POST['descr'] : $pconfig['descr']; - $natent['performance'] = $_POST['performance'] ? $_POST['performance'] : $pconfig['performance']; - /* if post = on use on off or rewrite the conf */ - if ($_POST['blockoffenders7'] == "on") { $natent['blockoffenders7'] = on; }else{ $natent['blockoffenders7'] = off; } if ($_POST['enable'] == "") { $natent['blockoffenders7'] = $pconfig['blockoffenders7']; } - $natent['snortalertlogtype'] = $_POST['snortalertlogtype'] ? $_POST['snortalertlogtype'] : $pconfig['snortalertlogtype']; - if ($_POST['alertsystemlog'] == "on") { $natent['alertsystemlog'] = on; }else{ $natent['alertsystemlog'] = off; } if ($_POST['enable'] == "") { $natent['alertsystemlog'] = $pconfig['alertsystemlog']; } - if ($_POST['tcpdumplog'] == "on") { $natent['tcpdumplog'] = on; }else{ $natent['tcpdumplog'] = off; } if ($_POST['enable'] == "") { $natent['tcpdumplog'] = $pconfig['tcpdumplog']; } - if ($_POST['snortunifiedlog'] == "on") { $natent['snortunifiedlog'] = on; }else{ $natent['snortunifiedlog'] = off; } if ($_POST['enable'] == "") { $natent['snortunifiedlog'] = $pconfig['snortunifiedlog']; } - /* if optiion = 0 then the old descr way will not work */ - - /* rewrite the options that are not in post */ - /* make shure values are set befor repost or conf.xml will be broken */ - if ($pconfig['def_ssl_ports_ignore'] != "") { $natent['def_ssl_ports_ignore'] = $pconfig['def_ssl_ports_ignore']; } - if ($pconfig['flow_depth'] != "") { $natent['flow_depth'] = $pconfig['flow_depth']; } - if ($pconfig['perform_stat'] != "") { $natent['perform_stat'] = $pconfig['perform_stat']; } - if ($pconfig['http_inspect'] != "") { $natent['http_inspect'] = $pconfig['http_inspect']; } - if ($pconfig['other_preprocs'] != "") { $natent['other_preprocs'] = $pconfig['other_preprocs']; } - if ($pconfig['ftp_preprocessor'] != "") { $natent['ftp_preprocessor'] = $pconfig['ftp_preprocessor']; } - if ($pconfig['smtp_preprocessor'] != "") { $natent['smtp_preprocessor'] = $pconfig['smtp_preprocessor']; } - if ($pconfig['sf_portscan'] != "") { $natent['sf_portscan'] = $pconfig['sf_portscan']; } - if ($pconfig['dce_rpc_2'] != "") { $natent['dce_rpc_2'] = $pconfig['dce_rpc_2']; } - if ($pconfig['dns_preprocessor'] != "") { $natent['dns_preprocessor'] = $pconfig['dns_preprocessor']; } - if ($pconfig['def_dns_servers'] != "") { $natent['def_dns_servers'] = $pconfig['def_dns_servers']; } - if ($pconfig['def_dns_ports'] != "") { $natent['def_dns_ports'] = $pconfig['def_dns_ports']; } - if ($pconfig['def_smtp_servers'] != "") { $natent['def_smtp_servers'] = $pconfig['def_smtp_servers']; } - if ($pconfig['def_smtp_ports'] != "") { $natent['def_smtp_ports'] = $pconfig['def_smtp_ports']; } - if ($pconfig['def_mail_ports'] != "") { $natent['def_mail_ports'] = $pconfig['def_mail_ports']; } - if ($pconfig['def_http_servers'] != "") { $natent['def_http_servers'] = $pconfig['def_http_servers']; } - if ($pconfig['def_www_servers'] != "") { $natent['def_www_servers'] = $pconfig['def_www_servers']; } - if ($pconfig['def_http_ports'] != "") { $natent['def_http_ports'] = $pconfig['def_http_ports']; } - if ($pconfig['def_sql_servers'] != "") { $natent['def_sql_servers'] = $pconfig['def_sql_servers']; } - if ($pconfig['def_oracle_ports'] != "") { $natent['def_oracle_ports'] = $pconfig['def_oracle_ports']; } - if ($pconfig['def_mssql_ports'] != "") { $natent['def_mssql_ports'] = $pconfig['def_mssql_ports']; } - if ($pconfig['def_telnet_servers'] != "") { $natent['def_telnet_servers'] = $pconfig['def_telnet_servers']; } - if ($pconfig['def_telnet_ports'] != "") { $natent['def_telnet_ports'] = $pconfig['def_telnet_ports']; } - if ($pconfig['def_snmp_servers'] != "") { $natent['def_snmp_servers'] = $pconfig['def_snmp_servers']; } - if ($pconfig['def_snmp_ports'] != "") { $natent['def_snmp_ports'] = $pconfig['def_snmp_ports']; } - if ($pconfig['def_ftp_servers'] != "") { $natent['def_ftp_servers'] = $pconfig['def_ftp_servers']; } - if ($pconfig['def_ftp_ports'] != "") { $natent['def_ftp_ports'] = $pconfig['def_ftp_ports']; } - if ($pconfig['def_ssh_servers'] != "") { $natent['def_ssh_servers'] = $pconfig['def_ssh_servers']; } - if ($pconfig['def_ssh_ports'] != "") { $natent['def_ssh_ports'] = $pconfig['def_ssh_ports']; } - if ($pconfig['def_pop_servers'] != "") { $natent['def_pop_servers'] = $pconfig['def_pop_servers']; } - if ($pconfig['def_pop2_ports'] != "") { $natent['def_pop2_ports'] = $pconfig['def_pop2_ports']; } - if ($pconfig['def_pop3_ports'] != "") { $natent['def_pop3_ports'] = $pconfig['def_pop3_ports']; } - if ($pconfig['def_imap_servers'] != "") { $natent['def_imap_servers'] = $pconfig['def_imap_servers']; } - if ($pconfig['def_imap_ports'] != "") { $natent['def_imap_ports'] = $pconfig['def_imap_ports']; } - if ($pconfig['def_sip_proxy_ip'] != "") { $natent['def_sip_proxy_ip'] = $pconfig['def_sip_proxy_ip']; } - if ($pconfig['def_sip_proxy_ports'] != "") { $natent['def_sip_proxy_ports'] = $pconfig['def_sip_proxy_ports']; } - if ($pconfig['def_auth_ports'] != "") { $natent['def_auth_ports'] = $pconfig['def_auth_ports']; } - if ($pconfig['def_finger_ports'] != "") { $natent['def_finger_ports'] = $pconfig['def_finger_ports']; } - if ($pconfig['def_irc_ports'] != "") { $natent['def_irc_ports'] = $pconfig['def_irc_ports']; } - if ($pconfig['def_nntp_ports'] != "") { $natent['def_nntp_ports'] = $pconfig['def_nntp_ports']; } - if ($pconfig['def_rlogin_ports'] != "") { $natent['def_rlogin_ports'] = $pconfig['def_rlogin_ports']; } - if ($pconfig['def_rsh_ports'] != "") { $natent['def_rsh_ports'] = $pconfig['def_rsh_ports']; } - if ($pconfig['def_ssl_ports'] != "") { $natent['def_ssl_ports'] = $pconfig['def_ssl_ports']; } - if ($pconfig['barnyard_enable'] != "") { $natent['barnyard_enable'] = $pconfig['barnyard_enable']; } - if ($pconfig['barnyard_mysql'] != "") { $natent['barnyard_mysql'] = $pconfig['barnyard_mysql']; } - if ($pconfig['rulesets'] != "") { $natent['rulesets'] = $pconfig['rulesets']; } - if ($pconfig['rule_sid_off'] != "") { $natent['rule_sid_off'] = $pconfig['rule_sid_off']; } - if ($pconfig['rule_sid_on'] != "") { $natent['rule_sid_on'] = $pconfig['rule_sid_on']; } - - - if (isset($id) && $a_nat[$id]) - $a_nat[$id] = $natent; - else { - if (is_numeric($after)) - array_splice($a_nat, $after+1, 0, array($natent)); - else - $a_nat[] = $natent; - } - - write_config(); - - touch("$d_snortconfdirty_path"); - - 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' ); - header( 'Cache-Control: post-check=0, pre-check=0', false ); - header( 'Pragma: no-cache' ); - sleep(2); - header("Location: /snort/snort_interfaces_edit.php?id=$id"); - - //exit; - } -} - - if ($_POST["Submit2"]) { - - sync_snort_package_all($id, $if_real, $snort_uuid); - sync_snort_package(); - sleep(1); - - Running_Start($snort_uuid, $if_real, $id); - - 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' ); - header( 'Cache-Control: post-check=0, pre-check=0', false ); - header( 'Pragma: no-cache' ); - sleep(2); - header("Location: /snort/snort_interfaces_edit.php?id=$id"); - } - - if ($_POST["Submit3"]) - { - - Running_Stop($snort_uuid, $if_real, $id); - - 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' ); - header( 'Cache-Control: post-check=0, pre-check=0', false ); - header( 'Pragma: no-cache' ); - sleep(2); - header("Location: /snort/snort_interfaces_edit.php?id=$id"); - - } - - /* This code needs to be below headers */ - if (isset($config['installedpackages']['snortglobal']['rule'][$id]['interface'])) - { - - $snort_up_ck2_info = Running_Ck($snort_uuid, $if_real, $id); - - if ($snort_up_ck2_info == 'no') { - $snort_up_ck = ''; - }else{ - $snort_up_ck = ''; - } - - }else{ - $snort_up_ck = ''; - } - - -$pgtitle = "Snort: Interface Edit: $id $snort_uuid $if_real"; -include("head.inc"); - -?> - - - - - -

    - - -" method="post" enctype="multipart/form-data" name="iform" id="iform"> - -'; - - if($savemsg) { - print_info_box_np2("{$savemsg}"); - }else{ - print_info_box_np2(' - The Snort configuration has changed and snort needs to be restarted on this interface.
    - You must apply the changes in order for them to take effect.
    - '); - } - } - -?> - -
    -
    +
    @@ -168,7 +245,7 @@ if(!$pgtitle_output) "; + echo "\n"; echo ""; - echo ""; + echo " \n\n"; + echo "\n"; + echo "\n\n\n"; //echo ""; @@ -204,7 +281,7 @@ if(!$pgtitle_output) - +
    "; if(is_array($enabled_rulesets_array)) if(in_array($file, $enabled_rulesets_array)) { @@ -187,11 +264,11 @@ if(!$pgtitle_output) } else $CHECKED = ""; - echo " "; - echo ""; - echo "{$file}"; - echo "\n"; + echo "{$file}\n"; + echo "
    "; //echo "description"; //echo "
     
    Check the rulesets that you would like Snort to load at startup.
     
    - - - -
    - -
    - - - - \n\n"; - ?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      - - // care with spaces - if ($pconfig['enable'] == "on") - $checked = checked; - - $onclick_enable = "onClick=\"enable_change(false)\">"; - - echo " - Enable Interface
    Interface -
    - Choose which interface this rule applies to.
    - Hint: in most cases, you'll want to use WAN here.
    Description - -
    You may enter a description here for your reference (not parsed).
    Memory Performance -
    - Lowmem and ac-bnfa are recommended for low end systems, Ac: high memory, best performance, ac-std: moderate memory,high performance, acs: small memory, moderateperformance, ac-banded: small memory,moderate performance, ac-sparsebands: small memory, high performance.
    -
    Block offenders - onClick="enable_change(false)">
    - Checking this option will automatically block hosts that generate a Snort alert.
    Send alerts to main System logs - onClick="enable_change(false)">
    - Snort will send Alerts to the Pfsense system logs.
    Log to a Tcpdump file - onClick="enable_change(false)">
    - Snort will log packets to a tcpdump-formatted file. The file then can be analyzed by an application such as Wireshark which understands pcap file formats. WARNING: File may become large.
    Log Alerts to a snort unified2 file - onClick="enable_change(false)">
    - Snort will log Alerts to a file in the UNIFIED2 format. This is a requirement for barnyard2.
    - - - - -
     Note: -
    - Please save your settings before you click start.
    -
    -
    - - - - - diff --git a/config/snort/snort_preprocessors.php b/config/snort/snort_preprocessors.php index 25963cbe..d6cbb55d 100644 --- a/config/snort/snort_preprocessors.php +++ b/config/snort/snort_preprocessors.php @@ -119,7 +119,7 @@ if (isset($_GET['dup'])) } /* convert fake interfaces to real */ -$if_real = convert_friendly_interface_to_real_interface_name2($pconfig['interface']); +$if_real = convert_friendly_interface_to_real_interface_name($pconfig['interface']); $snort_uuid = $pconfig['uuid']; @@ -212,7 +212,7 @@ $d_snortconfdirty_path = "/var/run/snort_conf_{$snort_uuid}_{$if_real}.dirty"; $natent['dce_rpc_2'] = $_POST['dce_rpc_2'] ? on : off; $natent['dns_preprocessor'] = $_POST['dns_preprocessor'] ? on : off; - if (isset($id) && $a_nat[$id]) + if (isset($id) && $a_nat[$id]) $a_nat[$id] = $natent; else { if (is_numeric($after)) @@ -220,11 +220,11 @@ $d_snortconfdirty_path = "/var/run/snort_conf_{$snort_uuid}_{$if_real}.dirty"; else $a_nat[] = $natent; } - + write_config(); /* after click go to this page */ - touch($d_snortconfdirty_path); + //touch($d_snortconfdirty_path); 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' ); -- cgit v1.2.3 From 90ab5fb165d4462e419a91e6383abeb9c4dde0fb Mon Sep 17 00:00:00 2001 From: robiscool Date: Mon, 5 Apr 2010 16:54:46 -0700 Subject: snort, rulesets correct iface look --- config/snort/snort_rulesets.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config') diff --git a/config/snort/snort_rulesets.php b/config/snort/snort_rulesets.php index d232c097..0a726a76 100644 --- a/config/snort/snort_rulesets.php +++ b/config/snort/snort_rulesets.php @@ -55,7 +55,7 @@ if (isset($id) && $a_nat[$id]) { } /* convert fake interfaces to real */ -$if_real = convert_friendly_interface_to_real_interface_name2($pconfig['interface']); +$if_real = convert_friendly_interface_to_real_interface_name($pconfig['interface']); $iface_uuid = $a_nat[$id]['uuid']; -- cgit v1.2.3 From 95b4cf32ed4a85b4f7d96e0e2bd9f7ba67930c56 Mon Sep 17 00:00:00 2001 From: robiscool Date: Mon, 5 Apr 2010 18:54:02 -0700 Subject: snort, fix the service path entry --- config/snort/snort.xml | 2 +- config/snort/snort_define_servers.php | 6 +----- config/snort/snort_interfaces.php | 10 ++++++++++ config/snort/snort_preprocessors.php | 7 +------ 4 files changed, 13 insertions(+), 12 deletions(-) (limited to 'config') diff --git a/config/snort/snort.xml b/config/snort/snort.xml index 502438c2..bf053112 100644 --- a/config/snort/snort.xml +++ b/config/snort/snort.xml @@ -58,7 +58,7 @@ snort - snort + /usr/local/bin/snort Snort is the most widely deployed IDS/IPS technology worldwide. diff --git a/config/snort/snort_define_servers.php b/config/snort/snort_define_servers.php index 97e6a28b..b22e206b 100644 --- a/config/snort/snort_define_servers.php +++ b/config/snort/snort_define_servers.php @@ -573,11 +573,7 @@ if($id != "") - + diff --git a/config/snort/snort_interfaces.php b/config/snort/snort_interfaces.php index b83068e1..d11422cc 100644 --- a/config/snort/snort_interfaces.php +++ b/config/snort/snort_interfaces.php @@ -169,6 +169,16 @@ if (isset($_POST['del_x'])) { } write_config(); + sleep(2); + + /* if there are no ifaces do not create snort.sh */ + if (isset($config['installedpackages']['snortglobal']['rule'][0]['enable'])) { + create_snort_sh(); + }else{ + conf_mount_rw(); + exec('/bin/rm /usr/local/etc/rc.d/snort.sh'); + conf_mount_ro(); + } //touch("/var/run/snort_conf_delete.dirty"); diff --git a/config/snort/snort_preprocessors.php b/config/snort/snort_preprocessors.php index d6cbb55d..cb00099e 100644 --- a/config/snort/snort_preprocessors.php +++ b/config/snort/snort_preprocessors.php @@ -224,7 +224,7 @@ $d_snortconfdirty_path = "/var/run/snort_conf_{$snort_uuid}_{$if_real}.dirty"; write_config(); /* after click go to this page */ - //touch($d_snortconfdirty_path); + touch($d_snortconfdirty_path); 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' ); @@ -428,11 +428,6 @@ if($id != "") - -- cgit v1.2.3 From 291c7210947a87dfdf8e347a65b38fc9e00a0955 Mon Sep 17 00:00:00 2001 From: robiscool Date: Tue, 6 Apr 2010 13:39:59 -0700 Subject: snort-old, update deinstall --- config/snort-old/snort.inc | 24 ++++++++++++++++-------- config/snort-old/snort.xml | 2 +- config/snort/snort.xml | 4 ++-- 3 files changed, 19 insertions(+), 11 deletions(-) (limited to 'config') diff --git a/config/snort-old/snort.inc b/config/snort-old/snort.inc index 00a86c35..74a863ad 100755 --- a/config/snort-old/snort.inc +++ b/config/snort-old/snort.inc @@ -152,7 +152,7 @@ function sync_package_snort() if ($snortbarnyardlog_info_chk == on) $start .= "\nsleep 4;/usr/local/bin/barnyard2 -c /usr/local/etc/barnyard2.conf -d /var/log/snort -f snort.u2 -w /usr/local/etc/snort/barnyard2.waldo -D -q\n"; } - $check_if_snort_runs = "\n\tif [ \"`ls -A /usr/local/etc/snort/rules`\" ] ; then\n\techo \"rules exist\"\n\telse\n\techo \"rules DONT exist\"\n\texit 2\n\tfi \n\n\tif [ \"`pgrep -x snort`\" = \"\" ] ; then\n\t/bin/rm /tmp/snort.sh.pid\n\tfi \n\n\tif [ \"`pgrep -x snort`\" != \"\" ] ; then\n\tlogger -p daemon.info -i -t SnortStartup \"Snort already running...\"\n\t/usr/local/bin/php -f /usr/local/pkg/pf/snort_dynamic_ip_reload.php\n\texit 1\n\tfi\n\n"; + $check_if_snort_runs = "\n\tif [ \"`ls -A /usr/local/etc/snort/rules`\" ] ; then\n\techo \"rules exist\"\n\telse\n\techo \"rules DONT exist\"\n\texit 2\n\tfi \n\n\tif [ \"`pgrep -x snort`\" = \"\" ] ; then\n\t/bin/rm /tmp/snort.sh.pid\n\tfi \n\n\tif [ \"`pgrep -x snort`\" != \"\" ] ; then\n\tlogger -p daemon.info -i -t SnortStartup \"Snort already running...\"\n\t/usr/local/bin/php -f /usr/local/pkg/pf/snort_dynamic_ip_reload.php &\n\texit 1\n\tfi\n\n"; $if_snort_pid = "\nif ls /tmp/snort.sh.pid > /dev/null\nthen\n echo \"snort.sh is running\"\n exit 0\nelse\n echo \"snort.sh is not running\"\nfi\n"; $echo_snort_sh_pid = "\necho \"snort.sh run\" > /tmp/snort.sh.pid\n"; $echo_snort_sh_startup_log = "\necho \"snort.sh run\" >> /tmp/snort.sh_startup.log\n"; @@ -290,7 +290,9 @@ function create_snort_conf() { function snort_deinstall() { global $config, $g; - + conf_mount_rw(); + + /* remove custom sysctl */ remove_text_from_file("/etc/sysctl.conf", "sysctl net.bpf.bufsize=20480"); /* decrease bpf buffers back to 4096, from 20480 */ @@ -361,12 +363,18 @@ function snort_deinstall() { snort_rm_blocked_deinstall_cron(""); snort_rules_up_deinstall_cron(""); - - /* Unset snort registers in conf.xml IMPORTANT snort will not start with out this */ - /* Keep this as a last step */ - unset($config['installedpackages']['snort']['config'][0]['autorulesupdate7']); - unset($config['installedpackages']['snort']['config'][0]['rm_blocked']); - write_config(); +/* Unset snort registers in conf.xml IMPORTANT snort will not start with out this */ +/* Keep this as a last step */ + +unset($config['installedpackages']['snort']); +unset($config['installedpackages']['snortdefservers']); +unset($config['installedpackages']['snortwhitelist']); +unset($config['installedpackages']['snortthreshold']); +unset($config['installedpackages']['snortadvanced']); + + +write_config(); +conf_mount_ro(); } diff --git a/config/snort-old/snort.xml b/config/snort-old/snort.xml index 6f067f2d..3bc40fce 100644 --- a/config/snort-old/snort.xml +++ b/config/snort-old/snort.xml @@ -47,7 +47,7 @@ Currently there are no FAQ items provided. Snort 2.8.4.1_5 - Services: Snort 2.8.4.1_5 pkg v. 1.7 + Services: Snort 2.8.4.1_5 pkg v. 1.8 /usr/local/pkg/snort.inc Snort diff --git a/config/snort/snort.xml b/config/snort/snort.xml index bf053112..0a3eb7a3 100644 --- a/config/snort/snort.xml +++ b/config/snort/snort.xml @@ -57,8 +57,8 @@ snort - - /usr/local/bin/snort + snort.sh + snort Snort is the most widely deployed IDS/IPS technology worldwide. -- cgit v1.2.3 From ad41f98973dd49302885bd66a096263257ee62e4 Mon Sep 17 00:00:00 2001 From: robiscool Date: Tue, 6 Apr 2010 14:39:47 -0700 Subject: snort, start work on nanobsd code --- config/snort/snort.inc | 87 +++++++++++++++++++++++++++----------------------- 1 file changed, 47 insertions(+), 40 deletions(-) (limited to 'config') diff --git a/config/snort/snort.inc b/config/snort/snort.inc index 61449c30..5a967f3d 100644 --- a/config/snort/snort.inc +++ b/config/snort/snort.inc @@ -209,13 +209,18 @@ function snort_postinstall() global $config; conf_mount_rw(); - if(!file_exists("/var/log/snort/")) { - mwexec("mkdir -p /var/log/snort/"); - mwexec("mkdir -p /var/log/snort/barnyard2"); + if(!file_exists('/var/log/snort/')) { + mwexec('mkdir -p /var/log/snort/'); + mwexec('mkdir -p /var/log/snort/barnyard2'); } - if(!file_exists("/var/log/snort/alert")) - touch("/var/log/snort/alert"); + if(!file_exists('/var/log/snort/alert')) { + touch('/var/log/snort/alert'); + }else{ + exec('/bin/rm -rf /var/log/snort/*'); + touch('/var/log/snort/alert'); + } + /* snort -> advanced features */ $bpfbufsize = $config['installedpackages']['snortglobal']['bpfbufsize']; @@ -224,47 +229,47 @@ function snort_postinstall() /* create a few directories and ensure the sample files are in place */ - exec("/bin/mkdir -p /usr/local/etc/snort"); - exec("/bin/mkdir -p /var/log/snort"); - exec("/bin/mkdir -p /usr/local/etc/snort/rules"); + exec('/bin/mkdir -p /usr/local/etc/snort'); + exec('/bin/mkdir -p /var/log/snort'); + exec('/bin/mkdir -p /usr/local/etc/snort/rules'); - if(file_exists("/usr/local/etc/snort/snort.conf-sample")) + if(file_exists('/usr/local/etc/snort/snort.conf-sample')) { - exec("/bin/rm /usr/local/etc/snort/snort.conf-sample"); - exec("/bin/rm /usr/local/etc/snort/threshold.conf-sample"); - exec("/bin/rm /usr/local/etc/snort/sid-msg.map-sample"); - exec("/bin/rm /usr/local/etc/snort/unicode.map-sample"); - exec("/bin/rm /usr/local/etc/snort/classification.config-sample"); - exec("/bin/rm /usr/local/etc/snort/generators-sample"); - exec("/bin/rm /usr/local/etc/snort/reference.config-sample"); - exec("/bin/rm /usr/local/etc/snort/gen-msg.map-sample"); - exec("/bin/rm /usr/local/etc/snort/sid"); - exec("/bin/rm /usr/local/etc/rc.d/snort"); - exec("/bin/rm /usr/local/etc/rc.d/bardyard2"); + exec('/bin/rm /usr/local/etc/snort/snort.conf-sample'); + exec('/bin/rm /usr/local/etc/snort/threshold.conf-sample'); + exec('/bin/rm /usr/local/etc/snort/sid-msg.map-sample'); + exec('/bin/rm /usr/local/etc/snort/unicode.map-sample'); + exec('/bin/rm /usr/local/etc/snort/classification.config-sample'); + exec('/bin/rm /usr/local/etc/snort/generators-sample'); + exec('/bin/rm /usr/local/etc/snort/reference.config-sample'); + exec('/bin/rm /usr/local/etc/snort/gen-msg.map-sample'); + exec('/bin/rm /usr/local/etc/snort/sid'); + exec('/bin/rm /usr/local/etc/rc.d/snort'); + exec('/bin/rm /usr/local/etc/rc.d/bardyard2'); } - if(!file_exists("/usr/local/etc/snort/custom_rules")) + if(!file_exists('/usr/local/etc/snort/custom_rules')) { - exec("/bin/mkdir -p /usr/local/etc/snort/custom_rules/"); + exec('/bin/mkdir -p /usr/local/etc/snort/custom_rules/'); } - exec("/usr/sbin/pw groupadd snort"); + exec('/usr/sbin/pw groupadd snort'); exec('/usr/sbin/pw useradd snort -c "SNORT USER" -d /nonexistent -g snort -s /sbin/nologin'); - exec("/usr/sbin/chown -R snort:snort /var/log/snort"); - exec("/usr/sbin/chown -R snort:snort /usr/local/etc/snort"); - exec("/usr/sbin/chown -R snort:snort /usr/local/lib/snort"); - exec("/bin/chmod -R 755 /var/log/snort"); - exec("/bin/chmod -R 755 /usr/local/etc/snort"); - exec("/bin/chmod -R 755 /usr/local/lib/snort"); + exec('/usr/sbin/chown -R snort:snort /var/log/snort'); + exec('/usr/sbin/chown -R snort:snort /usr/local/etc/snort'); + exec('/usr/sbin/chown -R snort:snort /usr/local/lib/snort'); + exec('/bin/chmod -R 755 /var/log/snort'); + exec('/bin/chmod -R 755 /usr/local/etc/snort'); + exec('/bin/chmod -R 755 /usr/local/lib/snort'); /* remove example files */ - if(file_exists("/usr/local/lib/snort/dynamicrules/lib_sfdynamic_example_rule.so.0")) + if(file_exists('/usr/local/lib/snort/dynamicrules/lib_sfdynamic_example_rule.so.0')) { exec('/bin/rm /usr/local/lib/snort/dynamicrules/lib_sfdynamic_example*'); } - if(file_exists("/usr/local/lib/snort/dynamicpreprocessor/lib_sfdynamic_preprocessor_example.so")) + 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*'); } @@ -1118,24 +1123,26 @@ function create_snort_conf($id, $if_real, $snort_uuid) function snort_deinstall() { - global $config, $g, $id, $if_real; + global $config, $g; conf_mount_rw(); /* remove custom sysctl */ remove_text_from_file("/etc/sysctl.conf", "sysctl net.bpf.bufsize=20480"); /* decrease bpf buffers back to 4096, from 20480 */ - exec("/sbin/sysctl net.bpf.bufsize=4096"); - exec("/usr/usr/bin/killall snort"); + exec('/sbin/sysctl net.bpf.bufsize=4096'); + exec('/usr/usr/bin/killall snort'); sleep(2); - exec("/usr/usr/bin/killall -9 snort"); + exec('/usr/usr/bin/killall -9 snort'); sleep(2); - exec("/usr/usr/bin/killall barnyard2"); + exec('/usr/usr/bin/killall barnyard2'); sleep(2); - exec("/usr/usr/bin/killall -9 barnyard2"); + exec('/usr/usr/bin/killall -9 barnyard2'); sleep(2); - exec("/usr/sbin/pw userdel snort"); - exec("/usr/sbin/pw groupdel snort"); - exec("rm -rf /usr/local/etc/snort*"); + exec('/usr/sbin/pw userdel snort'); + exec('/usr/sbin/pw groupdel snort'); + exec('rm -rf /usr/local/etc/snort*'); + exec('rm -rf /usr/local/pkg/snort*'); + exec('rm -rf /usr/local/pkg/pf/snort*'); //exec("cd /var/db/pkg && pkg_delete `ls | grep barnyard2`"); exec("cd /var/db/pkg && pkg_delete `ls | grep snort`"); /* TODO: figure out how to detect pfsense packages that use the same freebsd pkckages and not deinstall */ -- cgit v1.2.3 From 01bfd5a0ef9a057149f933b6fcbea377cfc32687 Mon Sep 17 00:00:00 2001 From: robiscool Date: Tue, 6 Apr 2010 20:18:51 -0700 Subject: snort, add snort-old deinstall xml, fix vlan --- config/snort/snort.inc | 53 ++++++++++++++++----------- config/snort/snort_barnyard.php | 2 +- config/snort/snort_check_for_rule_updates.php | 2 +- config/snort/snort_define_servers.php | 2 +- config/snort/snort_download_rules.php | 2 +- config/snort/snort_interfaces.php | 12 +++--- config/snort/snort_interfaces_edit.php | 8 ++-- config/snort/snort_interfaces_global.php | 6 +-- config/snort/snort_preprocessors.php | 2 +- config/snort/snort_rules.php | 2 +- config/snort/snort_rules_edit.php | 2 +- config/snort/snort_rulesets.php | 2 +- 12 files changed, 51 insertions(+), 44 deletions(-) (limited to 'config') diff --git a/config/snort/snort.inc b/config/snort/snort.inc index 5a967f3d..d4af6b85 100644 --- a/config/snort/snort.inc +++ b/config/snort/snort.inc @@ -67,7 +67,7 @@ $pfsense_theme_is = $config['theme']; /* use ob_clean to clear output buffer, this code needs to be watched */ ob_clean(); - $snort_up_prell = exec("/usr/bin/top -a -U snort -u | grep -v grep | grep \"R {$snort_uuid}_{$if_real}\" | awk '{print \$1;}'", $retval); + $snort_up_prell = exec("/usr/bin/top -a -U snort -u | grep -v grep | grep \"R {$snort_uuid}{$if_real}\" | awk '{print \$1;}'", $retval); if ($snort_up_prell != "") { $snort_uph = 'yes'; @@ -113,7 +113,7 @@ $pfsense_theme_is = $config['theme']; function Running_Stop($snort_uuid, $if_real, $id) { global $config; - $start_up_pre = exec("/usr/bin/top -a -U snort -u | grep -v grep | grep \"R {$snort_uuid}_{$if_real}\" | awk '{print \$1;}'"); + $start_up_pre = exec("/usr/bin/top -a -U snort -u | grep -v grep | grep \"R {$snort_uuid}{$if_real}\" | awk '{print \$1;}'"); $start_up_s = exec("/usr/bin/top -U snort -u | grep snort | grep {$start_up_pre} | awk '{ print $1; }'"); $start_up_r = exec("/usr/bin/top -U root -u | grep snort | grep {$start_up_pre} | awk '{ print $1; }'"); @@ -158,7 +158,7 @@ $pfsense_theme_is = $config['theme']; $snort_info_chk = $config['installedpackages']['snortglobal']['rule'][$id]['enable']; if ($snort_info_chk == 'on') { - exec("/usr/local/bin/snort -u snort -g snort -R \"{$snort_uuid}_{$if_real}\" -D -q -l /var/log/snort -G {$snort_uuid} -c /usr/local/etc/snort/snort_{$snort_uuid}_{$if_real}/snort.conf -i {$if_real}"); + exec("/usr/local/bin/snort -u snort -g snort -R \"{$snort_uuid}{$if_real}\" -D -q -l /var/log/snort -G {$snort_uuid} -c /usr/local/etc/snort/snort_{$snort_uuid}_{$if_real}/snort.conf -i {$if_real}"); } /* define snortbarnyardlog_chk */ /* top will have trouble if the uuid is to far back */ @@ -177,7 +177,7 @@ function convert_friendly_interface_to_real_interface_name2($interface) { global $config; - $lc_interface = strtolower($interface); + $lc_interface = strtolower($interface); if($lc_interface == "lan") return $config['interfaces']['lan']['if']; if($lc_interface == "wan") return $config['interfaces']['wan']['if']; $ifdescrs = array(); @@ -194,7 +194,7 @@ function convert_friendly_interface_to_real_interface_name2($interface) return $interface; } -$if_real_wan = convert_friendly_interface_to_real_interface_name2($interface_fake); +//$if_real_wan = convert_friendly_interface_to_real_interface_name2($interface_fake); /* Allow additional execution time 0 = no limit. */ ini_set('max_execution_time', '9999'); @@ -323,6 +323,16 @@ function snort_postinstall() /* back to default */ chdir ("/root/"); + /* make sure snort-pld is deinstalled */ + /* remove when snort-old is removed */ + unset($config['installedpackages']['snort']); + unset($config['installedpackages']['snortdefservers']); + unset($config['installedpackages']['snortwhitelist']); + unset($config['installedpackages']['snortthreshold']); + unset($config['installedpackages']['snortadvanced']); + write_config(); + conf_mount_rw(); + conf_mount_ro(); } @@ -595,7 +605,7 @@ class array_ereg { $id += 1; $result_lan = $config['installedpackages']['snortglobal']['rule'][$id]['interface']; - $if_real = convert_friendly_interface_to_real_interface_name($result_lan); + $if_real = convert_friendly_interface_to_real_interface_name2($result_lan); $snort_rules_list[] = "snort_$id$if_real"; @@ -659,7 +669,7 @@ if ($id != '' && $if_real != '') //new $snort_uuid = $config['installedpackages']['snortglobal']['rule'][$id]['uuid']; $result_lan = $config['installedpackages']['snortglobal']['rule'][$id]['interface']; - $if_real = convert_friendly_interface_to_real_interface_name($result_lan); + $if_real = convert_friendly_interface_to_real_interface_name2($result_lan); /* create snort configuration file */ create_snort_conf($id, $if_real, $snort_uuid); @@ -706,7 +716,7 @@ function sync_snort_package_empty() $id += 1; $result_lan = $config['installedpackages']['snortglobal']['rule'][$id]['interface']; - $if_real = convert_friendly_interface_to_real_interface_name($result_lan); + $if_real = convert_friendly_interface_to_real_interface_name2($result_lan); $snort_uuid = $config['installedpackages']['snortglobal']['rule'][$id]['uuid']; if ($if_real != '' && $snort_uuid != '') { @@ -758,7 +768,7 @@ function sync_snort_package_config() $id += 1; $result_lan = $config['installedpackages']['snortglobal']['rule'][$id]['interface']; - $if_real = convert_friendly_interface_to_real_interface_name($result_lan); + $if_real = convert_friendly_interface_to_real_interface_name2($result_lan); $snort_uuid = $config['installedpackages']['snortglobal']['rule'][$id]['uuid']; if ($if_real != '' && $snort_uuid != '') { @@ -808,7 +818,7 @@ function create_snort_sh() $snort_uuid = $config['installedpackages']['snortglobal']['rule'][$id]['uuid']; $result_lan = $config['installedpackages']['snortglobal']['rule'][$id]['interface']; - $if_real = convert_friendly_interface_to_real_interface_name($result_lan); + $if_real = convert_friendly_interface_to_real_interface_name2($result_lan); /* define snortbarnyardlog_chk */ $snortbarnyardlog_info_chk = $config['installedpackages']['snortglobal']['rule'][$id]['barnyard_enable']; @@ -824,7 +834,7 @@ $snort_sh_text2[] = << /tmp/snort.sh.pid @@ -832,7 +842,7 @@ $snort_sh_text2[] = << @@ -361,7 +361,7 @@ padding: 15px 10px 50% 50px; /* convert fake interfaces to real and check if iface is up */ /* There has to be a smarter way to do this */ - $if_real = convert_friendly_interface_to_real_interface_name($natent['interface']); + $if_real = convert_friendly_interface_to_real_interface_name2($natent['interface']); $snort_uuid = $natent['uuid']; $tester2 = Running_Ck($snort_uuid, $if_real, $id); diff --git a/config/snort/snort_interfaces_edit.php b/config/snort/snort_interfaces_edit.php index dddca3af..cba0cc8a 100644 --- a/config/snort/snort_interfaces_edit.php +++ b/config/snort/snort_interfaces_edit.php @@ -74,7 +74,7 @@ while ($snort_uuid > 65535 || $snort_uuid == 0) { } /* convert fake interfaces to real */ -$if_real = convert_friendly_interface_to_real_interface_name($a_nat[$id]['interface']); +$if_real = convert_friendly_interface_to_real_interface_name2($a_nat[$id]['interface']); if ($config['installedpackages']['snortglobal']['rule'][$id]['uuid'] != '') { $snort_uuid = $config['installedpackages']['snortglobal']['rule'][$id]['uuid']; @@ -162,7 +162,7 @@ $d_snortconfdirty_path = "/var/run/snort_conf_{$snort_uuid}_{$if_real}.dirty"; write_config(); - $if_real = convert_friendly_interface_to_real_interface_name($a_nat[$id]['interface']); + $if_real = convert_friendly_interface_to_real_interface_name2($a_nat[$id]['interface']); sync_snort_package_all($id, $if_real, $snort_uuid); sync_snort_package(); @@ -202,7 +202,7 @@ if ($_POST["Submit"]) { $id_c += 1; $result_lan = $config['installedpackages']['snortglobal']['rule'][$id_c]['interface']; - $if_real = convert_friendly_interface_to_real_interface_name($result_lan); + $if_real = convert_friendly_interface_to_real_interface_name2($result_lan); if ($_POST['interface'] == $result_lan) { $input_errors[] = "Interface $result_lan is in use. Please select another interface."; @@ -457,7 +457,7 @@ if ($a_nat[$id]['interface'] != '') { //print_r($if_array); if($if_array) { foreach($if_array as $iface2) { - $if2 = convert_friendly_interface_to_real_interface_name($iface2); + $if2 = convert_friendly_interface_to_real_interface_name2($iface2); if($config['interfaces'][$iface2]['ipaddr'] == "pppoe") { $if2 = "ng0"; diff --git a/config/snort/snort_interfaces_global.php b/config/snort/snort_interfaces_global.php index 648b5bda..3c487ce0 100644 --- a/config/snort/snort_interfaces_global.php +++ b/config/snort/snort_interfaces_global.php @@ -369,11 +369,7 @@ include("head.inc"); - + diff --git a/config/snort/snort_preprocessors.php b/config/snort/snort_preprocessors.php index cb00099e..0d7fdde3 100644 --- a/config/snort/snort_preprocessors.php +++ b/config/snort/snort_preprocessors.php @@ -119,7 +119,7 @@ if (isset($_GET['dup'])) } /* convert fake interfaces to real */ -$if_real = convert_friendly_interface_to_real_interface_name($pconfig['interface']); +$if_real = convert_friendly_interface_to_real_interface_name2($pconfig['interface']); $snort_uuid = $pconfig['uuid']; diff --git a/config/snort/snort_rules.php b/config/snort/snort_rules.php index c95d76ca..b5fa2fb2 100644 --- a/config/snort/snort_rules.php +++ b/config/snort/snort_rules.php @@ -52,7 +52,7 @@ if (isset($id) && $a_nat[$id]) { } /* convert fake interfaces to real */ -$if_real = convert_friendly_interface_to_real_interface_name($pconfig['interface']); +$if_real = convert_friendly_interface_to_real_interface_name2($pconfig['interface']); $iface_uuid = $a_nat[$id]['uuid']; diff --git a/config/snort/snort_rules_edit.php b/config/snort/snort_rules_edit.php index b770867f..759193c8 100644 --- a/config/snort/snort_rules_edit.php +++ b/config/snort/snort_rules_edit.php @@ -65,7 +65,7 @@ if (isset($id) && $a_nat[$id]) { } /* convert fake interfaces to real */ -$if_real = convert_friendly_interface_to_real_interface_name($pconfig['interface']); +$if_real = convert_friendly_interface_to_real_interface_name2($pconfig['interface']); $file = $_GET['openruleset']; diff --git a/config/snort/snort_rulesets.php b/config/snort/snort_rulesets.php index 0a726a76..d232c097 100644 --- a/config/snort/snort_rulesets.php +++ b/config/snort/snort_rulesets.php @@ -55,7 +55,7 @@ if (isset($id) && $a_nat[$id]) { } /* convert fake interfaces to real */ -$if_real = convert_friendly_interface_to_real_interface_name($pconfig['interface']); +$if_real = convert_friendly_interface_to_real_interface_name2($pconfig['interface']); $iface_uuid = $a_nat[$id]['uuid']; -- cgit v1.2.3 From 7b1f60f4e1420aaf5038a945b5997f1b4d4d3d29 Mon Sep 17 00:00:00 2001 From: thompsa Date: Thu, 8 Apr 2010 15:42:49 +1200 Subject: Use fixed uid/gid to keep the numbers < 2000, above this is reserved in pfSense 2.0+. 558 was taken from the avahi entry in /usr/ports/UIDs and /usr/ports/GIDs. --- config/avahi/avahi.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'config') diff --git a/config/avahi/avahi.inc b/config/avahi/avahi.inc index a06485c5..d8ab263b 100644 --- a/config/avahi/avahi.inc +++ b/config/avahi/avahi.inc @@ -56,8 +56,8 @@ function avahi_install() { } // Add needed users and groups - exec("/usr/sbin/pw useradd avahi"); - exec("/usr/sbin/pw groupadd avahi"); + exec("/usr/sbin/pw useradd avahi -u 558"); + exec("/usr/sbin/pw groupadd avahi -g 558"); // Make image RO conf_mount_ro(); -- cgit v1.2.3 From bd635a0d1336e21b1940452e594b44df5f90915a Mon Sep 17 00:00:00 2001 From: thompsa Date: Thu, 8 Apr 2010 15:46:13 +1200 Subject: Use fixed uid/gid to keep the numbers < 2000, above this is reserved in pfSense 2.0+. 920 was taken from the vboxusers entry in /usr/ports/UIDs and /usr/ports/GIDs as there is no default value for snort and this is unlikely to ever be used. While I am here turn off the loudhailer for the snort user description. --- config/snort/snort.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'config') diff --git a/config/snort/snort.inc b/config/snort/snort.inc index d4af6b85..cd2f9946 100644 --- a/config/snort/snort.inc +++ b/config/snort/snort.inc @@ -253,8 +253,8 @@ function snort_postinstall() exec('/bin/mkdir -p /usr/local/etc/snort/custom_rules/'); } - exec('/usr/sbin/pw groupadd snort'); - exec('/usr/sbin/pw useradd snort -c "SNORT USER" -d /nonexistent -g snort -s /sbin/nologin'); + exec('/usr/sbin/pw groupadd snort -g 920'); + exec('/usr/sbin/pw useradd snort -u 920 -c "Snort User" -d /nonexistent -g snort -s /sbin/nologin'); exec('/usr/sbin/chown -R snort:snort /var/log/snort'); exec('/usr/sbin/chown -R snort:snort /usr/local/etc/snort'); exec('/usr/sbin/chown -R snort:snort /usr/local/lib/snort'); -- cgit v1.2.3 From 107e44d435f9805003de709a1b9d36f0a3cbb05a Mon Sep 17 00:00:00 2001 From: thompsa Date: Thu, 8 Apr 2010 15:55:24 +1200 Subject: Fixed; 2.0 group snort gets lost on reboot. --- config/snort/NOTES.txt | 2 -- 1 file changed, 2 deletions(-) (limited to 'config') diff --git a/config/snort/NOTES.txt b/config/snort/NOTES.txt index b8c61c39..0bfae161 100644 --- a/config/snort/NOTES.txt +++ b/config/snort/NOTES.txt @@ -7,8 +7,6 @@ Final day. Odds and ends left. -2.0 group snort gets lost on reboot. - Pierre POMES code needs to be added. Threshold tab needs to be added. -- cgit v1.2.3 From e8fa9505ad3c402bf4a5b5143842c0028382a658 Mon Sep 17 00:00:00 2001 From: robiscool Date: Wed, 7 Apr 2010 23:40:40 -0700 Subject: snort, add passthrough option --- config/snort/snort.inc | 11 +++++++++++ config/snort/snort_barnyard.php | 20 +++++++++++++++++--- config/snort/snort_define_servers.php | 5 ++++- config/snort/snort_interfaces.php | 2 +- config/snort/snort_interfaces_edit.php | 12 ++++++++++++ config/snort/snort_preprocessors.php | 4 ++++ 6 files changed, 49 insertions(+), 5 deletions(-) (limited to 'config') diff --git a/config/snort/snort.inc b/config/snort/snort.inc index cd2f9946..104c1a5a 100644 --- a/config/snort/snort.inc +++ b/config/snort/snort.inc @@ -1055,6 +1055,8 @@ function generate_barnyard2_conf($id, $if_real, $snort_uuid) { $snortbarnyardlog_database_info_chk = $config['installedpackages']['snortglobal']['rule'][$id]['barnyard_mysql']; $snortbarnyardlog_hostname_info_chk = exec("/bin/hostname"); +/* user add arguments */ +$snortbarnyardlog_config_pass_thru = str_replace("\r", "", base64_decode($config['installedpackages']['snortglobal']['rule'][$id]['barnconfigpassthru'])); $barnyard2_conf_text = << document.iform.barnyard_mysql.disabled = endis; + document.iform.barnconfigpassthru.disabled = endis; } //--> @@ -409,8 +415,16 @@ if($id != "") Log to a Mysql Database - -
    Example: output database: log, mysql, dbname=snort user=snort host=localhost password=xyz + +
    Example: output database: alert, mysql, dbname=snort user=snort host=localhost password=xyz
    + Example: output database: log, mysql, dbname=snort user=snort host=localhost password=xyz
    + + + Advanced configuration pass through + + +
    + Arguments here will be automatically inserted into the running barnyard2 configuration.   diff --git a/config/snort/snort_define_servers.php b/config/snort/snort_define_servers.php index 5e9b0f31..9641b767 100644 --- a/config/snort/snort_define_servers.php +++ b/config/snort/snort_define_servers.php @@ -117,6 +117,8 @@ if (isset($id) && $a_nat[$id]) { $pconfig['alertsystemlog'] = $a_nat[$id]['alertsystemlog']; $pconfig['tcpdumplog'] = $a_nat[$id]['tcpdumplog']; $pconfig['snortunifiedlog'] = $a_nat[$id]['snortunifiedlog']; + $pconfig['configpassthru'] = $a_nat[$id]['configpassthru']; + $pconfig['barnconfigpassthru'] = $a_nat[$id]['barnconfigpassthru']; $pconfig['rulesets'] = $a_nat[$id]['rulesets']; $pconfig['rule_sid_off'] = $a_nat[$id]['rule_sid_off']; $pconfig['rule_sid_on'] = $a_nat[$id]['rule_sid_on']; @@ -166,7 +168,8 @@ $d_snortconfdirty_path = "/var/run/snort_conf_{$snort_uuid}_{$if_real}.dirty"; if ($pconfig['rulesets'] != "") { $natent['rulesets'] = $pconfig['rulesets']; } if ($pconfig['rule_sid_off'] != "") { $natent['rule_sid_off'] = $pconfig['rule_sid_off']; } if ($pconfig['rule_sid_on'] != "") { $natent['rule_sid_on'] = $pconfig['rule_sid_on']; } - + if ($pconfig['configpassthru'] != "") { $natent['configpassthru'] = $pconfig['configpassthru']; } + if ($pconfig['barnconfigpassthru'] != "") { $natent['barnconfigpassthru'] = $pconfig['barnconfigpassthru']; } /* post new options */ if ($_POST['def_dns_servers'] != "") { $natent['def_dns_servers'] = $_POST['def_dns_servers']; }else{ $natent['def_dns_servers'] = ""; } diff --git a/config/snort/snort_interfaces.php b/config/snort/snort_interfaces.php index 30fed8e5..5f42725f 100644 --- a/config/snort/snort_interfaces.php +++ b/config/snort/snort_interfaces.php @@ -241,7 +241,7 @@ if ($_GET['act'] == 'toggle' && $_GET['id'] != '') -$pgtitle = "Services: Snort 2.8.5.3 pkg v. 1.20"; +$pgtitle = "Services: Snort 2.8.5.3 pkg v. 1.21"; include("head.inc"); ?> diff --git a/config/snort/snort_interfaces_edit.php b/config/snort/snort_interfaces_edit.php index cba0cc8a..b63bbfbd 100644 --- a/config/snort/snort_interfaces_edit.php +++ b/config/snort/snort_interfaces_edit.php @@ -138,6 +138,8 @@ if (isset($id) && $a_nat[$id]) { $pconfig['alertsystemlog'] = $a_nat[$id]['alertsystemlog']; $pconfig['tcpdumplog'] = $a_nat[$id]['tcpdumplog']; $pconfig['snortunifiedlog'] = $a_nat[$id]['snortunifiedlog']; + $pconfig['configpassthru'] = base64_decode($a_nat[$id]['configpassthru']); + $pconfig['barnconfigpassthru'] = $a_nat[$id]['barnconfigpassthru']; $pconfig['rulesets'] = $a_nat[$id]['rulesets']; $pconfig['rule_sid_off'] = $a_nat[$id]['rule_sid_off']; $pconfig['rule_sid_on'] = $a_nat[$id]['rule_sid_on']; @@ -235,6 +237,7 @@ if ($_POST["Submit"]) { if ($_POST['alertsystemlog'] == "on") { $natent['alertsystemlog'] = on; }else{ $natent['alertsystemlog'] = off; } if ($_POST['enable'] == "") { $natent['alertsystemlog'] = $pconfig['alertsystemlog']; } if ($_POST['tcpdumplog'] == "on") { $natent['tcpdumplog'] = on; }else{ $natent['tcpdumplog'] = off; } if ($_POST['enable'] == "") { $natent['tcpdumplog'] = $pconfig['tcpdumplog']; } if ($_POST['snortunifiedlog'] == "on") { $natent['snortunifiedlog'] = on; }else{ $natent['snortunifiedlog'] = off; } if ($_POST['enable'] == "") { $natent['snortunifiedlog'] = $pconfig['snortunifiedlog']; } + $natent['configpassthru'] = base64_encode($_POST['configpassthru']) ? base64_encode($_POST['configpassthru']) : $pconfig['configpassthru']; /* if optiion = 0 then the old descr way will not work */ /* rewrite the options that are not in post */ @@ -284,6 +287,7 @@ if ($_POST["Submit"]) { if ($pconfig['def_ssl_ports'] != "") { $natent['def_ssl_ports'] = $pconfig['def_ssl_ports']; } if ($pconfig['barnyard_enable'] != "") { $natent['barnyard_enable'] = $pconfig['barnyard_enable']; } if ($pconfig['barnyard_mysql'] != "") { $natent['barnyard_mysql'] = $pconfig['barnyard_mysql']; } + if ($pconfig['barnconfigpassthru'] != "") { $natent['barnconfigpassthru'] = $pconfig['barnconfigpassthru']; } if ($pconfig['rulesets'] != "") { $natent['rulesets'] = $pconfig['rulesets']; } if ($pconfig['rule_sid_off'] != "") { $natent['rule_sid_off'] = $pconfig['rule_sid_off']; } if ($pconfig['rule_sid_on'] != "") { $natent['rule_sid_on'] = $pconfig['rule_sid_on']; } @@ -408,6 +412,7 @@ echo " document.iform.alertsystemlog.disabled = endis; document.iform.tcpdumplog.disabled = endis; document.iform.snortunifiedlog.disabled = endis; + document.iform.configpassthru.disabled = endis; } //--> @@ -580,6 +585,13 @@ if ($a_nat[$id]['interface'] != '') { onClick="enable_change(false)">
    Snort will log Alerts to a file in the UNIFIED2 format. This is a requirement for barnyard2. + + Advanced configuration pass through + + +
    + Arguments here will be automatically inserted into the running snort configuration. + diff --git a/config/snort/snort_preprocessors.php b/config/snort/snort_preprocessors.php index 0d7fdde3..1d3abf0b 100644 --- a/config/snort/snort_preprocessors.php +++ b/config/snort/snort_preprocessors.php @@ -110,6 +110,8 @@ if (isset($id) && $a_nat[$id]) { $pconfig['tcpdumplog'] = $a_nat[$id]['tcpdumplog']; $pconfig['snortunifiedlog'] = $a_nat[$id]['snortunifiedlog']; $pconfig['flow_depth'] = $a_nat[$id]['flow_depth']; + $pconfig['configpassthru'] = $a_nat[$id]['configpassthru']; + $pconfig['barnconfigpassthru'] = $a_nat[$id]['barnconfigpassthru']; $pconfig['rulesets'] = $a_nat[$id]['rulesets']; $pconfig['rule_sid_off'] = $a_nat[$id]['rule_sid_off']; $pconfig['rule_sid_on'] = $a_nat[$id]['rule_sid_on']; @@ -195,6 +197,8 @@ $d_snortconfdirty_path = "/var/run/snort_conf_{$snort_uuid}_{$if_real}.dirty"; if ($pconfig['def_rlogin_ports'] != "") { $natent['def_rlogin_ports'] = $pconfig['def_rlogin_ports']; } if ($pconfig['def_rsh_ports'] != "") { $natent['def_rsh_ports'] = $pconfig['def_rsh_ports']; } if ($pconfig['def_ssl_ports'] != "") { $natent['def_ssl_ports'] = $pconfig['def_ssl_ports']; } + if ($pconfig['configpassthru'] != "") { $natent['configpassthru'] = $pconfig['configpassthru']; } + if ($pconfig['barnconfigpassthru'] != "") { $natent['barnconfigpassthru'] = $pconfig['barnconfigpassthru']; } if ($pconfig['rulesets'] != "") { $natent['rulesets'] = $pconfig['rulesets']; } if ($pconfig['rule_sid_off'] != "") { $natent['rule_sid_off'] = $pconfig['rule_sid_off']; } if ($pconfig['rule_sid_on'] != "") { $natent['rule_sid_on'] = $pconfig['rule_sid_on']; } -- cgit v1.2.3