|
|
|
@ -5,6 +5,9 @@ import sys
|
|
|
|
|
import imp
|
|
|
|
|
import base64
|
|
|
|
|
from . import Crypter # Crypto functions
|
|
|
|
|
import datetime #Datetime
|
|
|
|
|
import hashlib #Get hash of the word
|
|
|
|
|
import pyautogui
|
|
|
|
|
EXT = '.cry'
|
|
|
|
|
|
|
|
|
|
# How to run
|
|
|
|
@ -87,7 +90,9 @@ class Base64Importer(object):
|
|
|
|
|
src = ''
|
|
|
|
|
|
|
|
|
|
return src
|
|
|
|
|
|
|
|
|
|
# for __main__
|
|
|
|
|
def get_code(self, inModName):
|
|
|
|
|
return self.get_source(inModName)
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
def __collect_modules_info(self, root_package_path):
|
|
|
|
|
"""Собирает информацию о модулях из указанного пакета
|
|
|
|
@ -125,14 +130,31 @@ class Base64Importer(object):
|
|
|
|
|
gInUncryptedExtension = "py" # cry for filename.cry
|
|
|
|
|
gOutCryptedExtension = "cry" # cry for filename.cry
|
|
|
|
|
gFileMaskToDelete = "pyc" #Remove all .pyc files
|
|
|
|
|
|
|
|
|
|
#Settings to run crypted module
|
|
|
|
|
gSettings = {
|
|
|
|
|
#runpy
|
|
|
|
|
"run_module": {
|
|
|
|
|
"mod_name": "TestPackage", #"TestPackage",
|
|
|
|
|
"init_globals": None,
|
|
|
|
|
"run_name": None,
|
|
|
|
|
"alter_sys": True
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Create process run
|
|
|
|
|
def Run():
|
|
|
|
|
global gSettings
|
|
|
|
|
print(f"{str(datetime.datetime.now())}: Run decryptography")
|
|
|
|
|
############# Step 5 - Ask and confirm the secret word
|
|
|
|
|
lKeyHashStr_1 = hashlib.sha256(pyautogui.password('Please enter the key to protect source code').encode("utf-8")).digest()
|
|
|
|
|
lKeyHashStr_2 = hashlib.sha256(pyautogui.password('Please repeat the key to protect source code').encode("utf-8")).digest()
|
|
|
|
|
if lKeyHashStr_1 == lKeyHashStr_2:
|
|
|
|
|
CryptographerInit("", inKey = lKeyHashStr_1)
|
|
|
|
|
sys.meta_path.append(Base64Importer("TestPackage",inKey = lKeyHashStr_1))
|
|
|
|
|
#CryptographerInit("", inKey = lKeyHashStr_1)
|
|
|
|
|
#Init the functions
|
|
|
|
|
import runpy
|
|
|
|
|
runpy.run_module(**gSettings["run_module"])
|
|
|
|
|
else:
|
|
|
|
|
raise Exception("User set different secret key 1 and key 2")
|
|
|
|
|
############ Step 6 - Final stage
|
|
|
|
|