-
Notifications
You must be signed in to change notification settings - Fork 6
/
goldphish.py
183 lines (145 loc) · 4.99 KB
/
goldphish.py
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#!/usr/bin/env python
#
__author__ = 'Marcin Ulikowski'
__version__ = '20150920'
__email__ = 'marcin@ulikowski.pl'
import sys
from MaltegoTransform import *
me = MaltegoTransform()
me.parseArguments(sys.argv)
def bitsquatting(domain):
out = []
dom = domain.rsplit('.', 1)[0]
tld = domain.rsplit('.', 1)[1]
masks = [1, 2, 4, 8, 16, 32, 64, 128]
for i in range(0, len(dom)):
c = dom[i]
for j in range(0, len(masks)):
b = chr(ord(c) ^ masks[j])
o = ord(b)
if (o >= 48 and o <= 57) or (o >= 97 and o <= 122) or o == 45:
out.append(dom[:i] + b + dom[i+1:] + '.' + tld)
return out
def homoglyph(domain):
glyphs = {
'd':['b', 'cl'], 'm':['n', 'nn', 'rn'], 'l':['1', 'i'], 'o':['0'],
'w':['vv'], 'n':['m'], 'b':['d'], 'i':['1', 'l'], 'g':['q'], 'q':['g']
}
out = []
dom = domain.rsplit('.', 1)[0]
tld = domain.rsplit('.', 1)[1]
for ws in range(0, len(dom)):
for i in range(0, (len(dom)-ws)+1):
win = dom[i:i+ws]
j = 0
while j < ws:
c = win[j]
if c in glyphs:
for g in glyphs[c]:
win = win[:j] + g + win[j+1:]
if len(g) > 1:
j += len(g) - 1
out.append(dom[:i] + win + dom[i+ws:] + '.' + tld)
j += 1
return list(set(out))
def repetition(domain):
out = []
dom = domain.rsplit('.', 1)[0]
tld = domain.rsplit('.', 1)[1]
for i in range(0, len(dom)):
if dom[i].isalpha():
out.append(dom[:i] + dom[i] + dom[i] + dom[i+1:] + '.' + tld)
return list(set(out))
def transposition(domain):
out = []
dom = domain.rsplit('.', 1)[0]
tld = domain.rsplit('.', 1)[1]
for i in range(0, len(dom)-1):
if dom[i+1] != dom[i]:
out.append(dom[:i] + dom[i+1] + dom[i] + dom[i+2:] + '.' + tld)
return out
def replacement(domain):
keys = {
'1':'2q', '2':'3wq1', '3':'4ew2', '4':'5re3', '5':'6tr4', '6':'7yt5', '7':'8uy6', '8':'9iu7', '9':'0oi8', '0':'po9',
'q':'12wa', 'w':'3esaq2', 'e':'4rdsw3', 'r':'5tfde4', 't':'6ygfr5', 'y':'7uhgt6', 'u':'8ijhy7', 'i':'9okju8', 'o':'0plki9', 'p':'lo0',
'a':'qwsz', 's':'edxzaw', 'd':'rfcxse', 'f':'tgvcdr', 'g':'yhbvft', 'h':'ujnbgy', 'j':'ikmnhu', 'k':'olmji', 'l':'kop',
'z':'asx', 'x':'zsdc', 'c':'xdfv', 'v':'cfgb', 'b':'vghn', 'n':'bhjm', 'm':'njk'
}
out = []
dom = domain.rsplit('.', 1)[0]
tld = domain.rsplit('.', 1)[1]
for i in range(0, len(dom)):
if dom[i] in keys:
for c in range(0, len(keys[dom[i]])):
out.append(dom[:i] + keys[dom[i]][c] + dom[i+1:] + '.' + tld)
return out
def omission(domain):
out = []
dom = domain.rsplit('.', 1)[0]
tld = domain.rsplit('.', 1)[1]
for i in range(0, len(dom)):
out.append(dom[:i] + dom[i+1:] + '.' + tld)
return list(set(out))
def hyphenation(domain):
out = []
dom = domain.rsplit('.', 1)[0]
tld = domain.rsplit('.', 1)[1]
for i in range(1, len(dom)):
if dom[i] not in ['-', '.'] and dom[i-1] not in ['-', '.']:
out.append(dom[:i] + '-' + dom[i:] + '.' + tld)
return out
def subdomain(domain):
out = []
dom = domain.rsplit('.', 1)[0]
tld = domain.rsplit('.', 1)[1]
for i in range(1, len(dom)):
if dom[i] not in ['-', '.'] and dom[i-1] not in ['-', '.']:
out.append(dom[:i] + '.' + dom[i:] + '.' + tld)
return out
def insertion(domain):
keys = {
'1':'2q', '2':'3wq1', '3':'4ew2', '4':'5re3', '5':'6tr4', '6':'7yt5', '7':'8uy6', '8':'9iu7', '9':'0oi8', '0':'po9',
'q':'12wa', 'w':'3esaq2', 'e':'4rdsw3', 'r':'5tfde4', 't':'6ygfr5', 'y':'7uhgt6', 'u':'8ijhy7', 'i':'9okju8', 'o':'0plki9', 'p':'lo0',
'a':'qwsz', 's':'edxzaw', 'd':'rfcxse', 'f':'tgvcdr', 'g':'yhbvft', 'h':'ujnbgy', 'j':'ikmnhu', 'k':'olmji', 'l':'kop',
'z':'asx', 'x':'zsdc', 'c':'xdfv', 'v':'cfgb', 'b':'vghn', 'n':'bhjm', 'm':'njk'
}
out = []
dom = domain.rsplit('.', 1)[0]
tld = domain.rsplit('.', 1)[1]
for i in range(1, len(dom)-1):
if dom[i] in keys:
for c in range(0, len(keys[dom[i]])):
out.append(dom[:i] + keys[dom[i]][c] + dom[i] + dom[i+1:] + '.' + tld)
out.append(dom[:i] + dom[i] + keys[dom[i]][c] + dom[i+1:] + '.' + tld)
return out
def fuzz_domain(domain):
domains = []
domains.append({ 'type':'Original*', 'domain':domain })
for i in bitsquatting(domain):
domains.append({ 'type':'Bitsquatting', 'domain':i })
for i in homoglyph(domain):
domains.append({ 'type':'Homoglyph', 'domain':i })
for i in repetition(domain):
domains.append({ 'type':'Repetition', 'domain':i })
for i in transposition(domain):
domains.append({ 'type':'Transposition', 'domain':i })
for i in replacement(domain):
domains.append({ 'type':'Replacement', 'domain':i })
for i in omission(domain):
domains.append({ 'type':'Omission', 'domain':i })
for i in hyphenation(domain):
domains.append({ 'type':'Hyphenation', 'domain':i })
for i in insertion(domain):
domains.append({ 'type':'Insertion', 'domain':i })
for i in subdomain(domain):
domains.append({ 'type':'Subdomain', 'domain':i })
domains[:] = [x for x in domains if x['domain']]
return domains
def main():
domains = fuzz_domain(sys.argv[1].lower())
for i in domains:
ent = me.addEntity("maltego.Domain",i['domain'])
#print i['type'], i['domain']
me.returnOutput()
if __name__ == '__main__':
main()