def process_object(self, file_object): result = {} result['strings'] = find_all_strings( file_object.binary, min_length=self.config[self.NAME]['min_length']) file_object.processed_analysis[self.NAME] = result return file_object
def words_in_strings(my_bytes, word_list, min_length=10): total_matches = 0 strings_containing_words = set() for string in find_all_strings(my_bytes, min_length=min_length): for word in word_list: if word.lower() in string.lower(): total_matches += 1 strings_containing_words.add(string) return total_matches, sorted(list(strings_containing_words), key=len, reverse=True)
def test_find_all_strings(self): input_data = b'\x03\x01[test_string1!\\]\x03\x01(t3st 5tring2?)\x03to\x01[test_string1!\\]' result = find_all_strings(input_data) self.assertEqual(result, ['(t3st 5tring2?)', '[test_string1!\\]'], "result not correct")