๋ฐ์ํ
https://cryptohack.org/challenges/general/
XOR Starter
Given the string "label", XOR each character with the integer 13. Convert these integers back to a string and submit the flag as crypto{new_string}.
The Python pwntools library has a convenient xor() function that can XOR together data of different types and lengths. But first, you may want to implement your own function to solve this.
"label" ์ด๋ผ๋ ๋ฌธ์์ด์ 13์ด๋ผ๋ ์ ์ํ๊ณผ xor ์ฐ์ฐ์ ํ๋ฉด ๋๋ค.
code = "label"
decode = []
for i in code :
decode.append(ord(i) ^ 13)
for d in decode:
print(chr(d))
๋๋ณด๊ธฐ
crypto{aloha}
XOR Properties
Let's try this out in action! Below is a series of outputs where three random keys have been XOR'd together and with the flag. Use the above properties to undo the encryption in the final line to obtain the flag.
KEY1 = a6c8b6733c9b22de7bc0253266a3867df55acde8635e19c73313
KEY2 ^ KEY1 = 37dcb292030faa90d07eec17e3b1c6d8daf94c35d4c9191a5e1e
KEY2 ^ KEY3 = c1545756687e7573db23aa1c3452a098b71a7fbf0fddddde5fc1
FLAG ^ KEY1 ^ KEY3 ^ KEY2 = 04ee9855208a2cd59091d04767ae47963170d1660df7f56f5faf
Before you XOR these objects, be sure to decode from hex to bytes.
A^B ์์ A๋ฅผ XOR ์ฐ์ฐํด์ฃผ๋ฉด B ๊ฐ ๋จ๋๋ค๋ ์ฌ์ค์ ์ด์ฉํ์.
(A^B) ^ A = B
from Crypto.Util.number import *
hint0 = "a6c8b6733c9b22de7bc0253266a3867df55acde8635e19c73313" # KEY1
hint1 = "37dcb292030faa90d07eec17e3b1c6d8daf94c35d4c9191a5e1e" # KEY1 ^ KEY2
hint2 = "c1545756687e7573db23aa1c3452a098b71a7fbf0fddddde5fc1" # KEY2 ^ KEY3
hint3 = "04ee9855208a2cd59091d04767ae47963170d1660df7f56f5faf" # KEY1 ^ KEY2 ^ KEY3 ^ FLAG
# KEY1 = hint0
KEY1 = bytes_to_long(bytes.fromhex(hint0))
# KEY2 = (KEY1 ^ KEY2) ^ KEY1
KEY2 = bytes_to_long(bytes.fromhex(hint1)) ^ KEY1
# KEY3 = (KEY2 ^ KEY3) ^ KEY2
KEY3 = bytes_to_long(bytes.fromhex(hint2)) ^ KEY2
# FLAG = (KEY1 ^ KEY2 ^ KEY3 ^ FLAG) ^ KEY1 ^ KEY2 ^ KEY3
FLAG = bytes_to_long(bytes.fromhex(hint3)) ^ KEY1 ^ KEY2 ^ KEY3
print(str(long_to_bytes(FLAG), "UTF-8"))
๋๋ณด๊ธฐ
crypto{x0r_i5_ass0c1at1v3}
Favourite Bite
For the next few challenges, you'll use what you've just learned to solve some more XOR puzzles.
I've hidden some data using XOR with a single byte, but that byte is a secret. Don't forget to decode from hex first.
73626960647f6b206821204f21254f7d694f7624662065622127234f726927756d
๋ฐ์ํ
'๐ Cyber Security > Cryptography (์ํธํ)' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[CryptoHack] General Challenge - Ecoding (0) | 2022.11.10 |
---|---|
[CryptoHack] Introduction to CryptoHack (0) | 2022.11.10 |