蚁剑AntSword命令执行增强:Bypass Disable Functions

  • 发表于
  • 周边

蚁剑AntSword Bypass Disable Functions

在昨天,蚁剑AntSword更新了新姿势「Bypass Disable Functions」,提供了另一种攻击思路,我们来过一遍。

原理分析

基于蚁剑的 FastCGI/PHP-FPM 模式和 AntSword-Labs 5 环境。蚁剑在服务器上传了 1 个 so 库和一个.antproxy.php,看下.antproxy.php代码:

正如文件名,就是代理127.0.0.1:60049 的 index.php 发送请求,60049 居然还有 Web, 看下是什么东西

ss 看不到(为什么看不到?)

蚁剑AntSword命令执行增强:Bypass Disable Functions

ps 可以

蚁剑AntSword命令执行增强:Bypass Disable Functions

/bin/sh -c php -n -S 127.0.0.1:60049 -t /var/www/html

看来是开启了一个新的 PHP Server,-n 就是不使用 php.ini,从而实现了 bypass disable_functions。大致推测出是利用之前上传的 so 库实现的命令执行,然后跑了个 PHP Server。

下面看下蚁剑干了什么,仓库在这里,主要代码在 core/php_fpm/index.js 里了,启动 PHP Server 的代码,然后生成 ext 传到服务器上

构造攻击 PHP-FPM 的 Payload,加载扩展库

触发 Payload 后,就会执行启动一个新的 PHP Server

后续 shell 都通过.antproxy.php 代理用 60049 的 PHP 解析,也就没有 disable_functions 了。

那么ext的so是什么?其实就是system 执行命令的钩子,再没有其它了。至此蚁剑AntSword完成突破 disable_functions 执行系统命令,绕过 Open_basedir 等安全机制。

AntSword Bypass disable_function插件下载

商店安装

进入 AntSword 插件中心,选择「绕过disable_functions」,点击安装

手动安装

  1. 获取源代码:git clone https://github.com/Medicean/as_bypass_php_disable_functions.git
  2. 拷贝源代码至插件目录

将插件目录拷贝至 antSword/antData/plugins/ 目录下即安装成功

蚁剑AntSword命令执行增强:Bypass Disable Functions
AntSword Bypass disable_function插件

相关

  • N/A