Skip to content

Instantly share code, notes, and snippets.

@Zenithar
Last active June 29, 2022 13:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zenithar/aa722864b584d73a71357009810a5999 to your computer and use it in GitHub Desktop.
Save Zenithar/aa722864b584d73a71357009810a5999 to your computer and use it in GitHub Desktop.
Threat test server - This server implements common attacks when your product needs to request external HTTP server.
package main
import (
"encoding/json"
"fmt"
"net/http"
"time"
)
// -----------------------------------------------------------------------------
// https://github.com/kuszaj/Flask-GzipBomb/blob/master/flask_gzipbomb/_rawdata.py
var gzipBomb = map[string][]byte{
"1k": {0x1f, 0x8b, 0x08, 0x00, 0xca, 0x77, 0x62, 0x59,
0x02, 0x03, 0x63, 0x60, 0x18, 0x05, 0xa3, 0x60,
0x14, 0x8c, 0x54, 0x00, 0x00, 0x2e, 0xaf, 0xb5,
0xef, 0x00, 0x04, 0x00, 0x00,
},
"10k": {
0x1f, 0x8b, 0x08, 0x00, 0xcb, 0x77, 0x62, 0x59,
0x02, 0x03, 0xed, 0xc1, 0x01, 0x0d, 0x00, 0x00,
0x00, 0xc2, 0xa0, 0xf7, 0x4f, 0x6d, 0x0e, 0x37,
0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x80, 0x37, 0x03, 0x9a, 0xde, 0x1d,
0x27, 0x00, 0x28, 0x00, 0x00,
},
"100k": {
0x1f, 0x8b, 0x08, 0x00, 0xcb, 0x77, 0x62, 0x59,
0x02, 0x03, 0x93, 0xef, 0xe6, 0x60, 0x38, 0x5d,
0x9e, 0x14, 0xc9, 0xc4, 0xfc, 0xf6, 0x20, 0x23,
0x23, 0x03, 0x03, 0x43, 0x93, 0xc2, 0xff, 0xf5,
0x79, 0x1e, 0x0e, 0x20, 0x26, 0x8d, 0x41, 0x8d,
0x44, 0x62, 0xeb, 0x0f, 0x2f, 0x86, 0x09, 0x8c,
0x0c, 0x00, 0x62, 0x5b, 0xc0, 0x8c, 0x85, 0x00,
0x00, 0x00,
},
"1M": {0x1f, 0x8b, 0x08, 0x00, 0xca, 0x77, 0x62, 0x59,
0x02, 0x03, 0x93, 0xef, 0xe6, 0x60, 0x38, 0x55,
0x9e, 0x14, 0xc9, 0xc4, 0xfc, 0xf6, 0xa0, 0x21,
0x23, 0x03, 0x03, 0xc3, 0xa1, 0x05, 0x5f, 0xfd,
0x73, 0x39, 0xe2, 0x17, 0x30, 0x8c, 0x82, 0x51,
0x30, 0x0a, 0x46, 0x1c, 0xb0, 0x63, 0x96, 0x79,
0x65, 0xb1, 0x9c, 0x81, 0x41, 0x80, 0x01, 0x00,
0xa8, 0x32, 0x11, 0xcf, 0x1b, 0x04, 0x00, 0x00,
},
"10M": {
0x1f, 0x8b, 0x08, 0x00, 0xca, 0x77, 0x62, 0x59,
0x02, 0x03, 0xed, 0xd0, 0xb1, 0x0d, 0x82, 0x50,
0x14, 0x40, 0xd1, 0xc7, 0xa7, 0x01, 0x97, 0xa0,
0x67, 0x05, 0x2b, 0xe2, 0x14, 0x54, 0x26, 0x2e,
0x41, 0x4b, 0x62, 0x69, 0xe3, 0x04, 0xc6, 0x0d,
0x98, 0xc1, 0xd8, 0x11, 0x37, 0x70, 0x05, 0x43,
0x98, 0x00, 0x0c, 0x63, 0x90, 0x9c, 0x53, 0xdd,
0xfa, 0x56, 0xb7, 0x22, 0xc6, 0xee, 0xd2, 0xa6,
0xfc, 0xf7, 0xca, 0xb2, 0x88, 0xe8, 0xef, 0xcb,
0x30, 0x15, 0x87, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x76, 0xae, 0xff, 0x5e, 0x4f,
0x69, 0x8b, 0x66, 0x3d, 0x1f, 0xdf, 0xc9, 0x10,
0x00, 0xd8, 0x81, 0xb9, 0xfc, 0xd4, 0xe3, 0x23,
0xe2, 0x19, 0x7f, 0x31, 0xd9, 0x23, 0x9c, 0xe0,
0x27, 0x00, 0x00,
},
"100M": {
0x1f, 0x8b, 0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
}
// -----------------------------------------------------------------------------
func SlowResponder(wait time.Duration) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
time.Sleep(wait)
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
json.NewEncoder(w).Encode(map[string]any{
"success": true,
})
}
}
func ChunkedResponser(delay time.Duration) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// Convert to a flusher instance
flusher, ok := w.(http.Flusher)
if !ok {
http.Error(w, "The server doesn't support streaming.", http.StatusInternalServerError)
return
}
w.Header().Set("Connection", "Keep-Alive")
w.Header().Set("Transfer-Encoding", "chunked")
w.Header().Set("X-Content-Type-Options", "nosniff")
w.WriteHeader(http.StatusOK)
flusher.Flush()
time.Sleep(delay)
json.NewEncoder(w).Encode(map[string]any{
"success": true,
})
flusher.Flush()
}
}
func GzipBomb(size string) http.HandlerFunc {
bomb, ok := gzipBomb[size]
if !ok {
panic(fmt.Errorf("unsupported gzip bomb size: %s", size))
}
return func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Encoding", "gzip")
w.Header().Set("Content-Length", fmt.Sprintf("%d", len(bomb)))
w.WriteHeader(http.StatusOK)
w.Write(bomb)
}
}
// -----------------------------------------------------------------------------
func main() {
http.HandleFunc("/chunked-responder", ChunkedResponser(time.Second))
http.HandleFunc("/slow-responder/1s", SlowResponder(time.Second))
http.HandleFunc("/slow-responder/30s", SlowResponder(30*time.Second))
http.HandleFunc("/slow-responder/60s", SlowResponder(60*time.Second))
http.HandleFunc("/slow-responder/120s", SlowResponder(120*time.Second))
http.HandleFunc("/slow-responder/240s", SlowResponder(240*time.Second))
http.HandleFunc("/gzip-bomb/1k", GzipBomb("1k"))
http.HandleFunc("/gzip-bomb/10k", GzipBomb("10k"))
http.HandleFunc("/gzip-bomb/100k", GzipBomb("100k"))
http.HandleFunc("/gzip-bomb/1M", GzipBomb("1M"))
http.HandleFunc("/gzip-bomb/10M", GzipBomb("10M"))
http.HandleFunc("/gzip-bomb/100M", GzipBomb("100M"))
http.HandleFunc("/gzip-bomb/1G", GzipBomb("1G"))
http.HandleFunc("/gzip-bomb/10G", GzipBomb("10G"))
http.ListenAndServe(":8888", nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment