-
Notifications
You must be signed in to change notification settings - Fork 1
/
oracle.go
89 lines (79 loc) · 1.41 KB
/
oracle.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package main
import (
"encoding/json"
"fmt"
"log"
"net/url"
"strings"
"sync"
"gopkg.in/yaml.v2"
)
type Output struct {
URL string
Keys []string
}
var (
Filter sync.Map
)
func filter(u string, n int) bool {
if n < 4 {
return true
}
parsed, _ := url.Parse(u)
buildurl := parsed.Scheme + "://" + parsed.Host + parsed.Path
str := fmt.Sprintf("%d%s", n, buildurl)
_, present := Filter.Load(str)
if present {
return false
}
Filter.Store(str, true)
return true
}
// goroutine to handle output
func writer() {
for res := range Results {
reflected := 0
str := res.URL
keys := []string{}
if strings.Contains(res.URL, "?") {
str += "&"
} else {
str += "?"
}
for i, param := range res.Parameters {
hash := fmt.Sprintf("zzx%dy", i)
if strings.Contains(res.Response, hash) {
reflected++
str += param + "=" + hash + "&"
keys = append(keys, param)
}
}
// remove trailing '&'
str = str[:len(str)-1]
if reflected > 0 && filter(str, reflected) {
if Json {
b, err := json.Marshal(Output{
URL: res.URL,
Keys: keys,
})
if err != nil {
log.Println("Error:", err)
continue
}
fmt.Println(string(b))
} else if Yaml {
b, err := yaml.Marshal(Output{
URL: res.URL,
Keys: keys,
})
if err != nil {
log.Println("Error:", err)
continue
}
fmt.Println(string(b))
} else {
fmt.Println(str)
}
}
}
}