• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

NathanGibbs3 / BASE / 590

pending completion
590

push

travis-ci-com

NathanGibbs3
20230420 Fix CI build breakage. 2

2755 of 16977 relevant lines covered (16.23%)

21.61 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/base_main.php
1
<?php
2
/*
3
** Copyright (C) 2004 Kevin Johnson
4
** Copyright (C) 2000 Carnegie Mellon University
5
**
6
** Author: Kevin Johnson <kjohnson@secureideas.net>
7
** Project Leads: Kevin Johnson <kjohnson@secureideas.net>
8
**                Sean Muller <samwise_diver@users.sourceforge.net>
9
** Built upon work by Roman Danyliw <rdd@cert.org>, <roman@danyliw.com>
10
**
11
** This program is free software; you can redistribute it and/or modify
12
** it under the terms of the GNU General Public License as published by
13
** the Free Software Foundation; either version 2 of the License, or
14
** (at your option) any later version.
15
**
16
** This program is distributed in the hope that it will be useful,
17
** but WITHOUT ANY WARRANTY; without even the implied warranty of
18
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
** GNU General Public License for more details.
20
**
21
** You should have received a copy of the GNU General Public License
22
** along with this program; if not, write to the Free Software
23
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24
*/
25

26
/*  
27
 * Basic Analysis and Security Engine (BASE) by Kevin Johnson
28
 * based upon Analysis Console for Incident Databases (ACID) by Roman Danyliw
29
 *
30
 * See http://sourceforge.net/projects/secureideas for the most up to date 
31
 * information and documentation about this application.
32
 *
33
 * Purpose:
34
 *
35
 *   BASE is an PHP-based analysis engine to search and process 
36
 *   a database of security incidents generated by the NIDS Snort.
37
 *
38
 * Configuration:
39
 *
40
 *   See the 'docs/README' file, and 'base_conf.php'
41
 *
42
 */
43

44
   require("base_conf.php");
×
45
   include_once("$BASE_path/includes/base_auth.inc.php");
×
46
   include_once("$BASE_path/includes/base_db.inc.php");
×
47
   include_once("$BASE_path/includes/base_output_html.inc.php");
×
48
   include_once("$BASE_path/base_common.php");
×
49
   include_once("$BASE_path/base_db_common.php");
×
50
   include_once("$BASE_path/includes/base_cache.inc.php");
×
51
   include_once("$BASE_path/includes/base_state_criteria.inc.php");
×
52
   include_once("$BASE_path/includes/base_log_error.inc.php");
×
53
   include_once("$BASE_path/includes/base_log_timing.inc.php");
×
54

55
AuthorizedRole(10000);
×
56
$et = new EventTiming($debug_time_mode);
×
57
RegisterGlobalState();
×
58
// Initialize the history
59
$_SESSION = NULL;
×
60
InitArray($_SESSION['back_list'], 1, 3, "");
×
61
$_SESSION['back_list_cnt'] = 0;
×
62
PushHistory();
×
63
if ( isset($_GET['archive']) ){ // Set cookie to use the correct db.
×
64
        "no" == $_GET['archive'] ? $value = 0 : $value = 1;
×
65
        setcookie('archive', $value);
×
66
        base_header("Location: $BASE_urlpath/base_main.php");
×
67
}
68

69
function DBLink(){ // Generate link to select other DB.
70
        GLOBAL $archive_exists;
71
        if ( ChkArchive() ){
×
72
                NLIO('<a href="base_main.php?archive=no">' . _USEALERTDB . '</a>');
×
73
        }elseif( $archive_exists != 0 ){
×
74
                NLIO('<a href="base_main.php?archive=1">' . _USEARCHIDB . '</a>');
×
75
        }
76
}
77

78
PrintBASESubHeader('', '', '',1);
×
79
$CTR = verify_php_build($DBtype); // Check that PHP was built correctly.
×
80
// @codeCoverageIgnoreStart
81
if ( LoadedString($CTR) ){
82
        BuildError($CTR, $CTR);
83
}
84
// @codeCoverageIgnoreEnd
85
$db = NewBASEDBConnection($DBlib_path, $DBtype); // Connect to DB.
×
86
$db->baseDBConnect(
×
87
        $db_connect_method, $alert_dbname, $alert_host, $alert_port, $alert_user,
88
        $alert_password
89
);
90
// Check that DB schema is recent.
91
$CTR = verify_db($db, $alert_dbname, $alert_host);
×
92
// @codeCoverageIgnoreStart
93
if ( LoadedString($CTR) ){
94
        BuildError($CTR, $CTR);
95
}
96
// @codeCoverageIgnoreEnd
97

98
NLIO("<table width='100%' style='border:0;padding:0'>",2);
×
99
NLIO('<tr>',2);
×
100
NLIO("<td align='left' rowspan='2'>",3);
×
101

102
// Various things for the snapshot functiuonality on the first page.... Kevin
103
$tmp_month = date("m");
×
104
$tmp_day = date("d");
×
105
$tmp_year = date("Y");
×
106
$tmp_DSO = '&amp;sort_order=occur_d'; // Default Sort Order.
×
107
$today = '&amp;time%5B0%5D%5B0%5D=+&amp;time%5B0%5D%5B1%5D=%3E%3D'.
×
108
    '&amp;time%5B0%5D%5B2%5D='.$tmp_month.
109
    '&amp;time%5B0%5D%5B3%5D='.$tmp_day.
110
    '&amp;time%5B0%5D%5B4%5D='.$tmp_year.
111
    '&amp;time%5B0%5D%5B5%5D=&amp;time%5B0%5D%5B6%5D=&amp;time%5B0%5D%5B7%5D='.
112
    '&amp;time%5B0%5D%5B8%5D=+&amp;time%5B0%5D%5B9%5D=+';
113
$yesterday_year = date("Y", time() - 86400);
×
114
$yesterday_month = date("m", time() - 86400);
×
115
$yesterday_day = date ("d", time() - 86400);
×
116
$yesterday_hour = date ("H", time() - 86400);
×
117
$yesterday =  '&amp;time%5B0%5D%5B0%5D=+&amp;time%5B0%5D%5B1%5D=%3E%3D'.
×
118
    '&amp;time%5B0%5D%5B2%5D='.$yesterday_month.
119
    '&amp;time%5B0%5D%5B3%5D='.$yesterday_day.
120
    '&amp;time%5B0%5D%5B4%5D='.$yesterday_year.
121
    '&amp;time%5B0%5D%5B5%5D='.$yesterday_hour.
122
    '&amp;time%5B0%5D%5B6%5D=&amp;time%5B0%5D%5B7%5D='.
123
    '&amp;time%5B0%5D%5B8%5D=+&amp;time%5B0%5D%5B9%5D=+';
124
$last72_year  = date("Y", time()-86400 * 3);
×
125
$last72_month = date("m", time()-86400 * 3);
×
126
$last72_day   = date ("d", time()-86400 * 3);
×
127
$last72_hour  = date ("H", time()-86400 * 3);
×
128
$last72 = '&amp;time%5B0%5D%5B0%5D=+&amp;time%5B0%5D%5B1%5D=%3E%3D'.
×
129
    '&amp;time%5B0%5D%5B2%5D='.$last72_month.
130
    '&amp;time%5B0%5D%5B3%5D='.$last72_day.
131
    '&amp;time%5B0%5D%5B4%5D='.$last72_year.
132
    '&amp;time%5B0%5D%5B5%5D='.$last72_hour.
133
    '&amp;time%5B0%5D%5B6%5D=&amp;time%5B0%5D%5B7%5D='.
134
    '&amp;time%5B0%5D%5B8%5D=+&amp;time%5B0%5D%5B9%5D=+';
135
$tmp_24hour        = 'base_qry_main.php?new=1'.$yesterday.'&amp;submit='._QUERYDBP.'&amp;num_result_rows=-1&amp;time_cnt=1';
×
136
$tmp_24hour_unique = 'base_stat_alerts.php?time_cnt=1'.$yesterday;
×
137
$tmp_24hour_sip    = 'base_stat_uaddr.php?addr_type=1' . $tmp_DSO . '&amp;time_cnt=1'.$yesterday;
×
138
$tmp_24hour_dip    = 'base_stat_uaddr.php?addr_type=2' . $tmp_DSO . '&amp;time_cnt=1'.$yesterday;
×
139
$tmp_72hour        = 'base_qry_main.php?new=1'.$last72.'&amp;submit='._QUERYDBP.'&amp;num_result_rows=-1&amp;time_cnt=1';
×
140
$tmp_72hour_unique = 'base_stat_alerts.php?time_cnt=1'.$last72;
×
141
$tmp_72hour_sip    = 'base_stat_uaddr.php?addr_type=1' . $tmp_DSO . '&amp;time_cnt=1'.$last72;
×
142
$tmp_72hour_dip    = 'base_stat_uaddr.php?addr_type=2' . $tmp_DSO . '&amp;time_cnt=1'.$last72;
×
143
$tmp_today         = 'base_qry_main.php?new=1'.$today.'&amp;submit='._QUERYDBP.'&amp;num_result_rows=-1&amp;time_cnt=1';
×
144
$tmp_today_unique  = 'base_stat_alerts.php?time_cnt=1'.$today;
×
145
$tmp_sip           = 'base_stat_uaddr.php?addr_type=1' . $tmp_DSO . '&amp;time_cnt=1'.$today;
×
146
$tmp_dip           = 'base_stat_uaddr.php?addr_type=2' . $tmp_DSO . '&amp;time_cnt=1'.$today;
×
147

148
$tmp_Source = _SOURCE;
×
149
$tmp_Dest = _DEST;
×
150

151
echo '
×
152
          <div class="stats">
153
            <table width="100%" class="systemstats">
154
              <tr class="main_quick_surf">
155
                    <td style="text-align:left;">- '. _TALERTS .'</td>
156
                    <td><a href="'.$tmp_today_unique.'">'. _UNI .'</a></td>
157
                    <td><a href="'.$tmp_today.'">'. _LISTING .'</a></td>
158
                    <td><a href="'.$tmp_sip.'">'._SOURCEIP.'</a></td>
159
                    <td><a href="'.$tmp_dip.'">'._DESTIP.'</a></td>
160
                  </tr>
161

162
              <tr class="main_quick_surf">
163
                    <td style="text-align:left;">- '. _L24ALERTS .'</td>
164
                    <td><A href="'.$tmp_24hour_unique.'">'. _UNI .'</a></td>
165
                    <td><A href="'.$tmp_24hour.'">'. _LISTING .'</a></td>
166
                    <td><A href="'.$tmp_24hour_sip.'">'._SOURCEIP.'</a></td>
167
                    <td><A href="'.$tmp_24hour_dip.'">'._DESTIP.'</a></td>
168
                  </tr>
169

170
              <tr class="main_quick_surf">
171
                    <td style="text-align:left;">- '. _L72ALERTS .'</td>
172
                    <td><a href="'.$tmp_72hour_unique.'">'._UNI.'</a></td>
173
                    <td><a href="'.$tmp_72hour.'">'. _LISTING .'</a></td>
174
                    <td><a href="'.$tmp_72hour_sip.'">'._SOURCEIP.'</a></td>
175
                    <td><a href="'.$tmp_72hour_dip.'">'._DESTIP.'</a></td>
176
                  </tr>
177

178
                  <tr class="main_quick_surf">
179
                    <td style="text-align:left;">- ' . _MOSTRECENT . $last_num_alerts . _ALERTS .'</td>
180
                    <td><a href="base_qry_main.php?new=1&amp;caller=last_any&amp;num_result_rows=-1&amp;submit=Last%20Any">' . _ANYPROTO . '</a></td>
181
                    <td><a href="base_qry_main.php?new=1&amp;layer4=TCP&amp;caller=last_tcp&amp;num_result_rows=-1&amp;submit=Last%20TCP">TCP</a></td>
182
                    <td><a href="base_qry_main.php?new=1&amp;layer4=UDP&amp;caller=last_udp&amp;num_result_rows=-1&amp;submit=Last%20UDP">UDP</a></td>
183
                    <td><a href="base_qry_main.php?new=1&amp;layer4=ICMP&amp;caller=last_icmp&amp;num_result_rows=-1&amp;submit=Last%20ICMP">ICMP</a></td>
184
                  </tr>
185

186
              <tr class="main_quick_surf">
187
                    <td style="text-align:left;">- '._LSOURCEPORTS.'</td>
188
                    <td><a href="base_stat_ports.php?caller=last_ports&amp;port_type=1&amp;proto=-1&amp;sort_order=last_d">'._ANYPROTO.'</a></td>
189
                <td><a href="base_stat_ports.php?caller=last_ports&amp;port_type=1&amp;proto=6&amp;sort_order=last_d">TCP</a></td>
190
                <td><a href="base_stat_ports.php?caller=last_ports&amp;port_type=1&amp;proto=17&amp;sort_order=last_d">UDP</a></td>
191
                  </tr>
192
      
193
              <tr class="main_quick_surf">
194
                    <td style="text-align:left;">- '._LDESTPORTS.'
195
                <td><a href="base_stat_ports.php?caller=last_ports&amp;port_type=2&amp;proto=-1&amp;sort_order=last_d">'._ANYPROTO.'</a></td>
196
                <td><a href="base_stat_ports.php?caller=last_ports&amp;port_type=2&amp;proto=6&amp;sort_order=last_d">TCP</a></td>
197
                <td><a href="base_stat_ports.php?caller=last_ports&amp;port_type=2&amp;proto=17&amp;sort_order=last_d">UDP</a></td>
198
              </tr>
199

200
              <tr class="main_quick_surf">
201
                    <td style="text-align:left;">- '._FREGSOURCEP.'</td>
202
                    <td><a href="base_stat_ports.php?caller=most_frequent&amp;port_type=1&amp;proto=-1' . $tmp_DSO . '">'._ANYPROTO.'</a></td>
203
                    <td><a href="base_stat_ports.php?caller=most_frequent&amp;port_type=1&amp;proto=6' . $tmp_DSO . '">TCP</a></td>
204
                    <td><a href="base_stat_ports.php?caller=most_frequent&amp;port_type=1&amp;proto=17' . $tmp_DSO . '">UDP</a></td>
205
                  </tr>
206
      
207
              <tr class="main_quick_surf">
208
                    <td style="text-align:left;">- '._FREGDESTP.'</td>
209
                    <td><a href="base_stat_ports.php?caller=most_frequent&amp;port_type=2&amp;proto=-1' . $tmp_DSO . '">'._ANYPROTO.'</a></td>
210
                    <td><a href="base_stat_ports.php?caller=most_frequent&amp;port_type=2&amp;proto=6' . $tmp_DSO . '">TCP</a></td>
211
                    <td><a href="base_stat_ports.php?caller=most_frequent&amp;port_type=2&amp;proto=17' . $tmp_DSO . '">UDP</a></td>
212
                  </tr>
213

214
              <tr class="main_quick_surf">
215
                    <td style="text-align:left;">- '._MOSTFREQUENT . $freq_num_uaddr . " " ._ADDRESSES.":".'</td>';
216
NLIO('<td>',4);
×
217
NLIO(
×
218
        "<a href='base_stat_uaddr.php?caller=most_frequent&amp;addr_type=1"
219
        . $tmp_DSO . "'>" . $tmp_Source . '</a>', 5
220
);
221
NLIO('</td><td>',4);
×
222
NLIO(
×
223
        "<a href='base_stat_uaddr.php?caller=most_frequent&amp;addr_type=2"
224
        . $tmp_DSO . "'>" . $tmp_Dest . '</a>', 5
225
);
226
NLIO('<td>',4);
×
227
NLIO("</tr><tr class='main_quick_surf_2'>",3);
×
228
echo'              <td colspan=2>- <a href="base_stat_alerts.php?caller=last_alerts&amp;sort_order=last_d">'._MOSTRECENT.$last_num_ualerts._UNIALERTS.'</a></td>
×
229
                  </tr>
230

231
                  <tr class="main_quick_surf_2">
232
                    <td colspan=2>- <a href="base_stat_alerts.php?caller=most_frequent' . $tmp_DSO . '">'._MOSTFREQUENT . $freq_num_alerts . " " ._UNIALERTS.'</a>';
233
PrintFramedBoxFooter(1,2);
×
234
print '          </div>
×
235
    </td>
236
    <td align="right" valign="top">
237
      <div class="systemstats">';
238
UpdateAlertCache($db);
×
239
NLIO('<b>' . _QUERIED . ':</b> ' . date('D F d, Y H:i:s') . '<br/>');
×
240
$DSN = $db->DB_host; // Pull this info from the DB object.
×
241
$tdp = $db->DB_port;
×
242
if ( LoadedString($tdp) ){
×
243
        $DSN = "$DSN:$tdp";
×
244
}
245
$tmp = $db->DB_name . '@' . $DSN;
×
246
printf(
×
247
        "<b>" . _DATABASE . "</b> %s &nbsp;&nbsp;&nbsp;(<b>" .
×
248
        _SCHEMAV . "</b> %d)<br/>", $tmp, $db->baseGetDBversion()
×
249
);
250
StartStopTime($start_time, $end_time, $db);
×
251
$tmp = '<b>' . _TIMEWIN . '</b> ';
×
252
if ( LoadedString($start_time) ){
×
253
        $tmp .= '[' . $start_time . '] - [' . $end_time . ']';
×
254
}else{
×
255
        $tmp .= '<em>' . _NOALERTSDETECT . '</em>';
×
256
}
257
NLIO($tmp,4);
×
258
NLIO('</div>',3);
×
259
PrintTblNewRow(0);
×
260
?>
261
    <td align="center" valign="top">
262
      <strong><a href="base_qry_main.php?new=1"><?php echo _SEARCH; ?></a></strong><br />
263

264
<?php
265
if ( PearInc('Graphing', 'Image', 'Graph') ){
×
266
        NLIO("<a href='base_graph_main.php?new=1'>" . _GALERTD . '</a>');
×
267
        NLIO('<br/>');
×
268
}
269
?>
270
      <a href="base_stat_time.php"><?php echo _GALERTDT; ?></a><br /><br />
271
<?php
272
DBLink();
×
273
PrintFramedBoxFooter(1,2);
×
274
NLIO('<hr/>',2);
×
275
?>
276
<table style='border:0' width='100%'>
277
  <tr>
278
    <td width='30%' valign='top'>
279
<?php
280
/* mstone 20050309 avoid count(*) if requested */
281
PrintGeneralStats($db, 0, $main_page_detail, "", "", $avoid_counts != 1);
×
282

283
/* mstone 20050309 make show_stats even leaner! */
284
if ( $main_page_detail == 1 ){
×
285
    echo '
×
286
    </td>
287
    <td width="70%" valign="top">
288
    <strong>'._TRAFFICPROBPRO.'</strong>';
289
    PrintProtocolProfileGraphs($db);
×
290
}
291
PrintFramedBoxFooter(1,2);
×
292
NLIO('<hr/>',2);
×
293
PrintBASESubFooter();
×
294
?>
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc