$res = Av_center::get_system_info_by_id($conn, $system_ids['non-canonical']); if ($res['status'] == 'success') { //We use this function to calculate sensor name because in HA environments there are two systems for one Sensor ID if (empty($res['data']['ha_ip'])) { $sensor_name = $res['data']['name']; } else { $sensor_name = Av_sensor::get_name_by_id($conn, $sensor_id); } $sensor_ip = $res['data']['current_ip']; if (Ossec_utilities::get_default_sensor_id() == $sensor_id && empty($res['data']['ha_ip'])) { $sensor_ip = $res['data']['admin_ip']; } $sensor_ip_txt = $sensor_ip . ' [' . $sensor_name . ']'; } //Getting Agent information $_aux_agent = Asset_host::get_related_hids_agents($conn, $asset_id, $sensor_id); $agent_key = md5(strtoupper($sensor_id) . '#' . $agent_id); $agent = $_aux_agent[$agent_key]; if (empty($agent)) { $validation_errors['agent_id'] = _('Error! Agent information cannot be retrieved from system'); } else { $agent_descr = $agent['name'] . ' (' . $agent['ip_cidr'] . ')'; } } } } $db->close(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html>
//Getting assets with Windows OS $tables = ', host_properties hp, user_component_filter f'; $filters = array('where' => 'hp.host_id=host.id AND hp.property_ref=3 AND (hp.value LIKE "windows%" OR hp.value LIKE "microsoft%") AND f.asset_id = host.id AND f.asset_type="asset" AND f.session_id = "' . session_id() . '"'); list($assets_w_os, $total_windows) = Asset_host::get_list($conn, $tables, $filters, FALSE); $total_deployed = 0; $deployment_stats = array(); if ($total_windows > 0) { //HIDS sensors $s_data = Ossec_utilities::get_sensors($conn); $hids_sensors = $s_data['sensors']; foreach ($assets_w_os as $asset_id => $a_data) { $deployment_stats[$asset_id] = array('status' => 'success', 'data' => ''); //Getting HIDS sensor and Windows IP $sensor_id = NULL; $hids_agents = Asset_host::get_related_hids_agents($conn, $asset_id); $aux_ip_address = explode(',', $a_data['ips']); $aux_ip_address = array_flip($aux_ip_address); $default_ip_address = array_pop(array_keys($aux_ip_address)); if (is_array($hids_agents) && !empty($hids_agents)) { //Case 1: HIDS Agents was previously deployed $hids_agent = array_pop($hids_agents); $sensor_id = $hids_agent['sensor_id']; $agent_id = $hids_agent['agent_id']; if (Asset_host_ips::valid_ip($hids_agent['ip_cidr']) && array_key_exists($hids_agent['ip_cidr'], $aux_ip_address)) { $ip_address = $hids_agent['ip_cidr']; } else { $ip_address = $default_ip_address; } } else { //Case 2: Not HIDS Agent deployed