Exemplo n.º 1
0
/**
 * Select how to scan based on scan type.
 *
 * if ping/pear make threads, if fping than just check since it has built-in threading !
 */
# fping
if ($Scan->settings->scanPingType == "fping" && $argv[1] == "discovery") {
    # fetch subnet
    $subnet = $Subnets->fetch_subnet(null, $argv[2]);
    $subnet !== false ?: die(json_encode(array("status" => 1, "error" => "Invalid subnet ID provided")));
    //set exit flag to true
    $Scan->ping_set_exit(false);
    # set cidr
    $subnet_cidr = $Subnets->transform_to_dotted($subnet->subnet) . "/" . $subnet->mask;
    # execute
    $retval = $Scan->ping_address_method_fping_subnet($subnet_cidr);
    # errors
    if ($retval == 3) {
        die(json_encode(array("status" => 1, "error" => "invalid command line arguments")));
    }
    if ($retval == 4) {
        die(json_encode(array("status" => 1, "error" => "system call failure")));
    }
    # parse result
    if (sizeof(@$Scan->fping_result) == 0) {
        die(json_encode(array("status" => 0, "values" => array("alive" => null))));
    } else {
        //check each line
        foreach ($Scan->fping_result as $l) {
            //split
            $field = array_filter(explode(" ", $l));