Ancient Encodings
Difficulty: Very easy
Category: Crypto
Date: 2024-03-20
Completed:complete
Background
Your initialization sequence requires loading various programs to gain the necessary knowledge and skills for your journey. Your first task is to learn the ancient encodings used by the aliens in their communication.
Artifact Contents
Files:
├── output.txt
└── source.py
Output.txt:
0x53465243657a51784d56383361444e664d32356a4d475178626a6c664e44497a5832677a4d6a4e664e7a42664e5463306558303d
Source.py:
from Crypto.Util.number import bytes_to_long
from base64 import b64encode
from secret import FLAG
def encode(message):
return hex(bytes_to_long(b64encode(message)))
def main():
encoded_flag = encode(FLAG)
with open("output.txt", "w") as f:
f.write(encoded_flag)
if __name__ == "__main__":
main()
Solution
Decrypt.py
from Crypto.Util.number import long_to_bytes
from base64 import b64decode
secret = '0x53465243657a51784d56383361444e664d32356a4d475178626a6c664e44497a5832677a4d6a4e664e7a42664e5463306558303d'
flag = ''
def decrypt():
final_flag = b64decode(long_to_bytes(int(secret, 16)))
return final_flag
def main():
decoded_flag = decrypt()
print(decoded_flag)
main()
Output from decrypt.py
b'HTB{411_7h3_3nc0d1n9_423_h323_70_574y}'
Flag:
HTB{411_7h3_3nc0d1n9_423_h323_70_574y}