• 攻防世界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}`

  • 相关阅读:
    ⑤SpringBoot之定时任务
    ④SpringBoot之thymeleaf使用
    ③SpringBoot中Redis的使用
    ②SpringBoot之Web综合开发
    Redis、Memcache和MongoDB
    ADB常用命令 & 无线调试Debug黑科技
    Flutter生命周期
    Flutter-Tips
    Git rebase命令
    Git 恢复本地误删的文件
  • 原文地址:https://www.cnblogs.com/Jessie-/p/14354101.html
Copyright © 2020-2023  润新知