Skip to content

Instantly share code, notes, and snippets.

@dmitris
Last active August 29, 2015 14:21
Show Gist options
  • Save dmitris/7f7cf36bd43aae713b89 to your computer and use it in GitHub Desktop.
Save dmitris/7f7cf36bd43aae713b89 to your computer and use it in GitHub Desktop.
XSS injection inside of a tag (UNSAFE code, use with caution and remember to shut down the server!)
package main
import (
"fmt"
"net/http"
"net/url"
)
func main() {
http.HandleFunc("/", badHandler)
http.ListenAndServe(":8184", nil)
}
// Purposedly unsafe!! DO NOT USE in any setting where it can lead to a compromise!
func badHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-type", "text/html; charset=utf-8")
unsafe, _ := url.QueryUnescape(r.RequestURI)
fmt.Fprintf(w, "<!doctype html>\n<B>URL: %s</B>", unsafe)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment