COVIL HACKER

, ! .


» COVIL HACKER » C/C++/C#/.NET/Java » [C#] Básico .exe e .bat AES crypter


[C#] Básico .exe e .bat AES crypter

1 2 2

1

Como dito no título:

usando System.IO;
usando System.Security.Cryptography;

class Program
{
static void Main()
{
string inputFile = "seu_arquivo.exe"; // substitua pelo nome do arquivo/caminho
string outputFile = "encrypted_file.exe"; // define o nome do arquivo criptografado

// cria uma chave AES aleatória (para criptografia simétrica)
byte[] key = new byte[32];
usando (RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider())
{
rng.GetBytes(key);
}

// lê o arquivo de entrada
byte[] bytesToEncrypt = File.ReadAllBytes(inputFile);

// criptografa os bytes do arquivo de entrada com AES
byte[]cryptBytes = null;
usando (Aes aesAlg = Aes.Create())
{
aesAlg.Key = chave;
aesAlg.GenerateIV();
Encriptador ICryptoTransform = aesAlg.CreateEncryptor(aesAlg.Key, aesAlg.IV);
using (MemoryStream msEncrypt = new MemoryStream())
{
using (CryptoStream csEncrypt = new CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write))
{
csEncrypt.Write(bytesToEncrypt, 0, bytesToEncrypt.Length);
csEncrypt.FlushFinalBlock();
criptografadoBytes = msEncrypt.ToArray();
}
}
}

// grava os bytes criptografados em um arquivo
File.WriteAllBytes(outputFile,cryptedBytes);
}
}

0

2


» COVIL HACKER » C/C++/C#/.NET/Java » [C#] Básico .exe e .bat AES crypter


|