


#!/usr/bin/env python3
import sys
# import this
if sys.version_info.major == 2:
print("You are running Python 2, which is no longer supported. Please update to Python 3.")
ords = [81, 64, 75, 66, 70, 93, 73, 72, 1, 92, 109, 2, 84, 109, 66, 75, 70, 90, 2, 92, 79]
print("Here is your flag:")
print("".join(chr(o ^ 0x32) for o in ords))


c = [99, 114, 121, 112, 116, 111, 123, 65, 83, 67, 73, 73, 95, 112, 114, 49, 110, 116, 52, 98, 108, 51, 125]
print("".join(chr(i) for i in c))


c = "63727970746f7b596f755f77696c6c5f62655f776f726b696e675f776974685f6865785f737472696e67735f615f6c6f747d"
print(bytes.fromhex(c))


import base64
c = "72bca9b68fc16ac7beeb8f849dca1d8a783e8acf9679bf9269f7bf"
c = bytes.fromhex(c)
c = base64.b64encode(c)
print(c)

위의 코드와 같이 강의에서 요구하는데로 작성했음에도 오류가 뜨는 것을 볼 수 있습니다. 위의 오류는 코드를 보면 알 수 있습니다. 코드에서 base64로 encoding하는 함수를 사용하기 위해 base64 모듈을 import하는 것을 첫줄에서 확인 할 수 있는데 이 모듈과 내가 지은 파이썬 파일의 이름이 같아서 발생하는 오류입니다. 따라서 이름만 변경해주면 아래와 같이 해결 됩니다. 저와 같은 실수를 하신 분들은 밑에 사이트 글에서 참고하시면 됩니다.

https://stackoverflow.com/questions/12020885/python-converting-file-to-base64-encoding
Python: Converting file to base64 encoding
This is my code: import base64 with open('/Users/Bob/test.txt') as f: encoded = base64.b64encode(f.readlines()) print(encoded) I've based it on the base64 documentation. However, when I ...
stackoverflow.com

from Crypto.Util.number import *
c = "11515195063862318899931685488813747395775516287289682636499965282714637259206269"
c = long_to_bytes(c)
print(c)

첫 course에서 xor 연산 전까지 강의 내용을 공부겸 풀이를 해봤습니다. 다음 글에서 나머지 부분을 올리겠습니다.
'security > crypto' 카테고리의 다른 글
[CryptoHack] Modular Arithmetic (1) (0) | 2023.11.22 |
---|---|
[CryptoHack] Introduction to CryptoHack (2) (0) | 2023.11.22 |
[Dreamhack] Textbook-DSA 풀이 (0) | 2023.11.15 |
[Dreamhack] Textbook-RSA 풀이 (0) | 2023.11.13 |
[Dreamhack] SingleByteXor 풀이 (0) | 2023.11.11 |