diff --git a/auto.json b/Plugins/local/avdetect/auto.json similarity index 100% rename from auto.json rename to Plugins/local/avdetect/auto.json diff --git a/Plugins/local/avdetect/plugin.go b/Plugins/local/avdetect/plugin.go index 6f25772..6dfef10 100644 --- a/Plugins/local/avdetect/plugin.go +++ b/Plugins/local/avdetect/plugin.go @@ -3,6 +3,7 @@ package avdetect import ( "bufio" "context" + _ "embed" "encoding/json" "fmt" "os" @@ -18,6 +19,9 @@ import ( "github.com/shadow1ng/fscan/plugins/local" ) +//go:embed auto.json +var embeddedAVDatabase []byte + // AVDetectPlugin AV/EDR检测插件 type AVDetectPlugin struct { *local.BaseLocalPlugin @@ -325,41 +329,16 @@ func (p *AVDetectPlugin) ScanLocal(ctx context.Context, info *common.HostInfo) ( // loadAVDatabase 加载AV/EDR数据库 func (p *AVDetectPlugin) loadAVDatabase() error { - // 尝试多个可能的配置文件路径 - possiblePaths := []string{ - p.configPath, - "auto.json", - filepath.Join(".", "auto.json"), - filepath.Join("config", "auto.json"), - filepath.Join("..", "auto.json"), - } - - var configData []byte - var err error - var usedPath string - - for _, path := range possiblePaths { - configData, err = os.ReadFile(path) - if err == nil { - usedPath = path - break - } - } + // 首先尝试使用嵌入的数据库 + common.LogDebug("使用嵌入的AV/EDR规则数据库") + err := json.Unmarshal(embeddedAVDatabase, &p.avDatabase) if err != nil { - return fmt.Errorf("无法找到配置文件 auto.json: %v", err) - } - - common.LogDebug(fmt.Sprintf("使用配置文件: %s", usedPath)) - - // 解析JSON - err = json.Unmarshal(configData, &p.avDatabase) - if err != nil { - return fmt.Errorf("解析配置文件失败: %v", err) + return fmt.Errorf("解析嵌入的AV数据库失败: %v", err) } if len(p.avDatabase) == 0 { - return fmt.Errorf("配置文件为空或格式错误") + return fmt.Errorf("嵌入的AV数据库为空或格式错误") } return nil