@@ -29,6 +29,7 @@ def initialize
29
29
[
30
30
'et' , #original module
31
31
'Chris John Riley' , #additions
32
+ 'Veit Hailperin' , # checks for public key size, valid time
32
33
] ,
33
34
'License' => MSF_LICENSE
34
35
)
@@ -52,6 +53,15 @@ def run_host(ip)
52
53
print_status ( "#{ ip } :#{ rport } Subject: #{ cert . subject } " )
53
54
print_status ( "#{ ip } :#{ rport } Issuer: #{ cert . issuer } " )
54
55
print_status ( "#{ ip } :#{ rport } Signature Alg: #{ cert . signature_algorithm } " )
56
+ public_key = cert . public_key . to_pem ( )
57
+ # removing header and footer
58
+ public_key = public_key . sub ( "-----BEGIN RSA PUBLIC KEY-----" , "" )
59
+ public_key = public_key . sub ( "-----END RSA PUBLIC KEY-----" , "" )
60
+ public_key_size = Rex ::Text . decode_base64 ( public_key ) . size
61
+ # removing 12 bytes for some shmoo of exponent and modulus
62
+ print_status ( "#{ ip } :#{ rport } Public Key Size: #{ ( public_key_size - 12 ) * 8 } bits" )
63
+ print_status ( "#{ ip } :#{ rport } Not Valid Before: #{ cert . not_before } " )
64
+ print_status ( "#{ ip } :#{ rport } Not Valid After: #{ cert . not_after } " )
55
65
56
66
# Checks for common properties of self signed certificates
57
67
caissuer = ( /CA Issuers - URI:(.*?),/i ) . match ( cert . extensions . to_s )
@@ -76,6 +86,17 @@ def run_host(ip)
76
86
cert . subject . to_a . each do |n |
77
87
vhostn = n [ 1 ] if n [ 0 ] == 'CN'
78
88
end
89
+ if public_key_size = 1024
90
+ print_status ( "#{ ip } :#{ rport } WARNING: Public Key only 1024 bits" )
91
+ elsif public_key_size < 1024
92
+ print_status ( "#{ ip } :#{ rport } WARNING: Weak Public Key: #{ public_key_size } bits" )
93
+ end
94
+ if cert . not_after < Time . now
95
+ print_status ( "#{ ip } :#{ rport } WARNING: Certificate not valid anymore" )
96
+ end
97
+ if cert . not_before > Time . now
98
+ print_status ( "#{ ip } :#{ rport } WARNING: Certificate not valid yet" )
99
+ end
79
100
80
101
if vhostn
81
102
print_status ( "#{ ip } :#{ rport } has common name #{ vhostn } " )
@@ -98,7 +119,10 @@ def run_host(ip)
98
119
:data => {
99
120
:cn => vhostn ,
100
121
:subject => cert . subject . to_a ,
101
- :algorithm => alg
122
+ :algorithm => alg ,
123
+ :valid_from => cert . not_before ,
124
+ :valid_after => cert . not_after ,
125
+ :key_size => public_key_size
102
126
103
127
}
104
128
)
0 commit comments