3
3
4
4
describe Msf ::Exploit ::Remote ::BrowserExploitServer do
5
5
6
- # When unpacked, this gives us:
7
- # {
8
- # "BAP.1433806920.Client.blLGFIlwYrxfvcY" =>
9
- # {
10
- # "source" => "script",
11
- # "os_name" => "Windows 8.1",
12
- # "os_vendor" => "undefined",
13
- # "os_device" => "undefined",
14
- # "ua_name" => "Firefox",
15
- # "ua_ver" => "35.0",
16
- # "arch" => "x86",
17
- # "java" => "1.7",
18
- # "silverlight" => "false",
19
- # "flash" => "14.0",
20
- # "vuln_test" => "true",
21
- # "proxy" => false,
22
- # "language" => "en-US,en;q=0.5",
23
- # "tried" => true,
24
- # "activex" => [{"clsid"=>"{D27CDB6E-AE6D-11cf-96B8-444553540000}", "method"=>"LoadMovie"}]
25
- # }}
26
- let ( :first_packed_profile ) do
27
- "\x81 \xD9 %BAP.1433806920.Client.blLGFIlwYrxfvcY\x8F \xA6 source\xA6 script\xA7 os_name\xAB Windows 8.1\xA9 os_vendor\xA9 undefined\xA9 os_device\xA9 undefined\xA7 ua_name\xA7 Firefox\xA6 ua_ver\xA4 35.0\xA4 arch\xA3 x86\xA4 java\xA3 1.7\xAB silverlight\xA5 false\xA5 flash\xA4 14.0\xA9 vuln_test\xA4 true\xA5 proxy\xC2 \xA8 language\xC4 \x0E en-US,en;q=0.5\xA5 tried\xC3 \xA7 activex\x91 \x82 \xA5 clsid\xD9 &{D27CDB6E-AE6D-11cf-96B8-444553540000}\xA6 method\xA9 LoadMovie"
6
+ let ( :in_memory_profile ) do
7
+ {
8
+ "BAP.1433806920.Client.blLGFIlwYrxfvcY" =>
9
+ {
10
+ source : "script" ,
11
+ os_name : "Windows 8.1" ,
12
+ os_vendor : "undefined" ,
13
+ os_device : "undefined" ,
14
+ ua_name : "Firefox" ,
15
+ ua_ver : "35.0" ,
16
+ arch : "x86" ,
17
+ java : "1.7" ,
18
+ silverlight : "false" ,
19
+ flash : "14.0" ,
20
+ vuln_test : "true" ,
21
+ proxy : false ,
22
+ language : "en-US,en;q=0.5" ,
23
+ tried : true ,
24
+ activex : [ { "clsid" => "{D27CDB6E-AE6D-11cf-96B8-444553540000}" , "method" => "LoadMovie" } ]
25
+ } }
28
26
end
29
27
30
28
let ( :default_note_type_prefix ) do
31
- MessagePack . unpack ( first_packed_profile ) . keys . first . split ( '.' ) [ 0 , 3 ] * "."
29
+ in_memory_profile . keys . first . split ( '.' ) [ 0 , 3 ] * "."
32
30
end
33
31
34
32
let ( :first_profile_tag ) do
35
- MessagePack . unpack ( first_packed_profile ) . keys . first . split ( '.' ) [ 3 ]
33
+ in_memory_profile . keys . first . split ( '.' ) [ 3 ]
36
34
end
37
35
38
36
let ( :first_profile_info ) do
39
- MessagePack . unpack ( first_packed_profile ) . values . first
37
+ in_memory_profile . values . first
40
38
end
41
39
42
40
let ( :cli ) do
46
44
sock
47
45
end
48
46
47
+ let ( :shortname ) do
48
+ 'browser_exploit_server'
49
+ end
50
+
49
51
def create_fake_note ( tag , data )
50
52
note = double ( 'note' )
51
53
allow ( note ) . to receive ( :ntype ) . and_return ( tag )
@@ -57,14 +59,15 @@ def create_fake_note(tag, data)
57
59
58
60
before ( :each ) do
59
61
allow_any_instance_of ( described_class ) . to receive ( :vprint_status )
60
- @notes = [ create_fake_note ( first_profile_tag , first_packed_profile ) ]
62
+ @notes = [ create_fake_note ( first_profile_tag , in_memory_profile ) ]
61
63
end
62
64
63
65
subject ( :server ) do
64
66
mod = Msf ::Exploit ::Remote . allocate
65
67
mod . extend described_class
66
68
mod . send ( :initialize )
67
69
mod . send ( :datastore= , { 'NoteTypePrefix' => default_note_type_prefix } )
70
+ allow ( mod ) . to receive ( :shortname ) . and_return ( shortname )
68
71
mod
69
72
end
70
73
@@ -99,14 +102,14 @@ def create_fake_note(tag, data)
99
102
100
103
describe '#has_bad_activex?' do
101
104
context 'when there is a bad activex' do
102
- let ( :js_ax_value ) { "#{ first_profile_info [ ' activex' ] [ 0 ] [ :clsid ] } =>#{ first_profile_info [ ' activex' ] [ 0 ] [ :method ] } =>false" }
105
+ let ( :js_ax_value ) { "#{ first_profile_info [ : activex] [ 0 ] [ :clsid ] } =>#{ first_profile_info [ : activex] [ 0 ] [ :method ] } =>false" }
103
106
it 'returns false' do
104
107
expect ( server . has_bad_activex? ( js_ax_value ) ) . to be_truthy
105
108
end
106
109
end
107
110
108
111
context 'when there is no bad activex' do
109
- let ( :js_ax_value ) { "#{ first_profile_info [ ' activex' ] [ 0 ] [ :clsid ] } =>#{ first_profile_info [ ' activex' ] [ 0 ] [ :method ] } =>true" }
112
+ let ( :js_ax_value ) { "#{ first_profile_info [ : activex] [ 0 ] [ :clsid ] } =>#{ first_profile_info [ : activex] [ 0 ] [ :method ] } =>true" }
110
113
it 'returns true' do
111
114
expect ( server . has_bad_activex? ( js_ax_value ) ) . to be_falsey
112
115
end
@@ -194,7 +197,7 @@ def create_fake_note(tag, data)
194
197
195
198
describe '#on_request_uri' do
196
199
before ( :each ) do
197
- allow ( server ) . to receive ( :get_profile_info ) { MessagePack . unpack ( first_packed_profile ) }
200
+ allow ( server ) . to receive ( :get_profile_info ) { in_memory_profile }
198
201
allow ( server ) . to receive ( :init_profile ) . with ( kind_of ( String ) )
199
202
allow ( server ) . to receive ( :update_profile )
200
203
allow ( server ) . to receive ( :process_browser_info )
@@ -260,4 +263,113 @@ def create_fake_note(tag, data)
260
263
end
261
264
end
262
265
end
266
+
267
+ describe '#browser_profile_prefix' do
268
+ it 'returns a BES prefix' do
269
+ expect ( subject . browser_profile_prefix ) . to include ( shortname )
270
+ end
271
+ end
272
+
273
+ describe '#get_custom_404_url' do
274
+ let ( :custom_404 ) do
275
+ 'http://example.com'
276
+ end
277
+
278
+ before ( :each ) do
279
+ allow ( subject ) . to receive ( :datastore ) . and_return ( { 'Custom404' => custom_404 } )
280
+ end
281
+
282
+ context 'when a custom 404 URL is set' do
283
+ it 'returns the URL' do
284
+ expect ( subject . get_custom_404_url ) . to eq ( custom_404 )
285
+ end
286
+ end
287
+ end
288
+
289
+ describe '#get_module_uri' do
290
+ let ( :exploit_receiver_page ) do
291
+ 'exploit_receiver_page'
292
+ end
293
+
294
+ before ( :each ) do
295
+ subject . instance_variable_set ( :@exploit_receiver_page , exploit_receiver_page )
296
+ allow ( subject ) . to receive ( :get_uri ) . and_return ( '' )
297
+ end
298
+
299
+ it 'returns a module URI' do
300
+ expect ( subject . get_module_uri ) . to include ( exploit_receiver_page )
301
+ end
302
+ end
303
+
304
+ describe '#try_set_target' do
305
+ let ( :aux_mod ) do
306
+ mod = Msf ::Auxiliary . allocate
307
+ mod . extend described_class
308
+ mod . send ( :initialize )
309
+ mod
310
+ end
311
+
312
+ let ( :target_options ) do
313
+ { ua_name : 'Firefox' }
314
+ end
315
+
316
+ let ( :target ) do
317
+ t = double ( 'target' )
318
+ allow ( t ) . to receive ( :opts ) . and_return ( target_options )
319
+ t
320
+ end
321
+
322
+ let ( :default_auto_target ) do
323
+ # The default auto target is always the first on the list.
324
+ # In a module this would be the "Automatic" target.
325
+ t = double ( 'target' )
326
+ allow ( t ) . to receive ( :opts ) . and_return ( { } )
327
+ t
328
+ end
329
+
330
+ let ( :targets ) do
331
+ [ default_auto_target , target ]
332
+ end
333
+
334
+ context 'when an auxiliary uses BES' do
335
+ it 'returns nil' do
336
+ expect ( aux_mod . try_set_target ( first_profile_info ) ) . to be_nil
337
+ end
338
+ end
339
+
340
+ context 'when an exploit uses BES' do
341
+ it 'sets the instance variable @target' do
342
+ expect ( subject . instance_variable_get ( :@target ) ) . to be_nil
343
+ allow ( subject ) . to receive ( :targets ) . and_return ( targets )
344
+ subject . try_set_target ( first_profile_info )
345
+ expect ( subject . instance_variable_get ( :@target ) ) . to eq ( target )
346
+ end
347
+ end
348
+ end
349
+
350
+ skip '#get_bad_requirements' do
351
+ end
352
+
353
+ skip '#process_browser_info' do
354
+ end
355
+
356
+ skip '#has_proxy?' do
357
+ end
358
+
359
+ skip '#cookie_name' do
360
+ end
361
+
362
+ skip '#cookie_header' do
363
+ end
364
+
365
+ skip '#send_exploit_html' do
366
+ end
367
+
368
+ skip '#send_not_found' do
369
+ end
370
+
371
+ skip '#js_vuln_test' do
372
+ end
373
+
263
374
end
375
+
0 commit comments