-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
63 lines (48 loc) · 1.1 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
package main
import (
"bytes"
"encoding/json"
"fmt"
"math/rand"
"net/http"
"time"
)
var attackType = [...]string{
"Type1",
"Type2",
"Type3",
"Type4",
}
func main() {
fmt.Println("Hello World")
client := &http.Client{}
r := rand.New(rand.NewSource(time.Now().UnixNano()))
for {
source1 := 11 + r.Int63n(181)
source2 := r.Int63n(256)
source3 := r.Int63n(256)
source4 := r.Int63n(256)
source := fmt.Sprintf("%v.%v.%v.%v", source1, source2, source3, source4)
dest1 := 11 + r.Int63n(181)
dest2 := r.Int63n(256)
dest3 := r.Int63n(256)
dest4 := r.Int63n(256)
dest := fmt.Sprintf("%v.%v.%v.%v", dest1, dest2, dest3, dest4)
selectedType := attackType[rand.Intn(len(attackType))]
body := map[string]string{
"srcIP": source,
"dstIP": dest,
"attackType": selectedType,
}
jsonBody, err := json.Marshal(body)
if err != nil {
fmt.Println(err.Error())
panic(err)
}
_, err = client.Post("http://localhost:3000", "application/json", bytes.NewReader(jsonBody))
if err != nil {
panic(err)
}
time.Sleep(time.Duration(1+r.Int63n(9)) * time.Second)
}
}