Skip to content

Commit

Permalink
Save Getter
Browse files Browse the repository at this point in the history
  • Loading branch information
SlejmUr committed Jan 31, 2024
1 parent 365249d commit 2b11b2f
Show file tree
Hide file tree
Showing 7 changed files with 185 additions and 4 deletions.
8 changes: 7 additions & 1 deletion PayCheck3.sln
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.editorconfig = .editorconfig
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DS_Server", "DS_Server\DS_Server.csproj", "{ECDB0271-5226-4381-9460-2D550F4B4D4B}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DS_Server", "DS_Server\DS_Server.csproj", "{ECDB0271-5226-4381-9460-2D550F4B4D4B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SaveGetter", "SaveGetter\SaveGetter.csproj", "{A40D3EF0-D4B0-468A-85C6-6A92719E0497}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -32,6 +34,10 @@ Global
{ECDB0271-5226-4381-9460-2D550F4B4D4B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ECDB0271-5226-4381-9460-2D550F4B4D4B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ECDB0271-5226-4381-9460-2D550F4B4D4B}.Release|Any CPU.Build.0 = Release|Any CPU
{A40D3EF0-D4B0-468A-85C6-6A92719E0497}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A40D3EF0-D4B0-468A-85C6-6A92719E0497}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A40D3EF0-D4B0-468A-85C6-6A92719E0497}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A40D3EF0-D4B0-468A-85C6-6A92719E0497}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
3 changes: 0 additions & 3 deletions PayCheckServerLib/PayCheckServerLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,4 @@
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="git branch --show-current &gt; &quot;$(ProjectDir)/Properties/BuildDate.txt&quot;&#xD;&#xA;echo $([System.DateTime]::UtcNow.ToString(&quot;s&quot;))&gt;&gt; &quot;$(ProjectDir)/Properties/BuildDate.txt&quot;&#xD;&#xA;git rev-parse --short HEAD &gt;&gt; &quot;$(ProjectDir)/Properties/BuildDate.txt&quot;" />
</Target>

<ProjectExtensions><VisualStudio><UserProperties config_1json__JsonSchema="" files_4basicinfamytable_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>

</Project>
66 changes: 66 additions & 0 deletions SaveGetter/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; }
}
}
87 changes: 87 additions & 0 deletions SaveGetter/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
using Newtonsoft.Json;
using Steamworks;

namespace SaveGetter
{
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("Getting your save!");

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);
//Console.WriteLine(Token);
var token = Auth(Token);
GetSave(token);
Exit();
}

static LoginToken Auth(string Token)
{
HttpClient client = new HttpClient();
client.BaseAddress = new Uri("https://nebula.starbreeze.com");

var formvalues = new Dictionary<string, string>
{
{ "platform_token", Token }
};
var content = new FormUrlEncodedContent(formvalues);
//client.DefaultRequestHeaders.Add("Content-Type", "application/x-www-form-urlencoded");
client.DefaultRequestHeaders.Add("Authorization", "Basic MGIzYmZkZjVhMjVmNDUyZmJkMzNhMzYxMzNhMmRlYWI6");
client.DefaultRequestHeaders.Add("Namespace", "pd3");
var resp = client.PostAsync("/iam/v3/oauth/platforms/steam/token", content).Result;
if (resp.StatusCode == System.Net.HttpStatusCode.OK)
{
Console.WriteLine("SUCCESS! Got your Login Tokens");
var json = JsonConvert.DeserializeObject<LoginToken>(resp.Content.ReadAsStringAsync().Result);
//Console.WriteLine(JsonConvert.SerializeObject(json));
return json;

Check warning on line 45 in SaveGetter/Program.cs

View workflow job for this annotation

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

Possible null reference return.

Check warning on line 45 in SaveGetter/Program.cs

View workflow job for this annotation

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

Possible null reference return.

Check warning on line 45 in SaveGetter/Program.cs

View workflow job for this annotation

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

Possible null reference return.

Check warning on line 45 in SaveGetter/Program.cs

View workflow job for this annotation

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

Possible null reference return.
}
else
{
Console.WriteLine("Error!");
Console.WriteLine(resp.StatusCode);
Console.WriteLine(resp.Content.ReadAsStringAsync().Result);
Exit();
return null;

Check warning on line 53 in SaveGetter/Program.cs

View workflow job for this annotation

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

Possible null reference return.

Check warning on line 53 in SaveGetter/Program.cs

View workflow job for this annotation

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

Possible null reference return.

Check warning on line 53 in SaveGetter/Program.cs

View workflow job for this annotation

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

Possible null reference return.

Check warning on line 53 in SaveGetter/Program.cs

View workflow job for this annotation

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

Possible null reference return.
}
}

static void GetSave(LoginToken token)
{
string save = "cloudsave/v1/namespaces/__namespace__/users/__userId__/records/progressionsavegame";
HttpClient client = new HttpClient();
client.BaseAddress = new Uri("https://nebula.starbreeze.com");
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + token.AccessToken);
client.DefaultRequestHeaders.Add("Cookie", $"access_token={token.AccessToken};refresh_token={token.RefreshToken}");
client.DefaultRequestHeaders.Add("Namespace", token.Namespace);

var result = client.GetAsync(save.Replace("__namespace__", token.Namespace).Replace("__userId__", token.UserId)).Result;

if (result.StatusCode == System.Net.HttpStatusCode.OK)
{
Console.WriteLine("SUCCESS! Your save saved!");
File.WriteAllText($"{token.UserId}.save.txt", result.Content.ReadAsStringAsync().Result);
}
else
{
Console.WriteLine("Error!");
Exit();
}
}

static void Exit()
{
Console.WriteLine("Quitting..");
SteamAPI.Shutdown();
Environment.Exit(0);
}
}
}
24 changes: 24 additions & 0 deletions SaveGetter/SaveGetter.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="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>
Binary file added SaveGetter/steam_api64.dll
Binary file not shown.
1 change: 1 addition & 0 deletions SaveGetter/steam_appid.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1272080

0 comments on commit 2b11b2f

Please sign in to comment.