【无标题】[广东省大学生攻防大赛 2022]pyre

使用pycdc工具得到源码

# Source Generated with Decompyle++
# File: 1.pyc (Python 3.7)


def check():
    a = input('plz input your flag:')
    c = [
        144,
        163,
        158,
        177,
        121,
        39,
        58,
        58,
        91,
        111,
        25,
        158,
        72,
        53,
        152,
        78,
        171,
        12,
        53,
        105,
        45,
        12,
        12,
        53,
        12,
        171,
        111,
        91,
        53,
        152,
        105,
        45,
        152,
        144,
        39,
        171,
        45,
        91,
        78,
        45,
        158,
        8]
    if len(a) != 42:
        print('wrong length')
        return 0
    b = None
    for i in range(len(a)):
        if ord(a[i]) * 33 % b != c[i]:
            print('wrong')
            return None

    print('win')

但是没有看到模数,因此查看字节码,获知模数(使用pycdas工具查看字节码)

【无标题】[广东省大学生攻防大赛 2022]pyre_第1张图片

import gmpy2
enc = [144, 163, 158, 177, 121, 39, 58, 58, 91, 111, 25, 158, 72, 53, 152, 78, 171, 12, 53, 105, 45, 12, 12, 53, 12, 171, 111, 91, 53, 152, 105, 45, 152, 144, 39, 171, 45, 91, 78, 45, 158, 8]
key = gmpy2.invert(33, 179) # 求一个模的逆元
for i in range(len(enc)):
    enc[i] = enc[i] * key % 179
print(bytes(enc))

你可能感兴趣的:(CTF_RE做题笔记,前端,javascript,数据库)