Exemple #1
0
             $cnd_2 = !empty($asset_sensors[$asset_sensor_id]);
             if ($cnd_1 && $cnd_2) {
                 $sensor_id = $asset_sensor_id;
                 break;
             }
         }
         $agent_id = NULL;
         $ip_address = $default_ip_address;
     }
     if ($sensor_id === NULL) {
         $deployment_stats[$asset_id]['status'] = 'error';
         $deployment_stats[$asset_id]['data'] = _('Error! No HIDS sensor related to asset');
         continue;
     }
     $d_data = array('asset_id' => $asset_id, 'w_ip' => $ip_address, 'w_user' => $user, 'w_password' => $pass, 'w_domain' => $domain, 'agent_id' => $agent_id);
     $res = Ossec_agent::deploy_windows_agent($sensor_id, $d_data);
     $job_id = $res['job_id'];
     if (valid_hex32($job_id, TRUE) == FALSE) {
         $deployment_stats[$asset_id]['status'] = 'warning';
         $deployment_stats[$asset_id]['data'] = _('Warning! Deployment job cannot be launched');
     } else {
         $total_deployed++;
     }
 }
 if ($total_deployed == $total_windows) {
     $data = array('status' => 'success', 'data' => _('Deployment job/s scheduled successfully.
             <br/>Check out the <span class="bold" id="go_to_mc">Message Center</span> for more details'));
 } else {
     if ($total_deployed == 0) {
         $data = array('status' => 'warning', 'data' => _('Unable to deploy HIDS agents due to an internal error. Please try again'), 'stats' => $deployment_stats);
     } else {
Exemple #2
0
    if (!Ossec_utilities::is_sensor_allowed($conn, $sensor_id)) {
        $validation_errors['sensor_id'] = _('Unable to deploy HIDS agent. The selected sensor is not allowed. Please update the sensor in asset details and try again');
    }
}
if (is_array($validation_errors) && !empty($validation_errors)) {
    $data['status'] = 'error';
    if (POST('ajax_validation_all') == TRUE) {
        $data['data'] = $validation_errors;
    } else {
        $data['data'] = '<div>' . _('The following errors occurred') . ":</div>\n            <div style='padding: 10px;'>" . implode('<br/>', $validation_errors) . '</div>';
    }
} else {
    if (POST('ajax_validation_all') == TRUE) {
        $data['status'] = 'OK';
        $data['data'] = _('HIDS data successfully checked');
    } else {
        $asset_id = POST('asset_id');
        $sensor_id = POST('sensor_id');
        $agent_id = POST('agent_id');
        try {
            $d_data = array('asset_id' => $asset_id, 'w_ip' => POST('asset_ip'), 'w_user' => POST('user'), 'w_password' => POST('pass'), 'w_domain' => POST('domain'), 'agent_id' => $agent_id);
            $data['status'] = 'success';
            $data['data'] = Ossec_agent::deploy_windows_agent($sensor_id, $d_data);
        } catch (Exception $e) {
            $data['status'] = 'error';
            $data['data'] = $e->getMessage();
        }
    }
}
$db->close();
echo json_encode($data);