forked from R3dFruitRollUp/warberry
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwrapper.py
executable file
·216 lines (189 loc) · 10.4 KB
/
wrapper.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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#!/usr/bin/python2
"""
This file is part of the WarBerry tool.
Copyright (c) 2016 Yiannis Ioannides (@sec_groundzero).
https://github.com/secgroundzero/warberry
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
"""
import logging
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
logging.info("finished")
logging.captureWarnings(True)
#Suppress Scapy IPv6 Warnings
import requests.packages.urllib3
requests.packages.urllib3.disable_warnings()
import os, os.path
import signal
#External modules
from src.core.scanners.targetted_scanner import *
from src.core.scanners.targetted_thread_scanner import *
from src.core.enumeration.nameservers import *
from src.core.enumeration.bluetooth_enum import *
from src.core.enumeration.ip_enum import *
from src.core.enumeration.network_packets import *
from src.core.enumeration.services_enum import *
from src.core.enumeration.wifi_enum import *
from src.core.enumeration.zones import *
from src.utils.console_colors import *
from optparse import OptionParser
from src.utils.encryption import *
from src.utils.move_files import *
from src.utils.delete_files import *
from xml_producer import *
from multiprocessing import Process
from scapy.all import *
from src.core.exploits.responder_poison import poison
def warberry():
start_time = time.time()
#move previous files in /Results
move_files(int(start_time))
delete_files()
version = bcolors.TITLE + ( '''
_ _ ___ ____________ ___________________ __
| | | |/ _ \ | ___ \ ___ \ ___| ___ \ ___ \ \ / /
| | | / /_\ \| |_/ / |_/ / |__ | |_/ / |_/ /\ V /
| |/\| | _ || /| ___ \ __|| /| / \ /
\ /\ / | | || |\ \| |_/ / |___| |\ \| |\ \ | |
\/ \/\_| |_/\_| \_\____/\____/\_| \_\_| \_| \_/
TACTICAL EXPLOITATION
v5.1 @sec_groundzero
''') + bcolors.ENDC
parser = OptionParser(usage= "usage: sudo %prog [options]",version=version)
parser.add_option("-p", "--packets", action="store", dest="packets", default=20, type=int, help="# of Network Packets to capture" + bcolors.WARNING + " Default: 20" + bcolors.ENDC)
parser.add_option("-x", "--expire", action="store", dest="expire", default=20, type=int,help="Time for packet capture to stop" + bcolors.WARNING + " Default: 20s" + bcolors.ENDC)
parser.add_option("-I", "--interface", action="store", dest="iface", default="eth0",help="Network Interface to use." + bcolors.WARNING + " Default: eth0" + bcolors.ENDC, choices=['eth0', 'eth1', 'wlan0', 'wlan1', 'wlan2', 'at0'])
parser.add_option("-N", "--name", action="store", dest="name", default="WarBerry",help="Hostname to use." + bcolors.WARNING + " Default: Auto" + bcolors.ENDC)
parser.add_option("-i", "--intensity", action="store", dest="intensity", default="-T1", help="Port scan intensity." + bcolors.WARNING + " Default: T1" + bcolors.ENDC,choices=['-T1', '-T2', '-T3', '-T4'])
parser.add_option("-P", "--poison", action="store_false",dest="poison",default=True, help="Turn Poisoning off."+ bcolors.WARNING + " Default: On" + bcolors.ENDC)
parser.add_option("-t", "--time", action="store", dest="time", default=900, type=int, help="Responder Timeout Seconds")
parser.add_option("-Q", "--quick", action="store_true", dest="fast", default=False, help="Scan using threads." + bcolors.WARNING + " Default: Off" + bcolors.ENDC)
parser.add_option("-H", "--hostname", action="store_false", dest="hostname", default= True, help="Do not change WarBerry hostname" + bcolors.WARNING + " Default: Off" + bcolors.ENDC)
parser.add_option("-e", "--enumeration", action="store_true",dest="enum", default=False, help="Disable enumeration mode." + bcolors.WARNING + " Default: Off" + bcolors.ENDC)
parser.add_option("-M", "--malicious", action="store_true", dest="malicious", default=False, help="Enable Malicious only mode" + bcolors.WARNING + " Default: Off" + bcolors.ENDC)
parser.add_option("-B", "--bluetooth", action="store_true", dest="btooth", default=False, help="Enable Bluetooth Scanning" + bcolors.WARNING + " Default: Off" + bcolors.ENDC)
parser.add_option("-W", "--wifi", action="store_true", dest="wifi", default=False, help="Enable WiFi Scanning" + bcolors.WARNING + " Default: Off" + bcolors.ENDC)
parser.add_option("-r", "--recon", action="store_true", dest="reconmode", default=False,help="Enable Recon only mode. " + bcolors.WARNING + " Default: Off" + bcolors.ENDC)
parser.add_option("-C", "--clear", action="store_true", dest="clear", default=False, help="Clear previous output folders in ../Results")
parser.add_option("-m", "--man", action="store_true", dest="manpage", default=False, help="Print WarBerry man pages")
(options, args) = parser.parse_args()
if options.clear == True:
clear_output()
elif options.manpage == True:
subprocess.call('clear', shell=True)
banner_full()
else:
if not os.geteuid() == 0:
print bcolors.FAIL + '*** You are not running as root and some modules will fail ***\nRun again with sudo.' + bcolors.ENDC
sys.exit(-1)
dhcp_check()
if (os.path.isfile('/sys/class/net/' + options.iface + '/carrier') == True):
iface = options.iface
else:
for ifaces in os.listdir("/sys/class/net/"):
if ifaces[0] == "e":
file_iface = open("/sys/class/net/" + ifaces + "/carrier")
if file_iface.readline()[0] == "1":
iface = ifaces
subprocess.call("clear", shell = True)
banner()
host_name = options.name
int_ip = iprecon(iface)
if (int_ip == None):
exit
else:
if options.malicious == True:
netmask = netmask_recon(iface)
with open('../Results/running_status', 'w') as status:
status.write("<root>")
status.write("Entering poisoning mode\n")
poison_time = options.time
poison(iface, poison_time)
status.write("</root>")
else:
netmask = netmask_recon(iface)
CIDR = subnet(int_ip, netmask)
status_str=""
packets = options.packets
expire = options.expire
status_str+=str(sniffer(iface, packets, expire))
status_str +=str(hostnames(int_ip,CIDR))
with open('../Results/running_status', 'w') as status:
status.write(status_str)
if host_name != "WarBerry":
manual_namechange(host_name)
if options.hostname == True and host_name == "WarBerry":
namechange()
if options.reconmode == False:
intensity = options.intensity
status_str=""
if options.fast == False:
status_str +=str(single_port_scanner(CIDR, intensity, iface))
else:
status_str +=str(thread_port_scanner(CIDR, intensity, iface))
if options.enum == False:
status_str +=str(shares_enum(iface))
status_str +=str(smb_users(iface))
status_str += str(webs_prep())
status_str +=str(nfs_enum(iface))
status_str +=str(mysql_enum(iface))
status_str +=str(mssql_enum(iface))
status_str +=str(ftp_enum(iface))
status_str +=str(sip_methods_enum(iface))
status_str +=str(sip_users_enum(iface))
#status_str +=str(zone_transfers(CIDR,iface))
with open('../Results/running_status', 'a') as status:
status.write(status_str)
if options.btooth == True:
bluetooth_enum()
with open('../Results/running_status', 'a') as status:
status.write("Completed bluetooth scan\n")
if options.wifi == True:
wifi_enum()
with open('../Results/running_status', 'a') as status:
status.write("Completed wifi networks scan\n")
print ""
print bcolors.TITLE + "All scripts completed. Check the /Results directory" + bcolors.ENDC
print " "
if options.poison == True:
with open('../Results/running_status', 'a') as status:
status.write("Entering poisoning mode\n")
poison_time = options.time
poison(iface, poison_time)
create_xmls()
encrypt_files()
#Sytem exit due to finish.
print bcolors.TITLE + "Warberry is now finished. The system will now exit.\n" + bcolors.ENDC
print bcolors.TITLE + "Time of execution: " + "--- %s seconds ---\n" % (time.time() - start_time) + bcolors.ENDC
sys.exit(0)
def main():
#Spawn thread for responder
q = Process(target=warberry())
q.start()
q.join()
if __name__ == '__main__':
try:
warberry()
except KeyboardInterrupt:
try:
if os.path.exists("../Results") == False:
subprocess.call("sudo mkdir ../Results", shell = True)
subprocess.call("sudo mkdir ../Results/Responder_logs", shell=True)
subprocess.call("sudo mv ../Tools/Responder/logs/* ../Results/Responder_logs/", shell=True)
p = subprocess.Popen(['ps', '-A'], stdout=subprocess.PIPE)
out, err = p.communicate()
for line in out.splitlines():
if 'python' in line:
pid = int(line.split(None, 1)[0])
os.kill(pid, signal.SIGKILL)
print "Killing threads done"
finally:
subprocess.call("clear", shell=True)
banner_full()