forked from hahwul/a2sv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
a2sv.py
executable file
·428 lines (408 loc) · 17.7 KB
/
a2sv.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
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
#==============================================
# A2SV(Auto Scanning to SSL Vulnerability |
# by HaHwul(www.hahwul.com) |
# https://github.com/hahwul/a2sv |
#==============================================
import os
import sys
import argparse
import socket
import datetime
from urlparse import urlparse
sys.path.append(os.path.dirname( os.path.abspath( __file__ ))+"/module")
from M_ccsinjection import *
from M_heartbleed import *
from M_poodle import *
from M_freak import *
from M_logjam import *
from M_drown import *
from M_crime import *
from M_anonymous import *
from C_display import *
#==============================================
displayMode=0
targetMode=0
output_ck=0
output_path="./a2sv_output.txt"
targetfileList = []
# Version
myPath=os.path.dirname( os.path.abspath( __file__ ))
vfp = open(myPath+"/version","r") #Version File Pointer
a2sv_version = vfp.read()
a2sv_version = a2sv_version.rstrip()
#==============================================
global targetIP
global port
global ccs_result
global heartbleed_result
global poodle_result
global freak_result
global logjam_result
global drown_result
global crime_result
global anonymous_result
# Set Result Val
# -1: Not Scan
# 0x00: Not Vuln
# 0x01: Vuln
ccs_result = "-1"
heartbleed_result = "-1"
poodle_result = "-1"
freak_result = "-1"
logjam_result = "-1"
drown_result = "-1"
crime_result = "-1"
anonymous_result = "-1"
#===========================
RED = '\033[91m'
GREEN = '\033[92m'
YELLOW = '\033[93m'
BLUE = '\033[94m'
PURPLE = '\033[95m'
VIOLET = '\033[0;35m'
END = '\033[0m'
## Report Table
class TablePrinter(object):
"Print a list of dicts as a table"
def __init__(self, fmt, sep=' ', ul=None):
"""
@param fmt: list of tuple(heading, key, width)
heading: str, column label
key: dictionary key to value to print
width: int, column width in chars
@param sep: string, separation between columns
@param ul: string, character to underline column label, or None for no underlining
"""
super(TablePrinter,self).__init__()
self.fmt = str(sep).join('{lb}{0}:{1}{rb}'.format(key, width, lb='{', rb='}') for heading,key,width in fmt)
self.head = {key:heading for heading,key,width in fmt}
self.ul = {key:str(ul)*width for heading,key,width in fmt} if ul else None
self.width = {key:width for heading,key,width in fmt}
def row(self, data):
return self.fmt.format(**{ k:str(data.get(k,''))[:w] for k,w in self.width.iteritems() })
def __call__(self, dataList):
_r = self.row
res = [_r(data) for data in dataList]
res.insert(0, _r(self.head))
if self.ul:
res.insert(1, _r(self.ul))
return '\n'.join(res)
########################
def mainScreen():
os.system('cls' if os.name=='nt' else 'clear')
showDisplay(displayMode," A_A")
showDisplay(displayMode," (-.-)")
showDisplay(displayMode," / h ")
showDisplay(displayMode," | | __ ")
showDisplay(displayMode," | || | | t__ ")
showDisplay(displayMode," t_|| /_/ ")
showDisplay(displayMode," █████╗ ██████╗ ███████╗██╗ ██╗ ")
showDisplay(displayMode," ██╔══██╗╚════██╗██╔════╝██║ ██║ ")
showDisplay(displayMode," ███████║ █████╔╝███████╗██║ ██║ ")
showDisplay(displayMode," ██╔══██║██╔═══╝ ╚════██║╚██╗ ██╔╝")
showDisplay(displayMode," ██║ ██║███████╗███████║ ╚████╔╝ ")
showDisplay(displayMode," ╚═╝ ╚═╝╚══════╝╚══════╝ ╚═══╝ ")
showDisplay(displayMode,BLUE+" [Auto Scanning to SSL Vulnerability "+a2sv_version+"]"+END)
showDisplay(displayMode,VIOLET+" by HaHwul (www.hahwul.com)"+END)
showDisplay(displayMode,"________________________________________________________________________")
def runScan(s_type):
global ccs_result
global heartbleed_result
global poodle_result
global freak_result
global logjam_result
global drown_result
global crime_result
global anonymous_result
print " "
# SSL Check Logic ---------------------------
showDisplay(displayMode,GREEN+"[INF] Check the SSL.."+END)
result = subprocess.Popen(['timeout','4','openssl','s_client','-connect',targetIP+":"+str(port)], stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0]
if "Connection refused" in result:
showDisplay(displayMode,RED+"[RES] This target does not support SSL.."+END)
# ------------------------------------------------------
else:
showDisplay(displayMode,GREEN+"[RES] This target supports SSL.."+END)
if s_type == "anonymous":
showDisplay(displayMode,GREEN+"[INF] Scan Anonymous Cipher.."+END)
anonymous_result = m_anonymous_run(targetIP,port,displayMode)
showDisplay(displayMode,GREEN+"[RES] Anonymous Cipher :: "+anonymous_result+END)
elif s_type == "crime":
showDisplay(displayMode,GREEN+"[INF] Scan CRIME(SPDY).."+END)
crime_result = m_crime_run(targetIP,port,displayMode)
showDisplay(displayMode,GREEN+"[RES] CRIME(SPDY) :: "+crime_result+END)
elif s_type == "heart":
showDisplay(displayMode,GREEN+"[INF] Scan HeartBleed.."+END)
heartbleed_result = m_heartbleed_run(targetIP,port,displayMode)
showDisplay(displayMode,GREEN+"[RES] HeartBleed :: "+heartbleed_result+END)
elif s_type == "ccs":
showDisplay(displayMode,GREEN+"[INF] Scan CCS Injection.."+END)
ccs_result = m_ccsinjection_run(targetIP,port,displayMode)
showDisplay(displayMode,GREEN+"[RES] CCS Injection :: "+ccs_result+END)
elif s_type == "poodle":
showDisplay(displayMode,GREEN+"[INF] Scan SSLv3 POODLE.."+END)
poodle_result = m_poodle_run(targetIP,port,displayMode)
showDisplay(displayMode,GREEN+"[RES] SSLv3 POODLE :: "+poodle_result+END)
elif s_type == "freak":
showDisplay(displayMode,GREEN+"[INF] Scan OpenSSL FREAK.."+END)
freak_result = m_freak_run(targetIP,port,displayMode)
showDisplay(displayMode,GREEN+"[RES] OpenSSL FREAK :: "+freak_result+END)
elif s_type == "logjam":
showDisplay(displayMode,GREEN+"[INF] Scan OpenSSL LOGJAM.."+END)
logjam_result = m_logjam_run(targetIP,port,displayMode)
showDisplay(displayMode,GREEN+"[RES] OpenSSL LOGJAM :: "+logjam_result+END)
elif s_type == "drown":
showDisplay(displayMode,GREEN+"[INF] Scan SSLv2 DROWN.."+END)
logjam_result = m_drown_run(targetIP,port,displayMode)
showDisplay(displayMode,GREEN+"[RES] SSLv2 DROWN :: "+drown_result+END)
else:
showDisplay(displayMode,GREEN+"[INF] Scan Anonymous Cipher.."+END)
anonymous_result = m_anonymous_run(targetIP,port,displayMode)
showDisplay(displayMode,GREEN+"[INF] Scan CRIME(SPDY).."+END)
crime_result = m_crime_run(targetIP,port,displayMode)
showDisplay(displayMode,GREEN+"[INF] Scan CCS Injection.."+END)
ccs_result = m_ccsinjection_run(targetIP,port,displayMode)
showDisplay(displayMode,GREEN+"[INF] Scan HeartBleed.."+END)
heartbleed_result = m_heartbleed_run(targetIP,port,displayMode)
showDisplay(displayMode,GREEN+"[INF] Scan SSLv3 POODLE.."+END)
poodle_result = m_poodle_run(targetIP,port,displayMode)
showDisplay(displayMode,GREEN+"[INF] Scan OpenSSL FREAK.."+END)
freak_result = m_freak_run(targetIP,port,displayMode)
showDisplay(displayMode,GREEN+"[INF] Scan OpenSSL LOGJAM.."+END)
logjam_result = m_logjam_run(targetIP,port,displayMode)
showDisplay(displayMode,GREEN+"[INF] Scan SSLv2 DROWN.."+END)
drown_result = m_drown_run(targetIP,port,displayMode)
showDisplay(displayMode,GREEN+"[RES] Finish scan all vulnerability.."+END)
def outVersion():
print "A2SV v"+a2sv_version
def updateVersion():
print GREEN+"[INF] Update A2SV"+END
print GREEN+"[INF] This A2SV version is .. v"+a2sv_version+END
os.chdir(os.path.dirname( os.path.abspath( __file__ )))
os.system("git reset --hard HEAD")
os.system("git pull -v")
vfp = open(myPath+"/version","r") #Version File Pointer
print RED+"[FIN] Updated A2SV"+END
def outReport(o_ck,o_path,tmode):
global ccs_result
global heartbleed_result
global poodle_result
global freak_result
global logjam_result
global drown_result
global crime_result
global anonymous_result
if anonymous_result == "0x01":
anonymous_result = "Vulnerable!"
elif anonymous_result == "0x00":
anonymous_result = "Not Vulnerable."
elif anonymous_result == "0x02":
anonymous_result = "Exception."
else:
anonymous_result = "Not Scan."
if crime_result == "0x01":
crime_result = "Vulnerable!"
elif crime_result == "0x00":
crime_result = "Not Vulnerable."
elif crime_result == "0x02":
crime_result = "Exception."
else:
crime_result = "Not Scan."
if ccs_result == "0x01":
ccs_result = "Vulnerable!"
elif ccs_result == "0x00":
ccs_result = "Not Vulnerable."
elif ccs_result == "0x02":
ccs_result = "Exception."
else:
ccs_result = "Not Scan."
if heartbleed_result == "0x01":
heartbleed_result = "Vulnerable!"
elif heartbleed_result == "0x00":
heartbleed_result = "Not Vulnerable."
elif heartbleed_result == "0x02":
heartbleed_result = "Exception"
else:
heartbleed_result = "Not Scan."
if poodle_result == "0x01":
poodle_result = "Vulnerable!"
elif poodle_result == "0x00":
poodle_result = "Not Vulnerable."
elif poodle_result == "0x02":
poodle_result = "Exception"
else:
poodle_result = "Not Scan."
if freak_result == "0x01":
freak_result = "Vulnerable!"
elif freak_result == "0x00":
freak_result = "Not Vulnerable."
elif freak_result == "0x02":
freak_result = "Exception"
else:
freak_result = "Not Scan."
if logjam_result == "0x01":
logjam_result = "Vulnerable!"
elif logjam_result == "0x00":
logjam_result = "Not Vulnerable."
elif logjam_result == "0x02":
logjam_result = "Exception"
else:
logjam_result = "Not Scan."
if drown_result == "0x01":
drown_result = "Vulnerable!"
elif drown_result == "0x00":
drown_result = "Not Vulnerable."
elif drown_result == "0x02":
drown_result = "Exception"
else:
drown_result = "Not Scan."
#----------- Template -----------
# if logjam_result == "0x01":
# logjam_result = "Vulnerable!"
# elif logjam_result == "0x00":
# logjam_result = "Not Vulnerable."
# else:
# logjam_result = "Not Scan."
#----------- -------- -----------
data = [
{'v_vuln':'Anonymous Cipher', 'v_cve':'CVE-2007-1858', 'cvss':'AV:N/AC:H/Au:N/C:P/I:N/A:N', 'v_state':anonymous_result},
{'v_vuln':'CRIME(SPDY)', 'v_cve':'CVE-2012-4929', 'cvss':'AV:N/AC:H/Au:N/C:P/I:N/A:N', 'v_state':crime_result},
{'v_vuln':'HeartBleed', 'v_cve':'CVE-2014-0160', 'cvss':'AV:N/AC:L/Au:N/C:P/I:N/A:N', 'v_state':heartbleed_result},
{'v_vuln':'CCS Injection', 'v_cve':'CVE-2014-0224', 'cvss':'AV:N/AC:M/Au:N/C:P/I:P/A:P', 'v_state':ccs_result},
{'v_vuln':'SSLv3 POODLE', 'v_cve':'CVE-2014-3566', 'cvss':'AV:N/AC:M/Au:N/C:P/I:N/A:N', 'v_state':poodle_result},
{'v_vuln':'OpenSSL FREAK', 'v_cve':'CVE-2015-0204', 'cvss':'AV:N/AC:M/Au:N/C:N/I:P/A:N', 'v_state':freak_result},
{'v_vuln':'OpenSSL LOGJAM', 'v_cve':'CVE-2015-4000', 'cvss':'AV:N/AC:M/Au:N/C:N/I:P/A:N', 'v_state':logjam_result},
{'v_vuln':'SSLv2 DROWN', 'v_cve':'CVE-2016-0800', 'cvss':'AV:N/AC:M/Au:N/C:P/I:N/A:N', 'v_state':drown_result}
]
fmt = [
('Vulnerability', 'v_vuln', 16),
('CVE', 'v_cve', 13),
('CVSS v2 Base Score', 'cvss', 26),
('State', 'v_state', 15)
]
if o_ck == 1:
print "The result is in \""+str(o_path)+"\"."
if tmode == 1:
of = open(str(o_path),'a')
of.write(" [TARGET]: "+targetIP+"\r\n")
of.write(" [PORT]: "+str(port)+"\r\n")
of.write(" [SCAN TIME]: "+str(datetime.datetime.now())+"\r\n")
of.write(" [VULNERABILITY]"+"\r\n")
of.write(TablePrinter(fmt, ul='=')(data))
of.write("\r\n")
else:
of = open(str(o_path),'w')
of.write(" [TARGET]: "+targetIP+"\r\n")
of.write(" [PORT]: "+str(port)+"\r\n")
of.write(" [SCAN TIME]: "+str(datetime.datetime.now())+"\r\n")
of.write(" [VULNERABILITY]"+"\r\n")
of.write(TablePrinter(fmt, ul='=')(data))
of.write("\r\n")
else:
print BLUE+" [TARGET]: "+targetIP+END
print BLUE+" [PORT]: "+str(port)+END
print BLUE+" [SCAN TIME]: "+str(datetime.datetime.now())+END
print RED+" [VULNERABILITY]"+END
print( TablePrinter(fmt, ul='=')(data) )
###MAIN##
parser = argparse.ArgumentParser("a2sv",formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument("-t","--target", help="Target URL and IP Address\n > e.g -t 127.0.0.1")
parser.add_argument("-tf","--targetfile", help="Target file(list) URL and IP Address\n > e.g -tf ./target.list")
parser.add_argument("-p","--port", help="Custom Port / Default: 443\n > e.g -p 8080")
parser.add_argument("-m","--module", help="Check SSL Vuln with one module\n[anonymous]: Anonymous Cipher\n[crime]: Crime(SPDY)\n[heart]: HeartBleed\n[ccs]: CCS Injection\n[poodle]: SSLv3 POODLE\n[freak]: OpenSSL FREAK\n[logjam]: OpenSSL LOGJAM\n[drown]: SSLv2 DROWN")
parser.add_argument("-d","--display", help="Display output\n[Y,y] Show output\n[N,n] Hide output")
parser.add_argument("-o","--out", help="Result write to file\n > e.g -o /home/yourdir/result.txt")
parser.add_argument("-u","--update", help="Update A2SV (GIT)",action='store_true')
parser.add_argument("-v","--version", help="Show Version",action='store_true')
args = parser.parse_args()
if args.version:
outVersion()
exit()
if args.update:
updateVersion()
exit()
if args.display:
disoption = args.display
if((disoption == "n") or (disoption == "N")):
print "Running a2sv sillent mode"
displayMode = 1
else:
displayMode = 0
if args.target:
target = args.target
showDisplay(displayMode,BLUE+"[SET] target => "+args.target+END)
targetIP = socket.gethostbyname(target)
showDisplay(displayMode,BLUE+"[SET] IP Address => "+targetIP+END)
elif args.targetfile:
f = open(args.targetfile,"r")
showDisplay(displayMode,BLUE+"[SET] target => "+args.targetfile+END)
showDisplay(displayMode,BLUE+"[SET] IP Address list"+END)
line = f.readline()
while line:
targetfileList.append(socket.gethostbyname(line.rstrip('\n')))
showDisplay(displayMode,BLUE+" => "+str(targetfileList[-1:])+END)
line = f.readline()
targetMode = 1
displayMode = 1
print "Running a2sv sillent mode[file list default]"
f.close()
else:
mainScreen()
showDisplay(displayMode,"Please Input Target Argument / -h --help")
exit()
if args.port:
port = int(args.port)
showDisplay(displayMode,BLUE+"[SET] target port => "+args.port+END)
else:
port = 443
showDisplay(displayMode,BLUE+"[SET] target port => 443"+END)
if args.module:
checkVun = args.module
ModuleName = args.module
if ModuleName == "ccs":
ModuleName = "CCS Injection"
elif ModuleName == "heart":
ModuleName = "HeartBleed"
elif ModuleName == "poodle":
ModuleName = "SSLv3 POODLE Attack"
elif ModuleName == "freak":
ModuleName = "OpenSSL FREAK Attack"
elif ModuleName == "logjam":
ModuleName = "OpenSSL LOGJAM Attack"
elif ModuleName == "drown":
ModuleName = "SSLv2 DROWN Attack"
elif ModuleName == "crime":
ModuleName = "CRIME(SPDY)"
elif ModuleName == "anonymous":
ModuleName = "Anonymous Cipher Suite"
showDisplay(displayMode,BLUE+"[SET] include => "+ModuleName+" Module"+END)
else:
checkVun = "all"
showDisplay(displayMode,BLUE+"[SET] include => All Module"+END)
if args.out:
output_path = args.out
output_ck = 1
else:
output_ck = 0
if displayMode == 0:
mainScreen()
if targetMode == 1:
i=0
imax = len(targetfileList)
print "_________________________________________________________________________"
print " [A2SV REPORT] "
while(i<imax):
targetIP = targetfileList.pop()
runScan(checkVun)
outReport(output_ck,output_path,targetMode)
i+=1
print "_________________________________________________________________________"
else:
runScan(checkVun)
print "_________________________________________________________________________"
print " [A2SV REPORT] "
outReport(output_ck,output_path,targetMode)
print "_________________________________________________________________________"
showDisplay(displayMode,RED+"[FIN] Scan Finish!"+END)