BUUCTF第16题[GWCTF 2019]pyre1

发现是pyc文件,那我们首先要反编译一下,这里我用的这个网站python反编译 - 在线工具 (tool.lu)

把编译后的结果放到我们的vscode里

#!/usr/bin/env python
# visit https://tool.lu/pyc/ for more information
# Version: Python 2.7

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 = [
    '%1f',
    '%12',
    '%1d',
    '(',
    '0',
    '4',
    '%01',
    '%06',
    '%14',
    '4',
    ',',
    '%1b',
    'U',
    '?',
    'o',
    '6',
    '*',
    ':',
    '%01',
    'D',
    ';',
    '%',
    '%13']

为方便观察,将code重新整理一下

#!/usr/bin/env python
# visit https://tool.lu/pyc/ for more information
# Version: Python 2.7

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 = ['%1f','%12','%1d','(','0','4','%01','%06','%14','4',',','%1b','U','?','o','6','*',':','%01','D',';','%','%13']

第一个for in 函数可以简化,因为后面+128再%128对结果无影响,第二个for in涉及到异或运算,一个数异或两次等于本身,且每一位与自己后一位异或的话那么数组中的最后一个数是不变的,又不难发现由于语句顺序的原因需要将两个for in的位置互换,再将code拿到最前面,更改后如下

最后得到flag为{Just_Re_1s_Ha66y!}

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值