mysql数据库udf提权
发布于 2021-05-13 21:25 ,所属分类:数据库和大数据技术学习资料
mysql数据库udf提权
UDF介绍
UDF提权复现
udf提权的前提条件
0x01 判断mysql版本
0x02 查看mysql是否有写入文件的权限
0x03 使用MDUT 工具写入udf.dll
0x04 使用msf进行udf提权
最近面试经常被问到udf提权,奈何每次都回答不上来,于是有了下面的学习过程。
UDF介绍
UDF (user defined function),即用户自定义函数。通过添加新函数,对MySQL数据库的功能进行扩充,就像使用本地MySQL函数如 database() 或 version() 一样。
UDF提权复现
udf提权的前提条件
① 知道数据库的用户和密码
② mysql可以远程登录
③mysql有写入文件的权限,即secure_file_priv的值为空。
0x01 判断mysql版本
在mysql>5.1版本,udf.dll应放置在mysql安装目录的lib\plugin下
mysql<5.1版本udf.dll应放置在C:\windows或者C:\windows\system32目录
selectversion();

我的mysql版本是5.5.53,udf.dll 应该放在mysql/lib/plugin 目录下。由于mysql安装目录下lib\plugin是不存在的,所以手工创建好。

0x02 查看mysql是否有写入文件的权限
showvariableslike'%secure%'

如果secure_file_priv 为空则允许写入文件。
如果具备这两个条件和可以远程登录,我们就可以用MDUT 工具写入udf.dll了 。
0x03 使用MDUT 工具写入udf.dll
下载地址:https://github.com/SafeGroceryStore/MDUT



测试一下


0x04 使用msf进行udf提权
msf6exploit(multi/mysql/mysql_udf_payload)>
配置password 、rhosts 、 username

成功写入udf.dll


自定义函数sys_eval()和sys_exec() 两个执行命令的函数可以直接调用。
sys_exec()函数无回显
执行成功返回0 执行失败返回1


sys_eval()函数有回显

相关资源