♧ Godown 安全知识树

Mythic C2 命令级 Block List 只按命令名拦截:禁用 shell 后仍可用 run 执行命令

pentest/c2 · verified

一句话结论

Mythic 支持按 Operation/用户配置 Command Block List,粒度是命令名:把 apollo 的 shell 放进 Blocked 并分配给低权操作员后,该操作员执行 shell whoami 会被界面拦截(Block list preventing execution);但同一会话仍能执行 run -Executable whoami 并回显主机名——因为 run 未在阻断名单且同样能拉起进程执行命令。命令级 ACL 只是功能开关,不是命令执行边界。

原理

  • Block List 的绑定与粒度:Mythic 的 Command Block Lists 按 payload 类型(如 apollo/freyja)列出命令,管理员勾选进入 Blocked,再在 Operation 的 Modify Operator Assignments 里把该 Block List 分配给指定 operator;运行时按「命令名」匹配并拒绝执行。
  • 等价命令族:Mythic agent 命令中能执行系统命令/程序的不止 shell:run -Executable <程序> -Arguments <参数> 直接创建进程;powershell/powershell_import 执行 PowerShell;psinject 在指定进程内执行 PowerShell;execute-assembly/assembly_inject 加载 .NET 程序集;shinject 注入 shellcode。只要其中任意一个未列入 Blocked,就能达到与 shell 相同的执行效果。
  • Operation 隔离管的是管理面:每个 Operation 有独立的 payload/beacon 列表,当前 Operation 决定可见的 beacon(原文:在 operate 组创建的 beacon 在 Operation Chimera 组看不到,切回才可见);角色 Lead/Operator/Spectator 控制成员管理与查看权限,但它们都不改变「agent 内置命令可等价执行」这一事实。
  • 原文观察到的权限行为:普通 operator 尝试把 Lead 成员移出 Operation 时更新失败(原文报错 Failed to update members: field 'updateOperatorOperation' not found in type: 'mutation_root'),可视为非 Lead 无法修改成员管理;该报错是 GraphQL 字段/版本问题还是权限校验,原文未进一步区分,本卡仅记录现象。
  • 为什么值得记录:红队常把 C2 平台的命令黑名单当作「实习生护栏」或分权边界;本案例说明只要等价命令未被同时封锁,限制即可绕过。对防守方而言,看到 C2 任务日志里出现 run/powershell 而非 shell,不能据此认为没有命令执行。

触发条件

  • Mythic 多操作员部署,管理员为低权 operator 配置了 Command Block List(例如只 block shell)。
  • 攻击者/操作员持有该低权账号,且能切换到目标 Operation。
  • 目标 agent(apollo/medusa/athena 等)内置了未被阻断的等价执行命令(run、powershell、execute-assembly 等)。

利用步骤

  1. 管理员侧:Command Block Lists 新建 CMDLLIST,在 apollo 分类下把 shell 移入 Blocked,并在 Operation 的 Modify Operator Assignments 中把它分配给 relaysec_user(Role=operator)。
  2. 以 relaysec_user 登录,MAKE CURRENT 切换到目标 Operation。
  3. 执行 shell whoami:界面弹出 Block list preventing execution,命令未下发。
  4. 同一会话执行 run -Executable whoami -Arguments None:成功回显 win-4hc2cu196d9\admin(原文截图)。
  5. 如 run 也被阻断,继续尝试 powershell -Command whoami、psinject <pid> whoami、execute-assembly 等等价路径,直到找到未封锁命令。

PoC

# 被阻断的命令
shell whoami
→ 界面提示:Block list preventing execution

# 等价命令绕过
run -Executable whoami -Arguments None
→ 回显:win-4hc2cu196d9\admin

对应的 Mythic 配置示意(JSON 非官方格式,仅表达绑定关系):

Command Block List "CMDLLIST":
  agent apollo:
    Blocked:   [shell]
    Not Blocked: [run, powershell, psinject, execute-assembly, shinject, ...]
Operator relaysec_user @ Operation Chimera:
  Role: operator
  Block List: CMDLLIST

变体与关联

  • 变体:把 Block List 换成其它 C2 的等价限制(CobaltStrike 的 blockdlls/命令白名单、Sliver 的扩展命令)时,同样要检查 run/powershell/execute-assembly 等等价执行面。
  • 关联:[[pentest-c2-merlin-agent-multi-proto-p2p-pivot-proxy-chain]](另一 C2 的跳板/代理使用,涉及命令层面的横向能力)、[[pentest-c2-blockdlls-block-non-ms-dll-edr-injection]](同属 C2 操作员可控的命令级开关)。
  • 边界:该绕过只针对「命令级 Block List」;如果平台按参数/进程行为做强制策略(RASP、远程命令审计、禁用 agent 的 executable 命令),等价路径可能被封死。

检测与防御

  • C2 管理侧:不要把 Command Block List 当作安全边界;对低权操作员应同时封锁等价命令族(run、powershell、psinject、execute-assembly、shinject 等),并最小化编译进 agent 的命令集。
  • 权限侧:按 Operation 隔离敏感目标,Lead 仅授予必要人员;审计操作员的任务日志与命令历史,发现被禁命令后改用等价命令的行为。
  • 防守方检测:Mythic HTTP profile 的配置(自定义 Server 头、POST URI、jitter/interval)、payload 与 agent 特征仍可被识别;C2 任务日志中的 run/powershell 等价命令应作为执行证据,而非只看 shell。