Instantly share code, notes, and snippets.

What would you like to do?
Parse tcpflow report to find time of connections
#!/usr/bin/env python
import untangle
import datetime
date_format = '%Y-%m-%dT%H:%M:%S.%fZ'
obj = untangle.parse('report.xml')
for fileobject in obj.dfxml.configuration.fileobject:
tcpflow = fileobject.tcpflow
startime = datetime.datetime.strptime(tcpflow['startime'], date_format)
endtime = datetime.datetime.strptime(tcpflow['endtime'], date_format)
delta = endtime - startime
print str(delta.seconds) + ":" + str(delta.microseconds) + " | " + str(startime)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment