PHP SQL 预防注入与攻击技术实现以及办法 (1/4)_PHP教程

WBOY
Release: 2016-07-13 17:09:41
Original
856 people have browsed it

php教程 sql 预防注入与攻击技术实现以及办法
1. php 配置文件 php.ini 中的 magic_quotes_gpc 选项没有打开,被置为 off

  2. 开发者没有对数据类型进行检查和转义

  不过事实上,第二点最为重要。我认为, 对用户输入的数据类型进行检查,向 mysql教程 提交正确的数据类型,这应该是一个 web 程序员最最基本的素质。但现实中,常常有许多小白式的 web 开发者忘了这点, 从而导致后门大开。

  为什么说第二点最为重要?因为如果没有第二点的保证,magic_quotes_gpc 选项,不论为 on,还是为 off,都有可能引发 sql 注入攻击。下面来看一下技术实现:

 一. magic_quotes_gpc = off 时的注入攻击
  magic_quotes_gpc = off 是 php 中一种非常不安全的选项。新版本的 php 已经将默认的值改为了 on。但仍有相当多的服务器的选项为 off。毕竟,再古董的服务器也是有人用的。

  当magic_quotes_gpc = on 时,它会将提交的变量中所有的 '(单引号)、"(双号号)、(反斜线)、空白字符,都为在前面自动加上 。下面是 php 的官方说明:

magic_quotes_gpc boolean

sets the magic_quotes state for gpc (get/post/cookie) operations. when magic_quotes are on, all ' (single-quote), " (double quote), (backslash) and nul's are escaped with a backslash automatically

  1 2 3 4

www.bkjia.com true http://www.bkjia.com/PHPjc/629722.html TechArticle php教程 sql 预防注入与攻击技术实现以及办法 1. php 配置文件 php.ini 中的 magic_quotes_gpc 选项没有打开,被置为 off 2. 开发者没有对数据类型进...
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!