攻防世界easychallenge

### easychallenge

**将 `pyc` 文件转化成 `py` 文件**

使用 `cmd` 转移到 `pyc` 的目录

```
uncompyle6 -o rsa.py rsa.pyc
```

得到 `py` 代码

```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 = raw_input()
final = 'UC7KOWVXWVNKNIC2XCXKHKK2W5NLBKNOUOSK3LNNVWW3E==='
if encode3(encode2(encode1(flag))) == final:
print 'correct'
else:
print 'wrong'
```

对于每个 `encode` 解读转换,得到 `flag`

`base64.b32encode()` 逆向为 `base64.b32decode()`

`for A in B` 表示 `A` 依次表示 `B` 中的一个元素,遍历完所有元素循环结束。用于遍历字符串、列表,元组,字典等。

`ord()` 返回对应的 `ASCII` 数值,或者 `Unicode` 数值。逆函数为 `chr()`

```python
import base64

def decode3(ans):
return base64.b32decode(ans)

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

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


final = 'UC7KOWVXWVNKNIC2XCXKHKK2W5NLBKNOUOSK3LNNVWW3E==='
flag=decode1(decode2(decode3(final)))
print(flag)
```

`flag` 为 `cyberpeace{interestinghhhhh}`

 

posted @ 2021-01-31 21:18  Jessiejzy  阅读(164)  评论(0编辑  收藏  举报