From e9562289eb7346dc2782e8f2ffe0236878deedc7 Mon Sep 17 00:00:00 2001 From: jim-p Date: Sat, 17 Oct 2009 15:27:13 -0400 Subject: Snort widget updates, courtesy of matrix200 --- config/widget-snort/snort_alerts.inc.php | 8 ++++++-- config/widget-snort/snort_alerts.js | 9 ++++----- config/widget-snort/snort_alerts.widget.php | 14 ++++++-------- config/widget-snort/widget-snort.xml | 2 +- 4 files changed, 17 insertions(+), 16 deletions(-) (limited to 'config/widget-snort') diff --git a/config/widget-snort/snort_alerts.inc.php b/config/widget-snort/snort_alerts.inc.php index 99e3ee9f..48506f9b 100644 --- a/config/widget-snort/snort_alerts.inc.php +++ b/config/widget-snort/snort_alerts.inc.php @@ -26,7 +26,7 @@ function get_snort_alerts($snort_alerts, $nentries, $tail = 20) { function parse_snort_alert_line($line) { $log_split = ""; - + $datesplit = ""; preg_match("/^(.*)\s+\[\*\*\]\s+\[(\d+\:\d+:\d+)\]\s(.*)\s(.*)\s+\[\*\*\].*\s+\[Priority:\s(\d+)\]\s{(.*)}\s+(.*)\s->\s(.*)$/U", $line, $log_split); list($all, $alert['time'], $alert['rule'], $alert['category'], $alert['descr'], @@ -40,6 +40,10 @@ function parse_snort_alert_line($line) { $usableline = false; if($usableline == true) { + preg_match("/^(\d+)\/(\d+)-(\d+\:\d+\:\d+).\d+$/U", $alert['time'], $datesplit); + $alert['dateonly'] = $datesplit[2] . "/" . $datesplit[1]; + $alert['timeonly'] = $datesplit[3]; + $alert['category'] = strtoupper( substr($alert["category"],0 , 1) ) . strtolower( substr($alert["category"],1 ) ); return $alert; } else { if($g['debug']) { @@ -67,7 +71,7 @@ function handle_snort_ajax($snort_alerts_logfile, $nentries = 5, $tail = 50) { preg_match("/.*([0-9][0-9]:[0-9][0-9]:[0-9][0-9]).*/", $log_row['time'], $time_regex); $row_time = strtotime($time_regex[1]); if($row_time > $lastsawtime) { - $new_rules .= "{$log_row['time']}||{$log_row['priority']}||{$log_row['category']}||{$log_row['src']}||{$log_row['dst']}||" . time() . "||\n"; + $new_rules .= "{$log_row['time']}||{$log_row['priority']}||{$log_row['category']}||{$log_row['src']}||{$log_row['dst']}||" . time() . "||{$log_row['timeonly']}||{$log_row['dateonly']}" . "||\n"; } } echo $new_rules; diff --git a/config/widget-snort/snort_alerts.js b/config/widget-snort/snort_alerts.js index 48c97d6c..2eebb140 100644 --- a/config/widget-snort/snort_alerts.js +++ b/config/widget-snort/snort_alerts.js @@ -72,10 +72,9 @@ function snort_alerts_fetch_new_rules_callback(callback_data) { /* loop through rows */ row_split = data_split[x].split("||"); var line = ''; - line = '' + row_split[1] + ''; - line += '' + row_split[2] + ''; - line += '' + row_split[3] + ''; - line += '' + row_split[4] + ''; + line = '' + row_split[6] + '
' + row_split[7]+ ''; + line += '' + row_split[3] + '
' + row_split[4] + ''; + line += '' + 'Pri : ' + row_split[1] + '
' + 'Cat : ' + row_split[2] + ''; snortlastsawtime = row_split[5]; new_data_to_add[new_data_to_add.length] = line; } @@ -142,4 +141,4 @@ function snort_alerts_toggle_pause() { } } /* start local AJAX engine */ -snorttimer = setInterval('snort_alerts_fetch_new_rules()', snortupdateDelay); +snorttimer = setInterval('snort_alerts_fetch_new_rules()', snortupdateDelay); \ No newline at end of file diff --git a/config/widget-snort/snort_alerts.widget.php b/config/widget-snort/snort_alerts.widget.php index 22bd1b69..aa416274 100644 --- a/config/widget-snort/snort_alerts.widget.php +++ b/config/widget-snort/snort_alerts.widget.php @@ -30,10 +30,9 @@ global $config, $g; - - - - + + + @@ -56,10 +55,9 @@ global $config, $g; ?> > - - - - + + + diff --git a/config/widget-snort/widget-snort.xml b/config/widget-snort/widget-snort.xml index b32a27d7..1644181c 100644 --- a/config/widget-snort/widget-snort.xml +++ b/config/widget-snort/widget-snort.xml @@ -46,7 +46,7 @@ Dashboard package and SnortCurrently there are no FAQ items provided.widget-snort - 0.1 + 0.2Widget - Snort/usr/local/pkg/widget-snort.inc -- cgit v1.2.3
PriCategorySrcDstDateSrc/DstDetails
' . $alert["dst"] ?>' . 'Cat : ' . $alert['category'] ?>