Skip to content

[Feature request] option to encrypt without obfuscation #1

@LaurentEsingle

Description

@LaurentEsingle

Hi,

First of all thank you for your great work and your decision to publish that work so that the community can benefit from it.

I think it would be beneficial to have an option to not obfuscate some files similar to what we have with encryption exclusions.

codeclose \
    --encryption-excluded [...] 
    --obfuscation-excluded [...]

Here's why.
In my particular scenario, I have a lot of modules/classes that use many third parties modules. Which means I end up with an extremely long list of identifiers/attributes to exclude. I have tried to obfuscate my entire application without success. In my case it is a daunting task.

Even if I succeeded, it would be difficult to maintain such a list with an application that gets updated constantly.

In contrast, encryption only requires a small effort to implement, and is not dependent on code change. And the performance is also great.

As a workaround, I changed the code to only obfuscate the application entry point (main.py) and encrypt the remaining files.

In model.py:

with open(srcFilePath, 'r', encoding='utf-8') as handler:
    content = handler.read()
    content = _remapModules(content, codecloseModuleName)
    if srcFilePath == "./main.py":
      print("obfuscating file: " + str(srcFilePath))
      content = obfuscator.obfuscate(content)

But I am facing two caveats with that workaround:

  • I have to put all my files in the same directory as main.py (which means I end up mostly with one directory with dozens of files)
  • There is one file that I cannot obfuscate/encrypt, which handles the security of my application and uses similar libraries as codeclose (base64 and cryptography 3.0). It also uses "decrypt" keyword in its code.
    This is the only notable difference I can see that sets it apart from other files.

Here are the details of the error:

~/.local/lib/python3.8/site-packages/vquery/GLOBAL/_Warning_ReferenceError/runtime.py in map_ord(divmod_help, compile_bytes, breakpoint_PendingDeprecationWarning)
     23   return ''
     24  IndexError_FloatingPointError = nonlocal_SystemExit.new(license[(3097986357711097591446599161849 + int(4938221631556028608960218434944)).to_bytes(13, 'big').decode()], nonlocal_SystemExit.MODE_CBC, iv=exit_quit(compile_bytes))
---> 25  object_BytesWarning = IndexError_FloatingPointError.oct_UnicodeEncodeError(exit_quit(divmod_help))
     26  return object_BytesWarning[:breakpoint_PendingDeprecationWarning].decode((148091511572 + int(356372515364)).to_bytes(5, 'big').decode())
     27 def license_zip(type_ChildProcessError=True):

AttributeError: 'CbcMode' object has no attribute 'oct_UnicodeEncodeError'

I think the error happens here (in runtime.py)

def expose(encryptedContent, initializationVector, originalSize):
    try:
        license = getLicense()
    except:
        return ''
    
    cipher = AES.new(license['encryptingKey'], AES.MODE_CBC, iv=b64decode(initializationVector))
    contentBytes = cipher.decrypt(b64decode(encryptedContent))
    return contentBytes[:originalSize].decode('utf-8')

I am not sure how to fix such an error but again thank you for letting us use your code.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions