forked from hatRiot/zarp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzarp.py
executable file
·164 lines (154 loc) · 4.72 KB
/
zarp.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
#! /usr/bin/python
from os import getcwd, getuid
from sys import path, argv, exit
path.insert(0, getcwd() + '/src/')
path.insert(0, getcwd() + '/src/core/')
path.insert(0, getcwd() + '/src/modules/')
from util import get_subclass, print_menu, header, Error, Msg, debug
from commands import getoutput
import stream
import session_manager
import parse_cmd
import config
from colors import color
# module loading
from src.modules import poison, dos, scanner, services, sniffer, parameter
import importlib
class LoadedModules:
""" Load modules
"""
def __init__(self):
self.total = 0
self.poison = []
self.dos = []
self.sniffers = []
self.services = []
self.scanner = []
self.parameter = []
def load(self):
""" Load modules.
"""
for module in poison.__all__:
mod = getattr(importlib.import_module('src.modules.poison.%s'%module, 'poison'),module)
self.poison.append(mod)
self.total += 1
for module in dos.__all__:
mod = getattr(importlib.import_module('src.modules.dos.%s'%module, 'dos'),module)
self.dos.append(mod)
self.total += 1
for module in scanner.__all__:
mod = getattr(importlib.import_module('src.modules.scanner.%s'%module, 'scanner'),module)
self.scanner.append(mod)
self.total += 1
for module in services.__all__:
mod = getattr(importlib.import_module('src.modules.services.%s'%module, 'services'),module)
self.services.append(mod)
self.total += 1
for module in sniffer.__all__:
mod = getattr(importlib.import_module('src.modules.sniffer.%s'%module, 'sniffer'),module)
self.sniffers.append(mod)
self.total += 1
for module in parameter.__all__:
mod = getattr(importlib.import_module('src.modules.parameter.%s'%module, 'parameter'),module)
self.parameter.append(mod)
self.total += 1
def main():
""" Zarp entry point
"""
# set up configuration
config.initialize()
# load modules
loader = LoadedModules()
loader.load()
Msg('Loaded %d modules.'%loader.total)
# handle command line options first
if len(argv) > 1:
parse_cmd.parse(argv, loader)
# menus
main_menu = [ 'Poisoners', 'DoS Attacks', 'Sniffers', 'Scanners',
'Parameter','Services','Sessions']
running = True
choice = -1
while running:
header()
choice = print_menu(main_menu)
if choice == 0:
# check if they've got running sessions!
cnt = stream.get_session_count()
if cnt > 0:
choice = raw_input(color.YELLOW + 'You have %d sessions running. Are you sure? [y] '%cnt\
+ color.END)
if 'y' in choice.lower() or choice == '':
Msg('Shutting all sessions down...')
stream.stop_session('all', -1)
running = False
else:
debug("Exiting with session count: %d"%(cnt))
Msg("Exiting...")
running = False
elif choice == 1:
while True:
choice = print_menu([x().which for x in loader.poison])
if choice == 0: break
elif choice == -1: pass
elif choice > len(loader.poison): continue
else:
stream.initialize(loader.poison[choice-1])
elif choice == 2:
while True:
choice = print_menu([x().which for x in loader.dos])
if choice == 0: break
elif choice == -1: pass
elif choice > len(loader.dos): continue
else:
stream.initialize(loader.dos[choice-1])
elif choice == 3:
while True:
choice = print_menu([x().which for x in loader.sniffers])
if choice == 0: break
elif choice == -1: pass
elif choice > len(loader.sniffers): continue
else:
stream.initialize(loader.sniffers[choice-1])
elif choice == 4:
while True:
choice = print_menu([x().which for x in loader.scanner])
if choice == 0: break
elif choice == -1: pass
elif choice > len(loader.scanner): continue
else:
stream.initialize(loader.scanner[choice-1])
elif choice == 5:
while True:
choice = print_menu([x().which for x in loader.parameter])
if choice == 0: break
elif choice == -1: pass
elif choice > len(loader.parameter): continue
else:
stream.initialize(loader.parameter[choice-1])
elif choice == 6:
while True:
choice = print_menu([x().which for x in loader.services])
if choice == 0: break
elif choice == -1: pass
elif choice > len(loader.services): continue
else:
stream.initialize(loader.services[choice-1])
elif choice == 7:
session_manager.menu()
elif choice == -1:
pass
# Application entry; dependency checks, etc.
if __name__=="__main__":
# perm check
if int(getuid()) > 0:
Error('Please run as root.')
exit(1)
# check for forwarding
if not getoutput('cat /proc/sys/net/ipv4/ip_forward') == '1':
Msg('IPv4 forwarding disabled. Enabling..')
tmp = getoutput('sudo sh -c \'echo "1" > /proc/sys/net/ipv4/ip_forward\'')
if len(tmp) > 0:
Error('Error enabling IPv4 forwarding.')
exit(1)
main()