Last active
January 28, 2019 09:49
-
-
Save fredeil/6beeba366f75f7349bea118e5257e5e5 to your computer and use it in GitHub Desktop.
Endlessly spam random bytes over HTTP POST to a server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"math/rand" | |
"fmt" | |
"time" | |
"strings" | |
"net/http" | |
) | |
const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
func randData(n int) string { | |
b := make([]byte, n) | |
for i := range b { | |
b[i] = letterBytes[rand.Intn(len(letterBytes))] | |
} | |
return string(b) | |
} | |
func main() { | |
url := "http://192.168.1.123:5000/api/values/1" | |
fmt.Println("URL:>", url) | |
// Generate 1GiB of data | |
data := randData(1024*1024*1024) | |
req, _ := http.NewRequest("POST", url, strings.NewReader(data)) | |
req.Header.Set("Content-Type", "application/octet-stream") | |
client := &http.Client{ | |
Timeout: time.Second * 5, | |
} | |
for { | |
client.Do(req) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment