Evtx.BinaryParser.OverrunBufferException raised unexpectedly
還沒有人認領這個 Issue。
評估
研究方向
Start with the reported failure path in Evtx/Nodes.py while parsing substitutions and loading templates, then trace the buffer reads in Evtx/BinaryParser.py and reproduce with one of the named Windows 7 EVTX files using evtx_dump.py. The report identifies several affected logs and Python versions; done means those files parse without runaway allocations or buffer overrun exceptions. The issue offers to provide sample files, but no sample or specific failing test is named.
由索引模型根據 Issue 內容生成。
描述
Hi,
I'm seeing exception Evtx.BinaryParser.OverrunBufferException raised unexpectedly when parsing event logs "Microsoft-Windows-Windows Firewall With Advanced Security%4Firewall.evtx", "Microsoft-Windows-WindowsUpdateClient%4Operational.evtx", and "Microsoft-Windows-CAPI2%4Operational.evtx" (all extracted from a Windows 7 testing instance) using evtx_dump.py.
For Microsoft-Windows-Windows Firewall With Advanced Security%4Firewall.evtx, the same behaviour is seen across Windows with Python 2.7 and Ubuntu with Python 2.7 / 3.5. Traceback from Ubuntu with Python 3.5 as follows:
Traceback (most recent call last):
File "/home/user/.local/lib/python3.5/site-packages/Evtx/BinaryParser.py", line 273, in unpack_byte
return struct.unpack_from("<B", self._buf, o)[0]
struct.error: unpack_from requires a buffer of at least 1 bytes
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/user/.local/bin/evtx_dump.py", line 42, in <module>
main()
File "/home/user/.local/bin/evtx_dump.py", line 37, in main
print(record.xml())
File "/home/user/.local/lib/python3.5/site-packages/Evtx/Evtx.py", line 481, in xml
return e_views.evtx_record_xml_view(self)
File "/home/user/.local/lib/python3.5/site-packages/Evtx/Views.py", line 204, in evtx_record_xml_view
return render_root_node(record.root())
File "/home/user/.local/lib/python3.5/site-packages/Evtx/Views.py", line 182, in render_root_node
for sub in root_node.substitutions():
File "/home/user/.local/lib/python3.5/site-packages/Evtx/BinaryParser.py", line 64, in __call__
cache[key] = self.func(*args, **kw)
File "/home/user/.local/lib/python3.5/site-packages/Evtx/Nodes.py", line 1001, in substitutions
ofs = self.tag_and_children_length()
File "/home/user/.local/lib/python3.5/site-packages/Evtx/Nodes.py", line 962, in tag_and_children_length
for child in self.children():
File "/home/user/.local/lib/python3.5/site-packages/Evtx/BinaryParser.py", line 64, in __call__
cache[key] = self.func(*args, **kw)
File "/home/user/.local/lib/python3.5/site-packages/Evtx/Nodes.py", line 952, in children
return self._children(end_tokens=[SYSTEM_TOKENS.EndOfStreamToken])
File "/home/user/.local/lib/python3.5/site-packages/Evtx/Nodes.py", line 153, in _children
self._chunk, self)
File "/home/user/.local/lib/python3.5/site-packages/Evtx/Nodes.py", line 777, in __init__
parent=self)
File "/home/user/.local/lib/python3.5/site-packages/Evtx/Evtx.py", line 398, in add_template
self._load_templates()
File "/home/user/.local/lib/python3.5/site-packages/Evtx/Evtx.py", line 380, in _load_templates
token = self.unpack_byte(ofs - 10)
File "/home/user/.local/lib/python3.5/site-packages/Evtx/BinaryParser.py", line 275, in unpack_byte
raise OverrunBufferException(o, len(self._buf))
Evtx.BinaryParser.OverrunBufferException: Tried to parse beyond the end of the file (read: 0x240f0ff7, buffer length: 0x101000)
For Microsoft-Windows-WindowsUpdateClient%4Operational.evtx, Python 3.5 on Ubuntu gives Evtx.BinaryParser.OverrunBufferException, while Python 2.7 on Windows / Ubuntu gives a MemoryError. Python 3.5 traceback as follows:
Traceback (most recent call last):
File "/home/user/.local/lib/python3.5/site-packages/Evtx/BinaryParser.py", line 273, in unpack_byte
return struct.unpack_from("<B", self._buf, o)[0]
struct.error: unpack_from requires a buffer of at least 1 bytes
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/user/.local/bin/evtx_dump.py", line 42, in <module>
main()
File "/home/user/.local/bin/evtx_dump.py", line 37, in main
print(record.xml())
File "/home/user/.local/lib/python3.5/site-packages/Evtx/Evtx.py", line 481, in xml
return e_views.evtx_record_xml_view(self)
File "/home/user/.local/lib/python3.5/site-packages/Evtx/Views.py", line 204, in evtx_record_xml_view
return render_root_node(record.root())
File "/home/user/.local/lib/python3.5/site-packages/Evtx/Views.py", line 182, in render_root_node
for sub in root_node.substitutions():
File "/home/user/.local/lib/python3.5/site-packages/Evtx/BinaryParser.py", line 64, in __call__
cache[key] = self.func(*args, **kw)
File "/home/user/.local/lib/python3.5/site-packages/Evtx/Nodes.py", line 1006, in substitutions
type_ = self.unpack_byte(ofs + 0x2)
File "/home/user/.local/lib/python3.5/site-packages/Evtx/BinaryParser.py", line 275, in unpack_byte
raise OverrunBufferException(o, len(self._buf))
Evtx.BinaryParser.OverrunBufferException: Tried to parse beyond the end of the file (read: 0x101000, buffer length: 0x101000)
Python 2.7 traceback (from Ubuntu) as follows:
Traceback (most recent call last):
File "/home/user/.local/bin/evtx_dump.py", line 42, in <module>
main()
File "/home/user/.local/bin/evtx_dump.py", line 37, in main
print(record.xml())
File "/home/user/.local/lib/python2.7/site-packages/Evtx/Evtx.py", line 481, in xml
return e_views.evtx_record_xml_view(self)
File "/home/user/.local/lib/python2.7/site-packages/Evtx/Views.py", line 204, in evtx_record_xml_view
return render_root_node(record.root())
File "/home/user/.local/lib/python2.7/site-packages/Evtx/Views.py", line 182, in render_root_node
for sub in root_node.substitutions():
File "/home/user/.local/lib/python2.7/site-packages/Evtx/BinaryParser.py", line 64, in __call__
cache[key] = self.func(*args, **kw)
File "/home/user/.local/lib/python2.7/site-packages/Evtx/Nodes.py", line 1004, in substitutions
for _ in range(sub_count):
MemoryError
And similarly for Microsoft-Windows-CAPI2%4Operational.evtx, Python 3.5 on Ubuntu gives Evtx.BinaryParser.OverrunBufferException, while Python 2.7 on Windows / Ubuntu BSODs / has process 'Killed'. Traceback for Python 3.5 on Ubuntu as follows:
Traceback (most recent call last):
File "/home/user/.local/lib/python3.5/site-packages/Evtx/BinaryParser.py", line 302, in unpack_word
return struct.unpack_from("<H", self._buf, o)[0]
struct.error: unpack_from requires a buffer of at least 2 bytes
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/user/.local/bin/evtx_dump.py", line 42, in <module>
main()
File "/home/user/.local/bin/evtx_dump.py", line 37, in main
print(record.xml())
File "/home/user/.local/lib/python3.5/site-packages/Evtx/Evtx.py", line 481, in xml
return e_views.evtx_record_xml_view(self)
File "/home/user/.local/lib/python3.5/site-packages/Evtx/Views.py", line 204, in evtx_record_xml_view
return render_root_node(record.root())
File "/home/user/.local/lib/python3.5/site-packages/Evtx/Views.py", line 191, in render_root_node
return render_root_node_with_subs(root_node, subs)
File "/home/user/.local/lib/python3.5/site-packages/Evtx/Views.py", line 176, in render_root_node_with_subs
rec(c, acc)
File "/home/user/.local/lib/python3.5/site-packages/Evtx/Views.py", line 126, in rec
rec(child, acc)
File "/home/user/.local/lib/python3.5/site-packages/Evtx/Views.py", line 126, in rec
rec(child, acc)
File "/home/user/.local/lib/python3.5/site-packages/Evtx/Views.py", line 166, in rec
sub = render_root_node(sub.root())
File "/home/user/.local/lib/python3.5/site-packages/Evtx/Views.py", line 182, in render_root_node
for sub in root_node.substitutions():
File "/home/user/.local/lib/python3.5/site-packages/Evtx/BinaryParser.py", line 64, in __call__
cache[key] = self.func(*args, **kw)
File "/home/user/.local/lib/python3.5/site-packages/Evtx/Nodes.py", line 1005, in substitutions
size = self.unpack_word(ofs)
File "/home/user/.local/lib/python3.5/site-packages/Evtx/BinaryParser.py", line 304, in unpack_word
raise OverrunBufferException(o, len(self._buf))
Evtx.BinaryParser.OverrunBufferException: Tried to parse beyond the end of the file (read: 0x101000, buffer length: 0x101000)
I can forward the EVTX files in question if that assists?
- 主要語言
- Python
- 星號
- 786
- 分支
- 170
- 平均合併
- 2 天 21 小時
- 30 天內合併 PR
- 1
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
williballenthin/python-evtx 的其他 Issue
-
Infinite loop in ChunkHeader._load_strings / _load_templates on a crafted chunk (cyclic next_offset)可能已有人在做 @memx13 於 10 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
williballenthin/python-evtx#101 ·
-
難度 5/5 一週以上 新手友好度 25/100
-
難度 4/5 3-5 天 新手友好度 35/100
-
難度 2/5 1-3 小時 新手友好度 42/100
williballenthin/python-evtx#94 · 2 則留言 ·
-
bug
難度 4/5 3-5 天 新手友好度 35/100
williballenthin/python-evtx#85 · 2 則留言 ·
查看 williballenthin/python-evtx 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 72/100
pytest-dev/pyfakefs#1367 · 1 則留言 ·
維護者通常 2 天內回覆
-
IFEvalG exclude_word_harder misses the keyword next to punctuation, at the start or end of the text, and in other letter case可能已有人在做 @damienen 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 76/100
allenai/open-instruct#2151 ·
維護者通常 1 天內回覆
-
feat(plan): support convertorLabels and convertorAffinity in Plan resource可能已有人在做 @AmenB 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 82/100
RedHatQE/openshift-python-wrapper#2849 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 65/100
維護者通常 25 天內回覆
-
難度 2/5 1-3 小時 新手友好度 70/100
libnativeapi/nativeapi#21 ·