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

NathanGibbs3 / BASE / 587

pending completion
587

push

travis-ci-com

NathanGibbs3
Merge branch 'devel'

504 of 504 new or added lines in 21 files covered. (100.0%)

2594 of 16816 relevant lines covered (15.43%)

20.97 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 the link to select the other database....
70
        GLOBAL $archive_exists;
71
        if ( ChkCookie ('archive', 1) || ChkGet ('archive', 1) ){
×
72
                echo '<a href="base_main.php?archive=no">' . _USEALERTDB . '</a>';
×
73
        }elseif ($archive_exists != 0) {
×
74
                echo ('<a href="base_main.php?archive=1">' . _USEARCHIDB . '</a>');
×
75
        }
76
}
77

78
PrintBASESubHeader('', '', '',1);
×
79
$tmp_str = verify_php_build($DBtype); // Check that PHP was built correctly.
×
80
// @codeCoverageIgnoreStart
81
if ($tmp_str != ''){
82
        BuildError ($tmp_str, $tmp_str);
83
}
84
// @codeCoverageIgnoreEnd
85
// Connect to the Alert DB.
86
$db = NewBASEDBConnection($DBlib_path, $DBtype);
×
87
$db->baseDBConnect(
×
88
        $db_connect_method, $alert_dbname, $alert_host, $alert_port, $alert_user,
89
        $alert_password
90
);
91

92
/* Check that the DB schema is recent */
93
$tmp_str = verify_db($db, $alert_dbname, $alert_host);
×
94
if ($tmp_str != "") {
×
95
    echo $tmp_str;
×
96
    die();
×
97
}
98

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

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

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

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

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

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

179
                  <tr class="main_quick_surf">
180
                    <td style="text-align:left;">- ' . _MOSTRECENT . $last_num_alerts . _ALERTS .'</td>
181
                    <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>
182
                    <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>
183
                    <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>
184
                    <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>
185
                  </tr>
186

187
              <tr class="main_quick_surf">
188
                    <td style="text-align:left;">- '._LSOURCEPORTS.'</td>
189
                    <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>
190
                <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>
191
                <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>
192
                  </tr>
193
      
194
              <tr class="main_quick_surf">
195
                    <td style="text-align:left;">- '._LDESTPORTS.'
196
                <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>
197
                <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>
198
                <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>
199
              </tr>
200

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

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

226
                  <tr class="main_quick_surf_2">
227
                    <td colspan=2>- <a href="base_stat_alerts.php?caller=most_frequent'.$tmp_DSO.'">'._MOSTFREQUENT . $freq_num_alerts . " " ._UNIALERTS.'</a></td>
228
                  </tr>
229
                </table>
230
          </div>
231
    </td>
232
    <td align="right" valign="top">
233
      <div class="systemstats">';
234
UpdateAlertCache($db);
×
235
if (!setlocale(LC_TIME, _LOCALESTR1)) {
×
236
    if (!setlocale (LC_TIME, _LOCALESTR2)) {
×
237
        setlocale (LC_TIME, _LOCALESTR3);
×
238
    }
239
    
240
printf("<b>"._QUERIED." </b> : %s<br/>" , date('D F d, Y H:i:s'));
×
241
if ( ChkCookie ('archive', 1) ){
×
242
        printf("<strong>"._DATABASE."</strong> %s &nbsp;&nbsp;&nbsp;(<strong>"._SCHEMAV."</strong> %d) \n<br />\n", 
×
243
            ($archive_dbname.'@'.$archive_host. ($archive_port != "" ? ':'.$archive_port : "") ),
×
244
            $db->baseGetDBversion()
×
245
        );
246
}else{
×
247
        printf("<strong>"._DATABASE."</strong> %s &nbsp;&nbsp;&nbsp;(<strong>"._SCHEMAV."</strong> %d) \n<br />\n", 
×
248
            ( $alert_dbname.'@'.$alert_host. ($alert_port != "" ? ':'.$alert_port : "") ),
×
249
            $db->baseGetDBversion()
×
250
        );
251
}
252
    StartStopTime($start_time, $end_time, $db);
×
253
    if ($start_time != "") {
×
254
        printf("<strong>"._TIMEWIN."</strong> [%s] - [%s]\n", $start_time, $end_time);
×
255
    } else {
×
256
        printf("<strong>"._TIMEWIN."</strong> <em>"._NOALERTSDETECT."</em>\n");
×
257
    }
258
}
259
?>
260
      </div>
261
    </td>
262
  </tr>
263
  <tr>
264
    <td align="center" valign="top">
265
      <strong><a href="base_qry_main.php?new=1"><?php echo _SEARCH; ?></a></strong><br />
266
      <strong><a href="base_graph_main.php?new=1"><?php echo _GALERTD; ?></a></strong><br />
267
      <a href="base_stat_time.php"><?php echo _GALERTDT; ?></a><br /><br />
268
<?php DBLink(); ?>
269
    </td>
270
  </tr>
271
</table>
272

273
<hr />
274
<table style='border:0' width='100%'>
275
  <tr>
276
    <td width='30%' valign='top'>
277
<?php
278
/* mstone 20050309 avoid count(*) if requested */
279
PrintGeneralStats($db, 0, $main_page_detail, "", "", $avoid_counts != 1);
×
280

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