diff --git a/Gemfile.lock b/Gemfile.lock index cbbf9398aa..aeb9d12d1e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -9,7 +9,7 @@ PATH json metasploit-concern (= 1.0.0) metasploit-model (= 1.0.0) - metasploit-payloads (= 1.0.11) + metasploit-payloads (= 1.0.12) msgpack nokogiri packetfu (= 1.1.9) @@ -123,7 +123,7 @@ GEM activemodel (>= 4.0.9, < 4.1.0) activesupport (>= 4.0.9, < 4.1.0) railties (>= 4.0.9, < 4.1.0) - metasploit-payloads (1.0.11) + metasploit-payloads (1.0.12) metasploit_data_models (1.2.5) activerecord (>= 4.0.9, < 4.1.0) activesupport (>= 4.0.9, < 4.1.0) diff --git a/lib/msf/core/post/android.rb b/lib/msf/core/post/android.rb new file mode 100644 index 0000000000..dbe96e2d53 --- /dev/null +++ b/lib/msf/core/post/android.rb @@ -0,0 +1,8 @@ +# -*- coding: binary -*- + +module Msf::Post::Android + + require 'msf/core/post/android/system' + require 'msf/core/post/android/priv' + +end diff --git a/lib/msf/core/post/android/priv.rb b/lib/msf/core/post/android/priv.rb new file mode 100644 index 0000000000..42d4bc09e4 --- /dev/null +++ b/lib/msf/core/post/android/priv.rb @@ -0,0 +1,35 @@ +# -*- coding: binary -*- + +require 'msf/core/post/common' +require 'msf/core/post/file' +require 'msf/core/post/unix' + +module Msf +class Post +module Android +module Priv + + include Msf::Post::Common + + public + + # Returns whether we are running as root or not. + # + # @return [Boolean] TrueClass if as root, otherwise FalseClass. + def is_root? + id = cmd_exec('id') + uid = id.scan(/uid=(\d+)(.+)/).flatten.first + if /^0$/ === uid + return true + else + return false + end + end + + private + + def get_id + cmd_exec('id') + end + +end ; end ; end ; end \ No newline at end of file diff --git a/lib/msf/core/post/android/system.rb b/lib/msf/core/post/android/system.rb new file mode 100644 index 0000000000..38f1afe4f1 --- /dev/null +++ b/lib/msf/core/post/android/system.rb @@ -0,0 +1,31 @@ +# -*- coding: binary -*- + +require 'msf/core/post/common' +require 'msf/core/post/file' +require 'msf/core/post/unix' + +module Msf +class Post +module Android +module System + + include Msf::Post::Common + include Msf::Post::File + + # Returns system information from build.prop. + # + # @return [Hash] System information. + def get_build_prop + sys_data = {} + build_prop = cmd_exec('cat /system/build.prop') + + return sys_data if build_prop.blank? + + build_prop.scan(/(.+)=(.+)/i).collect {|e| Hash[*e]}.each do |setting| + sys_data.merge!(setting) + end + + return sys_data + end + +end ; end ; end ; end \ No newline at end of file diff --git a/metasploit-framework.gemspec b/metasploit-framework.gemspec index 718c9c274b..3ef681604f 100644 --- a/metasploit-framework.gemspec +++ b/metasploit-framework.gemspec @@ -61,7 +61,7 @@ Gem::Specification.new do |spec| # are needed when there's no database spec.add_runtime_dependency 'metasploit-model', '1.0.0' # Needed for Meterpreter - spec.add_runtime_dependency 'metasploit-payloads', '1.0.11' + spec.add_runtime_dependency 'metasploit-payloads', '1.0.12' # Needed by msfgui and other rpc components spec.add_runtime_dependency 'msgpack' # Needed by anemone crawler diff --git a/spec/lib/msf/core/post/android/priv_spec.rb b/spec/lib/msf/core/post/android/priv_spec.rb new file mode 100644 index 0000000000..527d58a03c --- /dev/null +++ b/spec/lib/msf/core/post/android/priv_spec.rb @@ -0,0 +1,37 @@ +# -*- coding: binary -*- + +require 'msf/core/post/android/priv' + +describe Msf::Post::Android::Priv do + + subject do + mod = Module.new + mod.extend(described_class) + mod + end + + let(:nonroot_id) do + %Q|uid=10043(u0_a43) gid=10043(u0_a43) groups=1006(camera),1015(sdcard_rw),1028(sdcard_r),3003(inet)| + end + + let(:root_id) do + %Q|uid=0(0)| + end + + describe '#is_root?' do + context 'when not root' do + it 'returns FalseClass' do + allow(subject).to receive(:cmd_exec).with('id').and_return(nonroot_id) + expect(subject.is_root?).to be_falsey + end + end + + context 'when root' do + it 'returns TrueClass' do + allow(subject).to receive(:cmd_exec).with('id').and_return(root_id) + expect(subject.is_root?).to be_truthy + end + end + end + +end diff --git a/spec/lib/msf/core/post/android/system_spec.rb b/spec/lib/msf/core/post/android/system_spec.rb new file mode 100644 index 0000000000..e24bc0cbf0 --- /dev/null +++ b/spec/lib/msf/core/post/android/system_spec.rb @@ -0,0 +1,30 @@ +# -*- coding: binary -*- + +require 'msf/core/post/android/system' + +describe Msf::Post::Android::System do + + subject do + mod = Module.new + mod.extend(described_class) + mod + end + + let(:build_prop_output) do + %Q|ro.build.version.sdk=16 +ro.build.version.release=4.1.1 +| + end + + describe '#get_sysinfo' do + let(:expected_android_version) do + '4.1.1' + end + + it 'returns the android version' do + allow(subject).to receive(:cmd_exec).and_return(build_prop_output) + expect(subject.get_build_prop['ro.build.version.release']).to eq(expected_android_version) + end + end + +end