首页
论坛
专栏
课程

[原创] 2019看雪CTFQ2第四题WP

2019-6-13 16:11 156

[原创] 2019看雪CTFQ2第四题WP

2019-6-13 16:11
156

一开始以为是z3可解,就直接上z3,后来上angr,浪费很多时间,仔细看了一下源码发现是大整数乘积,a*a-7*b*b=8,再加上其他限制可解Pell's equation.

import gmpy

for i in range(1<<30):
    t = 7 * i * i + 8
    if gmpy.is_square(t):
        print('find %d' % (i))

def pp(x, y):
    x = hex(x).replace('0x', '')
    y = hex(y).replace('0x', '')
    print(len(x), x)
    print(len(y), y)
    print()

x1, y1 = 8, 3
x, y = 127, 48
for i in range(3, 0x15):
    pp(6*x - 14*y, 6*y - 2*x)
    pp(6*x + 14*y, 6*y + 2*x)
    x, y = x1*x + 7*y1*y, x1*y + y1*x
    print(x,y)

x = '\x02\x05\x09\x88\xb2\xbd\x38\xde\x05\x57\xf3\xb3\xb9\xe1\xa5\x5a'[::-1]
a = '\x16\x96\x8C\xE3\x81\x98\x6E\x64\x84\x08\xDC\x81\xBE\x4D\x48\x4F'

print(''.join(chr(ord(x[i]) ^ ord(a[i])) for i in range(16)))

'''
find 2
find 34
find 542
find 8638
find 137666
find 2194018
'''


[公告]安全服务和外包项目请将项目需求发到看雪企服平台:https://qifu.kanxue.com

最后于 2019-6-27 18:49 被pinohans编辑 ,原因: markdown 转义
最新回复 (0)
游客
登录 | 注册 方可回帖
返回