其他分享
首页 > 其他分享> > BUUCTF-RE-pyre

BUUCTF-RE-pyre

作者:互联网

初步探索

.pyc文件 通过在线 反编译后

print 'Welcome to Re World!'
print 'Your input1 is your flag~'
l = len(input1)
for i in range(l):
    num = ((input1[i] + i) % 128 + 128) % 128
    code += num

for i in range(l - 1):
    code[i] = code[i] ^ code[i + 1]

print code
code = [
    '\x1f',
    '\x12',
    '\x1d',
    '(',
    '0',
    '4',
    '\x01',
    '\x06',
    '\x14',
    '4',
    ',',
    '\x1b',
    'U',
    '?',
    'o',
    '6',
    '*',
    ':',
    '\x01',
    'D',
    ';',
    '%',
    '\x13']

解题

①*关于%有注意的点 (;´д`)ゞ算术真头大啊
( a + b ) % c=(a%c+b%c)%c,所以第5行等价于(input1[i]+i)%128。
((input1[i] + i) % 128 + 128) % 128
=((input1[i]+i)%128%128 + 128%128)%128
=(input1[i]+i)%128

l=len(code)=23
然后我们异或的范围是rang(l-1)
code[i]=code[i]^code[i+1],
i应该是从0取到l-1-1。处理后,code[22]没有变
也就是说code[21]=code[21]^code[22] 这个异或做到21已经是最大的值了 在l-1的范围内
code[22]^=code[23]是在范围外的

脚本

code = ['\x1f', '\x12', '\x1d', '(', '0', '4', '\x01', '\x06', '\x14', '4', ',', '\x1b', 'U', '?', 'o', '6', '*', ':', '\x01', 'D', ';', '%', '\x13']
l=len(code)
print('Welcome to Reverse!')
for x in range(l-2,-1,-1):
     code[x]=chr(ord(code[x])^ord(code[x+1]))
for x in range(l):
     print(chr((ord(code[x])-x)%128),end='')

flag

GWHT{Just_Re_1s_Ha66y!}

参考:
平静的雨田
re学习笔记

标签:code,print,input1,RE,range,BUUCTF,128,pyre,x01
来源: https://www.cnblogs.com/Nickyl07/p/12828381.html