ctfsolver.managers.manager_files_re

manager_files_re.py

This module provides the ManagerFileRegex class for extracting printable strings from files using regular expressions.

Classes:
ManagerFileRegex:

A manager class for file operations involving regular expressions, including extracting printable ASCII strings from binary files.

Usage:

Instantiate ManagerFileRegex and use its methods to process files for printable string extraction.

Example

manager = ManagerFileRegex() strings = manager.extract_strings(“/path/to/file”, min_length=4)

None[source]

Classes

Module Contents

class ManagerFileRegex(*args, **kwargs)[source]
initializing_all_ancestors(*args, **kwargs)[source]
Description:

Initializes all the ancestors of the class

extract_strings(file_path, min_length=4)[source]
Description:

Extracts printable strings from a file

Parameters:
  • file_path (str) – The path to the file

  • min_length (int) – The minimum length of the string to extract

Returns:

The list of strings

Return type:

list

normalize_name(name)[source]

Normalize a file or folder name so different naming styles correlate.

Parameters:

name (str)

Return type:

str

string_similarity(str1, str2)[source]

Calculate the similarity ratio between two strings using rapidfuzz.

Parameters:
  • str1 (str) – The first string.

  • str2 (str) – The second string.

Returns:

Similarity ratio between 0 and 100.

Return type:

float

check_name_similarity_in_files(files, information, threshold=70.0)[source]

Check for similar names in a list of files based on provided information.

Parameters:
  • information (list) – List of strings to compare against file names.

  • files (list) – List of file names to check.

  • threshold (float) – Similarity threshold (0-100) to consider a match.

Returns:

List of files that have similar names above the threshold.

Return type:

list