Search code examples
pythonhttpresponsescapy

Python-Scapy HTTP Traffic Manipulation


I need to intercept an HTTP Response packet from the server and replace it with my own response, or at least modify that response, before it arrives to my browser.

I'm already able to sniff this response and print it, the problem is with manipulating/replacing it.

  • Is there a way to do so wiht scapy library ?
  • Or do i have to connect my browser through a proxy to manipulate the response ?

Solution

  • If you want to work from your ordinary browser, then you need proxy between browser and server in order to manipulate it. E.g. see https://portswigger.net/burp/ which is a proxy specifically created for penetration testing with easy replacing of responses/requests (which is sriptable, too).

    If you want to script all your session in scapy, then you can create requests and responses to your liking, but response does not go to the browser. Also, you can record ordinary web session (with tcpdump/wireshark/scapy) into pcap, then use scapy to read pcap modify it and send similar requests to the server.