Maison  >  Article  >  développement back-end  >  mysql-关于PHP-MYSQL注入攻击实例

mysql-关于PHP-MYSQL注入攻击实例

WBOY
WBOYoriginal
2016-06-02 11:29:521151parcourir

mysqlphp实例数据库

请问能实例一个基于PHP MYSQL类的注入攻击吗?

PHP VERSION 5.6.3

在尝试进行模拟注入攻击时失败。打印了SQL语句,直接复制脚本到Mysql Workbench是可以成功DROP掉数据库的,但是在本地运行的时候始终报语法错误,求问错误在哪里,如何实例化这样一次的攻击。

<code> error_reporting(E_ALL^E_NOTICE^E_WARNING^E_DEPRECATED);$data = $_GET['sql'];$data2 = mysql_real_escape_string($data);$sql = "INSERT INTO test (test) VALUES ('$data');";$sqlx = "INSERT INTO test (test) VALUES ('$data2');";echo $sql.'<br>';echo $sqlx.'<br>';mysql_query($sql);echo  mysql_error();</code>

上面链接部分略,
访问的URL为 test.php?sql=values%27);%20DROP%20DATABASE%20test;%20--%20

输出为
INSERT INTO test (test) VALUES ('values'); DROP DATABASE test; -- ');
INSERT INTO test (test) VALUES ('values\'); DROP DATABASE test; -- ');
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DROP DATABASE test; -- ')' at line 1

第二行做过防注入处理的是可以执行的,但是一个没做处理,依然报错了

Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn