Skip to content

Commit

Permalink
Merge pull request #68 from bmeeks8/pfSense-pkg-snort_3.2.9.1_6
Browse files Browse the repository at this point in the history
  • Loading branch information
rbgarga committed Mar 4, 2016
2 parents 0ac2274 + c4d60ea commit f0a1528
Show file tree
Hide file tree
Showing 11 changed files with 236 additions and 311 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
require_once("pfsense-utils.inc");
require_once("config.inc");
require_once("functions.inc");
require_once("service-utils.inc");
require_once("service-utils.inc"); // Need this to get RCFILEPREFIX definition
require_once("pkg-utils.inc");
require_once("filter.inc");
require("/usr/local/pkg/snort/snort_defs.inc");
Expand Down Expand Up @@ -3685,11 +3685,11 @@ function snort_remove_dead_rules() {
$cats = array();

// If there is no "deprecated_rules" file, then exit
if (!file_exists("{$rulesdir}deprecated_rules"))
if (!file_exists("/usr/local/pkg/snort/deprecated_rules"))
return;

// Open a SplFileObject to read in deprecated rules
$file = new SplFileObject("{$rulesdir}/deprecated_rules");
$file = new SplFileObject("/usr/local/pkg/snort/deprecated_rules");
$file->setFlags(SplFileObject::READ_AHEAD | SplFileObject::SKIP_EMPTY | SplFileObject::DROP_NEW_LINE);
while (!$file->eof()) {
$line = $file->fgets();
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Copyright (C) 2006 Scott Ullrich
* Copyright (C) 2009-2010 Robert Zelaya
* Copyright (C) 2011-2012 Ermal Luci
* Copyright (C) 2013-2015 Bill Meeks
* Copyright (C) 2013-2016 Bill Meeks
* part of pfSense
* All rights reserved.
*
Expand Down Expand Up @@ -50,7 +50,7 @@ if (!defined("SNORT_BIN_VERSION")) {
if (!empty($snortver))
define("SNORT_BIN_VERSION", $snortver);
else
define("SNORT_BIN_VERSION", "2.9.7.6");
define("SNORT_BIN_VERSION", "2.9.8.0");
}
if (!defined("SNORT_SID_MODS_PATH"))
define('SNORT_SID_MODS_PATH', "{$g['vardb_path']}/snort/sidmods/");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Copyright (C) 2006 Scott Ullrich
* Copyright (C) 2009-2010 Robert Zelaya
* Copyright (C) 2011-2012 Ermal Luci
* Copyright (C) 2013-2014 Bill Meeks
* Copyright (C) 2013-2016 Bill Meeks
* part of pfSense
* All rights reserved.
*
Expand Down Expand Up @@ -40,6 +40,7 @@

require_once("config.inc");
require_once("functions.inc");
require_once("service-utils.inc"); // Need this to get RCFILEPREFIX constant
require_once("/usr/local/pkg/snort/snort.inc");
require("/usr/local/pkg/snort/snort_defs.inc");

Expand Down Expand Up @@ -67,6 +68,9 @@
unlink_if_exists("{$g['varrun_path']}/barnyard2_*.pid");
}

// Remove any LCK files for Snort that might have been left behind
unlink_if_exists("{$g['varrun_path']}/snort_pkg_starting.lck");

/* Set flag for post-install in progress */
$g['snort_postinstall'] = true;

Expand All @@ -85,9 +89,6 @@
@rename("{$snortdir}/gen-msg.map-sample", "{$snortdir}/gen-msg.map");
//@rename("{$snortdir}/attribute_table.dtd-sample", "{$snortdir}/attribute_table.dtd");

/* Move deprecated_rules file to SNORTDIR/rules directory */
@rename("/usr/local/pkg/snort/deprecated_rules", "{$snortdir}/rules/deprecated_rules");

/* fix up the preprocessor rules filenames from a PBI package install */
$preproc_rules = array("decoder.rules", "preprocessor.rules", "sensitive-data.rules");
foreach ($preproc_rules as $file) {
Expand Down Expand Up @@ -141,8 +142,8 @@

/* remake saved settings */
if ($config['installedpackages']['snortglobal']['forcekeepsettings'] == 'on') {
log_error(gettext("[Snort] Saved settings detected... rebuilding installation with saved settings..."));
update_status(gettext("Saved settings detected..."));
log_error(gettext("[Snort] Saved settings detected... rebuilding installation with saved settings."));
update_status(gettext("Saved settings detected.") . "\n");

/****************************************************************/
/* Do test and fix for duplicate UUIDs if this install was */
Expand Down Expand Up @@ -180,16 +181,12 @@
/****************************************************************/

/* Do one-time settings migration for new multi-engine configurations */
$static_output .= gettext("\nMigrating settings to new configuration...");
update_output_window($static_output);
update_status(gettext("Migrating settings to new configuration..."));
include('/usr/local/pkg/snort/snort_migrate_config.php');
$static_output .= gettext(" done.\n");
update_output_window($static_output);
log_error(gettext("[Snort] Downloading and updating configured rule sets..."));
if ($pkg_interface <> "console")
$snort_gui_include = true;
update_status(gettext(" done.") . "\n");
log_error(gettext("[Snort] Downloading and updating configured rule sets."));
include('/usr/local/pkg/snort/snort_check_for_rule_updates.php');
update_status(gettext("Generating snort.conf configuration file from saved settings..."));
update_status(gettext("Generating snort.conf configuration file from saved settings.") . "\n");
$rebuild_rules = true;
conf_mount_rw();

Expand All @@ -199,8 +196,7 @@
$if_real = get_real_interface($snortcfg['interface']);
$snort_uuid = $snortcfg['uuid'];
$snortcfgdir = "{$snortdir}/snort_{$snort_uuid}_{$if_real}";
$static_output .= gettext("Generating configuration for " . convert_friendly_interface_to_friendly_descr($snortcfg['interface']) . "...");
update_output_window($static_output);
update_status(gettext("Generating configuration for " . convert_friendly_interface_to_friendly_descr($snortcfg['interface']) . "..."));

// Pull in the PHP code that generates the snort.conf file
// variables that will be substituted further down below.
Expand All @@ -227,16 +223,13 @@
if ($snortcfg['barnyard_enable'] == 'on')
snort_generate_barnyard2_conf($snortcfg, $if_real);

$static_output .= gettext(" done.\n");
update_output_window($static_output);
update_status(gettext(" done.") . "\n");
}

/* create snort bootup file snort.sh */
$static_output .= gettext("Generating snort.sh script in {$rcdir}...");
update_output_window($static_output);
update_status(gettext("Generating snort.sh script in {$rcdir}..."));
snort_create_rc();
$static_output .= gettext(" done.\n");
update_output_window($static_output);
update_status(gettext(" done.") . "\n");

/* Set Log Limit, Block Hosts Time and Rules Update Time */
snort_snortloglimit_install_cron(true);
Expand All @@ -249,22 +242,8 @@
$config['widgets']['sequence'] .= "," . $config['installedpackages']['snortglobal']['dashboard_widget'];

$rebuild_rules = false;
if ($pkg_interface <> "console")
update_output_window(gettext("Finished rebuilding Snort configuration files..."));
log_error(gettext("[Snort] Finished rebuilding installation from saved settings..."));

/* Only try to start Snort if not in reboot */
if (!($g['booting'])) {
if ($pkg_interface <> "console") {
update_status(gettext("Starting Snort using rebuilt configuration..."));
$static_output .= gettext("Starting Snort as a background task using the rebuilt configuration... ");
mwexec_bg("{$rcdir}snort.sh start");
update_output_window($static_output);
}
else
mwexec_bg("{$rcdir}snort.sh start");
}
update_status("");
update_status(gettext("Finished rebuilding Snort configuration files.") . "\n");
log_error(gettext("[Snort] Finished rebuilding installation from saved settings."));
}

/* We're finished with conf partition mods, return to read-only */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
else
$response = array('resolve_ip' => $ip, 'resolve_text' => gettext("Cannot resolve"));

echo json_encode(str_replace("\\","\\\\", $response)); // single escape chars can break JSON decode
print(json_encode(str_replace("\\","\\\\", $response))); // single escape chars can break JSON decode
exit;
}
# --- AJAX REVERSE DNS RESOLVE End ---
Expand Down Expand Up @@ -148,7 +148,7 @@

/* refresh every 60 secs */
if ($pconfig['brefresh'] == 'on')
echo "<meta http-equiv=\"refresh\" content=\"60;url=/snort/snort_blocked.php\" />\n";
print('<meta http-equiv="refresh" content="60;url=/snort/snort_blocked.php" />\n');

/* Display Alert message */
if ($input_errors) {
Expand Down Expand Up @@ -321,29 +321,29 @@
$rdns_link .= "<i class=\"fa fa-search icon-pointer\" onclick=\"javascript:resolve_with_ajax('{$blocked_ip}');\" title=\"";
$rdns_link .= gettext("Resolve host via reverse DNS lookup") . "\" alt=\"Icon Reverse Resolve with DNS\"></i>";

/* use one echo to do the magic*/
echo "<tr class=\"text-nowrap\">
/* print the table row */
print("<tr class=\"text-nowrap\">
<td>{$counter}</td>
<td style=\"word-wrap:break-word; white-space:normal\">{$tmp_ip}<br/>{$rdns_link}</td>
<td style=\"word-wrap:break-word; white-space:normal\">{$blocked_desc}</td>
<td><i class=\"fa fa-times icon-pointer text-danger\" onClick=\"$('#ip').val('{$blocked_ip}');$('#mode').val('todelete');$('#formblock').submit();\"
title=\"" . gettext("Delete host from Blocked Table") . "\"></i></td>
</tr>\n";
</tr>\n");
}
}
?>
</tbody>
<tfoot>
<tr>
<td colspan="4">
<td colspan="4" style="text-align:center;" class="alert-info">
<?php if (!empty($blocked_ips_array)) {
if ($counter > 1)
echo "{$counter}" . gettext(" host IP addresses are currently being blocked.");
print($counter . gettext(" host IP addresses are currently being blocked by Snort."));
else
echo "{$counter}" . gettext(" host IP address is currently being blocked.");
print($counter . gettext(" host IP address is currently being blocked Snort."));
}
else {
echo gettext("There are currently no hosts being blocked by Snort.");
print(gettext("There are currently no hosts being blocked by Snort."));
}
?>
</td>
Expand Down
Loading

0 comments on commit f0a1528

Please sign in to comment.