1
0

More than 1 year has passed since last update.

【picoCTF 2023】Specialer Write-UP

Last updated at Posted at 2023-04-15

概要

picoCTF 2023出ましたー

結果は学生部門8位、高校生部門2位でした🥈
https://cognitivehack-jp.cognitivectf.com/

個人的に面白かった問題のWriteUpです。

image.png

Description

Reception of Special has been cool to say the least. That's why we made an exclusive version of Special, called Secure Comprehensive Interface for Affecting Linux Empirically Rad, or just 'Specialer'. With Specialer, we really tried to remove the distractions from using a shell. Yes, we took out spell checker because of everybody's complaining. But we think you will be excited about our new, reduced feature set for keeping you focused on what needs it the most. Please start an instance to test your very own copy of Specialer.

スペシャルのレセプションは、控えめに言ってもクールです。そのため、私たちは Special の専用バージョンを作成しました。これは、Linux に影響を与えるための Secure Comprehensive Interface for Affecting Empirically Rad、または単に「Specialer」と呼ばれます。 Specialer では、シェルの使用による気を散らすものを取り除こうとしました。 はい、皆さんから苦情があったため、スペル チェッカーを削除しました。 しかし、最も必要なものに集中できるように、機能を減らした新しい機能セットに興奮していただけると思います。 インスタンスを開始して、Specialer の独自のコピーをテストしてください。

Hint

What programs do you have access to?

どのコマンド使えますか?

アプローチ

Shellにログインすると、以下のようなコンソールが出てきます。
image.png

lscatなど普段使えるコマンドが使えません。

helpコマンドが使えました。
Bashの組み込みコマンドがすべて使えるようです。

Specialer$ help
GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu)
These shell commands are defined internally.  Type `help' to see this list.
Type `help name' to find out more about the function `name'.
Use `info bash' to find out more about the shell in general.
Use `man -k' or `info' to find out more about commands not in this list.

A star (*) next to a name means that the command is disabled.

 job_spec [&]                                                history [-c] [-d offset] [n] or history -anrw [filename]>
 (( expression ))                                            if COMMANDS; then COMMANDS; [ elif COMMANDS; then COMMAN>
<中略>
 hash [-lr] [-p pathname] [-dt] [name ...]                   while COMMANDS; do COMMANDS; done
 help [-dms] [pattern ...]                                   { COMMANDS ; }
Specialer$

コマンド再実装

lscatを再実装します。

alias ls='printf "%s\n" .* && printf "%s\n" *'

*はカレントディレクトリのすべてのファイルを出力できます。
また.*とすることで隠しファイルも出力できます。
これらをprintfコマンドで出力することでlsを実装できます。

alias cat='while IFS= read -r line || [[ -n $line ]]; do echo "$line"; done < '

また、catの再実装はreadで開いたファイルの行をすべて出力します。

探索

Specialer$ ls
.
..
.hushlogin
.profile
abra
ala
sim

~/以下のabra/, ala/, sim/が怪しいです。

順番に見ていくと、フラグが見えました。

Specialer$ cd ala

Specialer$ ls
.
..
kazam.txt
mode.txt

Specialer$ cat kazam.txt
return 0 picoCTF{XXX}

まとめ

Bashのコマンドが機能しない場合は組み込みコマンドで再実装してしまいましょう。
この問題めちゃくちゃ面白かったです。

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