refactor: 完成全局状态到 session 的完整迁移

将 plugins/services、plugins/local、plugins/web、webscan 层的日志输出、
漏洞结果保存和 TCP 计数器从全局 common.Log*/GetGlobalState() 迁移到
session 实例方法,确保 SDK 并发扫描时各实例完全隔离。

- 50 个文件,所有插件日志走 session.Log*
- DoRequest 加入 session 参数,计数器走 session.State
- POC 执行器通过 POCContext.Session 传递
- 仅保留 init() 和 CEL runtime 等无 session 场景的全局回退
This commit is contained in:
ZacharyZcR
2026-06-01 08:13:23 +08:00
parent 569d21a8bc
commit d6d323854a
50 changed files with 256 additions and 225 deletions
+4 -4
View File
@@ -68,7 +68,7 @@ func (p *ReverseShellPlugin) Scan(ctx context.Context, info *common.HostInfo, se
output.WriteString(i18n.Tr("local_platform", runtime.GOOS) + "\n\n")
// 启动反弹Shell
err = p.startNativeReverseShell(ctx, host, port, state)
err = p.startNativeReverseShell(ctx, host, port, state, session)
if err != nil {
output.WriteString(i18n.Tr("reverseshell_error", err) + "\n")
return &plugins.Result{
@@ -79,7 +79,7 @@ func (p *ReverseShellPlugin) Scan(ctx context.Context, info *common.HostInfo, se
}
output.WriteString(i18n.GetText("reverseshell_done") + "\n")
common.LogSuccess(i18n.Tr("reverseshell_complete", target))
session.LogSuccess(i18n.Tr("reverseshell_complete", target))
return &plugins.Result{
Success: true,
@@ -90,7 +90,7 @@ func (p *ReverseShellPlugin) Scan(ctx context.Context, info *common.HostInfo, se
}
// startNativeReverseShell 启动Go原生反弹Shell
func (p *ReverseShellPlugin) startNativeReverseShell(ctx context.Context, host string, port int, state *common.State) error {
func (p *ReverseShellPlugin) startNativeReverseShell(ctx context.Context, host string, port int, state *common.State, session *common.ScanSession) error {
// 连接到目标
conn, err := net.Dial("tcp", net.JoinHostPort(host, strconv.Itoa(port)))
if err != nil {
@@ -98,7 +98,7 @@ func (p *ReverseShellPlugin) startNativeReverseShell(ctx context.Context, host s
}
defer func() { _ = conn.Close() }()
common.LogSuccess(i18n.Tr("reverseshell_connected", host, port))
session.LogSuccess(i18n.Tr("reverseshell_connected", host, port))
// 设置反弹Shell为活跃状态
state.SetReverseShellActive(true)