-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.go
87 lines (66 loc) · 1.26 KB
/
main.go
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package main
import (
"bufio"
"fmt"
"os"
"os/exec"
"os/signal"
"runtime"
"strconv"
"strings"
"sync"
"syscall"
)
var (
cls string
isWin = false
)
const defaultThreads = 2048
func init() {
if runtime.GOOS == "windows" {
isWin = true
}
}
func main() {
wg := sync.WaitGroup{}
defer wg.Wait()
ip, port, threads := userInput()
botManager := newBotManager(ip, port, threads, &wg)
botManager.start()
clear()
fmt.Printf("Target: %s:%s\nThreads: %d\n\n(Ctrl + C) to quit\n", ip, port, threads)
c := make(chan os.Signal)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
go func() {
<-c
botManager.stop()
}()
}
func userInput() (ip string, port string, threads int) {
scanner := bufio.NewScanner(os.Stdin)
fmt.Print("Enter IP: ")
scanner.Scan()
ip = scanner.Text()
fmt.Print("Enter Port: ")
scanner.Scan()
port = scanner.Text()
fmt.Printf("Enter Threads (default: %d): ", defaultThreads)
scanner.Scan()
strThreads := scanner.Text()
if len(strings.TrimSpace(strThreads)) != 0 {
threads, _ = strconv.Atoi(strThreads)
} else {
threads = defaultThreads
}
return
}
func clear() {
var cmd *exec.Cmd
if isWin {
cmd = exec.Command("cmd", "/c", "cls")
} else {
cmd = exec.Command("clear")
}
cmd.Stdout = os.Stdout
cmd.Run()
}