function host_get_network_data($ip, $groups, $networks) { // search in groups $groups_belong['groups'] = array(); $groups_belong['nets'] = array(); foreach ($groups as $group_name => $g_data) { foreach ($g_data['nets'] as $net_name => $n_data) { $address = $n_data['address']; if (!strpos($address, "/")) { // tvvcox: i've detected some wrong network addresses, catch them with that //echo "<font color='red'>"._("Invalid network address for")." $net_name: $address</font><br>"; continue; } if (Net::isIpInNet($ip, $address)) { if (!$n_data['has_perms'] && !check_sensor_perms($ip, 'host')) { continue; } $groups_belong['groups'][$group_name]++; $groups_belong['nets'][$net_name] = $n_data; } } } // search in nets foreach ($networks as $net_name => $n_data) { $address = $n_data['address']; if ($address != "" && Net::isIpInNet($ip, $address)) { if (!$n_data['has_perms'] && !check_sensor_perms($ip, 'host')) { continue; } $groups_belong['nets'][$net_name] = $n_data; } } return $groups_belong; }
function Import() { parent::Import(); require dirname(__FILE__) . '/../base_conf.php'; $vals = NULL; $empty = 1; /* expand IP into octets */ $this->criteria = $_SESSION['ip_addr']; $this->criteria_cnt = $_SESSION['ip_addr_cnt']; for ($i = 0; $i < $this->criteria_cnt; $i++) { if (isset($this->criteria[$i][3]) && ereg("([0-9]*)\\.([0-9]*)\\.([0-9]*)\\.([0-9]*)", $this->criteria[$i][3])) { if ($use_ossim_session && Session::allowedNets()) { require_once 'classes/Net.inc'; $domain = Session::allowedNets(); if ($domain != "") { $tmp_myip = $this->criteria[$i][3]; $myip = strtok($tmp_myip, "/"); if (Net::isIpInNet($myip, $domain)) { $tmp_ip_str = $this->criteria[$i][7] = $this->criteria[$i][3]; $this->criteria[$i][2] = "="; $this->criteria[$i][3] = strtok($tmp_ip_str, "."); $this->criteria[$i][4] = strtok("."); $this->criteria[$i][5] = strtok("."); $this->criteria[$i][6] = strtok("/"); $this->criteria[$i][10] = strtok(""); $empty = 0; $vals[] = $this->criteria[$i]; } } } else { $tmp_ip_str = $this->criteria[$i][7] = $this->criteria[$i][3]; $this->criteria[$i][3] = strtok($tmp_ip_str, "."); $this->criteria[$i][4] = strtok("."); $this->criteria[$i][5] = strtok("."); $this->criteria[$i][6] = strtok("/"); $this->criteria[$i][10] = strtok(""); $empty = 0; $vals[] = $this->criteria[$i]; } } elseif (is_array($this->criteria[$i]) && array_key_exists(7, $this->criteria[$i]) && ereg("([0-9]*)\\.([0-9]*)\\.([0-9]*)\\.([0-9]*)", $this->criteria[$i][7])) { $empty = 0; $vals[] = $this->criteria[$i]; } } //print_r ($this->criteria); $this->criteria = $vals; $this->criteria_cnt = count($vals); if ($use_ossim_session && $empty) { $domain = Session::allowedNets(); if ($domain != "") { $nets = explode(",", $domain); $this->criteria = array(); for ($i = 0; $i < count($nets); $i++) { $tmp_ip_str = $tmp[7] = $nets[$i]; $tmp[0] = " "; $tmp[1] = "ip_both"; $tmp[2] = "="; $tmp[3] = strtok($tmp_ip_str, "."); $tmp[4] = strtok("."); $tmp[5] = strtok("."); $tmp[6] = strtok("/"); $tmp[10] = strtok(""); $tmp[8] = " "; if ($i == count($nets) - 1) { $tmp[9] = " "; } else { $tmp[9] = "OR"; } $this->criteria[$this->criteria_cnt] = $tmp; $this->criteria_cnt++; } } } $new = ImportHTTPVar("new", VAR_DIGIT); $submit = ImportHTTPVar("submit", VAR_ALPHA | VAR_SPACE); if ($new == 1 && $submit == "") { $this->criteria = NULL; $this->criteria_cnt = 1; } if ($this->criteria_cnt == "") { $this->criteria_cnt = 1; } //print_r ($this->criteria); $_SESSION['ip_addr'] =& $this->criteria; $_SESSION['ip_addr_cnt'] =& $this->criteria_cnt; }
<!-- end rule for threshold --> <?php /* * Hosts */ /* * If click on a net, only show hosts of this net */ if (GET('net')) { if ($net_list = Net::get_list($conn, "name = '{$net_name}'")) { $ips = $net_list[0]->get_ips(); print "<h1>{$ips}</h1>"; if ($ip_list = Host_qualification::get_list($conn)) { foreach ($ip_list as $host_qualification) { if (Net::isIpInNet($host_qualification->get_host_ip(), $ips)) { $ip_stats[] = new Host_qualification($host_qualification->get_host_ip(), $host_qualification->get_compromise(), $host_qualification->get_attack()); } } } } } else { $ip_stats = Host_qualification::get_list($conn, "", "ORDER BY compromise + attack DESC"); } //if (count($ip_stats) > 0) { $max_level = max(ossim_db::max_val($conn, "compromise", "host_qualification"), ossim_db::max_val($conn, "attack", "host_qualification")); ?> <tr><td colspan="3"><br/></td></tr> <tr><th align="center" colspan="3">