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

NathanGibbs3 / BASE / 625

pending completion
625

push

travis-ci-com

NathanGibbs3
20230512 Standardized BASE Iconography.
         Using 3dicons from @realvjy
         https://github.com/realvjy/3dicons
         Thank You. :smile:

33 of 33 new or added lines in 3 files covered. (100.0%)

648 of 10178 relevant lines covered (6.37%)

71.31 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
$sc = DIRECTORY_SEPARATOR;
×
45
require_once("includes$sc" . 'base_krnl.php');
×
46
include_once("$BASE_path$sc" . "includes$sc" . 'base_include.inc.php');
×
47
include_once("$BASE_path/base_db_common.php");
×
48

49
AuthorizedRole(10000);
×
50
// Initialize the history
51
$_SESSION = NULL;
×
52
InitArray($_SESSION['back_list'], 1, 3, "");
×
53
$_SESSION['back_list_cnt'] = 0;
×
54
PushHistory();
×
55
if ( isset($_GET['archive']) ){ // Set cookie to use the correct db.
×
56
        "no" == $_GET['archive'] ? $value = 0 : $value = 1;
×
57
        BCS('archive', $value);
×
58
        HTTP_header("Location: $BASE_urlpath/base_main.php");
×
59
}
60

61
function DBLink(){ // Generate link to select other DB.
62
        GLOBAL $archive_exists;
63
        if ( ChkArchive() ){
×
64
                NLIO('<a href="base_main.php?archive=no">' . _USEALERTDB . '</a>');
×
65
        }elseif( $archive_exists != 0 ){
×
66
                NLIO('<a href="base_main.php?archive=1">' . _USEARCHIDB . '</a>');
×
67
        }
68
}
69

70
PrintBASESubHeader('', '', '', 1);
×
71
$CTR = verify_php_build($DBtype); // Check that PHP was built correctly.
×
72
// @codeCoverageIgnoreStart
73
if ( LoadedString($CTR) ){
74
        BuildError($CTR, $CTR);
75
}
76
// @codeCoverageIgnoreEnd
77
$db = NewBASEDBConnection($DBlib_path, $DBtype); // Connect to DB.
×
78
$db->baseDBConnect(
×
79
        $db_connect_method, $alert_dbname, $alert_host, $alert_port, $alert_user,
80
        $alert_password
81
);
82
// Check that DB schema is recent.
83
$CTR = verify_db($db, $alert_dbname, $alert_host);
×
84
// @codeCoverageIgnoreStart
85
if ( LoadedString($CTR) ){
86
        BuildError($CTR, $CTR);
87
}
88
// @codeCoverageIgnoreEnd
89

90
NLIO("<table width='100%' style='border:0;padding:0'>",2);
×
91
NLIO('<tr>',2);
×
92
NLIO("<td align='left' rowspan='2'>",3);
×
93

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

140
$tmp_Source = _SOURCE;
×
141
$tmp_Dest = _DEST;
×
142

143
echo '
×
144
          <div class="stats">
145
            <table width="100%" class="systemstats">
146
              <tr class="main_quick_surf">
147
                    <td style="text-align:left;">- '. _TALERTS .'</td>
148
                    <td><a href="'.$tmp_today_unique.'">'. _UNI .'</a></td>
149
                    <td><a href="'.$tmp_today.'">'. _LISTING .'</a></td>
150
                    <td><a href="'.$tmp_sip.'">'._SOURCEIP.'</a></td>
151
                    <td><a href="'.$tmp_dip.'">'._DESTIP.'</a></td>
152
                  </tr>
153

154
              <tr class="main_quick_surf">
155
                    <td style="text-align:left;">- '. _L24ALERTS .'</td>
156
                    <td><A href="'.$tmp_24hour_unique.'">'. _UNI .'</a></td>
157
                    <td><A href="'.$tmp_24hour.'">'. _LISTING .'</a></td>
158
                    <td><A href="'.$tmp_24hour_sip.'">'._SOURCEIP.'</a></td>
159
                    <td><A href="'.$tmp_24hour_dip.'">'._DESTIP.'</a></td>
160
                  </tr>
161

162
              <tr class="main_quick_surf">
163
                    <td style="text-align:left;">- '. _L72ALERTS .'</td>
164
                    <td><a href="'.$tmp_72hour_unique.'">'._UNI.'</a></td>
165
                    <td><a href="'.$tmp_72hour.'">'. _LISTING .'</a></td>
166
                    <td><a href="'.$tmp_72hour_sip.'">'._SOURCEIP.'</a></td>
167
                    <td><a href="'.$tmp_72hour_dip.'">'._DESTIP.'</a></td>
168
                  </tr>
169

170
                  <tr class="main_quick_surf">
171
                    <td style="text-align:left;">- ' . _MOSTRECENT . $last_num_alerts . _ALERTS .'</td>
172
                    <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>
173
                    <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>
174
                    <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>
175
                    <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>
176
                  </tr>
177

178
              <tr class="main_quick_surf">
179
                    <td style="text-align:left;">- '._LSOURCEPORTS.'</td>
180
                    <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>
181
                <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>
182
                <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>
183
                  </tr>
184
      
185
              <tr class="main_quick_surf">
186
                    <td style="text-align:left;">- '._LDESTPORTS.'
187
                <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>
188
                <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>
189
                <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>
190
              </tr>
191

192
              <tr class="main_quick_surf">
193
                    <td style="text-align:left;">- '._FREGSOURCEP.'</td>
194
                    <td><a href="base_stat_ports.php?caller=most_frequent&amp;port_type=1&amp;proto=-1' . $tmp_DSO . '">'._ANYPROTO.'</a></td>
195
                    <td><a href="base_stat_ports.php?caller=most_frequent&amp;port_type=1&amp;proto=6' . $tmp_DSO . '">TCP</a></td>
196
                    <td><a href="base_stat_ports.php?caller=most_frequent&amp;port_type=1&amp;proto=17' . $tmp_DSO . '">UDP</a></td>
197
                  </tr>
198
      
199
              <tr class="main_quick_surf">
200
                    <td style="text-align:left;">- '._FREGDESTP.'</td>
201
                    <td><a href="base_stat_ports.php?caller=most_frequent&amp;port_type=2&amp;proto=-1' . $tmp_DSO . '">'._ANYPROTO.'</a></td>
202
                    <td><a href="base_stat_ports.php?caller=most_frequent&amp;port_type=2&amp;proto=6' . $tmp_DSO . '">TCP</a></td>
203
                    <td><a href="base_stat_ports.php?caller=most_frequent&amp;port_type=2&amp;proto=17' . $tmp_DSO . '">UDP</a></td>
204
                  </tr>
205

206
              <tr class="main_quick_surf">
207
                    <td style="text-align:left;">- '._MOSTFREQUENT . $freq_num_uaddr . " " ._ADDRESSES.":".'</td>';
208
NLIO('<td>',4);
×
209
NLIO(
×
210
        "<a href='base_stat_uaddr.php?caller=most_frequent&amp;addr_type=1"
211
        . $tmp_DSO . "'>" . $tmp_Source . '</a>', 5
212
);
213
NLIO('</td><td>',4);
×
214
NLIO(
×
215
        "<a href='base_stat_uaddr.php?caller=most_frequent&amp;addr_type=2"
216
        . $tmp_DSO . "'>" . $tmp_Dest . '</a>', 5
217
);
218
NLIO('<td>',4);
×
219
NLIO("</tr><tr class='main_quick_surf_2'>",3);
×
220
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>
×
221
                  </tr>
222

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

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

275
/* mstone 20050309 make show_stats even leaner! */
276
if ( $main_page_detail == 1 ){
×
277
    echo '
×
278
    </td>
279
    <td width="70%" valign="top">
280
    <strong>'._TRAFFICPROBPRO.'</strong>';
281
    PrintProtocolProfileGraphs($db);
×
282
}
283
PrintFramedBoxFooter(1,2);
×
284
NLIO('<hr/>',2);
×
285
PrintBASESubFooter();
×
286
?>
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