Exemple #1
0
$db->close();
$assets = $assets_string;
$scan_path_log = "/tmp/nmap_scanning_" . md5(Session::get_secure_id()) . '.log';
// Only Stop
if ($only_stop) {
    $scan = new Scan();
    $scan->stop();
    $data['status'] = 'OK';
    $data['data'] = NULL;
    echo json_encode($data);
    exit;
}
// Launch scan
if (!$only_status && !$only_stop) {
    // This object is only for checking available sensors
    $rscan = new Remote_scan($assets, $scan_mode == 'full' ? 'root' : 'ping');
    $available = $rscan->available_scan(preg_match('/^[0-9A-F]{32}$/i', $sensor) ? $sensor : '');
    $remote_sensor = "null";
    // default runs local scan
    unset($_SESSION['_remote_sensor_scan']);
    if (preg_match('/[0-9A-F]{32}/i', $sensor)) {
        if ($available == '') {
            $remote_sensor = 'null';
            $data['status'] = 'warning';
            $data['data'] = _('Warning! The selected sensor is not available for remote scan. Using automatic option...');
        } else {
            $remote_sensor = $sensor;
            $_SESSION['_remote_sensor_scan'] = $sensor;
        }
    }
    if ($sensor == 'auto' && $available != '') {
</th>
    <th><?php 
echo _("Nmap Scan");
?>
</th>
    <th><?php 
echo _("Load");
?>
</th>
</tr>
    <?php 
// get available sensors
$_list_data = Av_sensor::get_list($conn);
$all_sensors = $_list_data[0];
// remote nmap
$rscan = new Remote_scan('', '');
$rscan->available_scan();
$ids = array();
if (is_array($rscan->get_sensors()) && count(array_keys($rscan->get_sensors())) > 0) {
    $agents = $rscan->get_sensors();
    foreach ($agents as $asid => $agent) {
        $ids[] = $asid;
    }
}
$withnmapforced = 0;
if (valid_hex32($scan_server) && !$hosts_alive && $sensor_id != "") {
    $ids = array_merge(array($sensor_id), $ids);
    $withnmapforced = 1;
}
// targets
$total_host = 0;
// check scan file
ossim_valid($user, OSS_NULLABLE, OSS_USER_2, 'illegal:' . _('User'));
if (ossim_error()) {
    $error_message[] = 'Illegal scan file';
    ossim_set_error(FALSE);
}
// check ports
ossim_valid($ports, OSS_DIGIT, OSS_SPACE, OSS_SCORE, OSS_NULLABLE, ',', 'illegal:' . _('Custom Ports'));
if (ossim_error()) {
    $error_message[] = 'Illegal custom ports';
}
if (!empty($error_message)) {
    die(implode("\n", $error_message) . "\n");
}
if ($remote_sensor != '' && $remote_sensor != 'null') {
    $rscan = new Remote_scan($targets, $scan_type, $remote_sensor, $user, $timing_template, $autodetect, $rdns, $ports);
    $quiet = $timing_template != '' ? FALSE : TRUE;
    echo 'Scanning remote networks: ' . $targets . "\n";
    $rscan->do_scan($quiet);
    if ($rscan->err() == '') {
        $ips = $rscan->get_scan();
    } else {
        $ips = array();
        echo '<br>\\n<b>Unable to run remote scan:</b> ' . $rscan->err() . "\n";
    }
    // delete results (only for vulnerabilities scans)
    if ($argv[3] == 'vulnscan') {
        $rscan->del_scan();
    }
} else {
    echo 'Scanning local networks: ' . $targets . "\n";