2020-11-01 | Csharp | UNLOCK

DTCMS4.0 Crypt.cs(DumpDecryptFunction)

program.cs

Unpack Crypt.Dll
DumpDecryptFunction

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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
using System;
using System.Security.Cryptography;
using System.IO;
using System.Text;


namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
if (args.Length==1)
{
Console.WriteLine("默认盐 4B2H04");
Console.WriteLine(DESEncrypt.Encrypt(args[0]) + "4B2H04");
}
else if (args.Length < 2)
{
//Console.WriteLine("DTCMS动力启航 解密\nDTCMS_Decrypt.exe password salt");
Console.WriteLine("DTCMS动力启航 加密\nDTCMS_Encrypt.exe 明文password salt");
//Console.WriteLine(DESEncrypt.Decrypt("6F52E60F7791757F","6N0X24"));
//Console.WriteLine(DESEncrypt.Decrypt("B6E9067430813CE9", "6N0X24"));
Console.WriteLine(DESEncrypt.Encrypt("12455", "4B2H04"));
//Console.WriteLine(DESEncrypt.Encrypt("fuckyou"));
//Console.WriteLine(DESEncrypt.Encrypt("12455"));
//Console.WriteLine(DESEncrypt.Decrypt(""))
}
else
{
Console.WriteLine("加密结果:\n" + DESEncrypt.Encrypt(args[0], args[1])+args[1]);
}

}
}
public class DESEncrypt
{
// Token: 0x0600000A RID: 10 RVA: 0x000021E4 File Offset: 0x000003E4
/*public static string Decrypt(string Text)
{
return DESEncrypt.Decrypt(Text, "4B2H04");
}

// Token: 0x0600000B RID: 11 RVA: 0x000021F4 File Offset: 0x000003F4
public static string Decrypt(string Text, string sKey)
{
DESCryptoServiceProvider dESCryptoServiceProvider = new DESCryptoServiceProvider();
int num = Text.Length / 2;
byte[] array = new byte[num];
for (int i = 0; i < num; i++)
{
int num2 = Convert.ToInt32(Text.Substring(i * 2, 2), 16);
array[i] = (byte)num2;
}
dESCryptoServiceProvider.Key = Encoding.ASCII.GetBytes(HashPasswordForStoringInConfigFile(sKey, "md5").Substring(0, 8));
dESCryptoServiceProvider.IV = Encoding.ASCII.GetBytes(HashPasswordForStoringInConfigFile(sKey, "md5").Substring(0, 8));
MemoryStream memoryStream = new MemoryStream();
CryptoStream cryptoStream = new CryptoStream(memoryStream, dESCryptoServiceProvider.CreateDecryptor(), CryptoStreamMode.Write);
cryptoStream.Write(array, 0, array.Length);
cryptoStream.FlushFinalBlock();
return Encoding.Default.GetString(memoryStream.ToArray());
}*/

// Token: 0x06000008 RID: 8 RVA: 0x0000210B File Offset: 0x0000030B
public static string Encrypt(string Text)
{
return DESEncrypt.Encrypt(Text, "4B2H04");
}

// Token: 0x06000009 RID: 9 RVA: 0x00002118 File Offset: 0x00000318
public static string Encrypt(string Text, string sKey)
{
DESCryptoServiceProvider dESCryptoServiceProvider = new DESCryptoServiceProvider();
byte[] bytes = Encoding.Default.GetBytes(Text);
dESCryptoServiceProvider.Key = Encoding.ASCII.GetBytes(HashPasswordForStoringInConfigFile(sKey, "md5").Substring(0, 8));
dESCryptoServiceProvider.IV = Encoding.ASCII.GetBytes(HashPasswordForStoringInConfigFile(sKey, "md5").Substring(0, 8));
MemoryStream memoryStream = new MemoryStream();
CryptoStream cryptoStream = new CryptoStream(memoryStream, dESCryptoServiceProvider.CreateEncryptor(), CryptoStreamMode.Write);
cryptoStream.Write(bytes, 0, bytes.Length);
cryptoStream.FlushFinalBlock();
StringBuilder stringBuilder = new StringBuilder();
byte[] array = memoryStream.ToArray();
for (int i = 0; i < array.Length; i++)
{
byte b = array[i];
stringBuilder.AppendFormat("{0:X2}", b);
}
return stringBuilder.ToString();
}
public static string HashPasswordForStoringInConfigFile(string password, string passwordFormat)
{
if (password == null)
{
throw new ArgumentNullException("password");
}
if (passwordFormat == null)
{
throw new ArgumentNullException("passwordFormat");
}
HashAlgorithm hashAlgorithm;
if (Equals(passwordFormat, "sha1"))
{
hashAlgorithm = SHA1.Create();
}
else
{
if (Equals(passwordFormat, "md5"))
{

}
hashAlgorithm = MD5.Create();
}
return MachineKeySection.ByteArrayToHexString(hashAlgorithm.ComputeHash(Encoding.UTF8.GetBytes(password)), 0);
}
}
public sealed class MachineKeySection
{
private static char[] s_acharval;
internal unsafe static string ByteArrayToHexString(byte[] buf, int iLen)
{

char[] array = MachineKeySection.s_acharval;
if (array == null)
{
array = new char[16];
int num = array.Length;
while (--num >= 0)
{
if (num < 10)
{
array[num] = (char)(48 + num);
}
else
{
array[num] = (char)(65 + (num - 10));
}
}
MachineKeySection.s_acharval = array;
}
if (buf == null)
{
return null;
}
if (iLen == 0)
{
iLen = buf.Length;
}
char[] array2 = new char[iLen * 2];
fixed (char* ptr = array2, ptr2 = array)
{
fixed (byte* ptr3 = buf)
{
char* ptr4 = ptr;
byte* ptr5 = ptr3;
while (--iLen >= 0)
{
*(ptr4++) = ptr2[(*ptr5 & 240) >> 4];
*(ptr4++) = ptr2[*ptr5 & 15];
ptr5++;
}
}
}
return new string(array2);
}
}
}

评论加载中