대칭키 암호
암복호화에 사용하는 키가 동일한 방식으로 각 사용자 pair 마다 키를 교환해야 하는 문제가 있다.
공개키 암호 (비대칭키 암호)
Finding Flags
flag : crypto{y0ur_f1rst_fl4g}
Great Snakes
첨부된 파일을 실행시키면 플래그가 출력된다.
flag : crypto{z3n_0f_pyth0n}
Network Attacks
첨부된 파일을 열어서 보면
#!/usr/bin/env python3
import telnetlib
import json
HOST = "socket.cryptohack.org"
PORT = 11112
tn = telnetlib.Telnet(HOST, PORT)
def readline():
return tn.read_until(b"\n")
def json_recv():
line = readline()
return json.loads(line.decode())
def json_send(hsh):
request = json.dumps(hsh).encode()
tn.write(request)
print(readline())
print(readline())
print(readline())
print(readline())
request = {
"buy": "clothes"
}
json_send(request)
response = json_recv()
print(response)
이 코드에서 "buy": "clothes"를 "buy": "flag"로 바꾸어 실행 시키면 flag가 출력된다.
request = {
"buy": "flag"
}
flag : crypto{sh0pp1ng_f0r_fl4g5}
Encoding
array = [99, 114, 121, 112, 116, 111, 123, 65, 83, 67, 73, 73, 95, 112, 114, 49, 110, 116, 52, 98, 108, 51, 125]
flag = ""
for i in range(len(array)):
flag += chr(array[i])
print(flag)
flag : crypto{ASCII_pr1nt4bl3}
hax_string = bytes.fromhex('63727970746f7b596f755f77696c6c5f62655f776f726b696e675f776974685f6865785f737472696e67735f615f6c6f747d')
print(hax_string)
flag : crypto{You_will_be_working_with_hex_strings_a_lot}
import base64
hex_string = bytes.fromhex('72bca9b68fc16ac7beeb8f849dca1d8a783e8acf9679bf9269f7bf')
print(base64.b64encode(hex_string).decode())
flag : crypto/Base+64+Encoding+is+Web+Safe/
Bytes and Big Integers long_to_bytes()라는 함수를 사용해서 변환하면 flag를 얻을 수 있다.
(PyCryptodome을 먼저 설치해야 한다.)
flag : crypto{3nc0d1n6_4ll_7h3_w4y_d0wn}
Encoding Challenge 해결하기 힘들어서 구글링을 했다. Pwntools의 기초와, json 문법에 대해서 알아야 한다고 한다.
flag : crypto{3nc0d3_d3c0d3_3nc0d3}
XOR
data = "label"
flag = ''
for i in data:
flag += chr(ord(i) ^ 13)
print('crypto{{{}}}'.format(flag))
flag : crypto{aloha}
from pwn import xor
k1=bytes.fromhex('a6c8b6733c9b22de7bc0253266a3867df55acde8635e19c73313')
k2_3=bytes.fromhex('c1545756687e7573db23aa1c3452a098b71a7fbf0fddddde5fc1')
flag=bytes.fromhex('04ee9855208a2cd59091d04767ae47963170d1660df7f56f5faf')
print(xor(k1,k2_3,flag))
flag : crypto{x0r_i5_ass0c1at1v3}
input_str = bytes.fromhex('73626960647f6b206821204f21254f7d694f7624662065622127234f726927756d')
key = input_str[0] ^ ord('c')
print(''.join(chr(c ^ key) for c in input_str))
flag : crypto{0x10_15_my_f4v0ur173_by7e}
flag : crypto{1f_y0u_Kn0w_En0uGH_y0u_Kn0w_1t_4ll}
flag : crypto{X0Rly_n0t!}
HOW AES WORKS
flag : crypto{bijection}
flag : crypto{biclique}
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))
flag : crypto{inmatrix}
SYMMETRIC STARTER
Modes of Operation Starter encrypt_flag를 해독하고 hex to bytes를 실행하면 flag를 얻을 수 있다.
flag : crypto{bl0ckc1ph3r5_4r3_f457!}
Passwords as Keys words를 다운받아서 가능한 키들을 모두 decrypt했을 때 앞글자가 cr로 시작하는 것으로 필터링하면 flag가 출력된다.
flag : crypto{k3y5rn07__p455w0rdz?}