I have a pcap with many tcp/http sessions. I would like to be able to handle each session as an object. Ideally, i could see all the requests in the sessions (get, post ...) and all of the responses to these requests. Each request and response will have it's headers as dictionary, etc.
so i want smth that does this: import smth
pcap_obj = smth.readpcap('pcap_file.txt')
for session in pcap_obj:
for req in session.requests():
print req.headers['Content-Type']
...
print req.body
for req in session.responses():
print res.status_code
print res.body
...
I know about scapy, and managed to read pcap, and get the list of sessions. But those are raw tcps, and i need to reconstruct and parse the HTTP. I've seen that BaseHTTPServer might have something like this, but it seems it's mainly to parse requests, and doesn't handle sessions with multiple requests.
Any ideas?