File tree Expand file tree Collapse file tree 1 file changed +13
-9
lines changed Expand file tree Collapse file tree 1 file changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -16,24 +16,28 @@ module Exploit::Remote::DCERPC_SERVICES
16
16
# @param rhost [String] the target host.
17
17
# @param access [Fixnum] the access flags requested.
18
18
#
19
- # @return [String] the handle to the service control manager.
19
+ # @return [String] the handle to the service control manager or nil if
20
+ # the call is not successful.
20
21
def dce_openscmanagerw ( dcerpc , rhost , access = 0xF003F )
21
22
scm_handle = nil
22
23
scm_status = nil
23
24
stubdata =
24
25
NDR . uwstring ( "\\ \\ #{ rhost } " ) +
25
26
NDR . long ( 0 ) +
26
27
NDR . long ( access )
27
- response = dcerpc . call ( 0x0f , stubdata )
28
- if dcerpc . last_response and dcerpc . last_response . stub_data
29
- scm_handle = dcerpc . last_response . stub_data [ 0 , 20 ]
30
- scm_status = dcerpc . last_response . stub_data [ 20 , 4 ]
28
+ begin
29
+ response = dcerpc . call ( 0x0f , stubdata )
30
+ if response
31
+ scm_status = response [ 20 , 4 ] . unpack ( 'V' ) . first
32
+ if scm_status == 0
33
+ scm_handle = response [ 0 , 20 ]
34
+ end
35
+ end
36
+ rescue Rex ::Proto ::DCERPC ::Exceptions ::Fault => e
37
+ print_error ( "#{ peer } - Error getting scm handle: #{ e } " )
31
38
end
32
39
33
- if scm_status . to_i != 0
34
- scm_handle = nil
35
- end
36
- return scm_handle
40
+ scm_handle
37
41
end
38
42
39
43
You can’t perform that action at this time.
0 commit comments