【问题标题】:OSquery - How to preload data to find infected filesOSquery - 如何预加载数据以查找受感染的文件
【发布时间】:2019-03-03 18:36:22
【问题描述】:

我必须在网络演习期间“接管”一些已被感染的 Windows 工作站和服务器。 计划是设置例如。一个干净的带有最新补丁的 Windows 7 工作站...然后将受感染的工作站 7 更新为最新的补丁...加载 osquery 数据(文件校验和、文件所有者/组、权限等)并根据此已知信息检查受感染的工作站'基线'。 有没有用 osquery 做这件事的好方法,或者您是否为此推荐了其他工具?

【问题讨论】:

    标签: baseline osquery


    【解决方案1】:

    我不确定您所说的“加载 osquery 数据”究竟是什么意思,但您可以使用 osquery 确定地查询该信息。例如,以下将允许您获取用户下载目录中所有文件的文件信息(包括权限、所有者等):

    select * from file where path like '/Users/user/Downloads/%';
    

    如果您需要哈希,可以查询hash 表:

    select * from hash where path like '/Users/user/Downloads/%';
    

    【讨论】:

    • 也许要澄清一下:我想在干净、全新安装的系统上创建 OSquery 文件信息(哈希、大小、权限等),并使用该数据在不同的系统上查找更改/木马化的文件(当然,两个系统都有相同的 OS/patch_level)。这有可能吗……?
    • 您可以使用 osquery 查询干净机器上的信息,然后进行查询以查找差异,例如查询像 select * from hash where path = '<myfile> and md5 != '<known_hash>'; 这样的哈希表。但是 osquery 没有任何功能可以将结果与基线进行比较。
    【解决方案2】:

    这应该是可行的,但是您的问题非常广泛。获得一个已知良好的 Windows 7 系统外观的基线在很大程度上取决于您关心的内容。我建议做的是获取一些您认为可能对您的特定调查很重要的表的 json 转储,因此可能类似于:

    PS C:\Users\thor\Desktop> osqueryi --json -A drivers
    PS C:\Users\thor\Desktop> osqueryi --json -A programs
    PS C:\Users\thor\Desktop> osqueryi --json -A users
    PS C:\Users\thor\Desktop> osqueryi --json -A startup_items
    PS C:\Users\thor\Desktop> osqueryi --json "select f.filename, f.path, h.md5, h.sha256 from file f, hash h where h.path = f.path and f.path like 'C:\Windows\%';"
    PS C:\Users\thor\Desktop> osqueryi --json "select f.filename, f.path, h.md5, h.sha256 from file f, hash h where h.path = f.path and f.path like 'C:\Windows\system32\%%';"
    PS C:\Users\thor\Desktop> osqueryi --json -A scheduled_tasks
    PS C:\Users\thor\Desktop> osqueryi --json -A certificates
    

    注意这绝对不是一个详尽的列表,只是一些值得检查的东西。我还建议添加上面提到的查询@fmanco。

    一旦您使用来自基线系统的数据构建了大量 JSON blob 列表,您就可以对受感染的系统运行相同的查询,并“比较”json 输出以查找差异。这可能会变得非常棘手,尤其是在考虑 C:\Windows\system32\%% 文件的哈希时,考虑到即使在系统的相同补丁版本上哈希值也会有很大差异,仅供参考。

    希望有帮助!

    【讨论】:

      【解决方案3】:

      你可能对https://github.com/Netflix-Skunkworks/diffy感兴趣

      这是一个旨在比较主机之间差异的工具。

      【讨论】:

        猜你喜欢
        • 2018-09-20
        • 1970-01-01
        • 1970-01-01
        • 2013-10-14
        • 2023-04-06
        • 1970-01-01
        • 2011-03-03
        • 2016-05-08
        • 2022-06-17
        相关资源
        最近更新 更多