跳到内容
HackIndex.io
工具

命令注入绕过生成器

输入一条命令和一个正则过滤规则,我们会生成绕过它的载荷。

\rA-Z]*$\"">

提示:可以带或不带分隔符输入 regex——/pattern/flags 和纯模式均有效。

工作原理

此工具自动查找能通过给定 regex 过滤器的命令注入载荷。它生成数十种混淆的命令变体,并逐一在服务端通过 PHP 对 regex 进行测试——不会执行任何内容。

  1. 1. 输入你的命令: 要注入的原始命令,例如 whoami 或 cat /etc/passwd.
  2. 2. 粘贴 regex 过滤器: 任何格式:PHP /pattern/flags, Python r"pattern" 或 re.compile(...), JavaScript new RegExp(...), Go 反引号,或普通模式。
  3. 3. 选择过滤器类型: 黑名单过滤器阻止匹配的输入(载荷不得匹配);白名单过滤器只允许匹配的输入(载荷必须匹配)。
  4. 4. 获取绕过方式: 所有通过过滤条件的载荷均会返回,按技术分组,并注明适用的操作系统。

绕过技术分类

生成器涵盖以下适用于 Linux/Bash 和 Windows CMD/PowerShell 的绕过技术系列。

Linux

Encoding (base64 / hex / xxd / octal)

Encodes the entire command using base64 (subshell and pipe-to-sh), raw hex decoded by xxd -r -p, printf \x escapes (lowercase), and ANSI-C $'\x..' quoting. Lowercase-only variants bypass [A-Z] filters.

Linux

Quote splitting

Inserts empty single quotes, double quotes, or backslash escapes inside the keyword, e.g. c''at or c\at, breaking pattern matching without changing shell semantics.

Linux

Space bypass

Replaces literal spaces with $IFS, ${IFS}, a tab character ($'\t'), brace expansion ({cmd,arg}), or input redirection (cat</etc/passwd).

Linux

Slash bypass

Replaces forward slashes using ${HOME:0:1}, ANSI-C $'\x2f', $'\57', or $(printf '\57').

Linux

Variable concat

Splits the command across two shell variables (a=wh; b=oami; $a$b) to avoid matching the full keyword in the regex.

Linux

Alternative commands

Substitutes blocked commands: cat → less, tac, nl, head, xxd; whoami → id; ls → echo *.

Linux

Wildcards / globbing (hint)

Generates c?t and c* variants. These bypass the regex but require the correct binary on the filesystem. Verify manually.

Windows

CMD caret obfuscation

Inserts the ^ escape character between chars (w^h^o^a^m^i). CMD ignores ^ and executes the command normally.

Windows

CMD quote splitting

Inserts empty double quotes (wh""oami). Functionally identical to the unquoted form in CMD.

Windows

CMD variable tricks

Splits across environment variables (set a=wh& set b=oami& call %a%%b%). Also supports delayed expansion via cmd /V:ON and !var!.

Windows

PowerShell backtick

The backtick (`) is a PowerShell escape character silently ignored in identifiers. wh`oami executes as whoami.

Windows

PowerShell encoding

Encodes as UTF-16LE base64 for powershell -enc, or rebuilds from a char array ([char[]](119,104,...) -join '') or string concat ('wh'+'oami').

Windows

PowerShell invoke variants

Uses iex, the & operator, ScriptBlock::Create, or mixed-case IeX without spelling Invoke-Expression.

黑名单与白名单过滤器

黑名单 — 载荷不得匹配

当 regex 匹配时,应用程序会阻止输入。regex 描述危险模式——例如 [;&|`$] 或 cat|ls|whoami. 载荷不得触发 regex 才能通过过滤。

常见于:匹配时执行 die/block 的 PHP preg_match()、Python re.search() 守卫。

白名单 — 载荷必须匹配

只有当 regex 匹配时,应用程序才处理输入。regex 描述允许的字符——例如 ^[^;\/&A-Z]*$. 载荷必须满足 regex,同时仍能执行命令。

常见于:输入验证器、CTF 题目源码、WAF 白名单。

提示:如果 regex 使用以下锚点 ^ 和 $,这几乎始终是白名单。如果你的模式选择看起来有误,工具会发出警告。

支持的 regex 输入格式

按源代码中的原样粘贴 regex——工具会自动检测格式,提取模式和标志,并编译为 PHP 兼容的表达式。

语言 / 格式 示例
PHP / JS / Ruby / Perl /[;&|`$\s]/i
纯模式 ^[0-9a-z]+$
Python 原始字符串 r"^[^;/\&.<>\rA-Z]*$"
Python re.compile re.compile(r"[;&|]", re.IGNORECASE)
JavaScript new RegExp new RegExp("[;&|]", "gi")
Go 原始字符串 `^[a-z0-9]+$`
Perl m// m/[;&|]/gi
带引号的字符串 "^[a-z0-9]+$"

常见问题

这真的会执行命令吗?

不会。所有处理都在服务器端的 PHP 中进行。Payload 以字符串形式生成,并用 preg_match() 与你的正则匹配测试。服务器上从不执行任何命令。

“payload 必须匹配 / 必须不匹配”是什么意思?

黑名单在正则匹配时阻止输入:payload 必须不匹配。白名单仅在正则匹配时允许输入:payload 必须匹配。工具会自动检测更可能的情况,并在你的选择看起来有误时发出警告。

为什么有些 payload 带有警告标记?

基于通配符和 glob 的 payload(如 /bin/c?t)依赖目标的文件系统布局。它们能绕过正则过滤器,但仅当预期的二进制文件存在于该路径时才有效。

为什么我的 ANSI-C 引用 payload 不能直接运行?

像 $'\x77\x68\x6f\x61\x6d\x69' 这样的 ANSI-C 字符串在 bash 中会求值为字面字符串 whoami,但本身并不会执行。在前面加上 eval 或 bash -c,它们是小写字母,通常不会被过滤。

我可以将它用于 CTF 挑战吗?

可以。此工具专为 CTF 和已授权的渗透测试场景设计,用于绕过输入过滤器以实现命令执行。仅在你拥有或已获得明确测试许可的系统上使用。