Ejemplo n.º 1
0
        $search = utf8_decode($search);
        $search = escape_sql($search, $conn);
        $filters['where'] = 'host.hostname LIKE "%' . $search . '%"';
    }
}
try {
    list($assets, $total) = Asset_host::get_list($conn, $tables, $filters, TRUE);
} catch (Exception $e) {
    $assets = array();
    $total = 0;
}
$results = array();
foreach ($assets as $_id => $asset_data) {
    $_res = array();
    // Get OS
    $os = implode(' ', Asset_host_properties::get_property_from_db($conn, $_id, 3));
    $_os = '';
    $_dev = '';
    if (preg_match("/windows/i", $os)) {
        $_os = 'Windows';
    } elseif (preg_match("/linux/i", $os)) {
        $_os = 'Linux';
    }
    // Get device types
    $_devices = new Asset_host_devices($conn, $_id);
    $_devices->load_from_db($conn);
    $devices = $_devices->get_devices();
    if ($_os == 'Windows') {
        $_dev = 'windows_';
    } elseif (is_array($devices[1]) && !empty($devices[1])) {
        if ($_os == 'Linux') {
Ejemplo n.º 2
0
 $_SESSION['_csv_file_hosts'] = $file;
 session_write_close();
 $csv = array();
 //Export a filtered list
 $filters = array();
 $session = session_id();
 $tables = ', user_component_filter hc';
 $filters = array('where' => "hc.asset_id=host.id AND hc.asset_type='asset' AND hc.session_id = '{$session}'", 'order_by' => 'host.hostname ASC');
 $_host_list = Asset_host::get_list($conn, $tables, $filters);
 foreach ($_host_list[0] as $host) {
     $id = $host['id'];
     //Description
     $descr = $host['descr'];
     $descr = mb_convert_encoding($descr, 'UTF-8', 'HTML-ENTITIES');
     //Operating System
     $os = Asset_host_properties::get_property_from_db($conn, $host['id'], 3);
     $os = array_pop($os);
     //Latitude/Longitude
     $latitude = empty($host['location']['lat']) ? '' : $host['location']['lat'];
     $longitude = empty($host['location']['lon']) ? '' : $host['location']['lon'];
     //Devices
     $str_devices = '';
     $devices = Asset_host_devices::get_devices_to_string($conn, $id);
     if (!empty($devices)) {
         $str_devices = str_replace('<br/>', ',', $devices);
     }
     $h_data = array();
     $h_data['ips'] = $host['ips'];
     $h_data['name'] = $host['name'];
     $h_data['fqdns'] = $host['fqdns'];
     $h_data['descr'] = $descr;
Ejemplo n.º 3
0
        $search = utf8_decode($search);
        $search = escape_sql($search, $conn);
        $filters['where'] = 'host.hostname LIKE "%' . $search . '%"';
    }
}
try {
    list($assets, $total) = Asset_host::get_list($conn, $tables, $filters, TRUE);
} catch (Exception $e) {
    $assets = array();
    $total = 0;
}
$results = array();
foreach ($assets as $_id => $asset_data) {
    $_res = array();
    // Get OS
    $os = Asset_host_properties::get_property_from_db($conn, $_id, 3);
    $_os = '';
    $_dev = '';
    $windows_os = preg_grep("/^windows|microsoft/i", $os);
    $linux_os = preg_grep("/linux|alienvault/i", $os);
    if (count($windows_os) > 0) {
        $_os = 'Windows';
    } elseif (count($linux_os) > 0) {
        $_os = 'Linux';
    }
    // Get device types
    $_devices = new Asset_host_devices($conn, $_id);
    $_devices->load_from_db($conn);
    $devices = $_devices->get_devices();
    if ($_os == 'Windows') {
        $_dev = 'windows_';