Skip to content

Instantly share code, notes, and snippets.

@bborysenko
Created September 7, 2015 12:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bborysenko/8c87500c92419db40725 to your computer and use it in GitHub Desktop.
Save bborysenko/8c87500c92419db40725 to your computer and use it in GitHub Desktop.
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