Git Bomb
Gitのレポジトリをアップロードするとcommitをしてくれるサービスの情報と、
ファイル gcaas.zip
および prepare-git-repo.sh
が与えられた。
このサービスは、以下の手順で利用が可能である。
- 適当なディレクトリを用意し、
git init
コマンドでGitレポジトリにする。
- このディレクトリ内に適当なファイルを用意し、
git add
コマンドでステージングする。
- このディレクトリの中身全て (
.git
ディレクトリを含む) を7-Zipでtar.gz
アーカイブにする。
この時、このディレクトリ自体はアーカイブに入れず、.git
ディレクトリなどがアーカイブのルートに配置されるようにする。
- 作成したアーカイブファイルを以下のHTMLからサービスに送信する。
Information about a service that makes a commit to uploaded Git repositories,
and files gcaas.zip
and prepare-git-repo.sh
were given.
We can use this service by these steps:
- Create a directory and make the directory a Git repository via
git init
command.
- Create a file in the directory and stage the file via
git add
command.
- Put all contents (including the
.git
directory) of the directory into a tar.gz
archive using 7-Zip.
Note that the directory itself shouldn't put into the archive, and that things like the .git
directory should be placed in the root of the archive.
- Send the archive file via this HTML:
send.html
アーカイブファイルをサービスに送信すると、処理結果の標準出力と標準エラー出力の内容が返される。
問題文より、flagは /flag
にあるということなので、以下の内容をレポジトリ内の .git/hooks/pre-commit
ファイルに保存し、
同様にレポジトリのアーカイブを作成して送信した。
Sending archive files to the service, what is printed to the standard output and standard error in the process are returned.
As the flag is in /flag
according to the challenge description, I put following contents to the .git/hooks/pre-commit
file in the repository,
created an archive of the repository in the same way, and sent the archive.
pre-commit
すると、標準エラー出力の内容としてflagが得られた。
As a result, the flag was returned as the standard error.
sdctf{4lw4y5_Us3_GIT_cl0nE_n3v3R_sn3ak_R3P0}
writeup by MikeCAT
San Diego CTF 2022