Title Address: http://ctf.idf.cn/index.php?g=game&m=article&a=index&id=45
Download to discover is CRACKME.PYC
You can use Uncompyle2 to decompile. You can also directly http://tool.lu/pyc/on this site to decompile.
Get the source code:
1 #!/usr/bin/env python2 #Encoding:utf-83 #If you feel good, you can recommend to your friends! HTTP://TOOL.LU/PYC4 5 defEncrypt (key, Seed, string):6RST = []7 forVinchstring:8Rst.append ((Ord (v) + Seed ^ ord (key[seed]))% 255)9Seed = (seed + 1)%Len (key)Ten One returnrst A - if __name__=='__main__': - Print "Welcome to IDF ' s Python crackme" theFlag = input ('Enter the Flag:') -KEY1 ='Maybe you is good at Decryptint Byte Code with a try!' -KEY2 = [ -124, +48, -52, +59, A164, at50, -37, -62, -67, -52, -48, in6, -1, to122, +3, -22, the72, *1, $1,Panax Notoginseng14, -46, the27, +232] AEn_out = Encrypt (KEY1, 5, Flag) the ifKEY2 = =en_out: + Print 'You Win' - Else: $ Print 'Try Again!'
Program Encryption function:
1 def Encrypt (key, Seed, string): 2 rst = []3for in string:4 rst.append (Ord (v) + Seed ^ ord (key[seed]))% 255)5 seed = (seed + 1)% Len (key)
Flag is encrypted with the same words as KEY2 output you Win
Originally wanted to reverse, but can not get, it directly burst.
A-Z-a-to-a-0-9 notation can have ASCII code traversal, and then encode the conversion back, adding arrays.
It is then encrypted, compared to the value of the key array.
The code is as follows:
#!/usr/bin/env python#Encoding:utf-8defEncrypt (key, Seed, string): forVinchstring:a= (Ord (v) + Seed ^ ord (key[seed])% 255) returnaKEY1='Maybe you is good at Decryptint Byte Code with 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]s=[]seed=5; key='Maybe you is good at Decryptint Byte Code with a try!' forIinchRange (33,127): J=chr (i) s.append (j) forIinchRange (23): forJinchS:aa=Encrypt (key,seed,j)ifAA = =Key2[i]:PrintJ Seed= (seed + 1)% Len (key)
It is important to note that seed changes after the flag is compared to KEY2.
IDF Laboratory-python bytecode writeup