Description: The state of art on encryption, can you defeat it? CjBPewYGc2gdD3RpMRNfdDcQX3UGGmhpBxZhYhFlfQA=
We get Python script used for encrypt the flag. Output of this script is Base64 string contains encrypted flag (CjBPewYGc2gdD3RpMRNfdDcQX3UGGmhpBxZhYhFlfQA=)
importstructimportsysimportbase64iflen(sys.argv) !=2: print"Usage: %s data"%sys.argv[0] exit(0) data=sys.argv[1] padding=4-len(data) %4ifpadding!=0: data=data+"\x00"*paddingresult= [] blocks=struct.unpack("I"* (len(data) /4), data) forblockinblocks: result+= [block^block>>16] output=''forblockinresult: output+=struct.pack("I", block) printbase64.b64encode(output)
To resolve this, we have to create "decrypter".
Here's my sample solution for this, maybe not state-of-the-art, but I was able to get the flag :)
#!/usr/bin/env pythonimportstructimportsysimportbase64data=base64.b64decode(sys.argv[1]) padding=4-len(data) %4ifpadding!=0: data=data+"\x00"*paddingprintdatai=0padding=4output=''result=''whilei<len(data): junk=data[i:i+padding] printi, paddingoutput=struct.unpack("I", junk) forsinoutput: r=s^s>>16result+=struct.pack("I", r) i+=4printresult
And here's output with flag:
$ ./test.py CjBPewYGc2gdD3RpMRNfdDcQX3UGGmhpBxZhYhFlfQA= 0O{♠♠sh↔☼ti1‼_t7►_u♠→hi▬ab◄e} 0 4 4 4 8 4 12 4 16 4 20 4 24 4 28 4 32 4 EKO{unshifting_the_unshiftable}