Skip to content

Instantly share code, notes, and snippets.

@SyntheticDream
Created December 15, 2016 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SyntheticDream/197a15447a9bf297ff05bcbc7c650dc9 to your computer and use it in GitHub Desktop.
Save SyntheticDream/197a15447a9bf297ff05bcbc7c650dc9 to your computer and use it in GitHub Desktop.
from scapy.all import *
paks = rdpcap('sample.pcap')
db = {}
def check_ttl(packet):
new_ttl = packet.ttl
src = packet.src
last_ttl = db.get(src)
if last_ttl is None:
db[packet.src] = new_ttl
else:
if last_ttl != new_ttl:
return '{} is banned'.format(src)
else:
return '{} passes'.format(src)
for pak in paks:
print(check_ttl(pak))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment