Example #1
0
function get_network_info($conn, $net_id)
{
    $net = Asset_net::get_object($conn, $net_id);
    //Asset IPs
    $cidrs = $net->get_ips('array');
    //Asset Sensors
    $net_sensors = $net->get_sensors();
    $sensors = $net_sensors->get_sensors();
    $data = array('id' => $net_id, 'name' => $net->get_name(), 'owner' => $net->get_owner(), 'descr' => html_entity_decode($net->get_descr(), ENT_QUOTES, 'UTF-8'), 'cidrs' => $cidrs, 'asset_value' => $net->get_asset_value(), 'icon' => base64_encode($net->get_icon()), 'sensors' => $sensors);
    return $data;
}
Example #2
0
function get_network_status($conn, $data)
{
    $id = $data['id'];
    $location = $data['location'];
    ossim_valid($id, OSS_HEX, 'illegal:' . _("Network ID"));
    ossim_valid($location, OSS_HEX, 'illegal:' . _("Location ID"));
    if (ossim_error()) {
        $info_error = "Error: " . ossim_get_error();
        ossim_clean_error();
        $return['error'] = true;
        $return['msg'] = $info_error;
        return $return;
    }
    //aux variables
    $answ['0'] = 'error';
    $answ['1'] = 'ok';
    $answ['2'] = 'info';
    $types = array('ids', 'vulns', 'passive', 'active', 'netflow');
    //net info
    $net = Asset_net::get_object($conn, $id);
    if ($net != NULL) {
        $cidr = $net->get_ips();
        $data['net_name'] = $net->get_name() . " (" . $cidr . ")";
        $data['net_owner'] = Session::get_entity_name($conn, $net->get_ctx(), true);
        $data['net_descr'] = $net->get_descr();
    } else {
        $data['net_name'] = _('Unknown');
        $data['net_owner'] = _('Unknown');
        $data['net_descr'] = _('Unknown');
    }
    $checks = Locations::get_location_checks($conn, $location);
    foreach ($types as $t_pos => $t) {
        if (strlen($checks) == 5 && $checks[$t_pos] == 0) {
            $data[$t] = 'info';
        } else {
            $options = array("type" => $t, "percent" => false, "network" => $id);
            $var = get_network_visibility($conn, $options);
            $data[$t] = $answ[$var];
        }
    }
    $options = array("type" => 'asset_network', "network" => $id);
    $data['net_devices'] = get_asset_visibility($conn, $options);
    $options = array("type" => 'asset_server', "network" => $id);
    $data['servers'] = get_asset_visibility($conn, $options);
    $return['error'] = false;
    $return['data'] = $data;
    return $return;
}
?>
																</th>
																<td class="left nobborder">
																	<select id="toselect" name="toselect[]" size="12" multiple="multiple" style="width:150px">
																	<?php 
if ($rule->to != "ANY" && $rule->to != "" && !preg_match("/\\:...\\_IP/", $rule->to)) {
    $pre_list = explode(",", $rule->to);
    foreach ($pre_list as $list_element) {
        // Asset ID: Resolve by name
        if (preg_match("/(\\!)?([0-9A-Fa-f\\-]{36})/", $list_element, $found)) {
            $uuid_aux = str_replace("-", "", strtoupper($found[2]));
            $h_obj = Asset_host::get_object($conn, $uuid_aux);
            if ($h_obj != null) {
                echo "<option value='" . $found[1] . $found[2] . "'>" . $found[1] . $h_obj->get_name() . " (" . $h_obj->get_ips()->get_ips('string') . ")</option>\n";
            } else {
                $n_obj = Asset_net::get_object($conn, $uuid_aux);
                if ($n_obj != null) {
                    echo "<option value='" . $found[1] . $found[2] . "'>" . $found[1] . $n_obj->get_name() . " (" . $n_obj->get_ips() . ")</option>\n";
                }
            }
            // Another one (HOME_NET, 12.12.12.12...)
        } else {
            echo "<option value='{$list_element}'>{$list_element}</option>\n";
        }
    }
}
?>
																	</select>
																	<input type="button" class="small" value=" [X] " onclick="deletefrom('toselect');"/>
																</td>
															</tr>
Example #4
0
Session::logcheck("analysis-menu", "EventsForensics");
list($ip, $ctx, $net_id) = explode(";", GET('ip'));
ossim_valid($ip, OSS_IP_ADDR_0, 'illegal:' . _('IP address'));
ossim_valid($ctx, OSS_HEX, 'illegal:' . _('CTX'));
ossim_valid($net_id, OSS_HEX, OSS_NULLABLE, 'illegal:' . _('Net Id'));
if (ossim_error()) {
    die(ossim_error());
}
$db = new ossim_db(TRUE);
if (is_array($_SESSION['server']) && $_SESSION['server'][0] != '') {
    $conn = $db->custom_connect($_SESSION["server"][0], $_SESSION["server"][2], $_SESSION["server"][3]);
} else {
    $conn = $db->connect();
}
$net = NULL;
if ($net_id != '') {
    if ($net_obj = Asset_net::get_object($conn, $net_id)) {
        $net = array('name' => $net_obj->get_name(), 'ips' => $net_obj->get_ips(), 'icon' => $net_obj->get_html_icon());
    }
} else {
    $net = array_shift(Asset_host::get_closest_net($conn, $ip, $ctx));
    if ($net['icon'] != '') {
        $net['icon'] = "<img class='asset_icon w16' src='data:image/png;base64," . base64_encode($net['icon']) . "'/>";
    }
}
if (is_array($net) && !empty($net)) {
    echo $net['icon'] . "<strong>" . $net['name'] . "</strong> (" . $net['ips'] . ")";
} else {
    echo "<strong>{$ip}</strong> " . _("not found in home networks");
}
$db->close();
Example #5
0
    $response['sEcho'] = intval($sec);
    $response['iTotalRecords'] = 0;
    $response['iTotalDisplayRecords'] = 0;
    $response['aaData'] = array();
    $response['iDisplayStart'] = 0;
    echo json_encode($response);
    die;
}
$detail = "<img class='detail_img' src='" . AV_PIXMAPS_DIR . "/show_details.png'/>";
$results = array();
foreach ($nets as $_id => $net_data) {
    // Alarms
    $alarms = Asset_net::has_alarms($conn, $_id);
    $alarms_icon = $alarms ? "<img src='" . AV_PIXMAPS_DIR . "/assets_tick_gray.png'/>" : '-';
    // Vulns
    $net = Asset_net::get_object($conn, $_id);
    list($vulns_list, $vulns) = $net->get_vulnerabilities($conn);
    $vulns_icon = $vulns > 0 ? "<img src='" . AV_PIXMAPS_DIR . "/assets_tick_gray.png'/>" : '-';
    // Events
    $events = Asset_net::has_events($conn, $_id);
    $events_icon = $events ? "<img src='" . AV_PIXMAPS_DIR . "/assets_tick_gray.png'/>" : '-';
    // Sensors
    $sensors = Asset_net_sensors::get_sensors_by_id($conn, $_id);
    $sensors_string = '';
    foreach ($sensors as $sensor_id => $sensor_data) {
        if ($sensors_string != '') {
            $sensors_string .= ', ';
        }
        $sensors_string .= $sensor_data['name'];
    }
    // COLUMNS
Example #6
0
    case 'host':
        try {
            $host = Asset_host::get_object($conn, $keyname);
        } catch (Exception $e) {
            $host = NULL;
        }
        if (is_object($host)) {
            $vars['_HOST_NAME'] = $host->get_name();
            $vars['_HOST_IP'] = $host->get_ips();
            $vars['_HOST_FQDN'] = $host->get_fqdns();
            $vars['_HOST_DESC'] = $host->get_descr();
        }
        break;
    case 'net':
        try {
            $net = Asset_net::get_object($conn, $keyname);
        } catch (Exception $e) {
            $net = NULL;
        }
        if (is_object($net)) {
            $vars['_NET_CIDR'] = $net->get_ips();
            $vars['_NET_NAME'] = $net->get_name();
        }
        break;
    case 'host_group':
        $vars['_HG_NAME'] = Asset_group::get_name_by_id($conn, $keyname);
        break;
    case 'net_group':
        $vars['_NG_NAME'] = Net_group::get_name_by_id($conn, $keyname);
        break;
}
if (ossim_error()) {
    echo json_encode($response);
    exit;
}
$db = new ossim_db();
$conn = $db->connect();
// Load the current asset object in session same as in index.php
// Host
if (Asset_host::is_in_db($conn, $asset_id)) {
    if (Asset_host::is_allowed($conn, $asset_id)) {
        $asset_object = Asset_host::get_object($conn, $asset_id);
        $reloaded = TRUE;
    }
} elseif (Asset_net::is_in_db($conn, $asset_id)) {
    if (Asset_net::is_allowed($conn, $asset_id)) {
        $asset_object = Asset_net::get_object($conn, $asset_id);
        $reloaded = TRUE;
    }
} elseif (Asset_group::is_in_db($conn, $asset_id)) {
    $asset_object = Asset_group::get_object($conn, $asset_id);
    $reloaded = TRUE;
}
// Save session object only if is already saved (it means the user has perms)
if (!empty($_SESSION['asset_detail'][$asset_id]) && $reloaded) {
    $_SESSION['asset_detail'][$asset_id] = serialize($asset_object);
    $response['session_updated'] = TRUE;
} else {
    $response['session_updated'] = FALSE;
}
echo json_encode($response);
$db->close();
Example #8
0
echo $BAR_LENGTH_RIGHT;
?>
"/>
        </td>
    </tr>
    <!-- end rule for threshold -->

    <?php 
/*
 * Hosts
 */
/*
 * If click on a net, only show hosts of this net
 */
if (GET('net')) {
    $_net_aux = Asset_net::get_object($conn, $net_id);
    if (is_object($_net_aux)) {
        $ips = $_net_aux->get_ips();
        print "<h1>{$ips}</h1>";
        if ($ip_list = Asset_host_qualification::get_list($conn)) {
            foreach ($ip_list as $host_qualification) {
                if (Asset_host::is_ip_in_nets($host_qualification->get_host_ip(), $ips)) {
                    $ip_stats[] = new Asset_host_qualification($host_qualification->get_host_ip(), $host_qualification->get_compromise(), $host_qualification->get_attack());
                }
            }
        }
    }
} else {
    $ip_stats = Asset_host_qualification::get_list($conn, '', 'ORDER BY compromise + attack DESC');
}
//if (count($ip_stats) > 0) {