-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathConfiguration.cs
105 lines (90 loc) · 3.25 KB
/
Configuration.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Threading.Tasks;
using Spectre.Console;
namespace SteamTokenDumper;
internal sealed class Configuration
{
public bool RememberLogin { get; private set; }
public bool SkipAutoGrant { get; private set; }
public bool VerifyBeforeSubmit { get; private set; } = true;
public bool UserConsentBeforeRun { get; private set; } = true;
public bool DumpPayload { get; private set; }
public bool Debug { get; private set; }
public HashSet<uint> SkipApps { get; } = [];
public async Task Load()
{
var path = Path.Combine(Program.AppPath, "SteamTokenDumper.config.ini");
var lines = await File.ReadAllLinesAsync(path);
foreach (var line in lines)
{
if (string.IsNullOrWhiteSpace(line) || line[0] == ';')
{
continue;
}
var option = line.Split('=', 2, StringSplitOptions.TrimEntries);
if (option.Length != 2)
{
continue;
}
switch (option[0])
{
case "RememberLogin":
RememberLogin = option[1] == "1";
break;
case "SkipAutoGrant":
SkipAutoGrant = option[1] == "1";
break;
case "UserConsentBeforeRun":
UserConsentBeforeRun = option[1] == "1";
break;
case "VerifyBeforeSubmit":
VerifyBeforeSubmit = option[1] == "1";
break;
case "DumpPayload":
DumpPayload = option[1] == "1";
break;
case "Debug":
Debug = option[1] == "1";
break;
case "SkipAppIds":
var ids = option[1].Split(',', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries);
foreach (var id in ids)
{
if (!uint.TryParse(id, CultureInfo.InvariantCulture, out var appid))
{
AnsiConsole.MarkupLineInterpolated($"[red]Id '{id}' in 'SkipAppIds' is not a positive integer.[/]");
continue;
}
SkipApps.Add(appid);
}
break;
default:
AnsiConsole.MarkupLineInterpolated($"[red]Unknown option '{option[0]}'[/]");
break;
}
}
if (RememberLogin)
{
AnsiConsole.WriteLine("Will remember your login.");
}
if (SkipAutoGrant)
{
AnsiConsole.WriteLine("Will skip auto granted packages.");
}
if (DumpPayload)
{
AnsiConsole.WriteLine("Will dump payload.");
}
if (!VerifyBeforeSubmit)
{
AnsiConsole.WriteLine("Will not ask for confirmation before sending results.");
}
if (SkipApps.Count > 0)
{
AnsiConsole.MarkupLine($"Will skip these appids: [yellow]{string.Join(", ", SkipApps)}[/]");
}
}
}