0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

HTB敗北日記 3 Admirer

Last updated at Posted at 2020-12-12

とりまautorecon

quick_tcp_nmap.txt
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
tcp_80_http_gobuster.txt
/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]
http//10.10.10.187/robots.txt
folder contains personal contacts and creds, so no one -not even robots- should see it - waldo
Disallow: /admin-dir

/admin-dirはForbidden
スクリーンショット 2020-12-12 112817.png

なのでGobusterをかけてみる
(wordlistは/usr/share/dirbuster/wordlists/directory-list-2.3-medium.txt)

gobuster
/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

消されたファイルには興味深い記述が

utility-scripts/db_admin.php
 // TODO: Finish implementing this or find a better open source alternative

別のOSSツールに切り替わっている可能性が高いと考えひたすらぐぐったところ、下記のページを発見。
https://www.guru99.com/top-20-sql-management-tools.html
スクリーンショット 2020-12-12 120851.png
名前が激似

utility-scripts/adminer.phpを発見
スクリーンショット 2020-12-12 121417.png

脆弱性も発見
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を持ってくる。

その中のクレデンシャルでSSHログイン。
スクリーンショット 2020-12-12 122754.png

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拾ってきて試したがダメだった。
スクリーンショット 2020-12-12 123904.png
試したもの:
https://github.com/jas502n/CVE-2019-13272
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=812512

他にeximも権限昇格可能な脆弱性を持つバージョンがあったがプロセスが動いてなかったりで攻撃できなかった。

結果

root奪取失敗

反省点

罠が多いBoxだったがほぼすべての罠にはまった気がする。
admin_tasks.phpにかける時間を減らしていたらもっとなんとかなったかも。
夢にまで出てくるし本当に最悪だった。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?