Skip to content

Instantly share code, notes, and snippets.

@truekonrads
Last active August 22, 2020 01:02
Show Gist options
  • Save truekonrads/8953b4ad5f650594ba631b0a4158e804 to your computer and use it in GitHub Desktop.
Save truekonrads/8953b4ad5f650594ba631b0a4158e804 to your computer and use it in GitHub Desktop.
Retrieve a particular http2 stream for packet capture
#!/usr/bin/env python
import pyshark
import sys
cap=pyshark.FileCapture(sys.argv[1])
targetstream=sys.argv[2]
for p in cap:
if "http2" in p:
i=0
for s in p.http2.stream.all_fields:
val=s.showname_value
if val.startswith("DATA"):
if "Stream ID: {}".format(targetstream) in val:
sys.stdout.write(p.http2.data_data.all_fields[i].binary_value)
i+=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment