Home  >  Article  >  Backend Development  >  mysql-关于PHP-MYSQL注入攻击实例

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

WBOY
WBOYOriginal
2016-06-02 11:29:521177browse

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

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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn