Skip to content

Instantly share code, notes, and snippets.

@bityob
Last active January 8, 2017 22:13
Show Gist options
  • Select an option

  • Save bityob/9a04666ab3c32efbe09ca70945cd7612 to your computer and use it in GitHub Desktop.

Select an option

Save bityob/9a04666ab3c32efbe09ca70945cd7612 to your computer and use it in GitHub Desktop.
Print http conversation from pcap file using Scapy
GET / HTTP/1.1
Host: ifconfig.co
User-Agent: curl/7.47.0
Accept: */*
HTTP/1.1 200 OK
Server: nginx
Date: Sun, 08 Jan 2017 20:01:11 GMT
Content-Type: text/plain; charset=utf-8
Content-Length: 14
Connection: keep-alive
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
66.77.120.171
GET /json HTTP/1.1
Host: ifconfig.co
User-Agent: curl/7.47.0
Accept: */*
HTTP/1.1 429
Server: nginx
Date: Sun, 08 Jan 2017 20:01:17 GMT
Content-Type: text/plain
Content-Length: 22
Connection: keep-alive
429 Too Many Requests
GET /port/8080 HTTP/1.1
Host: ifconfig.co
User-Agent: curl/7.47.0
Accept: */*
HTTP/1.1 200 OK
Server: nginx
Date: Sun, 08 Jan 2017 20:01:39 GMT
Content-Type: application/json
Content-Length: 52
Connection: keep-alive
Vary: Accept-Encoding
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
{"ip":"66.77.120.171","port":8080,"reachable":false}
from scapy.all import *
import sys
pcap_file = sys.argv[1]
pckt = rdpcap(pcap_file)
for p in pckt:
if (p.dport == 80 or p.sport == 80):
flags = p.sprintf("%TCP.flags%")
if flags == 'PA':
print p.load
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment