Heim  >  Artikel  >  Backend-Entwicklung  >  mysql-关于PHP-MYSQL注入攻击实例

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

WBOY
WBOYOriginal
2016-06-02 11:29:521152Durchsuche

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

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

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn