From a5e46ae98dd6e9b2d6b7d3425fc27a28f36e1dae Mon Sep 17 00:00:00 2001 From: Arker123 Date: Sun, 23 Jun 2024 19:36:08 +0530 Subject: [PATCH] Tweaks --- floss/language/rust/decode_utf8.py | 8 +++++--- floss/language/rust/extract.py | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/floss/language/rust/decode_utf8.py b/floss/language/rust/decode_utf8.py index 9f0672e21..d2992524f 100644 --- a/floss/language/rust/decode_utf8.py +++ b/floss/language/rust/decode_utf8.py @@ -3,7 +3,7 @@ import logging import pathlib import argparse -from typing import List, Tuple, Iterable, Optional +from typing import Any, List, Tuple, Iterable, Optional import pefile @@ -20,7 +20,7 @@ def get_rdata_section(pe: pefile.PE) -> pefile.SectionStructure: raise ValueError("no .rdata section found") -def extract_utf8_strings_from_buffer(buf, min_length=MIN_STR_LEN) -> List[Tuple[str, int]]: +def extract_utf8_strings_from_buffer(buf, min_length=MIN_STR_LEN) -> List[List[Any]]: """ Extracts UTF-8 strings from a buffer. """ @@ -72,10 +72,12 @@ def extract_utf8_strings_from_buffer(buf, min_length=MIN_STR_LEN) -> List[Tuple[ # filter strings less than min length strings = [string for string in strings if len(string[0]) >= min_length] + print(strings) + return strings -def extract_utf8_strings(pe: pefile.PE, min_length=MIN_STR_LEN) -> List[Tuple[str, int, int]]: +def extract_utf8_strings(pe: pefile.PE, min_length=MIN_STR_LEN) -> List[List[Any]]: """ Extracts UTF-8 strings from the .rdata section of a PE file. """ diff --git a/floss/language/rust/extract.py b/floss/language/rust/extract.py index b56a10a92..543633227 100644 --- a/floss/language/rust/extract.py +++ b/floss/language/rust/extract.py @@ -4,7 +4,7 @@ import pathlib import argparse import itertools -from typing import List, Tuple, Iterable, Optional +from typing import Any, List, Tuple, Iterable, Optional import pefile import binary2strings as b2s @@ -60,7 +60,7 @@ def fix_b2s_wide_strings( def filter_and_transform_utf8_strings( - strings: List[Tuple[str, int, int]], + strings: list[list[Any]], start_rdata: int, ) -> List[StaticString]: transformed_strings = [] @@ -148,7 +148,7 @@ def get_string_blob_strings(pe: pefile.PE, min_length: int) -> Iterable[StaticSt buffer_rdata = rdata_section.get_data() # extract utf-8 strings - strings = extract_utf8_strings(pe, min_length) + fixed_strings = extract_utf8_strings(pe, min_length) # select only UTF-8 strings and adjust offset static_strings = filter_and_transform_utf8_strings(fixed_strings, start_rdata)