1. 程式人生 > >python逆向Crackme.pyc題目

python逆向Crackme.pyc題目

下載得到一個crackme.pyc檔案
通過uncompyle2反編譯為crackme.py檔案

如下:

# 2017.04.01 11:41:36 Öйú±ê׼ʱ¼ä
#Embedded file name: d:/idf.py


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 !' +++ okay decompyling crackme.pyc # decompiled 1 files: 1 okay, 0 failed, 0 verify failed # 2017.04.01 11:41:37 Öйú±ê׼ʱ¼ä

編寫逆向函式:



def decrypt(key1,seed,key2):
    str = ''
    for i in key2:
        v = (i^ord(key1[seed]))-seed
        seed = (seed+1)%255
        str += chr(v)
    return str

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]
    print decrypt(KEY1,5,KEY2)

得到答案:WCTF{ILOVEPYTHONSOMUCH}