SQL Injection topone-print Success
前言
- 本文是 https://zeroday.hitcon.org/vulnerability/ZD-2025-00980 的延伸
- Server (PHP) 會直接把 URL Encoded 的字串塞到 SQL 語法,例如半形空白 =>
%20,所以只要有包含半形空白的 SQL Injection Payload 都無效,例如 MYSQL 常用的註解-- 123 - 就在我即將放棄之前,跟 Claude 4 又再進行一輪問答以及實測,得出
/**/可以取代半形空白,於是這個 SQL Injection 的路又重新復活了!
學到的東西
- 如果在半形空白無法正確注入的情況,可以用
/**/來取代半形空白 - LOCATE()
- 一開始跟 AI 對話時,建議要把完整的現況交代清楚,清楚的告知任務,並且賦予 AI 一個角色,例如
你是 SQLi 大師
任務: 分析一個 SQLi,每次請提供一個 Payload 以及解釋攻擊手法
情境: URL Path Based SQLi
target: https://www.domain.com.tw/company.html
SQLi Payload: https://www.domain.com.tw/company.html'
Error Message: Fatal error: Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '1' AND meta_type = '1'' at line 1 in ...