1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221
|
<?php
/*
* Analysis Console for Intrusion Databases (ACID)
*
* Author: Roman Danyliw <rdd@cert.org>, <roman@danyliw.com>
*
* Copyright (C) 2000, 2001 Carnegie Mellon University
* (see the file 'acid_main.php' for license details)
*
* Purpose: Displays statistics on the detected alerts
*
* Input GET/POST variables
* - caller
* - submit:
*/
?>
<?php
include ("acid_constants.inc");
include ("acid_conf.php");
include ("acid_include.inc");
include_once ("acid_db_common.php");
include_once ("acid_qry_common.php");
include_once ("acid_stat_common.php");
$et = new EventTiming($debug_time_mode);
$cs = new CriteriaState("acid_stat_class.php");
$cs->ReadState();
$qs = new QueryState();
$submit = ImportHTTPVar("submit");
$qs->MoveView($submit); /* increment the view if necessary */
$page_title = "Classification";
if ( $qs->isCannedQuery() )
PrintACIDSubHeader($page_title.": ".$qs->GetCurrentCannedQueryDesc(),
$page_title.": ".$qs->GetCurrentCannedQueryDesc(), $cs->GetBackLink());
else
PrintACIDSubHeader($page_title, $page_title, $cs->GetBackLink());
/* Connect to the Alert database */
$db = NewACIDDBConnection($DBlib_path, $DBtype);
$db->acidDBConnect($db_connect_method,
$alert_dbname, $alert_host, $alert_port, $alert_user, $alert_password);
if ( $event_cache_auto_update == 1 ) UpdateAlertCache($db);
$criteria_clauses = ProcessCriteria();
PrintCriteria("");
$from = " FROM acid_event ".$criteria_clauses[0];
$where = " WHERE ".$criteria_clauses[1];
$qs->AddValidAction("ag_by_id");
$qs->AddValidAction("ag_by_name");
$qs->AddValidAction("del_alert");
$qs->AddValidAction("email_alert");
$qs->AddValidAction("email_alert2");
$qs->AddValidAction("archive_alert");
$qs->AddValidAction("archive_alert2");
$qs->AddValidActionOp("Selected");
$qs->AddValidActionOp("ALL on Screen");
$qs->SetActionSQL($from.$where);
$et->Mark("Initialization");
$qs->RunAction($submit, 50, $db);
$et->Mark("Alert Action");
/* Get total number of events */
$event_cnt = EventCnt($db);
/* create SQL to get Unique Alerts */
$cnt_sql = "SELECT count(DISTINCT sig_class_id) ".$from.$where;
/* Run the query to determine the number of rows (No LIMIT)*/
$qs->GetNumResultRows($cnt_sql, $db);
$et->Mark("Counting Result size");
/* Setup the Query Results Table */
$qro = new QueryResultsOutput("acid_stat_class.php?caller=".$caller);
$qro->AddTitle(" ");
$qro->AddTitle("Classification",
"class_a", " ",
" ORDER BY sig_class_id ASC",
"class_d", " ",
" ORDER BY sig_class_id DESC");
$qro->AddTitle("Total<BR>#",
"occur_a", " ",
" ORDER BY num_events ASC",
"occur_d", " ",
" ORDER BY num_events DESC");
$qro->AddTitle("Sensor<BR>#",
"sensor_a", " ",
" ORDER BY num_sensors ASC",
"sensor_d", " ",
" ORDER BY num_sensors DESC");
$qro->AddTitle("Signatures",
"sig_a", " ",
" ORDER BY num_sig ASC",
"sig_d", " ",
" ORDER BY num_sig DESC");
$qro->AddTitle("Src.<BR>Addr.",
"saddr_a", ", count(ip_src) AS saddr_cnt ",
" ORDER BY saddr_cnt ASC",
"saddr_d", ", count(ip_src) AS saddr_cnt ",
" ORDER BY saddr_cnt DESC");
$qro->AddTitle("Dest.<BR>Addr.",
"daddr_a", ", count(ip_dst) AS daddr_cnt ",
" ORDER BY daddr_cnt ASC",
"daddr_d", ", count(ip_dst) AS daddr_cnt ",
" ORDER BY daddr_cnt DESC");
$qro->AddTitle("First",
"first_a", ", min(timestamp) AS first_timestamp ",
" ORDER BY first_timestamp ASC",
"first_d", ", min(timestamp) AS first_timestamp ",
" ORDER BY first_timestamp DESC");
$qro->AddTitle("Last",
"last_a", ", max(timestamp) AS last_timestamp ",
" ORDER BY last_timestamp ASC",
"last_d", ", max(timestamp) AS last_timestamp ",
" ORDER BY last_timestamp DESC");
$sort_sql = $qro->GetSortSQL($qs->GetCurrentSort(), $qs->GetCurrentCannedQuerySort());
//if ( $sort_sql == NULL )
// ErrorMessage("Invalid or No Sort type was specified");
$sql = "SELECT DISTINCT sig_class_id, ".
" COUNT(acid_event.cid) as num_events,".
" COUNT( DISTINCT acid_event.sid) as num_sensors, ".
" COUNT( DISTINCT signature ) as num_sig, ".
" COUNT( DISTINCT ip_src ) as num_sip, ".
" COUNT( DISTINCT ip_dst ) as num_dip, ".
" min(timestamp) as first_timestamp, ".
" max(timestamp) as last_timestamp ".
$sort_sql[0].$from.$where." GROUP BY sig_class_id ".$sort_sql[1];
/* Run the Query again for the actual data (with the LIMIT) */
$result = $qs->ExecuteOutputQuery($sql, $db);
$et->Mark("Retrieve Query Data");
if ( $debug_mode == 1 )
{
$qs->PrintCannedQueryList();
$qs->DumpState();
echo "$sql<BR>";
}
/* Print the current view number and # of rows */
$qs->PrintResultCnt();
echo '<FORM METHOD="post" NAME="PacketForm" ACTION="acid_stat_class.php">';
$qro->PrintHeader();
$i = 0;
while ( ($myrow = $result->acidFetchRow()) && ($i < $qs->GetDisplayRowCnt()) )
{
$class_id = $myrow[0];
if ( $class_id == "" )
$class_id = 0;
$total_occurances = $myrow[1];
$sensor_num = $myrow[2];
$sig_num = $myrow[3];
$sip_num = $myrow[4];
$dip_num = $myrow[5];
$min_time = $myrow[6];
$max_time = $myrow[7];
/* Print out */
qroPrintEntryHeader($i);
$tmp_rowid = rawurlencode($class_id);
echo ' <TD>
<INPUT TYPE="checkbox" NAME="action_chk_lst['.$i.']" VALUE="'.$tmp_rowid.'">
</TD>';
echo ' <INPUT TYPE="hidden" NAME="action_lst['.$i.']" VALUE="'.$tmp_rowid.'">';
qroPrintEntry(GetSigClassName($class_id, $db));
qroPrintEntry('<FONT>'.
'<A HREF="acid_qry_main.php?new=1&sig_class='.$class_id.
'&submit=Query+DB&num_result_rows=-1">'.$total_occurances.'</A>
('.(round($total_occurances/$event_cnt*100)).'%)'.
'</FONT>');
qroPrintEntry('<FONT><A HREF="acid_stat_sensor.php?sig_class='.$class_id.'">'.
$sensor_num.'</A>');
qroPrintEntry('<FONT><A HREF="acid_stat_alerts.php?sig_class='.$class_id.'">'.
$sig_num.'</FONT>');
qroPrintEntry('<FONT>'.BuildUniqueAddressLink(1, '&sig_class='.$class_id).$sip_num.'</A></FONT>');
qroPrintEntry('<FONT>'.BuildUniqueAddressLink(2, '&sig_class='.$class_id).$dip_num.'</A></FONT>');
qroPrintEntry('<FONT>'.$min_time.'</FONT>');
qroPrintEntry('<FONT>'.$max_time.'</FONT>');
qroPrintEntryFooter();
$i++;
$prev_time = null;
}
$result->acidFreeRows();
$qro->PrintFooter();
$qs->PrintBrowseButtons();
$qs->PrintAlertActionButtons();
$qs->SaveState();
$et->Mark("Get Query Elements");
$et->PrintTiming();
echo "\n</FORM>\n";
PrintACIDSubFooter();
?>
|