沉默的rekall python库日志记录输出

时间:2018-08-07 10:50:41

标签: python logging

我创建了脚本rekall_offset_finder.py,该脚本正在导入Rekall内存取证框架,以从内存转储中提取各种内核偏移。

我在记录日志输出时遇到了问题,我觉得我无法完全控制住。

首先,在导入库时,我不得不使用一个小技巧来删除 Rekall logging.basicConfig(),以便我可以配置自己的日志记录级别:

    # remove Rekall basicConfig()
    for handler in logging.root.handlers[:]:
        logging.root.removeHandler(handler)
    # configure my logging level
    logging.basicConfig(level=log_level)

现在,我仍然收到烦人的输出消息:

./rekall_offset_finder.py -u qemu:///session winxp
INFO:root:Dumping winxp physical memory to /tmp/tmpsuam8btj/tmpa30uvrc5
WARNING:root:Unable to determine file size, assuming file is volatile.
INFO:root:Autodetected physical address space Elf64CoreDump
INFO:root:Loaded profile pe from Local Cache - (in 0.0884544849395752 sec)
INFO:root:Loaded profile nt/GUID/7075F995A48A414F8F7BE9A1E0240F821 from Local Cache - (in 0.21683239936828613 sec)
INFO:root:Loaded profile nt/eprocess_index from Local Cache - (in 0.19333624839782715 sec)
INFO:root:Detected ntkrpamp.pdb with GUID 7075F995A48A414F8F7BE9A1E0240F821
INFO:root:Detected kernel base at 0x804D7000
Trying to fetch http://msdl.microsoft.com/download/symbols/ntkrpamp.pdb/7075F995A48A414F8F7BE9A1E0240F821/ntkrpamp.pdb
INFO:root:Loaded profile mspdb from Local Cache - (in 0.08299803733825684 sec)

其中一些消息不是我的。

我知道我可以通过致电logging.getLogger(name).setLevel(logging.WARNING)

使他们沉默

-> 如何确定要静音的记录器的名称?

->是否可以列出所有可用的记录器?

谢谢!

1 个答案:

答案 0 :(得分:0)

@hoefling已将解决方案提供给我。

我将我的根记录器传递为Rekall的会话记录器。

通过删除它,Rekall必须创建它自己的记录器,并且它具有一个新的命名空间:rekall.1

WARNING:rekall.1:Unable to determine file size, assuming file is volatile.

要使其静音,我使用了:

logging.getLogger('rekall.1').setLevel(logging.CRITICAL)

要确定可用的记录器,您可以使用:

logging.Logger.manager.loggerDict.keys()

谢谢!

相关问题