Skip to content

Commit 7acba69

Browse files
author
Brent Cook
committed
Land rapid7#6577, add controls for Android ringer
2 parents 89b0c8a + 1427887 commit 7acba69

File tree

5 files changed

+46
-7
lines changed

5 files changed

+46
-7
lines changed

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ PATH
1313
metasploit-concern (= 1.0.0)
1414
metasploit-credential (= 1.0.1)
1515
metasploit-model (= 1.0.0)
16-
metasploit-payloads (= 1.1.0)
16+
metasploit-payloads (= 1.1.1)
1717
metasploit_data_models (= 1.2.10)
1818
msgpack
1919
network_interface (~> 0.0.1)
@@ -124,7 +124,7 @@ GEM
124124
activemodel (>= 4.0.9, < 4.1.0)
125125
activesupport (>= 4.0.9, < 4.1.0)
126126
railties (>= 4.0.9, < 4.1.0)
127-
metasploit-payloads (1.1.0)
127+
metasploit-payloads (1.1.1)
128128
metasploit_data_models (1.2.10)
129129
activerecord (>= 4.0.9, < 4.1.0)
130130
activesupport (>= 4.0.9, < 4.1.0)

lib/rex/post/meterpreter/extensions/android/android.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ def device_shutdown(n)
7171
response = client.send_request(request)
7272
response.get_tlv(TLV_TYPE_SHUTDOWN_OK).value
7373
end
74+
75+
def set_audio_mode(n)
76+
request = Packet.create_request('set_audio_mode')
77+
request.add_tlv(TLV_TYPE_AUDIO_MODE, n)
78+
response = client.send_request(request)
79+
end
7480

7581
def interval_collect(opts)
7682
request = Packet.create_request('interval_collect')

lib/rex/post/meterpreter/extensions/android/tlv.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ module Android
7575
TLV_TYPE_CELL_BASE_LONG = TLV_META_TYPE_UINT | (TLV_EXTENSIONS + 9072)
7676
TLV_TYPE_CELL_NET_ID = TLV_META_TYPE_UINT | (TLV_EXTENSIONS + 9073)
7777
TLV_TYPE_CELL_SYSTEM_ID = TLV_META_TYPE_UINT | (TLV_EXTENSIONS + 9074)
78+
TLV_TYPE_AUDIO_MODE = TLV_META_TYPE_UINT | (TLV_EXTENSIONS + 9075)
7879

7980
TLV_TYPE_URI_STRING = TLV_META_TYPE_STRING | (TLV_EXTENSIONS + 9101)
8081
TLV_TYPE_ACTIVITY_START_RESULT = TLV_META_TYPE_BOOL | (TLV_EXTENSIONS + 9102)

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

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ def commands
3030
'send_sms' => 'Sends SMS from target session',
3131
'wlan_geolocate' => 'Get current lat-long using WLAN information',
3232
'interval_collect' => 'Manage interval collection capabilities',
33-
'activity_start' => 'Start an Android activity from a Uri string'
33+
'activity_start' => 'Start an Android activity from a Uri string',
34+
'set_audio_mode' => 'Set Ringer Mode'
3435
}
3536

3637
reqs = {
@@ -43,7 +44,8 @@ def commands
4344
'send_sms' => ['send_sms'],
4445
'wlan_geolocate' => ['wlan_geolocate'],
4546
'interval_collect' => ['interval_collect'],
46-
'activity_start' => ['activity_start']
47+
'activity_start' => ['activity_start'],
48+
'set_audio_mode' => ['set_audio_mode']
4749
}
4850

4951
# Ensure any requirements of the command are met
@@ -153,6 +155,36 @@ def cmd_device_shutdown(*args)
153155
end
154156
end
155157

158+
def cmd_set_audio_mode(*args)
159+
help = false
160+
mode = 1
161+
set_audio_mode_opts = Rex::Parser::Arguments.new(
162+
'-h' => [ false, "Help Banner" ],
163+
'-m' => [ true, "Set Mode - (0 - Off, 1 - Normal, 2 - Max) (Default: '#{mode}')"]
164+
)
165+
166+
set_audio_mode_opts.parse(args) do |opt, _idx, val|
167+
case opt
168+
when '-h'
169+
help = true
170+
when '-m'
171+
mode = val.to_i
172+
else
173+
help = true
174+
end
175+
end
176+
177+
if help || mode < 0 || mode > 2
178+
print_line('Usage: set_audio_mode [options]')
179+
print_line('Set Ringer mode.')
180+
print_line(set_audio_mode_opts.usage)
181+
return
182+
end
183+
184+
client.android.set_audio_mode(mode)
185+
print_status("Ringer mode was changed to #{mode}!")
186+
end
187+
156188
def cmd_dump_sms(*args)
157189
path = "sms_dump_#{Time.new.strftime('%Y%m%d%H%M%S')}.txt"
158190
dump_sms_opts = Rex::Parser::Arguments.new(
@@ -536,7 +568,7 @@ def cmd_activity_start(*args)
536568
print_line("Start an Android activity from a uri")
537569
return
538570
end
539-
571+
540572
uri = args[0]
541573
result = client.android.activity_start(uri)
542574
if result.nil?
@@ -545,7 +577,7 @@ def cmd_activity_start(*args)
545577
print_error("Error: #{result}")
546578
end
547579
end
548-
580+
549581
#
550582
# Name for this dispatcher
551583
#

metasploit-framework.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Gem::Specification.new do |spec|
7070
# are needed when there's no database
7171
spec.add_runtime_dependency 'metasploit-model', '1.0.0'
7272
# Needed for Meterpreter
73-
spec.add_runtime_dependency 'metasploit-payloads', '1.1.0'
73+
spec.add_runtime_dependency 'metasploit-payloads', '1.1.1'
7474
# Needed by msfgui and other rpc components
7575
spec.add_runtime_dependency 'msgpack'
7676
# get list of network interfaces, like eth* from OS.

0 commit comments

Comments
 (0)