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をサポートする
- サブスクリプションプランを確認してください!
- **💬 Discordグループまたはテレグラムグループに参加するか、Twitter 🐦 @hacktricks_liveをフォローしてください。
- HackTricksおよびHackTricks CloudのGitHubリポジトリにPRを提出してハッキングトリックを共有してください。
基本情報
Telnetは、ユーザーがネットワーク経由でコンピュータにアクセスするための安全でないプロトコルです。
デフォルトポート: 23
23/tcp open telnet
列挙
バナーグラビング
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>
The telnet-encryption script checks whether the ENCRYPT option is supported; some implementations historically handled this option incorrectly and were vulnerable, but the script only checks support.
telnet-ntlm-info discloses NTLM metadata (NetBIOS/DNS/OS build) when Microsoft Telnet NTLM is enabled.
telnet-brute is an NSE brute-force auditor for Telnet.
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としてのコード実行が可能に。認証は必要だが回避可能。 - CVE-2022-39028 – GNU inetutils telnetd: 2バイトシーケンス(
0xff 0xf7/0xff 0xf8)がtelnetdで NULLポインタ参照 を引き起こし、繰り返しクラッシュさせると inetd がサービスを無効化してしまう(DoS)。
脆弱性トリアージ時にはこれらのCVEを念頭に置くこと。ターゲットが未修正のファームウェアや古い inetutils の Telnet デーモンを実行している場合、直接的なコード実行や破壊的な 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, and2:2.7-2). - Disable Telnet or restrict access to trusted management networks while patching.
Sniffing Credentials & Man-in-the-Middle
Telnet transmits everything, including credentials, in clear-text. Two quick ways to capture them:
# 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 を組み合わせ、スイッチングされたネットワーク上でパスワードを収集します。
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
ほとんどの IoT ボットネット (Mirai variants) は依然として小さなデフォルト認証情報辞書でポート 23 をスキャンします — そのロジックを模倣することで脆弱なデバイスを素早く特定できます。
エクスプロイトとポストエクスプロイテーション
Metasploit にはいくつか有用なモジュールがあります:
auxiliary/scanner/telnet/telnet_version– バナーおよびオプションの列挙。auxiliary/scanner/telnet/brute_telnet– マルチスレッドのブルートフォース。auxiliary/scanner/telnet/telnet_encrypt_overflow– ENCRYPT オプション処理に脆弱な Solaris 9/10 Telnet に対する RCE。exploit/linux/mips/netgear_telnetenable– 多くの NETGEAR ルータで細工したパケットを用いて telnet サービスを有効化する。
シェルを取得したら、TTY は通常単純(dumb)です。python -c 'import pty;pty.spawn("/bin/bash")' でアップグレードするか、HackTricks TTY tricks を利用してください。
Hardening & Detection (Blue team corner)
- SSH を優先し、Telnet サービスは完全に無効化する。
- Telnet が必要な場合は、管理 VLAN のみでバインドし、ACL を適用し、デーモンを TCP wrappers(
/etc/hosts.allow)でラップする。 - レガシーな
telnetd実装はssl-telnetまたはtelnetd-sslに置き換えてトランスポート暗号化を追加する。ただし、これはデータの転送保護のみであり、パスワード推測が容易であることに変わりはない。 - ポート 23 へのアウトバウンド通信を監視する。侵害されたデバイスはしばしば Telnet 経由でリバースシェルを生成し、厳格な HTTP イーグレスフィルタを回避する。
参考資料
- D-Link Advisory – CVE-2024-45698(重大な Telnet RCE)。
- NVD – CVE-2022-39028 inetutils の
telnetdDoS。 - NVD – CVE-2026-24061。
- Canadian Centre for Cyber Security Alert AL26-002 (CVE-2026-24061)。
- Debian Security Tracker – CVE-2026-24061 の修正済みバージョン。
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をサポートする
- サブスクリプションプランを確認してください!
- **💬 Discordグループまたはテレグラムグループに参加するか、Twitter 🐦 @hacktricks_liveをフォローしてください。
- HackTricksおよびHackTricks CloudのGitHubリポジトリにPRを提出してハッキングトリックを共有してください。


