-
Notifications
You must be signed in to change notification settings - Fork 0
/
crypynarf.py
executable file
·130 lines (118 loc) · 3.09 KB
/
crypynarf.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
#!/usr/bin/python
# CryPyNarf! Poit. ZOT!
# A threaded test of which SSL/TLS ciphers are
# supported on the server.
# Requires openssl for testing.
suites = {"ssl2": [
'DES-CBC3-MD5',
'IDEA-CBC-MD5',
'RC2-CBC-MD5',
'RC4-MD5',
'DES-CBC-MD5',
'EXP-RC2-CBC-MD5',
'EXP-RC4-MD5'],
"ssl3" : [
'DHE-RSA-AES256-SHA',
'DHE-DSS-AES256-SHA',
'AES256-SHA',
'DHE-RSA-CAMELLIA256-SHA',
'DHE-DSS-CAMELLIA256-SHA',
'CAMELLIA256-SHA',
'EDH-RSA-DES-CBC3-SHA',
'EDH-DSS-DES-CBC3-SHA',
'DES-CBC3-SHA',
'DHE-RSA-AES128-SHA',
'DHE-DSS-AES128-SHA',
'AES128-SHA',
'DHE-RSA-CAMELLIA128-SHA',
'DHE-DSS-CAMELLIA128-SHA',
'CAMELLIA128-SHA',
'IDEA-CBC-SHA',
'RC4-SHA',
'RC4-MD5',
'EDH-RSA-DES-CBC-SHA',
'EDH-DSS-DES-CBC-SHA',
'DES-CBC-SHA',
'EXP-EDH-RSA-DES-CBC-SHA',
'EXP-EDH-DSS-DES-CBC-SHA',
'EXP-DES-CBC-SHA',
'EXP-RC2-CBC-MD5',
'EXP-RC4-MD5'],
"tls1" : [
'DHE-RSA-AES256-SHA',
'DHE-DSS-AES256-SHA',
'AES256-SHA',
'DHE-RSA-CAMELLIA256-SHA',
'DHE-DSS-CAMELLIA256-SHA',
'CAMELLIA256-SHA',
'EDH-RSA-DES-CBC3-SHA',
'EDH-DSS-DES-CBC3-SHA',
'DES-CBC3-SHA',
'DHE-RSA-AES128-SHA',
'DHE-DSS-AES128-SHA',
'AES128-SHA',
'DHE-RSA-CAMELLIA128-SHA',
'DHE-DSS-CAMELLIA128-SHA',
'CAMELLIA128-SHA',
'IDEA-CBC-SHA',
'RC4-SHA',
'RC4-MD5',
'EDH-RSA-DES-CBC-SHA',
'EDH-DSS-DES-CBC-SHA',
'DES-CBC-SHA',
'EXP-EDH-RSA-DES-CBC-SHA',
'EXP-EDH-DSS-DES-CBC-SHA',
'EXP-DES-CBC-SHA',
'EXP-RC2-CBC-MD5',
'EXP-RC4-MD5']}
import threading as th, sys, subprocess as sub
# Input validation. Sort of.
if len(sys.argv) != 2:
sys.stderr.write("Syntax error! Correct usage:\n%s <target IP:target port> e.g. %s 127.0.0.1:443\n" % (sys.argv[0], sys.argv[0]))
sys.exit(2)
# Build the dictionaries to store results.
failciphers = {"ssl2": [], "ssl3": [], "tls1": []}
yayciphers = {"ssl2": [], "ssl3": [], "tls1": []}
# The thread class to spawn off all of the tests.
class ciphtest(th.Thread):
def __init__ (self, suite, host, cipher):
# Accept parameters passed in.
self.suite = suite
self.host = host
self.cipher = cipher
th.Thread.__init__ ( self )
def run(self):
# Build the openssl command, run it, and poll for results.
cmd = 'openssl s_client -' + self.suite + ' -connect ' + self.host + ' -cipher ' + self.cipher
p = sub.Popen(cmd, shell=True, stdout=sub.PIPE, stderr=sub.PIPE)
p.poll()
if p.returncode == None:
# If we have no return yet, read input, and kill ourself. (Emo, yeah!)
p.stdout.readline()
p.kill()
pcom = p.communicate()
# Check for stdout as failures report to stderr.
if pcom[0] != '':
yayciphers[self.suite].append(self.cipher)
else:
failciphers[self.suite].append(self.cipher)
# Spawn the threads.
for zed in suites:
for x in suites[zed]:
ciphtest(zed, sys.argv[1], x).start()
# Ungraceful, but effective for now. Display the results for each suite.
print "#####################"
print "## SSLv2 Ciphers ##"
print "#####################"
for a in yayciphers["ssl2"]:
print a
print "#####################"
print "## SSLv3 Ciphers ##"
print "#####################"
for a in yayciphers["ssl3"]:
print a
print "#####################"
print "## TLSv1 Ciphers ##"
print "#####################"
for a in yayciphers["tls1"]:
print a