Skip to content

Commit

Permalink
update to playable state (some stuff still missing but playable)
Browse files Browse the repository at this point in the history
  • Loading branch information
SlejmUr committed Sep 28, 2024
1 parent 15314e3 commit bb73693
Show file tree
Hide file tree
Showing 56 changed files with 85,232 additions and 112,339 deletions.
6 changes: 3 additions & 3 deletions DS_Server/DS_Server.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<OutputType>Exe</OutputType>
Expand All @@ -10,8 +10,8 @@

<ItemGroup>
<PackageReference Include="L" Version="5.0.0" />
<PackageReference Include="ModdableWebServer" Version="1.1.0.1" />
<PackageReference Include="NetCoreServer" Version="7.0.0" />
<PackageReference Include="ModdableWebServer" Version="1.5.0" />
<PackageReference Include="NetCoreServer" Version="8.0.7" />
</ItemGroup>

<ItemGroup>
Expand Down
51 changes: 51 additions & 0 deletions JsonRequester/Auth.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using RestSharp;
using SaveGetter;
using Steamworks;

namespace JsonRequester
{
public static class Auth
{
public static LoginToken LoginToken;
public static void AddDefault(this RestClient client)
{
client.AddDefaultHeader("Authorization", "Bearer " + LoginToken.AccessToken);
client.AddDefaultHeader("Cookie", $"access_token={LoginToken.AccessToken};refresh_token={LoginToken.RefreshToken}");
client.AddDefaultHeader("Namespace", LoginToken.Namespace);
client.AddDefaultHeader("Accept-Encoding", "deflate, gzip");
client.AddDefaultHeader("Content-Type", "application/json");
client.AddDefaultHeader("Accept", "application/json");
client.AddDefaultHeader("Game-Client-Version", "1.0.0.0");
client.AddDefaultHeader("AccelByte-SDK-Version", "24.7.2");
client.AddDefaultHeader("AccelByte-OSS-Version", "0.12.1-2");
client.AddDefaultHeader("User-Agent", "PAYDAY3/++UE4+Release-4.27-CL-0 Windows/10.0.19045.1.256.64bit");
}

public static void Init()
{

if (!SteamAPI.Init())
{
Console.WriteLine("Steam not running, make sure it is running in the background!");
Environment.Exit(0);
}
byte[] buffer = new byte[1024];
_ = SteamUser.GetAuthSessionTicket(buffer, 1024, out uint tikcet);
var Token = BitConverter.ToString(buffer[..(int)tikcet]).Replace("-", string.Empty);
LoginToken = DoAuth(Token);

Check warning on line 35 in JsonRequester/Auth.cs

View workflow job for this annotation

GitHub Actions / .NET on windows-latest (Release)

Possible null reference assignment.

Check warning on line 35 in JsonRequester/Auth.cs

View workflow job for this annotation

GitHub Actions / .NET on ubuntu-latest (Release)

Possible null reference assignment.
}


public static LoginToken? DoAuth(string Token)
{
var client = new RestClient(Consts.URL + "/iam/v3/oauth/platforms/steam/token");
client.AddDefaultHeader("Authorization", "Basic MGIzYmZkZjVhMjVmNDUyZmJkMzNhMzYxMzNhMmRlYWI6");
client.AddDefaultHeader("Namespace", "pd3");
client.AddDefaultHeader("Content-Type", "application/x-www-form-urlencoded");
var request = new RestRequest();
request.AddBody($"platform_token={Token}");
return Rest.Post<LoginToken>(client, request);
}

}
}
9 changes: 9 additions & 0 deletions JsonRequester/Consts.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace JsonRequester;

public static class Consts
{

public static string NameSpace = "pd3";
public static string AuthB64 = "MGIzYmZkZjVhMjVmNDUyZmJkMzNhMzYxMzNhMmRlYWI6";
public static string URL = "https://nebula.starbreeze.com";
}
24 changes: 24 additions & 0 deletions JsonRequester/JsonRequester.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="RestSharp" Version="112.0.0" />
<PackageReference Include="Steamworks.NET" Version="20.1.0" />
</ItemGroup>

<ItemGroup>
<None Update="steam_api64.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="steam_appid.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
66 changes: 66 additions & 0 deletions JsonRequester/LoginTokenJson.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using Newtonsoft.Json;

namespace SaveGetter
{
public class LoginToken
{
[JsonProperty("access_token")]
public string AccessToken { get; set; }

[JsonProperty("bans")]
public List<object> Bans { get; set; }

[JsonProperty("display_name")]
public string DisplayName { get; set; }

[JsonProperty("expires_in")]
public long ExpiresIn { get; set; }

[JsonProperty("is_comply")]
public bool IsComply { get; set; }

[JsonProperty("jflgs")]
public long Jflgs { get; set; }

[JsonProperty("namespace")]
public string Namespace { get; set; }

[JsonProperty("namespace_roles")]
public List<NamespaceRole> NamespaceRoles { get; set; }

[JsonProperty("permissions")]
public List<object> Permissions { get; set; }

[JsonProperty("platform_id")]
public string PlatformId { get; set; }

[JsonProperty("platform_user_id")]
public string PlatformUserId { get; set; }

[JsonProperty("refresh_expires_in")]
public long RefreshExpiresIn { get; set; }

[JsonProperty("refresh_token")]
public string RefreshToken { get; set; }

[JsonProperty("roles")]
public List<string> Roles { get; set; }

[JsonProperty("scope")]
public string Scope { get; set; }

[JsonProperty("token_type")]
public string TokenType { get; set; }

[JsonProperty("user_id")]
public string UserId { get; set; }
}
public partial class NamespaceRole
{
[JsonProperty("roleId")]
public string RoleId { get; set; }

[JsonProperty("namespace")]
public string Namespace { get; set; }
}
}
161 changes: 161 additions & 0 deletions JsonRequester/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Security.Cryptography;

namespace JsonRequester
{
internal class Program
{
static void Main(string[] args)
{
Directory.CreateDirectory("rsp");
Console.WriteLine("Hello, World!");
Auth.Init();
//_ = JsonConvert.SerializeObject(Auth.LoginToken);
SaveToFileResponse("/cloudsave/v1/namespaces/pd3/records/feature-toggle", "FeatureToggle");
SaveToFileResponse("/cloudsave/v1/namespaces/pd3/records/matchmaking", "Matchmaking");
SaveToFileResponse("/cloudsave/v1/namespaces/pd3/records/edgegap_beacons", "EdgeGapBeacons");
SaveToFileResponse("/cloudsave/v1/namespaces/pd3/records/title-data", "TitleData");
SaveToFileResponse("/cloudsave/v1/namespaces/pd3/records/infamy-translation-table", "InfamyTranslationTable");
SaveToFileResponse("/cloudsave/v1/namespaces/pd3/records/meta-events", "MetaEvents");
SaveToFileResponse("/cloudsave/v1/namespaces/pd3/records/time-based-player-content", "TimeBasedPlayerContent");
SaveToFileResponse("/cloudsave/v1/namespaces/pd3/records/dlc-entitlements", "DLC_Entitlements");
SaveToFileResponse("/cloudsave/v1/namespaces/pd3/records/client-configuration", "ClientConfiguration", false);
SaveToFileResponse("/cloudsave/v1/namespaces/pd3/records/challenge-recommendations", "ChallengeRecommendations", false);
SaveToFileResponse("/cloudsave/v1/namespaces/pd3/records/challenge-dailies", "ChallengeDailies");
SaveToFileResponse("/cloudsave/v1/namespaces/pd3/records/security-firm-rotation", "SecurityFirmRotation");
SaveToFileResponse("/cloudsave/v1/namespaces/pd3/records/reward-reduction", "rewardreduction");
SaveToFileResponse("/cloudsave/v1/namespaces/pd3/records/level-reward-diamonddistrict", "levelreward_diamonddistrict");
SaveToFileResponse("/cloudsave/v1/namespaces/pd3/records/level-reward-branchbank", "levelreward_branchbank");
/*
foreach (var item in bulk_items)
{
SaveToFileResponse(Requests.GetBulkRecords(item), $"Bulk_{item}");
}*/

SaveToFileResponse("/platform/public/namespaces/pd3/items/byCriteria?limit=2147483647&includeSubCategoryItem=false", "Items_NoSub");
SaveToFileResponse("/platform/public/namespaces/pd3/items/byCriteria?limit=2147483647&includeSubCategoryItem=true", "Items_WithSub");
SaveToFileResponse($"/platform/public/namespaces/pd3/users/{Auth.LoginToken.UserId}/entitlements?limit=2147483647", "Entitlements", false);
SaveToFileResponse($"/social/v1/public/namespaces/pd3/users/{Auth.LoginToken.UserId}/statitems?limit=100000", "Statitems");
SaveToFileResponse($"/cloudsave/v1/namespaces/pd3/records/challenges?limit=2147483647", "ChallengeRecords");
SaveToFileResponse($"/cloudsave/v1/namespaces/pd3/users/{Auth.LoginToken.UserId}/records/challenges", "CloudSave_Challenges", false);

Console.ReadLine();
List<UserStatItemsData> mainstat = JsonConvert.DeserializeObject<List<UserStatItemsData>>(File.ReadAllText("StatItems_pd3.json"));

Check warning on line 44 in JsonRequester/Program.cs

View workflow job for this annotation

GitHub Actions / .NET on windows-latest (Release)

Converting null literal or possible null value to non-nullable type.

Check warning on line 44 in JsonRequester/Program.cs

View workflow job for this annotation

GitHub Actions / .NET on ubuntu-latest (Release)

Converting null literal or possible null value to non-nullable type.


List<UserStatItemsData> secondary = JsonConvert.DeserializeObject<List<UserStatItemsData>>(File.ReadAllText("Statitems.json"));

var missing = secondary.Where(x=> !mainstat.Any(y=> y.StatCode == x.StatCode)).ToList();
File.WriteAllText("missing_stats.json", JsonConvert.SerializeObject(missing));
var time = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ");
foreach (var item in missing)
{
item.Value = 0;
item.UpdatedAt = time;
item.UserId = "UserId";
item.Tags = null;
mainstat.Add(item);
}
File.WriteAllText("StatItems_pd3.json", JsonConvert.SerializeObject(mainstat, Formatting.Indented));
Console.WriteLine("Done");
Console.ReadLine();
}


static void SaveToFileResponse(string url_end, string filename, bool clean = true)
{
var rsp = Requests.GetResponse(url_end);
if (rsp == null)
{
Console.WriteLine("Response doesnt seem to be right: " + url_end);
return;
}
if (clean)
rsp = RemoveUserIdAndTimeClean(rsp);
File.WriteAllText("rsp/" + filename + ".json", JsonConvert.SerializeObject(rsp, Formatting.Indented));
}

static void SaveToFileResponse(JObject? jobject, string filename)
{
if (jobject == null)
{
Console.WriteLine("Response doesnt seem to be right: " + filename);
return;
}
jobject = RemoveUserIdAndTimeClean(jobject);
File.WriteAllText("rsp/" + filename + ".json", JsonConvert.SerializeObject(jobject, Formatting.Indented));
}

static JObject RemoveUserIdAndTimeClean(JObject obj)
{
if (obj.ContainsKey("userId"))
{
obj["userId"] = "REPLACEME";
}
if (obj.ContainsKey("updatedAt"))
{
obj["updatedAt"] = "updatedattomakegitdiffseasiertoread";
}
if (obj.ContainsKey("updated_at"))
{
obj["updated_at"] = "updatedattomakegitdiffseasiertoread";
}
foreach (var item in obj)
{
if (item.Value != null)
checktoken(item.Value);

}
return obj;
}

static JToken checktoken(JToken token)
{
if (token.Type == JTokenType.Object)
{
token = RemoveUserIdAndTimeClean((JObject)token);
}
if (token.Type == JTokenType.Array)
{
var array = ((JArray)token).ToArray();
for (int j = 0; j < array.Length; j++)
{
array[j] = checktoken(array[j]);
}
}
return token;
}

static List<string> bulk_items = [
"weapon-translation-table-assaultrifle-car4",
"weapon-translation-table-shotgun-r880",
"weapon-translation-table-marksman-r900s",
"weapon-translation-table-smg-compact7",
"weapon-translation-table-assaultrifle-ku59",
"weapon-translation-table-smg-commando",
"weapon-translation-table-marksman-a114",
"weapon-translation-table-smg-pc9",
"weapon-translation-table-assaultrifle-nwb9",
"weapon-translation-table-shotgun-mosconi12c",
"weapon-translation-table-assaultrifle-vf7s",
"weapon-translation-table-shotgun-fsa12",
"weapon-translation-table-smg-war45",
"weapon-translation-table-marksman-fik22",
"weapon-translation-table-assaultrifle-rg5",
"weapon-translation-table-smg-atk7",
"weapon-translation-table-lmg-mx63",
"weapon-translation-table-assaultrifle-chs3",
"weapon-translation-table-shotgun-m7p",
"weapon-translation-table-pistol-s40",
"weapon-translation-table-revolver-castigo44",
"weapon-translation-table-pistol-stryk7",
"weapon-translation-table-pistol-spm11",
"weapon-translation-table-pistol-s403",
"weapon-translation-table-revolver-bison",
"weapon-translation-table-revolver-bullkick500",
"weapon-translation-table-pistol-t32",
"weapon-translation-table-pistol-pd5"
];
}
}
36 changes: 36 additions & 0 deletions JsonRequester/Requests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Newtonsoft.Json.Linq;
using RestSharp;

namespace JsonRequester
{
internal class Requests
{

public static JObject? GetResponse(string url_end)
{
var client = new RestClient(Consts.URL + url_end);
client.AddDefault();
return Rest.Get(client, new RestRequest());
}


public static JObject? PostResponse(string url_end, string json)
{
var client = new RestClient(Consts.URL + url_end);
client.AddDefault();
var req = new RestRequest();
req.AddBody(json);
return Rest.Post(client, req);
}


public static JObject? GetBulkRecords(string data)
{
var client = new RestClient(Consts.URL + "/cloudsave/v1/namespaces/pd3/records/bulk");
client.AddDefault();
var req = new RestRequest();
req.AddBody("{\"keys\":[\"" + data + "\"]}");
return Rest.Post(client, req);
}
}
}
Loading

0 comments on commit bb73693

Please sign in to comment.