我正在處理多線程和序列化流程,并希望自動化我的偵察流程。只要我不調用名為nmap. 調用時nmap,它退出并出現以下錯誤:./recon-s.go:54:12: 調用 nmap 時參數不足 () want (chan<- []byte)這是我的代碼:package mainimport ( "fmt" "log" "os/exec" "sync")var url stringvar wg sync.WaitGroupvar ip stringfunc 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()}
1 回答

達令說
TA貢獻1821條經驗 獲得超6個贊
你得到的錯誤是:
調用 nmap 時參數不足 have () want (chan<- []byte)
這意味著nmap()方法main沒有任何參數,但實際nmap()定義需要一個參數chan<-[]byte,所以你必須從nmap()下面傳遞一個參數,我提到了你剛剛錯過的參數。
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(outChan) //you are just missing the argument here.
for i := 0; i < 3; i++ {
bs := <-outChan
fmt.Println(string(bs))
}
close(outChan)
wg.Wait()
}
- 1 回答
- 0 關注
- 141 瀏覽
添加回答
舉報
0/150
提交
取消