|
13 | 13 |
|
14 | 14 | class Metasploit3 < Msf::Post
|
15 | 15 |
|
| 16 | + include Post::Windows::WindowsServices |
| 17 | + |
16 | 18 | def initialize
|
17 | 19 | super(
|
18 | 20 | 'Name' => 'Windows Gather Proxy Setting',
|
@@ -43,18 +45,31 @@ def run
|
43 | 45 | root_key, base_key = session.sys.registry.splitkey("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Connections")
|
44 | 46 | end
|
45 | 47 |
|
46 |
| - # print_status "#{root_key}" |
47 |
| - # print_status "#{base_key}" |
48 |
| - |
49 | 48 | 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 |
51 | 63 | open_key = key.open_key(base_key)
|
52 | 64 | else
|
53 | 65 | open_key = session.sys.registry.open_key(root_key, base_key)
|
54 | 66 | end
|
55 | 67 |
|
56 | 68 | values = open_key.query_value('DefaultConnectionSettings')
|
57 | 69 |
|
| 70 | + #If we started the service we need to stop it. |
| 71 | + service_stop('RemoteRegistry',datastore['RHOST']) if startedreg |
| 72 | + |
58 | 73 | data = values.data
|
59 | 74 |
|
60 | 75 | print_status "Proxy Counter = #{(data[4,1].unpack('C*'))[0]}"
|
|
0 commit comments