Skip to content

Commit

Permalink
hw slot list show disabled slots
Browse files Browse the repository at this point in the history
  • Loading branch information
Foxushka committed Aug 19, 2023
1 parent b1741c1 commit b50f9cd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
3 changes: 2 additions & 1 deletion software/script/chameleon_cli_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,9 +842,10 @@ def get_slot_name(self, slot, sense):
# hw slot list
def on_exec(self, args: argparse.Namespace):
data = self.cmd_positive.get_slot_info().data
enabled = self.cmd_positive.get_enabled_slots().data
selected = chameleon_cmd.SlotNumber.from_fw(self.cmd_positive.get_active_slot().data[0])
for slot in chameleon_cmd.SlotNumber:
print(f' - Slot {slot} data{" (active)" if slot == selected else ""}:')
print(f' - Slot {slot} data{" (active)" if slot == selected else ""}{" (disabled)" if not enabled[chameleon_cmd.SlotNumber.to_fw(slot)] else ""}:')
print(f' HF: {(self.get_slot_name(slot, chameleon_cmd.TagSenseType.TAG_SENSE_HF) + " - ") if args.names else ""}{chameleon_cmd.TagSpecificType(data[chameleon_cmd.SlotNumber.to_fw(slot) * 2])}')
print(f' LF: {(self.get_slot_name(slot, chameleon_cmd.TagSenseType.TAG_SENSE_LF) + " - ") if args.names else ""}{chameleon_cmd.TagSpecificType(data[chameleon_cmd.SlotNumber.to_fw(slot) * 2 + 1])}')

Expand Down
36 changes: 22 additions & 14 deletions software/script/chameleon_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

DATA_CMD_WIPE_FDS = 1020

DATA_CMD_GET_ENABLED_SLOTS = 1023

DATA_CMD_SCAN_14A_TAG = 2000
DATA_CMD_MF1_SUPPORT_DETECT = 2001
DATA_CMD_MF1_NT_LEVEL_DETECT = 2002
Expand Down Expand Up @@ -159,33 +161,33 @@ def get_firmware_version(self) -> int:
"""
Get firmware version number(application)
"""
resp = self.device.send_cmd_sync(DATA_CMD_GET_APP_VERSION, 0x00, None)
resp = self.device.send_cmd_sync(DATA_CMD_GET_APP_VERSION, 0x00)
return int.from_bytes(resp.data, 'little')

def get_device_chip_id(self) -> str:
"""
Get device chip id
"""
resp = self.device.send_cmd_sync(DATA_CMD_GET_DEVICE_CHIP_ID, 0x00, None)
resp = self.device.send_cmd_sync(DATA_CMD_GET_DEVICE_CHIP_ID, 0x00)
return resp.data.hex()

def get_device_address(self) -> str:
"""
Get device address
"""
resp = self.device.send_cmd_sync(DATA_CMD_GET_DEVICE_ADDRESS, 0x00, None)
resp = self.device.send_cmd_sync(DATA_CMD_GET_DEVICE_ADDRESS, 0x00)
return resp.data[::-1].hex()

def get_git_version(self) -> str:
resp = self.device.send_cmd_sync(DATA_CMD_GET_GIT_VERSION, 0x00, None)
resp = self.device.send_cmd_sync(DATA_CMD_GET_GIT_VERSION, 0x00)
return resp.data.decode('utf-8')

def is_reader_device_mode(self) -> bool:
"""
Get device mode, reader or tag
:return: True is reader mode, else tag mode
"""
resp = self.device.send_cmd_sync(DATA_CMD_GET_DEVICE_MODE, 0x00, None)
resp = self.device.send_cmd_sync(DATA_CMD_GET_DEVICE_MODE, 0x00)
return True if resp.data[0] == 1 else False

def set_reader_device_mode(self, reader_mode: bool = True):
Expand All @@ -201,21 +203,21 @@ def scan_tag_14a(self):
扫描场内的14a标签
:return:
"""
return self.device.send_cmd_sync(DATA_CMD_SCAN_14A_TAG, 0x00, None)
return self.device.send_cmd_sync(DATA_CMD_SCAN_14A_TAG, 0x00)

def detect_mf1_support(self):
"""
检测是否是mifare classic标签
:return:
"""
return self.device.send_cmd_sync(DATA_CMD_MF1_SUPPORT_DETECT, 0x00, None)
return self.device.send_cmd_sync(DATA_CMD_MF1_SUPPORT_DETECT, 0x00)

def detect_mf1_nt_level(self):
"""
检测mifare classic的nt漏洞的等级
:return:
"""
return self.device.send_cmd_sync(DATA_CMD_MF1_NT_LEVEL_DETECT, 0x00, None)
return self.device.send_cmd_sync(DATA_CMD_MF1_NT_LEVEL_DETECT, 0x00)

def detect_darkside_support(self):
"""
Expand Down Expand Up @@ -315,7 +317,7 @@ def read_em_410x(self):
读取EM410X的卡号
:return:
"""
return self.device.send_cmd_sync(DATA_CMD_SCAN_EM410X_TAG, 0x00, None)
return self.device.send_cmd_sync(DATA_CMD_SCAN_EM410X_TAG, 0x00)

def write_em_410x_to_t55xx(self, id_bytes: bytearray):
"""
Expand All @@ -342,14 +344,14 @@ def get_slot_info(self):
Get slots info
:return:
"""
return self.device.send_cmd_sync(DATA_CMD_GET_SLOT_INFO, 0x00, None)
return self.device.send_cmd_sync(DATA_CMD_GET_SLOT_INFO, 0x00)

def get_active_slot(self):
"""
Get selected slot
:return:
"""
return self.device.send_cmd_sync(DATA_CMD_GET_ACTIVE_SLOT, 0x00, None)
return self.device.send_cmd_sync(DATA_CMD_GET_ACTIVE_SLOT, 0x00)

def set_slot_activated(self, slot_index: SlotNumber):
"""
Expand Down Expand Up @@ -428,7 +430,7 @@ def get_mf1_detection_count(self):
获取当前侦测记录的统计个数
:return:
"""
return self.device.send_cmd_sync(DATA_CMD_GET_MF1_DETECTION_COUNT, 0x00, None)
return self.device.send_cmd_sync(DATA_CMD_GET_MF1_DETECTION_COUNT, 0x00)

def get_mf1_detection_log(self, index: int):
"""
Expand Down Expand Up @@ -498,7 +500,7 @@ def update_slot_data_config(self):
更新卡槽的配置和数据到flash中。
:return:
"""
return self.device.send_cmd_sync(DATA_CMD_SLOT_DATA_CONFIG_SAVE, 0x00, None)
return self.device.send_cmd_sync(DATA_CMD_SLOT_DATA_CONFIG_SAVE, 0x00)

def enter_dfu_mode(self):
"""
Expand All @@ -511,7 +513,13 @@ def get_settings_animation(self):
"""
Get animation mode value
"""
return self.device.send_cmd_sync(DATA_CMD_GET_ANIMATION_MODE, 0x00, None)
return self.device.send_cmd_sync(DATA_CMD_GET_ANIMATION_MODE, 0x00)

def get_enabled_slots(self):
"""
Get animation mode value
"""
return self.device.send_cmd_sync(DATA_CMD_GET_ENABLED_SLOTS, 0x00)

def set_settings_animation(self, value: int):
"""
Expand Down

0 comments on commit b50f9cd

Please sign in to comment.