Skip to content

module bytes_decoder

BytesDecoder class for attempting to decode bytes with various encodings.

Global Variables

  • ENCODING
  • ENCODINGS_TO_ATTEMPT
  • DEFAULT_TABLE_OPTIONS
  • SCORE_SCALER
  • WAS_DECODABLE_YES_NO

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.
  • label (str, optional): Label for this decoding attempt, defaults to bytes_match.label.
  • bytes (bytes): The bytes (including surrounding context) to decode.
  • decoded_strings (dict[str, str]): Maps encoding to decoded string.
  • decodings (list[DecodingAttempt]): DecodingAttempt objects for each encoding tried.
  • encoding_detector (EncodingDetector): Used to detect and assess possible encodings.
  • table (Table): Table that contains the decoding attempts.
  • 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.

method __init__

__init__(
    bytes_match: BytesMatch,
    label: str = '',
    decoded_strings: dict[str, str] = <factory>,
    decodings: list[DecodingAttempt] = <factory>,
    was_match_decodable: defaultdict[str, int] = <factory>,
    was_match_force_decoded: defaultdict[str, int] = <factory>,
    was_match_undecodable: defaultdict[str, int] = <factory>
) → None

property bytes


This file was automatically generated via lazydocs.