mirror of
https://github.com/wetox-team/flipperzero-goodies.git
synced 2024-08-17 00:11:10 +03:00
add script to check for duplicate keys
This commit is contained in:
parent
edda434c27
commit
4e65659617
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.idea
|
2
Makefile
Normal file
2
Makefile
Normal file
@ -0,0 +1,2 @@
|
||||
check-keys:
|
||||
python3 ./scripts/key-utils/check-duplicates.py
|
@ -1,6 +0,0 @@
|
||||
Filetype: Flipper iButton key
|
||||
Version: 1
|
||||
# Key type can be Cyfral, Dallas or Metakom
|
||||
Key type: Dallas
|
||||
# Data size for Cyfral is 2, for Metakom is 4, for Dallas is 8
|
||||
Data: 01 BE 40 11 5A 36 00 E1
|
@ -1,6 +0,0 @@
|
||||
Filetype: Flipper iButton key
|
||||
Version: 1
|
||||
# Key type can be Cyfral, Dallas or Metakom
|
||||
Key type: Dallas
|
||||
# Data size for Cyfral is 2, for Metakom is 4, for Dallas is 8
|
||||
Data: 01 76 B8 2E 0F 00 00 5C
|
@ -1,6 +0,0 @@
|
||||
Filetype: Flipper iButton key
|
||||
Version: 1
|
||||
# Key type can be Cyfral, Dallas or Metakom
|
||||
Key type: Dallas
|
||||
# Data size for Cyfral is 2, for Metakom is 4, for Dallas is 8
|
||||
Data: 01 FF FF FF FF FF FF 2F
|
@ -1,6 +0,0 @@
|
||||
Filetype: Flipper RFID key
|
||||
Version: 1
|
||||
# Key type can be EM4100, H10301 or I40134
|
||||
Key type: EM4100
|
||||
# Data size for EM4100 is 5, for H10301 is 3, for I40134 is 3
|
||||
Data: 56 5A 11 40 BE
|
@ -1,6 +0,0 @@
|
||||
Filetype: Flipper iButton key
|
||||
Version: 1
|
||||
# Key type can be Cyfral, Dallas or Metakom
|
||||
Key type: Dallas
|
||||
# Data size for Cyfral is 2, for Metakom is 4, for Dallas is 8
|
||||
Data: 01 5E 99 AC 12 00 00 FA
|
@ -1,6 +0,0 @@
|
||||
Filetype: Flipper RFID key
|
||||
Version: 1
|
||||
# Key type can be EM4100, H10301 or I40134
|
||||
Key type: EM4100
|
||||
# Data size for EM4100 is 5, for H10301 is 3, for I40134 is 3
|
||||
Data: 56 5A 11 40 BE
|
@ -1,6 +0,0 @@
|
||||
Filetype: Flipper iButton key
|
||||
Version: 1
|
||||
# Key type can be Cyfral, Dallas or Metakom
|
||||
Key type: Dallas
|
||||
# Data size for Cyfral is 2, for Metakom is 4, for Dallas is 8
|
||||
Data: 01 00 00 00 00 00 00 3D
|
@ -1,6 +0,0 @@
|
||||
Filetype: Flipper iButton key
|
||||
Version: 1
|
||||
# Key type can be Cyfral, Dallas or Metakom
|
||||
Key type: Dallas
|
||||
# Data size for Cyfral is 2, for Metakom is 4, for Dallas is 8
|
||||
Data: 01 76 B8 2E 0F 00 00 5C
|
@ -1,6 +0,0 @@
|
||||
Filetype: Flipper iButton key
|
||||
Version: 1
|
||||
# Key type can be Cyfral, Dallas or Metakom
|
||||
Key type: Dallas
|
||||
# Data size for Cyfral is 2, for Metakom is 4, for Dallas is 8
|
||||
Data: 01 00 BE 11 AA 00 00 FB
|
@ -1,6 +0,0 @@
|
||||
Filetype: Flipper iButton key
|
||||
Version: 1
|
||||
# Key type can be Cyfral, Dallas or Metakom
|
||||
Key type: Dallas
|
||||
# Data size for Cyfral is 2, for Metakom is 4, for Dallas is 8
|
||||
Data: 01 00 00 00 00 90 19 FF
|
@ -1,6 +0,0 @@
|
||||
Filetype: Flipper iButton key
|
||||
Version: 1
|
||||
# Key type can be Cyfral, Dallas or Metakom
|
||||
Key type: Dallas
|
||||
# Data size for Cyfral is 2, for Metakom is 4, for Dallas is 8
|
||||
Data: 01 53 D4 FE 00 00 00 6F
|
@ -1,6 +0,0 @@
|
||||
Filetype: Flipper iButton key
|
||||
Version: 1
|
||||
# Key type can be Cyfral, Dallas or Metakom
|
||||
Key type: Dallas
|
||||
# Data size for Cyfral is 2, for Metakom is 4, for Dallas is 8
|
||||
Data: 01 BE 40 11 5A 36 00 E1
|
@ -1,6 +0,0 @@
|
||||
Filetype: Flipper iButton key
|
||||
Version: 1
|
||||
# Key type can be Cyfral, Dallas or Metakom
|
||||
Key type: Dallas
|
||||
# Data size for Cyfral is 2, for Metakom is 4, for Dallas is 8
|
||||
Data: 01 FF FF FF FF FF FF 2F
|
@ -1,6 +0,0 @@
|
||||
Filetype: Flipper iButton key
|
||||
Version: 1
|
||||
# Key type can be Cyfral, Dallas or Metakom
|
||||
Key type: Dallas
|
||||
# Data size for Cyfral is 2, for Metakom is 4, for Dallas is 8
|
||||
Data: 01 FF FF FF FF 00 00 9B
|
71
scripts/key-utils/check-duplicates.py
Normal file
71
scripts/key-utils/check-duplicates.py
Normal file
@ -0,0 +1,71 @@
|
||||
from collections import defaultdict
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
KEYS_DIR = Path(__file__).parent.parent.parent / 'intercom-keys'
|
||||
KEYS = defaultdict(list)
|
||||
|
||||
|
||||
class KeyTypes:
|
||||
ibtn = 'ibutton'
|
||||
rfid = 'lfrfid'
|
||||
nfc = 'nfc'
|
||||
|
||||
|
||||
def parse_data(file_path: Path):
|
||||
with file_path.open() as file:
|
||||
key_data = file.read()
|
||||
|
||||
if 'Data' not in key_data:
|
||||
return ''
|
||||
|
||||
start_index = key_data.index('\nData: ') + 7
|
||||
end_index = start_index + key_data[start_index + 1:].index('\n')
|
||||
|
||||
return key_data[start_index:end_index]
|
||||
|
||||
|
||||
def handle_keys(dir_path, key_type):
|
||||
for file in (dir_path / key_type).iterdir():
|
||||
if not file.is_file() or file.name == '.gitkeep':
|
||||
continue
|
||||
|
||||
data = parse_data(file).replace(' ', '').strip()
|
||||
if not data:
|
||||
continue
|
||||
|
||||
KEYS[f'{key_type}:{data}'].append(file)
|
||||
|
||||
|
||||
def check_duplicates():
|
||||
for city_dir in KEYS_DIR.iterdir():
|
||||
if not city_dir.is_dir():
|
||||
continue
|
||||
|
||||
keys_dir = city_dir / 'keys'
|
||||
handle_keys(keys_dir, KeyTypes.ibtn)
|
||||
handle_keys(keys_dir, KeyTypes.rfid)
|
||||
handle_keys(keys_dir, KeyTypes.nfc)
|
||||
|
||||
|
||||
def main():
|
||||
global KEYS
|
||||
|
||||
print('CHECK FOR DUPLICATE KEYS:\n')
|
||||
|
||||
KEYS.clear()
|
||||
check_duplicates()
|
||||
|
||||
result = '\n'.join(
|
||||
(f'{k}:\n\t' + '\n\t'.join(f.as_posix() for f in v))
|
||||
for k, v in KEYS.items() if len(v) > 1
|
||||
)
|
||||
|
||||
if not result:
|
||||
print('no duplicates')
|
||||
else:
|
||||
print(result)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
Reference in New Issue
Block a user