def rotr(byte, shift):
return ((byte >> shift) | (byte << (8 - shift))) & 0xff
def two_layer_decrypt(data, param_3, param_4, param_5, param_6):
decrypted_data = []
for byte in data:
# First layer: XOR with param_5, then rotate right by param_6
bVar1 = rotr(byte ^ param_5, param_6)
# Second layer: XOR with param_3, then rotate right by param_4
uVar2 = rotr(bVar1 ^ param_3, param_4)
decrypted_data.append(uVar2)
return bytes(decrypted_data)
# Encrypted key extracted from memory
encrypted_key = bytes([0x59, 0x78, 0x39, 0x58, 0xd9, 0x19, 0xd8, 0x99])
# Decrypt the key using the parameters from the challenge
decrypted_key = two_layer_decrypt(encrypted_key, 0xaa, 3, 0x5f, 2)
# Print the decrypted key
print(f"Decrypted Key: {decrypted_key.decode()}")
Decrypted Key: elfmagic
┌──(zwique㉿kali)-[~/Downloads/slv/Shimbles_the_E-L-F]
└─$ ./Shimbles-the-elf
__
.-' |
/ <\|
/ \
|_.- o-o
/ C -._)\
/', |
| `-,_,__,'
(,,)====[_]=|
'. ____/
| -|-|_
|____)_)
Schimbles: Hello, mortal! I am Schimbles, the enchanted gnome.
Schimbles: I've encrypted your precious data and you'll never see it again...
Schimbles: ...unless you can decrypt my file.
Schimbles: Enter the decryption key: elfmagic
Schimbles: Ha! You have bested me!
Schimbles: Here is your flag: BCC{n0t_t0day_e1f}