Guest User

Untitled

a guest
Oct 3rd, 2023
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.19 KB | None | 0 0
  1.             internal static string DecryptContent(string content, Encryption enc)
  2.             {
  3.                 // removes 'DbdDAwACNS0' from string, converts from base64
  4.                 var fixed1 = content.Substring(12).Trim();
  5.                 var base64 = Convert.FromBase64String(fixed1);
  6.                 enc.encprefix = content.Substring(0, 12);
  7.  
  8.                 // removes unknown bytes, unknown what they mean
  9.                 var fixed2 = new byte[base64.Length - 8];
  10.                 Buffer.BlockCopy(base64, 8, fixed2, 0, fixed2.Length);
  11.                 Buffer.BlockCopy(base64, 0, enc.encBytes, 0, 8);
  12.  
  13.                 // Decrypt with AES using key from above
  14.                 var decrypted = AES.Decrypt(fixed2);
  15.  
  16.                 // Decode ASCII 'obfuscation'
  17.                 var array = new char[decrypted.Length];
  18.                 for (var i = 0; i < decrypted.Length; i++) array[i] = (char)(decrypted[i] + '\u0001');
  19.  
  20.                 var ascii_content = new string(array);
  21.                 ascii_content = ascii_content.Replace("\u0001", string.Empty);
  22.  
  23.                 // Continues with Zlib Decompression if needed. DbdDAQEB = Decompression needed
  24.                 if (!ascii_content.StartsWith("DbdDAQEB"))
  25.                 {
  26.                     enc.originalLength = ascii_content.Length;
  27.                     enc.enccompressed = false;
  28.                     return ascii_content;
  29.                 }
  30.  
  31.                 enc.enccompressed = true;
  32.  
  33.                 // removes unnecessary text 'DbdDAQEB', converts from base64
  34.                 var fixed3 = ascii_content.Substring(8).Trim();
  35.                 var base642 = Convert.FromBase64String(fixed3);
  36.  
  37.                 // removes unknown bytes unknown what they mean
  38.                 var fixed4 = new byte[base642.Length - 4];
  39.                 Buffer.BlockCopy(base642, 4, fixed4, 0, fixed4.Length);
  40.                 Buffer.BlockCopy(base642, 0, enc.encBytes2, 0, 4);
  41.  
  42.                 // Decompress fixed content
  43.                 var decompressed = Zlib.Decompress(fixed4);
  44.  
  45.                 var unicode = Encoding.Unicode.GetString(decompressed);
  46.  
  47.                 enc.originalLength = unicode.Length;
  48.  
  49.                 return unicode;
  50.             }
Add Comment
Please, Sign In to add comment