Пример #1
0
     // Append RDNS
     if (!$rdns) {
         $scan->append_option('-n');
     }
     if ($scan_type == 'fast') {
         $scan->append_option('-p21,22,23,25,53,80,113,115,135,139,161,389,443,445,554,1194,1241,1433,3000,3306,3389,8080,9390,27017');
     } elseif ($scan_type == 'custom') {
         $scan->append_option("-sS -p {$ports}");
     } 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();
Пример #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;
}