Created
September 21, 2014 08:39
-
-
Save y0ug/bd7b2c94943afac276f9 to your computer and use it in GitHub Desktop.
Extract task scheduler log from evtx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mmap | |
import contextlib | |
import argparse | |
from bs4 import BeautifulSoup, element | |
from Evtx.Evtx import FileHeader | |
from Evtx.Views import evtx_file_xml_view | |
def main(): | |
parser = argparse.ArgumentParser( | |
description="Dump a binary EVTX file into XML.") | |
parser.add_argument("evtx", type=str, | |
help="Path to the Windows System EVTX event log file") | |
args = parser.parse_args() | |
with open(args.evtx, 'r') as f: | |
with contextlib.closing(mmap.mmap(f.fileno(), 0, | |
access=mmap.ACCESS_READ)) as buf: | |
fh = FileHeader(buf, 0x0) | |
for xml, record in evtx_file_xml_view(fh): | |
soup = BeautifulSoup(xml) | |
eventid = int(soup.event.system.eventid.string) | |
date = soup.event.system.timecreated['systemtime'] | |
processid = soup.event.system.execution['processid'] | |
threadid = soup.event.system.execution['threadid'] | |
out = "%s; %s; %s; %s" % (eventid, date, processid, threadid) | |
for child in soup.eventdata.children: | |
if type(child) is element.Tag: | |
out += "; %s: %s " % (child['name'], child.text) | |
if eventid == 200: | |
print out | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment