Skip to content
Snippets Groups Projects
Verified Commit 7d77b5c4 authored by Tóth Miklós Tibor's avatar Tóth Miklós Tibor :shrug:
Browse files

useragent challenge

parents
No related branches found
No related tags found
No related merge requests found
useragent
all: build
build:
go build -o useragent useragent.go
package main
import (
"flag"
"fmt"
"net/http"
"strconv"
"time"
"github.com/mssola/user_agent"
)
func handler(w http.ResponseWriter, r *http.Request) {
uagent := r.Header.Get("User-Agent")
ua := user_agent.New(uagent)
name, ver := ua.Browser()
v, e := strconv.ParseFloat(ver, 64)
if e != nil {
fmt.Println(e)
_, _ = w.Write([]byte(e.Error()))
return
}
if name == "Netscape" && v >= 7.1 {
_, _ = w.Write([]byte("SECURITEAM{03ff4a5fdf50dd7cd1078ba3f97507ae}"))
} else {
_, _ = w.Write([]byte("You need Netscape 7.1 or newer to view this page"))
}
}
func main() {
port := flag.String("addr", ":8080", "address to bind to")
flag.Parse()
for {
e := http.ListenAndServe(*port, http.HandlerFunc(handler))
if e != nil {
fmt.Println(e)
}
time.Sleep(time.Second)
}
}
[Unit]
Description=Server
[Service]
Type=idle
User=root
WorkingDirectory=/home/securiteam
ExecStart=/home/securiteam/useragent -addr :80
Restart=always
[Install]
WantedBy=multi-user.target
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment