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

Crypto CTF 2021 | Salt and Pepper

#cryptoctf2021 #!/usr/bin/env python3 from hashlib import md5, sha1 import sys from secret import salt, pepper from flag import flag assert len(salt) == len(pepper) == 19 assert md5(salt).hexdigest() == '5f72c4360a2287bc269e0ccba6fc24ba' a…

CPCTF 2021 | xorsa

z3

import os from Crypto.Util.number import isPrime state = int.from_bytes(os.urandom(4), "big") def xorshift(): global state y = state y = y ^ (y << 13) y = y & 0xffffffff y = y ^ (y >> 17) y = y & 0xffffffff y = y ^ (y << 5) y = y & 0xfffff…

0CTF/TCTF 2019 Quals|zer0des

#0CTF/TCTF2019 https://ctftime.org/task/7869

平方剰余

quadratic residue

任意modのLSB Leak Attack考

としておいて、 か? → ならYes で、ある について (ただし 続いて、 なので、引いて掛ければよい で かけるのも その次は なので、引いて掛ければ良い。実装的にはを持ってるはずなので引けばよくなる ……という理論に基づいて書いてみたけどうまく動かない…

一変数多項式のgcd

polynomialgcd 普通にユークリッドの互除法をすれば良い def gcd(a, b): while b != 0: a, b = b, a % b return a.monic() 高次数の多項式でも早い half-GCDもあるのでそちらもつかおう

isogeny

全射 (surjective)のうち、有限の核(kernel)を持つものを言う なんか単位元を保存するようなものという意味でも使われてそう?(つまり がisogenyであるとは、 の単位元 を移した が の単位元 に一致する separable isogeny isogeny が以下を満たす時、 …

SECCON 2020 | This is RSA

require 'openssl' def get_prime i = OpenSSL::BN.rand(512).to_s.unpack1('H*').hex OpenSSL::BN.new(i).prime? ? i : get_prime end p = get_prime q = get_prime n = p * q e = 65537 m = File.read('flag.txt').unpack1('H*').hex c = m.pow(e, n) puts…

S4CTF 2021 | Khayyam

#s4ctf_2021 #!/usr/bin/env python3 from gmpy import * from flag import FLAG l = len(FLAG) // 2 x = int(FLAG[:l].encode("utf-8").hex(), 16) y = int(FLAG[l:].encode("utf-8").hex(), 16) p = next_prime(x) q = next_prime(y) e, n = 65537, p * q …

Ricerca CTF 2023 | dice-vs-kymn

#ricerca_ctf_2023 #good_challenges_2023 #EllipticCurve #division_polynomial https://furutsuki.hatenablog.com/entry/2023/04/23/143704#dice-vs-kymn

Google CTF 2021 | tonality

#googlectf2021 // Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://w…

Fword CTF 2021 | boombastic

#fwordctf2021

Edwards Curve

EllipticCurveの一種。次の式で定義される 加算は と定義される。 Genus 0 Curve もし d = 0なら加算は (また、とするときもある。このとき このような曲線は実は円で(それはそう)、離散対数より弱い問題になる。具体的にはと定義して、 という写像が作れ…

DownUnderCTF 2021 | Substitution Cipher 1

#joseph #downunderctf2021 def encrypt(msg, f): return ''.join(chr(f.substitute(c)) for c in msg) P.<x> = PolynomialRing(ZZ) f = 13*x^2 + 3*x + 7 FLAG = open('./flag.txt', 'rb').read().strip() enc = encrypt(FLAG, f) print(enc) 単一換字暗号 P.<x> </x></x>…

DownUnderCTF 2021 | 1337cryptov2

#downunderctf2021 #joseph #good_challenges_2021 from Crypto.Util.number import getPrime, bytes_to_long flag = open('flag.txt', 'rb').read().strip() p, q = getPrime(1337), getPrime(1337) n = p*q K.<z> = NumberField((x-p)^2 + q^2) hint1 = p^2 +</z>…

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…

Chujowy CTF 2020 | middle-aged RSA

RSA from hashlib import sha256 from flag import flag def encrypt_chunk(N, e, chunk): x = int.from_bytes(chunk, 'big') y = randint(0, 256^len(chunk)) return Zmod(N)(x*y)^e p, q = [random_prime(2^1024) for _ in range(2)] N = p * q e = 0x1000…

CYBER APOCALYPSE CTF 2021 | RSA JAM

#cyber_apocalypse_ctf_2021 from Crypto.Util.number import getPrime, inverse import random def main(): print("They want my private key, but it has sentimental value to me. Please help me and send them something different.") p = getPrime(512…

BSides Noida CTF | baby crypto

#bsidesnoidactf from functools import reduce from operator import mul from secrets import token_bytes from sys import exit from Crypto.Util.number import bytes_to_long, getPrime, long_to_bytes def main(): a = getPrime(512) b = reduce(mul, …

BITSCTF 2019/What again??

#BITSCTF2019 #BASE91 Mike - "Ea_:fv3j9V~(@@Sb|nR>WkM#In/5E)mr}UK{&.YiTo!v6P" Harvey - Now that's what I'm talking about... なんだろう。ぱっtみて思いつくのは - 何かのエンコーディング - xorされている(全部表示可能文字なのでその可能性はうす…

1337UP CTF 2022 | Equality

#1337UP_CTF_2022 {’n’ = ‘0xa6241c28743fbbe4f2f67cee7121497f622fd81947af30f327fb028445b39c2d517ba7fdcb5f6ac9e6217205f8ec9576bdec7a0faef221c29291c784eed393cd95eb0d358d2a1a35dbff05d6fa0cc597f672dcfbeecbb14bd1462cb6ba4f465f30f22e595c36e6282c3e…

0CTF/TCTF Quals 2021 | CheckIn

#0CTF_Quals_2021 Show me your computation: 2210981206 mod 1361765897256292765020124434114243132147253633094928670919039182311664291381585249352388272687354503871496476584836120486179012464470066110560739431106648328245087618470415480047719…

Insomni'hack teaser 2020 | out of the sbox

#done #wakaran #des https://github.com/Cryptanalyse/writeups/tree/master/2020-insomnihack-teaser/crypto-OutOfTheSbox http://blog.tihmstar.net/2020/01/writeup-out-of-sbox-insomnihack-teaser.html 50000個の plaintext - ciphertext pairが与えら…

Zh3r0 CTF V2 | b00tleg

#zh3ro_CTF_2021 まあこれはやらなくていい from ptrlib import Socket, xor, chunks sock = Socket("nc crypto.zh3r0.cf 1111") sock.sendlineafter(">>> ", "2") sock.sendlineafter("hex:", b'hello world! Lets get going'.hex()) sock.sendlineafter(">…

Hensel's Lift

定理 を整数係数多項式とする。 である正整数 に対して、 であるとき、 かつ である を求めることができる(ただし )。 これはを法での根に「押し上げて」いる は定理を繰り返し用いることで実質無視できる。 例 とする。このときかつ、である。このとき、…

Sekai CTF 2022 | diffecient

#Sekai_CTF_2022 import math import random import re import mmh3 def randbytes(n): return bytes ([random.randint(0,255) for i in range(n)]) class BloomFilter: def __init__(self, m, k, hash_func=mmh3.hash): self.__m = m self.__k = k self.__i…

線形合同法

lcg

#LCG

Cyber Apocalypse 2021 | Wii Phit

#cyber_apocalypse_ctf_2021 from Crypto.Util.number import bytes_to_long from secrets import FLAG,p,q N = p**3 * q e = 0x10001 c = pow(bytes_to_long(FLAG),e,N) print(f'Flag: {hex(c)}') # Hint w = 25965460884749769384351428855708318685345170…

UMASS CTF 2022 | FastCrypto

#UMASS_CTF_2022 #!/usr/bin/env python3 # # Polymero # # Imports import os # Local imports with open("flag.txt",'rb') as f: FLAG = f.read() f.close() HDR = r"""| | __________ ______________ _____ | ___ ____/_____ _________ /__ ____/________…

TokyoWesterns CTF 6th 2020 | easy hash

warmup問というだけあって簡単そう import struct import os MSG = b'twctf: please give me the flag of 2020' assert os.environ['FLAG'] def easy_hash(x): m = 0 for i in range(len(x) - 3): m += struct.unpack('