Skip to content

Instantly share code, notes, and snippets.

@elliptic-shiho
Created December 30, 2023 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elliptic-shiho/aeeca4d8c179d204a6dfbfca55647244 to your computer and use it in GitHub Desktop.
Save elliptic-shiho/aeeca4d8c179d204a6dfbfca55647244 to your computer and use it in GitHub Desktop.
ASIS CTF Finals 2023: Tapernous
import sys
m = 12
t = 171
_z12, _x = var("_z12, _x")
dataset = open('output.txt').read().strip().replace('^', '**').split('\n')
F.<z12> = GF(2^m)
R.<x> = F['x']
f = eval(dataset[0].lstrip('f = '))
if f.is_irreducible():
S.<x> = R.quotient(f)
c = eval(dataset[1].lstrip('c = '))
SQRT = pow(2, m * t - 1, 2^(m*t) - 1)
enc = c
for _r in range(0, 200):
enc = enc^SQRT
res = []
a = list(enc)
for i in range(t):
res.append(int(''.join(map(str, list(a[i]))), 2))
print(_r, res)
if all(t < 256 for t in res):
res_bytes = bytes(res)
print(res_bytes)
if b"ASIS{" in res_bytes:
sys.exit(0)
"""
0 [766, 1214, 2720, 1852, 2172, 4079, 336, 3538, 949, 1772, 3130, 3960, 469, 113, 848, 2432, 1663, 787, 3898, 968, 175, 3418, 3179, 1249, 3682, 2547, 3087, 2198, 3616, 391, 3343, 3819, 1549, 3872, 2962, 2030, 2126, 3974, 1538, 2507, 1638, 2876, 601, 530, 1375, 222, 3423, 3727, 2247, 3345, 2757, 1136, 995, 1489, 3462, 870, 399, 3720, 106, 1644, 1133, 998, 3236, 2579, 797, 2613, 3070, 980, 3648, 2370, 2468, 1082, 1092, 2745, 530, 2889, 2188, 2968, 385, 1401, 2760, 276, 1310, 200, 2839, 1953, 1289, 514, 1195, 569, 3481, 1876, 3454, 419, 2242, 2170, 71, 3588, 721, 1273, 492, 1557, 3832, 11, 230, 61, 2261, 1653, 350, 1734, 3608, 574, 1485, 1686, 790, 325, 3002, 1887, 1910, 3393, 2772, 1880, 3093, 3244, 2965, 1000, 139, 1857, 2714, 1828, 2083, 3792, 3386, 3106, 1928, 3186, 861, 4047, 3292, 3447, 2581, 1367, 3291, 3511, 223, 596, 2648, 2657, 1430, 3747, 1455, 2897, 829, 858, 3309, 1509, 3258, 2280, 3428, 1102, 1148, 3040, 3067, 261, 3913, 2530, 504, 3852, 2373, 1259, 2274]
1 [2064, 1524, 2681, 2853, 3104, 3946, 1443, 976, 2546, 1910, 3948, 900, 3390, 892, 1027, 1177, 3513, 3657, 660, 3741, 688, 3179, 1847, 3618, 1738, 3064, 2671, 3201, 1157, 2089, 1596, 2814, 2412, 2169, 4042, 223, 1253, 2008, 1035, 2857, 2404, 1968, 3943, 3402, 2961, 3623, 690, 1158, 3359, 2741, 538, 1254, 401, 1317, 2455, 689, 385, 1070, 1242, 2822, 4065, 1117, 2596, 3544, 896, 1232, 2920, 3055, 267, 3285, 1693, 3876, 1735, 1082, 1058, 3404, 3184, 3358, 4023, 1167, 1399, 748, 377, 310, 3097, 3540, 3416, 2627, 1187, 2629, 1566, 3464, 3789, 2049, 2184, 3853, 2954, 1774, 978, 3817, 4058, 2867, 774, 1597, 2351, 1216, 3706, 3319, 1103, 998, 3903, 1988, 2854, 3594, 1367, 1829, 1059, 3232, 1540, 2317, 2357, 2531, 1512, 2138, 449, 1462, 919, 3946, 2163, 2623, 2943, 1900, 2797, 2040, 2640, 2410, 159, 3084, 3797, 665, 2694, 1987, 177, 1725, 2790, 2262, 127, 3299, 2842, 2122, 3669, 2628, 669, 603, 710, 3544, 3841, 3284, 3773, 1140, 1801, 1816, 575, 3926, 3240, 1226, 1576, 4033, 3487, 880, 1673]
(snip)
38 [46, 58, 32, 71, 111, 111, 100, 32, 106, 48, 98, 32, 97, 110, 100, 32, 67, 111, 110, 103, 114, 97, 116, 122, 32, 58, 41, 32, 65, 83, 73, 83, 123, 85, 53, 49, 110, 57, 95, 80, 52, 116, 116, 101, 114, 115, 48, 110, 115, 95, 97, 76, 103, 48, 114, 49, 116, 72, 109, 95, 116, 48, 95, 112, 101, 82, 102, 79, 114, 109, 95, 69, 102, 102, 49, 99, 33, 51, 110, 55, 95, 100, 51, 99, 48, 100, 49, 110, 71, 33, 125, 32, 58, 46, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
b'.: Good j0b and Congratz :) ASIS{U51n9_P4tters0ns_aLg0r1tHm_t0_peRfOrm_Eff1c!3n7_d3c0d1nG!} :.\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment