-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbase_main.php
299 lines (280 loc) · 12.5 KB
/
base_main.php
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
<?php
/*
** Copyright (C) 2004 Kevin Johnson
** Copyright (C) 2000 Carnegie Mellon University
**
** Author: Kevin Johnson <[email protected]>
** Project Leads: Kevin Johnson <[email protected]>
** Sean Muller <[email protected]>
** Built upon work by Roman Danyliw <[email protected]>, <[email protected]>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/*
* Basic Analysis and Security Engine (BASE) by Kevin Johnson
* based upon Analysis Console for Incident Databases (ACID) by Roman Danyliw
*
* See http://sourceforge.net/projects/secureideas for the most up to date
* information and documentation about this application.
*
* Purpose:
*
* BASE is an PHP-based analysis engine to search and process
* a database of security incidents generated by the NIDS Snort.
*
* Configuration:
*
* See the 'docs/README' file, and 'base_conf.php'
*
*/
$sc = DIRECTORY_SEPARATOR;
require_once("includes$sc" . 'base_krnl.php');
include_once("$BASE_path$sc" . "includes$sc" . 'base_include.inc.php');
include_once("$BASE_path/base_db_common.php");
AuthorizedRole(10000);
// Initialize the history
$_SESSION = NULL;
InitArray($_SESSION['back_list'], 1, 3, '');
$_SESSION['back_list_cnt'] = 0;
PushHistory();
if ( isset($_GET['archive']) ){ // Set cookie to use the correct db.
"no" == $_GET['archive'] ? $value = 0 : $value = 1;
BCS('archive', $value);
HTTP_header("Location: $BASE_urlpath/base_main.php");
}
function DBLink(){ // Generate link to select other DB.
GLOBAL $archive_exists;
if ( ChkArchive() ){
NLIO('<a href="base_main.php?archive=no">'
. Icon('alert', _USEALERTDB, 6) . _USEALERTDB . '</a>', 5
);
}elseif( $archive_exists != 0 ){
NLIO(
'<a href="base_main.php?archive=1">'
. Icon('archive', _USEARCHIDB, 6) . _USEARCHIDB . '</a>', 5
);
}
}
PrintBASESubHeader('', '', '', 1);
$CTR = verify_php_build($DBtype); // Check that PHP was built correctly.
// @codeCoverageIgnoreStart
if ( LoadedString($CTR) ){
BuildError($CTR, $CTR);
}
// @codeCoverageIgnoreEnd
$db = NewBASEDBConnection($DBlib_path, $DBtype); // Connect to DB.
$db->baseDBConnect(
$db_connect_method, $alert_dbname, $alert_host, $alert_port, $alert_user,
$alert_password
);
// Check that DB schema is recent.
$CTR = verify_db($db, $alert_dbname, $alert_host);
// @codeCoverageIgnoreStart
if ( LoadedString($CTR) ){
BuildError($CTR, $CTR);
}
// @codeCoverageIgnoreEnd
NLIO("<table width='100%' style='border:0;padding:0'>",2);
NLIO('<tr>',2);
NLIO("<td align='left' rowspan='2'>",3);
// Various things for the snapshot functiuonality on the first page.... Kevin
$tmp_month = date("m");
$tmp_day = date("d");
$tmp_year = date("Y");
$tmp_DSO = '&sort_order=occur_d'; // Default Sort Order.
$today = '&time%5B0%5D%5B0%5D=+&time%5B0%5D%5B1%5D=%3E%3D'.
'&time%5B0%5D%5B2%5D='.$tmp_month.
'&time%5B0%5D%5B3%5D='.$tmp_day.
'&time%5B0%5D%5B4%5D='.$tmp_year.
'&time%5B0%5D%5B5%5D=&time%5B0%5D%5B6%5D=&time%5B0%5D%5B7%5D='.
'&time%5B0%5D%5B8%5D=+&time%5B0%5D%5B9%5D=+';
$yesterday_year = date("Y", time() - 86400);
$yesterday_month = date("m", time() - 86400);
$yesterday_day = date ("d", time() - 86400);
$yesterday_hour = date ("H", time() - 86400);
$yesterday = '&time%5B0%5D%5B0%5D=+&time%5B0%5D%5B1%5D=%3E%3D'.
'&time%5B0%5D%5B2%5D='.$yesterday_month.
'&time%5B0%5D%5B3%5D='.$yesterday_day.
'&time%5B0%5D%5B4%5D='.$yesterday_year.
'&time%5B0%5D%5B5%5D='.$yesterday_hour.
'&time%5B0%5D%5B6%5D=&time%5B0%5D%5B7%5D='.
'&time%5B0%5D%5B8%5D=+&time%5B0%5D%5B9%5D=+';
$last72_year = date("Y", time()-86400 * 3);
$last72_month = date("m", time()-86400 * 3);
$last72_day = date ("d", time()-86400 * 3);
$last72_hour = date ("H", time()-86400 * 3);
$last72 = '&time%5B0%5D%5B0%5D=+&time%5B0%5D%5B1%5D=%3E%3D'.
'&time%5B0%5D%5B2%5D='.$last72_month.
'&time%5B0%5D%5B3%5D='.$last72_day.
'&time%5B0%5D%5B4%5D='.$last72_year.
'&time%5B0%5D%5B5%5D='.$last72_hour.
'&time%5B0%5D%5B6%5D=&time%5B0%5D%5B7%5D='.
'&time%5B0%5D%5B8%5D=+&time%5B0%5D%5B9%5D=+';
$tmp_24hour = 'base_qry_main.php?new=1'.$yesterday.'&submit='._QUERYDBP.'&num_result_rows=-1&time_cnt=1';
$tmp_24hour_unique = 'base_stat_alerts.php?time_cnt=1'.$yesterday;
$tmp_24hour_sip = 'base_stat_uaddr.php?addr_type=1' . $tmp_DSO . '&time_cnt=1'.$yesterday;
$tmp_24hour_dip = 'base_stat_uaddr.php?addr_type=2' . $tmp_DSO . '&time_cnt=1'.$yesterday;
$tmp_72hour = 'base_qry_main.php?new=1'.$last72.'&submit='._QUERYDBP.'&num_result_rows=-1&time_cnt=1';
$tmp_72hour_unique = 'base_stat_alerts.php?time_cnt=1'.$last72;
$tmp_72hour_sip = 'base_stat_uaddr.php?addr_type=1' . $tmp_DSO . '&time_cnt=1'.$last72;
$tmp_72hour_dip = 'base_stat_uaddr.php?addr_type=2' . $tmp_DSO . '&time_cnt=1'.$last72;
$tmp_today = 'base_qry_main.php?new=1'.$today.'&submit='._QUERYDBP.'&num_result_rows=-1&time_cnt=1';
$tmp_today_unique = 'base_stat_alerts.php?time_cnt=1'.$today;
$tmp_sip = 'base_stat_uaddr.php?addr_type=1' . $tmp_DSO . '&time_cnt=1'.$today;
$tmp_dip = 'base_stat_uaddr.php?addr_type=2' . $tmp_DSO . '&time_cnt=1'.$today;
$tmp_Source = _SOURCE;
$tmp_Dest = _DEST;
echo '
<div class="stats">
<table width="100%" class="systemstats">
<tr class="main_quick_surf">
<td style="text-align:left;">- '. _TALERTS .'</td>
<td><a href="'.$tmp_today_unique.'">'. _UNI .'</a></td>
<td><a href="'.$tmp_today.'">'. _LISTING .'</a></td>
<td><a href="'.$tmp_sip.'">'._SOURCEIP.'</a></td>
<td><a href="'.$tmp_dip.'">'._DESTIP.'</a></td>
</tr>
<tr class="main_quick_surf">
<td style="text-align:left;">- '. _L24ALERTS .'</td>
<td><A href="'.$tmp_24hour_unique.'">'. _UNI .'</a></td>
<td><A href="'.$tmp_24hour.'">'. _LISTING .'</a></td>
<td><A href="'.$tmp_24hour_sip.'">'._SOURCEIP.'</a></td>
<td><A href="'.$tmp_24hour_dip.'">'._DESTIP.'</a></td>
</tr>
<tr class="main_quick_surf">
<td style="text-align:left;">- '. _L72ALERTS .'</td>
<td><a href="'.$tmp_72hour_unique.'">'._UNI.'</a></td>
<td><a href="'.$tmp_72hour.'">'. _LISTING .'</a></td>
<td><a href="'.$tmp_72hour_sip.'">'._SOURCEIP.'</a></td>
<td><a href="'.$tmp_72hour_dip.'">'._DESTIP.'</a></td>
</tr>
<tr class="main_quick_surf">
<td style="text-align:left;">- ' . _MOSTRECENT . $last_num_alerts . _ALERTS .'</td>
<td><a href="base_qry_main.php?new=1&caller=last_any&num_result_rows=-1&submit=Last%20Any">' . _ANYPROTO . '</a></td>
<td><a href="base_qry_main.php?new=1&layer4=TCP&caller=last_tcp&num_result_rows=-1&submit=Last%20TCP">TCP</a></td>
<td><a href="base_qry_main.php?new=1&layer4=UDP&caller=last_udp&num_result_rows=-1&submit=Last%20UDP">UDP</a></td>
<td><a href="base_qry_main.php?new=1&layer4=ICMP&caller=last_icmp&num_result_rows=-1&submit=Last%20ICMP">ICMP</a></td>
</tr>
<tr class="main_quick_surf">
<td style="text-align:left;">- '._LSOURCEPORTS.'</td>
<td><a href="base_stat_ports.php?caller=last_ports&port_type=1&proto=-1&sort_order=last_d">'._ANYPROTO.'</a></td>
<td><a href="base_stat_ports.php?caller=last_ports&port_type=1&proto=6&sort_order=last_d">TCP</a></td>
<td><a href="base_stat_ports.php?caller=last_ports&port_type=1&proto=17&sort_order=last_d">UDP</a></td>
</tr>
<tr class="main_quick_surf">
<td style="text-align:left;">- '._LDESTPORTS.'
<td><a href="base_stat_ports.php?caller=last_ports&port_type=2&proto=-1&sort_order=last_d">'._ANYPROTO.'</a></td>
<td><a href="base_stat_ports.php?caller=last_ports&port_type=2&proto=6&sort_order=last_d">TCP</a></td>
<td><a href="base_stat_ports.php?caller=last_ports&port_type=2&proto=17&sort_order=last_d">UDP</a></td>
</tr>
<tr class="main_quick_surf">
<td style="text-align:left;">- '._FREGSOURCEP.'</td>
<td><a href="base_stat_ports.php?caller=most_frequent&port_type=1&proto=-1' . $tmp_DSO . '">'._ANYPROTO.'</a></td>
<td><a href="base_stat_ports.php?caller=most_frequent&port_type=1&proto=6' . $tmp_DSO . '">TCP</a></td>
<td><a href="base_stat_ports.php?caller=most_frequent&port_type=1&proto=17' . $tmp_DSO . '">UDP</a></td>
</tr>
<tr class="main_quick_surf">
<td style="text-align:left;">- '._FREGDESTP.'</td>
<td><a href="base_stat_ports.php?caller=most_frequent&port_type=2&proto=-1' . $tmp_DSO . '">'._ANYPROTO.'</a></td>
<td><a href="base_stat_ports.php?caller=most_frequent&port_type=2&proto=6' . $tmp_DSO . '">TCP</a></td>
<td><a href="base_stat_ports.php?caller=most_frequent&port_type=2&proto=17' . $tmp_DSO . '">UDP</a></td>
</tr>
<tr class="main_quick_surf">
<td style="text-align:left;">- '._MOSTFREQUENT . $freq_num_uaddr . " " ._ADDRESSES.":".'</td>';
NLIO('<td>',4);
NLIO(
"<a href='base_stat_uaddr.php?caller=most_frequent&addr_type=1"
. $tmp_DSO . "'>" . $tmp_Source . '</a>', 5
);
NLIO('</td><td>',4);
NLIO(
"<a href='base_stat_uaddr.php?caller=most_frequent&addr_type=2"
. $tmp_DSO . "'>" . $tmp_Dest . '</a>', 5
);
NLIO('<td>',4);
NLIO("</tr><tr class='main_quick_surf_2'>",3);
echo' <td colspan=2>- <a href="base_stat_alerts.php?caller=last_alerts&sort_order=last_d">'._MOSTRECENT.$last_num_ualerts._UNIALERTS.'</a></td>
</tr>
<tr class="main_quick_surf_2">
<td colspan=2>- <a href="base_stat_alerts.php?caller=most_frequent' . $tmp_DSO . '">'._MOSTFREQUENT . $freq_num_alerts . " " ._UNIALERTS.'</a>';
PrintFramedBoxFooter(1,2);
print ' </div>
</td>
<td align="right" valign="top">
<div class="systemstats">';
UpdateAlertCache($db);
NLIO('<b>' . _QUERIED . ':</b> ' . date('D F d, Y H:i:s') . '<br/>');
$DSN = $db->DB_host; // Pull this info from the DB object.
$tdp = $db->DB_port;
if ( LoadedString($tdp) ){
$DSN = "$DSN:$tdp";
}
$tmp = $db->DB_name . '@' . $DSN;
printf(
"<b>" . _DATABASE . "</b> %s (<b>" . _SCHEMAV . "</b> %d)<br/>",
$tmp, $db->baseGetDBversion()
);
StartStopTime($start_time, $end_time, $db);
$tmp = '<b>' . _TIMEWIN . '</b> ';
if ( LoadedString($start_time) ){
$tmp .= '[' . $start_time . '] - [' . $end_time . ']';
}else{
$tmp .= '<em>' . _NOALERTSDETECT . '</em>';
}
NLIO($tmp,4);
NLIO('</div>',3);
PrintTblNewRow(0);
?>
<td align="center" valign="top">
<?php
NLIO(
"<a href='base_qry_main.php?new=1'>" . Icon('search', _SEARCH, 6)
. _SEARCH . '</a>', 5
);
NLIO('<br/>', 5);
if ( PearInc('Graphing', 'Image', 'Graph') ){
NLIO(
"<a href='base_graph_main.php?new=1'>" . Icon('graph', _GALERTD, 6)
. _GALERTD . '</a>', 5
);
NLIO('<br/>', 5);
}
NLIO(
"<a href='base_stat_time.php'>" . Icon('graph', _GALERTDT, 6) . _GALERTDT
. '</a>', 5
);
NLIO('<br/>', 5);
DBLink();
PrintFramedBoxFooter(1,2);
NLIO('<hr/>',2);
?>
<table style='border:0' width='100%'>
<tr>
<td width='30%' valign='top'>
<?php
/* mstone 20050309 avoid count(*) if requested */
PrintGeneralStats($db, 0, $main_page_detail, "", "", $avoid_counts != 1);
/* mstone 20050309 make show_stats even leaner! */
if ( $main_page_detail == 1 ){
echo '
</td>
<td width="70%" valign="top">
<strong>'._TRAFFICPROBPRO.'</strong>';
PrintProtocolProfileGraphs($db);
}
PrintFramedBoxFooter(1,2);
NLIO('<hr/>',2);
PrintBASESubFooter();
?>