Module: Msf::Post::Solaris::Priv

Includes:
Common
Defined in:
lib/msf/core/post/solaris/priv.rb

Instance Method Summary collapse

Methods included from Common

#clear_screen, #cmd_exec, #cmd_exec_get_pid, #command_exists?, #get_env, #get_envs, #has_pid?, #peer, #report_virtualization, #rhost, #rport

Instance Method Details

#is_root?Boolean

Returns true if running as root, false if not.

Returns:

  • (Boolean)

12
13
14
15
16
17
18
19
# File 'lib/msf/core/post/solaris/priv.rb', line 12

def is_root?
  user_id = cmd_exec("/usr/xpg4/bin/id -u")
  clean_user_id = user_id.to_s.gsub(/[^\d]/, '')
  if clean_user_id.empty?
    raise "Could not determine UID: #{user_id.inspect}"
  end
  (clean_user_id == '0')
end