aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config/snort-dev/css/style_snort2.css16
-rw-r--r--config/snort-dev/snort_download_rules.inc409
-rw-r--r--config/snort-dev/snort_download_updates.php333
-rw-r--r--config/snort-dev/snort_headbase.inc1
-rw-r--r--config/snort-dev/snort_json_get.php43
5 files changed, 791 insertions, 11 deletions
diff --git a/config/snort-dev/css/style_snort2.css b/config/snort-dev/css/style_snort2.css
index 07d21de6..54ce4af6 100644
--- a/config/snort-dev/css/style_snort2.css
+++ b/config/snort-dev/css/style_snort2.css
@@ -87,7 +87,7 @@ a {
visibility:hidden;
}
-#loadingWaiting, #loadingRuleEditGUI{
+#loadingWaiting, #loadingRuleEditGUI, #loadingRuleUpadteGUI{
display:none;
position:fixed;
left:0;
@@ -99,24 +99,22 @@ a {
color: #ffffff;
}
-.loadingRuleEditGUIDiv {
+.loadingWaitingMessage{
position: absolute;
- top: 2%;
- left: 5%;
- right: 5%;
- bottom: 50%;
+ top: 25%;
+ left: 50%;
color: #ffffff;
z-index: 9999;
text-align: center;
}
-.loadingWaitingMessage {
+.loadingWaitingUpdateGUI{
position: absolute;
top: 25%;
- left: 50%;
+ left: 35%;
color: #ffffff;
z-index: 9999;
text-align: center;
@@ -241,7 +239,7 @@ padding-bottom: 12px;
.vncell2 {
background-color: #eeeeee;
padding-right: 5px;
- padding-left: 8px;
+ padding-left: 5px;
border-bottom: 1px solid #999999;
font-size: 11px;
}
diff --git a/config/snort-dev/snort_download_rules.inc b/config/snort-dev/snort_download_rules.inc
new file mode 100644
index 00000000..92714795
--- /dev/null
+++ b/config/snort-dev/snort_download_rules.inc
@@ -0,0 +1,409 @@
+#!/usr/local/bin/php
+<?php
+
+/*
+ * WARNING: THIS FILE SHOULD NEVER BE IN WWWW DIR
+ *
+ */
+
+//require_once("/usr/local/pkg/snort/snort_new.inc");
+
+// fetch db Settings NONE Json
+function snortSql_fetchAllSettings($dbname, $table, $type, $id_uuid)
+{
+
+ if ($dbname == '' || $table == '' || $type == '')
+ {
+ return false;
+ }
+
+ $db = sqlite_open("/usr/local/pkg/snort/$dbname");
+
+
+ if ($type == 'id')
+ {
+ $result = sqlite_query($db,
+ "SELECT * FROM {$table} where id = '{$id_uuid}';
+ ");
+ }
+
+
+ if ($type == 'id')
+ {
+ $chktable = sqlite_fetch_array($result, SQLITE_ASSOC);
+ }
+
+ sqlite_close($db);
+
+ return $chktable;
+
+
+} // end func
+
+function snortCmpareMD5($type, $path1, $path2, $filename_md5)
+{
+ update_output_window2('ms2', 'Checking ' . $filename_md5 . ' MD5...');
+
+ if (file_exists("{$path1}/{$filename_md5}"))
+ {
+
+ if ($type == 'string')
+ {
+ $md5_check_new = @file_get_contents("{$path1}/{$filename_md5}");
+ $md5_check_old = @file_get_contents("{$path2}/{$filename_md5}");
+ if ($md5_check_new != $md5_check_old || !file_exists("$path2}/{$filename_md5}"))
+ {
+ update_output_window2('ms2', 'MD5s do not match...');
+ return false;
+ }
+ }
+
+ if ($type == 'md5')
+ {
+ //md5 snortrules-snapshot-2905.tar.gz | awk '{print $4}'
+ $md5_check_new2 = exec("/sbin/md5 {$path1}/{$filename_md5} | '{print $4}'");
+ $md5_check_old2 = exec("/sbin/md5 {$path2}/{$filename_md5} | '{print $4}'");
+ if ($md5_check_new != $md5_check_old)
+ {
+ update_output_window2('ms2', 'MD5s do not match...');
+ return false;
+ }
+ }
+ }
+
+
+ return true;
+}
+
+
+/*
+ * update_output_window: update bottom textarea dynamically.
+ */
+function update_output_window2($type, $text)
+{
+
+ if ($GLOBALS['tmp']['snort']['downloadupdate']['console'] != 'on')
+ {
+ snortSql_updateRuleSetList($type, $text, '', '', $GLOBALS['tmp']['snort']['downloadupdate']['workingfile']); // write out msg to db
+ }else{
+ echo "\n" . $type . ': ' . $text;
+ }
+
+}
+
+function snortSql_updateRuleSetList($type, $value, $file_size, $downloaded, $filename)
+{
+
+ $dbname = 'snortDBtemp';
+ $table = 'SnortDownloads';
+ $addDate = date(U);
+
+ // do let user pick the DB path
+ $db = sqlite_open("/var/snort/{$dbname}");
+
+ if ($type === 'percent2')
+ {
+ $query_ck = sqlite_query($db, // @ supress warnings usonly in production
+ "UPDATE {$table} SET date = '{$addDate}', percent = '{$value}', filesize = '{$file_size}', downloaded = '{$downloaded}' where filename = '{$filename}';
+ ");
+ }
+
+
+ if ($type === 'percent')
+ {
+ $query_ck = sqlite_query($db, // @ supress warnings usonly in production
+ "UPDATE {$table} SET date = '{$addDate}', percent = '{$value}' where filename = '{$filename}';
+ ");
+ }
+
+ if ($type === 'msg1')
+ {
+ $query_ck = sqlite_query($db, // @ supress warnings usonly in production
+ "UPDATE SnortDownloadsMsg SET date = '{$addDate}', msg = '{$value}' where id = '1';
+ ");
+ }
+
+ if ($type === 'msg2')
+ {
+ $query_ck = sqlite_query($db, // @ supress warnings usonly in production
+ "UPDATE SnortDownloadsMsg SET date = '{$addDate}', msg = '{$value}' where id = '2';
+ ");
+ }
+
+ if ($type === 'working')
+ {
+ $query_ck = sqlite_query($db, // @ supress warnings usonly in production
+ "UPDATE {$table} SET date = '{$addDate}', working = '{$value}' where filename = '{$filename}';
+ ");
+ }
+
+ if (sqlite_changes($db) < 1)
+ {
+ sqlite_close($db);
+ return 'Error in query';
+ }
+
+ sqlite_close($db);
+
+
+}
+
+function sendUpdateSnortLogDownload($console)
+{
+
+ if ($console === 'console')
+ {
+ $GLOBALS['tmp']['snort']['downloadupdate']['console'] = 'on';
+ }
+
+
+ // set page vars
+ $generalSettings = snortSql_fetchAllSettings('snortDB', 'SnortSettings', 'id', '1');
+
+ // Setup file names and dir
+ $tmpfname = '/usr/local/etc/snort/snort_download';
+ $snortdir = '/usr/local/etc/snort';
+ $snortdir_wan = '/usr/local/etc/snort'; /// WHAT ?
+ $snort_filename_md5 = 'snortrules-snapshot-2905.tar.gz.md5';
+ $snort_filename = 'snortrules-snapshot-2905.tar.gz';
+ $emergingthreats_filename_md5 = 'emerging.rules.tar.gz.md5';
+ $emergingthreats_filename = 'emerging.rules.tar.gz';
+ $pfsense_rules_filename_md5 = 'pfsense_rules.tar.gz.md5';
+ $pfsense_rules_filename = 'pfsense_rules.tar.gz';
+
+
+ /* Set user agent to Mozilla */
+ ini_set('user_agent','Mozilla/4.0 (compatible; MSIE 6.0)');
+ ini_set("memory_limit","150M");
+
+
+ // Get file that does not use redirects, mostly for none snort.org downloads
+ function snort_file_get_contents($tmpfname, $snort_filename, $snort_UrlGet)
+ {
+ if (!file_exists("{$tmpfname}/{$snort_filename}") || filesize("{$tmpfname}/{$snort_filename}") <= 0)
+ {
+ update_output_window2('ms2', 'Downloading ' . $snort_filename. ' MD5...');
+ ini_set('user_agent','Mozilla/4.0 (compatible; MSIE 6.0)');
+ $file = file_get_contents("$snort_UrlGet/{$snort_filename}"); // use a @ infront of file_get_contents when in production
+ $f = fopen("{$tmpfname}/{$snort_filename}", 'w');
+ fwrite($f, $file);
+ fclose($f);
+ update_output_window2('ms2', 'Finnished Downloading ' . $snort_filename. ' MD5...');
+ }
+ }
+
+ function read_header2($ch, $string) {
+ global $file_size, $fout;
+ $length = strlen($string);
+ $regs = "";
+ ereg("(Content-Length:) (.*)", $string, $regs);
+ if($regs[2] <> "") {
+ $file_size = intval($regs[2]);
+ }
+ ob_flush();
+ return $length;
+ }
+
+ function read_body2($ch, $string) {
+ global $fout, $file_size, $downloaded, $sendto, $static_status, $static_output, $lastseen;
+ global $pkg_interface;
+ $length = strlen($string);
+ $downloaded += intval($length);
+ if($file_size > 0) {
+ $downloadProgress = round(100 * (1 - $downloaded / $file_size), 0);
+ $downloadProgress = 100 - $downloadProgress;
+ } else
+ $downloadProgress = 0;
+ if($lastseen <> $downloadProgress and $downloadProgress < 101) {
+ if($sendto == "status") {
+ if($pkg_interface == "console") {
+ if(substr($downloadProgress,2,1) == "0" || count($downloadProgress) < 2) {
+ $tostatus = $static_status . $downloadProgress . "%";
+ update_status($tostatus);
+ }
+ } else {
+ $tostatus = $static_status . $downloadProgress . "%";
+ update_status($tostatus);
+ }
+ } else {
+ if($pkg_interface == "console") {
+ if(substr($downloadProgress,2,1) == "0" || count($downloadProgress) < 2) {
+ $tooutput = $static_output . $downloadProgress . "%";
+ update_output_window($tooutput);
+ }
+ } else {
+ $tooutput = $static_output . $downloadProgress . "%";
+ update_output_window($tooutput);
+ }
+ }
+ update_progress_bar($downloadProgress);
+ $lastseen = $downloadProgress;
+ }
+ if($fout)
+ fwrite($fout, $string);
+ ob_flush();
+ return $length;
+ }
+
+ /*
+ * update_progress_bar($percent): updates the javascript driven progress bar.
+ */
+ function update_progress_bar2($percent, $file_size, $downloaded)
+ {
+ if($percent > 100) $percent = 1;
+
+ if ($GLOBALS['tmp']['snort']['downloadupdate']['console'] != 'on')
+ {
+ snortSql_updateRuleSetList('percent2', $percent, $file_size, $downloaded, $GLOBALS['tmp']['snort']['downloadupdate']['workingfile']); // write out percent to db
+ }else{
+ echo "\n" . 'percent: ' . $percent . ' filesize: ' . $file_size . ' downloaded: ' . $downloaded;
+ }
+ }
+
+
+ function read_body_firmware($ch, $string) {
+ global $fout, $file_size, $downloaded, $counter;
+ $length = strlen($string);
+ $downloaded += intval($length);
+ $downloadProgress = round(100 * (1 - $downloaded / $file_size), 0);
+ $downloadProgress = 100 - $downloadProgress;
+ $counter++;
+ if($counter > 150) {
+ update_progress_bar2($downloadProgress, $file_size, $downloaded);
+ flush();
+ $counter = 0;
+ }
+ fwrite($fout, $string);
+ return $length;
+ }
+
+ function download_file_with_progress_bar2($url_file, $destination, $workingfile, $readbody = 'read_body2') {
+ global $ch, $fout, $file_size, $downloaded;
+ $file_size = 1;
+ $downloaded = 1;
+ $destination_file = $destination . '/' . $workingfile;
+
+ /* open destination file */
+ $fout = fopen($destination_file, "wb");
+
+ /*
+ * Originally by Author: Keyvan Minoukadeh
+ * Modified by Scott Ullrich to return Content-Length size
+ */
+
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL, $url_file);
+ curl_setopt($ch, CURLOPT_HEADERFUNCTION, 'read_header2');
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+ curl_setopt($ch, CURLOPT_WRITEFUNCTION, $readbody);
+ curl_setopt($ch, CURLOPT_NOPROGRESS, '1');
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, '5');
+ curl_setopt($ch, CURLOPT_TIMEOUT, 0);
+
+ curl_exec($ch);
+ $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+ if($fout)
+ fclose($fout);
+ curl_close($ch);
+ return ($http_code == 200) ? true : $http_code;
+ }
+
+// ----------------------------------------------------- Begin Code --------------------------------------------
+
+ /*
+ if (!file_exists("{$tmpfname}/{$snort_filename}"))
+ {
+ $GLOBALS['tmp']['snort']['downloadupdate']['workingfile'] = $snort_filename;
+ snortSql_updateRuleSetList('working', 'on', '', '', $snort_filename); // finish downloading
+ //download_file_with_progress_bar2("http://www.snort.org/pub-bin/oinkmaster.cgi/{$oinkid}/{$snort_filename}", $tmpfname . "/{$snort_filename}", "read_body_firmware");
+ download_file_with_progress_bar2("http://theseusnetworking.com/pub-bin/oinkmaster.cgi/{$oinkid}/{$snort_filename}", $tmpfname, $snort_filename, "read_body_firmware");
+ snortSql_updateRuleSetList('percent', '100', '', '', $snort_filename); // finsh percent
+ snortSql_updateRuleSetList('working', 'off', '', '', $snort_filename); // finish downloading
+ }
+ */
+
+
+
+ // rm all tmp filea
+ exec("/bin/rm -r $tmpfname/\*");
+
+ // Set all downloads to be true so NO download by default
+ $snort_md5_check_ok = true;
+ $emerg_md5_check_ok = true;
+ $pfsense_md5_check_ok = true;
+
+ /* define checks */
+ $snortdownload = $generalSettings['snortdownload'];
+ //$oinkid = $generalSettings['oinkmastercode'];
+ $oinkid = '55a1b7a1291b55ac3c157124133744cfc386bb83'; // remove when finished testing
+
+ $emergingthreats = $generalSettings['emergingthreatsdownload'];
+ $emergingthreatscode = $generalSettings['emergingthreatscode'];
+
+
+
+ if ($oinkid == '' && $snortdownload == 'on')
+ {
+ update_output_window2('ms1', 'You must obtain an oinkid from snort.org and set its value in the Snort settings tab.');
+ 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;
+ }
+
+ if ($snortdownload != "on" && $emergingthreats != "on")
+ {
+ update_output_window2('ms1', 'SnortStartup: No rules have been selected to download.');
+ exec("/usr/bin/logger -p daemon.info -i -t SnortStartup 'No rules have been selected to download.'");
+ exit;
+ }
+
+ /*
+ * Check MD5s and MARK
+ *
+ */
+ update_output_window2('ms1', 'Starting MD5 checks.....');
+
+ // download snort.org md5 and compare
+ snort_file_get_contents($tmpfname, $snort_filename_md5, 'http://www.snort.org/pub-bin/oinkmaster.cgi/' . $oinkid);
+
+ // if snort.org md5 do not match
+ if(!snortCmpareMD5('string', $tmpfname, $snortdir, $snort_filename_md5))
+ {
+ $snort_md5_check_ok = false;
+ }
+
+ // download emergingthreats.net md5 and compare
+ snort_file_get_contents($tmpfname, $emergingthreats_filename_md5, 'http://rules.emergingthreats.net/open/snort-2.9.0');
+
+ // if emergingthreats.net md5 do not match
+ if(!snortCmpareMD5('string', $tmpfname, $snortdir, $emergingthreats_filename_md5))
+ {
+ $emerg_md5_check_ok = false;
+ }
+
+ // download pfsense.org md5 and compare
+ snort_file_get_contents($tmpfname, $pfsense_rules_filename_md5, 'http://www.pfsense.com/packages/config/snort/pfsense_rules');
+
+ // if pfsense.org md5 do not match
+ if(!snortCmpareMD5('string', $tmpfname, $snortdir, $pfsense_rules_filename_md5))
+ {
+ $pfsense_md5_check_ok = false;
+ }
+
+
+
+
+// ----------------------------------------------------- End Code --------------------------------------------
+
+} // -------------------- END Main function ------------
+
+$argv[1] = 'console';
+
+sendUpdateSnortLogDownload($argv[1]); // start main function
+
+
+
+
+
+
+?> \ No newline at end of file
diff --git a/config/snort-dev/snort_download_updates.php b/config/snort-dev/snort_download_updates.php
new file mode 100644
index 00000000..4f99cda8
--- /dev/null
+++ b/config/snort-dev/snort_download_updates.php
@@ -0,0 +1,333 @@
+<?php
+/* $Id$ */
+/*
+ snort_interfaces.php
+ part of m0n0wall (http://m0n0.ch/wall)
+
+ Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Pfsense snort GUI
+ Copyright (C) 2008-2011 Robert Zelaya.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+
+require_once("guiconfig.inc");
+require_once("/usr/local/pkg/snort/snort_new.inc");
+require_once("/usr/local/pkg/snort/snort_gui.inc");
+
+
+// set page vars
+
+$generalSettings = snortSql_fetchAllSettings('snortDB', 'SnortSettings', 'id', '1');
+
+header("Cache-Control: no-cache, must-revalidate");
+header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
+
+
+ $pgtitle = 'Services: Snort: Updates';
+ include("/usr/local/pkg/snort/snort_head.inc");
+
+?>
+
+
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+
+
+<div id="loadingWaiting">
+ <p class="loadingWaitingMessage"><img src="./images/loading.gif" /> <br>Please Wait...</p>
+</div>
+
+<div class="pb_div" id="pb3"></div>
+
+<div id="loadingRuleUpadteGUI">
+
+ <div class="loadingWaitingUpdateGUI" >
+ <table>
+ <tr>
+ <td>Yellow Bar</td>
+ </tr>
+ <tr>
+ <td><span class="progressBar" id="pb2"></span></td>
+ </tr>
+ <tr>
+ <td>Yellow Bar</td>
+ </tr>
+ </table>
+ </div>
+
+
+ <!-- progress bar -->
+ <!--
+ <table id="progholder" width='800px' style='border-collapse: collapse; border: 1px solid #000000;' cellpadding='2' cellspacing='2' bgcolor="#eeeeee">
+ <tr>
+ <td>
+ <img border='0' src='/themes/<?= $g['theme']; ?>/images/misc/progress_bar.gif' width='280' height='23' name='progressbar' id='progressbar' alt='' />
+ </td>
+ </tr>
+ </table>
+ <br />
+
+ <table width="800px" cellpadding="9" cellspacing="9" bgcolor="#eeeeee">
+ <tr>
+ <td align="center" valign="top">
+ <textarea cols="90" rows="2" name="status" id="status" wrap="hard">
+ <?=gettext("Initializing...");?>
+ </textarea>
+ <textarea cols="90" rows="2" name="output" id="output" wrap="hard">
+ </textarea>
+ </td>
+ </tr>
+ </table>
+ -->
+
+
+</div>
+
+
+<?php include("fbegin.inc"); ?>
+
+<div class="body2"><!-- hack to fix the hardcoed fbegin link in header -->
+<div id="header-left2"><a href="../index.php" id="status-link2"><img src="./images/transparent.gif" border="0"></img></a></div>
+
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td>
+
+ <div class="newtabmenu" style="margin: 1px 0px; width: 790px;"><!-- Tabbed bar code-->
+ <ul class="newtabmenu">
+ <li><a href="/snort/snort_interfaces.php"><span>Snort Interfaces</span></a></li>
+ <li><a href="/snort/snort_interfaces_global.php"><span>Global Settings</span></a></li>
+ <li class="newtabmenu_active"><a href="/snort/snort_download_updates.php"><span>Updates</span></a></li>
+ <li><a href="/snort/snort_alerts.php"><span>Alerts</span></a></li>
+ <li><a href="/snort/snort_blocked.php"><span>Blocked</span></a></li>
+ <li><a href="/snort/snort_interfaces_whitelist.php"><span>Whitelists</span></a></li>
+ <li><a href="/snort/snort_interfaces_suppress.php"><span>Suppress</span></a></li>
+ <li><a href="/snort/snort_help_info.php"><span>Help</span></a></li>
+ </li>
+ </ul>
+ </div>
+
+ </td>
+ </tr>
+ <tr>
+ <td>
+
+ <div class="newtabmenu" style="margin: 1px 0px; width: 775px;"><!-- Tabbed bar code-->
+ <ul class="newtabmenu">
+ <li class="newtabmenu_active"><a href="/snort/snort_download_rules.php"><span>Rule Update</span></a></li>
+ <li><a href="#"><span>Upload Custom Rules</span></a></li>
+ <li><a href="#"><span>Gui Update</span></a></li>
+ </ul>
+
+ </div>
+
+ </td>
+ </tr>
+ <tr>
+ <td id="tdbggrey">
+ <div style="width:780px; margin-left: auto ; margin-right: auto ; padding-top: 10px; padding-bottom: 10px;">
+ <!-- START MAIN AREA -->
+
+
+ <!-- start Interface Satus -->
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr id="maintable77" >
+ <td colspan="2" valign="top" class="listtopic2">
+ There are <?=$countSig; ?> rule databases that are ready to be updated.
+ </td>
+ <td width="6%" colspan="2" valign="middle" class="listtopic3" >
+ </td>
+ </tr>
+ </table>
+<br>
+
+ <!-- start User Interface -->
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr id="maintable77" >
+ <td colspan="2" valign="top" class="listtopic">SIGNATURE RULESET DATABASES:</td>
+ </tr>
+ </table>
+
+
+ <table class="vncell2" width="100%" border="0" cellpadding="0" cellspacing="0">
+
+ <td class="list" ></td>
+ <td class="list" valign="middle" >
+
+ <tr id="frheader" >
+ <td width="1%" class="listhdrr2">On</td>
+ <td width="25%" class="listhdrr2">Signature DB Name</td>
+ <td width="35%" class="listhdrr2">MD5 Version</td>
+ <td width="38%" class="listhdrr2">New Rule DB Available</td>
+ <td width="1%" class="listhdrr2">&nbsp;</td>
+ </tr>
+
+ <!-- START javascript sid loop here -->
+ <tbody class="rulesetloopblock">
+
+<tr id="fr0" valign="top">
+<td class="odd_ruleset2">
+<input class="domecheck" name="filenamcheckbox2[]" value="1292" checked="checked" type="checkbox" disabled="disabled" >
+</td>
+<td class="odd_ruleset2" id="frd0">SNORT.ORG</td>
+<td class="odd_ruleset2" id="frd0">tcp</td>
+<td class="listbg" id="frd0"><font color="white">ATTACK-RESPONSES directory listing</font></td>
+<td class="odd_ruleset2">
+<img src="/themes/pfsense_ng/images/icons/icon_alias_url_reload.gif" title="edit rule" width="17" border="0" height="17">
+</td>
+</tr>
+
+<tr id="fr0" valign="top">
+<td class="odd_ruleset2">
+<input class="domecheck" name="filenamcheckbox2[]" value="1292" checked="checked" type="checkbox" disabled="disabled" >
+</td>
+<td class="odd_ruleset2" id="frd0">EMERGINGTHREATS.NET</td>
+<td class="odd_ruleset2" id="frd0">tcp</td>
+<td class="listbg" id="frd0"><font color="white">ATTACK-RESPONSES directory listing</font></td>
+<td class="odd_ruleset2">
+<img src="/themes/pfsense_ng/images/icons/icon_alias_url_reload.gif" title="edit rule" width="17" border="0" height="17">
+</td>
+</tr>
+
+<tr id="fr0" valign="top">
+<td class="odd_ruleset2">
+<input class="domecheck" name="filenamcheckbox2[]" value="1292" checked="checked" type="checkbox" disabled="disabled" >
+</td>
+<td class="odd_ruleset2" id="frd0">PFSENSE.ORG</td>
+<td class="odd_ruleset2" id="frd0">tcp</td>
+<td class="listbg" id="frd0"><font color="white">ATTACK-RESPONSES directory listing</font></td>
+<td class="odd_ruleset2">
+<img src="/themes/pfsense_ng/images/icons/icon_alias_url_reload.gif" title="edit rule" width="17" border="0" height="17">
+</td>
+</tr>
+
+ </tbody>
+ <!-- STOP javascript sid loop here -->
+
+ </td>
+ <td class="list" colspan="8"></td>
+
+ </table>
+ <br>
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td>
+ <input name="update" type="submit" class="formbtn" value="Update">
+ </td>
+ </tr>
+ </table>
+ <br>
+
+ <!-- stop snortsam -->
+
+ <!-- STOP MAIN AREA -->
+ </div>
+ </td>
+ </tr>
+</table>
+</div>
+
+<!-- start info box -->
+
+<br>
+
+<div style="width:790px; background-color: #dddddd;" id="mainarea4">
+<div style="width:780px; margin-left: auto ; margin-right: auto ; padding-top: 10px; padding-bottom: 10px;">
+<table class="vncell2" width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr >
+ <td width="10%" valign="middle" >
+ <img style="vertical-align: middle;" src="/snort/images/icon_excli.png" width="40" height="32">
+ </td>
+ <td width="90%" valign="middle" >
+ <span class="red"><strong>Note:</strong></span>
+ <strong>&nbsp;&nbsp;Snort.org and Emergingthreats.net will go down from time to time. Please be patient.</strong>
+ </td>
+ </tr>
+</table>
+</div>
+</div>
+
+
+<script type="text/javascript">
+
+
+//prepare the form when the DOM is ready
+jQuery(document).ready(function() {
+
+ jQuery('input[name=update]').live('click', function(){
+
+ // jQuery("#pb2").progressBar(percent,{width: 404, height: 22, barImage: 'images/pb_orange.png'});
+ // console.log(response[0].percent);
+ // '/snort/snort_json_get.php?snortGetUpdate=1'
+
+ showLoading('#loadingRuleUpadteGUI');
+
+ function callComplete(response) {
+ //alert("Response received is: "+response);
+
+ while(1)
+ {
+ console.log('HELLO: ' + response[0].percent);
+ // reconnect to the server
+ //connect();
+
+ if(response[0].percent === '100')
+ {
+ console.log('HELLO: ' + response[0].percent);
+ break;
+ }
+
+ };
+
+
+ };
+
+ function connect() {
+ // when the call completes, callComplete() will be called along with
+ // the response returned
+ jQuery.get('/snort/snort_json_get.php?snortGetUpdate=1', {}, callComplete, 'json');
+ };
+
+ connect(); // start loop
+
+
+ }); // end of on click
+
+}); // end of document ready
+
+</script>
+
+
+<!-- stop info box -->
+
+<!-- footer do not touch below -->
+<?php
+include("fend.inc");
+echo $snort_custom_rnd_box;
+?>
+
+
+</body>
+</html>
diff --git a/config/snort-dev/snort_headbase.inc b/config/snort-dev/snort_headbase.inc
index 4cf02489..6a2492ad 100644
--- a/config/snort-dev/snort_headbase.inc
+++ b/config/snort-dev/snort_headbase.inc
@@ -8,6 +8,7 @@
<script type="text/javascript" src="./javascript/jquery-1.6.min.js"></script>
<script type="text/javascript" src="./javascript/snort_globalsend.js"></script>
<script type="text/javascript" src="./javascript/jquery.form.js"></script>
+<script type="text/javascript" src="./javascript/jquery.progressbar.min.js"></script>
<!-- <script type="text/javascript" src="./javascript/jquery.bubblepopup.v2.3.1.min.js"></script> -->
<!-- STOP of Snort Package css and javascript -->
diff --git a/config/snort-dev/snort_json_get.php b/config/snort-dev/snort_json_get.php
index a8cdcd2d..1fdcc1e7 100644
--- a/config/snort-dev/snort_json_get.php
+++ b/config/snort-dev/snort_json_get.php
@@ -2,10 +2,49 @@
require_once("guiconfig.inc");
require_once("/usr/local/pkg/snort/snort_new.inc");
+require_once("/usr/local/pkg/snort/snort_download_rules.inc");
+session_start(); // alwaya at the very top of a php page or "Cannot send session cache limiter - headers already sent"
-
-
+// upload created log tar to user
+if ($_GET['snortGetUpdate'] == 1)
+{
+
+ $tmpfname = "/usr/local/etc/snort/snort_download";
+ $snort_filename = "snortrules-snapshot-2905.tar.gz";
+
+
+ $snortSessionPath = $_SESSION['tmp']['snort']['snort_download_updates'];
+
+ if (!file_exists("{$tmpfname}/{$snort_filename}"))
+ {
+
+ if ($snortSessionPath['download']['working'] != '1')
+ {
+ unset($_SESSION['tmp']);
+ $snortSessionPath['download']['working'] = '1';
+ sendUpdateSnortLogDownload();
+ }
+
+ }
+
+ $time = time();
+ while((time() - $time) < 30) {
+ // query memcache, database, etc. for new data
+ $data = $datasource->getLatest();
+
+ // if we have new data return it
+ if(!empty($data)) {
+ echo json_encode($data);
+ ob_flush();
+ flush();
+ break;
+ }
+
+ usleep(25000);
+ }
+
+} // end main if