Advertisement
Guest User

Untitled

a guest
Aug 11th, 2018
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.86 KB | None | 0 0
  1. using AccServer.Network.Cryptography;
  2. using System;
  3. using System.IO;
  4. using System.Text;
  5.  
  6.  
  7. namespace AccServer.Network.AuthPackets
  8. {
  9. public unsafe class Authentication : Interfaces.IPacket
  10. {
  11. public string Username;
  12. public string Password;
  13. public string Server;
  14. public string Mac;
  15.  
  16. public Authentication()
  17. {
  18. }
  19. private byte[] _array;
  20. public string ReadString(int length, int offset)
  21. {
  22. // Read the value:
  23. fixed (byte* ptr = _array)
  24. return new string((sbyte*)ptr, offset, length, Encoding.GetEncoding(1252)).TrimEnd('\0');
  25. }
  26. public void Deserialize(byte[] buffer)
  27. {
  28. if (buffer.Length == 312)
  29. {
  30. ushort length = BitConverter.ToUInt16(buffer, 0);
  31.  
  32. if (length == 312)
  33. {
  34.  
  35. ushort type = BitConverter.ToUInt16(buffer, 2);
  36. byte[] temp = new byte[16];
  37. if (type == 1542)
  38. {
  39. MemoryStream MS = new MemoryStream(buffer);
  40. BinaryReader BR = new BinaryReader(MS);
  41.  
  42. BR.ReadUInt16();
  43. BR.ReadUInt16();
  44. Username = Encoding.Default.GetString(BR.ReadBytes(32));
  45. Username = Username.Replace("\0", "");
  46. BR.ReadBytes(36);
  47. var PasswordArray = BR.ReadBytes(32);
  48. LoaderEncryption.Decrypt(PasswordArray, 32);
  49. Password = Encoding.Default.GetString(PasswordArray);
  50. Password = Password.Replace("\0", "");
  51. BR.ReadBytes(32);
  52. Server = Encoding.Default.GetString(BR.ReadBytes(32));
  53. Server = Server.Replace("\0", "");
  54. Mac = Encoding.Default.GetString(BR.ReadBytes(16));
  55. Mac = Mac.Replace("\0", "");
  56. BR.Close();
  57. MS.Close();
  58. }
  59. }
  60. }
  61. }
  62. public void Deserialize2(byte[] buffer)
  63. {
  64. if (buffer.Length == 312)
  65. {
  66. ushort length = BitConverter.ToUInt16(buffer, 0);
  67.  
  68. if (length == 312)
  69. {
  70.  
  71. ushort type = BitConverter.ToUInt16(buffer, 2);
  72. byte[] temp = new byte[16];
  73. if (type == 1542)
  74. {
  75. MemoryStream MS = new MemoryStream(buffer);
  76. BinaryReader BR = new BinaryReader(MS);
  77.  
  78. BR.ReadUInt16();
  79. BR.ReadUInt16();
  80. Username = Encoding.Default.GetString(BR.ReadBytes(32));
  81. Username = Username.Replace("\0", "");
  82. BR.ReadBytes(36);
  83. var PasswordArray = BR.ReadBytes(32);
  84. TQ_Host_ME.Network.Cryptography.LoaderEncryption.Decrypt(PasswordArray, 32);
  85. Password = Encoding.Default.GetString(PasswordArray);
  86. Password = Password.Replace("\0", "");
  87. BR.ReadBytes(32);
  88. Server = Encoding.Default.GetString(BR.ReadBytes(32));
  89. Server = Server.Replace("\0", "");
  90. Mac = Encoding.Default.GetString(BR.ReadBytes(16));
  91. Mac = Mac.Replace("\0", "");
  92. BR.Close();
  93. MS.Close();
  94. }
  95. }
  96. }
  97. }
  98. public byte[] ToArray()
  99. {
  100. throw new NotImplementedException();
  101. }
  102.  
  103.  
  104. }
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement