Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. // Decompiled with JetBrains decompiler
  2. // Type: CrackMe.Program
  3. // Assembly: CrackMe, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
  4. // MVID: 7588AF36-84AD-43FF-9334-793E1CC1BF11
  5. // Assembly location: C:\Users\Ian\Downloads\CrackMe.exe
  6.  
  7. using System;
  8. using System.IO;
  9.  
  10. namespace CrackMe
  11. {
  12. internal class Program
  13. {
  14. private static void Main(string[] args)
  15. {
  16. if (args.Length != 4)
  17. {
  18. Console.WriteLine("Incorrect arguments");
  19. Console.WriteLine("Usage: CrackMe.exe <input_file> <output_file> <user_pass_phrase> <mode>");
  20. }
  21. else
  22. {
  23. string path = args[0];
  24. string outputFile = args[1];
  25. string str1 = args[2];
  26. string str2 = args[3];
  27. if (!File.Exists(path))
  28. {
  29. Console.WriteLine("Input file doesn't exist");
  30. }
  31. else
  32. {
  33. CryptoOperation crypto = new CryptoOperation();
  34. crypto.FileName = path;
  35. crypto.UserPassword = str1;
  36. if (!(str2 == "encrypt"))
  37. {
  38. if (str2 == "decrypt")
  39. {
  40. Program.Decrypt(crypto, outputFile);
  41. }
  42. else
  43. {
  44. Console.WriteLine("Incorrect mode");
  45. Console.WriteLine("Use encrypt or decrypt");
  46. }
  47. }
  48. else
  49. Program.Encrypt(crypto, outputFile);
  50. }
  51. }
  52. }
  53.  
  54. private static void Encrypt(CryptoOperation crypto, string outputFile)
  55. {
  56. crypto.ParseFileToEncrypt();
  57. byte[] buffer = crypto.EncryptFile();
  58. using (BinaryWriter binaryWriter = new BinaryWriter((Stream) File.Open(outputFile, FileMode.Create)))
  59. {
  60. binaryWriter.Write(crypto.IV);
  61. binaryWriter.Write(buffer);
  62. }
  63. Console.WriteLine("That's all.");
  64. }
  65.  
  66. private static void Decrypt(CryptoOperation crypto, string outputFile)
  67. {
  68. crypto.ParseFileToDecrypt();
  69. byte[] buffer = crypto.DecryptFile();
  70. if (buffer == null)
  71. return;
  72. using (BinaryWriter binaryWriter = new BinaryWriter((Stream) File.Open(outputFile, FileMode.Create)))
  73. binaryWriter.Write(buffer);
  74. Console.WriteLine("That's all.");
  75. }
  76. }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement