0

I was able to print the data onto the console. But what if i want to store it in a log file.

Here is my code:

def pkt_callback(pkt):
    pkt_raw = raw(pkt)            
    print(" packet received ", pkt_raw)

**logger.info("Packet Received: %s",pkt_raw)**          

self.P = sniff(
    count = self.c, 
    filter="dst host %s or src host %s and udp and dport %s" % (self.dst, self.src, self.Port), 
    prn = pkt_callback
)

I was getting an error at the bolded part as:

ascii' codec can't decode byte 0xff in position 54: ordinal not in range(128)
Seanny123
  • 8,776
  • 13
  • 68
  • 124
  • the output of print command is : (' packet received ', '\xff\xff\xff\xff\xff\xff\x00PV\xab\x0b\xf3\x08\x06\x00\x01\x08\x00\x06\x04\x00\x01\x00PV\xab\x0b\xf3\n\xe7\xa0\xf0\x00\x00\x00\x00\x00\x00\n\xe7\xa0\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') –  May 29 '19 at 14:16
  • Please make sure you look up the error. There are known solutions. – schroeder May 29 '19 at 14:45
  • Potential duplicate: https://stackoverflow.com/questions/42339876/error-unicodedecodeerror-utf-8-codec-cant-decode-byte-0xff-in-position-0-in – schroeder May 29 '19 at 14:47

0 Answers0