YYK's Blog

命令执行

Word count: 305Reading time: 1 min
2020/03/15 Share

原因

没有对代码中可执行的特殊函数入口做过滤,导致用户可以提交恶意语句,并由服务端进行执行。例如system(),eval(),exec()等函数。

函数

eval()

assert()

call_user_func()

is_callable()

call_user_func_array()

后面注意是数组

create_function()

匿名函数

preg_replace()

/e修正符

array_map()

usort()

uasort()

${php代码}(eg:phpinfo())

system()

系统命令

exec()

passthru()

shell_exec()

``

与shell_esec功能相同

ob_start()

打开输出控制缓冲

绕过

分隔符

  1. %0a 换行符
  2. 连续指令
  3. & 后台进程
  4. | 管道符
  5. || &&逻辑或,与

    空格代替符

  6. <
  7. $IFS
  8. ${IFS}
  9. $IFS$9
  10. %09 用于url传递

    执行绕过

  11. a=l;b=s;$a$b
  12. `echo d2hvYW1p|base64 -D` whoamii的base64编码
    反引号是命令替换,命令替换是指Shell可以先执行中的命令,将输出结果暂时保存,在适当的地方输出
  13. “substr string pos len”
    从string中取出从pos位置开始长度为len的子字符串,如果pos或len为非正整数时,返回空字符串。
    eg:
    1
    2
    3
    4
    echo "${PATH:0:1}"
    ehco "`&IFS\subster\$IFS\$(pwd)\$IFS\1\$IFS\1`"
    echo `$(expr${IFS}substr${IFS}$PWD${IFS}1${IFS}1)`
    expr${IFS}substr${IFS}$SESSION_MANAGER${IFS}6${IFS}1
CATALOG
  1. 1. 原因
  2. 2. 函数
    1. 2.1. eval()
    2. 2.2. assert()
    3. 2.3. call_user_func()
    4. 2.4. call_user_func_array()
    5. 2.5. create_function()
    6. 2.6. preg_replace()
    7. 2.7. array_map()
    8. 2.8. usort()
    9. 2.9. uasort()
    10. 2.10. ${php代码}(eg:phpinfo())
    11. 2.11. system()
    12. 2.12. exec()
    13. 2.13. passthru()
    14. 2.14. shell_exec()
    15. 2.15. ``
    16. 2.16. ob_start()
  3. 3. 绕过
    1. 3.1. 分隔符
    2. 3.2. 空格代替符
    3. 3.3. 执行绕过