前言:

  这题跟python有关,可见看懂python代码还是很有必要得,需要有一些python基础才好

easychallenge:

 题目: 下载后来发现是一个.pyc为后缀得文件,查找资料可知,该文件为python编译后得文件,所以我们第一步应该是反编译,将其转成py文件

我们使用python得uncompyle6库来进行反编译,安装出错或者太慢试试这个,

 pip install -i https://pypi.doubanio.com/simple/ 包名

下面给出如何使用得命令

uncompyle6  -o  F:\桌面\  F:\桌面\tmp\1.pyc

然后将反编译后得py文件内容给出:

 1 # uncompyle6 version 3.7.3
2 # Python bytecode 2.7 (62211)
3 # Decompiled from: Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:43:08) [MSC v.1926 32 bit (Intel)]
4 # Embedded file name: ans.py
5 # Compiled at: 2018-08-09 11:29:44
6 import base64
7
8 def encode1(ans):
9 s = ''
10 for i in ans:
11 x = ord(i) ^ 36
12 x = x + 25
13 s += chr(x)
14
15 return s
16
17
18 def encode2(ans):
19 s = ''
20 for i in ans:
21 x = ord(i) + 36
22 x = x ^ 36
23 s += chr(x)
24
25 return s
26
27
28 def encode3(ans):
29 return base64.b32encode(ans)
30
31
32 flag = ' '
33 print 'Please Input your flag:'
34 flag = raw_input()
35 final = 'UC7KOWVXWVNKNIC2XCXKHKK2W5NLBKNOUOSK3LNNVWW3E==='
36 if encode3(encode2(encode1(flag))) == final:
37 print 'correct'
38 else:
39 print 'wrong'

可以看到通过该py文件加密后得final是 UC7KOWVXWVNKNIC2XCXKHKK2W5NLBKNOUOSK3LNNVWW3E===  ,然后我们修改一下encode3 encode2 encode1,将其改成decode1 decode2 decode3,

下面给出代码:

 1 # uncompyle6 version 3.7.3
2 # Python bytecode 2.7 (62211)
3 # Decompiled from: Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:43:08) [MSC v.1926 32 bit (Intel)]
4 # Embedded file name: ans.py
5 # Compiled at: 2018-08-09 11:29:44
6 import base64
7
8 def decode3(ans):
9 s = ''
10 for i in ans:
11 # x = ord(i) ^ 36
12 # x = x + 25
13
14 x = ord(i) -25
15 x = x ^ 36
16 s += chr(x)
17
18 return s
19
20
21 def decode2(ans):
22 s = ''
23 for i in ans:
24 # x = ord(i) + 36
25 # x = x ^ 36
26
27 x = i ^ 36
28 x = x - 36
29 s += chr(x)
30
31 return s
32
33
34 def decode1(ans):
35 return base64.b32decode(ans)
36
37
38 final = b'UC7KOWVXWVNKNIC2XCXKHKK2W5NLBKNOUOSK3LNNVWW3E==='
39 print(decode3(decode2(decode1(final))))

反向即可解码

参考链接:

https://www.runoob.com/python3/python3-func-ord.html

最新文章

  1. Android SQLITE 操作工具类
  2. C#抽象方法和虚拟方法理解
  3. js 简繁体字转换
  4. Beta版本冲刺Day6
  5. 《DSP using MATLAB》示例Example5.6
  6. 1427. SMS
  7. Slider插件(滑动条,拉链)
  8. Hadoop 的部署适用性(网上资料http://www.linuxidc.com/Linux/2013-10/92141.htm)
  9. mac 下 php 安装 中的坑
  10. Django 入门
  11. URL编码解码
  12. Lyx输入中文与代码高亮
  13. windows 2008 R2 断电重启进入修复模式
  14. Jmeter发送JDBC请求
  15. STL --> queue单向队列
  16. 2.sublime设置本地远程代码同步
  17. 关于FIFO异步复位的问题
  18. 循环输入到列表的基础方法 -----python-----
  19. #254 Find the Longest Word in a String
  20. awesomes前端资源库网站

热门文章

  1. CUDA Arch 代码
  2. HttpClient常用的一些常识
  3. 微信退款报错 400 the ssl certificatie error / no required SSL certificate was sent ; Guzzle json_encode Type is not supported;
  4. bottle库上传文件
  5. TCC事务解决方案
  6. postgresql 之修改psql log信息级别
  7. hierarchical-clustering
  8. python装饰器中高级用法(函数加参)
  9. 为什么JAVA中(byte)128结果为-128;(byte)-129结果为127
  10. QFramework UI 笔记(后续不断 直到UKitI篇结束)