Created
September 21, 2014 08:40
-
-
Save y0ug/7f2877526e27f51e1fe9 to your computer and use it in GitHub Desktop.
Extract usb connection from evtx files
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
#!/bin/python | |
import mmap | |
import contextlib | |
import argparse | |
from bs4 import BeautifulSoup | |
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'] | |
if eventid == 20001: | |
deviceinstanceid = soup.userdata.installdeviceid.deviceinstanceid.text | |
driverdescription = soup.userdata.installdeviceid.driverdescription.text | |
print "%s; %s; %s; %s" % (eventid, date, deviceinstanceid, driverdescription) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment