Skip to content

Commit 0dfd422

Browse files
David MaloneyDavid Maloney
authored andcommitted
Merge branch 'feature/MSP-12357/meterp-ntds' into feature/MSP-12358/ntds-dump-module
2 parents 2ce0e61 + f3effe5 commit 0dfd422

File tree

3 files changed

+38
-66
lines changed

3 files changed

+38
-66
lines changed

lib/metasploit/framework/ntds/account.rb

Lines changed: 32 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -5,73 +5,47 @@ module NTDS
55
# priv extension.
66
class Account
77

8-
# @!attribute description
9-
# @return [String] The AD Account Description
8+
#@return [String] The AD Account Description
109
attr_accessor :description
11-
# @!attribute disabled
12-
# @return [TrueClass] If the AD account is disabled
13-
# @return [FalseClass] If the AD account is not disabled
10+
#@return [Boolean] If the AD account is disabled
1411
attr_accessor :disabled
15-
# @!attribute expired
16-
# @return [TrueClass] If the AD account password is expired
17-
# @return [FalseClass] If the AD account password is not expired
12+
#@return [Boolean] If the AD account password is expired
1813
attr_accessor :expired
19-
# @!attribute expiry_date
20-
# @return [String] Human Readable Date for the account's password expiration
14+
#@return [String] Human Readable Date for the account's password expiration
2115
attr_accessor :expiry_date
22-
# @!attribute lm_hash
23-
# @return [String] The LM Hash of the current password
16+
#@return [String] The LM Hash of the current password
2417
attr_accessor :lm_hash
25-
# @!attribute lm_history
26-
# @return [Array<String>] The LM hashes for previous passwords, up to 24
18+
#@return [Array<String>] The LM hashes for previous passwords, up to 24
2719
attr_accessor :lm_history
28-
# @!attribute lm_history_count
29-
# @return [Fixnum] The count of historical LM hashes
20+
#@return [Fixnum] The count of historical LM hashes
3021
attr_accessor :lm_history_count
31-
# @!attribute locked
32-
# @return [TrueClass] If the AD account is locked
33-
# @return [FalseClass] If the AD account is not locked
22+
#@return [Boolean] If the AD account is locked
3423
attr_accessor :locked
35-
# @!attribute logon_count
36-
# @return [Fixnum] The number of times this account has logged in
24+
#@return [Fixnum] The number of times this account has logged in
3725
attr_accessor :logon_count
38-
# @!attribute logon_date
39-
# @return [String] Human Readable Date for the last time the account logged in
26+
#@return [String] Human Readable Date for the last time the account logged in
4027
attr_accessor :logon_date
41-
# @!attribute logon_time
42-
# @return [String] Human Readable Time for the last time the account logged in
28+
#@return [String] Human Readable Time for the last time the account logged in
4329
attr_accessor :logon_time
44-
# @!attribute name
45-
# @return [String] The samAccountName of the account
30+
#@return [String] The samAccountName of the account
4631
attr_accessor :name
47-
# @!attribute no_expire
48-
# @return [TrueClass] If the AD account password does not expire
49-
# @return [FalseClass] If the AD account password does expire
32+
#@return [Boolean] If the AD account password does not expire
5033
attr_accessor :no_expire
51-
# @!attribute no_pass
52-
# @return [TrueClass] If the AD account does not require a password
53-
# @return [FalseClass] If the AD account does require a password
34+
#@return [Boolean] If the AD account does not require a password
5435
attr_accessor :no_pass
55-
# @!attribute nt_hash
56-
# @return [String] The NT Hash of the current password
36+
#@return [String] The NT Hash of the current password
5737
attr_accessor :nt_hash
58-
# @!attribute nt_history
59-
# @return [Array<String>] The NT hashes for previous passwords, up to 24
38+
#@return [Array<String>] The NT hashes for previous passwords, up to 24
6039
attr_accessor :nt_history
61-
# @!attribute nt_history_count
62-
# @return [Fixnum] The count of historical NT hashes
40+
#@return [Fixnum] The count of historical NT hashes
6341
attr_accessor :nt_history_count
64-
# @!attribute pass_date
65-
# @return [String] Human Readable Date for the last password change
42+
#@return [String] Human Readable Date for the last password change
6643
attr_accessor :pass_date
67-
# @!attribute pass_time
68-
# @return [String] Human Readable Time for the last password change
44+
#@return [String] Human Readable Time for the last password change
6945
attr_accessor :pass_time
70-
# @!attribute rid
71-
# @return [Fixnum] The Relative ID of the account
46+
#@return [Fixnum] The Relative ID of the account
7247
attr_accessor :rid
73-
# @!attribute sid
74-
# @return [String] Byte String for the Account's SID
48+
#@return [String] Byte String for the Account's SID
7549
attr_accessor :sid
7650

7751
# @param raw_data [String] the raw 3948 byte string from the wire
@@ -105,17 +79,17 @@ def initialize(raw_data)
10579

10680
# @return [String] String representation of the account data
10781
def to_s
108-
<<EOS
109-
#{@name} (#{@description})
110-
#{ntlm_hash}
111-
Password Expires: #{@expiry_date}
112-
Last Password Change: #{@pass_time} #{@pass_date}
113-
Last Logon: #{@logon_time} #{@logon_date}
114-
Logon Count: #{@logon_count}
115-
#{uac_string}
116-
Hash History:
117-
#{hash_history}
118-
EOS
82+
<<-EOS.strip_heredoc
83+
#{@name} (#{@description})
84+
#{ntlm_hash}
85+
Password Expires: #{@expiry_date}
86+
Last Password Change: #{@pass_time} #{@pass_date}
87+
Last Logon: #{@logon_time} #{@logon_date}
88+
Logon Count: #{@logon_count}
89+
#{uac_string}
90+
Hash History:
91+
#{hash_history}
92+
EOS
11993
end
12094

12195
# @return [String] the NTLM hash string for the current password

lib/metasploit/framework/ntds/parser.rb

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,11 @@ class Parser
1111
# The size, in Bytes, of a batch of NTDS accounts
1212
BATCH_SIZE = 78960
1313

14-
# @!attribute channel
15-
# @return [Rex::Post::Meterpreter::Channels::Pool] The Meterpreter NTDS Parser Channel
14+
#@return [Rex::Post::Meterpreter::Channels::Pool] The Meterpreter NTDS Parser Channel
1615
attr_accessor :channel
17-
# @!attribute client
18-
# @return [Msf::Session] The Meterpreter Client
16+
#@return [Msf::Session] The Meterpreter Client
1917
attr_accessor :client
20-
# @!attribute file_path
21-
# @return [String] The path to the NTDS.dit file on the remote system
18+
#@return [String] The path to the NTDS.dit file on the remote system
2219
attr_accessor :file_path
2320

2421
def initialize(client, file_path='')
@@ -31,8 +28,9 @@ def initialize(client, file_path='')
3128
# Yields a [Metasploit::Framework::NTDS::Account] for each account found
3229
# in the remote NTDS.dit file.
3330
#
31+
# @yield [account]
3432
# @yieldparam account [Metasploit::Framework::NTDS::Account] an AD user account
35-
# @return [void] does not return a value
33+
# @yieldreturn [void] does not return a value
3634
def each_account
3735
raw_batch_data = pull_batch
3836
until raw_batch_data.nil?

lib/rex/post/meterpreter/extensions/priv/priv.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def ntds_parse(filepath)
103103
if channel_id.nil?
104104
raise Exception, "We did not get a channel back!"
105105
end
106-
channel = Rex::Post::Meterpreter::Channels::Pool.new(client, channel_id, "priv_ntds", CHANNEL_FLAG_SYNCHRONOUS)
106+
Rex::Post::Meterpreter::Channels::Pool.new(client, channel_id, "priv_ntds", CHANNEL_FLAG_SYNCHRONOUS)
107107
end
108108

109109
#

0 commit comments

Comments
 (0)