CTF CRYPTO 密码学-3

题目名称:反编译

题目描述:

在这里插入图片描述

分析

题目给出一个pyc后缀的文件,需要使用uncompyle6模块去还原成py文件

uncompyle6简介

uncompyle6 是一个 Python 反编译器,它能够将 Python 字节码(.pyc 文件)转换回源代码(.py 文件)。

解题过程:

Step1:下载uncompyle6包

pip install uncompyle6

注意 版本问题

uncompyle6默认只支持3.8及以下版本
如何修改?(我这里是python3.11.3)
在这里插入图片描述

Python311\Lib\site-packages\uncompyle6\bin\uncompile.py

在这里插入图片描述

修改位置:Python311\Lib\site-packages\xdis\magics.py

在这里插入图片描述

Step2:在uncompyle6.exe目录下运行反编译命令

在这里插入图片描述

Step3:编写逆算法

生成的py文件内容如下:

# uncompyle6 version 3.7.4
# Python bytecode 2.7 (62211)
# Decompiled from: Python 3.11.3 (tags/v3.11.3:f3909b8, Apr  4 2023, 23:49:59) [MSC v.1934 64 bit (AMD64)]
# Embedded file name: b'C:\\Users\\CD\\Desktop\\\xb7\xb4\xb1\xe0\xd2\xeb\\crypto11.py'
# Compiled at: 2019-11-24 10:36:35
import base64

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

    return s


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

    return s


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


flag = ' '
print 'Please Input your flag:'
flag = raw_input()
final = 'E9F3E8EA9EECE859E5555BA0A05F555A555CEBE955EC59E5EC5AECE858E9ECE555EB5FE6E8E4'
if encode3(encode2(encode1(flag))) == final:
    print 'correct'
else:
    print 'wrong'

逆运算脚本如下:

import base64
def decode2(ans):
    s = ''
    for i in ans:
        j=ord(i)
        x=j ^ 32
        x-=66
        s += chr(x)

    return s


def decode1(ans):
    s = ''
    for i in ans:
        j=ord(i)
        x=j-19
        x=x^18
        s += chr(x)

    return s

final = 'E9F3E8EA9EECE859E5555BA0A05F555A555CEBE955EC59E5EC5AECE858E9ECE555EB5FE6E8E4'
s = base64.b16decode(final)

s = decode1(decode2(s))

print s

相关资源:

链接:https://pan.baidu.com/s/13S5xdwEvsb1H0nLTlyzMAA
提取码:25fq

  • 8
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Brucye

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值