728x90
반응형
1. intro
2. code 및 분석
2.1. code
N/A
2.2. 분석
문제의 설명을 간단히 해석해보면
일반적으로 encrypt된 결과는 ASCII character가 아닌 bytes로 표현된다.
hex 값은 ascii strings로 대체하여 사용될 수 있다.
각각의 문자를 10진수로 표현하고, 이를 16진수 즉 hexadecimal로 변환한다.
그리고 그 값을 합치면 긴 hex string이 된다.
3. exploit
함수를 몰라도 이렇게 풀 수 있다.
e = '63727970746f7b596f755f77696c6c5f62655f776f726b696e675f776974685f6865785f737472696e67735f615f6c6f747d'
d = ''
for i in range(0,len(e),2):
d += chr(int(e[i:i+2],16))
print(d)
┌──(kali㉿kali)-[~/Downloads]
└─$ python solve.py
crypto{You_will_be_working_with_hex_strings_a_lot}
함수를 이용하면 더 간단.
┌──(kali㉿kali)-[~/Downloads]
└─$ python
Python 3.10.8 (main, Nov 4 2022, 09:21:25) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> e = '63727970746f7b596f755f77696c6c5f62655f776f726b696e675f776974685f6865785f737472696e67735f615f6c6f747d'
>>> bytes.fromhex(e)
b'crypto{You_will_be_working_with_hex_strings_a_lot}'
* 참고로 .hex()는 byte string을 hex로 (문제와 같이) 변환할 때 사용한다.
728x90
반응형
'Wargame > Cryptohack' 카테고리의 다른 글
Bytes and Big Integers (0) | 2023.01.31 |
---|---|
Base64 (0) | 2023.01.31 |
ASCII (0) | 2023.01.31 |
Great Snakes (0) | 2023.01.31 |
Finding Flags (0) | 2023.01.31 |