mirror of
https://github.com/raphaeIl/Novaria.git
synced 2025-12-12 14:34:38 +01:00
some handlers, dh pubkey negative problem still not solved...
This commit is contained in:
@@ -27,10 +27,16 @@ namespace Novaria.Common.Crypto
|
|||||||
Console.WriteLine(clientPubKeyInt.ToString());
|
Console.WriteLine(clientPubKeyInt.ToString());
|
||||||
|
|
||||||
var result = BigInteger.ModPow(clientPubKeyInt, spriv, p);
|
var result = BigInteger.ModPow(clientPubKeyInt, spriv, p);
|
||||||
if (result < 0)
|
|
||||||
{
|
//if (result < 0)
|
||||||
result += p; // Make the result non-negative, causes error if -
|
//{
|
||||||
}
|
// return result.ToByteArray(false, true)[..32];
|
||||||
|
//}
|
||||||
|
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
|
||||||
|
//}
|
||||||
|
|
||||||
return result.ToByteArray(true, true)[..32];
|
return result.ToByteArray(true, true)[..32];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,18 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Remove="all_mainmenu_packets.json" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="all_mainmenu_packets.json">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||||
|
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
<ProjectReference Include="..\Novaria.Common\Novaria.Common.csproj" />
|
<ProjectReference Include="..\Novaria.Common\Novaria.Common.csproj" />
|
||||||
|
|||||||
@@ -81,7 +81,8 @@ namespace Novaria.PcapParser
|
|||||||
Method = packet.type,
|
Method = packet.type,
|
||||||
Packet = Convert.ChangeType(decodedPayload, requestType),
|
Packet = Convert.ChangeType(decodedPayload, requestType),
|
||||||
MsgId = msgid,
|
MsgId = msgid,
|
||||||
ClassType = NetMsgIdToNameMappings[(short)msgid]
|
ClassType = NetMsgIdToNameMappings[(short)msgid],
|
||||||
|
MsgIdName = Enum.GetName(typeof(NetMsgId), msgid)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -682,6 +683,7 @@ namespace Novaria.PcapParser
|
|||||||
public object Packet { get; set; }
|
public object Packet { get; set; }
|
||||||
public string ClassType { get; set; }
|
public string ClassType { get; set; }
|
||||||
public NetMsgId MsgId { get; set; }
|
public NetMsgId MsgId { get; set; }
|
||||||
|
public string MsgIdName { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
{
|
{
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
PcapParser.Instance.Parse("first_instant_join.json");
|
PcapParser.Instance.Parse("all_mainmenu_packets.json");
|
||||||
|
|
||||||
PcapParser.Instance.SavePackets("parsed_packets.json");
|
PcapParser.Instance.SavePackets("parsed_packets.json");
|
||||||
}
|
}
|
||||||
|
|||||||
298
Novaria.PcapParser/all_mainmenu_packets.json
Normal file
298
Novaria.PcapParser/all_mainmenu_packets.json
Normal file
File diff suppressed because one or more lines are too long
19089
Novaria.PcapParser/all_menu_parsed_packets.json
Normal file
19089
Novaria.PcapParser/all_menu_parsed_packets.json
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,20 @@
|
|||||||
|
using Novaria.Common.Core;
|
||||||
|
using Proto;
|
||||||
|
using Serilog;
|
||||||
|
|
||||||
|
namespace Novaria.GameServer.Controllers.Api.ProtocolHandlers
|
||||||
|
{
|
||||||
|
public class ActivityDetail : ProtocolHandlerBase
|
||||||
|
{
|
||||||
|
public ActivityDetail(IProtocolHandlerFactory protocolHandlerFactory) : base(protocolHandlerFactory)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[ProtocolHandler(NetMsgId.activity_detail_req)] // req id goes here
|
||||||
|
public Packet PlayerLoginHandler(Nil req)
|
||||||
|
{
|
||||||
|
return Packet.Create(NetMsgId.activity_detail_succeed_ack, PcapParser.PcapParser.Instance.GetPcapPacket(NetMsgId.activity_detail_succeed_ack));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -55,7 +55,7 @@ namespace Novaria.GameServer.Controllers.Api.ProtocolHandlers
|
|||||||
|
|
||||||
byte[] real_key = AeadTool.key3;
|
byte[] real_key = AeadTool.key3;
|
||||||
// load from pcap
|
// load from pcap
|
||||||
PcapParser.PcapParser.Instance.Parse("first_instant_join.json");
|
PcapParser.PcapParser.Instance.Parse("all_mainmenu_packets.json");
|
||||||
|
|
||||||
PlayerInfo pcapPlayerInfo = (PlayerInfo)PcapParser.PcapParser.Instance.GetPcapPacket(NetMsgId.player_data_succeed_ack);
|
PlayerInfo pcapPlayerInfo = (PlayerInfo)PcapParser.PcapParser.Instance.GetPcapPacket(NetMsgId.player_data_succeed_ack);
|
||||||
|
|
||||||
@@ -69,14 +69,14 @@ namespace Novaria.GameServer.Controllers.Api.ProtocolHandlers
|
|||||||
return Packet.Create(NetMsgId.player_data_succeed_ack, pcapPlayerInfo);
|
return Packet.Create(NetMsgId.player_data_succeed_ack, pcapPlayerInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
//[ProtocolHandler(NetMsgId.player_reg_req)]
|
[ProtocolHandler(NetMsgId.player_ping_req)]
|
||||||
//public Packet PlayerRegHandler(PlayerReg req)
|
public Packet PlayerRegHandler(PlayerReg req)
|
||||||
//{
|
{
|
||||||
// Log.Information("player_reg_req received, contents: " + JsonSerializer.Serialize(req));
|
return Packet.Create(NetMsgId.player_ping_succeed_ack, new Pong()
|
||||||
|
{
|
||||||
|
ServerTs = DateTime.Now.Ticks,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// //Log.Information("Sending PlayerInfo packet: " + JsonSerializer.Serialize(playerInfoResp));
|
|
||||||
// return null;
|
|
||||||
//}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
26
Novaria.SDKServer/Controllers/Api/ProtocolHandlers/Mail.cs
Normal file
26
Novaria.SDKServer/Controllers/Api/ProtocolHandlers/Mail.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
using Novaria.Common.Core;
|
||||||
|
using Proto;
|
||||||
|
using Serilog;
|
||||||
|
|
||||||
|
namespace Novaria.GameServer.Controllers.Api.ProtocolHandlers
|
||||||
|
{
|
||||||
|
public class Mail : ProtocolHandlerBase
|
||||||
|
{
|
||||||
|
public Mail(IProtocolHandlerFactory protocolHandlerFactory) : base(protocolHandlerFactory)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[ProtocolHandler(NetMsgId.mail_list_req)] // req id goes here
|
||||||
|
public Packet PlayerLoginHandler(Nil req)
|
||||||
|
{
|
||||||
|
Mails mailListResp = (Mails)PcapParser.PcapParser.Instance.GetPcapPacket(NetMsgId.mail_list_succeed_ack);
|
||||||
|
|
||||||
|
mailListResp.List[0].Subject = "夏萝莉是小楠梁";
|
||||||
|
mailListResp.List[1].Subject = "夏萝莉是小楠梁";
|
||||||
|
mailListResp.List[2].Subject = "夏萝莉是小楠梁";
|
||||||
|
|
||||||
|
return Packet.Create(NetMsgId.mail_list_succeed_ack, mailListResp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
using Novaria.Common.Core;
|
||||||
|
using Proto;
|
||||||
|
using Serilog;
|
||||||
|
|
||||||
|
namespace Novaria.GameServer.Controllers.Api.ProtocolHandlers
|
||||||
|
{
|
||||||
|
public class ResidentShop : ProtocolHandlerBase
|
||||||
|
{
|
||||||
|
public ResidentShop(IProtocolHandlerFactory protocolHandlerFactory) : base(protocolHandlerFactory)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[ProtocolHandler(NetMsgId.resident_shop_get_req)] // req id goes here
|
||||||
|
public Packet PlayerLoginHandler(ResidentShopGetReq req)
|
||||||
|
{
|
||||||
|
ResidentShopGetResp resp = new ResidentShopGetResp();
|
||||||
|
|
||||||
|
resp.Shops.Add(new Proto.ResidentShop() { Id = 1, RefreshTime = 1 });
|
||||||
|
resp.Shops.Add(new Proto.ResidentShop() { Id = 2, RefreshTime = 1 });
|
||||||
|
resp.Shops.Add(new Proto.ResidentShop() { Id = 3, RefreshTime = 1 });
|
||||||
|
|
||||||
|
return Packet.Create(NetMsgId.resident_shop_get_succeed_ack, resp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,32 +18,12 @@ namespace Novaria.GameServer
|
|||||||
{
|
{
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
//AeadTool.key3 = new byte[] { 73, 90, 77, 19, 136, 20, 253, 207, 122, 182, 60, 5, 199, 187, 85, 43, 151, 253, 66, 167, 119, 12, 188, 145, 201, 3, 109, 105, 74, 79, 15, 128 };
|
byte[] spub = new byte[] { 0, 219, 176, 103, 73, 245, 239, 125, 227, 240, 79, 51, 62, 250, 113, 143, 251, 155, 158, 45, 101, 1, 6, 185, 140, 153, 221, 163, 200, 112, 161, 11, 138, 163, 7, 71, 182, 127, 144, 192, 147, 169, 124, 54, 220, 208, 253, 121, 80, 41, 4, 97, 51, 129, 32, 228, 40, 227, 89, 226, 152, 51, 24, 105, 233, 140, 153, 114, 142, 244, 105, 13, 201, 150, 39, 192, 101, 50, 39, 57, 59, 110, 88, 201, 150, 221, 251, 248, 247, 250, 33, 114, 125, 200, 182, 163, 176 };
|
||||||
|
byte[] cpriv = new byte[] { 10,128,76,30};
|
||||||
|
|
||||||
//PcapParser.PcapParser.Instance.Parse("first_instant_join.json");
|
byte[] res = DiffieHellman.Instance.CalculateKey(spub, cpriv);
|
||||||
//PlayerInfo pcapPlayerInfo = (PlayerInfo)PcapParser.PcapParser.Instance.GetPcapPacket(NetMsgId.player_data_succeed_ack);
|
|
||||||
|
|
||||||
//PlayerInfo playerInfoResponse = new PlayerInfo()
|
Utils.PrintByteArray(res);
|
||||||
//{
|
|
||||||
// Acc = pcapPlayerInfo.Acc
|
|
||||||
//};
|
|
||||||
|
|
||||||
//Packet responsePacket = (Packet)Packet.Create(NetMsgId.player_data_succeed_ack, playerInfoResponse);
|
|
||||||
// maybe just change invoke to return Packet
|
|
||||||
|
|
||||||
//Log.Information($"Response Packet msgid: {responsePacket.msgId}: {(short)responsePacket.msgId}");
|
|
||||||
|
|
||||||
//byte[] responsePackeBytes = HttpNetworkManager.Instance.BuildResponse(responsePacket);
|
|
||||||
|
|
||||||
//Log.Information("Sending player_new_notify packet: " + JsonSerializer.Serialize(playerInfoResponse));
|
|
||||||
|
|
||||||
|
|
||||||
//byte[] msg = new byte[] { 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 232, 13, 20, 241, 195, 53, 16, 138, 92, 58, 13, 230, 14, 119, 182, 230, 176, 64, 62, 155, 236, 97, 245, 1, 174, 23, 193, 236, 234, 144, 239, 35, 81, 123, 139, 14, 210, 111, 95, 34, 189, 41, 249, 84, 15, 148, 108, 132, 84, 145, 10, 49, 248, 185, 159, 200, 159, 109, 209, 96, 226, 56, 130, 86, 2, 157, 30, 225, 221, 44, 35, 26, 240, 23, 250, 248, 149, 129, 42, 123, 73, 38, 145, 178, 23, 33, 211, 20, 155, 92, 12, 210, 9, 4, 137, 139, 32, 9, 95, 48, 174, 99, 132, 63, 118, 60, 244, 92, 85, 182, 38, 188, 205, 89, 23, 233, 35, 124, 110, 110, 236, 99, 216, 83, 250, 82, 184, 197, 149, 210, 205, 200, 214, 126, 40, 79, 122, 125, 225, 110, 108, 152, 164, 70, 114, 237, 100, 164, 156, 0, 231, 96, 42, 186, 136, 92, 26, 145, 166, 120, 56, 114, 6, 255, 130, 252, 98, 0, 48, 119, 51, 76, 145, 203, 84, 27, 200, 106, 76, 152, 12, 193, 118, 211, 15, 114, 250, 32, 218, 188, 126, 5, 19, 208, 83, 7, 39, 78, 70, 146, 146, 255, 74, 224, 247, 210, 93, 50, 28, 176, 114, 237, 187, 6, 166, 104, 252, 157, 187, 223, 208, 7, 253, 95, 245, 211, 63, 201, 233, 106, 12, 9, 176, 122, 204, 32, 198, 154, 219, 175, 32, 220, 97, 244, 123, 224, 143, 167, 131, 222, 199, 205, 76, 102, 130, 13, 65, 221, 52, 117, 155, 33, 80, 23, 177, 171, 245, 65, 102, 113, 180, 87, 78, 132, 163, 152, 75, 99, 41, 231, 250, 255, 18, 44, 227, 250, 217, 164, 90, 205, 95, 42, 115, 195, 201, 77, 147, 193, 208, 171, 244, 75, 193, 70, 81, 48, 12, 223, 40, 74, 167, 78, 130, 239, 85, 127, 175, 180, 223, 74, 50, 50, 29, 40, 72, 9, 201, 187, 249, 216, 206, 157, 206, 237, 238, 124, 247, 215 };
|
|
||||||
|
|
||||||
//HttpNetworkManager.Instance.ParseRequest(msg);
|
|
||||||
|
|
||||||
|
|
||||||
//return;
|
|
||||||
Log.Information("Starting SDK Server...");
|
Log.Information("Starting SDK Server...");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
298
Novaria.SDKServer/packets.json
Normal file
298
Novaria.SDKServer/packets.json
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user