go:embed domain_1800w.txt中打包的domain_1800w.txt:
百度网盘
链接:https://pan.baidu.com/s/11wDJE4r8ZOcxcKDRySG0_g?pwd=osxl
提取码:osxl
package main
import (
"bytes"
_ "embed"
"flag"
"fmt"
"github.com/fatih/color"
"github.com/parnurzeal/gorequest"
"strings"
"sync"
"time"
)
//go:embed domain_1800w.txt
var d string
var domain string
var wg sync.WaitGroup
var current_url string
var thread int
var green = color.New(color.FgGreen) //创造一个新的颜色
var red = color.New(color.FgRed)
func scan(ch chan string) {
for x := range ch {//寻找管道内的东西
defer wg.Done()
http := fmt.Sprintf("http://%s", x)//补全字典里面的地址
https := fmt.Sprintf("https://%s", x)
request := gorequest.New()
resp, _, err := request.Head(http).Timeout(3*time.Second).End()
if err != nil {
goto HTTPS//如果改域名不是http的跳转到https查看是否存活//continue //不能使用return不然出现很多错误进程会卡住
}
if resp.StatusCode == 200 || resp.StatusCode == 403 {
current_url = http
green.Println("[+] 存活 -> ", http)
}
HTTPS:
resp, _, err = request.Head(https).Timeout(3*time.Second).End()
if err != nil {
continue
}
if resp.StatusCode == 200 || resp.StatusCode == 403 {
current_url = https
green.Println("[+] 存活 -> ", https)
}
}
}
func init() {
flag.StringVar(&domain, "domain", "", "域名")
flag.IntVar(&thread,"thread",10,"线程数量(默认为10最大为1024)")
}
func main() {
flag.Parse()
if domain == "" {
flag.Usage()//打印命令行里面的东西
return
}
ch := make(chan string, 1024)
for i := 0; i <= thread; i++ {
go scan(ch)
}
t:=time.Now()
var buffer bytes.Buffer
buffer.WriteString(d)
var process int
go func() {
for {
switch process % 4 {
case 0:
fmt.Print("\033[36m[/]\033[m")
case 1:
fmt.Print("\033[36m[-]\033[m")
case 2:
fmt.Print("\033[36m[\\]\033[m")
case 3:
fmt.Print("\033[36m[|]\033[m")
}
process += 1
fmt.Printf(" %s\r", current_url)
time.Sleep(75 * time.Millisecond)
}
}()
for {
line, err := buffer.ReadString('\n') //当缓冲区读到换行符的时候
if err != nil {
close(ch)
break
}
wg.Add(1)
line = strings.TrimSpace(line)//对读出来的line做空格的处理,把空格替换为空
sprintf := fmt.Sprintf("%s.%s", line, domain)
ch <- sprintf //把读出来的内容给这个ch管道
}
wg.Wait()
red.Println("运行结束 总耗时 ->",time.Now().Sub(t).String())
}
使用命令:
go build dxczymtc.go
.\dxczymtc.exe --domain "域名" --thread 线程数
.\dxczymtc.exe --domain "baidu.com" --thread 10
运行结果: