BugkuCTF flag.php

2019-06-09  本文已影响0人  Visianlee

一开始找不到突破口,看了别人的wp把hint当作参数
http://123.206.87.240:8002/flagphp/?hint

<?php 
error_reporting(0); 
include_once("flag.php"); 
$cookie = $_COOKIE['ISecer']; 
if(isset($_GET['hint'])){ 
    show_source(__FILE__); 
} 
elseif (unserialize($cookie) === "$KEY") 
{    
    echo "$flag"; 
} 
else { 
?> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
<title>Login</title> 
<link rel="stylesheet" href="admin.css" type="text/css"> 
</head> 
<body> 
<br> 
<div class="container" align="center"> 
  <form method="POST" action="#"> 
    <p><input name="user" type="text" placeholder="Username"></p> 
    <p><input name="password" type="password" placeholder="Password"></p> 
    <p><input value="Login" type="button"/></p> 
  </form> 
</div> 
</body> 
</html> 

<?php 
} 
$KEY='ISecer:www.isecer.com'; 
?>

我们可以看到

image.png

代码逻辑是传入的cookie参数的值反序列化后等于KEY就输出Flag,一开始以为KEY的值是最下面的ISecer:www.isecer.com,结果忙活了半天发现这里其实上面KEY的值还没有被定义,上面代码中$KEY的值应该是NULL,而不是下面的值,所以应该是反序列化的值为NULL.

若unserialize(cookie)全等于KEY,这里注意有双引号,大体意思是:cookie的参数为ISecer,值为$KEY的序列化

之所以序列化的KEY不为'ISecer:www.isecer.com',是因为定义的KEY在后面,所以执行的$KEY为NULL

用在线的php代码测试网站测试一下

image.png

可以看到serialize($KEY)的值为 s:0:""

image.png

现在我们来用bp抓包

image.png image.png

(这里不知道什么原因没有抓到cookie,求大佬们指教)

所以手动在headers里添加了cookie

Go一下就得到了flag

image.png

也可以通过hackbar插件来完成此操作

构造cookie :ISser = s:0:"";

但是注意;(分号)在cookie中不会被正确的上传到服务器,构造URL编码

;的URL编码为%3B

于是在火狐的HackBar插件中传入Cookie ISser = s:0:""%3B

参考:
https://www.cnblogs.com/0yst3r-2046/p/10759809.html

上一篇 下一篇

猜你喜欢

热点阅读