我正在处理多线程和序列化流程,并希望自动化我的侦察流程。
只要我不调用名为nmap. 调用时nmap,它退出并出现以下错误:
./recon-s.go:54:12: 调用 nmap 时参数不足 () want (chan<- []byte)
这是我的代码:
package main
import (
"fmt"
"log"
"os/exec"
"sync"
)
var url string
var wg sync.WaitGroup
var ip string
func nikto(outChan chan<- []byte) {
cmd := exec.Command("nikto", "-h", url)
bs, err := cmd.Output()
if err != nil {
log.Fatal(err)
}
outChan <- bs
wg.Done()
}
func whois(outChan chan<- []byte) {
cmd := exec.Command("whois",url)
bs, err := cmd.Output()
if err != nil {
log.Fatal(err)
}
outChan <- bs
wg.Done()
}
func nmap (outChan chan<-[]byte) {
fmt.Printf("Please input IP")
fmt.Scanln(&ip)
cmd := exec.Command("nmap","-sC","-sV","-oA","nmap",ip)
bs,err := cmd.Output()
if err != nil {
log.Fatal(err)
}
outChan <- bs
wg.Done()
}
func main() {
outChan := make(chan []byte)
fmt.Printf("Please input URL")
fmt.Scanln(&url)
wg.Add(1)
go nikto(outChan)
wg.Add(1)
go whois(outChan)
wg.Add(1)
go nmap()
for i := 0; i < 3; i++ {
bs := <-outChan
fmt.Println(string(bs))
}
close(outChan)
wg.Wait()
}
达令说
相关分类