Skip to content

Commit 732192a

Browse files
author
Brent Cook
committed
move ntds from priv to extapi
1 parent 7f27fd0 commit 732192a

File tree

6 files changed

+47
-17
lines changed

6 files changed

+47
-17
lines changed

lib/metasploit/framework/ntds/parser.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Parser
1919
def initialize(client, file_path='')
2020
raise ArgumentError, "Invalid Filepath" unless file_path.present?
2121
@file_path = file_path
22-
@channel = client.priv.ntds_parse(file_path)
22+
@channel = client.extapi.ntds.parse(file_path)
2323
@client = client
2424
end
2525

@@ -61,10 +61,10 @@ def pull_batch
6161
end
6262

6363
def reopen_channel
64-
@channel = client.priv.ntds_parse(file_path)
64+
@channel = client.extapi.ntds.parse(file_path)
6565
end
6666

6767
end
6868
end
6969
end
70-
end
70+
end

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
require 'rex/post/meterpreter/extensions/extapi/service/service'
66
require 'rex/post/meterpreter/extensions/extapi/clipboard/clipboard'
77
require 'rex/post/meterpreter/extensions/extapi/adsi/adsi'
8+
require 'rex/post/meterpreter/extensions/extapi/ntds/ntds'
89
require 'rex/post/meterpreter/extensions/extapi/wmi/wmi'
910

1011
module Rex
@@ -34,6 +35,7 @@ def initialize(client)
3435
'service' => Rex::Post::Meterpreter::Extensions::Extapi::Service::Service.new(client),
3536
'clipboard' => Rex::Post::Meterpreter::Extensions::Extapi::Clipboard::Clipboard.new(client),
3637
'adsi' => Rex::Post::Meterpreter::Extensions::Extapi::Adsi::Adsi.new(client),
38+
'ntds' => Rex::Post::Meterpreter::Extensions::Extapi::Ntds::Ntds.new(client),
3739
'wmi' => Rex::Post::Meterpreter::Extensions::Extapi::Wmi::Wmi.new(client)
3840
})
3941
},
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# -*- coding: binary -*-
2+
3+
module Rex
4+
module Post
5+
module Meterpreter
6+
module Extensions
7+
module Extapi
8+
module Ntds
9+
10+
###
11+
#
12+
# This meterpreter extension contains extended API functions for
13+
# parsing the NT Directory Service database.
14+
#
15+
###
16+
class Ntds
17+
18+
def initialize(client)
19+
@client = client
20+
end
21+
22+
def parse(filepath)
23+
request = Packet.create_request('extapi_ntds_parse')
24+
request.add_tlv( TLV_TYPE_NTDS_PATH, filepath)
25+
# wait up to 90 seconds for a response
26+
response = client.send_request(request, 90)
27+
channel_id = response.get_tlv_value(TLV_TYPE_CHANNEL_ID)
28+
if channel_id.nil?
29+
raise Exception, "We did not get a channel back!"
30+
end
31+
Rex::Post::Meterpreter::Channels::Pool.new(client, channel_id, "extapi_ntds", CHANNEL_FLAG_SYNCHRONOUS)
32+
end
33+
34+
attr_accessor :client
35+
36+
end
37+
38+
end; end; end; end; end; end
39+

lib/rex/post/meterpreter/extensions/extapi/tlv.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ module Extapi
7272
TLV_TYPE_EXT_ADSI_PATH_TYPE = TLV_META_TYPE_UINT | (TLV_TYPE_EXTENSION_EXTAPI + TLV_EXTENSIONS + 69)
7373
TLV_TYPE_EXT_ADSI_DN = TLV_META_TYPE_GROUP | (TLV_TYPE_EXTENSION_EXTAPI + TLV_EXTENSIONS + 70)
7474

75+
TLV_TYPE_NTDS_TEST = TLV_META_TYPE_STRING | (TLV_TYPE_EXTENSION_EXTAPI + TLV_EXTENSIONS + 80)
76+
TLV_TYPE_NTDS_PATH = TLV_META_TYPE_STRING | (TLV_TYPE_EXTENSION_EXTAPI + TLV_EXTENSIONS + 81)
77+
7578
TLV_TYPE_EXT_WMI_DOMAIN = TLV_META_TYPE_STRING | (TLV_TYPE_EXTENSION_EXTAPI + TLV_EXTENSIONS + 90)
7679
TLV_TYPE_EXT_WMI_QUERY = TLV_META_TYPE_STRING | (TLV_TYPE_EXTENSION_EXTAPI + TLV_EXTENSIONS + 91)
7780
TLV_TYPE_EXT_WMI_FIELD = TLV_META_TYPE_STRING | (TLV_TYPE_EXTENSION_EXTAPI + TLV_EXTENSIONS + 92)

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,6 @@ def sam_hashes
9595
}
9696
end
9797

98-
def ntds_parse(filepath)
99-
request = Packet.create_request( 'priv_ntds_parse' )
100-
request.add_tlv( TLV_TYPE_NTDS_PATH, filepath)
101-
response = client.send_request( request, 90 )
102-
channel_id = response.get_tlv_value(TLV_TYPE_CHANNEL_ID)
103-
if channel_id.nil?
104-
raise Exception, "We did not get a channel back!"
105-
end
106-
Rex::Post::Meterpreter::Channels::Pool.new(client, channel_id, "priv_ntds", CHANNEL_FLAG_SYNCHRONOUS)
107-
end
108-
10998
#
11099
# Modifying privileged file system attributes.
111100
#

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ module Priv
2222
TLV_TYPE_ELEVATE_SERVICE_DLL = TLV_META_TYPE_STRING | (TLV_EXTENSIONS + 202)
2323
TLV_TYPE_ELEVATE_SERVICE_LENGTH = TLV_META_TYPE_UINT | (TLV_EXTENSIONS + 203)
2424

25-
#NTDS
26-
TLV_TYPE_NTDS_PATH = TLV_META_TYPE_STRING | (TLV_EXTENSIONS + 301)
27-
2825
end
2926
end
3027
end

0 commit comments

Comments
 (0)