huge commit

This commit is contained in:
2026-03-09 21:44:25 +01:00
parent ab2e537520
commit d1017bae51
441 changed files with 3438154 additions and 1363 deletions

View File

@@ -0,0 +1 @@
3.13

View File

@@ -0,0 +1,69 @@
from Crypto.Cipher import AES
from Crypto.Util.Padding import unpad
# Given data
p = 161435094849208186723743776068899835990543
factors = [
156186292768571019331898663060909752711843,
109417470692453243484139400223645310959791,
93089433143062722427906401287402408530212,
28547969321924826217366869381297180095037,
8782064060721059630464173504550123514711,
102955100934149078143279795799942076169546,
6414672390685577718586273505396597123970,
104333325295219441337759136041049892760564,
112152969625868065689337753377527032666195,
73628881014191725621637709513252461493920,
55767305113105638821720350052172401226595,
151443380055257227298905238183594975661210,
154754427703287717852463872100570391036124,
109309350493404368756996675514019660378226,
72830920510645561848991903607768750782945,
140601680236381413682085702731572037454013
]
h = 55699848449950859593116400319282899455819
enc_flag = bytes.fromhex("62c4cc8d98f1cfbc92d0315fc939b464614c7c96cfc956b0c8a44eeda15e4856fcf87710f97b445b4c4986794666fa391eeaf70963ea8f522c5b3866b7e153b6")
n = len(factors)
W = 2**256
# --- THE FIX: Center the search space around 0 ---
OFFSET = 128
h_centered = (h - OFFSET * sum(factors)) % p
# Build an 18x18 Matrix
M = Matrix(ZZ, n + 2, n + 2)
for i in range(n):
M[i, i] = 1
M[i, n + 1] = factors[i] * W
M[n, n + 1] = p * W
M[n + 1, n] = 1
M[n + 1, n + 1] = -h_centered * W
# Run LLL Algorithm
L = M.LLL()
found = False
for row in L:
if row[n] in [1, -1]:
y_vals = list(row[:n])
# If flipped by LLL, flip it back
if row[n] == -1:
y_vals = [-y for y in y_vals]
preimage = [y + OFFSET for y in y_vals]
if all(0 <= x < 256 for x in preimage):
key = bytes(preimage)
cipher = AES.new(key, AES.MODE_ECB)
flag = unpad(cipher.decrypt(enc_flag), 16).decode()
print(flag)
found = True
break
if not found:
print(":/")

View File

@@ -0,0 +1,23 @@
{
"p": 161435094849208186723743776068899835990543,
"factors": [
156186292768571019331898663060909752711843,
109417470692453243484139400223645310959791,
93089433143062722427906401287402408530212,
28547969321924826217366869381297180095037,
8782064060721059630464173504550123514711,
102955100934149078143279795799942076169546,
6414672390685577718586273505396597123970,
104333325295219441337759136041049892760564,
112152969625868065689337753377527032666195,
73628881014191725621637709513252461493920,
55767305113105638821720350052172401226595,
151443380055257227298905238183594975661210,
154754427703287717852463872100570391036124,
109309350493404368756996675514019660378226,
72830920510645561848991903607768750782945,
140601680236381413682085702731572037454013
],
"hash": 55699848449950859593116400319282899455819,
"enc_flag": "62c4cc8d98f1cfbc92d0315fc939b464614c7c96cfc956b0c8a44eeda15e4856fcf87710f97b445b4c4986794666fa391eeaf70963ea8f522c5b3866b7e153b6"
}

View File

@@ -0,0 +1,34 @@
#!/usr/bin/env python3
import json
import random
from Crypto.Cipher import AES
from Crypto.Util.number import getPrime
from Crypto.Util.Padding import pad
FLAG = "dach2026{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}"
pbits = 137
p = getPrime(pbits)
key_bits = 16
# Generate hash of the key
factors = [random.SystemRandom().randint(0, p-1) for _ in range(key_bits)]
preimage = [random.SystemRandom().randint(0, 0xff) for _ in range(key_bits)]
hash = sum([factors[i] * preimage[i] % p for i in range(key_bits)]) % p
# Encrypt flag
key = bytes(preimage)
cipher = AES.new(key, AES.MODE_ECB)
enc = cipher.encrypt(pad(FLAG.encode(), 16)).hex()
data = {
"p": p,
"factors": factors,
"hash": hash,
"enc_flag": enc
}
with open("data.json", "w") as f:
json.dump(data, f, indent=4)

View File

@@ -0,0 +1,7 @@
[project]
name = "punkhash"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.13"
dependencies = []

8
2026/cscg/crypto/punkhash/uv.lock generated Normal file
View File

@@ -0,0 +1,8 @@
version = 1
revision = 3
requires-python = ">=3.13"
[[package]]
name = "punkhash"
version = "0.1.0"
source = { virtual = "." }