【代码审计】预备工具配置使用和学习

admin 2022年1月10日03:34:27评论113 views字数 1973阅读6分34秒阅读模式

前言

工具

PHPStrom + PHPDebug 调试配置建议看看这篇

动态调试的一些快键键

1
2
3
4
5
6
Ctrl + F8 下断点
F7 单步调试(进入子函数)
F8 单步调试(不进入子函数)
F9 执行到下一个断点
ALT + F8 计算表达式
Ctrl + Shift + F8 查看所有断点

溯源技巧

1
2
3
Ctrl + Shift + F 全项目查找
Ctrl + 右击 查看函数调用、类定义、函数定义、包含文件所在的位置
每一行左侧小图标 查看父类方法

PHP手工调试

  • 万金油函数
1
var_dump
  • 查看上下文内容
1
2
3
4
5
6
7
8
get_defined_functions # 返回所有已定义函数的数组
get_defined_vars # 获取当前php运行的所有变量
get_defined_constants # 返回所有常量的关联数组,键是常量名,值是常量值
get_included_files # 返回被 include 和 require 文件名的 array
get_loaded_extensions # 返回所有编译并加载模块名的 array
get_extenstion_funcs # 返回模块函数名称的数组
get_declared_classes # 返回由已定义类的名字所组成的数组
get_declared_interfaces # 返回一个数组包含所有已声明的接口
  • 查看函数调用过程
1
2
debug_backtrace
debug_print_backtrace
  • XDebug手工调试
1
2
3
4
5
xdebug_call_file #获取调用当前函数的文件
xdebug_call_line #获取当前函数的文件行
xdebug_call_function #获取调用当前函数的函数
xdebug_dump_superglobals #获取所有超全局变量
xdebug_get_monitored_functions #监控函数调用

PHP服务架构

PHP运行模式 (Sapi)

  • CLI

  • CGI

  • PHP Built-in Webserver

    • php -S localhost:9090 (当前目录启动基于php的服务)
  • Apache php_mod

  • php-fpm(Fastcgi)

    • Nginx
    • IIS7+
    • Lighttpd
  • IIS6 + ISAPI

  • Swoole

PHP安全配置

  • 影响PHP安全的全局配置

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    - magic_quotes_gpc: 5.3后废弃,5.4后移除
    - register_global: 4.2后默认为false
    - allow_url_include: 默认为False
    - allow_url_fopen: 默认true
    - request_order:5.3后从GPC改为GP
    - short_open_tag: 5.4+, 无论是否开启,<?=..?>总是可以被执行的
    - safe_mode (5.4移除)
    - open_basedir 限制网站是否能访问哪些目录
    - disable_functions/disable_classes
    -- enable_dl(5.2默认false)

PHP危险函数归纳

  • 危险操作、函数、方法、变量
1
2
3
4
5
6
7
8
9
10
11
12
13
- include/require/include_once/require_once/spl_autoload
- eval/assert/preg_replace/create_function
- system/passthru/exec/shell_exec/popen/proc_open/pcntl_exec/dl/`ls`
- file_get_contents/fread/readfile/file/highlight_file/show_source
- file_put_contents/fwrite/mkdir/fputs
- unlink/rmdir
- move_uploaded_file/copy/rename
- curl_exec/file_get_contents/readfile/fopen
- extract/parse_str/$$
- simplexml_load_file/simplexml_load_string/SimpleXMLElement/DOMDocument/xml_parse
- var_dump/print_r/exit/die
- unserialize
- urldecode/iconv/mb_convert_encoding/stripslashes/base64_decode/substr

遇到不懂的函数和类

XZ.Aliyun.com

Github.com

Wooyun历史漏洞

我的个人博客

孤桜懶契:http://gylq.gitee.io

FROM:gylq.gitee Author:孤桜懶契

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年1月10日03:34:27
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   【代码审计】预备工具配置使用和学习http://cn-sec.com/archives/730053.html

发表评论

匿名网友 填写信息