IKE WORKS (key exchange first req + response work)

This commit is contained in:
raphaeIl
2025-01-11 13:17:01 -05:00
parent 01ebb3239d
commit 6200e766f9
3 changed files with 258 additions and 88 deletions

View File

@@ -11,6 +11,12 @@ namespace Novaria.Common.Crypto
{
public static class AeadTool
{
public static byte[] CLIENT_PUBLIC_KEY { get; set; }
public static byte[] PS_REQUEST_NONCE = new byte[12];
public static byte[] PS_PUBLIC_KEY = new byte[96]; // this is my public key, [69, 0, 0, 0, ...., 0, 0, 0, 69], 69s so i actually know i sent it correctly in frida log
public static string TOKEN = "seggs"; // hardcoded for now
public static readonly byte[] DEFAULT_SERVERLIST_KEY;
public static readonly byte[] DEFAULT_SERVERLIST_IV;
@@ -50,11 +56,17 @@ namespace Novaria.Common.Crypto
associatedData[associatedData.Length - 1] = 1;
//byte[] testkey = Encoding.ASCII.GetBytes("#$*;1H&x*)0!@,/OcIe4VbiL[~fLyE7t");
//byte[] testkey = Encoding.ASCII.GetBytes("#$*;1H&x*)0!@,/OcIe4VbiL[~fLyE7t"); // apprently key different for pc
//Console.WriteLine("test key" + testkey.Length);
//Utils.Utils.PrintByteArray(testkey);
//Console.WriteLine();
//testkey.CopyTo(FIRST_IKE_KEY, 0);
PS_PUBLIC_KEY[0] = 69;
PS_PUBLIC_KEY[95] = 69;
PS_REQUEST_NONCE[0] = 42;
PS_REQUEST_NONCE[11] = 42;
}
public static bool Dencrypt_ChaCha20(Span<byte> result, ReadOnlySpan<byte> key, ReadOnlySpan<byte> nonce, ReadOnlySpan<byte> data, ReadOnlySpan<byte> associatedData)

View File

@@ -10,6 +10,10 @@ using System.IO;
using System.Numerics;
using System.Security.Cryptography;
using Microsoft.AspNetCore.Http;
using Novaria.Common.Core;
using Proto;
using Google.Protobuf;
using System.Collections;
namespace Novaria.SDKServer.Controllers.Api
{
@@ -59,11 +63,33 @@ namespace Novaria.SDKServer.Controllers.Api
// store key which is used in AeadTool
using var memoryStream = new MemoryStream();
Request.Body.CopyTo(memoryStream); // Copy request body to MemoryStream
byte[] rawBytes = memoryStream.ToArray(); // Get raw bytes from MemoryStream
byte[] rawPayload = memoryStream.ToArray(); // Get raw bytes from MemoryStream
Utils.PrintByteArray(rawBytes);
//byte[] msgId = BitConverter.GetBytes(msg.msgId);
//Utils.PrintByteArray(rawPayload);
IKEReq ikeRequest = ParseIkeRequest(rawPayload);
Console.WriteLine("Decoded Packet: " + JsonSerializer.Serialize(ikeRequest));
AeadTool.CLIENT_PUBLIC_KEY = ikeRequest.PubKey.ToArray();
IKEResp ikeResponse = new IKEResp()
{
PubKey = ByteString.CopyFrom(AeadTool.PS_PUBLIC_KEY),
Token = AeadTool.TOKEN
};
Packet ikePacket = new Packet()
{
msgId = 2,
msgBody = ikeResponse.ToByteArray()
};
var responsePayload = BuildIkeResponse(ikePacket);
Console.WriteLine("Sending ike response packet: " + JsonSerializer.Serialize(ikeResponse));
Console.WriteLine("Built bytes: ");
Utils.PrintByteArray(responsePayload);
//// Set response headers
//Response.Headers.Add("Date", DateTime.UtcNow.ToString("R"));
@@ -80,12 +106,181 @@ namespace Novaria.SDKServer.Controllers.Api
//byte[] fileBytes = System.IO.File.ReadAllBytes(filePath);
//// Write bytes directly to response body
//Response.Body.WriteAsync(fileBytes, 0, fileBytes.Length);
Response.Body.Write(responsePayload, 0, responsePayload.Length);
//// Return no content since the body is written manually
return new EmptyResult();
}
public static byte[] BuildIkeResponse(Packet packet)
{
BinaryWriter packetWriter = new BinaryWriter(new MemoryStream());
byte[] msgIdBytes = BitConverter.GetBytes(packet.msgId);
if (BitConverter.IsLittleEndian)
{
Array.Reverse<byte>(msgIdBytes);
}
packetWriter.Write(msgIdBytes.AsSpan<byte>());
packetWriter.Write(packet.msgBody.AsSpan<byte>());
byte[] packetData = ((MemoryStream)packetWriter.BaseStream).ToArray();
Span<byte> encryptedPacketData = (new byte[packetData.Length + 16]).AsSpan();
AeadTool.Encrypt_ChaCha20(encryptedPacketData, AeadTool.FIRST_IKE_KEY, AeadTool.PS_REQUEST_NONCE, packetData, false);
Console.WriteLine("build: encrypted data:");
Utils.PrintByteArray(encryptedPacketData.ToArray());
BinaryWriter rawResponseWriter = new BinaryWriter(new MemoryStream());
rawResponseWriter.Write(AeadTool.PS_REQUEST_NONCE);
rawResponseWriter.Write(encryptedPacketData);
return ((MemoryStream)rawResponseWriter.BaseStream).ToArray();
}
// used for parsing ike requests in ps (or any request ig) client -> server
public static IKEReq ParseIkeRequest(byte[] encryptedRawPayload)
{
bool flag = true; // original this flag is: flag = msg.msgId == 1, so true
BinaryReader reader = new BinaryReader(new MemoryStream(encryptedRawPayload));
byte[] nonceBytes = new byte[12]; // nonce 12 bytes length
reader.Read(nonceBytes);
byte[] aeadBytes = new byte[1]; // aead byte is 1 byte, original field in AeadTool
int packetSize = encryptedRawPayload.Length - nonceBytes.Length; // skip nonce length (12)
if (flag)
{
reader.Read(aeadBytes); // read to skip in memory, idk whats the use for this
packetSize--; // skip in payload
}
byte[] packetBytes = new byte[packetSize];
reader.Read(packetBytes);
if (reader.BaseStream.Position != encryptedRawPayload.Length)
{
Log.Error("something went wrong, not all the bytes were read");
Log.Error("reader pos: " + reader.BaseStream.Position);
Log.Error("original len:" + encryptedRawPayload.Length);
}
Span<byte> decrypt_result = new Span<byte>(new byte[packetSize - 16]); // for chacha20 decrypt, the result is 16 bytes less than the input data
Span<byte> nonce = nonceBytes.AsSpan();
Span<byte> packet_data = packetBytes.AsSpan();
//Console.WriteLine($"Nonce[{nonce.Length}]");
//Utils.PrintByteArray(nonce.ToArray());
//Console.WriteLine($"packet_data[{packet_data.Length}]: ");
//Utils.PrintByteArray(packet_data.ToArray());
//Console.WriteLine($"key[{AeadTool.FIRST_IKE_KEY.Length}]: ");
//Utils.PrintByteArray(AeadTool.FIRST_IKE_KEY.ToArray());
//Console.WriteLine($"Decrypted bytes[{decrypt_result.Length}]: ");
byte[] associateData = new byte[13]; // this is needed for req decrypt (size: nonce(12) + 1)
nonceBytes.CopyTo(associateData, 0); // associateData: [nonce, 1], 1 means AesGcm not supported
associateData[associateData.Length - 1] = 1;
bool success = AeadTool.Dencrypt_ChaCha20(decrypt_result, AeadTool.FIRST_IKE_KEY, nonce, packet_data, associateData);
if (!success)
{
Log.Error("something went wrong when chacha20 decrypting the data");
}
//Utils.PrintByteArray(decrypt_result.ToArray());
byte[] decrypted_bytes = decrypt_result.ToArray();
//Utils.PrintByteArray(decrypted_bytes);
byte[] msgid_bytes = decrypted_bytes[..2]; // first two bytes is msgid
Array.Reverse<byte>(msgid_bytes); // should check BitConverter.IsLittleEndian (if true -> reverse, was true on my pc)
short msgId = BitConverter.ToInt16(msgid_bytes);
Packet packet = new Packet()
{
msgId = msgId,
msgBody = decrypted_bytes[2..],
};
//Console.WriteLine("msgid: " + msgId);
//Console.WriteLine("msgBody length: " + packet.msgBody.Length);
IKEReq ike_request = IKEReq.Parser.ParseFrom(packet.msgBody);
return ike_request;
}
// used to parse offical pcaps, server -> client
public static IKEResp ParseIkeResponse(byte[] encryptedRawPayload)
{
bool flag = false; // false for this pcap ike resp
BinaryReader reader = new BinaryReader(new MemoryStream(encryptedRawPayload));
byte[] nonceBytes = new byte[12]; // nonce 12 bytes length
reader.Read(nonceBytes);
byte[] aeadBytes = new byte[1]; // aead byte is 1 byte, original field in AeadTool
int packetSize = encryptedRawPayload.Length - nonceBytes.Length; // skip nonce length (12)
if (flag)
{
reader.Read(aeadBytes); // read to skip in memory, idk whats the use for this
packetSize--; // skip in payload
}
byte[] packetBytes = new byte[packetSize];
reader.Read(packetBytes);
if (reader.BaseStream.Position != encryptedRawPayload.Length)
{
Log.Error("something went wrong, not all the bytes were read");
Log.Error("reader pos: " + reader.BaseStream.Position);
Log.Error("original len:" + encryptedRawPayload.Length);
}
Span<byte> decrypt_result = new Span<byte>(new byte[packetSize - 16]); // for chacha20, the result is 16 bytes less than the input data
Span<byte> nonce = nonceBytes.AsSpan();
Span<byte> packet_data = packetBytes.AsSpan();
bool success = AeadTool.Dencrypt_ChaCha20(decrypt_result, AeadTool.FIRST_IKE_KEY, nonce, packet_data, null); // associateData NULL FOR THIS response pcap
if (!success)
{
Log.Error("something went wrong when chacha20 decrypting the data");
}
byte[] decrypted_bytes = decrypt_result.ToArray();
byte[] msgid_bytes = decrypted_bytes[..2]; // first two bytes is msgid
Array.Reverse<byte>(msgid_bytes); // should check BitConverter.IsLittleEndian (if true -> reverse, was true on my pc)
short msgId = BitConverter.ToInt16(msgid_bytes);
Packet packet = new Packet()
{
msgId = msgId,
msgBody = decrypted_bytes[2..],
};
IKEResp ike_response = IKEResp.Parser.ParseFrom(packet.msgBody);
return ike_response;
}
//private DiffieHellmanManaged SendKey;
//// put in connection prob

View File

@@ -16,20 +16,16 @@ using Microsoft.AspNetCore.Http;
using System.IO;
using NSec.Cryptography;
using static System.Runtime.InteropServices.JavaScript.JSType;
using Novaria.SDKServer.Controllers.Api;
namespace Novaria.SDKServer
{
public class SDKServer
{
//public Packet ParseIkeMessage(byte[] encryptedRawPayload)
//{
//}
public static void Main(string[] args)
{
//byte[] result = new byte[] { 72, 115, 142, 228, 125, 80, 99, 136, 69, 104, 100, 1, 40, 52, 96, 130, 76, 79, 164, 172, 151, 94, 234, 141, 235, 198, 110, 211, 218, 213, 155, 111, 64, 170, 181, 53, 117, 77, 234, 162, 247, 154, 219, 157, 50, 59, 84, 148, 165, 122, 236, 76, 15, 134, 140, 229, 224, 105, 90, 2, 226, 240, 240, 16, 6, 209, 29, 11, 52, 224, 26, 174, 113, 114, 54, 169, 108, 63, 53, 170, 94, 142, 153, 65, 192, 116, 145, 127, 107, 137, 193, 141, 203, 149, 9, 188, 91, 78, 191, 117, 145, 14, 105, 108, 203, 106, 161, 97, 133, 123, 132, 205, 151, 184, 240, 165 };
//byte[] key = new byte[] { 51, 76, 83, 57, 38, 111, 89, 100, 115, 112, 94, 53, 119, 105, 56, 38, 90, 120, 67, 35, 99, 55, 77, 90, 103, 55, 51, 104, 98, 69, 68, 119 };
//byte[] nonce = new byte[] { 50, 103, 122, 81, 54, 57, 80, 109, 55, 49, 86, 55 };
//byte[] data = new byte[] { 0, 1, 10, 96, 30, 72, 185, 252, 24, 18, 102, 148, 64, 6, 58, 221, 16, 109, 243, 95, 183, 216, 77, 49, 124, 134, 97, 3, 136, 61, 184, 215, 41, 126, 194, 60, 133, 13, 82, 220, 41, 147, 27, 174, 137, 10, 6, 222, 251, 18, 201, 192, 53, 249, 223, 27, 67, 209, 125, 129, 139, 32, 32, 225, 233, 158, 23, 191, 187, 238, 129, 226, 180, 85, 152, 50, 137, 33, 65, 129, 225, 180, 154, 172, 39, 177, 136, 36, 141, 168, 43, 144, 155, 99, 85, 21, 213, 194, 139, 112 };
@@ -59,90 +55,57 @@ namespace Novaria.SDKServer
//byte[] ike_req_bytes = new byte[] { 10, 96, 108, 183, 187, 238, 19, 29, 80, 121, 193, 82, 107, 114, 202, 58, 16, 52, 131, 72, 179, 174, 18, 170, 8, 124, 161, 231, 241, 121, 27, 190, 176, 218, 90, 9, 9, 88, 190, 59, 190, 128, 9, 247, 199, 212, 136, 3, 198, 175, 89, 222, 172, 222, 157, 99, 247, 254, 237, 66, 68, 238, 188, 125, 169, 248, 17, 130, 150, 12, 213, 10, 197, 36, 122, 134, 139, 88, 52, 177, 53, 38, 114, 145, 99, 40, 111, 82, 237, 245, 178, 106, 108, 170, 57, 235, 136, 25 };
//byte[] player_login_req_bytes = new byte[] { 106, 8, 79, 102, 102, 105, 99, 105, 97, 108, 26, 48, 8, 240, 186, 151, 225, 3, 18, 40, 50, 50, 97, 99, 56, 56, 54, 101, 53, 102, 98, 101, 101, 102, 52, 100, 98, 98, 56, 100, 56, 51, 54, 100, 56, 98, 99, 98, 49, 54, 54, 54, 56, 100, 98, 55, 99, 97, 55, 100, 98, 5, 122, 104, 95, 67, 78, 120, 1, 114, 16, 100, 99, 49, 56, 101, 49, 50, 98, 57, 54, 50, 57, 101, 57, 52, 101, 88, 2 };
byte[] ike_req_raw_bytes = new byte[] { 50, 103, 122, 81, 54, 57, 80, 109, 55, 49, 86, 55, 1, 72, 115, 142, 228, 125, 80, 99, 136, 69, 104, 100, 1, 40, 52, 96, 130, 76, 79, 164, 172, 151, 94, 234, 141, 235, 198, 110, 211, 218, 213, 155, 111, 64, 170, 181, 53, 117, 77, 234, 162, 247, 154, 219, 157, 50, 59, 84, 148, 165, 122, 236, 76, 15, 134, 140, 229, 224, 105, 90, 2, 226, 240, 240, 16, 6, 209, 29, 11, 52, 224, 26, 174, 113, 114, 54, 169, 108, 63, 53, 170, 94, 142, 153, 65, 192, 116, 145, 127, 107, 137, 193, 141, 203, 149, 9, 188, 91, 78, 191, 117, 145, 14, 105, 108, 203, 106, 161, 97, 133, 123, 132, 205, 151, 184, 240, 165 };
ike_req_raw_bytes = new byte[] { 238, 229, 238, 9, 37, 193, 132, 180, 61, 153, 199, 186, 4, 244, 254, 140, 91, 117, 71, 80, 159, 135, 140, 203, 228, 77, 27, 179, 254, 183, 72, 176, 185, 189, 30, 193, 34, 117, 133, 225, 239, 52, 174, 149, 44, 203, 37, 116, 83, 34, 75, 49, 105, 102, 145, 145, 115, 125, 172, 100, 65, 173, 57, 198, 79, 9, 134, 169, 31, 138, 51, 247, 255, 85, 206, 195, 234, 144, 11, 167, 183, 159, 116, 21, 251, 193, 223, 68, 116, 202, 26, 223, 20, 101, 176, 136, 156, 88, 127, 113, 169, 34, 76, 180, 3, 157, 201, 127, 241, 46, 61, 56, 25, 18, 187, 103, 34, 64, 7, 115, 227, 135, 159, 149, 199, 166, 11, 119, 122, 225, 23, 134, 5, 63, 21, 182, 106, 94, 200, 13, 63, 231, 212, 51, 255, 81, 237, 238, 4, 156, 94, 149, 215, 120, 81, 14, 191, 209, 237, 139, 209, 238, 130, 202, 51, 63, 238, 214, 68, 109, 114, 108, 191, 208, 255, 32, 171, 246, 208, 139, 6, 223, 0, 120, 1, 104, 44, 82, 72, 129, 181, 237, 8, 213, 196, 193, 87, 114, 247, 12, 12, 218, 159, 182, 248, 63, 22, 207, 124, 217, 93, 121, 0, 49, 49, 237, 167, 215, 85, 173, 89, 152, 81, 151, 134, 240, 142, 208, 89, 9, 103, 243, 130, 221, 142, 44, 141, 64, 254, 215, 116, 155, 127, 32, 108, 178, 226 };
//byte[] ike_req_raw_bytes = new byte[] { 50, 103, 122, 81, 54, 57, 80, 109, 55, 49, 86, 55, 1, 72, 115, 142, 228, 125, 80, 99, 136, 69, 104, 100, 1, 40, 52, 96, 130, 76, 79, 164, 172, 151, 94, 234, 141, 235, 198, 110, 211, 218, 213, 155, 111, 64, 170, 181, 53, 117, 77, 234, 162, 247, 154, 219, 157, 50, 59, 84, 148, 165, 122, 236, 76, 15, 134, 140, 229, 224, 105, 90, 2, 226, 240, 240, 16, 6, 209, 29, 11, 52, 224, 26, 174, 113, 114, 54, 169, 108, 63, 53, 170, 94, 142, 153, 65, 192, 116, 145, 127, 107, 137, 193, 141, 203, 149, 9, 188, 91, 78, 191, 117, 145, 14, 105, 108, 203, 106, 161, 97, 133, 123, 132, 205, 151, 184, 240, 165 };
//ike_req_raw_bytes = new byte[] { 238, 229, 238, 9, 37, 193, 132, 180, 61, 153, 199, 186, 4, 244, 254, 140, 91, 117, 71, 80, 159, 135, 140, 203, 228, 77, 27, 179, 254, 183, 72, 176, 185, 189, 30, 193, 34, 117, 133, 225, 239, 52, 174, 149, 44, 203, 37, 116, 83, 34, 75, 49, 105, 102, 145, 145, 115, 125, 172, 100, 65, 173, 57, 198, 79, 9, 134, 169, 31, 138, 51, 247, 255, 85, 206, 195, 234, 144, 11, 167, 183, 159, 116, 21, 251, 193, 223, 68, 116, 202, 26, 223, 20, 101, 176, 136, 156, 88, 127, 113, 169, 34, 76, 180, 3, 157, 201, 127, 241, 46, 61, 56, 25, 18, 187, 103, 34, 64, 7, 115, 227, 135, 159, 149, 199, 166, 11, 119, 122, 225, 23, 134, 5, 63, 21, 182, 106, 94, 200, 13, 63, 231, 212, 51, 255, 81, 237, 238, 4, 156, 94, 149, 215, 120, 81, 14, 191, 209, 237, 139, 209, 238, 130, 202, 51, 63, 238, 214, 68, 109, 114, 108, 191, 208, 255, 32, 171, 246, 208, 139, 6, 223, 0, 120, 1, 104, 44, 82, 72, 129, 181, 237, 8, 213, 196, 193, 87, 114, 247, 12, 12, 218, 159, 182, 248, 63, 22, 207, 124, 217, 93, 121, 0, 49, 49, 237, 167, 215, 85, 173, 89, 152, 81, 151, 134, 240, 142, 208, 89, 9, 103, 243, 130, 221, 142, 44, 141, 64, 254, 215, 116, 155, 127, 32, 108, 178, 226 };
//ike_req_raw_bytes = File.ReadAllBytes("E:\\documents\\Decompiling\\Extracted\\NOVA\\Novaria\\Novaria.SDKServer\\options_req");
Console.WriteLine(ike_req_raw_bytes.Length);
bool flag = false;
//Console.WriteLine(ike_req_raw_bytes.Length);
Utils.PrintByteArray(ike_req_raw_bytes);
BinaryReader reader = new BinaryReader(new MemoryStream(ike_req_raw_bytes));
byte[] nonceBytes = new byte[12];
reader.Read(nonceBytes);
byte[] aheadmarkBytes = new byte[1];
int payloadSize = ike_req_raw_bytes.Length - nonceBytes.Length;
if (flag)
{
reader.Read(aheadmarkBytes);
payloadSize--;
}
byte[] packetBytes = new byte[payloadSize];
reader.Read(packetBytes);
if (reader.BaseStream.Position != ike_req_raw_bytes.Length)
{
Console.WriteLine("something went wrong, not all the bytes were read");
Console.WriteLine("reader pos: " + reader.BaseStream.Position);
Console.WriteLine("original len:" + ike_req_raw_bytes.Length);
}
Span<byte> decrypt_result = new Span<byte>(new byte[payloadSize - 16]);
Span<byte> nonce = nonceBytes.AsSpan();
Span<byte> packet_data = packetBytes.AsSpan();
Console.WriteLine($"Nonce[{nonce.Length}]");
Utils.PrintByteArray(nonce.ToArray());
Console.WriteLine($"packet_data[{packet_data.Length}]: ");
Utils.PrintByteArray(packet_data.ToArray());
Console.WriteLine($"key[{AeadTool.FIRST_IKE_KEY.Length}]: ");
Utils.PrintByteArray(AeadTool.FIRST_IKE_KEY.ToArray());
Console.WriteLine($"Decrypted bytes[{decrypt_result.Length}]: ");
byte[] associateData = new byte[13];
nonceBytes.CopyTo(associateData, 0);
associateData[associateData.Length - 1] = 1;
bool success = AeadTool.Dencrypt_ChaCha20(decrypt_result, AeadTool.FIRST_IKE_KEY, nonce, packet_data, null);
Console.WriteLine("sucess: " + success);
Utils.PrintByteArray(decrypt_result.ToArray());
byte[] decrypted_bytes = decrypt_result.ToArray();
Utils.PrintByteArray(decrypted_bytes);
byte[] msgid_bytes = decrypted_bytes[..2];
Array.Reverse<byte>(msgid_bytes);
short msgId = BitConverter.ToInt16(msgid_bytes);
Packet packet = new Packet()
{
msgId = msgId,
msgBody = decrypted_bytes[2..],
};
Console.WriteLine("msgid: " + msgId);
Console.WriteLine("msgBody length: " + packet.msgBody.Length);
var packetObj = IKEResp.Parser.ParseFrom(packet.msgBody);
//var ikereq = IKEReq.Parser.ParseFrom(ike_req_bytes);
//var ikerespBytes = new byte[] { 78, 173, 172, 234, 27, 192, 183, 83, 241, 101, 79, 213, 243, 225, 240, 5, 41, 112, 109, 167, 81, 176, 134, 17, 168, 113, 190, 218, 149, 218, 125, 173, 222, 18, 22, 107, 231, 62, 150, 140, 247, 49, 202, 165, 28, 147, 44, 92, 44, 195, 74, 239, 43, 79, 21, 38, 84, 1, 3, 140, 144, 217, 89, 35, 181, 20, 42, 253, 94, 67, 157, 192, 69, 30, 75, 36, 91, 207, 176, 221, 143, 71, 129, 114, 101, 77, 166, 231, 250, 60, 67, 69, 152, 179, 125, 156, 175, 58, 157, 189, 111, 172, 198, 143, 3, 82, 0, 57, 236, 247, 184, 229, 91, 46, 60, 37, 190, 188, 21, 215, 130, 113, 225, 167, 175, 218, 71, 96, 174, 38, 191, 244, 1, 31, 82, 131, 179, 160, 194, 226, 79, 196, 119, 109, 159, 228, 153, 1, 93, 60, 154, 175, 53, 65, 202, 30, 24, 63, 50, 54, 39, 195, 43, 49, 123, 4, 231, 215, 171, 236, 54, 120, 247, 71, 239, 187, 84, 35, 60, 52, 139, 72, 88, 234, 54, 137, 174, 200, 232, 118, 126, 152, 212, 205, 252, 197, 10, 183, 218, 198, 155, 248, 14, 154, 13, 177, 46, 216, 236, 121, 93, 0, 99, 6, 118, 202, 39, 60, 214, 193, 93, 158, 220, 186, 103, 120, 134, 58, 48, 185, 234, 17, 157, 233, 101, 30, 207, 112, 247, 201, 11, 35, 152, 102, 121, 235, 113 };
//var loginreq = LoginResp.Parser.ParseFrom(player_login_req_bytes);
//var loginreq = LoginReq.Parser.ParseFrom(player_login_req_bytes);
//var ikeResponse = GatewayController.ParseIkeResponse(ikerespBytes);
Console.WriteLine(JsonSerializer.Serialize(packetObj));
//IKEResp ikeResp = new IKEResp()
//{
// PubKey = ByteString.;
//}
//IKEResp ikeResponse = new IKEResp()
//{
// PubKey = ByteString.CopyFrom(AeadTool.PS_PUBLIC_KEY),
// Token = AeadTool.TOKEN
//};
//Console.WriteLine(JsonSerializer.Serialize(ikeResponse));
//Packet ikePacket = new Packet()
//{
// msgId = 2,
// msgBody = ikeResponse.ToByteArray()
//};
//var responsePayload = GatewayController.BuildIkeResponse(ikePacket);
//Console.WriteLine();
//Console.WriteLine("built response");
//Utils.PrintByteArray(responsePayload);
//Console.WriteLine("now deserializing...");
//IKEResp reparsed = GatewayController.ParseIkeResponse(responsePayload);
//Console.WriteLine();
//Console.WriteLine("reparsed:");
//Console.WriteLine(JsonSerializer.Serialize(reparsed));
//Console.WriteLine(JsonSerializer.Serialize(ikeresp));
//Console.WriteLine(Encoding.ASCII.GetString(new byte[] { 18, 111, 108, 118, 121, 50, 118, 73, 75, 73, 70, 78, 106, 74, 72, 106, 101, 122, 87, 70, 83, 50, 71, 47, 69, 109, 108, 48, 106, 99, 50, 56, 102, 122, 98, 74, 75, 54, 111, 57, 98, 50, 90, 70, 88, 43, 113, 69, 84, 69, 109, 97, 74, 77, 97, 80, 43, 80, 43, 110, 43, 79, 105, 77, 78, 77, 82, 108, 108, 82, 74, 67, 74, 106, 56, 110, 54, 73, 103, 54, 76, 104, 77, 98, 47, 80, 50, 120, 88, 89, 103, 122, 71, 43, 112, 86, 105, 73, 66, 47, 111, 49, 97, 116, 52, 104, 115, 50, 81, 114, 57, 70, 48, 24, 193, 167, 138, 188, 6 }));
//Utils.PrintByteArray(Encoding.ASCII.GetBytes("Di9OhjFgkabvOO26XfjOzQ4/IcQ6yaFuK23tE2yw9Q7yYs5B53Zffs1e4DygW4IFgCFBtDKwAJtddxYmPfnjCfpCGk5UOAdLCH1/0NLHf+tl/Qc4GuG7jaK0Lcs75gHcSmRUkA"));
//return;
Log.Information("Starting SDK Server...");
try