feat: add magic-byte challenge
This commit is contained in:
parent
79072f30c9
commit
209ca55ada
14
magic-byte/README.md
Normal file
14
magic-byte/README.md
Normal file
@ -0,0 +1,14 @@
|
||||
# Magic Byte
|
||||
|
||||
## Text
|
||||
|
||||
Hi! I encrypted my flag with some awesome magic. ... Lore ... Lore ...
|
||||
Figure it out :)
|
||||
|
||||
## Files
|
||||
|
||||
magic_byte.txt
|
||||
|
||||
## How to Deploy
|
||||
|
||||
N/A
|
15
magic-byte/SOLUTION.md
Normal file
15
magic-byte/SOLUTION.md
Normal file
@ -0,0 +1,15 @@
|
||||
## Difficulty
|
||||
|
||||
Easy, because it is easy.
|
||||
|
||||
## Category
|
||||
|
||||
Crypto
|
||||
|
||||
## How To Solve
|
||||
|
||||
Just bruteforce the magic byte, xoring the ciphertext with the byte.
|
||||
|
||||
## Flag
|
||||
|
||||
IGCTF{hello_flag!}
|
33
magic-byte/create_magic_byte.py
Normal file
33
magic-byte/create_magic_byte.py
Normal file
@ -0,0 +1,33 @@
|
||||
magic = 0xCC
|
||||
flag = "IGCTF{hello_flag!}"
|
||||
|
||||
def xor_string_with_byte(input_str, xor_byte):
|
||||
# Convert the input string to bytes
|
||||
input_bytes = input_str.encode()
|
||||
|
||||
# XOR each byte in the string with the given byte
|
||||
xor_result = bytes([b ^ xor_byte for b in input_bytes])
|
||||
|
||||
# Convert the XOR result to a hex string
|
||||
hex_result = xor_result.hex()
|
||||
|
||||
return hex_result
|
||||
|
||||
def reverse_xor(hex_str, xor_byte):
|
||||
# Convert the hex string back to bytes
|
||||
xor_bytes = bytes.fromhex(hex_str)
|
||||
|
||||
# XOR each byte in the result with the same XOR byte
|
||||
original_bytes = bytes([b ^ xor_byte for b in xor_bytes])
|
||||
|
||||
# Convert the result back to the original string
|
||||
original_str = original_bytes.decode()
|
||||
|
||||
return original_str
|
||||
|
||||
|
||||
result = xor_string_with_byte(flag, magic)
|
||||
print(result)
|
||||
|
||||
original = reverse_xor(result, magic)
|
||||
print(original)
|
1
magic-byte/magic_byte.txt
Normal file
1
magic-byte/magic_byte.txt
Normal file
@ -0,0 +1 @@
|
||||
flag: 858b8f988ab7a4a9a0a0a393aaa0adabedb1
|
Loading…
Reference in New Issue
Block a user