aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config/snort-dev/javascript/snort_globalsend.js6
-rw-r--r--config/snort-dev/snortDBrulesbin14336 -> 17408 bytes
-rw-r--r--config/snort-dev/snort_interfaces.php2
-rw-r--r--config/snort-dev/snort_json_post.php132
-rw-r--r--config/snort-dev/snort_new.inc37
5 files changed, 81 insertions, 96 deletions
diff --git a/config/snort-dev/javascript/snort_globalsend.js b/config/snort-dev/javascript/snort_globalsend.js
index 9f721053..04912cb3 100644
--- a/config/snort-dev/javascript/snort_globalsend.js
+++ b/config/snort-dev/javascript/snort_globalsend.js
@@ -283,7 +283,7 @@ jQuery(document).ready(function() {
var queryString = jQuery.param(formData);
// call to please wait
- showLoading();
+ showLoading('#loadingWaiting');
alert('About to submit: \n\n' + queryString);
@@ -298,13 +298,13 @@ jQuery(document).ready(function() {
var appendElem = jQuery('<br> <span>success...<span>');
appendElem.appendTo('.loadingWaitingMessage');
- setTimeout(hideLoading, 3000);
+ setTimeout(hideLoading('#loadingWaiting'), 3000);
}
// After Save Calls display
var appendElem = jQuery('<br> <span>success...<span>');
function finnish(){
- hideLoading();
+ hideLoading('#loadingWaiting');
appendElem.remove();
updatestarted = 1;
}
diff --git a/config/snort-dev/snortDBrules b/config/snort-dev/snortDBrules
index cd5da7e0..306d6774 100644
--- a/config/snort-dev/snortDBrules
+++ b/config/snort-dev/snortDBrules
Binary files differ
diff --git a/config/snort-dev/snort_interfaces.php b/config/snort-dev/snort_interfaces.php
index 56e4a600..f8f4c859 100644
--- a/config/snort-dev/snort_interfaces.php
+++ b/config/snort-dev/snort_interfaces.php
@@ -41,7 +41,7 @@ $new_ruleUUID = genAlphaNumMixFast(7, 8);
$a_interfaces = snortSql_fetchAllInterfaceRules('Snortrules', 'snortDBrules');
- $pgtitle = "Services: Snort 2.9.0.4 pkg v. 1.37";
+ $pgtitle = "Services: Snort 2.9.0.5 pkg v. 2.0";
include("/usr/local/pkg/snort/snort_head.inc");
?>
diff --git a/config/snort-dev/snort_json_post.php b/config/snort-dev/snort_json_post.php
index 8cf72f67..446e0db9 100644
--- a/config/snort-dev/snort_json_post.php
+++ b/config/snort-dev/snort_json_post.php
@@ -10,10 +10,6 @@ if(isset($_POST['__csrf_magic']))
unset($_POST['__csrf_magic']);
}
-// return codes
-$snortJsonReturnCode_success = '{"snortgeneralsettings":"success"}';
-
-$snortJsonReturnCode_fail = '{"snortgeneralsettings":"fail"}';
function snortJsonReturnCode($returnStatus)
{
@@ -67,37 +63,39 @@ if ($_POST['snortSaveRuleSets'] == 1)
if ($_POST['RMlistDelRow'] == 1)
{
- //conf_mount_rw();
if ($_POST['RMlistTable'] == 'Snortrules' || $_POST['RMlistTable'] == 'SnortSuppress')
- {
- if (snortSql_updatelistDelete($_POST['RMlistDB'], $_POST['RMlistTable'], 'uuid', $_POST['RMlistUuid']))
- {
- echo $snortJsonReturnCode_success;
- return true;
- }else{
- echo $snortJsonReturnCode_fail;
- return false;
- }
+ {
+
+ // list rules in the default dir
+ $a_list = snortSql_fetchAllSettings('snortDBrules', 'Snortrules', 'uuid', $_POST['RMlistUuid']);
+ $snortRuleDir = '/usr/local/etc/snort/sn_' . $_POST['RMlistUuid'] . '_' . $a_list['interface'];
+
+ exec('/bin/rm -r ' . $snortRuleDir);
+
+ snortSql_updatelistDelete('SnortruleSets', 'ifaceuuid', $_POST['RMlistUuid']);
+ snortSql_updatelistDelete('SnortruleSigs', 'ifaceuuid', $_POST['RMlistUuid']);
+ snortSql_updatelistDelete('Snortrules', 'uuid', $_POST['RMlistUuid']);
+
+ snortJsonReturnCode(true);
+
}
+ if ($_POST['RMlistTable'] == 'SnortSuppress')
+ {
+ snortJsonReturnCode(snortSql_updatelistDelete($_POST['RMlistTable'], 'uuid', $_POST['RMlistUuid']));
+ }
+
+
+
if ($_POST['RMlistTable'] == 'SnortWhitelist')
{
$fetchExtraWhitelistEntries = snortSql_fetchAllSettings($_POST['RMlistDB'], $_POST['RMlistTable'], 'uuid', $_POST['RMlistUuid']);
- if (snortSql_updatelistDelete($_POST['RMlistDB'], 'SnortWhitelistips', 'filename', $fetchExtraWhitelistEntries['filename']))
- {
- snortSql_updatelistDelete($_POST['RMlistDB'], $_POST['RMlistTable'], 'uuid', $_POST['RMlistUuid']);
-
- echo $snortJsonReturnCode_success;
- return true;
- }else{
- echo $snortJsonReturnCode_fail;
- return false;
- }
- }
-
- //conf_mount_ro();
+ snortJsonReturnCode(snortSql_updatelistDelete('SnortWhitelistips', 'filename', $fetchExtraWhitelistEntries['filename']));
+ snortJsonReturnCode(snortSql_updatelistDelete($_POST['RMlistTable'], 'uuid', $_POST['RMlistUuid']));
+
+ }
}
@@ -133,29 +131,15 @@ if ($_POST['snortSaveSettings'] == 1)
}
// unset POSTs that are markers not in db
- unset($_POST['snortSaveSettings']);
+ unset($_POST['snortSaveSettings']);
unset($_POST['ifaceTab']);
-
- // update date on every save
- $_POST['date'] = date(U);
-
- //print_r($_POST);
- //return true;
-
- conf_mount_rw();
- snortSql_updateSettings($_POST['dbName'], $_POST, 'id', '1');
- conf_mount_ro();
+
- echo '
- {
- "snortgeneralsettings": "success"
- }
- ';
- return true;
+ snortJsonReturnCode(snortSql_updateSettings('id', '1'));
} // end of dbTable SnortSettings
- // Save rules settings
+ // Save rule settings on the interface edit tab
if ($_POST['dbTable'] == 'Snortrules')
{
@@ -196,9 +180,9 @@ if ($_POST['snortSaveSettings'] == 1)
$newSnortDir = 'sn_' . $_POST['uuid'] . '_' . $_POST['interface'];
exec('/usr/bin/tar xvfz /usr/local/etc/snort/base_rules.tar.gz ' . '-C /usr/local/etc/snort/' . $newSnortDir);
}
- }
+ } //end of mkdir
- }
+ } // end of snort_interfaces_edit
// snort preprocessor edit
if ($_POST['ifaceTab'] == 'snort_preprocessors')
@@ -246,17 +230,9 @@ if ($_POST['snortSaveSettings'] == 1)
unset($_POST['snortSaveSettings']);
unset($_POST['ifaceTab']);
- // update date on every save
- $_POST['date'] = date(U);
-
-
- //print_r($_POST);
- //return true;
-
- snortJsonReturnCode(snortSql_updateSettings($_POST['dbName'], $_POST, 'uuid', $_POST['uuid']));
+ snortJsonReturnCode(snortSql_updateSettings('uuid', $_POST['uuid']));
- } // end of dbTable Snortrules
-
+ } // end of dbTable Snortrules
} // STOP General Settings Save
@@ -282,20 +258,10 @@ if ($_POST['snortSaveSuppresslist'] == 1)
// convert textbox to base64
$_POST['suppresspassthru'] = base64_encode($_POST['suppresspassthru']);
- //conf_mount_rw();
- snortSql_updateSettings($_POST['dbName'], $_POST, 'uuid', $_POST['uuid']);
- //conf_mount_ro();
-
- echo '
- {
- "snortgeneralsettings": "success"
- }
- ';
- return true;
-
+ // Write to database
+ snortJsonReturnCode(snortSql_updateSettings('uuid', $_POST['uuid']));
+
}
-
-
}
@@ -322,29 +288,19 @@ if ($_POST['snortSaveWhitelist'] == 1)
// unset POSTs that are markers not in db
unset($_POST['snortSaveWhitelist']);
unset($_POST['ifaceTab']);
-
- $genSettings = $_POST;
- unset($genSettings['list']);
- $genSettings['date'] = date(U);
+ // Split the POST for 2 arraus
+ $whitelistIPs = $_POST['list'];
+ unset($_POST['list']);
- //print_r($_POST);
- //return true;
- //conf_mount_rw();
- snortSql_updateSettings($_POST['dbName'], $genSettings, 'uuid', $genSettings['uuid']);
- if ($_POST['list'] != '')
+ if (snortSql_updateSettings('uuid', $_POST['uuid']) && snortSql_updateWhitelistIps($whitelistIPs))
{
- snortSql_updateWhitelistIps($_POST['dbTable'], $_POST['list'], $genSettings['filename']);
+ snortJsonReturnCode(true);
+ }else{
+ snortJsonReturnCode(false);
}
- //conf_mount_ro();
-
- echo '
- {
- "snortgeneralsettings": "success"
- }
- ';
- return true;
+
}
diff --git a/config/snort-dev/snort_new.inc b/config/snort-dev/snort_new.inc
index 9f318af0..cc574baf 100644
--- a/config/snort-dev/snort_new.inc
+++ b/config/snort-dev/snort_new.inc
@@ -250,9 +250,15 @@ function snortSql_updateRuleSigList()
} // END Save ruleSets settings
// Save ruleSets settings
-function snortSql_updateRuleSetList($dbname, $table, $ruleSetfilenames, $ifaceuuid)
+function snortSql_updateRuleSetList()
{
+ $dbname = $_POST['dbName'];
+ $table = $_POST['dbTable'];
+ $ruleSetfilenames = $_POST['filenamcheckbox'];
+ $ifaceuuid = $_POST['ifaceuuid'];
+
+
$addDate = date(U);
// do let user pick the DB path
@@ -427,7 +433,13 @@ function snortSql_fetchAllSettingsList($table, $listFilename)
}
// Update settings to database
-function snortSql_updateSettings($dbname, $settings, $type, $id_uuid) {
+function snortSql_updateSettings($type, $id_uuid)
+{
+ $dbname = $_POST['dbName'];
+ $settings = $_POST;
+
+ // update date on every save
+ $_POST['date'] = date(U);
$db = "/usr/local/pkg/snort/$dbname";
$mydb = sqlite_open("$db");
@@ -574,8 +586,16 @@ function snortSql_fetchAllWhitelistTypes($table, $table2)
// Save Whitelistips Settings
-function snortSql_updateWhitelistIps($table, $newPostListips, $filename)
+function snortSql_updateWhitelistIps($newPostListips)
{
+
+ if($newPostListips == '')
+ {
+ return true;
+ }
+
+ $table = $_POST['dbTable'];
+ $filename = $_POST['filename'];
$db = '/usr/local/pkg/snort/snortDB';
$mydb = sqlite_open("$db");
@@ -712,9 +732,11 @@ function snortSql_updateWhitelistIps($table, $newPostListips, $filename)
} // end of func
// RMlist Delete
-function snortSql_updatelistDelete($usrDB, $table, $type, $uuid_filename)
+function snortSql_updatelistDelete($table, $type, $uuid_filename)
{
+ $usrDB = $_POST['RMlistDB'];
+
$db = "/usr/local/pkg/snort/$usrDB";
$mydb = sqlite_open("$db");
@@ -732,6 +754,13 @@ function snortSql_updatelistDelete($usrDB, $table, $type, $uuid_filename)
");
}
+ if ($type == 'ifaceuuid')
+ {
+ $query = sqlite_query($mydb, // @ supress warnings use only in production
+ "DELETE FROM {$table} WHERE ifaceuuid = '{$uuid_filename}';
+ ");
+ }
+
if (sqlite_changes($mydb) < 1)
{
sqlite_close($mydb);