Skip to content

Commit

Permalink
Update Custom Machine Auth
Browse files Browse the repository at this point in the history
  • Loading branch information
oureveryday committed Jul 26, 2022
1 parent baa342e commit 6c715c8
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 17 deletions.
28 changes: 26 additions & 2 deletions DepotDownloaderMod/ContentDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -362,16 +362,40 @@ public static bool InitializeSteam3(string username, string password)
_ = AccountSettingsStore.Instance.LoginKeys.TryGetValue(username, out loginKey);
}

steam3 = new Steam3Session(

if (TokenCFG.useMachineAuth)
{
var sentryFileHash = CryptoHelper.SHAHash(File.ReadAllBytes(TokenCFG.MachineAuth));
var machineAuthFileName = Path.GetFileName(TokenCFG.MachineAuth);
Console.WriteLine("Using Machine Auth: {0}", machineAuthFileName);
steam3 = new Steam3Session(
new SteamUser.LogOnDetails
{
SentryFileHash = sentryFileHash,
Username = username,
Password = loginKey == null ? password : null,
ShouldRememberPassword = Config.RememberPassword,
LoginKey = loginKey,
LoginID = Config.LoginID ?? 0x534B32, // "SK2"
}
);
);
}
else
{
steam3 = new Steam3Session(
new SteamUser.LogOnDetails
{
Username = username,
Password = loginKey == null ? password : null,
ShouldRememberPassword = Config.RememberPassword,
LoginKey = loginKey,
LoginID = Config.LoginID ?? 0x534B32, // "SK2"
}
);
}




steam3Credentials = steam3.WaitForCredentials();

Expand Down
8 changes: 7 additions & 1 deletion DepotDownloaderMod/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ static class TokenCFG
{
public static bool useAppToken;
public static bool usePackageToken;
public static bool useMachineAuth;
public static ulong appToken;
public static ulong packageToken;
public static string MachineAuth;
}
class Program
{

static int Main(string[] args)
=> MainAsync(args).GetAwaiter().GetResult();

Expand Down Expand Up @@ -60,6 +62,9 @@ static async Task<int> MainAsync(string[] args)
TokenCFG.usePackageToken = HasParameter(args, "-packagetoken");
TokenCFG.appToken = Convert.ToUInt64(GetParameter<string>(args, "-apptoken"));
TokenCFG.packageToken = Convert.ToUInt64(GetParameter<string>(args, "-packagetoken"));
TokenCFG.useMachineAuth = HasParameter(args, "-machineauth");
TokenCFG.MachineAuth = GetParameter<string>(args, "-machineauth");
TokenCFG.MachineAuth = GetParameter<string>(args, "-machineauth");


ContentDownloader.Config.RememberPassword = HasParameter(args, "-remember-password");
Expand Down Expand Up @@ -430,6 +435,7 @@ static void PrintUsage()
Console.WriteLine("\t-depotkeys <depotkeysfile>\t- a list of depot keys to use ('depotID;hexKey' per line)");
Console.WriteLine("\t-apptoken <apptoken>\t- Use Specified App Access Token");
Console.WriteLine("\t-packagetoken <packagetoken>\t- Use Specified Package Access Token");
Console.WriteLine("\t-machineauth <ssfnpath>\t- Use Specified ssfn Machine Auth File");
Console.WriteLine();
Console.WriteLine("\t-dir <installdir>\t\t- the directory in which to place downloaded files.");
Console.WriteLine("\t-filelist <file.txt>\t- a list of files to download (from the manifest). Prefix file path with 'regex:' if you want to match with regex.");
Expand Down
7 changes: 7 additions & 0 deletions DepotDownloaderMod/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"profiles": {
"DepotDownloaderMod": {
"commandName": "Project"
}
}
}
23 changes: 9 additions & 14 deletions DepotDownloaderMod/Steam3Session.cs
Original file line number Diff line number Diff line change
Expand Up @@ -581,27 +581,21 @@ private void DisconnectedCallback(SteamClient.DisconnectedCallback disconnected)

private void LogOnCallback(SteamUser.LoggedOnCallback loggedOn)
{

var isSteamGuard = loggedOn.Result == EResult.AccountLogonDenied;
var is2FA = loggedOn.Result == EResult.AccountLoginDeniedNeedTwoFactor;
var isLoginKey = ContentDownloader.Config.RememberPassword && logonDetails.LoginKey != null && loggedOn.Result == EResult.InvalidPassword;

if (isSteamGuard || is2FA || isLoginKey)
{
bExpectingDisconnectRemote = true;
Abort(false);

if (!isLoginKey)
{
Console.WriteLine("This account is protected by Steam Guard.");
}

if (is2FA)
{
do
{
Console.Write("Please enter your 2 factor auth code from your authenticator app: ");
logonDetails.TwoFactorCode = Console.ReadLine();
} while (String.Empty == logonDetails.TwoFactorCode);
Console.WriteLine("2FA needed.");
}
else if (isLoginKey)
{
Expand All @@ -623,19 +617,14 @@ private void LogOnCallback(SteamUser.LoggedOnCallback loggedOn)
}
else
{
do
{
Console.Write("Please enter the authentication code sent to your email address: ");
logonDetails.AuthCode = Console.ReadLine();
} while (string.Empty == logonDetails.AuthCode);
Console.WriteLine("Auth Code needed.");
}

Console.Write("Retrying Steam3 connection...");
Connect();

return;
}

if (loggedOn.Result == EResult.TryAnotherCM)
{
Console.Write("Retrying Steam3 connection (TryAnotherCM)...");
Expand Down Expand Up @@ -675,8 +664,12 @@ private void LogOnCallback(SteamUser.LoggedOnCallback loggedOn)

private void SessionTokenCallback(SteamUser.SessionTokenCallback sessionToken)
{

Console.WriteLine("Got session token!");
credentials.SessionToken = sessionToken.SessionToken;



}

private void LicenseListCallback(SteamApps.LicenseListCallback licenseList)
Expand All @@ -703,6 +696,8 @@ private void LicenseListCallback(SteamApps.LicenseListCallback licenseList)

private void UpdateMachineAuthCallback(SteamUser.UpdateMachineAuthCallback machineAuth)
{


var hash = Util.SHAHash(machineAuth.Data);
Console.WriteLine("Got Machine Auth: {0} {1} {2} {3}", machineAuth.FileName, machineAuth.Offset, machineAuth.BytesToWrite, machineAuth.Data.Length, hash);

Expand Down

0 comments on commit 6c715c8

Please sign in to comment.