forked from SEC642/ssrf-playground
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdirect.go
65 lines (57 loc) · 1.41 KB
/
direct.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package main
import (
"html/template"
"net/http"
"strings"
log "github.com/sirupsen/logrus"
)
func direct01Handler(w http.ResponseWriter, r *http.Request) {
p := PageVariables{}
p.Title = "Direct - 01"
url := r.URL.Query().Get("url")
if url == "" {
p.Data = template.HTML(URLInput)
} else {
resp, err := SimpleGET(url)
if err != nil {
log.WithError(err).Warn("Could not make request")
p.Data = template.HTML(`Unexpected error occured. Could not make request`)
} else {
data := string(resp)
p.Data = template.HTML(strings.Replace(data, "\n", "<br>", -1))
}
}
ExecuteTemplate("tmpl/direct.html", w, p)
}
func direct02Handler(w http.ResponseWriter, r *http.Request) {
p := PageVariables{}
p.Title = "Direct - 02"
blackList := []string{
"localhost",
"127.0.0.1",
}
url := r.URL.Query().Get("url")
if url == "" {
p.Data = template.HTML(URLInput)
} else {
bad := false
for _, u := range blackList {
if strings.Contains(url, u) {
bad = true
}
}
if !bad {
resp, err := SimpleGET(url)
if err != nil {
log.WithError(err).Warn("Could not make request")
p.Data = template.HTML(`Unexpected error occured. Could not make request`)
} else {
data := string(resp)
p.Data = template.HTML(strings.Replace(data, "\n", "<br>", -1))
}
} else {
p.Data = "Invalid URL Entered. Please check you query again."
}
}
ExecuteTemplate("tmpl/direct.html", w, p)
}