0

When I print one of the packets in the file, I see the output as bytes. I wonder how I could convert this into a vector of numbers (0 and 1).

Here's an example for content in the packet:

\xce\xf4\x12\xd4\x1d\xe0\x06\xb9y
dlev99
  • 21
  • 3
  • 1
    It is unclear what you actually want here. If you want to just convert bytes in binary (*"0 and 1"*) see for example [Convert bytes to bits in python](https://stackoverflow.com/questions/8815592/convert-bytes-to-bits-in-python). If you want to extract features from the pcap in order to create some ML model you have to actually know what features you want to have in the feature vector, i.e. simply saying *"vector of numbers (0 and 1)"* is not sufficient. – Steffen Ullrich Apr 05 '21 at 14:24
  • I'm trying to build an anomaly deduction system, for example, the input will be a PCAP file, and one of the parameters to detect if a packet is suspicious or not is - if the port is 4444 (that means the packet is "suspicious"), and then add at the end of the vector 0 or 1. (0 = "good packet", 1 = "bad packet"). Do you have any idea how to solve that? or at least how to convert the content of the packet (\xce\xf4\x12\xd4\x1d\xe0\x06\xb9y) into a vector? – dlev99 Apr 05 '21 at 20:16

0 Answers0