NJUPT_CTF easychallenge 解题脚本

论坛 期权论坛 编程之家     
选择匿名的用户   2021-5-30 21:45   11   0

直接在线Python反编译,得到源代码

import base64


def encode1(ans):
    s = ''
    for i in ans:
        x = ord(i) ^ 36
        x = x + 25
        s += chr(x)

    return s


def encode2(ans):
    s = ''
    for i in ans:
        x = ord(i) + 36
        x = x ^ 36
        s += chr(x)

    return s


def encode3(ans):
    return base64.b32encode(ans)


flag = ' '
print('Please Input your flag:')
flag = input()
final = 'UC7KOWVXWVNKNIC2XCXKHKK2W5NLBKNOUOSK3LNNVWW3E==='
if encode3(encode2(encode1(flag))) == final:
    print('correct')

然后根据脚本,写出对应的decode脚本,这里需要注意,在使用base32解码之后,会出现编码问题,使用合适的编码即可

# -*- coding: UTF-8 -*-  
# --author:valecalida--
# 2021/2/2 15:31
from base64 import b32decode


def decode1(ans):
    s = ''
    for i in ans:
        s += chr((ord(i) - 25) ^ 36)
    return s


def decode2(ans):
    s = ''
    for i in ans:
        s += chr((ord(i) ^ 36) - 36)
    return s


def main():
    final = 'UC7KOWVXWVNKNIC2XCXKHKK2W5NLBKNOUOSK3LNNVWW3E==='
    flag = decode1(decode2(str(b32decode(final), encoding="ISO-8859-1")))
    print(flag)
    # ("\xa0\xbe\xa7Z\xb7\xb5Z\xa6\xa0Z\xb8\xae\xa3\xa9Z\xb7Z\xb0\xa9\xae\xa3\xa4\xad\xad\xad\xad\xad\xb2")


if __name__ == '__main__':
    main()

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP