mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-07-16 10:03:04 -07:00
rename paxton scripts and some code styling
This commit is contained in:
parent
cef07dedf6
commit
145b3ac8d6
3 changed files with 69 additions and 0 deletions
32
client/pyscripts/Paxton_convert.py → client/pyscripts/paxton_convert.py
Normal file → Executable file
32
client/pyscripts/Paxton_convert.py → client/pyscripts/paxton_convert.py
Normal file → Executable file
|
@ -1,3 +1,5 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
# paxton_convert.py - Convert Paxton Net2 and Switch2 to EM4102
|
# paxton_convert.py - Convert Paxton Net2 and Switch2 to EM4102
|
||||||
# Author jareckib <jareckib@hotmail.com>
|
# Author jareckib <jareckib@hotmail.com>
|
||||||
# Based on Equipter's tutorial - Downgrade Paxton Net to EM410x
|
# Based on Equipter's tutorial - Downgrade Paxton Net to EM410x
|
||||||
|
@ -19,68 +21,95 @@
|
||||||
import sys
|
import sys
|
||||||
def hex_to_bin(hex_string):
|
def hex_to_bin(hex_string):
|
||||||
return ''.join(format(byte, '08b') for byte in bytearray.fromhex(hex_string))
|
return ''.join(format(byte, '08b') for byte in bytearray.fromhex(hex_string))
|
||||||
|
|
||||||
def remove_last_two_bits(binary_str):
|
def remove_last_two_bits(binary_str):
|
||||||
return binary_str[:-2]
|
return binary_str[:-2]
|
||||||
|
|
||||||
def split_into_5bit_chunks(binary_str):
|
def split_into_5bit_chunks(binary_str):
|
||||||
return [binary_str[i:i+5] for i in range(0, len(binary_str), 5)]
|
return [binary_str[i:i+5] for i in range(0, len(binary_str), 5)]
|
||||||
|
|
||||||
def remove_parity_bit(chunks):
|
def remove_parity_bit(chunks):
|
||||||
return [chunk[1:] for chunk in chunks if len(chunk) == 5]
|
return [chunk[1:] for chunk in chunks if len(chunk) == 5]
|
||||||
|
|
||||||
def convert_to_hex(chunks):
|
def convert_to_hex(chunks):
|
||||||
return [format(int(chunk, 2), 'X') for chunk in chunks]
|
return [format(int(chunk, 2), 'X') for chunk in chunks]
|
||||||
|
|
||||||
def convert_to_decimal(chunks):
|
def convert_to_decimal(chunks):
|
||||||
return [int(chunk, 2) for chunk in chunks]
|
return [int(chunk, 2) for chunk in chunks]
|
||||||
|
|
||||||
def find_until_before_f(hex_values):
|
def find_until_before_f(hex_values):
|
||||||
result = []
|
result = []
|
||||||
for value in hex_values:
|
for value in hex_values:
|
||||||
if value == 'F':
|
if value == 'F':
|
||||||
break
|
break
|
||||||
result.append(value)
|
result.append(value)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def process_block(block):
|
def process_block(block):
|
||||||
binary_str = hex_to_bin(block)
|
binary_str = hex_to_bin(block)
|
||||||
binary_str = remove_last_two_bits(binary_str)
|
binary_str = remove_last_two_bits(binary_str)
|
||||||
chunks = split_into_5bit_chunks(binary_str)
|
chunks = split_into_5bit_chunks(binary_str)
|
||||||
no_parity_chunks = remove_parity_bit(chunks)
|
no_parity_chunks = remove_parity_bit(chunks)
|
||||||
|
|
||||||
return no_parity_chunks
|
return no_parity_chunks
|
||||||
|
|
||||||
def calculate_id_net(blocks):
|
def calculate_id_net(blocks):
|
||||||
|
|
||||||
all_hex_values = []
|
all_hex_values = []
|
||||||
for block in blocks:
|
for block in blocks:
|
||||||
hex_values = convert_to_hex(process_block(block))
|
hex_values = convert_to_hex(process_block(block))
|
||||||
all_hex_values.extend(hex_values)
|
all_hex_values.extend(hex_values)
|
||||||
|
|
||||||
selected_hex_values = find_until_before_f(all_hex_values)
|
selected_hex_values = find_until_before_f(all_hex_values)
|
||||||
|
|
||||||
if not selected_hex_values:
|
if not selected_hex_values:
|
||||||
raise ValueError("Error: No valid data found in blocks 4 and 5.")
|
raise ValueError("Error: No valid data found in blocks 4 and 5.")
|
||||||
|
|
||||||
combined_hex = ''.join(selected_hex_values)
|
combined_hex = ''.join(selected_hex_values)
|
||||||
|
|
||||||
if not combined_hex.isdigit():
|
if not combined_hex.isdigit():
|
||||||
raise ValueError("Error: Invalid data in blocks 4 and 5.")
|
raise ValueError("Error: Invalid data in blocks 4 and 5.")
|
||||||
|
|
||||||
decimal_id = int(combined_hex)
|
decimal_id = int(combined_hex)
|
||||||
stripped_hex_id = format(decimal_id, 'X').upper()
|
stripped_hex_id = format(decimal_id, 'X').upper()
|
||||||
padded_hex_id = stripped_hex_id.zfill(10)
|
padded_hex_id = stripped_hex_id.zfill(10)
|
||||||
|
|
||||||
return decimal_id, padded_hex_id
|
return decimal_id, padded_hex_id
|
||||||
|
|
||||||
def calculate_id_switch(blocks):
|
def calculate_id_switch(blocks):
|
||||||
|
|
||||||
all_decimal_values = []
|
all_decimal_values = []
|
||||||
for block in blocks:
|
for block in blocks:
|
||||||
decimal_values = convert_to_decimal(process_block(block))
|
decimal_values = convert_to_decimal(process_block(block))
|
||||||
all_decimal_values.extend(decimal_values)
|
all_decimal_values.extend(decimal_values)
|
||||||
|
|
||||||
if len(all_decimal_values) < 15:
|
if len(all_decimal_values) < 15:
|
||||||
raise ValueError("Error: Not enough data after processing blocks 4, 5, 6, and 7.")
|
raise ValueError("Error: Not enough data after processing blocks 4, 5, 6, and 7.")
|
||||||
|
|
||||||
id_positions = [9, 11, 13, 15, 2, 4, 6, 8]
|
id_positions = [9, 11, 13, 15, 2, 4, 6, 8]
|
||||||
id_numbers = [all_decimal_values[pos-1] for pos in id_positions]
|
id_numbers = [all_decimal_values[pos-1] for pos in id_positions]
|
||||||
decimal_id = int(''.join(map(str, id_numbers)))
|
decimal_id = int(''.join(map(str, id_numbers)))
|
||||||
padded_hex_id = format(decimal_id, 'X').upper().zfill(10)
|
padded_hex_id = format(decimal_id, 'X').upper().zfill(10)
|
||||||
|
|
||||||
return decimal_id, padded_hex_id
|
return decimal_id, padded_hex_id
|
||||||
|
|
||||||
def input_block_data(block_number):
|
def input_block_data(block_number):
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
block_data = input("Enter data for block {} (4 bytes in hex): ".format(block_number)).strip()
|
block_data = input("Enter data for block {} (4 bytes in hex): ".format(block_number)).strip()
|
||||||
if len(block_data) != 8 or not all(c in '0123456789abcdefABCDEF' for c in block_data):
|
if len(block_data) != 8 or not all(c in '0123456789abcdefABCDEF' for c in block_data):
|
||||||
print("Error: Data must be 4 bytes (8 characters) in hex. Try again.")
|
print("Error: Data must be 4 bytes (8 characters) in hex. Try again.")
|
||||||
else:
|
else:
|
||||||
return block_data
|
return block_data
|
||||||
|
|
||||||
block_4 = input_block_data(4)
|
block_4 = input_block_data(4)
|
||||||
block_5 = input_block_data(5)
|
block_5 = input_block_data(5)
|
||||||
|
|
||||||
if block_5[3] == 'F' or block_5[3] == 'f':
|
if block_5[3] == 'F' or block_5[3] == 'f':
|
||||||
print("Identified Paxton Net2")
|
print("Identified Paxton Net2")
|
||||||
blocks = [block_4, block_5]
|
blocks = [block_4, block_5]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
decimal_id, padded_hex_id = calculate_id_net(blocks)
|
decimal_id, padded_hex_id = calculate_id_net(blocks)
|
||||||
print('Calculations for block 4 and block 5:')
|
print('Calculations for block 4 and block 5:')
|
||||||
|
@ -89,11 +118,13 @@ if block_5[3] == 'F' or block_5[3] == 'f':
|
||||||
print('Use the following command in Proxmark3: lf em 410x clone --id {}'.format(padded_hex_id))
|
print('Use the following command in Proxmark3: lf em 410x clone --id {}'.format(padded_hex_id))
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print("Identified Paxton Switch2")
|
print("Identified Paxton Switch2")
|
||||||
block_6 = input_block_data(6)
|
block_6 = input_block_data(6)
|
||||||
block_7 = input_block_data(7)
|
block_7 = input_block_data(7)
|
||||||
blocks = [block_4, block_5, block_6, block_7]
|
blocks = [block_4, block_5, block_6, block_7]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
decimal_id, padded_hex_id = calculate_id_switch(blocks)
|
decimal_id, padded_hex_id = calculate_id_switch(blocks)
|
||||||
print('Calculated data from blocks 4, 5, 6, 7:')
|
print('Calculated data from blocks 4, 5, 6, 7:')
|
||||||
|
@ -102,4 +133,5 @@ else:
|
||||||
print('Use the following command in Proxmark3: lf em 410x clone --id {}'.format(padded_hex_id))
|
print('Use the following command in Proxmark3: lf em 410x clone --id {}'.format(padded_hex_id))
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
print('If EM4102 does not work, this option is probably disabled. Sorry for the inconvenience.')
|
print('If EM4102 does not work, this option is probably disabled. Sorry for the inconvenience.')
|
19
client/pyscripts/PAXTON_NET.py → client/pyscripts/paxton_net.py
Normal file → Executable file
19
client/pyscripts/PAXTON_NET.py → client/pyscripts/paxton_net.py
Normal file → Executable file
|
@ -1,3 +1,5 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
# paxton_net.py - Convert Paxton Net2 to EM4102
|
# paxton_net.py - Convert Paxton Net2 to EM4102
|
||||||
# Author jareckib <jareckib@hotmail.com>
|
# Author jareckib <jareckib@hotmail.com>
|
||||||
# Based on Equipter's tutorial - Downgrade Paxton Net to EM410x
|
# Based on Equipter's tutorial - Downgrade Paxton Net to EM410x
|
||||||
|
@ -17,16 +19,22 @@
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
def hex_to_bin(hex_string):
|
def hex_to_bin(hex_string):
|
||||||
return ''.join(format(byte, '08b') for byte in bytearray.fromhex(hex_string))
|
return ''.join(format(byte, '08b') for byte in bytearray.fromhex(hex_string))
|
||||||
|
|
||||||
def remove_last_two_bits(binary_str):
|
def remove_last_two_bits(binary_str):
|
||||||
return binary_str[:-2]
|
return binary_str[:-2]
|
||||||
|
|
||||||
def split_into_5bit_chunks(binary_str):
|
def split_into_5bit_chunks(binary_str):
|
||||||
return [binary_str[i:i+5] for i in range(0, len(binary_str), 5)]
|
return [binary_str[i:i+5] for i in range(0, len(binary_str), 5)]
|
||||||
|
|
||||||
def remove_parity_bit(chunks):
|
def remove_parity_bit(chunks):
|
||||||
return [chunk[1:] for chunk in chunks if len(chunk) == 5]
|
return [chunk[1:] for chunk in chunks if len(chunk) == 5]
|
||||||
|
|
||||||
def convert_to_hex(chunks):
|
def convert_to_hex(chunks):
|
||||||
return [format(int(chunk, 2), 'X') for chunk in chunks]
|
return [format(int(chunk, 2), 'X') for chunk in chunks]
|
||||||
|
|
||||||
def find_until_before_f(hex_values):
|
def find_until_before_f(hex_values):
|
||||||
result = []
|
result = []
|
||||||
for value in hex_values:
|
for value in hex_values:
|
||||||
|
@ -34,6 +42,7 @@ def find_until_before_f(hex_values):
|
||||||
break
|
break
|
||||||
result.append(value)
|
result.append(value)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def process_block(block):
|
def process_block(block):
|
||||||
binary_str = hex_to_bin(block)
|
binary_str = hex_to_bin(block)
|
||||||
binary_str = remove_last_two_bits(binary_str)
|
binary_str = remove_last_two_bits(binary_str)
|
||||||
|
@ -41,21 +50,30 @@ def process_block(block):
|
||||||
no_parity_chunks = remove_parity_bit(chunks)
|
no_parity_chunks = remove_parity_bit(chunks)
|
||||||
hex_values = convert_to_hex(no_parity_chunks)
|
hex_values = convert_to_hex(no_parity_chunks)
|
||||||
return hex_values
|
return hex_values
|
||||||
|
|
||||||
def calculate_id(blocks):
|
def calculate_id(blocks):
|
||||||
|
|
||||||
all_hex_values = []
|
all_hex_values = []
|
||||||
|
|
||||||
for block in blocks:
|
for block in blocks:
|
||||||
hex_values = process_block(block)
|
hex_values = process_block(block)
|
||||||
all_hex_values.extend(hex_values)
|
all_hex_values.extend(hex_values)
|
||||||
|
|
||||||
selected_hex_values = find_until_before_f(all_hex_values)
|
selected_hex_values = find_until_before_f(all_hex_values)
|
||||||
|
|
||||||
if not selected_hex_values:
|
if not selected_hex_values:
|
||||||
raise ValueError("Error: No valid data found in blocks 4 and 5.")
|
raise ValueError("Error: No valid data found in blocks 4 and 5.")
|
||||||
|
|
||||||
combined_hex = ''.join(selected_hex_values)
|
combined_hex = ''.join(selected_hex_values)
|
||||||
|
|
||||||
if not combined_hex.isdigit():
|
if not combined_hex.isdigit():
|
||||||
raise ValueError("Error: Invalid data in blocks 4 and 5.")
|
raise ValueError("Error: Invalid data in blocks 4 and 5.")
|
||||||
|
|
||||||
decimal_id = int(combined_hex)
|
decimal_id = int(combined_hex)
|
||||||
stripped_hex_id = format(decimal_id, 'X').upper()
|
stripped_hex_id = format(decimal_id, 'X').upper()
|
||||||
padded_hex_id = stripped_hex_id.zfill(10)
|
padded_hex_id = stripped_hex_id.zfill(10)
|
||||||
return combined_hex, decimal_id, stripped_hex_id, padded_hex_id
|
return combined_hex, decimal_id, stripped_hex_id, padded_hex_id
|
||||||
|
|
||||||
def input_block_data(block_number):
|
def input_block_data(block_number):
|
||||||
while True:
|
while True:
|
||||||
block_data = input("Enter data for block {} (4 bytes in hex): ".format(block_number)).strip()
|
block_data = input("Enter data for block {} (4 bytes in hex): ".format(block_number)).strip()
|
||||||
|
@ -75,6 +93,7 @@ blocks = [
|
||||||
block_4,
|
block_4,
|
||||||
block_5,
|
block_5,
|
||||||
]
|
]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result_hex, result_decimal, stripped_hex_id, padded_hex_id = calculate_id(blocks)
|
result_hex, result_decimal, stripped_hex_id, padded_hex_id = calculate_id(blocks)
|
||||||
print('Calculations for block 4 and block 5:')
|
print('Calculations for block 4 and block 5:')
|
18
client/pyscripts/Paxton_switch.py → client/pyscripts/paxton_switch.py
Normal file → Executable file
18
client/pyscripts/Paxton_switch.py → client/pyscripts/paxton_switch.py
Normal file → Executable file
|
@ -1,3 +1,5 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
# paxton_switch.py - Convert Paxton Switch2 to EM4102
|
# paxton_switch.py - Convert Paxton Switch2 to EM4102
|
||||||
# Author jareckib <jareckib@hotmail.com>
|
# Author jareckib <jareckib@hotmail.com>
|
||||||
# Based on Equipter's tutorial - Downgrade Paxton Net to EM410x
|
# Based on Equipter's tutorial - Downgrade Paxton Net to EM410x
|
||||||
|
@ -16,35 +18,48 @@
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
def hex_to_bin(hex_string):
|
def hex_to_bin(hex_string):
|
||||||
return ''.join(format(byte, '08b') for byte in bytearray.fromhex(hex_string))
|
return ''.join(format(byte, '08b') for byte in bytearray.fromhex(hex_string))
|
||||||
|
|
||||||
def remove_last_two_bits(binary_str):
|
def remove_last_two_bits(binary_str):
|
||||||
return binary_str[:-2]
|
return binary_str[:-2]
|
||||||
|
|
||||||
def split_into_5bit_chunks(binary_str):
|
def split_into_5bit_chunks(binary_str):
|
||||||
return [binary_str[i:i+5] for i in range(0, len(binary_str), 5)]
|
return [binary_str[i:i+5] for i in range(0, len(binary_str), 5)]
|
||||||
|
|
||||||
def remove_parity_bit(chunks):
|
def remove_parity_bit(chunks):
|
||||||
return [chunk[1:] for chunk in chunks if len(chunk) == 5]
|
return [chunk[1:] for chunk in chunks if len(chunk) == 5]
|
||||||
|
|
||||||
def convert_to_decimal(chunks):
|
def convert_to_decimal(chunks):
|
||||||
return [int(chunk, 2) for chunk in chunks]
|
return [int(chunk, 2) for chunk in chunks]
|
||||||
|
|
||||||
def process_block(block):
|
def process_block(block):
|
||||||
binary_str = hex_to_bin(block)
|
binary_str = hex_to_bin(block)
|
||||||
binary_str = remove_last_two_bits(binary_str)
|
binary_str = remove_last_two_bits(binary_str)
|
||||||
chunks = split_into_5bit_chunks(binary_str)
|
chunks = split_into_5bit_chunks(binary_str)
|
||||||
no_parity_chunks = remove_parity_bit(chunks)
|
no_parity_chunks = remove_parity_bit(chunks)
|
||||||
decimal_values = convert_to_decimal(no_parity_chunks)
|
decimal_values = convert_to_decimal(no_parity_chunks)
|
||||||
|
|
||||||
return decimal_values
|
return decimal_values
|
||||||
|
|
||||||
def calculate_id(blocks):
|
def calculate_id(blocks):
|
||||||
|
|
||||||
all_decimal_values = []
|
all_decimal_values = []
|
||||||
for block in blocks:
|
for block in blocks:
|
||||||
decimal_values = process_block(block)
|
decimal_values = process_block(block)
|
||||||
all_decimal_values.extend(decimal_values)
|
all_decimal_values.extend(decimal_values)
|
||||||
|
|
||||||
if len(all_decimal_values) < 15:
|
if len(all_decimal_values) < 15:
|
||||||
raise ValueError("Error: Not enough data after processing blocks 4, 5, 6, and 7.")
|
raise ValueError("Error: Not enough data after processing blocks 4, 5, 6, and 7.")
|
||||||
|
|
||||||
id_positions = [9, 11, 13, 15, 2, 4, 6, 8]
|
id_positions = [9, 11, 13, 15, 2, 4, 6, 8]
|
||||||
id_numbers = [all_decimal_values[pos-1] for pos in id_positions]
|
id_numbers = [all_decimal_values[pos-1] for pos in id_positions]
|
||||||
decimal_id = int(''.join(map(str, id_numbers)))
|
decimal_id = int(''.join(map(str, id_numbers)))
|
||||||
padded_hex_id = format(decimal_id, 'X').upper().zfill(10)
|
padded_hex_id = format(decimal_id, 'X').upper().zfill(10)
|
||||||
|
|
||||||
return decimal_id, padded_hex_id
|
return decimal_id, padded_hex_id
|
||||||
|
|
||||||
def input_block_data(block_number):
|
def input_block_data(block_number):
|
||||||
while True:
|
while True:
|
||||||
block_data = input("Enter data for block {} (4 bytes in hex): ".format(block_number)).strip()
|
block_data = input("Enter data for block {} (4 bytes in hex): ".format(block_number)).strip()
|
||||||
|
@ -52,6 +67,8 @@ def input_block_data(block_number):
|
||||||
print("Error: Data must be 4 bytes (8 characters) in hex. Try again.")
|
print("Error: Data must be 4 bytes (8 characters) in hex. Try again.")
|
||||||
else:
|
else:
|
||||||
return block_data
|
return block_data
|
||||||
|
|
||||||
|
|
||||||
block_4 = input_block_data(4)
|
block_4 = input_block_data(4)
|
||||||
block_5 = input_block_data(5)
|
block_5 = input_block_data(5)
|
||||||
block_6 = input_block_data(6)
|
block_6 = input_block_data(6)
|
||||||
|
@ -62,6 +79,7 @@ blocks = [
|
||||||
block_6,
|
block_6,
|
||||||
block_7,
|
block_7,
|
||||||
]
|
]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
decimal_id, padded_hex_id = calculate_id(blocks)
|
decimal_id, padded_hex_id = calculate_id(blocks)
|
||||||
print('Calculated data from blocks 4, 5, 6, 7:')
|
print('Calculated data from blocks 4, 5, 6, 7:')
|
Loading…
Add table
Add a link
Reference in a new issue