2023-12-12から1日間の記事一覧

zer0pts CTF 2022 | CurveCrypto

#zer0ptsCTF2022 import os from random import randrange from Crypto.Util.number import bytes_to_long, long_to_bytes, getStrongPrime from Crypto.Util.Padding import pad from fastecdsa.curve import Curve def xgcd(a, b): x0, y0, x1, y1 = 1, 0,…

tsg live ctf 10

tetctf 2021 | unevaluated

#tetctf_2021 from collections import namedtuple from Crypto.Util.number import getPrime, isPrime, getRandomRange Complex = namedtuple("Complex", ["re", "im"]) def complex_mult(c1, c2, modulus): return Complex( (c1.re * c2.re - c1.im * c2.i…

redpwn CTf 2021 | yahtzee

#redpwnctf2021 #!/usr/local/bin/python from Crypto.Cipher import AES from Crypto.Util.number import long_to_bytes from random import randint from binascii import hexlify with open('flag.txt','r') as f: flag = f.read().strip() with open('ke…

redpwn CTF 2021 | round the bases

#redpwnctf2021 #uninterested_challenge_list は? crypto/round-the-bases AdnanSlef 348 solves / 107 points My flag has been all around the bases. Can you help me get it back? 9mTfc:..Zt9mTZ_:IIcu9mTN[9km7D9mTfc:..Zt9mTZ_:K0o09mTN[9km7D9mTfc…

redpwn CTF 2021 | quaternion regenge

#redpwnctf2021 #uninterested_challenge_list #!/usr/bin/env sage from Crypto.Util.number import getPrime, bytes_to_long import secrets with open('flag.txt','r') as flagfile: flag = flagfile.read().strip() with open('secret.txt','rb') as sec…

memo

https://en.wikipedia.org/wiki/Integrated_Encryption_Scheme https://en.wikipedia.org/wiki/Cramer%E2%80%93Shoup_cryptosystem

groebner basis

グレブナー基底

diceCTF 2021

難しいCryptoが揃ってた

angstrom CTF 2021 | substitution

#angstromctf2021 #!/usr/bin/python from functools import reduce with open("flag", "r") as f: key = [ord(x) for x in f.read().strip()] def substitute(value): return (reduce(lambda x, y: x * value + y, key)) % 691 print("Enter a number and i…

angstrom CTF 2021 | Home Rolled Crypto

#angstromctf2021 #!/usr/bin/python import binascii from random import choice class Cipher: BLOCK_SIZE = 16 ROUNDS = 3 def __init__(self, key): assert(len(key) == self.BLOCK_SIZE * self.ROUNDS) self.key = key def __block_encrypt(self, block…

Zh3r0 CTF V2 | import numpy as MT

#zh3ro_CTF_2021 #good_challenges_2021 import os from numpy import random from Crypto.Cipher import AES from Crypto.Util.Padding import pad from secret import flag def rand_32(): return int.from_bytes(os.urandom(4),'big') flag = pad(flag,16…

XOR SWAP

def swap(a, b): a = a ^ b b = a ^ b a = a ^ b return a, b また、加減算でどうようのことができる場合もある(し、逆元の存在が保証されていれば、乗除算でもできる) def swap(a, b): a = a + b b = a - b a = a - b return a, b

XCTF-SCTF 2020 | RSA

RSA Common Private Exponent Attack Lattice Based Attack on Common Private Exponent RSA from Crypto.Util.number import * from random import randint flag = int('SCTF{*******************}'.encode('hex'), 16) d = getPrime(randint(380, 385)) fo…

WaniCTF 2021 spring | OUCS

#wanictf2021spring import random from Crypto.Util.number import bytes_to_long, getPrime, long_to_bytes from const import description, flag, logo class OkamotoUchiyamaCryptoSystem: def __init__(self, bits: int): p, q = getPrime(bits), getPr…

Union CTF | Mordell Primes

#UnionCTF from Crypto.Util.number import bytes_to_long from secrets import k, FLAG assert k < 2^128 assert FLAG.startswith(b'union{') E = EllipticCurve(QQ,[0,1,0,78,-16]) P = E(1,8) Q = k*P R = (k+1)*P p = Q[0].numerator() q = R[0].numerat…

UTCTF|Tale of Two Cities

#UTCTF https://ctftime.org/task/7813 Looks like this book got a little messed up... there are some weird characters in there. by balex https://utctf.live/files/b9d45c82d82b23b8fddceb519b0c0bd7/tale-of-two-cities.txt Hint: hOpEfully thIS hi…

TSGCTF 2021

https://rkm0959.tistory.com/241 https://jsur.in/posts/2021-10-03-tsg-ctf-2021-crypto-writeups https://hackmd.io/@mikit/H1k7A68EK

TSG Live CTF 6 | Broken RSA

#tsglivectf6 class key: def __init__(self, p, q): self.N = p * q self.phi = (p - 1) * (q - 1) self.e = 65537 self.d = pow(self.e, -1, self.phi) def gen_private_key(self): return (self.N, self.d) def gen_public_key(self): return (self.N, se…

TSG Live CTF 10 | random_pair

#tsg_live_ctf_10 #!/usr/bin/python3 from Crypto.Util.number import getPrime, bytes_to_long import flag import secrets assert(len(flag.flag) == 33) p = getPrime(512) q = getPrime(512) N = p * q phi = (p - 1) * (q - 1) e = 3 assert(phi%e!=0)…

TSG CTF 2020 | Beginner's Crypto

crt

#CRT

TG:HACK 2019 | Passing Notes

#TG:HACK2019 In one of my classes, some students were sending notes back and forth. I confiscated one of the notes, but it only contained this: vyLlwWSY1PCK5ELNTPUVdpl8z0rIXiB2+Ybcu/BeXidR3MEiym852HCkS6wHVCr+CdpP6Moe9VQUeFcyq3vZDpVK/orl+8v…

Sekai CTF 2022 | time capsule

#Sekai_CTF_2022 import time import os import random from SECRET import flag def encrypt_stage_one(message, key): u = [s for s in sorted(zip(key, range(len(key))))] res = '' for i in u: for j in range(i[1], len(message), len(key)): res += m…

SecurinetsQuals2k21 | Shilaformi

#securinetsquals2k21 import signal from secret import flag from Crypto.Random import random from Crypto.Util.number import getPrime #Odds and evens (hand game) #https://en.wikipedia.org/wiki/Odds_and_evens_(hand_game) def pad(choice, n): r…

San Diego 2022 | magic3

#San_Diego_CTF_2022 posixがrevしてくれた magic_arr = [i for i in range(0x30)] setup_arr1 = [41, 38, 11, 14, 19, 9, 16, 48, 6, 46, 8, 35, 22, 32, 17, 40, 25, 1] setup_arr2 = [26, 21, 29, 15, 12, 4, 47, 23, 31, 18, 2] setup_arr3 = [30, 27, 2…

Sagemath Reference

sage GF == FiniteField 有限体。Field = GF(13) みたいな感じで作って、 Field(9) みたいな感じでインスタンス化する。 Field(9) * 200 == 9とかになる PolynomialRing 多項式環。整数上の多項式だったり有限体上の多項式だったするので、 PR.<x> = Polynomial</x>…

SECCON ONLINE 2019 | Crazy Repetition of Codes

#seecononline2019 import os from Crypto.Cipher import AES def crc32(crc, data): crc = 0xFFFFFFFF ^ crc for c in data: crc = crc ^ ord(c) for i in range(8): crc = (crc >> 1) ^ (0xEDB88320 * (crc & 1)) return 0xFFFFFFFF ^ crc key = b"" crc =…

SECCON CTF 2022 Quals | janken vs kurenaif

#SECCON_CTF_2022_Quals import os import signal import random import secrets FLAG = os.getenv("FLAG", "fake{cast a special spell}") def janken(a, b): return (a - b + 3) % 3 signal.alarm(1000) print("kurenaif: Hi, I'm a crypto witch. Let's a…

RooterCTF 2019 ReallySillyAlgorithmLIBrary

#rooterctf2019 #!/usr/bin/env python3 from Crypto.Util.number import * import gmpy2, binascii from sillyLibrary import rsalib_p, rsalib_q from secret import flag n = rsalib_p*rsalib_q e = 0x10001 ciphertext = binascii.hexlify(long_to_bytes…

Ricerca CTF 2023 | Rotating Letters

#ricerca_ctf_2023 #RSA #Suspicious_Prime #素因数分解 https://furutsuki.hatenablog.com/entry/2023/04/23/143704#Rotated-Secret-Analysis