from tkinter import * from scapy.all import IP, ICMP, sr1 from scapy.layers.l2 import Ether, ARP from scapy.contrib.dtp import * from scapy.sendrecv import sniff def Packet_Capture(number): packets = sniff(filter="icmp", count=int(number)) for packet in range(0, int(number)): Label(window, text=packets[packet].summary()).grid(column=0, row=packet+3) Label(window, text=packets[packet].load).grid(column=1, row=packet+3) def T1_create_ping(): icmp = IP(src="10.10.10.22", dst="10.10.10.1") / ICMP() / "msg" resp = sr1(icmp, timeout=2) print(resp) def T2_ping_range(): active = [] for i in range(0, 5): icmp = IP(src="10.10.10.19", dst="10.10.10."+str(i+1)) / ICMP() / "test" resp = sr1(icmp, timeout=2) if resp: active.append("10.10.10."+str(i+1)) print("\n##########################") for adr in active: print("Address: " + adr + " is active") def T3_Arp_Spoofing(): spoofed_arp = Ether() / ARP() spoofed_arp[ARP].hwsrc = "aa:aa:aa:aa:aa:aa" spoofed_arp[ARP].psrc = "10.0.0.1" spoofed_arp[ARP].hwdst = "bb:bb:bb:bb:bb:bb" spoofed_arp[ARP].pdst = "10.0.0.2" spoofed_arp.dst = "bb:bb:bb:bb:bb:bb" spoofed_arp.src = "aa:aa:aa:aa:aa:aa" spoofed_arp[ARP].op = 2 sendp(spoofed_arp) def T4(): pkt = Ether()/IP()/ICMP() #pkt.show() pkt[Ether].src = "aa:aa:aa:aa:aa:aa" pkt[IP].dst = "192.168.10.1" pkt[ICMP].code = 2 sendp(pkt) print(pkt.summary()) if __name__ == '__main__': #window = Tk() #Label(window, text="Aplikácia pre odchytávanie paketov", font=("consolas", 22), fg="blue").grid(row=0, columnspan=2) #number = StringVar() #Label(window, text="Zadajte počet odchytávaných správ:").grid(row=1, column=0) #Entry(window, textvariable=number).grid(row=1, column=1) #Button(window, text="Capture", command=lambda: Packet_Capture(number.get())).grid(row=2, column=0) #window.mainloop() #T1_create_ping() #T2_ping_range() T3_Arp_Spoofing() T4()