Skip to content

Instantly share code, notes, and snippets.

@mpetroff
Created August 28, 2016 17:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mpetroff/8b33bc7d2a8a312c6b8e9fec94aa6568 to your computer and use it in GitHub Desktop.
Save mpetroff/8b33bc7d2a8a312c6b8e9fec94aa6568 to your computer and use it in GitHub Desktop.
Ricoh Theta desktop application configuration file decoder
#!/usr/bin/env python
'''
Decodes encrypted configuration file for Ricoh Theta desktop application.
I'm not sure what the point of double AES encryption is when the key is
embedded right in the executable.
Requires pycryto
Matthew Petroff <https://mpetroff.net/>, 2016
'''
import base64
import string
from Crypto.Cipher import AES
with open('CommonConfig.dat') as f:
to_decode = f.read()
to_decode = base64.b64decode(to_decode)
cipher0 = [201, 45, 6, 30, 24, 70, 78, 155, 134, 116, 25, 23, 119, 211, 42, 47,
207, 9, 7, 54, 210, 41, 77, 143, 161, 48, 119, 190, 117, 217, 28, 234]
cipher_str0 = string.join([chr(c) for c in cipher0], '')
iv_str0 = string.join([chr(i) for i in range(16)], '')
obj0 = AES.new(key=cipher_str0, mode=AES.MODE_CBC, IV=iv_str0)
decrypted0 = obj0.decrypt(to_decode)
cipher_str1 = decrypted0[:32]
obj1 = AES.new(key=cipher_str1, mode=AES.MODE_CBC, IV=iv_str0)
decrypted1 = obj1.decrypt(decrypted0[32:])
with open('decoded_config.xml', 'w') as f:
f.write(decrypted1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment