Open atcuno opened 5 years ago
I'm using this script a lot, with great results, and have also encountered this problem when converting some logs that contain illegal characters in its data for whatever reason. Here's a quick and dirty fix that did the trick for me:
In Evtx/Nodes.py:
def string(self):
binary = self.binary()
acc = []
while len(binary) > 0:
match = re.search(b"((?:[^\x00].)+)", binary)
if match:
frag = match.group()
acc.append("<string>")
# Begin change: add try/except block for handling illegal characters
try:
acc.append(frag.decode("utf16"))
except:
acc.append("[ILLEGAL CHARACTER]")
# End change
acc.append("</string>\n")
binary = binary[len(frag) + 2:]
if len(binary) == 0:
break
frag = re.search(b"(\x00*)", binary).group()
if len(frag) % 2 == 0:
for _ in range(len(frag) // 2):
acc.append("<string></string>\n")
else:
raise ParseException("Error parsing uneven substring of NULLs")
binary = binary[len(frag):]
return "".join(acc)
Of course, the "[ILLEGAL CHARACTER]" string could be something shorter.