Skip to content

Instantly share code, notes, and snippets.

@dmitris
Created May 12, 2015 13:59
Show Gist options
  • Save dmitris/2dbecd24facaeb79b500 to your computer and use it in GitHub Desktop.
Save dmitris/2dbecd24facaeb79b500 to your computer and use it in GitHub Desktop.
XSS injection outside 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(":8185", 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></B>URL: %s", unsafe)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment