Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Arker123 committed Jun 23, 2024
1 parent 3d1093a commit a5e46ae
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 5 additions & 3 deletions floss/language/rust/decode_utf8.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.
"""
Expand Down Expand Up @@ -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.
"""
Expand Down
6 changes: 3 additions & 3 deletions floss/language/rust/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = []
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit a5e46ae

Please sign in to comment.