1
votes

Is it possible to use Python to set up a "listener" service to inspect outgoing HTTP requests on a machine and their incoming responses and return their contents (URL, headers, etc) in an easily readable format? Do any good libraries exist for this purpose? The ideal application should be able to capture requests made by browsers and applications to web sites or web services (SOAP, REST, etc).

2

2 Answers

2
votes

Network sniffers like wireshark using libpcap to sniff traffic from network interfaces. There is a python module for this: pylibpcap

0
votes

FTR, if you want something a bit more high level, you can chose to use Scapy 2.4.3+

from scapy.layers.http import *
from scapy.sendrecv import sniff
packets = sniff()

See https://scapy.readthedocs.io/en/latest/layers/http.html