Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sentry file ignored — possible cause #122

Open
Delicious-Bacon opened this issue Sep 22, 2021 · 2 comments
Open

Sentry file ignored — possible cause #122

Delicious-Bacon opened this issue Sep 22, 2021 · 2 comments

Comments

@Delicious-Bacon
Copy link

I use Steam Guard 2FA and I can't solve this one.

Right now, the sentry file is ignored on subsequent login attempts, and I'm always asked for the 2FA. Here are some observations on the code.

An observation on the gsbot's Auth type HandleEvent method:

func (a *Auth) HandleEvent(event interface{}) {
	switch e := event.(type) {
	case *steam.MachineAuthUpdateEvent:
		a.machineAuthHash = e.Hash
		err := ioutil.WriteFile(a.sentryPath, e.Hash, 0666)
		if err != nil {
			panic(err)
		}
	}
}

It never informs Steam servers of accepting the Sentry file.

An observation on SteamKit's MachineAuthUpdateEvent:

        static void OnMachineAuth( SteamUser.UpdateMachineAuthCallback callback )
        {
            Console.WriteLine( "Updating sentryfile..." );

            // write out our sentry file
            // ideally we'd want to write to the filename specified in the callback
            // but then this sample would require more code to find the correct sentry file to read during logon
            // for the sake of simplicity, we'll just use "sentry.bin"

            int fileSize;
            byte[] sentryHash;
            using ( var fs = File.Open( "sentry.bin", FileMode.OpenOrCreate, FileAccess.ReadWrite ) )
            {
                fs.Seek( callback.Offset, SeekOrigin.Begin );
                fs.Write( callback.Data, 0, callback.BytesToWrite );
                fileSize = ( int )fs.Length;

                fs.Seek( 0, SeekOrigin.Begin );
                using ( var sha = SHA1.Create() )
                {
                    sentryHash = sha.ComputeHash( fs );
                }
            }

            // inform the steam servers that we're accepting this sentry file
            steamUser.SendMachineAuthResponse( new SteamUser.MachineAuthDetails
            {
                JobID = callback.JobID,

                FileName = callback.FileName,

                BytesWritten = callback.BytesToWrite,
                FileSize = fileSize,
                Offset = callback.Offset,

                Result = EResult.OK,
                LastError = 0,

                OneTimePassword = callback.OneTimePassword,

                SentryFileHash = sentryHash,
            } );

            Console.WriteLine( "Done!" );
        }

It informs Steam servers of accepting the sentry file.
Source: SteamKit SteamGuard example

@Philipp15b
Copy link
Owner

You're right! It seems that gsbot.go needs to send a response that it accepts the sentry file. I'm happy to accept pull requests for this.

@Delicious-Bacon
Copy link
Author

Do you know which fields would correspond to JobID, BytesWritten, EResult.OK to write back to Steam?

I'm also having errors when requesting the sentry file for the first time - the client immediately logs off after writing the request for sentry file:

sc.Write(
    protocol.NewClientMsgProtobuf(
        steamlang.EMsg_ClientUpdateMachineAuth,
        &protobuf.CMsgClientRequestMachineAuth{}, // Tried setting MachineName and FileName
    ),
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants