. * Copyright (C) 2003-2004 Manuel Kasper . * Copyright (C) 2006 Scott Ullrich * Copyright (C) 2009 Robert Zelaya Sr. Developer * Copyright (C) 2012 Ermal Luci * All rights reserved. * * Adapted for Suricata by: * Copyright (C) 2014 Bill Meeks * 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/suricata/suricata.inc"); if ($_POST['cancel']) { header("Location: /suricata/suricata_passlist.php"); exit; } if (!is_array($config['installedpackages']['suricata']['passlist'])) $config['installedpackages']['suricata']['passlist'] = array(); if (!is_array($config['installedpackages']['suricata']['passlist']['item'])) $config['installedpackages']['suricata']['passlist']['item'] = array(); $a_passlist = &$config['installedpackages']['suricata']['passlist']['item']; if (isset($_POST['id']) && is_numericint($_POST['id'])) $id = $_POST['id']; elseif (isset($_GET['id']) && is_numericint($_GET['id'])) $id = htmlspecialchars($_GET['id']); /* Should never be called without identifying list index, so bail */ if (is_null($id)) { header("Location: /suricata/suricata_interfaces_passlist.php"); exit; } if (isset($id) && isset($a_passlist[$id])) { /* Retrieve saved settings */ $pconfig['name'] = $a_passlist[$id]['name']; $pconfig['uuid'] = $a_passlist[$id]['uuid']; $pconfig['address'] = $a_passlist[$id]['address']; $pconfig['descr'] = html_entity_decode($a_passlist[$id]['descr']); $pconfig['localnets'] = $a_passlist[$id]['localnets']; $pconfig['wanips'] = $a_passlist[$id]['wanips']; $pconfig['wangateips'] = $a_passlist[$id]['wangateips']; $pconfig['wandnsips'] = $a_passlist[$id]['wandnsips']; $pconfig['vips'] = $a_passlist[$id]['vips']; $pconfig['vpnips'] = $a_passlist[$id]['vpnips']; } // Check for returned "selected alias" if action is import if ($_GET['act'] == "import") { // Retrieve previously typed values we passed to SELECT ALIAS page $pconfig['name'] = htmlspecialchars($_GET['name']); $pconfig['uuid'] = htmlspecialchars($_GET['uuid']); $pconfig['address'] = htmlspecialchars($_GET['address']); $pconfig['descr'] = htmlspecialchars($_GET['descr']); $pconfig['localnets'] = htmlspecialchars($_GET['localnets'])? 'yes' : 'no'; $pconfig['wanips'] = htmlspecialchars($_GET['wanips'])? 'yes' : 'no'; $pconfig['wangateips'] = htmlspecialchars($_GET['wangateips'])? 'yes' : 'no'; $pconfig['wandnsips'] = htmlspecialchars($_GET['wandnsips'])? 'yes' : 'no'; $pconfig['vips'] = htmlspecialchars($_GET['vips'])? 'yes' : 'no'; $pconfig['vpnips'] = htmlspecialchars($_GET['vpnips'])? 'yes' : 'no'; // Now retrieve the "selected alias" returned from SELECT ALIAS page if ($_GET['varname'] == "address" && isset($_GET['varvalue'])) $pconfig[$_GET['varname']] = htmlspecialchars($_GET['varvalue']); } /* If no entry for this passlist, then create a UUID and treat it like a new list */ if (!isset($a_passlist[$id]['uuid']) && empty($pconfig['uuid'])) { $passlist_uuid = 0; while ($passlist_uuid > 65535 || $passlist_uuid == 0) { $passlist_uuid = mt_rand(1, 65535); $pconfig['uuid'] = $passlist_uuid; $pconfig['name'] = "passlist_{$passlist_uuid}"; } } elseif (!empty($pconfig['uuid'])) { $passlist_uuid = $pconfig['uuid']; } else $passlist_uuid = $a_passlist[$id]['uuid']; /* returns true if $name is a valid name for a pass list file name or ip */ function is_validpasslistname($name) { if (!is_string($name)) return false; if (!preg_match("/[^a-zA-Z0-9\_\.\/]/", $name)) return true; return false; } if ($_POST['save']) { unset($input_errors); $pconfig = $_POST; /* input validation */ $reqdfields = explode(" ", "name"); $reqdfieldsn = explode(",", "Name"); $pf_version=substr(trim(file_get_contents("/etc/version")),0,3); if ($pf_version < 2.1) $input_errors = eval('do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); return $input_errors;'); else do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors); if(strtolower($_POST['name']) == "defaultpasslist") $input_errors[] = gettext("Pass List file names may not be named defaultpasslist."); if (is_validpasslistname($_POST['name']) == false) $input_errors[] = gettext("Pass List file name may only consist of the characters \"a-z, A-Z, 0-9 and _\". Note: No Spaces or dashes. Press Cancel to reset."); /* check for name conflicts */ foreach ($a_passlist as $p_list) { if (isset($id) && ($a_passlist[$id]) && ($a_passlist[$id] === $p_list)) continue; if ($p_list['name'] == $_POST['name']) { $input_errors[] = gettext("A Pass List file name with this name already exists."); break; } } if ($_POST['address']) { if (!is_alias($_POST['address'])) $input_errors[] = gettext("A valid alias must be provided"); if (is_alias($_POST['address']) && trim(filter_expand_alias($_POST['address'])) == "") $input_errors[] = gettext("FQDN aliases are not supported in Suricata."); } if (!$input_errors) { $p_list = array(); /* post user input */ $p_list['name'] = $_POST['name']; $p_list['uuid'] = $passlist_uuid; $p_list['localnets'] = $_POST['localnets']? 'yes' : 'no'; $p_list['wanips'] = $_POST['wanips']? 'yes' : 'no'; $p_list['wangateips'] = $_POST['wangateips']? 'yes' : 'no'; $p_list['wandnsips'] = $_POST['wandnsips']? 'yes' : 'no'; $p_list['vips'] = $_POST['vips']? 'yes' : 'no'; $p_list['vpnips'] = $_POST['vpnips']? 'yes' : 'no'; $p_list['address'] = $_POST['address']; $p_list['descr'] = mb_convert_encoding(str_replace("\r\n", "\n", $_POST['descr']),"HTML-ENTITIES","auto"); $p_list['detail'] = $final_address_details; if (isset($id) && $a_passlist[$id]) $a_passlist[$id] = $p_list; else $a_passlist[] = $p_list; write_config("Suricata pkg: modified PASS LIST {$p_list['name']}."); /* create pass list and homenet file, then sync files */ conf_mount_rw(); sync_suricata_package_config(); conf_mount_ro(); header("Location: /suricata/suricata_passlist.php"); exit; } } $pgtitle = gettext("Suricata: Pass List Edit - {$pconfig['name']}"); include_once("head.inc"); ?>

  

/>
/>
/>
/>
/>
/>
     "/>