题目要点 伪随机数生成器算法

伪随机数生成器 英文叫 PRNG 是一种用确定性算法生成“看起来随机”的数字序列的东西

题目是一个elf文件 无壳ida打开 第一遍没看出来什么 运行一下 发现中间小猫是循环动 而上方的字体不是 所以我们去找上方的字体的显示地方

image

通过函数调用约定和代码审计来定位到加密函数的位置 高端用词 哈哈哈哈

image

加密位置做了一个异或  伪随机数的生成的操作 还有对于dword_E1E8的增加 遂我们知道了 这个题目需要的是爆破而不是解密 爆破推荐使用c语言来写 而不是python python运行慢

image

image

image

exp

从网上扒下来的 哈哈哈 爆破要很久很久 他这个得1亿多次

dword_E1E8 = 0x1106
dword_E120 = [
    0x27fb, 0x27a4, 0x464e, 0x0e36, 0x7b70, 0x5e7a, 0x1a4a, 0x45c1,
    0x2bdf, 0x23bd, 0x3a15, 0x5b83, 0x1e15, 0x5367, 0x50b8, 0x20ca,
    0x41f5, 0x57d1, 0x7750, 0x2adf, 0x11f8, 0x09bb, 0x5724, 0x7374,
    0x3ce6, 0x646e, 0x010c, 0x6e10, 0x64f4, 0x3263, 0x3137, 0x00b8,
    0x229c, 0x7bcd, 0x73bd, 0x480c, 0x14db, 0x68b9, 0x5c8a, 0x1b61,
    0x6c59, 0x5707, 0x09e6, 0x1fb9, 0x2ad3, 0x76d4, 0x3113, 0x7c7e,
    0x11e0, 0x6c70
]
 
 
def sub_62B5():
    global dword_E1E8
    dword_E1E8 = (1103515245 * dword_E1E8 + 12345) & 0xFFFFFFFF
    return (dword_E1E8 >> 10) & 0x7FFF
 
 
def llog(n):
    a = 0
    while n >= 10:
        n //= 10
        a += 1
    return a
 
 
def sub_62E3(a1):
    return 0x7E >= (a1 & 0x7F) > 0x20
 
 
count = 0
while True:
    for i in range(50):
        dword_E120[i] ^= sub_62B5()
 
    count += 1
    dword_E1E8 += 42 + llog(count)
 
    if count % 1000000 == 0:
        print(f"Count: {count}")
 
    flag = bytearray(51)
    for i in range(50):
        if not sub_62E3(dword_E120[i]):
            break
        flag[i] = dword_E120[i] & 0xFF
    else:
        continue
 
    if flag[:6] == b'CatCTF':
        print(flag.decode())
        print(f"Count: {count}")
        break

flag

CatCTF{Fly1NG_NyAnC4t_Cha5eS_the_FL4G_in_The_Sky}