fork download
  1. from base64 import b64encode as be
  2. from secret import msg, KEY
  3.  
  4. #msg and KEY are meaningful english sentences in l33t
  5. msg2 = msg.replace('_','')
  6. KEY = KEY.replace('_','')
  7.  
  8. assert (len(KEY)==7) and KEY.isalnum() and msg2.isalnum()
  9. assert 'n00bCTF' in msg2
  10.  
  11. def XOR(A, B):
  12. return ''.join(chr(ord(A[i])^ord(B[i%len(B)])) for i in range(len(A)))
  13.  
  14. def encryption(msg, key):
  15. return be(XOR(msg, KEY))
  16.  
  17. def print_flag(msg):
  18. print 'CTF{%s}' % msg
  19.  
  20. if __name__ == '__main__':
  21. print encryption(msg2, KEY) #DRcGGQBfGw1QEA4XBUURCA0MDQdGBlFTCTo7MxwJUhgAXBQa
  22. #Decrypt msg2 to get the flag
  23. print_flag(msg2)# your code goes here
Runtime error #stdin #stdout #stderr 0s 23560KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "prog.py", line 2, in <module>
ImportError: No module named secret