测试文件:https://adworld.xctf.org.cn/media/task/attachments/69c8f29912ae4f679d92a6cd36c33196.pyc

这里需要用到一个pyc文件反编译的工具,可以使用在线https://tool.lu/pyc/,也可以使用命令下载

pip install uncompyle

1.准备

pyc文件就是 py程序编译后得到的字节码文件 (py->pyc)

2.pyc文件逆向

在命令窗口执行

uncompyle6 test.pyc > test.py

打开得到的test.py

# uncompyle6 version 3.4.0
# Python bytecode 2.7 (62211)
# Decompiled from: Python 2.7.16 (default, Apr 6 2019, 01:42:57)
# [GCC 8.3.0]
# Embedded file name: 1.py
# Compiled at: 2017-06-03 10:20:43
import base64 def encode(message):
s = ''
for i in message:
x = ord(i) ^ 32
x = x + 16
s += chr(x) return base64.b64encode(s) correct = 'XlNkVmtUI1MgXWBZXCFeKY+AaXNt'
flag = ''
print 'Input flag:'
flag = raw_input()
if encode(flag) == correct:
print 'correct'
else:
print 'wrong'
# okay decompiling test.pyc

2.1 代码分析

通过查看这段Python2代码,我们知道flag进行encode函数中的操作,得到‘XlNkVmtUI1MgXWBZXCFeKY+AaXNt’。

因此,我们只要反过来执行,就能够得到flag,写出代码

import base64

def decode(message):
s = ''
imessage = base64.b64decode(message) for i in imessage:
x = ord(i) - 16
x = x ^ 32
s += chr(x) return s correct = 'XlNkVmtUI1MgXWBZXCFeKY+AaXNt' flag = decode(correct)
print(flag)

3.get flag!

nctf{d3c0mpil1n9_PyC}

最新文章

  1. #define DELAY_ONE_MICROSECOND (-10) 时间是负数的原因
  2. UItableVIew初探
  3. 即时通信系统中如何实现:全局系统通知,并与Web后台集成?【低调赠送:QQ高仿版GGTalk 5.1 最新源码】
  4. linux系统命令:yum和apt-get
  5. How to increase TX Power Signal Strength of WiFi
  6. 《android 导入第三方源码jar包遇到的坑》
  7. .pch头文件的添加
  8. HTTP Status 500 - An exception occurred processing at line 35
  9. java intellij 写控制台程序 窗口程序
  10. ORACLE 11G用于有效期
  11. IDF实验室-简单编程-特殊的日子 writeup
  12. leetcode Contains Duplicate II python
  13. 枚举算法总结 coming~^.*
  14. &&运算符,三木运算符与React的条件渲染
  15. 一起来学Go --- (go的简介以及环境的安装)
  16. 《java入门第一季》之面向对象(重头戏继承来了)
  17. Linux 桌面玩家指南:15. 深度学习可以这样玩
  18. Python——字符串、文件操作,英文词频统计预处理
  19. ceil()函数的应用-hdu1065
  20. 第二次项目冲刺(Beta版本)

热门文章

  1. html中的块级元素和行内元素
  2. 【改】DOS文件格式转UNIX文件格式
  3. poj 2187 Beauty Contest(平面最远点)
  4. python tkinter画圆
  5. selenium 自动化的坑(3)
  6. 洛谷 P4827 [国家集训队] Crash 的文明世界
  7. 英语单词character
  8. 如何添加筛选器 (Reporting Services)
  9. Elven Postman
  10. Android7.1后对于Toast类型窗口的限制