Ingin menangid
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.0 KiB

5 years ago
  1. # Python2 ver.
  2. # If you use Python3 interpreter, the trouble will be in print format
  3. # [KSL Playground][Crypto][IDCC2018 DecryptME] written by Mr. Goodnight
  4. # Link: https://euectf.stikom-bali.ac.id/challenges#[IDCC]%20DecryptME
  5. # Flag: IDCC{S1mpl3_4nd_stR4ight}
  6. from base64 import *
  7. # Encryption algorithm
  8. # ciphertext = plaintext + keys
  9. with open('./enkripsi', mode = 'r') as f:
  10. ciphertext = f.read()
  11. # plaintext = ciphertext - keys
  12. # Make my own function to decrypt the ciphertext
  13. def decrypt(ciphertext, keys):
  14. plaintext = ""
  15. for num,char in enumerate (ciphertext):
  16. plaintext += chr((ord(char) - ord(keys[num % len(keys)])) % 127)
  17. return plaintext
  18. # keys = ciphertext - plaitext
  19. # Find the key by using known string attack
  20. # Then I found out that the key is raja
  21. known_string = b64encode("IDCC{")
  22. keys = ""
  23. for num,char in enumerate (known_string):
  24. keys += chr((ord(ciphertext[num]) - ord(char)) % 127)
  25. # Run the decrypt function the decode it
  26. keys = "raja"
  27. flag = b64decode(decrypt(ciphertext, keys))
  28. print ("Flag: {f}".format(f = flag))