23 - Pentesting Telnet

Tip

AWS ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ:HackTricks Training AWS Red Team Expert (ARTE)
GCP ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ: HackTricks Training GCP Red Team Expert (GRTE) Azure ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks ์ง€์›ํ•˜๊ธฐ

๊ธฐ๋ณธ ์ •๋ณด

Telnet์€ ๋„คํŠธ์›Œํฌ๋ฅผ ํ†ตํ•ด ์‚ฌ์šฉ์ž๊ฐ€ ์ปดํ“จํ„ฐ์— ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•ด์ฃผ๋Š” ์•ˆ์ „ํ•˜์ง€ ์•Š์€ ๋„คํŠธ์›Œํฌ ํ”„๋กœํ† ์ฝœ์ž…๋‹ˆ๋‹ค.

๊ธฐ๋ณธ ํฌํŠธ: 23

23/tcp open  telnet

Enumeration

nc -vn <IP> 23

๋ชจ๋“  ํฅ๋ฏธ๋กœ์šด enumeration์€ nmap์œผ๋กœ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

nmap -n -sV -Pn --script "*telnet* and safe" -p 23 <IP>

The script telnet-ntlm-info.nse will obtain NTLM info (Windows versions).

From the telnet RFC: In the TELNET Protocol are various โ€œ์˜ต์…˜โ€ that will be sanctioned and may be used with the โ€œDO, DONโ€™T, WILL, WONโ€™Tโ€ structure to allow a user and server to agree to use a more elaborate (or perhaps just different) set of conventions for their TELNET connection. Such options could include changing the character set, the echo mode, etc.

์ด ์˜ต์…˜๋“ค์„ ์—ด๊ฑฐํ•  ์ˆ˜ ์žˆ๋‹ค๋Š” ๊ฒƒ์€ ์•Œ๊ณ  ์žˆ์œผ๋‚˜ ๋ฐฉ๋ฒ•์„ ๋ชจ๋ฅด๊ฒ ์Šต๋‹ˆ๋‹ค. ๋ฐฉ๋ฒ•์„ ์•„์‹œ๋ฉด ์•Œ๋ ค์ฃผ์„ธ์š”.

Telnet ์˜ต์…˜ / ๊ธฐ๋Šฅ ์—ด๊ฑฐ

Telnet uses IAC + DO/DONT/WILL/WONT negotiations to enable options. You can observe supported options by capturing the initial negotiation and by probing for specific features.

Nmap ์˜ต์…˜/๊ธฐ๋Šฅ ํ”„๋กœ๋ธŒ

# Detect support for the Telnet ENCRYPT option
nmap -p 23 --script telnet-encryption <IP>

# Enumerate Microsoft Telnet NTLM info (NetBIOS/DNS/OS build)
nmap -p 23 --script telnet-ntlm-info <IP>

# Brute-force via NSE (alternative to Hydra/Medusa)
nmap -p 23 --script telnet-brute --script-args userdb=users.txt,passdb=pass.txt <IP>

telnet-encryption ์Šคํฌ๋ฆฝํŠธ๋Š” ENCRYPT ์˜ต์…˜์„ ์ง€์›ํ•˜๋Š”์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค; ์ผ๋ถ€ ๊ตฌํ˜„์ฒด๋Š” ๊ณผ๊ฑฐ์— ์ด ์˜ต์…˜์„ ์ž˜๋ชป ์ฒ˜๋ฆฌํ•ด ์ทจ์•ฝํ–ˆ์œผ๋‚˜, ์ด ์Šคํฌ๋ฆฝํŠธ๋Š” ์ง€์› ์—ฌ๋ถ€๋งŒ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค. telnet-ntlm-info๋Š” Microsoft Telnet NTLM์ด ํ™œ์„ฑํ™”๋œ ๊ฒฝ์šฐ NTLM ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ(NetBIOS/DNS/OS build)๋ฅผ ๋…ธ์ถœํ•ฉ๋‹ˆ๋‹ค. telnet-brute๋Š” Telnet์„ ์œ„ํ•œ NSE brute-force ๊ฐ์‚ฌ๊ธฐ์ž…๋‹ˆ๋‹ค.

Brute force

์„ค์ • ํŒŒ์ผ

/etc/inetd.conf
/etc/xinetd.d/telnet
/etc/xinetd.d/stelnet

HackTricks ์ž๋™ ๋ช…๋ น์–ด

Protocol_Name: Telnet    #Protocol Abbreviation if there is one.
Port_Number:  23     #Comma separated if there is more than one.
Protocol_Description: Telnet          #Protocol Abbreviation Spelled out

Entry_1:
Name: Notes
Description: Notes for t=Telnet
Note: |
wireshark to hear creds being passed
tcp.port == 23 and ip.addr != myip

https://book.hacktricks.wiki/en/network-services-pentesting/pentesting-telnet.html

Entry_2:
Name: Banner Grab
Description: Grab Telnet Banner
Command: nc -vn {IP} 23

Entry_3:
Name: Nmap with scripts
Description: Run nmap scripts for telnet
Command: nmap -n -sV -Pn --script "*telnet*" -p 23 {IP}

Entry_4:
Name: consoleless mfs enumeration
Description: Telnet enumeration without the need to run msfconsole
Note: sourced from https://github.com/carlospolop/legion
Command: msfconsole -q -x 'use auxiliary/scanner/telnet/telnet_version; set RHOSTS {IP}; set RPORT 23; run; exit' && msfconsole -q -x 'use auxiliary/scanner/telnet/brocade_enable_login; set RHOSTS {IP}; set RPORT 23; run; exit' && msfconsole -q -x 'use auxiliary/scanner/telnet/telnet_encrypt_overflow; set RHOSTS {IP}; set RPORT 23; run; exit' && msfconsole -q -x 'use auxiliary/scanner/telnet/telnet_ruggedcom; set RHOSTS {IP}; set RPORT 23; run; exit'

Recent Vulnerabilities (2022-2026)

  • CVE-2024-45698 โ€“ D-Link Wi-Fi 6 routers (DIR-X4860): telnet ์„œ๋น„์Šค์˜ ์ž…๋ ฅ ๊ฒ€์ฆ ๋ถ€์žฌ๋กœ ์›๊ฒฉ ๊ณต๊ฒฉ์ž๊ฐ€ ํ•˜๋“œ์ฝ”๋”ฉ๋œ ์ž๊ฒฉ์ฆ๋ช…์„ ์‚ฌ์šฉํ•ด ๋กœ๊ทธ์ธํ•˜๊ณ  OS ๋ช…๋ น์„ ์ฃผ์ž…ํ•  ์ˆ˜ ์žˆ์Œ; ํŽŒ์›จ์–ด 1.04B05 ์ด์ƒ์œผ๋กœ ์ˆ˜์ •๋จ.
  • CVE-2023-40478 โ€“ NETGEAR RAX30: Telnet CLI passwd ๋ช…๋ น์˜ ์Šคํƒ ๊ธฐ๋ฐ˜ ๋ฒ„ํผ ์˜ค๋ฒ„ํ”Œ๋กœ์šฐ๋กœ ๋„คํŠธ์›Œํฌ ์ธ์ ‘ ํ™˜๊ฒฝ์—์„œ root๋กœ์„œ์˜ code execution์ด ๊ฐ€๋Šฅํ•ด์ง; ์ธ์ฆ์ด ํ•„์š”ํ•˜์ง€๋งŒ ์šฐํšŒ๋  ์ˆ˜ ์žˆ์Œ.
  • CVE-2022-39028 โ€“ GNU inetutils telnetd: ๋‘ ๋ฐ”์ดํŠธ ์‹œํ€€์Šค (0xff 0xf7 / 0xff 0xf8)๊ฐ€ telnetd์—์„œ NULL-pointer dereference๋ฅผ ์œ ๋ฐœํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ, ๋ฐ˜๋ณต์ ์ธ ํฌ๋ž˜์‹œ๋Š” inetd๊ฐ€ ์„œ๋น„์Šค๋ฅผ ๋น„ํ™œ์„ฑํ™”ํ•˜๊ฒŒ ๋งŒ๋“ค์–ด DoS๋ฅผ ์ดˆ๋ž˜ํ•  ์ˆ˜ ์žˆ์Œ.

์ทจ์•ฝ์  ๋ถ„๋ฅ˜(vulnerability triage) ์‹œ ์ด๋Ÿฌํ•œ CVE๋“ค์„ ์—ผ๋‘์— ๋‘์–ด๋ผ โ€” ๋Œ€์ƒ์ด ํŒจ์น˜๋˜์ง€ ์•Š์€ ํŽŒ์›จ์–ด๋‚˜ ๋ ˆ๊ฑฐ์‹œ inetutils Telnet daemon์„ ์‹คํ–‰ ์ค‘์ด๋ผ๋ฉด ๋น„๊ต์  ์ง์„ ์ ์ธ code-execution ๊ฒฝ๋กœ ๋˜๋Š” ํŒŒ๊ดด์ ์ธ DoS๋กœ ์ด์–ด์งˆ ์ˆ˜ ์žˆ๋‹ค.

CVE-2026-24061 โ€” GNU Inetutils telnetd auth bypass (Critical)

Summary: telnetd in GNU Inetutils through 2.7 allows remote authentication bypass via a USER environment variable value of -f root, resulting in unauthenticated root access.
Root cause: argument injection (CWE-88) because telnetd forwards the client-supplied USER environment variable to login without sanitization.
Scope: GNU Inetutils telnetd versions 1.9.3โ€“2.7 are affected (published January 21, 2026).

Mitigations

  • Patch/upgrade affected packages immediately (e.g., Debian fixes are in 2:2.4-2+deb12u2, 2:2.6-3+deb13u1, and 2:2.7-2).
  • Disable Telnet or restrict access to trusted management networks while patching.

Sniffing Credentials & Man-in-the-Middle

Telnet์€ ๋ชจ๋“  ๊ฒƒ์„, credentials๋ฅผ ํฌํ•จํ•ด, clear-text๋กœ ์ „์†กํ•ฉ๋‹ˆ๋‹ค. ์ด๋“ค์„ ์บก์ฒ˜ํ•˜๋Š” ๋‘ ๊ฐ€์ง€ ๋น ๋ฅธ ๋ฐฉ๋ฒ•:

# Live capture with tcpdump (print ASCII)
sudo tcpdump -i eth0 -A 'tcp port 23 and not src host $(hostname -I | cut -d" " -f1)'

# Wireshark display filter
tcp.port == 23 && (telnet.data || telnet.option)

๋Šฅ๋™์  MITM์˜ ๊ฒฝ์šฐ ARP spoofing(์˜ˆ: arpspoof/ettercap)๊ณผ ๋™์ผํ•œ sniffing filters๋ฅผ ๊ฒฐํ•ฉํ•ด ์Šค์œ„์น˜ ๊ธฐ๋ฐ˜ ๋„คํŠธ์›Œํฌ์—์„œ passwords๋ฅผ ์ˆ˜์ง‘ํ•˜์„ธ์š”.

Automated Brute-force / Password Spraying

# Hydra (stop at first valid login)
hydra -L users.txt -P rockyou.txt -t 4 -f telnet://<IP>

# Ncrack (drop to interactive session on success)
ncrack -p 23 --user admin -P common-pass.txt --connection-limit 4 <IP>

# Medusa (parallel hosts)
medusa -M telnet -h targets.txt -U users.txt -P passwords.txt -t 6 -f

Most IoT botnets (Mirai variants) still scan port 23 with small default-credential dictionariesโ€”mirroring that logic can quickly identify weak devices.

Exploitation & Post-Exploitation

Metasploit์—๋Š” ๋ช‡ ๊ฐ€์ง€ ์œ ์šฉํ•œ ๋ชจ๋“ˆ์ด ์žˆ์Šต๋‹ˆ๋‹ค:

  • auxiliary/scanner/telnet/telnet_version โ€“ ๋ฐฐ๋„ˆ ๋ฐ ์˜ต์…˜ ์—ด๊ฑฐ.
  • auxiliary/scanner/telnet/brute_telnet โ€“ ๋ฉ€ํ‹ฐ์Šค๋ ˆ๋“œ ๋ธŒ๋ฃจํŠธํฌ์Šค.
  • auxiliary/scanner/telnet/telnet_encrypt_overflow โ€“ ์ทจ์•ฝํ•œ Solaris 9/10 Telnet์— ๋Œ€ํ•œ RCE (ENCRYPT ์˜ต์…˜ ์ฒ˜๋ฆฌ ๊ด€๋ จ).
  • exploit/linux/mips/netgear_telnetenable โ€“ ๋งŽ์€ NETGEAR ๋ผ์šฐํ„ฐ์—์„œ ์กฐ์ž‘๋œ ํŒจํ‚ท์œผ๋กœ telnet ์„œ๋น„์Šค๋ฅผ ํ™œ์„ฑํ™”ํ•ฉ๋‹ˆ๋‹ค.

์‰˜์„ ์–ป์€ ํ›„์—๋Š” TTYs are usually dumb์„ ๊ธฐ์–ตํ•˜์„ธ์š”; python -c 'import pty;pty.spawn("/bin/bash")'๋กœ ์—…๊ทธ๋ ˆ์ด๋“œํ•˜๊ฑฐ๋‚˜ HackTricks TTY tricks๋ฅผ ์‚ฌ์šฉํ•˜์„ธ์š”.

Hardening & Detection (Blue team corner)

  1. SSH๋ฅผ ์šฐ์„  ์‚ฌ์šฉํ•˜๊ณ  Telnet ์„œ๋น„์Šค๋ฅผ ์™„์ „ํžˆ ๋น„ํ™œ์„ฑํ™”ํ•˜์„ธ์š”.
  2. Telnet์ด ํ•„์š”ํ•œ ๊ฒฝ์šฐ ๊ด€๋ฆฌ VLAN์—๋งŒ ๋ฐ”์ธ๋”ฉํ•˜๊ณ , ACL์„ ์ ์šฉํ•˜๋ฉฐ ๋ฐ๋ชฌ์„ TCP wrappers(/etc/hosts.allow)๋กœ ๊ฐ์‹ธ์„ธ์š”.
  3. ๋ ˆ๊ฑฐ์‹œ telnetd ๊ตฌํ˜„์„ ssl-telnet ๋˜๋Š” telnetd-ssl๋กœ ๊ต์ฒดํ•˜์—ฌ ์ „์†ก ์•”ํ˜ธํ™”๋ฅผ ์ถ”๊ฐ€ํ•˜์„ธ์š”. ๊ทธ๋Ÿฌ๋‚˜ ์ด๊ฒƒ์€ ์ „์†ก ์ค‘ ๋ฐ์ดํ„ฐ๋งŒ ๋ณดํ˜ธํ•  ๋ฟโ€”๋น„๋ฐ€๋ฒˆํ˜ธ ์ถ”์ธก์€ ์—ฌ์ „ํžˆ ์‰ฝ๊ฒŒ ์„ฑ๊ณตํ•ฉ๋‹ˆ๋‹ค.
  4. ํฌํŠธ 23์œผ๋กœ์˜ ์•„์›ƒ๋ฐ”์šด๋“œ ํŠธ๋ž˜ํ”ฝ์„ ๋ชจ๋‹ˆํ„ฐ๋งํ•˜์„ธ์š”; ์นจํ•ด๋œ ์žฅ์น˜๋Š” ์—„๊ฒฉํ•œ HTTP ์ด๊ทธ๋ ˆ์Šค ํ•„ํ„ฐ๋ฅผ ์šฐํšŒํ•˜๊ธฐ ์œ„ํ•ด ์ข…์ข… Telnet์„ ํ†ตํ•œ ๋ฆฌ๋ฒ„์Šค ์…ธ์„ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.

References

  • D-Link Advisory โ€“ CVE-2024-45698 Critical Telnet RCE.
  • NVD โ€“ CVE-2022-39028 inetutils telnetd DoS.
  • NVD โ€“ CVE-2026-24061.
  • Canadian Centre for Cyber Security Alert AL26-002 (CVE-2026-24061).
  • Debian Security Tracker โ€“ CVE-2026-24061 fixed versions.

Tip

AWS ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ:HackTricks Training AWS Red Team Expert (ARTE)
GCP ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ: HackTricks Training GCP Red Team Expert (GRTE) Azure ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks ์ง€์›ํ•˜๊ธฐ