-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSniff_and_Spoof.py
34 lines (26 loc) · 1.06 KB
/
Sniff_and_Spoof.py
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
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python3
from scapy.all import *
# Task 1.4 ----------------------------------------------
# Lookup the code in the lecture
def spoof_pkt(pkt):
# sniff and print out icmp echo request packet
if ICMP in pkt and pkt[ICMP.type == 8:
print("Original Packet...........")
print("Source IP : ", pkt[IP].src)
print("Destination IP :", pkt[IP].dst)
# spoof an icmp echo reply packet
# swap srcip and dstip
ip = IP(src=pkt[IP].dst, dst=pkt[IP].src, ihl=pkt[IP].ihl)
icmp = ICMP(type=0, id=pkt[ICMP].id, seq=pkt[ICMP].seq)
data = pkt[Raw].load
newpkt = ip/icmp/data
print("Spoofed Packet..............")
print("Source IP : "' newpkt[IP}.src)
print("Destination IP :", newpkt[IP].dst)
send(newpkt, verbose=0)
#filter = 'icmp and host 1.2.3.4'
#filter = 'icmp and host 10.9.0.99'
#filter = 'icmp and host 8.8.8.8'
#filter = 'icmp and host host 8.8.4.4'
#print("filter:{}\n".format(filter))
pkt = sniff(iface = 'br-6d54bbcb5aeb', filter=filter, prn=spoof_pkt)