NewStarCTF 2023 broadcast

低加密指数广播攻击
这里更新一下以前的CRT脚本(这题好像要用十几组才行)
首先 手动nc 获取20组n,c
CRT求出m^e mod(N1N2N3...)后开e次方即可
exp:

from functools import *
def CRT(mi, ai):
    M = reduce(lambda x, y: x * y, mi)
    ai_ti_Mi = [a * (M // m) * gmpy2.invert(M // m, m) for (m, a) in zip(mi, ai)]
    return reduce(lambda x, y: x + y, ai_ti_Mi) % M
e = 17

n=[n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19]
c=[c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17,c18,c19]


m_e = CRT(n,c)
print(m_e)
m = gmpy2.iroot(m_e,e)[0]
print(m)
print(long_to_bytes(m))

最后flag:
image

posted @ 2023-10-10 11:06  N0zoM1z0  阅读(180)  评论(0编辑  收藏  举报