CTF
  • Introduction
  • IDF 实验室
    • 牛刀小试
      • 被改错的密码
      • ASCII 码而已
      • 聪明的小羊
      • 摩斯密码
      • 啥?
    • CRYPTO 百密一疏
      • 笨笨的小猪
      • 凯撒加密
      • 孔子的学费
      • 特殊的日子
      • 伟人的名字
    • WEB天罗地网
      • COOKIE欺骗
      • 不难不易的js加密
      • 超简单的js题
      • 古老的邮件编码
      • 简单的js解密
      • 你关注最新的漏洞吗
      • 一种编码而已
    • STEGA万里寻踪
      • 图片里的秘密
      • 上帝也哭泣
      • 红与黑
    • PPC初探乾坤
      • 简单编程-字符统计
      • Fuck your brain
      • 谁是卧底
    • REVERSE倒行逆施
      • 简单的PE文件逆向
      • 简单的ELF逆向
      • python ByteCode
    • MISC包罗万象
      • 图片里的英语
      • 抓到一只苍蝇
  • 实验吧
    • WEB
      • 登陆一下好吗??
      • 注入
      • 简单的sql注入
      • Forms
Powered by GitBook
On this page
  • 题目
  • write up

Was this helpful?

  1. IDF 实验室
  2. REVERSE倒行逆施

python ByteCode

Previous简单的ELF逆向NextMISC包罗万象

Last updated 5 years ago

Was this helpful?

题目

请看这里:

write up

使用python反编译工具,比如

得到代码实现:

def encrypt(key, seed, string):
    rst = []
    for v in string:
        rst.append((ord(v) + seed ^ ord(key[seed])) % 255)
        seed = (seed + 1) % len(key)

    return rst

if __name__ == '__main__':
    print("Welcome to idf's python crackme")
    flag = input('Enter the Flag: ')
    KEY1 = 'Maybe you are good at decryptint Byte Code, have a try!'
    KEY2 = [
        124,
        48,
        52,
        59,
        164,
        50,
        37,
        62,
        67,
        52,
        48,
        6,
        1,
        122,
        3,
        22,
        72,
        1,
        1,
        14,
        46,
        27,
        232]
    en_out = encrypt(KEY1, 5, flag)
    if KEY2 == en_out:
        print('You Win')
    else:
        print('Try Again !')

逆向:

def decrypt_each(key, seed, KEY2):
    answer = ""
    for each in KEY2:
        password = each
        for i in range(128):
            result = (i + seed ^ ord(key[seed])) % 255
            if password == result:
                answer += chr(i)
                break
        seed = (seed + 1) % len(key)

    return answer

if __name__ == '__main__':
    KEY1 = 'Maybe you are good at decryptint Byte Code, have a try!'
    KEY2 = [
    124,
    48,
    52,
    59,
    164,
    50,
    37,
    62,
    67,
    52,
    48,
    6,
    1,
    122,
    3,
    22,
    72,
    1,
    1,
    14,
    46,
    27,
    232]
    answer = decrypt_each(KEY1, 5, KEY2)
    print(answer)
http://pan.baidu.com/s/1jGpB8DS
http://tool.lu/pyc/