forked from fnmsd/awvs_script_decode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSSL_Audit.script
More file actions
220 lines (198 loc) · 7.34 KB
/
Copy pathSSL_Audit.script
File metadata and controls
220 lines (198 loc) · 7.34 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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#include classSSL.inc;
#include reporting_helpers.inc;
#noretest;
var sslKBase = "";
var validityLookaheadDays = 30;
var arrayOfPorts = [];
if (scanURL.scheme == 'https')
{
if (scanURL.port && !isNaN(scanURL.port)) arrayOfPorts.push(scanURL.port)
else arrayOfPorts.push(443);
}
function debug(str)
{
//Trace(str);
}
function getCipherStrength(cipher)
{
if((cipher == "") || (cipher== null))
return("Error");
var strength = "Uncategorised strength";
if(cipher.match(/Symmetric encryption method: None/))
strength = "Null strength";
else
if(cipher.match(/Symmetric encryption method: AES/))
strength = "High strength";
else
{
var match = cipher.match(/Symmetric encryption method: [^,]+\(([0-9]+)\)/);
if(match)
{
if(match[1] == 0)
strength = "Null strength";
else
if(match[1] <= 56)
strength = "Low strength";
else
if(match[1] <= 112)
strength = "Medium strength";
else
strength = "High strength";
}
else
strength = "Max strength";
}
return(strength);
}
var arrayReportedCertificates = new Array();
function checkCertForExpiration(cert, strProtocolVersion)
{
for (var i = 0; i < arrayReportedCertificates.length; i++)
{
if (arrayReportedCertificates[i] == cert.serialNumber)
return;
}
if(cert.boolNotValidYet)
{
arrayReportedCertificates.push(cert.serialNumber);
ReportItem("SSL_certificate_validity.xml", "The SSL certificate (serial: "
+ cert.serialNumber
//+ ", protocol: "
//+ strProtocolVersion
+ ") is not valid yet.[break] The certificate validity period is between [bold]"
+ cert.valabilityStart
+ "[/bold] and [bold]"
+ cert.valabilityEnd
+ "[/bold]");
}
else if(cert.boolExpired)
{
arrayReportedCertificates.push(cert.serialNumber);
ReportItem("SSL_certificate_validity.xml", "The SSL certificate (serial: "
+ cert.serialNumber
//+ ", protocol: "
//+ strProtocolVersion
+ ") is expired.[break] The certificate validity period is between [bold]"
+ cert.valabilityStart
+ "[/bold] and [bold]"
+ cert.valabilityEnd
+ "[/bold]");
}
else if(cert.intExpireInXDays < validityLookaheadDays)
{
arrayReportedCertificates.push(cert.serialNumber);
ReportItem("SSL_certificate_about_to_expire.xml", "The SSL certificate (serial: "
+ cert.serialNumber
//+ ", protocol: "
//+ strProtocolVersion
+ ")is about to expire in less than [bold]"
+ cert.intExpireInXDays
+ "[/bold] days. [break] The certificate validity period is between [bold]"
+ cert.valabilityStart
+ "[/bold] and [bold]"
+ cert.valabilityEnd
+ "[/bold]");
}
}
var reportedInvalidCommonName = false;
if (arrayOfPorts.length >= 1)
for(var portIndex in arrayOfPorts)
{
var ssl = new classSSL(ScanHost);
var sslKBase = "";
arrayReportedCertificates = new Array();
var arrayOfProtocols = new Array("SSL2", "SSL3", "TLS1");
//var arrayOfProtocols = new Array("SSL2");
for(p in arrayOfProtocols)
{
var strProtocol = arrayOfProtocols[p];
debug("Trying: " + strProtocol);
if(ssl.getCapabilities(arrayOfPorts[portIndex], strProtocol))
{
debug(strProtocol + " on port " + arrayOfPorts[portIndex]);
if(strProtocol == "SSL2")
ReportItem("SSLv2.xml", "The SSL server (port: " + arrayOfPorts[portIndex] + ") encrypts traffic using an old deprecated protocol (SSL 2.0) with known weaknesses.");
if(strProtocol == "SSL3")
ReportItem("SSLv3.xml", "The SSL server (port: " + arrayOfPorts[portIndex] + ") encrypts traffic using SSLv3.0.");
var ciphersInfo = "";
var lowStrengthCiphers = "";
var exportCiphers = "";
var rc4Ciphers = "";
for(var cipherIndex in ssl.sslInfo.ciphers)
{
var strength = getCipherStrength(ssl.ciphersDescription[ssl.sslInfo.ciphers[cipherIndex]]);
ciphersInfo += " - " + ssl.sslInfo.ciphers[cipherIndex] + '(' + ssl.ciphersDescription[ssl.sslInfo.ciphers[cipherIndex]] +') - ' + strength + ' [break]';
if(strength.match(/null/i) || strength.match(/low/i)) // low strength alert
lowStrengthCiphers += ssl.sslInfo.ciphers[cipherIndex] + " - " + strength + "[break]";
if (ssl.sslInfo.ciphers[cipherIndex].indexOf("EXPORT") != -1) {
exportCiphers += ssl.sslInfo.ciphers[cipherIndex] + " - " + strength + "[break]";
}
if (ssl.sslInfo.ciphers[cipherIndex].indexOf("RC4") != -1) {
rc4Ciphers += ssl.sslInfo.ciphers[cipherIndex] + " - " + strength + "[break]";
}
}
if (ciphersInfo != "")
{
ciphersInfo = "Ciphers suported:[break]" + ciphersInfo + "[break]";
}
strVersion = "SSL 2.0";
if(arrayOfProtocols == "SSL3") strVersion = "SSL 3.0";
if(arrayOfProtocols == "TLS1") strVersion = "TLS 1.0";
sslKBase += "[subtitle]A " + strProtocol + " server is running on TCP port "
+ arrayOfPorts[portIndex] + ".[/subtitle][break][break]"
+ "[li][subtitle]SSL server information:[/subtitle]"
//+ "[li]Version: " + arrayOfProtocols + "[\li]"
+ ciphersInfo + "[break]";
for(var i = 0; i < ssl.sslInfo.certificates.length; i++)
{
sslKBase += "[li][bold]Certificate";
var x = i + 1;
if (ssl.sslInfo.certificates.length > 1) sslKBase += " " + x;
sslKBase += ":[/bold][break]";
sslKBase += ssl.sslInfo.certificates[i].prettyPrint();
sslKBase += "[/li]"
checkCertForExpiration(ssl.sslInfo.certificates[i], strProtocol);
/*
var r = ssl.checkForRandomBug(ssl.sslInfo.certificates[i].publicKeyFingerprint);
if(r != "")
{
//debug("SSL_random" + r);
ReportItem("SSL_random.xml", "SSL Certificate serial number: [pre]" + ssl.sslInfo.certificates[i].serialNumber + "[/pre][break]Vulnerable hash: [pre]" + r + "[/pre]");
}
*/
var issuer = ssl.sslInfo.certificates[i].issuer;
// look for invalid common name
// if (!reportedInvalidCommonName)
// for(var k = 0; k < issuer.length; k++) {
// if (issuer[k][0] == "Common Name") {
// var commonName = issuer[k][1];
// if (commonName != scanHost) {
// ReportItem("SSL_certificate_common_name_invalid.xml", "Common name: [dark][bold]" + commonName + "[/bold][/dark][break]Hostname: [dark][bold]" + scanHost + "[/bold][/dark][break][break]Certificate information: [break]" + sslKBase);
// reportedInvalidCommonName = true;
// }
// }
// }
}
sslKBase += "[/li][break]";
if(lowStrengthCiphers != "")
{
debug("Low strength ciphers found.");
ReportItem("SSL_weak_ciphers.xml", "Weak SSL ciphers (" + strProtocol + " on port " + arrayOfPorts[portIndex] + "): [break][break]" + lowStrengthCiphers);
}
if(exportCiphers != "")
{
debug("Export ciphers found.");
ReportItem("SSL_export_cipher_suites_FREAK_attack.xml", "EXPORT cipher suites (" + strProtocol + " on port " + arrayOfPorts[portIndex] + "): [break][break]" + lowStrengthCiphers);
}
if(rc4Ciphers != "")
{
debug("RC4 ciphers found.");
ReportItem("RC4_Cipher_Suites.xml", "RC4 cipher suites (" + strProtocol + " on port " + arrayOfPorts[portIndex] + "): [break][break]" + rc4Ciphers);
}
}
}
if(sslKBase)
{
KBase( "SSL server running [" + arrayOfPorts[portIndex] + "]" ,sslKBase);
}
}