三个函数间的区别
在利用sql注入漏洞后期,最常用的就是通过mysql的file系列函数来进行读取敏感文件或者写入webshell,其中比较常用的函数有以下三个
into dumpfile()
into outfile()
load_file()
注意,以上函数跟文件导入导出有关,其中当my.ini的参数secure_file_priv为空时,对导入导出无限制
当值为一个指定的目录时,只能向指定的目录导入导出
当值被设置为NULL时,禁止导入导出功能
区别:
outfile函数可以导出多行,在将数据写到文件里时有特殊的格式转换;而dumpfile则保持原数据格式,导出的数据之间并未进行换行且只导出了部分数据,因为导出数据不能超过一行。outfile后面不能接0x开头或者char转换以后的路径,只能是单引号路径。这个问题在php注入中更加麻烦,因为会自动将单引号转义成\',但是load_file,后面的路径可以是单引号、0x、char转换的字符,但是路径中的斜杠是/而不是\;
什么是UDF
UDF(user defined function)用户自定义函数,是mysql的一个拓展接口。用户可以通过自定义函数实现在mysql中无法方便实现的功能,其添加的新函数都可以在sql语句中调用,就像调用本机函数一样。
一个有趣的UDF平台


根据版本提示导入对应版本的.dll文件。选择提权选项点击执行即可;

踩过的坑
记得在my.in中设置好secure_file_priv,这个就不啰嗦了。
出现:udf导出失败请查看失败内容Can't create/write to file 'D:\Desktop\phpstudy2018\PHPTutorial\MySQL\lib\plugin\moonudf.dll' (Errcode: 2)
在计算机管理中心右键数显,选择登陆选项。选择本地系统账户即可。


后来,查看了这个工具的源码,它就是通过into dumpfie函数将dll文件导入到特定目录一中;


换个姿势
通过手工的方式进行注入,这个方式是在输入mysql账号密码的情况下。
union select '','','',convert(0xUDF,binary) into dumpfile path
亲测成功!!!!

网友评论