forked from ketaminekid423/SprayingToolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vaporizer.py
executable file
·135 lines (109 loc) · 3.88 KB
/
vaporizer.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
import signal
import asyncio
from core.parsers import bing, google
from core.utils.messages import print_good
from atomizer import Atomizer
from termcolor import colored
from mitmproxy import ctx, exceptions, http
class Vaporizer:
def __init__(self):
self.emails = set()
self.names = set()
self.atomizer = None
self.loop = asyncio.get_event_loop()
for sig in (signal.SIGINT, signal.SIGTERM):
self.loop.add_signal_handler(sig, self.shutdown)
def load(self, loader):
loader.add_option(
name="sprayer",
typespec=str,
default='',
help="sprayer to use"
)
loader.add_option(
name="domain",
typespec=str,
default='',
help="domain to use for email generation"
)
loader.add_option(
name="target",
typespec=str,
default='',
help="target domain or url to password spray"
)
loader.add_option(
name="password",
typespec=str,
default='',
help="password to spray"
)
loader.add_option(
name="email_format",
typespec=str,
default='{first}.{last}',
help="email format",
)
loader.add_option(
name="threads",
typespec=int,
default=3,
help="number of concurrent threads",
)
loader.add_option(
name="no_spray",
typespec=bool,
default=False,
help="don't password spray, just parse emails",
)
def running(self):
if not self.atomizer and not ctx.options.no_spray:
self.atomizer = Atomizer(
loop=self.loop,
target=ctx.options.target,
threads=ctx.options.threads
)
getattr(self.atomizer, ctx.options.sprayer.lower())()
def response(self, flow: http.HTTPFlow) -> None:
try:
emails = []
if "html" in flow.response.headers["Content-Type"] and len(flow.response.content):
if "google.com" in flow.request.host:
names = google(flow.response.content)
elif "bing.com" in flow.request.host:
names = bing(flow.response.content)
else:
return
for name in names:
first, last, full_text = name
ctx.log.info(colored(f"{full_text} => {first} {last}", "yellow"))
self.names.add(f"{first} {last}")
email = f"{ctx.options.email_format.format(first=first, last=last, f=first[:1], l=last[:1])}@{ctx.options.domain}".lower()
emails.append(email)
ctx.log.info(print_good(f"Generated {len(emails)} email(s)"))
if self.atomizer:
asyncio.ensure_future(
self.atomizer.atomize(
userfile=[email for email in emails if email not in self.emails],
password=ctx.options.password
)
)
self.emails |= set(emails)
except KeyError:
pass
def shutdown(self):
with open("emails.txt", "a+") as email_file:
for email in self.emails:
email_file.write(email + '\n')
with open("names.txt", "a+") as name_file:
for name in self.names:
name_file.write(name + '\n')
ctx.log.info(print_good(f"Dumped {len(self.emails)} email(s) to emails.txt"))
if self.atomizer:
self.atomizer.shutdown()
self.loop.stop()
pending = asyncio.Task.all_tasks()
self.loop.run_until_complete(asyncio.gather(*pending))
addons = [
Vaporizer()
]