This repository has been archived by the owner on Feb 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
executable file
·169 lines (130 loc) · 4.54 KB
/
main.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
#!/usr/bin/env python3
import warnings
warnings.simplefilter("ignore", Warning)
import curses
import random
import sys
import time
from scapy.all import *
from modules.HelloWorld import HelloWorld
from modules.WebGet import WebGet
from modules.WebLogin import WebLogin
BANNER = r"""
__ __ __ __ __ ___ __ __
/ // /__ _____/ /__ / /_/ / ___ / _ \___ _____/ /_____ / /_
/ _ / _ `/ __/ '_/ / __/ _ \/ -_) / ___/ _ `/ __/ '_/ -_) __/
/_//_/\_,_/\__/_/\_\ \__/_//_/\__/ /_/ \_,_/\__/_/\_\\__/\__/
"""
DELTA_SPEED = 1
DELTA_LOOT = 0.001
class Loot:
"""
Wrapper over all Loot types.
"""
modules = None
def __init__(self, usernames, passwords, websites, directories):
# Weighted loot modules.
self.modules = {
WebGet(websites, directories): 0.999,
WebLogin(usernames, passwords, websites): 0.001
}
def play(self, s: conf.L2socket):
random.choices(list(self.modules.keys()), weights=list(self.modules.values()))[0].play(s)
def main(iface, pcap):
print(f":: Reading username wordlist...")
usernames = [l for l in open("wordlists/usernames.txt").read().split("\n")]
print(f":: Reading password wordlist...")
passwords = [l for l in open("wordlists/passwords.txt").read().split("\n")]
print(f":: Reading website wordlist...")
websites = [l for l in open("wordlists/websites.txt").read().split("\n")]
print(f":: Reading directories wordlist...")
directories = [l for l in open("wordlists/directories.txt").read().split("\n")]
l = Loot(usernames, passwords, websites, directories)
print(f":: Loading reader for packets from {pcap}...")
preader = PcapReader(pcap)
print(f":: Creating layer 2 socket on {iface}...")
s = conf.L2socket(iface=iface)
print(f":: Sending out a \"Hello World!\" as a sanity check...")
HelloWorld.play(s)
print(f":: Initialization complete.")
print(f":: Starting replay.")
time.sleep(1)
# Set up TUI.
stdscr = curses.initscr()
curses.noecho()
curses.cbreak()
curses.curs_set(0)
stdscr.keypad(True)
stdscr.clear()
# Non-blocking getch.
stdscr.nodelay(True)
speed = 0 # packets/second e [0, inf)
loot = 0 # probability e [0, 1]
for i,line in enumerate(BANNER.split("\n")):
stdscr.addstr(i, 1, line)
stati = i
stdscr.addstr(stati+1, 1, f" Current settings: ")
stdscr.addstr(stati+2, 1, f" rate = {speed} packets/second ")
stdscr.addstr(stati+3, 1, f" P(loot) = {loot:.2f} ")
stdscr.addstr(stati+4, 1, f" ")
stdscr.addstr(stati+5, 1, f" q Quit the program. ")
stdscr.addstr(stati+6, 1, f" Increase replay speed. ")
stdscr.addstr(stati+7, 1, f" Decrease replay speed. ")
stdscr.addstr(stati+8, 1, f" Increase loot probability. ")
stdscr.addstr(stati+9, 1, f" Decrease loot probability. ")
stdscr.addch(stati+6, 2, curses.ACS_UARROW, curses.A_ALTCHARSET)
stdscr.addch(stati+7, 2, curses.ACS_DARROW, curses.A_ALTCHARSET)
stdscr.addch(stati+8, 2, curses.ACS_RARROW, curses.A_ALTCHARSET)
stdscr.addch(stati+9, 2, curses.ACS_LARROW, curses.A_ALTCHARSET)
stdscr.refresh()
# Main loop.
while True:
c = stdscr.getch()
if c == ord("q"):
break
# Increase speed.
elif c == curses.KEY_UP:
speed += DELTA_SPEED
stdscr.addstr(stati+2, 1, f" rate = {speed} packets/second ")
stdscr.refresh()
# Decrease speed.
elif c == curses.KEY_DOWN and speed-DELTA_SPEED >= -0.0001:
speed -= DELTA_SPEED
stdscr.addstr(stati+2, 1, f" rate = {speed} packets/second ")
stdscr.refresh()
# Increase loot.
elif c == curses.KEY_RIGHT and loot+DELTA_LOOT <= 1.0001:
loot += DELTA_LOOT
stdscr.addstr(stati+3, 1, f" P(loot) = {loot:.2f} ")
stdscr.refresh()
# Decrease loot.
elif c == curses.KEY_LEFT and loot-DELTA_LOOT >= -0.0001:
loot -= DELTA_LOOT
stdscr.addstr(stati+3, 1, f" P(loot) = {loot:.2f} ")
stdscr.refresh()
# Random probability of a loot sequence.
try:
if random.random() < loot:
l.play(s)
elif speed > 0:
s.send(preader.next())
except:
pass
if speed == 0:
time.sleep(0.01)
else:
time.sleep(1/speed)
# End the TUI.
curses.echo()
curses.nocbreak()
curses.curs_set(1)
stdscr.keypad(False)
curses.endwin()
print(f":: Session complete.")
if __name__ == "__main__":
if len(sys.argv) < 2:
print("Usage: %s <INTERFACE> <PACKETCAP>" % sys.argv[0])
print("<INTERFACE> Interface to transmit packets on.")
print("<PACKETCAP> Capture of packets to replay as noise.")
else:
main(sys.argv[1], sys.argv[2])