forked from m1kemu/MiscellaneousCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComposer.cs
More file actions
49 lines (41 loc) · 1.27 KB
/
Composer.cs
File metadata and controls
49 lines (41 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Net;
using System.Security.Cryptography;
using System.IO;
public class Program
{
public static byte[] Encrypt(byte[] data, byte[] key, byte[] iv)
{
using (var aes = Aes.Create())
{
aes.KeySize = 128;
aes.BlockSize = 128;
aes.Key = key;
aes.IV = iv;
using (var encryptor = aes.CreateEncryptor(aes.Key, aes.IV))
{
using (var ms = new MemoryStream())
using (var cryptoStream = new CryptoStream(ms, encryptor, CryptoStreamMode.Write))
{
cryptoStream.Write(data, 0, data.Length);
cryptoStream.FlushFinalBlock();
return ms.ToArray();
}
}
}
}
public static void Main(String[] args)
{
byte[] input = File.ReadAllBytes("calc_x64.bin");
var key = new byte[16] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
var iv = new byte[16] { 0x00, 0xFE, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x47, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
var encrypted = Encrypt(input, key, iv);
var data_b64 = Convert.ToBase64String(encrypted);
var iv_b64 = Convert.ToBase64String(iv);
var message = data_b64 + ":" + iv_b64;
System.IO.File.WriteAllText(@"download_me_csharp.txt", message);
return;
}
}