Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
def callback(packet):
global response
if(packet.haslayer('Ethernet')):
response = response + "Ethernet src: " + str(packet['Ethernet'].src) + "\n"
response = response + "Ethernet dst: " + str(packet['Ethernet'].dst) + "\n"
response = response + "Ethernet type: " + str(packet['Ethernet'].type) + "\n"
if(packet.haslayer('IP')):
response = response + "IP ttl: " +str(packet['IP'].ttl) + "\n"
response = response + "IP src: " +str(packet['IP'].src) + "\n"
response = response + "IP dst: " + str(packet['IP'].dst) + "\n"
if(packet.haslayer('TCP')):
response = response + "TCP sport: " + str(packet['TCP'].sport) + "\n"
response = response + "TCP dport: " +str(packet['TCP'].dport) + "\n"
response = response + "TCP flags: " + str(packet['TCP'].flags) + "\n"
if(packet.haslayer('Raw')):
response = response + "Raw: " + str(hexdump(packet['Raw'].load)) + "\n"
response = response + ("------------------------------\n")
def sniffer(target_ip):
filter_string = "ip host " + target_ip
sniff(count=5, prn=callback, filter= filter_string)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.