| |
- Strings.Strings(builtins.object)
-
- MagicStrings
- builtins.object
-
- Result
class MagicStrings(Strings.Strings) |
|
MagicStrings(*args, process_level: int = 0, keys: List[Tuple[bytes, Optional[str]]] = [], **kwargs)
This class process exported strings recursively from binary file. |
|
- Method resolution order:
- MagicStrings
- Strings.Strings
- builtins.object
Methods defined here:
- __init__(self, *args, process_level: int = 0, keys: List[Tuple[bytes, Optional[str]]] = [], **kwargs)
- Initialize self. See help(type(self)) for accurate signature.
- bruteforces(self, data: bytes, is_string: bool = False) -> Iterator[bytes]
- This method bruteforces one character keys
for small crypto functions.
- decode_string(self, string_encoded: bytes, steps: List[MagicStrings.Step], last_step_decrypt: bool, this_formats: Dict[str, PegParser.Format], first: bool = False) -> Iterator[MagicStrings.Result]
- The method checks the string for all formats.
- decrypt_string(self, result: MagicStrings.Result) -> Iterator[bytes]
- This method bruteforces a string.
- magic(self) -> Iterator[MagicStrings.Result]
- This method process the file.
- new(self, data: bytes, steps: List[MagicStrings.Step], last_step_decrypt: bool) -> Iterator[MagicStrings.Result]
- This method makes a new instance of MagicStrings
for a in depth string search.
- process_crypto(self, data: bytes, last_step_decrypt: bool) -> Iterator[bytes]
- This method process data with crypto functions.
- process_data(self, data: bytes, steps: List[MagicStrings.Step], last_step_decrypt: bool) -> Iterator[MagicStrings.Result]
- This method sends each data to recursive function.
- process_string(self, result: MagicStrings.Result) -> Iterator[MagicStrings.Result]
- The recursive method to process each string.
- process_strings(self) -> Iterator[MagicStrings.Result]
- This method sends each string to recursive function.
Static methods defined here:
- yield_if_next(generator: Generator, result: MagicStrings.Result) -> Iterator[MagicStrings.Result]
- This function yields results and yields from generator
if there is a yield in the generator.
Data and other attributes defined here:
- __annotations__ = {'lasts': typing.Dict[str, bytes]}
- lasts = {}
Methods inherited from Strings.Strings:
- analyse_character(self, char: bytes) -> Tuple[bool, bool]
- This method analyses a byte and returns boolean to know when a
string is terminated.
>>> strings = Strings(None)
>>> strings.analyse_character(b'a')
(False, False)
>>> strings.analyse_character(b'\0')
(False, True)
>>> strings.current_string
'a'
>>> strings.analyse_character(b'\0')
(False, True)
>>> strings.analyse_character(b'\0')
(True, True)
>>> strings.current_unicode_string
'a'
>>> strings.analyse_character(b'\1')
(False, False)
>>> strings.current_string
''
>>> strings.current_unicode_string
''
>>> strings = Strings(None, null_terminated=False)
>>> strings.analyse_character(b'a')
(False, False)
>>> strings.analyse_character(b'\0')
(False, True)
>>> strings.current_string
'a'
>>> strings.analyse_character(b'\0')
(False, True)
>>> strings.analyse_character(b'\0')
(True, True)
>>> strings.current_unicode_string
'a'
>>> strings.analyse_character(b'a')
(False, False)
>>> strings.analyse_character(b'\1')
(False, True)
>>> strings.analyse_character(b'a')
(False, False)
>>> strings.analyse_character(b'\0')
(False, True)
>>> strings.analyse_character(b'\1')
(True, True)
>>>
- reader(self) -> Iterator[str]
- This method reads character after character and yield strings.
>>> from io import BytesIO
>>> strings = Strings(BytesIO(b"\x00\x01abcde\x00ghijk\x01lmnopqrst\x00"))
>>> for line in strings.reader(): print(line)
abcde
lmnopqrst
>>> strings = Strings(BytesIO(b"\x00\x01abcde\x00ghijk\x01lmnopqrst\x00"), null_terminated=False)
>>> for line in strings.reader(): print(line)
abcde
ghijk
lmnopqrst
>>>
Data descriptors inherited from Strings.Strings:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class Result(builtins.object) |
|
Result(string: bytes, format: PegParser.Format, process_level: int, steps: List[MagicStrings.Step] = <factory>, last_step_decrypt: bool = False) -> None
This dataclass contains the result for each
exported and processed strings and matchs. |
|
Methods defined here:
- __eq__(self, other)
- Return self==value.
- __init__(self, string: bytes, format: PegParser.Format, process_level: int, steps: List[MagicStrings.Step] = <factory>, last_step_decrypt: bool = False) -> None
- Initialize self. See help(type(self)) for accurate signature.
- __repr__(self)
- Return repr(self).
- __str__(self)
- Return str(self).
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
Data and other attributes defined here:
- __annotations__ = {'format': <class 'PegParser.Format'>, 'last_step_decrypt': <class 'bool'>, 'process_level': <class 'int'>, 'steps': typing.List[MagicStrings.Step], 'string': <class 'bytes'>}
- __dataclass_fields__ = {'format': Field(name='format',type=<class 'PegParser.Forma...appingproxy({}),kw_only=False,_field_type=_FIELD), 'last_step_decrypt': Field(name='last_step_decrypt',type=<class 'bool...appingproxy({}),kw_only=False,_field_type=_FIELD), 'process_level': Field(name='process_level',type=<class 'int'>,de...appingproxy({}),kw_only=False,_field_type=_FIELD), 'steps': Field(name='steps',type=typing.List[MagicStrings...appingproxy({}),kw_only=False,_field_type=_FIELD), 'string': Field(name='string',type=<class 'bytes'>,default...appingproxy({}),kw_only=False,_field_type=_FIELD)}
- __dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False)
- __hash__ = None
- __match_args__ = ('string', 'format', 'process_level', 'steps', 'last_step_decrypt')
- last_step_decrypt = False
| |