aboutsummaryrefslogtreecommitdiffstats
path: root/config/snort/snort_interfaces.php
diff options
context:
space:
mode:
Diffstat (limited to 'config/snort/snort_interfaces.php')
-rwxr-xr-xconfig/snort/snort_interfaces.php387
1 files changed, 252 insertions, 135 deletions
diff --git a/config/snort/snort_interfaces.php b/config/snort/snort_interfaces.php
index e8e690a8..390b83eb 100755
--- a/config/snort/snort_interfaces.php
+++ b/config/snort/snort_interfaces.php
@@ -32,9 +32,10 @@ $nocsrf = true;
require_once("guiconfig.inc");
require_once("/usr/local/pkg/snort/snort.inc");
-global $g;
+global $g, $rebuild_rules;
$snortdir = SNORTDIR;
+$rcdir = RCFILEPREFIX;
$id = $_GET['id'];
if (isset($_POST['id']))
@@ -57,19 +58,38 @@ if (isset($_POST['del_x'])) {
exec("/bin/rm -r /var/log/snort/snort_{$if_real}{$snort_uuid}");
exec("/bin/rm -r {$snortdir}/snort_{$snort_uuid}_{$if_real}");
+ // If interface had auto-generated Suppress List, then
+ // delete that along with the interface
+ $autolist = "{$a_nat[$rulei]['interface']}" . "suppress";
+ if (is_array($config['installedpackages']['snortglobal']['suppress']) &&
+ is_array($config['installedpackages']['snortglobal']['suppress']['item'])) {
+ $a_suppress = &$config['installedpackages']['snortglobal']['suppress']['item'];
+ foreach ($a_suppress as $k => $i) {
+ if ($i['name'] == $autolist) {
+ unset($config['installedpackages']['snortglobal']['suppress']['item'][$k]);
+ break;
+ }
+ }
+ }
+
+ // Finally delete the interface's config entry entirely
unset($a_nat[$rulei]);
}
conf_mount_ro();
+ /* If all the Snort interfaces are removed, then unset the config array. */
+ if (empty($a_nat))
+ unset($a_nat);
+
write_config();
sleep(2);
- /* if there are no ifaces do not create snort.sh */
+ /* if there are no ifaces remaining do not create snort.sh */
if (!empty($config['installedpackages']['snortglobal']['rule']))
snort_create_rc();
else {
conf_mount_rw();
- @unlink('/usr/local/etc/rc.d/snort.sh');
+ @unlink("{$rcdir}/snort.sh");
conf_mount_ro();
}
@@ -93,11 +113,11 @@ if ($_GET['act'] == 'bartoggle' && is_numeric($id)) {
$if_friendly = snort_get_friendly_interface($snortcfg['interface']);
if (snort_is_running($snortcfg['uuid'], $if_real, 'barnyard2') == 'no') {
- log_error("Toggle(barnyard starting) for {$if_friendly}({$snortcfg['descr']}}...");
+ log_error("Toggle (barnyard starting) for {$if_friendly}({$snortcfg['descr']})...");
sync_snort_package_config();
snort_barnyard_start($snortcfg, $if_real);
} else {
- log_error("Toggle(barnyard stopping) for {$if_friendly}({$snortcfg['descr']}}...");
+ log_error("Toggle (barnyard stopping) for {$if_friendly}({$snortcfg['descr']})...");
snort_barnyard_stop($snortcfg, $if_real);
}
@@ -113,7 +133,7 @@ if ($_GET['act'] == 'toggle' && is_numeric($id)) {
$if_friendly = snort_get_friendly_interface($snortcfg['interface']);
if (snort_is_running($snortcfg['uuid'], $if_real) == 'yes') {
- log_error("Toggle(snort stopping) for {$if_friendly}({$snortcfg['descr']})...");
+ log_error("Toggle (snort stopping) for {$if_friendly}({$snortcfg['descr']})...");
snort_stop($snortcfg, $if_real);
header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' );
@@ -122,8 +142,12 @@ if ($_GET['act'] == 'toggle' && is_numeric($id)) {
header( 'Cache-Control: post-check=0, pre-check=0', false );
header( 'Pragma: no-cache' );
} else {
- log_error("Toggle(snort starting) for {$if_friendly}({$snortcfg['descr']})...");
+ log_error("Toggle (snort starting) for {$if_friendly}({$snortcfg['descr']})...");
+
+ /* set flag to rebuild interface rules before starting Snort */
+ $rebuild_rules = "on";
sync_snort_package_config();
+ $rebuild_rules = "off";
snort_start($snortcfg, $if_real);
header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' );
@@ -174,26 +198,28 @@ if ($pfsense_stable == 'yes')
?>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
-<tr><td>
-<?php
- $tab_array = array();
- $tab_array[0] = array(gettext("Snort Interfaces"), true, "/snort/snort_interfaces.php");
- $tab_array[1] = array(gettext("Global Settings"), false, "/snort/snort_interfaces_global.php");
- $tab_array[2] = array(gettext("Updates"), false, "/snort/snort_download_updates.php");
- $tab_array[3] = array(gettext("Alerts"), false, "/snort/snort_alerts.php");
- $tab_array[4] = array(gettext("Blocked"), false, "/snort/snort_blocked.php");
- $tab_array[5] = array(gettext("Whitelists"), false, "/snort/snort_interfaces_whitelist.php");
- $tab_array[6] = array(gettext("Suppress"), false, "/snort/snort_interfaces_suppress.php");
- display_top_tabs($tab_array);
-?>
-</td></tr>
<tr>
<td>
- <div id="mainarea2">
- <table class="tabcont" width="100%" border="0" cellpadding="0"
- cellspacing="0">
+ <?php
+ $tab_array = array();
+ $tab_array[0] = array(gettext("Snort Interfaces"), true, "/snort/snort_interfaces.php");
+ $tab_array[1] = array(gettext("Global Settings"), false, "/snort/snort_interfaces_global.php");
+ $tab_array[2] = array(gettext("Updates"), false, "/snort/snort_download_updates.php");
+ $tab_array[3] = array(gettext("Alerts"), false, "/snort/snort_alerts.php");
+ $tab_array[4] = array(gettext("Blocked"), false, "/snort/snort_blocked.php");
+ $tab_array[5] = array(gettext("Whitelists"), false, "/snort/snort_interfaces_whitelist.php");
+ $tab_array[6] = array(gettext("Suppress"), false, "/snort/snort_interfaces_suppress.php");
+ $tab_array[7] = array(gettext("Sync"), false, "/pkg_edit.php?xml=snort/snort_sync.xml");
+ display_top_tabs($tab_array);
+ ?>
+ </td>
+</tr>
+<tr>
+ <td>
+ <div id="mainarea">
+ <table id="maintable" class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
<tr id="frheader">
- <td width="5%" class="list">&nbsp;</td>
+ <td width="3%" class="list">&nbsp;</td>
<td width="10%" class="listhdrr"><?php echo gettext("If"); ?></td>
<td width="13%" class="listhdrr"><?php echo gettext("Snort"); ?></td>
<td width="10%" class="listhdrr"><?php echo gettext("Performance"); ?></td>
@@ -201,44 +227,86 @@ if ($pfsense_stable == 'yes')
<td width="12%" class="listhdrr"><?php echo gettext("Barnyard2"); ?></td>
<td width="30%" class="listhdr"><?php echo gettext("Description"); ?></td>
<td width="3%" class="list">
- <table border="0" cellspacing="0" cellpadding="1">
+ <table border="0" cellspacing="0" cellpadding="0">
<tr>
- <td width="17"></td>
- <td><a href="snort_interfaces_edit.php?id=<?php echo $id_gen;?>"><img
- src="../themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif"
- width="17" height="17" border="0" title="<?php echo gettext('add interface');?>"></a></td>
+ <td></td>
+ <td align="center" valign="middle"><a href="snort_interfaces_edit.php?id=<?php echo $id_gen;?>"><img
+ src="../themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif"
+ width="17" height="17" border="0" title="<?php echo gettext('Add Snort interface mapping');?>"></a></td>
</tr>
</table>
</td>
</tr>
-<?php $nnats = $i = 0; foreach ($a_nat as $natent): ?>
-<tr valign="top" id="fr<?=$nnats;?>">
-<?php
+ <?php $nnats = $i = 0;
-/* convert fake interfaces to real and check if iface is up */
-/* There has to be a smarter way to do this */
- $if_real = snort_get_real_interface($natent['interface']);
- $snort_uuid = $natent['uuid'];
- if (snort_is_running($snort_uuid, $if_real) == 'no')
- $iconfn = 'pass';
- else
- $iconfn = 'block';
- if (snort_is_running($snort_uuid, $if_real, 'barnyard2') == 'no')
- $biconfn = 'pass';
- else
- $biconfn = 'block';
+ // Turn on buffering to speed up rendering
+ ini_set('output_buffering','true');
- ?>
- <td class="listt">
- <input type="checkbox" id="frc<?=$nnats;?>" name="rule[]" value="<?=$i;?>" onClick="fr_bgcolor('<?=$nnats;?>')" style="margin: 0; padding: 0;"></td>
- <td class="listr"
+ // Start buffering to fix display lag issues in IE9 and IE10
+ ob_start(null, 0);
+
+ /* If no interfaces are defined, then turn off the "no rules" warning */
+ $no_rules_footnote = false;
+ if ($id_gen == 0)
+ $no_rules = false;
+ else
+ $no_rules = true;
+
+ foreach ($a_nat as $natent): ?>
+ <tr valign="top" id="fr<?=$nnats;?>">
+ <?php
+
+ /* convert fake interfaces to real and check if iface is up */
+ /* There has to be a smarter way to do this */
+ $if_real = snort_get_real_interface($natent['interface']);
+ $natend_friendly= snort_get_friendly_interface($natent['interface']);
+ $snort_uuid = $natent['uuid'];
+ if (snort_is_running($snort_uuid, $if_real) == 'no'){
+ $iconfn = 'block';
+ $iconfn_msg1 = 'Snort is not running on ';
+ $iconfn_msg2 = '. Click to start.';
+ }
+ else{
+ $iconfn = 'pass';
+ $iconfn_msg1 = 'Snort is running on ';
+ $iconfn_msg2 = '. Click to stop.';
+ }
+ if (snort_is_running($snort_uuid, $if_real, 'barnyard2') == 'no'){
+ $biconfn = 'block';
+ $biconfn_msg1 = 'Barnyard2 is not running on ';
+ $biconfn_msg2 = '. Click to start.';
+ }
+ else{
+ $biconfn = 'pass';
+ $biconfn_msg1 = 'Barnyard2 is running on ';
+ $biconfn_msg2 = '. Click to stop.';
+ }
+
+ /* See if interface has any rules defined and set boolean flag */
+ $no_rules = true;
+ if (isset($natent['customrules']) && !empty($natent['customrules']))
+ $no_rules = false;
+ if (isset($natent['rulesets']) && !empty($natent['rulesets']))
+ $no_rules = false;
+ if (isset($natent['ips_policy']) && !empty($natent['ips_policy']))
+ $no_rules = false;
+ /* Do not display the "no rules" warning if interface disabled */
+ if ($natent['enable'] == "off")
+ $no_rules = false;
+ if ($no_rules)
+ $no_rules_footnote = true;
+ ?>
+ <td class="listt">
+ <input type="checkbox" id="frc<?=$nnats;?>" name="rule[]" value="<?=$i;?>" onClick="fr_bgcolor('<?=$nnats;?>')" style="margin: 0; padding: 0;">
+ </td>
+ <td class="listr"
id="frd<?=$nnats;?>"
ondblclick="document.location='snort_interfaces_edit.php?id=<?=$nnats;?>';">
<?php
- echo snort_get_friendly_interface($natent['interface']);
+ echo $natend_friendly;
?>
- </td>
- <td class="listr"
+ </td>
+ <td class="listr"
id="frd<?=$nnats;?>"
ondblclick="document.location='snort_interfaces_edit.php?id=<?=$nnats;?>';">
<?php
@@ -248,12 +316,13 @@ if ($pfsense_stable == 'yes')
echo "<a href='?act=toggle&id={$i}'>
<img src='../themes/{$g['theme']}/images/icons/icon_{$iconfn}.gif'
width='13' height='13' border='0'
- title='" . gettext('click to toggle start/stop snort') . "'></a>";
+ title='" . gettext($iconfn_msg1.$natend_friendly.$iconfn_msg2) . "'></a>";
+ echo ($no_rules) ? "&nbsp;<img src=\"../themes/{$g['theme']}/images/icons/icon_frmfld_imp.png\" width=\"15\" height=\"15\" border=\"0\">" : "";
} else
echo strtoupper("disabled");
?>
- </td>
- <td class="listr"
+ </td>
+ <td class="listr"
id="frd<?=$nnats;?>"
ondblclick="document.location='snort_interfaces_edit.php?id=<?=$nnats;?>';">
<?php
@@ -263,8 +332,9 @@ if ($pfsense_stable == 'yes')
}else{
$check_performance = "lowmem";
}
- ?> <?=strtoupper($check_performance);?></td>
- <td class="listr"
+ ?> <?=strtoupper($check_performance);?>
+ </td>
+ <td class="listr"
id="frd<?=$nnats;?>"
ondblclick="document.location='snort_interfaces_edit.php?id=<?=$nnats;?>';">
<?php
@@ -275,8 +345,9 @@ if ($pfsense_stable == 'yes')
} else {
$check_blockoffenders = disabled;
}
- ?> <?=strtoupper($check_blockoffenders);?></td>
- <td class="listr"
+ ?> <?=strtoupper($check_blockoffenders);?>
+ </td>
+ <td class="listr"
id="frd<?=$nnats;?>"
ondblclick="document.location='snort_interfaces_edit.php?id=<?=$nnats;?>';">
<?php
@@ -286,94 +357,140 @@ if ($pfsense_stable == 'yes')
echo "<a href='?act=bartoggle&id={$i}'>
<img src='../themes/{$g['theme']}/images/icons/icon_{$biconfn}.gif'
width='13' height='13' border='0'
- title='" . gettext('click to toggle start/stop barnyard') . "'></a>";
+ title='" . gettext($biconfn_msg1.$natend_friendly.$biconfn_msg2) . "'></a>";
} else
echo strtoupper("disabled");
?>
- </td>
- <td class="listbg"
+ </td>
+ <td class="listbg"
ondblclick="document.location='snort_interfaces_edit.php?id=<?=$nnats;?>';">
- <font color="#ffffff"> <?=htmlspecialchars($natent['descr']);?>&nbsp;
- </td>
- <td valign="middle" class="list" nowrap>
- <table border="0" cellspacing="0" cellpadding="1">
- <tr>
- <td><a href="snort_interfaces_edit.php?id=<?=$i;?>"><img
- src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif"
- width="17" height="17" border="0" title="<?php echo gettext('edit interface'); ?>"></a></td>
- </tr>
- </table>
-
- </tr>
- <?php $i++; $nnats++; endforeach; ?>
- <tr>
- <td class="list" colspan="8"></td>
- <td class="list" valign="middle" nowrap>
- <table border="0" cellspacing="0" cellpadding="1">
+ <font color="#ffffff"> <?=htmlspecialchars($natent['descr']);?>&nbsp;
+ </td>
+ <td valign="middle" class="list" nowrap>
+ <table border="0" cellspacing="0" cellpadding="0">
+ <tr>
+ <td><a href="snort_interfaces_edit.php?id=<?=$i;?>"><img
+ src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif"
+ width="17" height="17" border="0" title="<?php echo gettext('Edit Snort interface mapping'); ?>"></a>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <?php $i++; $nnats++; endforeach; ob_end_flush(); ?>
+ <tr>
+ <td class="list"></td>
+ <td class="list" colspan="6">
+ <?php if ($no_rules_footnote): ?><br><img src="../themes/<?= $g['theme']; ?>/images/icons/icon_frmfld_imp.png" width="15" height="15" border="0">
+ <span class="red">&nbsp;&nbsp <?php echo gettext("WARNING: Marked interface currently has no rules defined for Snort"); ?></span>
+ <?php else: ?>&nbsp;
+ <?php endif; ?>
+ </td>
+ <td class="list" valign="middle" nowrap>
+ <table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><?php if ($nnats == 0): ?><img
- src="../themes/<?= $g['theme']; ?>/images/icons/icon_x_d.gif"
- width="17" height="17" title="<?php echo gettext("delete selected interface"); ?>" border="0"><?php else: ?><input
- name="del" type="image"
- src="../themes/<?= $g['theme']; ?>/images/icons/icon_x.gif"
- width="17" height="17" title="<?php echo gettext("delete selected interface"); ?>"
- onclick="return confirm('Do you really want to delete the selected Snort mapping?')"><?php endif; ?></td>
+ src="../themes/<?= $g['theme']; ?>/images/icons/icon_x_d.gif"
+ width="17" height="17" " border="0">
+ <?php else: ?>
+ <input name="del" type="image"
+ src="../themes/<?= $g['theme']; ?>/images/icons/icon_x.gif"
+ width="17" height="17" title="<?php echo gettext("Delete selected Snort interface mapping(s)"); ?>"
+ onclick="return intf_del()">
+ <?php endif; ?></td>
</tr>
</table>
- </td>
- </tr>
- </table>
- </div>
- </td>
- </tr>
-</table>
-
-<br>
-<table width="100%" border="0" cellpadding="0" cellspacing="0">
- <tr>
- <td>
- <div id="mainarea4">
- <table class="tabcont" width="100%" border="0" cellpadding="0"
- cellspacing="0">
- <tr id="frheader">
- <td width="100%"><span class="red"><strong><?php echo gettext("Note:"); ?></strong></span> <br>
- <?php echo gettext('This is the <strong>Snort Menu</strong> where you can see an over ' .
- 'view of all your interface settings. <br> ' .
- 'Please edit the <strong>Global Settings</strong> tab before adding ' .
- 'an interface.'); ?> <br>
- <br>
- <span class="red"><strong><?php echo gettext("Warning:"); ?></strong></span> <br>
- <strong><?php echo gettext("New settings will not take effect until interface restart."); ?></strong>
- <br>
- <br>
- <strong>Click</strong> on the <img
- src="../themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif"
- width="17" height="17" border="0" title="<?php echo gettext("Add Icon"); ?>"> icon to add a
- interface.<strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Click</strong>
- on the <img
- src="../themes/<?= $g['theme']; ?>/images/icons/icon_pass.gif"
- width="13" height="13" border="0" title="<?php echo gettext("Start Icon"); ?>"> icon to <strong>start</strong>
- snort and barnyard2. <br>
- <strong>Click</strong> on the <img
- src="../themes/<?= $g['theme']; ?>/images/icons/icon_e.gif"
- width="17" height="17" border="0" title="<?php echo gettext("Edit Icon"); ?>"> icon to edit a
- interface and settings.<strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Click</strong>
- on the <img
- src="../themes/<?= $g['theme']; ?>/images/icons/icon_block.gif"
- width="13" height="13" border="0" title="<?php echo gettext("Stop Icon"); ?>"> icon to <strong>stop</strong>
- snort and barnyard2. <br>
- <strong> Click</strong> on the <img
- src="../themes/<?= $g['theme']; ?>/images/icons/icon_x.gif"
- width="17" height="17" border="0" title="<?php echo gettext("Delete Icon"); ?>"> icon to
- delete a interface and settings.</td>
- </tr>
- </table>
- </div>
-
- </tr>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="8">&nbsp;</td>
+ </tr>
+ <tr>
+ <td>&nbsp;</td>
+ <td colspan="6">
+ <table class="tabcont" width="100%" border="0" cellpadding="1" cellspacing="0">
+ <tr>
+ <td colspan="3" class="vexpl"><span class="red"><strong><?php echo gettext("Note:"); ?></strong></span> <br>
+ <?php echo gettext("This is the ") . "<strong>" . gettext("Snort Menu ") .
+ "</strong>" . gettext("where you can see an overview of all your interface settings.");
+ if (empty($a_nat)) {
+ echo gettext("Please visit the ") . "<strong>" . gettext("Global Settings") .
+ "</strong>" . gettext(" tab before adding an interface.");
+ }?>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="3" class="vexpl"><br>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="3" class="vexpl"><span class="red"><strong><?php echo gettext("Warning:"); ?></strong></span><br>
+ <strong><?php echo gettext("New settings will not take effect until interface restart."); ?></strong>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="3" class="vexpl"><br>
+ </td>
+ </tr>
+ <tr>
+ <td class="vexpl"><strong>Click</strong> on the <img src="../themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif"
+ width="17" height="17" border="0" title="<?php echo gettext("Add Icon"); ?>"> icon to add
+ an interface.
+ </td>
+ <td width="3%" class="vexpl">&nbsp;
+ </td>
+ <td class="vexpl"><img src="../themes/<?= $g['theme']; ?>/images/icons/icon_pass.gif"
+ width="13" height="13" border="0" title="<?php echo gettext("Running"); ?>">
+ <img src="../themes/<?= $g['theme']; ?>/images/icons/icon_block.gif"
+ width="13" height="13" border="0" title="<?php echo gettext("Not Running"); ?>"> icons will show current
+ snort and barnyard2 status.
+ </td>
+ </tr>
+ <tr>
+ <td class="vexpl"><strong>Click</strong> on the <img src="../themes/<?= $g['theme']; ?>/images/icons/icon_e.gif"
+ width="17" height="17" border="0" title="<?php echo gettext("Edit Icon"); ?>"> icon to edit
+ an interface and settings.
+ <td width="3%">&nbsp;
+ </td>
+ <td class="vexpl"><strong>Click</strong> on the status icons to <strong>toggle</strong> snort and barnyard2 status.
+ </td>
+ </tr>
+ <tr>
+ <td colspan="3" class="vexpl"><strong> Click</strong> on the <img src="../themes/<?= $g['theme']; ?>/images/icons/icon_x.gif"
+ width="17" height="17" border="0" title="<?php echo gettext("Delete Icon"); ?>"> icon to
+ delete an interface and settings.
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td>&nbsp;</td>
+ </tr>
+ </table>
+ </div>
</td>
+</tr>
</table>
</form>
+
+<script type="text/javascript">
+
+function intf_del() {
+ var isSelected = false;
+ var inputs = document.iform.elements;
+ for (var i = 0; i < inputs.length; i++) {
+ if (inputs[i].type == "checkbox") {
+ if (inputs[i].checked)
+ isSelected = true;
+ }
+ }
+ if (isSelected)
+ return confirm('Do you really want to delete the selected Snort mapping?');
+ else
+ alert("There is no Snort mapping selected for deletion. Click the checkbox beside the Snort mapping(s) you wish to delete.");
+}
+
+</script>
+
<?php
include("fend.inc");
?>