python-2.7
  • networking
  • scapy
  • packet-sniffers
  • 2016-08-03 6 views 0 likes 
    0

    Ich möchte nur IP.dst zu txt-Datei ausgeben, aber ich alle das Paket Informationen einschließlich Ether, src, etcPython scapy Ausgabe in txt-Datei

    from scapy.all import * 
    import time 
    import os 
    file = open("newfile.txt","w") 
    t = '%IP.dst%' 
    p = sniff(filter="ip", prn=lambda x:x.sprintf(t), count=10) 
    file.write(str(p)) 
    time.sleep(1) 
    os.system("cls") 
    

    Beispiel für die Ausgabe von TXT-Datei

    Ether dst = f4: ce: 46: 5c: bf: f8 src = 30: 10: b3: 24: 63: b6 type = 0x800/| IP version = 4L IHL = 5L

    Antwort

    0

    @TeckSupport, wie wäre es, wenn Sie eine Funktion einrichten, die zieht und schreibt die IP.dst:

    from scapy.all import * 
    
    fob = open("IP.txt","w") 
    
    def ip_dst(pkt): 
         fob.write(pkt[IP].dst+'\n') 
    
    sniff(filter='ip',count=10,prn=ip_dst) 
    fob.close() 
    

    Ist das, was Sie suchen zu tun?

    +0

    Ja danke @ Noob123 – TeckSupport

    Verwandte Themen