Path: blob/master/modules/auxiliary/scanner/http/caidao_bruteforce_login.rb
28052 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45require 'metasploit/framework/credential_collection'6require 'metasploit/framework/login_scanner/caidao'78class MetasploitModule < Msf::Auxiliary9include Msf::Exploit::Remote::HttpClient10include Msf::Auxiliary::Scanner11include Msf::Auxiliary::Report12include Msf::Auxiliary::AuthBrute1314def initialize(info = {})15super(16update_info(17info,18'Name' => 'Chinese Caidao Backdoor Bruteforce',19'Description' => 'This module attempts to bruteforce chinese caidao asp/php/aspx backdoor.',20'Author' => [ 'Nixawk' ],21'References' => [22['URL', 'https://www.fireeye.com/blog/threat-research/2013/08/breaking-down-the-china-chopper-web-shell-part-i.html'],23['URL', 'https://www.mandiant.com/resources/breaking-down-the-china-chopper-web-shell-part-ii'],24['URL', 'http://web.archive.org/web/20170214000632/https://www.exploit-db.com/docs/27654.pdf'],25['URL', 'https://www.cisa.gov/uscert/ncas/alerts/TA15-314A'],26['URL', 'http://blog.csdn.net/nixawk/article/details/40430329']27],28'License' => MSF_LICENSE,29'Notes' => {30'Reliability' => UNKNOWN_RELIABILITY,31'Stability' => UNKNOWN_STABILITY,32'SideEffects' => UNKNOWN_SIDE_EFFECTS33}34)35)3637register_options(38[39OptString.new('TARGETURI', [true, 'The URL that handles the login process', '/caidao.php']),40OptPath.new('PASS_FILE', [41false,42'The file that contains a list of of probable passwords.',43File.join(Msf::Config.install_root, 'data', 'wordlists', 'unix_passwords.txt')44])45]46)4748# caidao does not have an username, there's only password49deregister_options('HttpUsername', 'HttpPassword', 'USERNAME', 'USER_AS_PASS', 'USERPASS_FILE', 'USER_FILE', 'DB_ALL_USERS')50end5152def scanner(ip)53@scanner ||= lambda {54cred_collection = build_credential_collection(55# The LoginScanner API refuses to run if there's no username, so we give it a fake one.56# But we will not be reporting this to the database.57username: 'caidao',58password: datastore['PASSWORD']59)6061return Metasploit::Framework::LoginScanner::Caidao.new(62configure_http_login_scanner(63host: ip,64port: datastore['RPORT'],65uri: datastore['TARGETURI'],66cred_details: cred_collection,67stop_on_success: datastore['STOP_ON_SUCCESS'],68bruteforce_speed: datastore['BRUTEFORCE_SPEED'],69connection_timeout: 5,70http_username: datastore['HttpUsername'],71http_password: datastore['HttpPassword']72)73)74}.call75end7677def report_good_cred(ip, port, result)78service_data = {79address: ip,80port: port,81service_name: 'http',82protocol: 'tcp',83workspace_id: myworkspace_id84}8586credential_data = {87module_fullname: self.fullname,88origin_type: :service,89private_data: result.credential.private,90private_type: :password,91}.merge(service_data)9293login_data = {94core: create_credential(credential_data),95last_attempted_at: DateTime.now,96status: result.status,97proof: result.proof98}.merge(service_data)99100create_credential_login(login_data)101end102103def report_bad_cred(ip, rport, result)104invalidate_login(105address: ip,106port: rport,107protocol: 'tcp',108private: result.credential.private,109realm_key: result.credential.realm_key,110realm_value: result.credential.realm,111status: result.status,112proof: result.proof113)114end115116# Attempts to login117def bruteforce(ip)118scanner(ip).scan! do |result|119case result.status120when Metasploit::Model::Login::Status::SUCCESSFUL121print_brute(:level => :good, :ip => ip, :msg => "Success: '#{result.credential.private}'")122report_good_cred(ip, rport, result)123when Metasploit::Model::Login::Status::UNABLE_TO_CONNECT124vprint_brute(:level => :verror, :ip => ip, :msg => result.proof)125report_bad_cred(ip, rport, result)126when Metasploit::Model::Login::Status::INCORRECT127vprint_brute(:level => :verror, :ip => ip, :msg => "Failed: '#{result.credential.private}'")128report_bad_cred(ip, rport, result)129end130end131end132133def run_host(ip)134unless scanner(ip).check_setup135print_brute(:level => :error, :ip => ip, :msg => 'Backdoor type is not support')136return137end138139bruteforce(ip)140end141end142143144