Commit Graph
423 Commits
Author SHA1 Message Date
M09IcandClaude Opus 4.6 f4b8e61376 feat: add ResourceLoader for controllable resource loading
Mirrors gogo's ResourceLoader pattern. SDK spray engine sets it to
no-op after init, preventing RunWithArgs from reloading ports/fingers/templates.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
2026-06-16 03:17:14 -07:00
M09IcandClaude Opus 4.6 97452ba163 chore(deps): update chainreactors dependencies to latest
Fix proton import path change: protocols/file -> proton/file
Remove local replace directive for parsers

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
2026-06-08 01:56:29 -07:00
M09IcandClaude Opus 4.6 729dee3d06 feat: enhance extract system with severity, context capture, matchers, and new rules
- parsers.Extracted: add Severity and Items (ExtractItem with ctx/line/offset)
- ProtonExtract: preserve severity from templates, capture N-char context around matches
- Add --extract-context CLI flag (default 0, e.g. --extract-context 50)
- Add word matchers pre-filtering to 14 existing templates for performance
- Add 9 new HaE-inspired rules: lfi-indicator, upload-form, url-as-value,
  location-redirect, mac-address, sensitive-field, linkfinder, url-schemes,
  authorization-header
- Total proton templates: 45 (was 35)
- Update ColorString/TreeString to render severity and context
- Comprehensive tests for severity, context, new templates, tag mappings

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
2026-06-01 01:44:48 -07:00
M09IcandClaude Opus 4.8 5d3ddeae56 ci(dependabot): enable automated dependency updates
gomod (grouped golang.org/x/* and chainreactors/*) plus github-actions where present. No ignore on chainreactors/* so inter-repo deps are auto-updated.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
2026-05-29 10:23:59 -07:00
M09IcandClaude Opus 4.8 bd046d7c7f deps: use proxyclient v1.1.0 directly, drop replace
The replace pinned a pre-v1.0.3 pseudo-version up to the v1.0.3 release.
proxyclient v1.1.0 is now published, so require it directly and remove
the replace. Core schemes (SOCKS/SOCKS5/HTTP/HTTPS) cover spray's proxy
use; the extra protocols (trojan/vmess/ssh/...) are split into separate
modules in v1.1.0 but spray doesn't use them. go build ./... passes.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
2026-05-29 09:03:03 -07:00
M09IcandClaude Opus 4.6 d1b63ad67b fix: regenerate templates and fix logs API for updated submodule
go generate with the updated templates submodule (7d5675c) produces
different embedded data and code. Key changes:
- cmd/cmd.go: logs.Info/Important → logs.InfoLevel/ImportantLevel
- pkg/templates.go: remove proton_rules.bin/neutron.bin embeds (no longer needed)
- core/baseline: use ProtonExtract instead of Extractors.Extract
- core/format: list proton extractor names
- Update embedded binary data files

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
v1.3.0
2026-05-26 07:25:07 -07:00
M09IcandClaude Opus 4.6 f4b8adf642 ci: upgrade Go version to 1.25 for goreleaser workflow
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
2026-05-26 07:16:23 -07:00
M09IcandClaude Opus 4.6 f284cdbc20 chore: update templates submodule to latest upstream master
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
2026-05-26 07:14:22 -07:00
M09Ic d7b322ed8c fix: preserve pool outputs during close 2026-05-23 16:39:07 +08:00
M09Ic cb09e8eebf fix: add proton template loader 2026-05-23 15:59:35 +08:00
M09IcandClaude Opus 4.6 48ca310bdd fix: add missing embedded resource proton_rules.bin
The file was referenced by //go:embed but never committed,
causing build failures when consumed as a remote Go module.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
2026-05-22 23:58:05 +08:00
M09IcandClaude Opus 4.6 ba7cc844f7 chore: update fingers/proton/utils deps, remove local proton replace
Fingers now defaults to RE2 regex engine with AC pre-filtering.
No build tag changes needed — RE2 is the new default.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
2026-05-19 20:24:31 -07:00
M09IcandClaude Opus 4.6 a319b9b9e2 fix: drain additionCh in Close() to prevent wg.Wait hang after ctx cancel
When ctx is cancelled (e.g. IsFailed threshold), the Run loop breaks
and stops reading additionCh. But doCheck (now via addAddition) may
have queued items with wg.Add(1) that no one consumes. Close().wg.Wait()
hangs forever.

Fix: spawn a drain goroutine in Close() before wg.Wait() that consumes
and Done()s remaining additionCh items, then close the channel after
Wait returns.

Verified: 16 IPs x 2 ports x 1000 words completes with EXIT 0.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
2026-05-19 20:21:25 -07:00
M09IcandClaude Opus 4.6 c8b71dc47b feat: add --poc plugin for neutron-based vulnerability verification after fingerprint detection
Supports check mode (exploit verification via finger field) and brute mode
(default credential testing via zombie/tags field). POC templates are only
executed against targets whose fingerprints match, avoiding blind scanning.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
2026-05-19 20:17:05 -07:00
M09IcandClaude Opus 4.6 c179e1484f fix: resolve Handler-reqPool deadlock in doCheck and add CIDR E2E tests
Root cause: doCheck() called reqPool.Invoke() from the Handler goroutine.
When all reqPool workers blocked on sendProcess waiting for Handler to
drain processCh, and Handler blocked on Invoke waiting for a free worker,
a circular wait formed.

Fix: doCheck now uses addAddition() to submit check requests via
additionCh consumed by the Run loop, breaking the circular dependency.

Before: 16 targets x 500 words = HANG (>130s)
After:  16 targets x 500 words = 1.8s

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
2026-05-19 20:05:31 -07:00
M09IcandClaude Opus 4.6 c73a77408f fix: eliminate monitor goroutine race and simplify concurrency
Root cause: the atomic.Bool + polling monitor goroutine pattern had a
race between wg.Wait() in the monitor and wg.Add(1) in the main loop.
When the monitor observed done=true and started Wait, the main loop
could still dispatch new work, causing Close().wg.Wait() to hang.

Fix: replace with nil-channel + sync.Once pattern. When the word stream
exhausts or limit is hit, worderCh is set to nil (disabling that select
branch permanently), then a single goroutine waits for wg to reach zero.
Since wg.Add(1) only occurs in the worderCh branch, nil-ing it before
Wait guarantees no new Add after Wait starts — no race possible.

Other fixes:
- Task feeder goroutine now ctx-aware (prevents leak on cancel)
- AddPool checks Invoke error (prevents poolwg counter mismatch)
- Revert resource_provider IIFE (reading a struct field cannot panic)
- Remove E2E -short skip (race is fixed, full coverage in CI)
- Fix Go 1.24+ vet: non-constant format strings in Init()

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
2026-05-19 12:22:58 -07:00
M09IcandClaude Opus 4.6 11c90dc313 fix: resolve deadlock/panic risks and add comprehensive test coverage
Bug fixes:
- Defer scopeLocker.Unlock in doScopeCrawl (deadlock on panic)
- Defer statsMu.Unlock in recordStat (deadlock on panic)
- Defer RUnlock in resource_provider.LoadConfig via inline func
- Fix data race in invoke(): move bl field writes before doRedirect
- Close response body on ReadAll error (connection leak)
- Add defer raw.Close() for raw file parsing (fd leak)
- Safe type assertion in load.go keyword parsing (panic on bad YAML)
- Check ants pool creation errors in NewBrutePool/NewCheckPool

New tests (15 test functions):
- pool_test.go: scopeLocker panic recovery, cancel mid-processing,
  single-threaded map access, valid pool creation
- runner_test.go: concurrent recordStat safety, nil stat handling
- load_test.go: malformed YAML tolerance, valid YAML loading
- e2e_test.go: normal brute scan, context cancellation, server errors,
  WAF behavior, multi-target check mode, mixed status codes

CI hardening:
- Add -race detector (Linux, -short mode)
- Add -timeout 300s to prevent deadlock hangs

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
2026-05-19 11:36:42 -07:00
M09IcandClaude Opus 4.6 8d2dbe403d feat: switch templates from base64 to go:embed for smaller source and faster startup
- go:generate now uses -embed flag to produce //go:embed binary data
- templates.go reduced from 125KB base64 source to 0.9KB + 93KB .bin files
- binary saves ~28KB (removes base64 decode overhead at runtime)
- templates submodule updated with embed-aware generator

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
2026-05-19 10:48:37 -07:00
M09Ic 9c298d04b2 Use core fingers engine by default 2026-05-18 20:07:29 +08:00
M09Ic da17acac92 spray: fix adaptive filtering and stats 2026-05-16 11:32:51 +08:00
M09IcandClaude Opus 4.6 0a6132ca02 chore: normalize line endings (CRLF → LF)
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
2026-05-08 10:12:56 -07:00
M09IcandClaude Opus 4.6 b4e9b10c84 fix: null pointer guards and idempotency for embedded/SDK usage
- FingerEngine nil 检查防止未初始化时 panic (baseline.go, fingers.go)
- 日志/颜色/指纹引擎/Extractor 注册增加状态检查, 防止 SDK 多次调用时重复设置

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
2026-05-08 10:12:56 -07:00
M09IcandClaude Opus 4.6 2e32408efe fix: concurrency safety and graceful pool shutdown
- reqCount/failedCount 改为 atomic.Int64, done 改为 atomic.Bool
- rand.Source 加 sync.Mutex 防止并发 panic
- Invoke 失败时正确回退 wg 计数, 避免死锁
- 新增 waitWorkers() 排空残留消息, ctx.Done 正确设置退出标记
- Close() 增加 nil 检查防止 panic

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
2026-05-08 10:12:55 -07:00
M09IcandClaude Opus 4.6 161ce8b145 feat: add SDK integration hooks (BeforePrepare/AfterPrepare) and Help()
- RunOptions 新增 BeforePrepare/AfterPrepare 生命周期回调, 供 aiscan 控制初始化流程
- 新增 Help() 函数以编程方式获取命令行帮助文本

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
2026-05-08 10:12:55 -07:00
M09IcandClaude Opus 4.6 08886ebb7d refactor: 强化 BrutePool 隔离性, 统一 Runner channel 生命周期
- BrutePool: 去除 checkCh / closed / locker 等冗余字段, 用 atomic.Bool
  替换 done bool 修复 race, Init 失败路径正确回滚 wg + initwg,
  invoke/invokeNoScope 入口 defer wg.Done 保证配对, Close 顺序改为
  Cancel → wg.Wait → Release → close(processCh) → handlerDone
- Runner: RunWithBrute 结束时关闭 OutputCh/FuzzyCh (与 RunWithCheck
  对称, Runner 自管 channel 生命周期); r.Pools defer Release 修复
  SDK 多次 Execute 时的 ants goroutine 泄露; RunWithCheck 的 stopCh
  改为缓冲 1 修复 ctx 取消时的 goroutine 泄露

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
2026-05-08 10:12:55 -07:00
M09Ic b19a8341e9 feat: add resource provider override 2026-05-08 10:12:55 -07:00
M09Ic d887259fcb fix: load spray fingers from resource provider 2026-05-08 10:12:54 -07:00
M09Ic d2a22e4e01 feat: expose reusable spray runner entrypoint 2026-05-08 10:12:54 -07:00
M09IcandClaude Opus 4.6 5179d7a33c ci: add pool shutdown regression tests and PR CI workflow
Add 19 tests in core/pool/pool_test.go covering:
- addAddition: normal, after cancel, wg balance, full buffer, concurrent
- sendProcess: normal, after cancel, full buffer, concurrent
- putToOutput/putToFuzzy: normal, after cancel, Outwg balance
- Handler lifecycle: processCh close exits handler, drains all items
- Shutdown sequence: no deadlock, cancel mid-flight
- Goroutine leak detection after full shutdown

Add .github/workflows/ci.yml:
- Runs on PR to master and push to master
- Tests on ubuntu-latest and windows-latest
- go build, go test -race, go vet

Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-03-06 23:39:22 +08:00
M09IcandClaude Opus 4.6 7d293f8c72 fix: use ctx as unified shutdown signal to prevent channel close panics
- Replace additionClosed atomic with ctx-based guard in addAddition
- Add handlerDone chan to coordinate Handler goroutine lifecycle
- Add sendProcess method with select+ctx.Done protection
- Protect putToOutput/putToFuzzy/checkCh sends with select+ctx.Done
- Rewrite BrutePool.Close/CheckPool.Close with correct shutdown order:
  Cancel → Release pools → close(processCh) → <-handlerDone
- Fix doCrawl orphan wg.Add(1) with defer wg.Done()
- Fix analyzeDone inverted condition (replaced with handlerDone chan)
- Add ctx.Done check to Run monitor goroutine

Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-03-06 23:39:09 +08:00
M09IcandClaude Opus 4.6 263958e760 fix: prevent send-on-closed-channel panic and baseline invalid on raw parse failure
- Replace close(additionCh) with additionClosed atomic.Bool flag to
  prevent panic when async producers (redirect/crawl/retry/append)
  write after pool shutdown
- Guard addAddition() with ctx.Err() and additionClosed check before send
- ParseRawResponse failure no longer marks baseline as invalid or
  returns early; log at debug level instead
- Read Location header from live response (resp.GetHeader) instead of
  re-parsed bl.Response.Header for reliability
- Add ParseRawResponse boundary tests (nil, empty, truncated, binary, etc.)

Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-03-06 23:08:19 +08:00
M09Ic b11b5535db chore: support finger send_data v1.2.5 2026-02-12 15:20:08 +08:00
Copilotandchainreactorbot 6837b01818 Fix --recon to extract info-tagged data (phone, email, ID) (#133)
* Initial plan

* Fix --recon plugin to extract both pentest and info data

The --recon flag was only extracting items tagged as "pentest", missing
important reconnaissance information tagged as "info" such as phone numbers,
emails, and ID cards. This caused the plugin to appear broken compared to v1.2.1.

Changed BuildPlugin() to combine both "pentest" and "info" tagged extractors
when ReconPlugin is enabled, restoring the expected behavior of extracting
comprehensive reconnaissance data including:
- Phone numbers (info)
- Email addresses (info)
- AWS keys (pentest)
- Passwords (pentest)
- And other sensitive information

Tested with a sample HTML page containing phone, email, and AWS key data,
confirming all three are now properly extracted and displayed.

Co-authored-by: chainreactorbot <[email protected]>

* Add *.stat to .gitignore and remove test stat file

* Optimize --recon extractor initialization with pre-allocated capacity

Address code review feedback by pre-allocating the slice capacity based on
the combined size of pentest and info extractors. This avoids multiple
reallocations during append operations, improving performance.

Also simplified the conditional checks to use len() instead of map lookups,
which is more idiomatic and slightly more efficient.

Tested with multiple extraction types (phones, emails, IPs, AWS keys) and
confirmed all are properly extracted.

Co-authored-by: chainreactorbot <[email protected]>

* Simplify --recon extractor code by removing unnecessary length checks

Remove redundant length checks before append operations. The append operation
with spread operator safely handles empty slices without requiring explicit
guards, making the code cleaner and more idiomatic.

This change does not affect functionality - empty slices are appended safely
without any performance penalty.

Co-authored-by: chainreactorbot <[email protected]>

* Add nil-safety for --recon extractor initialization

Extract pentest and info extractors into variables before using them. This
approach is nil-safe because len() on nil slices returns 0 and append() with
nil slices works correctly in Go. This also makes the code cleaner by avoiding
repeated map lookups.

Addresses code review feedback about potential panics if the extractor maps
don't exist or are nil.

Co-authored-by: chainreactorbot <[email protected]>

* Remove binary and add spray to .gitignore

* Remove binary from repo and update .gitignore

Co-authored-by: chainreactorbot <[email protected]>

* Remove stat files that should be ignored

* Fix .gitignore to properly exclude stat files and binary

Co-authored-by: chainreactorbot <[email protected]>

* Complete --recon functionality fix with security verification

Co-authored-by: chainreactorbot <[email protected]>

* Revert go.mod and go.sum to keep go 1.20 version

按用户要求,不升级 go.mod 版本,保持原样:
- 恢复 go 版本从 1.21 到 1.20
- 移除 toolchain go1.24.12 行
- 恢复 go.sum 到之前的状态

已验证:
- 代码可以成功编译
- --recon 功能正常工作(提取 phone 和 mail)
- 所有功能保持不变

Co-authored-by: chainreactorbot <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: chainreactorbot <[email protected]>
2026-02-12 15:19:23 +08:00
M09Ic d733b4fb93 chore: check mod redirect 2026-01-29 01:27:29 +08:00
M09Ic 9a0858fd3c chore: fix new statistor 2026-01-29 00:34:04 +08:00
M09Ic 5661a4acad chore: bump fingers and neutron v1.2.4 2026-01-21 10:59:11 +08:00
root 20533e9d92 chore: remove NewDefaultOption and clean code 2026-01-21 10:41:13 +08:00
M09Ic 9a4c1af362 fix: request safe path join 2026-01-19 18:02:39 +08:00
M09Ic a3d7d1eccb fix: pool wg negative count 2026-01-19 18:02:18 +08:00
M09Ic 6618e025c3 fix: content type parse 2026-01-19 17:32:04 +08:00
M09Ic 709a701cf7 fix: addAddition deadlock 2025-12-10 11:27:04 +08:00
M09Ic a93d0397e6 chore: fix host brute not work 2025-12-09 11:30:16 +08:00
M09Ic 4e789b8f2e chore: update templates.go 2025-12-06 01:08:59 +08:00
M09Ic b364729bfc feat: check support host flag
- add function options validate
2025-12-05 18:31:29 +08:00
M09Ic 8030998b5e feat: support -o tree format 2025-12-05 14:25:35 +08:00
M09Ic f248e740ec chore: remove debug v1.2.3 2025-12-05 01:36:05 +08:00
M09Ic b388b2fda4 feat: add spray sdk 2025-12-05 01:33:57 +08:00
M09Ic 69e1d30143 chore: improve init config table 2025-12-05 01:10:37 +08:00
M09Ic d201ced3a9 feat: support --finger-file dynamic load fingers from file/url 2025-12-05 00:58:33 +08:00
M09Ic 5b0c90f967 feat: add --host flag, https://github.com/chainreactors/spray/issues/120.
fix: body not work, https://github.com/chainreactors/spray/issues/113
2025-12-05 00:58:33 +08:00