如何使用go-yara扫描进程?

问题描述

我有一些yara规则,我想用它们在golang中扫描一个进程。
我已经找到了这个go-yara项目(https://github.com/hillu/go-yara),在大多数情况下,我都按照他们的示例代码进行了工作。
但是,当我尝试扫描进程时,总是出现错误Could not attach to process

为简单起见,我尝试扫描我创建的睡眠过程

sleep 100 &

将此过程的PID赋予我的程序,并尝试像使用go-yara示例中一样对它进行扫描

err = yaraRules.ScanProc(processID,10,&matches)

但是每次我只会得到Could not attach to process
我尝试扫描一些不同的进程,并尝试以root用户身份运行程序,但未做任何更改。

任何指导将不胜感激。

这是我的代码,用于初始化Yararules

func parseYaraRules(rules string) {
        logger.Debug("Compiling Yara Rules")
        compiler,err := yara.NewCompiler()
        if err != nil {
                logger.Errorf("Failed to initalize Yara compiler: %s",err)
        }

        file,err := os.Open(rules)
        if err != nil {
                logger.Errorf("Could not open rule file %s: %s",rules,err)
        }
        err = compiler.AddFile(file,"my-namespace")
        file.Close()
        if err != nil {
                logger.Errorf("Could not parse rule file %s: %s",err)
        }

        yaraRules,err = compiler.GetRules()
        if err != nil {
                logger.Errorf("Failed to compile rules: %s",err)
        } else {
                logger.Debug("Successfully compiled yara rules")
        }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)