@@ -30,6 +30,7 @@ module Exploit::Remote::MsIcpr
30
30
class MsIcprError < StandardError ; end
31
31
class MsIcprConnectionError < MsIcprError ; end
32
32
class MsIcprAuthenticationError < MsIcprError ; end
33
+ class MsIcprAuthorizationError < MsIcprError ; end
33
34
class MsIcprNotFoundError < MsIcprError ; end
34
35
class MsIcprUnexpectedReplyError < MsIcprError ; end
35
36
class MsIcprUnknownError < MsIcprError ; end
@@ -91,7 +92,7 @@ def request_certificate(opts = {})
91
92
rescue RubySMB ::Error ::UnexpectedStatusCode => e
92
93
if e . status_code == ::WindowsError ::NTStatus ::STATUS_OBJECT_NAME_NOT_FOUND
93
94
# STATUS_OBJECT_NAME_NOT_FOUND will be the status if Active Directory Certificate Service (AD CS) is not installed on the target
94
- raise MsIcprNotFoundError , 'Connection failed (AD CS was not found)'
95
+ raise MsIcprNotFoundError , 'Connection failed (AD CS was not found). '
95
96
end
96
97
97
98
elog ( e . message , error : e )
@@ -192,6 +193,17 @@ def do_request_cert(icpr, opts)
192
193
print_error ( " Source: #{ hresult . facility } " ) if hresult . facility
193
194
print_error ( " HRESULT: #{ hresult } " )
194
195
end
196
+
197
+ case hresult
198
+ when ::WindowsError ::HResult ::CERTSRV_E_ENROLL_DENIED
199
+ raise MsIcprAuthorizationError . new ( hresult . description )
200
+ when ::WindowsError ::HResult ::CERTSRV_E_TEMPLATE_DENIED
201
+ raise MsIcprAuthorizationError . new ( hresult . description )
202
+ when ::WindowsError ::HResult ::CERTSRV_E_UNSUPPORTED_CERT_TYPE
203
+ raise MsIcprNotFoundError . new ( hresult . description )
204
+ else
205
+ raise MsIcprUnknownError . new ( hresult . description )
206
+ end
195
207
end
196
208
197
209
return unless response [ :certificate ]
0 commit comments