Skip to content

Encrypted drivers #442

@nirs

Description

@nirs

The examples drivers are too easy to decompile. Change the code to support
encrypted drivers and add a tool to encrypt driver modules.

Examples for encrypting and decrypting:
https://pycryptodome.readthedocs.io/en/latest/src/examples.html

Change rose.client.main.load_driver_module() to read client data from file
and create a module without importing module from disk. This is better anyway
for plugins.

For loading module from decrypted bytes:
https://docs.python.org/3.6/library/functions.html#exec

$ cat load.py 
import sys

with open(sys.argv[1], "rb") as f:
    data = f.read()

env = {}
exec(data, env, env)

print(env["driver_name"])
print(env["drive"])


$ python load.py examples/none.py 
No Driver
<function drive at 0x7fb3ea287d90>

The example code does not support pyc files, they are not needed once we use
encrypted drivers and are also not portable between python versions so we
should stop using them.

The client needs new --key-file argument with the path to the key used to decrypt
the driver.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions