Skip to content

Commit 2036699

Browse files
author
Brent Cook
committed
Land rapid7#5937, use the Android mixin to get the Android version
2 parents 28685f0 + e9e4b60 commit 2036699

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

modules/post/android/manage/remove_lock.rb

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class Metasploit4 < Msf::Post
99
Rank = NormalRanking
1010

1111
include Msf::Post::Common
12+
include Msf::Post::Android::System
1213

1314
def initialize(info={})
1415
super( update_info( info, {
@@ -39,15 +40,25 @@ def initialize(info={})
3940
))
4041
end
4142

42-
def run
43-
buildprop = cmd_exec('cat /system/build.prop')
43+
def is_version_compat?
44+
build_prop = get_build_prop
4445

45-
if buildprop.blank?
46-
print_error("Blank build.prop, try again")
47-
return
46+
# Sometimes cmd_exec fails to cat build_prop, so the #get_build_prop method returns
47+
# empty.
48+
if build_prop.empty?
49+
fail_with(Failure::Unknown, 'Failed to retrieve build.prop, you might need to try again.')
50+
end
51+
52+
android_version = Gem::Version.new(build_prop['ro.build.version.release'])
53+
if android_version <= Gem::Version.new('4.3') && android_version >= Gem::Version.new('4.0')
54+
return true
4855
end
4956

50-
unless buildprop =~ /ro.build.version.release=4.[0|1|2|3]/
57+
false
58+
end
59+
60+
def run
61+
unless is_version_compat?
5162
print_error("This module is only compatible with Android versions 4.0 to 4.3")
5263
return
5364
end

0 commit comments

Comments
 (0)