Update response handling and fix detection command

Signed-off-by: Trigat <trigat@protonmail.com>
This commit is contained in:
Trigat authored and GitHub committed 2025-09-02 08:42:35 -05:00
1 parent f9b3bff4b7
commit e68babd6ba
1 file changed
+15 -3
+15 -3
View File
@@ -80,7 +80,7 @@ def send_proxmark_command(command):
host_device = detect_proxmark_device() host_device = detect_proxmark_device()
process = subprocess.Popen( process = subprocess.Popen(
["proxmark3", host_device], ["proxmark3", "-p", host_device],
stdin=subprocess.PIPE, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, stderr=subprocess.PIPE,
@@ -154,7 +154,7 @@ def authenticate_and_menu():
print("3. Delete an AID") print("3. Delete an AID")
print("4. Format PICC") print("4. Format PICC")
print("5. Show free memory") print("5. Show free memory")
print("6. Change keys") print("6. Change Master and AID keys")
print("7. Exit") print("7. Exit")
choice = input("Enter your choice: ").strip() choice = input("Enter your choice: ").strip()
@@ -241,6 +241,7 @@ def create_aid(key_type, key, com_mode):
create_command = f"hf mfdes createapp -n 0 --aid {aid} --fid {iso_fid} --dstalgo {dstalgo} -t {key_type} -k {key} -m {com_mode} -a" create_command = f"hf mfdes createapp -n 0 --aid {aid} --fid {iso_fid} --dstalgo {dstalgo} -t {key_type} -k {key} -m {com_mode} -a"
response = send_proxmark_command(create_command) response = send_proxmark_command(create_command)
print(response) print(response)
print("\n.:: DESFire assigns all-zero keys to new applications by default. Keys can be modified via the main menu. ::.\n")
def delete_aid(key_type, key, com_mode): def delete_aid(key_type, key, com_mode):
@@ -337,7 +338,8 @@ def list_files(aid, key_type, key, com_mode, aid_key_type, aid_key):
print(f"{i}. {file_id}") print(f"{i}. {file_id}")
return file_ids return file_ids
else: else:
print("No files found in this AID.") print("No files found in this AID.\n")
print(response)
return [] return []
def read_file(aid, key_type, key, com_mode, aid_key_type, aid_key): def read_file(aid, key_type, key, com_mode, aid_key_type, aid_key):
@@ -356,6 +358,11 @@ def read_file(aid, key_type, key, com_mode, aid_key_type, aid_key):
f"--offset {offset_hex} --length {length_hex} -m {com_mode}" f"--offset {offset_hex} --length {length_hex} -m {com_mode}"
response = send_proxmark_command(read_command) response = send_proxmark_command(read_command)
# Check for authentication error
if "authenticate error" in response.lower():
print("\nAuthentication Error")
return None
# Extract and display file content # Extract and display file content
print("\nFile Data:") print("\nFile Data:")
for line in response.splitlines(): for line in response.splitlines():
@@ -410,6 +417,11 @@ def write_to_file(aid, key_type, key, com_mode, aid_key_type, aid_key):
file_size_command = f"hf mfdes getfilesettings --aid {aid} --fid {file_id} -t {aid_key_type} -k {aid_key} -m {com_mode}" file_size_command = f"hf mfdes getfilesettings --aid {aid} --fid {file_id} -t {aid_key_type} -k {aid_key} -m {com_mode}"
response = send_proxmark_command(file_size_command) response = send_proxmark_command(file_size_command)
# Check for authentication error
if "authenticate error" in response.lower():
print("\nAuthentication Error")
return None
# Extract the file size from the response # Extract the file size from the response
file_size_match = re.search(r"File size \(bytes\)... (\d+) / 0x([0-9A-Fa-f]+)", response) file_size_match = re.search(r"File size \(bytes\)... (\d+) / 0x([0-9A-Fa-f]+)", response)
if not file_size_match: if not file_size_match: