williballenthin / python-evtx

Pure Python parser for Windows Event Log files (.evtx)
Apache License 2.0
732 stars 166 forks source link

Errors while running #54

Open ghost opened 5 years ago

ghost commented 5 years ago

The following errors occur for the program when I run it. Previously it was running perfectly fine but now it doesn't get corrected. Does anyone have any ideas on how to correct these?

Traceback (most recent call last):
  File "C:\Users\Admin\Desktop\HTC\python-evtx\scripts\evtx_filter_records.py", line 65, in <module>
    main()
  File "C:\Users\Admin\Desktop\HTC\python-evtx\scripts\evtx_filter_records.py", line 56, in main
    for node, err in xml_records(args.evtx):
  File "C:\Users\Admin\Desktop\HTC\python-evtx\scripts\evtx_filter_records.py", line 30, in xml_records
    yield to_lxml(xml), None
  File "C:\Users\Admin\Desktop\HTC\python-evtx\scripts\evtx_filter_records.py", line 15, in to_lxml
    record_xml)
  File "src\lxml\etree.pyx", line 3211, in lxml.etree.fromstring
  File "src\lxml\parser.pxi", line 1872, in lxml.etree._parseMemoryDocument
ValueError: Unicode strings with encoding declaration are not supported. Please use bytes input or XML fragments without declaration.
williballenthin commented 5 years ago

what changed since the last time it was running fine?

ghost commented 5 years ago

nothing actually. I didn't run it for a few days and the next time I did, it shows these errors

ghost commented 5 years ago

Hey, anyone else who had this issue? Did it get rectified??

IceM4nn commented 5 years ago

Add .encode('utf-8') at line 15 file evtx_filter_records.py after record_xml like so:

    return etree.fromstring("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>%s" %
                         record_xml.encode('utf-8'))

This fixes the error.