Back to skill

Security audit

Poly-Mal-Scan_恶意代码扫描器

Security checks for vulnerabilities and agentic risk

Overview

This is a disclosed PHP/JS/Bash malware-scanning skill; the scary strings are detector signatures and examples, not payloads the skill runs.

Install only if you want a local static scanner that can read source files you point it at and return suspicious code snippets/locations. Treat detections as security triage output, and review rule updates before accepting them because changing rule JSON changes future scanner behavior.

Vulnerability Patterns
  • YARA SignaturesMalware Match, Webshell Match, Cryptominer Match
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (155)

YARA rule 'reverse_shell': Reverse shell patterns in scripts or source code [malware]

Critical
Category
YARA Match
Content
MULTI_ENC_TRAITS`(词条推导 ∪ RAW、去重、按 `MIN_TRAIT_LEN=4` 过滤短码防二进制误报)与各结构化规则列表/索引。

### 提取规约(三种语言通用)
- 只收**"看到即可判死"的高确定性指纹**(典型/高危优先);剔易碰撞短串(<4 字节、纯常见英文词)。
- `plain` 明文只收**完整恶意片段**(如 `eval($_POST['p1']`、`nc -e /bin/bash`、`>> ~/.ssh/authorized_keys`),不收 `eval`/`curl`/`system` 这类被 threat_func 覆盖且易误报的裸词。
- 编码特征码写"该编码最终形态"(base64 去 `=`;url/hex/octal/chr/rot13/html)。
- 类别键与对应 `MULTI_ENC_TRAITS` / 规则结构类别一致(别自造拼不上的键)。

### 🔁 持续更新:新规则从哪来
> 使用中**要随时更新规则库**。新来源除各 `特征码来源.md` 已登记的**也可自己找**。加完在对应 `特征码来源.md` 补记"来源/许可/如何提取/已采用对照",保持可追溯。
Confidence
85% confidence
Finding
YARA rule matched a known malware signature (reverse shell, backdoor, ransomware, C2 framework, or info stealer).

YARA rule 'reverse_shell': Reverse shell patterns in scripts or source code [malware]

Critical
Category
YARA Match
Content
{
  "恶意函数": [
    "eval",
    "exec",
    "source",
    ".",
    "trap",
    "enable",
    "builtin",
    "command",
    "alias",
    "declare -f",
    "typeset -f"
  ],
  "恶意命令": [
    "chmod u+s",
    "chmod 4755",
    "useradd -u 0",
    "usermod -aG sudo",
    "iptables -F",
    "rm -rf /",
    "dd if=/dev/urandom of=/dev/sda",
    "mkfs",
    "systemctl stop firewalld",
    "nc -e /bin/bash",
    "base64 -d | bash",
    "curl | bash",
    "wget | sh",
    "kill -9",
    "nmap",
    "arpspoof",
    "sshpass",
    "StrictHostKeyChecking=no"
  ],
  "恶意变量": [
    "LD_PRELOAD",
    "LD_LIBRARY_PATH",
    "LD_AUDIT",
    "BASH_ENV",
    "ENV=",
    "IFS=",
    "PATH=",
    "HISTFILE=/dev/null",
    "PROMPT_COMMAND"
  ],
  "恶意文件写入": [
    "authorized_keys",
    ".bashrc",
    "/etc/crontab",
    "/etc/cron.",
    "/etc/ld.so.preload",
    "/etc/passwd",
    "/etc/shadow",
    "ssh_config",
    "systemd/system",
    "/etc/profile.d",
    "rc.local"
  ]
Confidence
85% confidence
Finding
YARA rule matched a known malware signature (reverse shell, backdoor, ransomware, C2 framework, or info stealer).

YARA rule 'reverse_shell': Reverse shell patterns in scripts or source code [malware]

Critical
Category
YARA Match
Content
"trap \"",
      "enable -f",
      "command -v ",
      "alias "
    ],
    "base64": [
      "ZXZhbCg",
      "ZXZhbCA"
    ]
  },
  "恶意命令": {
    "plain": [
      "chmod u+s",
      "chmod 4755",
      "useradd -u 0",
      "usermod -aG sudo",
      "iptables -F",
      "rm -rf /",
      "dd if=/dev/urandom of=/dev/sda",
      "mkfs.ext4 /dev/",
      "systemctl stop firewalld",
      "nc -e /bin/bash",
      "base64 -d | bash",
      "curl | bash",
      "wget | sh",
      "kill -9 ",
      "nmap -sn",
      "arpspoof -i",
      "sshpass -p",
      "StrictHostKeyChecking=no",
      ":(){ :|:& };:",
      ":|:&"
    ],
    "base64": [
      "Y2htb2QgdStz",
      "dXNlcmFkZCAtdSAw",
      "aXB0YWJsZXMgLUY",
      "cm0gLXJmIC8"
    ]
  },
  "恶意变量": {
    "plain": [
      "LD_PRELOAD=",
      "export LD_PRELOAD",
      "export LD_LIBRARY_PATH=/tmp",
      "BASH_ENV=",
      "export BASH_ENV",
      "export PATH=/tmp",
      "IFS='",
      "HISTFILE=/dev/null",
      "PR
Confidence
85% confidence
Finding
YARA rule matched a known malware signature (reverse shell, backdoor, ransomware, C2 framework, or info stealer).

YARA rule 'reverse_shell': Reverse shell patterns in scripts or source code [malware]

Critical
Category
YARA Match
Content
��,
  剔除易与正常代码碰撞的短串(长度 < 4 字节、纯常见英文词等)。
- 编码形式写入 `bash_raw_traits.json` 时必须是"该编码下的最终形态"
  (base64 去 `=` 填充 / url / hex / octal / chr / rot13 / html 等)。
- **plain 明文指纹**:直接以明文子串参与匹配,命中即判死。
  只收完整的高确定性调用/注入片段(如 `nc -e /bin/bash`、`>> ~/.ssh/authorized_keys`),
  不收 `eval`、`curl` 这类被 threat_func / 正常运维覆盖且易误报的纯词条。
- 类别键必须与 `bash_detect_rules.py` 的 `MULTI_ENC_TRAITS` 类别一致:
  `恶意函数执行` / `恶意命令` / `恶意变量` / `恶意文件写入` / `自我复制` /
  `反弹Shell` / `代码解密/混淆还原` / `网络外带/SSRF` / `权限维持/常驻`。

---

## 来源 1:MITRE ATT&CK(攻击行为分类与级别/参考来源)【已采用】

- **地址**:https://attack.mitre.org/techniques/enterprise/
- **许可**:�
Confidence
85% confidence
Finding
YARA rule matched a known malware signature (reverse shell, backdoor, ransomware, C2 framework, or info stealer).

YARA rule 'php_webshell_generic': Generic PHP webshell — eval/assert on user-controlled input [webshells]

Critical
Category
YARA Match
Content
`\\b(?:eval|system|...)\\s*\\(` —— 认"函数名+左括号"
  2. 超全局:        `\\$_()(...)\\[\\s*['\"]?\\w+['\"]?\\]`
  3. 溯源:          取参数里的 $var → 在 lines_upto 里找 `$var = ...;` → 查赋值串含超全局 → 级别+1
  4. 特征码:        MULTI_ENC_TRAITS 子串匹配(plain/base64/url/hex/octal/chr/rot13/html)

正则组件的三大盲点(已实测确认):
  A. eval($_POST['c']) 直接作参数 → find_php_variables 匹配不到 $var(已是超全局) → 溯源空 → 危险级别不+1
  B. $x="sys";$y="tem";eval($x.$y) → 命中 eval 但看不出拼接成危险函数双段
  C. $f="system";$f($a)            → 动态函数名 $f(...) 正则 \\b(...) 匹配不到 → 完全漏报

AST 归一化目标:
  经 tree-sitter 解析生成一份"等效但暴露更多行为特点"的 PHP 文本:
  1. 常量折叠     : $x="sys" 解析为字面量
  2. 变量解析     : 全文件赋值表替换参数里的 $var(递归到叶子)
  3. 动态函数名   : $f=
Confidence
85% confidence
Finding
YARA rule matched a known webshell pattern (PHP, Python, JSP, or ASPX webshell).

YARA rule 'php_webshell_generic': Generic PHP webshell — eval/assert on user-controlled input [webshells]

Critical
Category
YARA Match
Content
`\\b(?:eval|system|...)\\s*\\(` —— 认"函数名+左括号"
  2. 超全局:        `\\$_()(...)\\[\\s*['\"]?\\w+['\"]?\\]`
  3. 溯源:          取参数里的 $var → 在 lines_upto 里找 `$var = ...;` → 查赋值串含超全局 → 级别+1
  4. 特征码:        MULTI_ENC_TRAITS 子串匹配(plain/base64/url/hex/octal/chr/rot13/html)

正则组件的三大盲点(已实测确认):
  A. eval($_POST['c']) 直接作参数 → find_php_variables 匹配不到 $var(已是超全局) → 溯源空 → 危险级别不+1
  B. $x="sys";$y="tem";eval($x.$y) → 命中 eval 但看不出拼接成危险函数双段
  C. $f="system";$f($a)            → 动态函数名 $f(...) 正则 \\b(...) 匹配不到 → 完全漏报

AST 归一化目标:
  经 tree-sitter 解析生成一份"等效但暴露更多行为特点"的 PHP 文本:
  1. 常量折叠     : $x="sys" 解析为字面量
  2. 变量解析     : 全文件赋值表替换参数里的 $var(递归到叶子)
  3. 动态函数名   : $f=
Confidence
85% confidence
Finding
YARA rule matched a known webshell pattern (PHP, Python, JSP, or ASPX webshell).

YARA rule 'php_webshell_obfuscated': Obfuscated PHP webshell — eval(base64_decode/gzinflate/str_rot13) [webshells]

Critical
Category
YARA Match
Content
��但暴露更多行为特点"的 PHP 文本:
  1. 常量折叠     : $x="sys" 解析为字面量
  2. 变量解析     : 全文件赋值表替换参数里的 $var(递归到叶子)
  3. 动态函数名   : $f="system";$f(...) → system(...)
  4. 拼接折叠     : eval($x.$y) 若 $x="s" $y="ystem" → eval(system) 并在旁标注
  5. 污点链摊平   : $a=$_POST; $d=str_rot13($a); eval($d) → eval(str_rot13($_POST...)) 供溯源+1

输出: 归一化文本(供 phpdect.py 扫描/或后续 AST 特征识别)。

本文件职责(2026-09-01 重构):
  作为 纯翻译函数库 供 phpdect.py import 调用:
    - normalize(file_path) / normalize_source(src_bytes) → 返回归一化等效 PHP 文本;
    - 只做 AST 解析 + 归一化翻译(常量折叠/变量解析/动态函数名/拼接折叠/污点摊平/编码还原),
      不包含任何"是否判定为恶意/威胁级别"的研判逻辑;
    - 最终安全研判由调用方 phpdect.py 负责(威胁函数/特征码/逻辑规则)。
Confidence
80% confidence
Finding
YARA rule matched a known webshell pattern (PHP, Python, JSP, or ASPX webshell).

YARA rule 'php_webshell_generic': Generic PHP webshell — eval/assert on user-controlled input [webshells]

Critical
Category
YARA Match
Content
{
  "恶意函数执行": {
    "plain": [
      "eval($_POST['p1']",
      "system($_POST['command']",
      "shell_exec($_POST['command']",
      "exec($_POST['command']",
      "passthru($_POST['command']",
      "popen($_POST['command']",
      "assert($_POST[c",
      "shell_exec($_POST[baba]",
      "shell_exec($_POST[liz0]",
      "passthru($_POST['cmd']",
      "include($_POST['p2']",
      "@include($_POST['test2_file']",
      "@unserialize($_COOKIE['f']",
      "unserialize($_COOKIE[\"$sess_cookie\"]"
    ],
    "base64": [
      "ZXZhbCgkX1BPU1RbJ2MnXSk7"
    ]
  },
  "网络外带/SSRF": {
    "base64": [
      "ZXZpbC5jb20="
Confidence
85% confidence
Finding
YARA rule matched a known webshell pattern (PHP, Python, JSP, or ASPX webshell).

YARA rule 'php_webshell_generic': Generic PHP webshell — eval/assert on user-controlled input [webshells]

Critical
Category
YARA Match
Content
�先),
  剔除易与正常代码碰撞的短串(长度 < 4 字节、纯常见英文词等)。
- 编码形式写入 `raw_traits.json` 时必须是"该编码下的最终形态"
  (base64 去 `=` 填充 / url / hex / octal / chr / rot13 / html 等)。
- **plain 明文指纹**:直接以明文子串参与匹配,命中即判死。
  只收完整的高确定性调用/注入片段(如 `eval($_POST['p1']`、`system($_POST['command']`),
  不收 `eval`、`system` 这类被 threat_func 覆盖且易误报的纯函数名词条。
- 类别键必须与 `detect_rules.py` 的 `MULTI_ENC_TRAITS` 类别一致:
  `恶意函数执行` / `网络外带/SSRF` / `自我复制` / `代码解密/混淆还原` / `敏感输入源` / `权限维持/常驻`。

---

## 来源 1:tennc/webshell(PHP 真实 webshell 样本库)【已采用】

- **地址**:https://github.com/tennc/webshell
- **分支**:master
- **许可**:MIT(自由、开源、免费)
- **规模**:约 10.7k stars�
Confidence
85% confidence
Finding
YARA rule matched a known webshell pattern (PHP, Python, JSP, or ASPX webshell).

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
The declared description presents a malware/webshell scanning detector with operational detection capabilities, MCP integration, and rule maintenance workflows. The supplied code instead is a narrow developer tool for building and printing a Bash syntax tree using tree-sitter. Its own docstring explicitly states it is only the first step toward later analysis and '暂不做任何恶意判定' (does not do any malicious judgment yet). This is a material purpose mismatch: the code is parser/AST inspection infrastructure, not an actual scanner or detector as described.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
The declared description presents a malware/webshell scanning and detection tool with rule management and MCP integration. The supplied code does not perform any security analysis, signature matching, detection, or integration tasks. Its actual function is limited to inferring the programming language of a file by trying AST parses across a fixed set of languages and marking very short unparsable content as no_code. While such language detection could be a supporting component inside a larger scanner, this code chunk by itself materially differs from the declared primary purpose and lacks the core advertised capabilities.

Ae1

High
Category
analysis-evasion
Content
> `php_security/`、`js_security/`、`bash_security/`、`detect_mcp_server.py` 的那层目录"。
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
> `php_security/`、`js_security/`、`bash_security/`、`detect_mcp_server.py` 的那层目录"。
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
> `php_security/`、`js_security/`、`bash_security/`、`detect_mcp_server.py` 的那层目录"。
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
| PHP | `php_security/` | `phpdect.py` | 恶意函数执行 / 威胁性动态变量 / 特征码威胁 / 自我复制·文件写入 |
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
| JS | `js_security/` | `jsdect.py` | 恶意函数/API执行 / 动态代码执行 / 特征码威胁 / 自我复制·文件写入 |
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
| Bash | `bash_security/` | `bashdect.py` | 恶意命令 / 恶意变量 / 恶意文件写入 / 自我复制 / 恶意函数 / 特征码威胁 |
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
- **PHP**:`threatening_funcs.json`(函数名+级别)、`categories.json`(词条 + 可带 `逻辑规则` 键做 and/or/not 组合)、`raw_traits.json`("看到即判死"直接指纹,写各编码最终形态)。
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
- **PHP**:`threatening_funcs.json`(函数名+级别)、`categories.json`(词条 + 可带 `逻辑规则` 键做 and/or/not 组合)、`raw_traits.json`("看到即判死"直接指纹,写各编码最终形态)。
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
- **PHP**:`threatening_funcs.json`(函数名+级别)、`categories.json`(词条 + 可带 `逻辑规则` 键做 and/or/not 组合)、`raw_traits.json`("看到即判死"直接指纹,写各编码最终形态)。
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
- **PHP**:`threatening_funcs.json`(函数名+级别)、`categories.json`(词条 + 可带 `逻辑规则` 键做 and/or/not 组合)、`raw_traits.json`("看到即判死"直接指纹,写各编码最终形态)。
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
- **PHP**:`threatening_funcs.json`(函数名+级别)、`categories.json`(词条 + 可带 `逻辑规则` 键做 and/or/not 组合)、`raw_traits.json`("看到即判死"直接指纹,写各编码最终形态)。
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
- **PHP**:`threatening_funcs.json`(函数名+级别)、`categories.json`(词条 + 可带 `逻辑规则` 键做 and/or/not 组合)、`raw_traits.json`("看到即判死"直接指纹,写各编码最终形态)。
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
- **JS**:`js_threatening_funcs.json` / `js_categories.json`(+`逻辑规则`)/ `js_raw_traits.json`。
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
- **Bash**:`bash_threatening_funcs.json`/`bash_categories.json`/`bash_raw_traits.json`,另按类别拆 `bash_malicious_commands.json`、`bash_malicious_variables.json`、`bas
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Static analysis

Detected: suspicious.dangerous_exec, suspicious.dynamic_code_execution, suspicious.env_credential_access (+1 more)

Shell command execution detected (child_process).

Critical
Code
suspicious.dangerous_exec
Location
js_security/js_logic_engine.py:128

Dynamic code execution detected.

Critical
Code
suspicious.dynamic_code_execution
Location
js_security/js_ast_normalize.py:18

Dynamic code execution detected.

Critical
Code
suspicious.dynamic_code_execution
Location
js_security/js_common.py:76

Dynamic code execution detected.

Critical
Code
suspicious.dynamic_code_execution
Location
js_security/js_detect_rules.py:68

Dynamic code execution detected.

Critical
Code
suspicious.dynamic_code_execution
Location
js_security/js_logic_engine.py:127

Dynamic code execution detected.

Critical
Code
suspicious.dynamic_code_execution
Location
php_security/detect_rules.py:65

Dynamic code execution detected.

Critical
Code
suspicious.dynamic_code_execution
Location
php_security/logic_engine.py:81

Dynamic code execution detected.

Critical
Code
suspicious.dynamic_code_execution
Location
php_security/php_ast_normalize.py:13

Environment variable access combined with network send.

Critical
Code
suspicious.env_credential_access
Location
js_security/js_threat_func_dect.py:6

Potential obfuscated payload detected.

Warn
Code
suspicious.obfuscated_code
Location
php_security/detect_rules.py:43