id: php-webshell

info:
  name: PHP Webshell - Detect
  author: lu4nx
  severity: high
  reference:
    - https://github.com/tennc/webshell/tree/master/php
    - https://www.rapid7.com/blog/post/2016/12/14/webshells-101/
  metadata:
    verified: true
  tags: php,file,webshell
file:
  - extensions:
      - php

    extractors:
      - type: regex
        regex:
          - '(?i)\b(passthru|eval|exec|system|phpinfo|assert|call_user_func|call_user_func_array)\('
          - '(?i)cmd.exe'
          - '(?i)/bin/sh'
          - '(?i)/bin/bash'
          - '(?i)WScript.Shell'
          - '(?i)gzuncompress\(base64_decode\('
          - '\]\(\$_(GET|POST|COOKIE|REQUEST)\['
          - '(?i)new\s*(ReflectionFunction|ReflectionClass)'
          - '(?i)0x647261646e617473'
          - '65786563' # exec
          - '(?i)\$\w+\(\$_(GET|POST|COOKIE|REQUEST)'
          - '(?i)b4tm4n'
          - '(?i)cmdshell'

# digest: 490a00463044022078097d3237ceb0cabb1e0b1c456f4c14b80ea66d392154a136bdb5d453a7dcca0220201d8304738ea91076d9deb51e67c381d87e8f0d953a51743fa29fbd4615963f:922c64590222798bb761d5b6d8e72950
