PHP代码审计


环境搭建

推荐用 phpstudy 搭建 php 代码审计的环境,简单快捷,切换 php 版本也很方便,再配置好 Xdebug 在 PHPstorm 即可远程调试。

  • 下载地址: https://www.xp.cn/download.html

相关文章

如果是云服务器,推荐使用 aapanel 部署 lnmp 环境,很方便

相关工具

  • LoRexxar/Kunlun-M

    git clone --depth 1 https://github.com/LoRexxar/Kunlun-M.git
    cd Kunlun-M
    pip3 install -r requirements.txt
    cp Kunlun_M/settings.py.bak Kunlun_M/settings.py    # 配置文件迁移
    python3 kunlun.py init initialize                   # 初始化数据库,默认采用sqlite作为数据库
    python3 kunlun.py config load                       # 加载规则进数据库(每次修改规则文件都需要加载)
    python3 kunlun.py -h
    python3 kunlun.py scan -t ./tests/vulnerabilities/

相关文章

相关靶场

php代码解密


硬编码

通用关键词

  • APIkey/密钥信息通用关键词


文件包含

描述

include 将会包含语句并执行指定文件

条件

PHP 的配置文件 allow_url_fopen 和 allow_url_include 设置为 ON

漏洞示例

更多内容

  • 文件包含


文件操作

相关文章

相关工具

相关案例

  • https://github.com/Taiwan-Tech-WebSec/Bug-Report/issues/91

ctf writeup

文件操作类威胁函数

关键词


PHP反序列化

反序列化威胁函数

更多内容

  • PHP反序列化


SSRF

漏洞示例

curl()

file_get_contents()

fsockopen()

审计函数

关键词

更多内容

  • SSRF

cURL

cURL 支持 http、https、ftp、gopher、telnet、dict、file 和 ldap 等协议,利用 gopher,dict 协议,我们可以构造出相应 payload 直接攻击内网的 redis 服务。

curl/libcurl 7.43 版本上 Gopher 协议存在 bug 即 %00 截断,经测试 7.49 版本可用;

curl_exec() 默认不跟踪跳转;

file_get_contents

file_get_contents() 支持 php://input 协议

file_get_contents 的 gopher 协议不能 UrlEncode


PHP弱类型

  • 弱类型


PHP变量覆盖

  • 变量覆盖


PHP伪协议

  • PHP伪协议


PHP反序列化

  • PHP反序列化


命令执行

审计函数


代码执行

审计函数