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?

More than 1 year has passed since last update.

cpawCTFのwriteup(SQLインジェクション)

1
Posted at

備忘録

今回はSQLインジェクションなのでユーザー名とパスワードを入力するだけ!

問題を見るとリンクがあるので飛んでみる。

スクリーンショット 2025-07-06 13.49.52.png

この問題はSQLインジェクション不要で単純にテーブルから値を取得するだけ

スクリーンショット 2025-07-06 13.13.52.png

問題を解くと、ステージ2のURLが表示されるので飛ぶ。

スクリーンショット 2025-07-06 13.30.19.png

パスワードが不明のため、一般的なSQLインジェクションを試してみる。

パスワード部分に'OR'a'='aを入力することで、サーバ側で'と'の間に入力値が格納される。
つまり、サーバ側では

' 'OR'a'='a'

となり、'a'='a'によりTrueが常に成立する

スクリーンショット 2025-07-06 13.24.01.png

別解としてuser名に以下を入力しても突破できる!

'OR 'a'='a' ; --

この場合は、;がSQL文の改行を意味し、- -で後続をコメントアウトするのでパスワードの認証をバイパスできる!

スクリーンショット 2025-07-06 13.31.08.png

ただし、パスワードの入力欄が空だとエラーチェックが働くので何か文字を入力しておく必要がある。

この方法でパスワード認証をバイパスすると以下のようにWarningが表示される。

スクリーンショット 2025-07-06 13.33.28.png

今回は基本的なSQLインジェクションの知識だけで解ける問題でした!

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?