Created
July 17, 2012 16:12
-
-
Save bonsaiviking/3130353 to your computer and use it in GitHub Desktop.
Rate TLS ciphers similar to ssllabs.com's ranking system
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use 5.012; | |
my %kex_scores = ( | |
NULL => 0, | |
anon => 0, | |
EXPORT => 40, | |
#Otherwise => 80 | |
); | |
my %cipher_scores = ( | |
NULL => 0, | |
40 => 20, | |
DES40 => 20, | |
DES => 20, #56 | |
56 => 20, | |
IDEA => 20, #64 | |
128 => 80, | |
SEED => 80, #128 | |
"3DES" => 80, #168 | |
256 => 100, | |
); | |
while (<>) { | |
chomp; | |
my $state = 0; | |
my ($ks, $cs); | |
for my $f (split /_/) { | |
if ($state == 0) { | |
$ks = $kex_scores{$f}; | |
if (defined $ks) { | |
$state = 1; | |
} | |
else { | |
$cs = $cipher_scores{$f}; | |
if (defined $cs) { | |
$state = 2; | |
} | |
} | |
} | |
elsif ($state == 1) { | |
$cs = $cipher_scores{$f}; | |
if (defined $cs) { | |
$state = 2; | |
} | |
} | |
else { | |
last; | |
} | |
} | |
$ks //= 80; | |
$cs = 0 if $ks == 0; #NULL means 0, period. | |
if (defined $cs) { | |
my $score = .4 * $ks + .6 * $cs; | |
$score = 0 if $ks == 0 or $cs == 0; | |
if ($score >= 80) { | |
$score = 'strong'; | |
} | |
elsif ($score < 50) { | |
if ($score >= 20) { | |
$score = 'weak'; | |
} | |
else { | |
$score = 'broken'; | |
} | |
} | |
say "$_ $score"; | |
} | |
else { | |
#say "$_ unknown"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment