cbcモード

Integral Communication | IrisCTF2024

#IrisCTF2024 from json import JSONDecodeError, loads, dumps from binascii import hexlify, unhexlify from Crypto.Cipher import AES from Crypto.Random import get_random_bytes with open("flag") as f: flag = f.readline() key = get_random_bytes…

Padding Oracle Attack

以下の条件を満たすとき、暗号文から平文を復元できる CBCモード で暗号化されている PKCS#7 でパディングされている 復号の成否がわかる 何度でも復号できる 原理 CBCモードでは暗号化は次のように行われる 同様に復号はこう ここで偽物のデータ を与えて復…

BSidesSF 2019 CTF|decrypto

#BSidesSF2019CTF https://ctftime.org/task/7764 (decrypto's signature cookie is important.. the text at the top is wrong. Sorry!) Hack the mainframe! Location - https://decrypto-6213399b.challenges.bsidessf.net Web +Crypto。幸いにも問題情報…

BSides Noida CTF | Macaw Revenge

#bsidesnoidactf #!/usr/bin/env python3 from Crypto.Cipher import AES import os with open('flag.txt') as f: FLAG = f.read() menu = r""" /===== MENU =====\ | | | [M] MAC Gen | | [A] AUTH | | | \================/ """ def MAC(data, check=False…

CBC

CBCモード

ACSC 2021 | CBCB

#acsc2021 #!/usr/bin/env python3 import base64 import json import os from Crypto.Cipher import AES from Crypto.Util.Padding import pad, unpad from flag import flag key = os.urandom(16) iv1 = os.urandom(16) iv2 = os.urandom(16) admin_userna…

WMCTF 2020 | game

CBCモード IV固定のCBCモードでECB のChosen Plaintext Attackのようなものをやれという問題。リクエストの回数に制限がなく、時間も20minと十分にとってあったので、適切なサーバを使って高速ネットワークに頼ればなんとかなる IVがわかっているので最初のb…

ångstromCTF 2019 | MAC Forgery

#angstromCTF2019 https://ctftime.org/task/8345 CBC-MAC is so overrated. This new scheme supports variable lengths and multiple tags per message. nc 54.159.113.26 19002 import binascii import socketserver from cbc_mac import CBC_MAC from se…

CBC-IV-Detection

CBCモード IVがわからなくて、使い回されているというなかなか見ない状況だけど、そういうときにIVを特定する手法がある。 条件は CBCモードでの暗号化ができること CBCモードでの復号の成否がわかること 何をするかと言うと、 適当な3ブロック以上の平文を…

Crypto CTF 2021 | KeyBase

#cryptoctf2021 #!/usr/bin/env python3 from Crypto.Util import number from Crypto.Cipher import AES import os import sys import random from flag import flag def keygen(): iv, key = [os.urandom(16) for _ in '01'] return iv, key def encrypt(m…