-
Notifications
You must be signed in to change notification settings - Fork 4
/
awacs.py
336 lines (272 loc) · 13.1 KB
/
awacs.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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
#!/usr/bin/python3
#Awacs vulnerability scanner by @R00tendo
import random
from pathlib import Path
import argparse
import time
import sys
import socket
import os
import shutil
from xml.dom import minidom
from termcolor import colored as c
try:
from awacs_core.errors import handler
except:
if os.getuid() != 0:
print("Initialization Error! Tried to resolve issure but root is needed!")
sys.exit()
print("Initialization Error! Can't import awacs_core, trying to automatically fix the issue.")
awacs = input("Path to awacs_core:")
for dire in sys.path:
if "/usr/lib/python" in dire and "dist-packages" in dire:
os.system("cp -r " + awacs + " " + dire.strip())
print("Please restart awacs")
sys.exit()
from awacs_core.scan import s3_bucket_scanner
from awacs_core.scan import nmap
from awacs_core.xml import xml_parser
from awacs_core.conf import read_conf
from awacs_core.genocide_engine import scanner as genocide_engine_scanner
from awacs_core.genocide_engine import api as genocide_engine_api
from awacs_core.loading_screens import scanning
from awacs_core.files import read_file
from awacs_core.exploit_search import searchsploit
from awacs_core.exploit_search import vulners
if "/go/bin" not in os.getenv("PATH"):
print("not")
os.environ["PATH"] += ":" + os.getenv("HOME") + "/go/bin"
print(os.getenv("PATH"))
for needed_program in ["gau", "searchsploit", "nmap"]:
if shutil.which(needed_program) == None:
print(c(f"⦗ERROR⦘ Program not found: {needed_program}", "red"))
sys.exit()
logo = c("""
GGGBBBBBBBBBBBBGG
GGMGGMMM GMMMOMMMG
MPPP GGGGGG
GM GGGG
M GGG
:~. GGHHHH!MMMMMMMMMM GG
:GG! GGGG GMMM G
YGB7 MM
~BGBY .:. GG
.PGGB5.!YB#&&B? ... G
P5BBGGB##&&#BJ~. G*!!G&##B57!. :?5?^:.
.7#&&&&#BB##GPY~.FFGHKPL:JGBBBGGY~ .~YPPP55J?J.
.~JPB&&&&&&&&&&&5JJJYK?^GGEHUFME^7YYJJY^ ^JPPPGGG5YJ7.
YB&&&&&##GPJ7!G&&&GPGGBBGGGJ.KOLBBBBB:J55J. :?PGPPPPGPYJ7.
.!7~:. ~G&&###&&GGGGGG.^FFJ5?????^7. :75GGGP5555YJ?~..
^P#&&&&&H#G4447GGHGHHHHGGG .75GBBGGGGGG5J7^^^^~!^:
:?B&&&&GGGGGGGGG?^.JFF .!5GBBBBBBBBBPJJ^ .:^^.
:JG#&&&&@@@&&&&?^. .!YGBBBBBBBBBBGYJ7.
.!5B&&&&&&@&&&&&&BP7:^YGBBBBBBBBBBBB5JJ^
^?P#&&&&&&@&&&&&&#GPPGGGBBBBBBPJ?! .^JG#&&&&&@@&&&&&#BGPPGGGPJ??: :!5PGB#&&&&&@@&&&&&#BG5??7^^:^~^:. .^7YPGGGGGGGBB#&&&&&&@&&&&&&#BPJ7!^^::. .^?5GGGGGGGGGGGGGGBBB#&&&&&&@@&&&&&&#GY~^
.~?5PGPPPP5PPPPPPPGGB##&@@@@##&&&&&&@@&&&&&&BPJ~.
:~?5PPP555555555PPGB#&&@@@&#GJ^. .~JG#&&&&&&@@&&&&&&#P?.
..!?5PPP555555PPPGB##&@@@&&GY7: .~5B&&&&&&&&&&@@@&P!
.:!7YPPGGGGGGGGGGB#&&@@@&&BY^^. ^?P#&&&&&@@@&#B#G:
.~JPGGGGGGGBBBBB##&@@@@&BJ!^~^:. .~JG#&@@@@@@@&#~
.^75PGGGGGGGGGGB#&&@@@&GY!:. .:^^^::^: :75#&@@@@@@&. .~?5PGGPPPPGGGB#&&@@&#P?^. .:~!!^~ :!75G#GG. .!5PGGGGGBBB##&&@@@!^. ..: ^5B&&&&&@@@&#PJ~:^^:.
.7B&#PJ!:. .:^^^:^^.
:^~!^^~
.:::
AWACS Scanner. CODED BY:@R00tendo """, "cyan") #Scanners class scanners: def s3_buckets(domain, threads): output = "" try: buckets = s3_bucket_scanner.scan(domain, wordlist_path, threads)
output += c("⦗S3 Bucket discovery⦘\n║\n║\n", "cyan")
for bucket in buckets:
output += c("╟╴", "cyan") + bucket.strip() + "\n"
except KeyboardInterrupt:
handler.throw.keyboardinterrupt()
return output
def vuln_search(target):
output = ""
try:
output += c("⦗Vulnerabilities⦘\n║\n║\n", "cyan")
scan_output = xml_parser.parse(f"{Path.home()}/.awacs/loot/{target}_nmap.xml")
for tech in scan_output:
exploits_searchsploit = searchsploit.search(tech['name'], tech['version'])
for exploit in exploits_searchsploit:
output += f"{c('╟╴', 'cyan')}" + c(f"Affected: {exploit['name']} Exploit path: {exploit['exploit']} Source: Searchsploit\n", "yellow")
if hasattr(session, "vulners_api"):
try:
exploits_vulners = vulners.search(tech['name'], tech['version'], session.vulners_api)
for exploit in exploits_vulners:
output += f"{c('╟╴', 'cyan')}" + c(f"Affected: {tech['name']} {tech['version']} Exploit: {exploit['vhref']} cvss: {exploit['cvss']['score']}\n", "yellow")
except Exception as e:
handler.throw.vulners(e)
else:
print(c("⦗VULNERS_API⦘ Api token not found, ignoring", "grey"))
return output
except KeyboardInterrupt:
handler.throw.keyboardinterrupt()
def genocide_engine(target, char):
output = ""
try:
scanning.start_loadingscreen(target, char)
lines = genocide_engine_api.scan(target, wordlist_path).split("\n")
scanning.stop_loadingscreen()
output += c("⦗Genocide_engine output⦘\n║\n║\n", "cyan")
for line in lines:
if len(line) > 0:
output += f"{c('╟╴','cyan')}{c(line, 'yellow')}\n"
return output
except KeyboardInterrupt:
handler.throw.keyboardinterrupt()
def nmap(target, flags, char):
output = ""
try:
scanning.start_loadingscreen(target, char)
nmap.scan(target, flags)
scanning.stop_loadingscreen()
output += c("⦗Nmap⦘\n║\n║\n", "cyan")
nmap_scan = minidom.parse(f"{Path.home()}/.awacs/loot/{target}_nmap.xml")
ports = nmap_scan.getElementsByTagName('port')
services = nmap_scan.getElementsByTagName('service')
for i,port in enumerate(ports):
if port.hasAttribute('portid'):
try:
service = services[i]
if port.hasAttribute('portid') and service.hasAttribute('name'):
port_template = c(port.attributes['portid'].value + " " + service.attributes['name'].value,'yellow')
except:
port_template = c(port.attributes['portid'].value + " UKNOWN", 'yellow')
output += f"{c('╟╴Open port:','cyan')}{port_template}\n"
return output
except KeyboardInterrupt:
handler.throw.keyboardinterrupt()
def setup():
handler.throw.setup()
os.system("apt update")
os.system("apt install -y golang")
os.system("apt install -y libmariadb3 libmariadb-dev")
os.system("apt install -y python3")
os.system("apt install -y python3-pip")
os.system("apt install -y searchsploit")
os.system("apt install -y nmap")
os.system("go install github.com/lc/gau/v2/cmd/gau@latest")
os.system("export PATH=$PATH:$HOME/go/bin")
os.chdir(Path.home())
os.mkdir(".awacs")
os.chdir(".awacs")
os.mkdir("loot")
open("configuration.conf", "w").write("")
print(c(f"⦗SUCCESS ✈⦘ Awacs scanner is now successfully installed and set up at {Path.home()}/.awacs. Please run awacs again.", "cyan"))
sys.exit()
def check_setup():
good_setup = True
if not os.path.isdir(f"{Path.home()}/.awacs"):
good_setup = False
if not os.path.isdir(f"{Path.home()}/.awacs/loot"):
good_setup = False
if not os.path.isfile(f"{Path.home()}/.awacs/configuration.conf"):
good_setup = False
if not good_setup:
setup()
def after_scans():
os.system("clear")
print(logo)
#Scan types
def stealth_flight():
cur_output = ""
threads = 10
for target in session.target:
cur_output += c(f"⦗SCAN RESULTS FOR {target}⦘\n", "cyan")
#Custom module (non intrusive)
scanning.start_loadingscreen(target, "")
lines = genocide_engine_scanner.url_finder(target).split("\n")
if session.company != "NULL":
cur_output += scanners.s3_buckets(session.company, threads)
scanning.stop_loadingscreen()
after_scans()
cur_output += c("⦗Genocide_engine output⦘\n║\n║\n", "cyan")
for line in lines:
if len(line) > 0:
cur_output += f"{c('╟╴','cyan')}{c(line, 'yellow')}\n"
output = scanners.nmap(target, "-sS -F -T2", "")
cur_output += output + "\n"
print(cur_output)
def vuln_scan():
cur_output = ""
for target in session.target:
cur_output += c(f"⦗SCAN RESULTS FOR {target}⦘\n", "cyan")
if not session.flags:
session.flags = ""
nmap_output = scanners.nmap(target, f"-Pn -sV -A {session.flags}", "◡")
vuln_output = scanners.vuln_search(target)
after_scans()
cur_output += nmap_output + "\n"
cur_output += vuln_output + "\n"
print(cur_output)
def battering_ram():
cur_output = ""
threads = 50 #Amount of threads used to scan for s3 buckets
for target in session.target:
cur_output += c(f"⦗SCAN RESULTS FOR {target}⦘\n", "cyan")
if not session.flags:
session.flags = ""
genocide_output = scanners.genocide_engine(target, "💣")
nmap_output = scanners.nmap(target, f"-T4 -p- -sV -A {session.flags}", "💣")
vuln_output = scanners.vuln_search(target)
if session.company != "NULL":
s3_output = scanners.s3_buckets(session.company, threads)
after_scans()
cur_output += genocide_output + "\n"
cur_output += nmap_output + "\n"
cur_output += vuln_output + "\n"
if session.company != "NULL":
cur_output += s3_output + "\n"
print(cur_output)
#Parse arguments
def get_args():
parser = argparse.ArgumentParser()
parser.add_argument("-t", "--target", help="Targets/target to scan in one of these formats: divided by \",\" or file of targets.", required=True)
parser.add_argument("-f", "--flags", help="Nmap flags (\"-sV -A\")")#, required=True)
parser.add_argument("--st", "--scan-type", help="stealth_flight (OSINT), vuln_scan, battering_ram (everything + bruteforce) (Read more about scans from github)", default="vuln_scan")
parser.add_argument("-c", "--configuration", help="Configuration file for awacs scanner (Syntax in github).", default=f"{Path.home()}/.awacs/configuration.conf")
parser.add_argument("--company", help="Name of the company being scanned. This will be used for s3 bucket scanning (default is \"NULL\" aka it's not a company)", default="NULL")
args = parser.parse_args()
return args
def host_up(targets):
for target in targets:
try:
socket.gethostbyname(target)
except:
handler.throw.target_doesnt_exist()
#MAIN
def main(args):
global session, wordlist_path
#Path to the python library eg. /usr/lib/python3/awacs_core
wordlist_path = nmap.__file__.split("/scan/nmap.py")[0]
#Main "database" for the target and configuration
class session:
None
#Prerequisities
if "," not in args.target:
if os.path.isfile(args.target):
session.target = []
for target in read_file.read(args.target):
session.target.append(target.strip())
else:
session.target = [args.target]
else:
session.target = args.target.split(",")
session.configuration = args.configuration
session.flags = args.flags
session.scan_type = args.st
session.company = args.company
session = read_conf.read(session)
host_up(session.target)
if session.scan_type.lower() == "stealth_flight": #Done
stealth_flight()
elif session.scan_type.lower() == "vuln_scan":
vuln_scan()
elif session.scan_type.lower() == "battering_ram":
battering_ram()
else:
handler.throw.invalid_scan_type()
if __name__ == "__main__":
#Very cool logo
print(logo)
check_setup()
args = get_args()
main(args)