Skip to content

module bytes_decoder

BytesDecoder class for attempting to decode bytes with various encodings.

Global Variables

  • ENCODING
  • ENCODINGS_TO_ATTEMPT
  • CENTER
  • WAS_DECODABLE_YES_NO
  • SCORE_SCALER

class BytesDecoder

Handles decoding a chunk of bytes into strings using various possible encodings, ranking and displaying results.

This class leverages the chardet library and custom logic to try multiple encodings, track decoding outcomes, and present the results in a rich, user-friendly format. It is used to analyze and display the possible interpretations of a byte sequence, especially in the context of YARA matches or binary analysis.

Attributes:

  • bytes_match (BytesMatch): The BytesMatch instance being decoded.
  • bytes (bytes): The bytes (including surrounding context) to decode.
  • label (str): Label for this decoding attempt.
  • was_match_decodable (dict): Tracks successful decodes per encoding.
  • was_match_force_decoded (dict): Tracks forced decodes per encoding.
  • was_match_undecodable (dict): Tracks failed decodes per encoding.
  • decoded_strings (dict): Maps encoding to decoded string.
  • undecoded_rows (list): Stores undecoded table rows.
  • decodings (list): List of DecodingAttempt objects for each encoding tried.
  • encoding_detector (EncodingDetector): Used to detect and assess possible encodings.

method __init__

__init__(bytes_match: 'BytesMatch', label: Optional[str] = None) → None

Initialize a BytesDecoder for attempting to decode a chunk of bytes using various encodings.

Args:

  • bytes_match (BytesMatch): The BytesMatch object containing the bytes to decode and match metadata.
  • label (Optional[str], optional): Optional label for this decoding attempt. Defaults to the match label.

This file was automatically generated via lazydocs.