当前位置:首页 > Web开发 > 正文

Redhat 线下赛 WEB WP

2024-03-31 Web开发

给每个参赛队伍所有题目的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

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/web/41449.html