crypto attempts

This commit is contained in:
raphaeIl
2025-01-11 02:24:07 -05:00
parent 55c3fc1fec
commit 0b12a29289
18 changed files with 6810 additions and 41 deletions

View File

@@ -0,0 +1,104 @@
using Microsoft.AspNetCore.Mvc;
using Novaria.Common.Crypto;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Text.Json;
using System.Text;
using Serilog;
using Novaria.Common.Utils;
using System.IO;
using System.Numerics;
using System.Security.Cryptography;
namespace Novaria.SDKServer.Controllers.Api
{
[Route("/agent-zone-1")]
public class GatewayController : ControllerBase
{
public int req_count;
[HttpPost]
public IActionResult PostRequest()
{
//var memoryStream = new MemoryStream();
//Request.Body.CopyTo(memoryStream);
//byte[] requestBodyBytes = memoryStream.ToArray();
//Log.Information("Received Gateway Post Request, Payload: ");
//Utils.PrintByteArray(requestBodyBytes);
Response.Headers.Add("Date", DateTime.UtcNow.ToString("R"));
Response.Headers.Add("Content-Length", "171");
Response.Headers.Add("Connection", "keep-alive");
Response.Headers.Append("Set-Cookie", "SERVERID=eef797ff9d3671d413582d7dc2f39f29|1736422941|1736422941;Path=/");
Response.Headers.Append("Set-Cookie", "SERVERCORSID=eef797ff9d3671d413582d7dc2f39f29|1736422941|1736422941;Path=/;SameSite=None;Secure");
string filePath = "E:\\documents\\Decompiling\\Extracted\\NOVA\\Novaria\\Novaria.SDKServer\\response1"; // Replace with the actual file path
if (req_count == 1)
{
filePath = "E:\\documents\\Decompiling\\Extracted\\NOVA\\Novaria\\Novaria.SDKServer\\response2"; // Replace with the actual file path
}
byte[] fileBytes = System.IO.File.ReadAllBytes(filePath);
Response.Body.WriteAsync(fileBytes, 0, fileBytes.Length);
req_count++;
return new EmptyResult();
}
[HttpOptions] // Ike
public IActionResult OptionsRequest()
{
// store key which is used in AeadTool
// Set response headers
Response.Headers.Add("Date", DateTime.UtcNow.ToString("R"));
Response.Headers.Add("Content-Length", "251");
Response.Headers.Add("Connection", "keep-alive");
// Set cookies
Response.Headers.Append("Set-Cookie", "acw_tc=cb6df452e3196d1ec00d2fcdf7726b25ed2accbaa45e1066701a61d2da90b384;path=/;HttpOnly;Max-Age=1800");
Response.Headers.Append("Set-Cookie", "SERVERID=eef797ff9d3671d413582d7dc2f39f29|1736422941|1736422941;Path=/");
Response.Headers.Append("Set-Cookie", "SERVERCORSID=eef797ff9d3671d413582d7dc2f39f29|1736422941|1736422941;Path=/;SameSite=None;Secure");
// Set binary content as the response body
string filePath = "E:\\documents\\Decompiling\\Extracted\\NOVA\\Novaria\\Novaria.SDKServer\\options_response"; // Replace with the actual file path
byte[] fileBytes = System.IO.File.ReadAllBytes(filePath);
// Write bytes directly to response body
Response.Body.WriteAsync(fileBytes, 0, fileBytes.Length);
// Return no content since the body is written manually
return new EmptyResult();
}
//private DiffieHellmanManaged SendKey;
//// put in connection prob
//public static void SetAeadKey(byte[] pubKey) // original lead to HttpNetworkManager
//{
// byte[] array = this.SendKey.DecryptKeyExchange(pubKey);
// int num = array.Length;
// if (num > 32)
// {
// num = 32;
// }
// this.key3 = new byte[32];
// Buffer.BlockCopy(array, 0, this.key3, 0, num);
// this.HasKey3 = true;
// this.seq = 1;
//}
//public byte[] DecryptKeyExchange(byte[] keyEx)
//{
// BigInteger bigInteger = new BigInteger(keyEx).ModPow(this.m_X, this.m_P);
// byte[] bytes = bigInteger.GetBytes();
// bigInteger.Clear();
// return bytes;
//}
}
}

View File

@@ -0,0 +1,35 @@
using Microsoft.AspNetCore.Mvc;
using Serilog;
namespace Novaria.SDKServer.CoNovariaollers
{
[ApiController]
[Route("/health-game")]
public class HealthGameController : ControllerBase
{
[Route("identity-auth")]
public IResult PostIdentityAuth()
{
Log.Information("post login received!");
string jsonResponse = @"
{
""Code"": 200,
""Data"": {
""Identity"": {
""BirthDate"": """",
""IDCard"": ""500*********11861*"",
""PI"": """",
""RealName"": ""*思"",
""State"": 1,
""Type"": 0,
""Underage"": false
}
},
""Msg"": ""OK""
}
";
return Results.Text(jsonResponse, "application/json");
}
}
}

View File

@@ -39,20 +39,6 @@ namespace Novaria.SDKServer.CoNovariaollers
Log.Information("Response bytes:");
return File(response, "text/html");
}
[HttpGet("{*catchAll}")]
public IResult CatchAllGet(string catchAll)
{
Log.Information($"HttpGet: {catchAll}");
return Results.Empty;
}
[HttpPost("{*catchAll}")]
public IResult CatchAllPost(string catchAll)
{
Log.Information($"HttpGet: {catchAll}");
return Results.Empty;
}
}
}

View File

@@ -1,23 +0,0 @@
using Microsoft.AspNetCore.Mvc;
using Serilog;
namespace Novaria.SDKServer.CoNovariaollers
{
[ApiController]
[Route("/user")]
public class SDKController : ControllerBase
{
[Route("login")]
public IResult PostLogin()
{
Log.Information("post login received!");
return Results.Text(@"
{
""Code"": 200,
""Data"": {},
""Msg"": ""夏萝莉是小楠梁""
}
");
}
}
}

View File

@@ -0,0 +1,129 @@
using Microsoft.AspNetCore.Mvc;
using Serilog;
namespace Novaria.SDKServer.CoNovariaollers
{
[ApiController]
[Route("/user")]
public class UserController : ControllerBase
{
[Route("login")]
public IResult PostLogin()
{
Log.Information("post login received!");
string jsonResponse = @"
{
""Code"": 200,
""Data"": {
""IsNew"": true,
""IsTestAccount"": false,
""User"": {
""DestroyState"": 0,
""ID"": 1,
""PID"": ""CN-NOVA"",
""State"": 1,
""Token"": ""f94d936f7235f84493564ee0282e845cccd44828""
}
},
""Msg"": ""OK""
}
";
return Results.Text(jsonResponse, "application/json");
}
[Route("quick-login")]
public IResult PostQuickLogin()
{
Log.Information("post login received!");
string jsonResponse = @"
{
""Code"": 200,
""Data"": {
""Destroy"": {
""DestroyAt"": 0
},
""Identity"": {
""BirthDate"": """",
""IDCard"": ""500*********11861*"",
""PI"": """",
""RealName"": ""*思"",
""State"": 1,
""Type"": 0,
""Underage"": false
},
""IsTestAccount"": false,
""Keys"": [
{
""NickName"": ""123****4567"",
""Type"": ""mobile""
}
],
""User"": {
""DestroyState"": 0,
""ID"": 1,
""PID"": ""CN-NOVA"",
""State"": 1,
""Token"": ""f94d936f7235f84493564ee0282e845cccd44828""
},
""Yostar"": {
""CreatedAt"": 1735902342,
""DefaultNickName"": """",
""ID"": 1,
""NickName"": ""夏萝莉是小楠梁"",
""Picture"": """",
""State"": 1
}
},
""Msg"": ""OK""
}
";
return Results.Text(jsonResponse, "application/json");
}
[Route("detail")]
public IResult PostDetail()
{
string jsonResponse = @"
{
""Code"": 200,
""Data"": {
""Destroy"": {
""DestroyAt"": 0
},
""Identity"": null,
""IsTestAccount"": false,
""Keys"": [
{
""NickName"": ""123****4567"",
""Type"": ""mobile""
}
],
""User"": {
""DestroyState"": 0,
""ID"": 1,
""PID"": ""CN-NOVA"",
""State"": 1,
""Token"": ""f94d936f7235f84493564ee0282e845cccd44828""
},
""Yostar"": {
""CreatedAt"": 1,
""DefaultNickName"": """",
""ID"": 1,
""NickName"": ""夏萝莉是小楠梁"",
""Picture"": """",
""State"": 1
}
},
""Msg"": ""OK""
}
";
return Results.Text(jsonResponse, "application/json");
}
}
}