2026-11-05 11:10:32 +01:00
|
|
|
import base64
|
2026-11-05 11:19:40 +01:00
|
|
|
from Crypto.Util.number import long_to_bytes
|
|
|
|
|
from pwn import xor
|
2026-11-05 11:10:32 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
# Challenge intro-1
|
|
|
|
|
def int_to_ascii(input: [int]) -> str:
|
|
|
|
|
res = bytearray()
|
|
|
|
|
for i in input:
|
|
|
|
|
res += i.to_bytes()
|
|
|
|
|
return res.decode("utf-8")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Challenge intro-2
|
|
|
|
|
def hex_to_ascii(input: str) -> str:
|
|
|
|
|
return bytes.fromhex(input).decode("utf-8")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Challenge intro-3
|
|
|
|
|
def hex_to_b64(input: str) -> bytes:
|
|
|
|
|
return base64.b64encode(bytes.fromhex(input))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Challenge intro-4
|
|
|
|
|
def int_to_message_rsa(input: int) -> str:
|
|
|
|
|
return long_to_bytes(input)
|
2026-11-05 11:19:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
# Challenge intro-5
|
|
|
|
|
def xor_13(input: str) -> str:
|
|
|
|
|
return xor(input, 13).decode("utf-8")
|