ttl script
This commit is contained in:
parent
732ac7989f
commit
7ee5db4120
@ -1,10 +1,11 @@
|
||||
import sys
|
||||
from scapy.all import sniff, send, IP, IPv6
|
||||
from scapy.all import sniff, send, IP, IPv6, Packet, Raw, Ether, sendp
|
||||
from datetime import datetime
|
||||
|
||||
modifications = 0
|
||||
|
||||
def modify_packet(packet):
|
||||
def modify_packet(packet: Packet):
|
||||
global modifications
|
||||
global seen
|
||||
if packet.haslayer(IP):
|
||||
if packet[IP].ttl != 65:
|
||||
packet[IP].ttl = 65
|
||||
@ -13,11 +14,14 @@ def modify_packet(packet):
|
||||
if packet[IPv6].ttl != 65:
|
||||
packet[IPv6].ttl = 65
|
||||
modifications += 1
|
||||
seen += 1
|
||||
#Can be extented with other protocols which have TTL
|
||||
send(packet)
|
||||
sendp(packet, iface=sys.argv[1])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
modifications = 0
|
||||
seen = 0
|
||||
if len(sys.argv) != 2:
|
||||
print(f"Usage: {sys.argv[0]} <interface>")
|
||||
sys.exit(1)
|
||||
@ -27,8 +31,9 @@ if __name__ == "__main__":
|
||||
start_time = datetime.now()
|
||||
print(f"Script started at: {start_time.strftime('%Y-%m-%d %H:%M:%S')}")
|
||||
|
||||
packets = sniff(filter="ip or ipv6", iface=interface, timeout=30*1, prn=modify_packet)
|
||||
packets = sniff(filter="ip or ip6", iface=interface, timeout=2.5*1, prn=modify_packet)
|
||||
|
||||
end_time = datetime.now()
|
||||
print(f"Script ended at: {end_time.strftime('%Y-%m-%d %H:%M:%S')}")
|
||||
print(f"{modifications} packets modified")
|
||||
print(f"{modifications} ip(v6) packets modified")
|
||||
print(f"{seen} total ip(v6) packets seen")
|
Reference in New Issue
Block a user