File tree Expand file tree Collapse file tree 1 file changed +17
-6
lines changed
modules/post/android/manage Expand file tree Collapse file tree 1 file changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ class Metasploit4 < Msf::Post
9
9
Rank = NormalRanking
10
10
11
11
include Msf ::Post ::Common
12
+ include Msf ::Post ::Android ::System
12
13
13
14
def initialize ( info = { } )
14
15
super ( update_info ( info , {
@@ -39,15 +40,25 @@ def initialize(info={})
39
40
) )
40
41
end
41
42
42
- def run
43
- buildprop = cmd_exec ( 'cat /system/build.prop' )
43
+ def is_version_compat?
44
+ build_prop = get_build_prop
44
45
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
48
55
end
49
56
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?
51
62
print_error ( "This module is only compatible with Android versions 4.0 to 4.3" )
52
63
return
53
64
end
You can’t perform that action at this time.
0 commit comments