Skip to content

feat: zombie 2.0 — Session/Action architecture + service template protocol#70

Open
M09Ic wants to merge 18 commits into
zombie_v1from
zombie2.0
Open

feat: zombie 2.0 — Session/Action architecture + service template protocol#70
M09Ic wants to merge 18 commits into
zombie_v1from
zombie2.0

Conversation

@M09Ic

@M09Ic M09Ic commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Zombie 2.0 对核心架构进行了重构,引入 Session/Action 模型和 YAML 驱动的 service template 协议。

架构改动

  • Session/Action 模型:Plugin 返回类型化 Session(ShellSession/SQLSession/KVSession/FileSession/DirectorySession),Action 接口在认证后 session 上执行操作
  • Service Template 协议:YAML 驱动的原子操作模板,支持 ops(shell/db/kv/file/ldap)、matchers、extractors
  • Chain 机制:模板间通过 chain 字段声明依赖,ChainExecutor 按拓扑序执行并传递变量
  • Neutron Request 集成:service template 可直接使用 neutron HTTP/Network request 类型,与 service ops 统一编排
  • PostAction + Proton 扫描:认证后自动收集信息并用 proton 规则扫描凭证/密钥

新功能

  • --service-template <path> 加载 service template 目录
  • --gather 加载内嵌信息收集模板(70+ 模板覆盖 SSH/MySQL/PostgreSQL/MSSQL/Oracle/Redis/SMB/FTP/LDAP/Memcached/MongoDB)
  • --risk safe|dangerous|critical 按风险等级过滤模板
  • --tags <tag> 按标签过滤模板
  • --proton + --scan-template 启用 proton 凭证扫描
  • --payload key=value-V key=value 自定义模板变量/payload
  • FileSession.Write 支持 SMB/FTP 文件写入
  • per-host 并发限制(--concurrency)避免冲破服务端限速
  • 代理支持(ProxyDial)透传到所有插件
  • ResourceProvider/ResourceLoader 支持 SDK 注入外部模板

凭证爆破增强

  • 蜜罐检测(随机凭证预检)
  • 未授权访问检测(空密码)
  • pk: / hash: / raw: 凭证前缀
  • SMB hash 认证
  • 严格模式(--strict)指纹匹配后才爆破

稳定性

  • 优雅中断(Ctrl+C 打印部分结果)
  • panic 恢复 + nil session 防护
  • Output channel data race 修复
  • goroutine 超时强制取消

Test plan

  • go test ./... 全部通过
  • service template 编译/执行/chain/payload/变量覆盖 单元测试
  • PostAction shell/sql/kv/file proton 扫描单元测试
  • risk/tags 过滤测试
  • Docker 集成测试(MySQL/PostgreSQL/Redis/SSH)

🤖 Generated with Claude Code

M09Ic and others added 18 commits June 16, 2026 03:22
Major architecture refactor for zombie v2:

Session layer: typed capability interfaces (ShellSession, SQLSession,
KVSession, FileSession, DirectorySession) replacing raw connection hiding.
Plugin.Open() returns Session instead of Login() returning error.

Action layer: composable post-auth pipeline. PostAction collects remote
info (Loot) and runs proton template matching on remote data. Triggered
via --proton --scan-template flags; default behavior (pure brute) unchanged.

Plugin rewrite: all 23 plugins converted to stateless factories returning
typed Sessions. Shared sqlsess/kvsess internal packages eliminate duplication.
Dispatch switch replaced by plugin registry.

Worker: Execute(task, plugins, pipeline) replaces Brute(task). Empty pipeline
= pure auth verification (backward compatible).

27 e2e tests cover: CLI parsing, 3 attack modes, 6+ services, --proton
pipeline, Runner API, Worker Execute.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
- Execute(): check for nil session before defer Close()
- OutputHandler: guard result.Err.Error() against nil Err
- Add 8 panic-specific tests covering: nil session, nil Param on all
  23 plugins, nil ActionResult merge, nil Err formatting

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…g logging

- Signal handling: SIGINT/SIGTERM triggers graceful shutdown with partial stats
- Pool release: defer Pool.Release() to prevent goroutine leak in SDK usage
- File cleanup: close output file after run completes
- Error classification: categorize errors into timeout/refused/auth/other
- Unified stats: Statistor.SummaryString() consolidates total/success/extracteds/loot/errors
- Debug logging: action/post.go logs partial failures at Debug level for diagnostics
- Worker logging: Execute/ExecuteUnauth log action errors at Debug level
- Remove dead code: delete unused telnet plugin

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Mirrors gogo/spray ResourceLoader pattern. SDK zombie engine sets it
to no-op after init, preventing repeated resource loading.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Inner goroutines may still be sending on OutputCh when the main
goroutine closes it after wg.Wait(). Protect both sides with a mutex
and a closed flag.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Introduce a new `service` protocol that extends neutron's template engine
into zombie's post-exploitation domain. Templates define operations
(shell/db/kv/file/ldap) against authenticated sessions, reusing neutron's
matcher/extractor/DSL engine for result analysis.

Key components:
- service/ package: Request, Op, Template implementing protocols.Request
- Op types aligned to session types: shell, db, kv, file:{list/read}, ldap
- KV unified command expression with GET/KEYS dispatch + RawCommander fallback
- Template-level variables, CLI overrides (-V key=value), payload iteration
- Chain mechanism for OS-adaptive template dispatch
- ServiceAction bridging into zombie's existing worker pipeline
- RedisSession.Command() for raw Redis command execution
- --service-template CLI flag for loading service templates

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…§marker§ support

- Template.ExecuteWithOptions(session, host, vars, payloads) for full control
- Payload CLI override via -V and cliPayloads passthrough
- ServiceAction chain execution with dynamic value propagation
- §marker§ payload marker replacement in op fields
- parseCommandFields with quoted string and escape support
- formatCommandResult for array/interface{} Redis responses

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Replace hand-rolled DFS chain logic with neutron's generic ChainExecutor
(DepthFirst + PassVariables). Removes loadServiceTemplateFileWithChains,
findChainTemplateFile, and chainTargets field — chain resolution is now
fully in-memory via the shared executor. Adds comprehensive chain tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
… filter, FileSession.Write, gather embedding

- Template supports neutron HTTP and Network request types alongside service ops
- Info struct with Risk field (safe/dangerous/critical) for template filtering
- HasTag/RiskAllowed methods for runtime template selection
- FileSession.Write interface + SMB/FTP implementations
- FileOp Write/Data support in service execute
- --gather flag loads embedded service templates (tag=gather)
- --risk and --tags CLI filters for ServiceAction
- LoadServiceTemplatesFromData/FromPaths for embedded + path-based loading
- templates submodule updated with 70+ service templates

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…o service templates

PostAction no longer collects data from sessions (credentialColumns,
shellScanPaths, shellGatherCmds, per-protocol enumeration). All info
gathering is now driven by service templates in templates/services/.

PostAction retains only the proton scanner — called after pipeline
execution to scan Loot produced by ServiceAction templates.

- Remove postShell/postSQL/postKV/postFile and all hardcoded constants
- PostAction.ScanData() replaces the private scanData method
- worker.go feeds result.Loot to PostAction after pipeline completes
- PostAction moved from Pipeline to Runner.PostAction field
- Remove unused DBLimit option

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Each plugin package now registers itself and its service definition in
its own init(), eliminating the centralized registry.go and the 26
hardcoded Service variables in pkg/types.go.

- Plugin interface moved to pkg.Plugin; plugin/ package provides thin aliases
- Each plugin init() calls pkg.RegisterPlugin() + pkg.Services.Register()
- plugin/registry.go reduced to blank imports that trigger init()
- pkg/types.go: removed all global Service vars and RegisterServices()
- Adding a new plugin only requires creating the package + importing it

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Session interfaces now provide only atomic DSL execution, with
template-driven orchestration on top.

- SQLSession: remove Databases() — templates use `db: "SHOW DATABASES"` directly
- KVSession: absorb RawCommander's Command() — unified kv op dispatch
- Delete 5 AsXxx() helpers — direct type assertions in execute.go
- Remove Op.Databases field and __databases__ special case in execDB
- Memcached: implement KVSession (Get/Command for SET/DELETE/FLUSH)
- MongoDB: implement KVSession (Get/Keys/Command via RunCommand)
- ZooKeeper: implement KVSession (Get/Keys/Command for SET/CREATE/DELETE)

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
MongoDB is a database, not a KV store. Query() now handles:
- "show databases" → ListDatabaseNames
- "show collections <db>" → ListCollectionNames
- any other command → RunCommand on admin db

Templates use `db: "show databases"` instead of forced KV semantics.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Connect the ServiceAction → Loot → PostAction pipeline:
- service/execute.go: populate OperatorsResult.Response with raw op output
- service/template.go: accumulate raw responses across all requests
- action/service.go: store raw response as Loot entry per template
- action/post.go: add NewPostActionFromData() for embedded loot rules
- core/runner.go: --gather auto-activates PostAction from embedded rules

Add 10 PII/secret detection rules (proton file: format):
phone, email, id-card, bank-card, password-hash, jwt,
cloud-credential, connection-string, private-key, internal-ip

Embed loot rules via templates_gen.go zombie_loot key.

CI: split into lint/test/build/templates jobs, add template
validation and embedded-data freshness check.

Tests: Response preservation, Loot population, PostActionFromData,
gather pipeline, loot template validation, docker integration.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Aligns with RequestsHTTP and RequestsNetwork naming convention.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant