scan.go
func (s Scan) Run() (output Scan, err error) {
	if s.configErr != nil {
		return s, s.configErr
	}

	args, err := s.CreateNmapArgs()
	if err != nil {
		return s, err
	}

	// Find path for nmap binary
	nmapPath, err := exec.LookPath("nmap")
	if err != nil {
		return s, err
	}

	cmd := exec.Command(nmapPath, args...)

	// Configure output pipes
	errPipe, err := cmd.StderrPipe()
	if err != nil {
		return s, err
	}

	outPipe, err := cmd.StdoutPipe()
	if err != nil {
		return s, err
	}

	// Start command
	if err := cmd.Start(); err != nil {
		return s, err
	}

	// Read output
	stdout, err := ioutil.ReadAll(outPipe)
	if err != nil {
		return s, err
	}

	stderr, err := ioutil.ReadAll(errPipe)
	if err != nil {
		return s, err
	}

	// Wait on command to be finished
	if err := cmd.Wait(); err != nil {
		fmt.Println(err)
		return s, errors.New(err.Error() + "\n" + string(stderr))
	}

	// Parse command output
	rawScan, err := parseXML(stdout)
	if err != nil {
		return s, err
	}

	scan := rawScan.cleanScan(s)

	return scan, nil
}
func (s Scan) Run() (output Scan, err error) {
	if s.configErr != nil {
		return s, s.configErr
	}

	args, err := s.CreateNmapArgs()
	if err != nil {
		return s, err
	}

	// Find path for nmap binary
	nmapPath, err := exec.LookPath("nmap")
	if err != nil {
		return s, err
	}

	cmd := exec.Command(nmapPath, args...)

	// Configure output pipes
	errPipe, err := cmd.StderrPipe()
	if err != nil {
		return s, err
	}

	outPipe, err := cmd.StdoutPipe()
	if err != nil {
		return s, err
	}

	// Start command
	if err := cmd.Start(); err != nil {
		return s, err
	}

	// Read output
	stdout, err := ioutil.ReadAll(outPipe)
	if err != nil {
		return s, err
	}

	stderr, err := ioutil.ReadAll(errPipe)
	if err != nil {
		return s, err
	}

	// Wait on command to be finished
	if err := cmd.Wait(); err != nil {
		fmt.Println(err)
		return s, errors.New(err.Error() + "\n" + string(stderr))
	}

	// Parse command output
	rawScan, err := parseXML(stdout)
	if err != nil {
		return s, err
	}

	scan := rawScan.cleanScan(s)

	return scan, nil
}
func ( s Scan ) Run ( ) ( output Scan , err error ) { if s . configErr != nil { return s , s . configErr } args , err := s . CreateNmapArgs ( ) if err != nil { return s , err } // Find path for nmap binary nmapPath , err := exec . LookPath ( " " ) if err != nil { return s , err } cmd := exec . Command ( nmapPath , args ... ) // Configure output pipes errPipe , err := cmd . StderrPipe ( ) if err != nil { return s , err } outPipe , err := cmd . StdoutPipe ( ) if err != nil { return s , err } // Start command if err := cmd . Start ( ) ; err != nil { return s , err } // Read output stdout , err := ioutil . ReadAll ( outPipe ) if err != nil { return s , err } stderr , err := ioutil . ReadAll ( errPipe ) if err != nil { return s , err } // Wait on command to be finished if err := cmd . Wait ( ) ; err != nil { fmt . Println ( err ) return s , errors . New ( err . Error ( ) + " \n " + string ( stderr ) ) } // Parse command output rawScan , err := parseXML ( stdout ) if err != nil { return s , err } scan := rawScan . cleanScan ( s ) return scan , nil }
// Run is used to scan hosts. The Scan object should be configured using
// specified Add* Set* functions.
//
// BUG(t94j0): The scan will sometimes segfault and theres no reason why
Run is used to scan hosts . The Scan object should be configured using specified Add * Set * functions . BUG ( t94j0 ) : The scan will sometimes segfault and theres no reason why