Skip to content

Latest commit

 

History

History
110 lines (85 loc) · 2.35 KB

File metadata and controls

110 lines (85 loc) · 2.35 KB

Cryptohack [3/4]

previous

Bytes and Big Integers

python not working on WSL

from Crypto.Util.number import long_to_bytes
out = 11515195063862318899931685488813747395775516287289682636499965282714637259206269
print(long_to_bytes(out))

XOR Starter

Demo

"%b" % (0b0110 ^ 0b1010)

Solver

label = "label"
puts "crypto{#{label.chars.map { |c| (c.ord ^ 13).chr }.join}}"
crypto{aloha}

Keyed Permutations

  • CLOSING NOTE [2026-02-27 金 23:59]
Advanced Encryption Standard

Bijection,全単射

Resisting Bruteforce

  • CLOSING NOTE [2026-02-28 土 00:21]

Structure of AES

  • CLOSING NOTE [2026-02-28 土 00:38]
    ?

DL

curl -OL https://cryptohack.org/static/challenges/matrix_e1b463dddbee6d17959618cf370ff1a5.py

Solver

sum によって 1 行にして、バイト列に変換する。

def bytes2matrix(text):
    """ Converts a 16-byte array into a 4x4 matrix.  """
    return [list(text[i:i+4]) for i in range(0, len(text), 4)]

def matrix2bytes(matrix):
    """ Converts a 4x4 matrix into a 16-byte array.  """
    return bytes(sum(matrix, []))

matrix = [
    [99, 114, 121, 112],
    [116, 111, 123, 105],
    [110, 109, 97, 116],
    [114, 105, 120, 125],
]

print(matrix2bytes(matrix))
b'crypto{inmatrix}'

XOR Properties

key1 = 'a6c8b6733c9b22de7bc0253266a3867df55acde8635e19c73313'
key2_key1 = '37dcb292030faa90d07eec17e3b1c6d8daf94c35d4c9191a5e1e'
key2__key3 = 'c1545756687e7573db23aa1c3452a098b71a7fbf0fddddde5fc1'
flag_key1_key3_key2 = '04ee9855208a2cd59091d04767ae47963170d1660df7f56f5faf'