-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmet.py
More file actions
196 lines (153 loc) · 6.03 KB
/
met.py
File metadata and controls
196 lines (153 loc) · 6.03 KB
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
#!/bin/python3
import argparse
import subprocess
import ast
parser = argparse.ArgumentParser(description = "This is a Machine Exploitation Tool which will tell you the exploit you need to run in order to gain access to the machine, if it has an exploit.")
parser.add_argument("-i", metavar="",help="Provide an IP", type=str)
args = parser.parse_args()
ip = args.i
result = ""
ports = []
service = []
ps = {}
w = ""
v = ""
r = ""
s = ""
if(ip == None):
print("Use this tool with an option. Use -h or --help for help.")
elif(ip != None):
octet = ip.split(".")
for i in range(0, len(octet)):
if(not(octet[i].isdigit()) or int(octet[i]) < 0 or int(octet[i]) > 255 or len(octet) != 4):
print("Provide a valid IP address.")
break
subprocess.call(['bash', './cleanup.sh'])
subprocess.call(['bash', './ports.sh', ip])
with open('Text/ports') as file:
for line in file:
if(line[0].isdigit() and "/" in line):
line = line.split()
s += line[0].split("/")[0] + ","
s = s[0:-1]
subprocess.call(['bash', './nmap.sh', ip, s])
output = subprocess.run(['python3', 'ver.py'], text=True, capture_output=True)
ps = output.stdout.strip()
ps = ast.literal_eval(ps)
ports = list(ps.keys())
service = list(ps.values())
print("Ports open on this machine -")
print(ps)
print("Nmap result has been saved.")
print("---------------------------------------------------------------------------------------------------------------------------------")
if 'http' in service or 'https' in service:
print("Run ffuf ?")
a = input()
with open('Text/ffuf', 'w') as file:
file.write("")
if(a == "Y" or a == "y" or a == "yes" or a == "Yes" or a == "YES"):
for key, value in ps.items():
if("http" in value or "https" in value):
if("https" in value):
subprocess.call(['bash', './ffuf.sh', ip, key, "https"])
else:
subprocess.call(['bash', './ffuf.sh', ip, key, "http"])
with open('Text/ffuf') as f:
r += "\nPort " + key + " (" + value + ") -\n"
for line in f:
if "Status" in line and "#" not in line:
r += line
r = r.strip()
print(r)
with open("Text/ffuf", 'w') as file:
file.write(r)
subprocess.call(['python3', 'curl.py', ip, str(ps)])
print("---------------------------------------------------------------------------------------------------------------------------------")
if '21' in ports:
print("FTP -")
subprocess.call(['bash', './ftp.sh', ip])
with open('Text/ftp') as f:
for line in f:
if "incorrect" in line:
print("Anonymous Login Failed.")
print("---------------------------------------------------------------------------------------------------------------------------------")
if '139' in ports or '445' in ports:
with open('Text/inputmsf', 'w') as f:
f.write("""use auxiliary/scanner/smb/smb_version
set RHOSTS """)
f.write(ip)
f.write("\nrun")
with open('Text/inputsmb', 'w') as f:
f.write("\n")
subprocess.call(['bash', './smb.sh', ip])
print("smbclient -")
with open("Text/smb") as f:
for line in f:
if "Anonymous" in line:
print(line)
if "Sharename" in line:
print(line, end='')
for line in f:
print(line, end='')
print("---------------------------------------------------------------------------------------------------------------------------------")
print("msfconsole smb_version -")
with open("Text/smbversion") as f:
for line in f:
if ip+":139" in line:
print(line, end='')
for line in f:
if "stty" in line:
break
print(line, end='')
print("---------------------------------------------------------------------------------------------------------------------------------")
if '2049' in ports:
print("NFS -")
subprocess.call(['bash', './nfs.sh', ip])
with open('Text/nfs') as f:
for line in f:
if "Export" not in line and line.strip() != "":
w = line.split()
w = w[0]
print("NFS Share present so it is extracted, check /mnt/vms.")
subprocess.call(['bash', './nfs2.sh', ip, w])
print("---------------------------------------------------------------------------------------------------------------------------------")
if '53' in ports:
print("DNSRecon -")
subprocess.call(['bash', './dns.sh', ip])
print("---------------------------------------------------------------------------------------------------------------------------------")
if 'ssh' in ps.values() or 'smtp' in ps.values() or 'pop3' in ps.values() or 'ftp' in ps.values():
print("Use Hydra to bruteforce ? If yes provide username and port separated by a space, or say no(n).")
a = input()
if(a != "N" and a != "n" and a != "no" and a != "No" and a != "NO"):
u, p = a.split()
s = ps[p]
subprocess.call(['bash', './hydra.sh', ip, u, p, s])
with open('Text/hydra') as f:
for line in f:
if "host" in line:
print(line, end='')
for line in f:
if "github" not in line:
print(line, end='')
print("---------------------------------------------------------------------------------------------------------------------------------")
subprocess.call(['python3', 'info.py', ip, str(ps)])
with open('Text/info') as f:
for line in f:
v += line + " "
with open('Text/inputexploit', 'w') as file:
file.write("search " + v)
if(len(v.split()) > 1):
subprocess.call(['bash', './exploit.sh', ip])
print("Exploits -")
with open("Text/exploit") as f:
for line in f:
if "Matching Modules" in line:
print(line, end='')
for line in f:
if "stty" in line:
break
if "For example" in line:
break
print(line, end='')
with open("Text/results", 'w') as f:
f.write("")