php注入

WBOY
Release: 2016-06-23 14:36:48
Original
1138 people have browsed it



先说一下PHP默认安装的这个选项:
; Magic quotes for incoming GET/POST/Cookie data.
magic_quotes_gpc = On
默认都是打开的,我们提交的很多字符都会被转义,所以把要查询的变量用单引号包括起来是非常正确的做法,以前很多程序这样写:select * form article where id = $id;这样我们后面可以直接跟union,当然你的mysql版本要支持,现在这种情况几乎不存在了,所以PHP的注入是非常困难的.今天在一个安全公告看到了一个PHP注入漏洞报着怀疑的态度去看代码,这种写法第一次见,但是原理一样,记录之~
article.php这样写:
if ($_REQUEST['sid']){
$sid = $_REQUEST['sid'];
$module = 'announce';
}
include('mod.php');
把直接获取的sid赋值,没有过滤,接着看mod.php:
if (!file_exists($announce))
  break;
  include ($announce);
  $oldID = $sid;
  $newID = $convert[$oldID];
  if ($newID)
  $reroute = "index.php?module=announce&ANN_user_op=view&ANN_id=$newID";
  break;
}

if (empty($reroute))
  $reroute = "index.php";
  header("location:" . $reroute);
exit();
变量直接转向到URL并把sid附加上去了,这样变量newid就是个漏洞变量了,如果mysql版本支持union就可以直接访问该URL提交and 1=2 union ....进行查询了~

Related labels:
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template