Ip sniffer in python utilizand scapy

0

Buna ziua doamnelor si domnilor si bine v-am regasit. Ma numesc Zero Davila, iar astazi vom scrie un ip sniffer in python utilizand scapy, care va afisa adresele ip de unde vin si pleaca pachetele pe retea, cat si porturile.

from scapy.all import *

def print_summary(pkt):
if IP in pkt:
ip_src=pkt[IP].src
ip_dst=pkt[IP].dst
if TCP in pkt:
tcp_sport=pkt[TCP].sport
tcp_dport=pkt[TCP].dport

print ” IP src ” + str(ip_src) + ” TCP sport ” + str(tcp_sport)
print ” IP dst ” + str(ip_dst) + ” TCP dport ” + str(tcp_dport)
print “”

if ((pkt[IP].src == “192.168.0.1”) or (pkt[IP].dst == “192.168.0.1”)):
print “[!]”

sniff(filter=”ip”,prn=print_summary)
sniff(filter=”ip and host 192.168.0.1″,prn=print_summary)

Leave A Reply

Your email address will not be published.