File tree Expand file tree Collapse file tree 1 file changed +21
-4
lines changed
lib/msf/core/post/windows Expand file tree Collapse file tree 1 file changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,21 @@ module Accounts
24
24
[ 'ClientSiteName' , :LPSTR ]
25
25
]
26
26
27
+ ##
28
+ # get_domain(server_name=nil)
29
+ #
30
+ # Summary:
31
+ # Retrieves the current DomainName the given server is
32
+ # a member of.
33
+ #
34
+ # Parameters
35
+ # server_name - DNS or NetBIOS name of the remote server
36
+ # Returns:
37
+ # The DomainName of the remote server or nil if windows
38
+ # could not retrieve the DomainControllerInfo or encountered
39
+ # an exception.
40
+ #
41
+ ##
27
42
def get_domain ( server_name = nil )
28
43
domain = nil
29
44
result = session . railgun . netapi32 . DsGetDcNameA (
@@ -36,14 +51,16 @@ def get_domain(server_name=nil)
36
51
37
52
begin
38
53
dc_info_addr = result [ 'DomainControllerInfo' ]
39
- dc_info = session . railgun . util . read_data ( DOMAIN_CONTROLLER_INFO , dc_info_addr )
40
- pointer = session . railgun . util . unpack_pointer ( dc_info [ 'DomainName' ] )
41
- domain = session . railgun . util . read_string ( pointer )
54
+ unless dc_info_addr == 0
55
+ dc_info = session . railgun . util . read_data ( DOMAIN_CONTROLLER_INFO , dc_info_addr )
56
+ pointer = session . railgun . util . unpack_pointer ( dc_info [ 'DomainName' ] )
57
+ domain = session . railgun . util . read_string ( pointer )
58
+ end
42
59
ensure
43
60
session . railgun . netapi32 . NetApiBufferFree ( dc_info_addr )
44
61
end
45
62
46
- return domain
63
+ domain
47
64
end
48
65
49
66
##
You can’t perform that action at this time.
0 commit comments