0x00 mysql
00 UDF提权
简介
UDF是MySQL的一个拓展接口,UDF(Userdefined function)可翻译为用户自定义函数,这个是用来拓展Mysql的技术手段。
条件:
1、secure_file_priv 是用来限制 load dumpfile、into outfile、load_file() 函数在哪个目录下拥有上传或者读取文件的权限
#查看 secure_file_priv的值
show global variables like 'secure%';
当 secure_file_priv 的值为 NULL ,表示限制 mysqld 不允许导入|导出,此时无法提权
当 secure_file_priv 的值为/tmp/ ,表示限制 mysqld 的导入|导出只能发生在 /tmp/ 目录下,此时也无法提权
当 secure_file_priv 的值没有具体值时,表示不对 mysqld 的导入|导出做限制,此时可提权
2、 查看plugin的值
#查看plugin 的值
select Host,user,plugin from mysql.user where user = substring_index(user(),'@',1);
当 plugin 的值为空时不可提权
当 plugin 值为 mysql_native_password 时可通过账户连接提权
3、当前用户拥有可以将udf.dll写入相应目录的权限。
如果MySQL版本小于5.1且为Windows系统,则udf.dll文件存放在 C:\windows 或者 C:\windows\system32 目录下。
如果MySQL版本大于5.1,udf.dll文件必须放置在MySQL安装目录的lib/plugin文件夹下,该plugin 目录默认不存在需要创建。
利用步骤
1、查看 secure_file_priv 的值,没有具体值可以提权。
show global variables like 'secure%';
2、查看plugin的值,为mysql_native_password可提权(网上说实际情况提权成功与该值无关)
select Host,user,plugin from mysql.user where user = substring_index(user(),'@',1);
3、查看系统架构以及plugin目录
show variables like '%compile%'; #查看主机版本及架构
show variables l