picoctf/crypto/tapping/solve.py

54 lines
813 B
Python
Raw Normal View History

2024-09-03 00:04:53 +02:00
#!/usr/bin/env python
MORSE_MAP = {
'.-': 'A',
'-...': 'B',
'-.-.': 'C',
'-..': 'D',
'.': 'E',
'..-.': 'F',
'--.': 'G',
'....': 'H',
'..': 'I',
'.---': 'J',
'-.-': 'K',
'.-..': 'L',
'--': 'M',
'-.': 'N',
'---': 'O',
'.--.': 'P',
'--.-': 'Q',
'.-.': 'R',
'...': 'S',
'-': 'T',
'..-': 'U',
'...-': 'V',
'.--': 'W',
'-..-': 'X',
'-.--': 'Y',
'--..': 'Z',
'-----': '0',
'.----': '1',
'..---': '2',
'...--': '3',
'....-': '4',
'.....': '5',
'-....': '6',
'--...': '7',
'---..': '8',
'----.': '9',
'{': '{',
'}': '}',
}
with open('output.txt', 'r') as f:
content = f.read().strip()
result = ''
for word in content.split(' '):
result += MORSE_MAP.get(word, '?')
# PICO -> pico
result = result[:4].lower() + result[4:]
print(result)