Skip to content

Commit

Permalink
Add base64 string to test
Browse files Browse the repository at this point in the history
  • Loading branch information
dani-garcia committed Mar 1, 2024
1 parent 939ef28 commit d35751b
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions crates/memory-testing/analyze_dumps.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ def find_subarrays(needle: bytearray, haystack: bytearray) -> List[int]:
assert find_subarrays([1, 2, 3], [1, 2, 4, 3, 5]) == []


def find_subarrays_batch(needles: List[Tuple[bytearray, str]], haystack: bytearray):
for needle, name in needles:
print(f"Subarrays of {name}:", find_subarrays(needle, haystack))


def read_file_to_byte_array(file_path: str) -> bytearray:
with open(file_path, "rb") as file:
return bytearray(file.read())
Expand All @@ -43,6 +38,10 @@ def read_file_to_byte_array(file_path: str) -> bytearray:
SYMMETRIC_MAC = bytearray.fromhex(
"4136 481f 8581 93f8 3f6c 5468 b361 7acf 7dfb a3db 2a32 5aa3 3017 d885 e5a3 1085"
)
SYMMETRIC_B64 = bytearray.fromhex(
"4666 6856 5650 3866 6d46 495a 5931 576d 5273 7a50 6d52 6d56 4378 584e 5756 634a 6666 5072 626b 7977 5450 7442 4e6b 6766 6859 4754 2b44 3973 5647 697a 5958 7250 6666 756a 3279 6f79 5771 4d77 4639 6946 3561 4d51 6851 3d3d"
)


# ---------------------------------------------------------------------------

Expand All @@ -59,6 +58,7 @@ def read_file_to_byte_array(file_path: str) -> bytearray:

key_initial_matches = find_subarrays(SYMMETRIC_KEY, initial_core)
mac_initial_matches = find_subarrays(SYMMETRIC_MAC, initial_core)
b64_initial_matches = find_subarrays(SYMMETRIC_B64, initial_core)
test_initial_matches = find_subarrays(TEST_STRING, initial_core)

print("-------------- Processing final core dump --------------")
Expand All @@ -67,6 +67,7 @@ def read_file_to_byte_array(file_path: str) -> bytearray:

key_final_matches = find_subarrays(SYMMETRIC_KEY, final_core)
mac_final_matches = find_subarrays(SYMMETRIC_MAC, final_core)
b64_final_matches = find_subarrays(SYMMETRIC_B64, final_core)
test_final_matches = find_subarrays(TEST_STRING, final_core)


Expand All @@ -76,10 +77,12 @@ def read_file_to_byte_array(file_path: str) -> bytearray:
print("Initial matches")
print(" Key:", key_initial_matches)
print(" MAC:", mac_initial_matches)
print(" Base64 Key:", b64_initial_matches)
print(" Test:", test_initial_matches)
print("Final matches")
print(" Key:", key_final_matches)
print(" MAC:", mac_final_matches)
print(" Base64 Key:", b64_final_matches)
print(" Test:", test_final_matches)

print("------------------ Checking for leaks -----------------")
Expand Down

0 comments on commit d35751b

Please sign in to comment.