Files
metasploit-gs/lib/msf/core/post/android/priv.rb
T

35 lines
567 B
Ruby
Raw Normal View History

2015-08-24 18:37:25 -05:00
# -*- 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
2015-09-03 01:10:13 -05:00
if /^0$/ === uid
2015-08-24 18:37:25 -05:00
return true
else
return false
end
end
private
def get_id
cmd_exec('id')
end
end ; end ; end ; end