fork download
  1. class XORCryptor:
  2. def __init__(self, key):
  3. self.key = key
  4.  
  5. def decrypt(self, encrypted_buffer):
  6. return [byte ^ ord(self.key[i % len(self.key)]) for i, byte in enumerate(encrypted_buffer)]
  7.  
  8. def decrypt(encrypted_buffer, borrowed_string):
  9. # Key for decryption
  10. key = "CSUCKS"
  11.  
  12. # Editing our borrowed value
  13. borrowed_string += "PARTY FOUL! Here is your flag: "
  14.  
  15. # Create decryption object
  16. xor_cryptor = XORCryptor(key)
  17.  
  18. # Decrypt the encrypted buffer
  19. decrypted_buffer = xor_cryptor.decrypt(encrypted_buffer)
  20.  
  21. # Print the raw decrypted bytes for inspection
  22. print("Decrypted bytes:", decrypted_buffer)
  23.  
  24. # Convert the decrypted buffer to a string (handling possible invalid UTF-8)
  25. decrypted_str = ''.join(chr(byte) for byte in decrypted_buffer if 32 <= byte <= 126)
  26.  
  27. # Append the decrypted string to the borrowed string
  28. borrowed_string += decrypted_str
  29.  
  30. # Print the final message
  31. print(borrowed_string)
  32.  
  33. def main():
  34. # Encrypted flag values (in hexadecimal)
  35. hex_values = [
  36. "41", "30", "20", "63", "4a", "45", "54", "76", "12", "90", "7e", "53", "63", "e1",
  37. "01", "35", "7e", "59", "60", "f6", "03", "86", "7f", "56", "41", "29", "30", "6f", "08",
  38. "c3", "61", "f9", "35"
  39. ]
  40.  
Success #stdin #stdout 0.1s 14068KB
stdin
Standard input is empty
stdout
Standard output is empty