예제 #1
0
        } elseif ($scan_type == 'normal') {
            $scan->append_option('-sS');
        } elseif ($scan_type == 'full') {
            $scan->append_option('-sS -p 1-65535');
        }
    }
    // ping scan
    $scan->search_hosts();
    $status = $scan->get_status();
    while ($status == 'Searching Hosts') {
        $status = $scan->get_status();
        sleep(2);
    }
    // normal scan
    if ($scan_type != 'ping' && $argv[3] != 'vulnscan') {
        $scan->launch_scan();
        while ($scan->get_status() == 'Scanning Hosts') {
            $progress = $scan->get_progress();
            echo $scan->get_status() . ': ' . $progress['hosts_scanned'] . '/' . $progress['total_hosts'] . '  ' . $progress['remaining'] . "\n";
            sleep(2);
        }
    }
    $ips = $scan->get_results();
    // delete results (only for vulnerabilities scans)
    if ($argv[3] == 'vulnscan') {
        $scan->delete_data();
    }
}
if (is_array($ips['scanned_ips']) && !empty($ips['scanned_ips'])) {
    foreach ($ips['scanned_ips'] as $ip => $val) {
        echo "Host {$ip} appears to be up\n";
예제 #2
0
function do_ping($wizard)
{
    $step = intval($wizard->get_step_data('scan_step'));
    if ($step == 0) {
        $nets = $wizard->get_step_data('scan_nets');
        if (count($nets) < 1) {
            $msg = _('Invalid networks selected to scan');
            set_scan_error_message($wizard, $msg);
            $response['error'] = TRUE;
            return $response;
        }
        $nets = implode(' ', $nets);
        $obj = new Scan($nets);
        // ping scan
        $obj->search_hosts();
        $wizard->set_step_data('scan_step', 1);
    } else {
        $obj = new Scan();
    }
    $data = array();
    $status = $obj->get_status();
    if ($status == 'Searching Hosts') {
        $data['finish'] = FALSE;
    } elseif ($status == 'Search Finished') {
        $total = $obj->get_num_of_hosts();
        if ($total == 0) {
            $next_step = 3;
            $obj->delete_data();
        } else {
            $res = $obj->launch_scan();
            if ($res === FALSE) {
                $msg = _('Impossible to launch NMAP scan');
                set_scan_error_message($wizard, $msg);
                $response['error'] = TRUE;
                return $response;
            }
            $next_step = 2;
        }
        $wizard->set_step_data('scan_hosts', $total);
        $wizard->set_step_data('scan_step', $next_step);
        $data['finish'] = TRUE;
    } else {
        $msg = _("Invalid NMAP status ({$status}). Expecting 'Searching Hosts' or 'Search Finished'");
        set_scan_error_message($wizard, $msg);
        $response['error'] = TRUE;
        return $response;
    }
    $response['error'] = FALSE;
    $response['data'] = $data;
    $wizard->save_status();
    return $response;
}