gpt4 book ai didi

linux - Golang 中的 slice 导致空白终端和困惑的线程

转载 作者:IT王子 更新时间:2023-10-29 02:20:18 26 4
gpt4 key购买 nike

嘿,我正在尝试自动化一个工具来进行我的侦察我正在使用 url 来存储带有 https:// 的 url 但是有一个工具 whois 和 sublist3r 需要地址没有 https:// 所以我将字符串 slice 但是当我运行该工具时它崩溃并使我的终端空白我可以输入但看不到输出。

import (
"fmt"
"log"
"os/exec"
"sync"
)

var url string
var wg sync.WaitGroup
var ip string
var nsurl 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",nsurl)
bs, err := cmd.Output()
if err != nil {
log.Fatal(err)
}
outChan <- bs
wg.Done()
}
func nmap (outChan chan<-[]byte) {
cmd := exec.Command("nmap","-sC","-sV","-oA","nmap",ip)
// cmd := exec.Command("nmap","-h")
bs,err := cmd.Output()
if err != nil {
log.Fatal(err)
}
outChan <- bs
wg.Done()
}
func sniper(outChan chan<-[]byte){
cmd:=exec.Command("sniper","-t",url)
bs,err := cmd.Output()
if err!=nil{
log.Fatal(err)
}
outChan <- bs
wg.Done()
}
func sublist3r(outChan chan<-[]byte) {
cmd := exec.Command("sublist3r","-d",nsurl)
bs,err := cmd.Output()
if err!=nil {
log.Fatal(err)
}
outChan <- bs
wg.Done()
}

func inspy (outChan chan<-[]byte){
cmd := exec.Command("inspy","--empspy","/opt/wordlists/wordlists/title-list-large.txt",url)
bs,err := cmd.Output()
if err!=nil {
log.Fatal(err)
}
outChan <- bs
wg.Done()
}
func wig (outChan chan<-[]byte){
//nsurl = url[8:]
cmd := exec.Command("wig",url)
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 with https:// \n")
fmt.Scanln(&url)
fmt.Printf("Please input IP \n")
fmt.Scanln(&ip)
nsurl = url[8:]
wg.Add(1)
go nikto(outChan)
wg.Add(1)
go whois(outChan)
wg.Add(1)
go nmap(outChan)
wg.Add(1)
go sniper(outChan)
wg.Add(1)
go sublist3r(outChan)
wg.Add(1)
go inspy(outChan)
wg.Add(1)
go wig(outChan)
for i := 0; i <7 ; i++ {
bs := <-outChan
fmt.Println(string(bs))
}

close(outChan)
wg.Wait()
}

最佳答案

如果“它崩溃并清空我的终端”那么程序的输出可能包含您的终端 react 不佳的字符

将“unicode/utf8”添加到导入中并尝试替换

fmt.Println(string(bs))

if utf8.ValidString(bs) {
fmt.Printf("%v\n",bs)
} else {
fmt.Printf("warning, loosing output")
}

请参阅此答案,了解如何清理输出以使其可读 Remove invalid UTF-8 characters from a string (Go lang)

关于linux - Golang 中的 slice 导致空白终端和困惑的线程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52456970/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com