使用select 'payload' into outfile '/path/to/webshell'
便可写入一个webshell到/path/to/webshell
,这种方式的利用条件为:html
select user,file_priv from mysql.user where user=current_user()
为 Yshow variables like '%secure_file_priv%'
的结果符合要求(前面的语句执行结果可能与 select @@global.secure_file_priv
不一样,但通过个人测试这时候前面的语句的结果是准确的,不过我也不知道为何两个结果会不一致,按照MySQL官方文档的说法该变量是全局系统变量,应该是不会出现两个不一样结果的。。。若是有权限的话仍是用 select * from information_schema.session_variables where variable_name='secure_file_priv'
看比较好,这个确定准确)。具体要求以下:
原理同webshell,都是经过select 'payload' into outfile '/path/to/plugin_dir'
写入payload,因此利用条件和webshell的前两点相同,只有第三点不同,那就是mysql服务所属用户须要有插件目录(show variables like '%plugin%'
查看目录绝对路径)的写入权限,linux上mysql的plugin目录默认为root全部,权限为755。须要注意的是经过UDF的方式获取到的shell是管理员权限,因此有些时候能够用来提权。mysql