Exemplo n.º 1
0
        /// <summary>
        /// Logs onto the Steam network as a persistent game server.
        /// The client should already have been connected at this point.
        /// Results are return in a <see cref="SteamUser.LoggedOnCallback"/>.
        /// </summary>
        /// <param name="details">The details to use for logging on.</param>
        /// <exception cref="ArgumentNullException">No logon details were provided.</exception>
        /// <exception cref="ArgumentException">Username or password are not set within <paramref name="details"/>.</exception>
        public void LogOn(LogOnDetails details)
        {
            if (details == null)
            {
                throw new ArgumentNullException("details");
            }

            if (string.IsNullOrEmpty(details.Username) || string.IsNullOrEmpty(details.Password))
            {
                throw new ArgumentException("LogOn requires a username and password to be set in 'details'.");
            }

            var logon = new ClientMsgProtobuf <CMsgClientLogon>(EMsg.ClientLogon);

            SteamID gsId = new SteamID(0, 0, Client.ConnectedUniverse, EAccountType.GameServer);

            logon.ProtoHeader.client_sessionid = 0;
            logon.ProtoHeader.steamid          = gsId.ConvertToUInt64();

            uint localIp = NetHelpers.GetIPAddress(this.Client.LocalIP);

            logon.Body.obfustucated_private_ip = localIp ^ MsgClientLogon.ObfuscationMask;

            logon.Body.protocol_version = MsgClientLogon.CurrentProtocol;

            logon.Body.client_os_type     = ( uint )Utils.GetOSType();
            logon.Body.game_server_app_id = ( int )details.AppID;
            logon.Body.machine_id         = Utils.GenerateMachineID();

            logon.Body.account_name = details.Username;
            logon.Body.password     = details.Password;

            this.Client.Send(logon);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Logs onto the Steam network as a persistent game server.
        /// The client should already have been connected at this point.
        /// Results are return in a <see cref="SteamUser.LoggedOnCallback"/>.
        /// </summary>
        /// <param name="details">The details to use for logging on.</param>
        /// <exception cref="System.ArgumentNullException">No logon details were provided.</exception>
        /// <exception cref="System.ArgumentException">Username or password are not set within <paramref name="details"/>.</exception>
        public void LogOn( LogOnDetails details )
        {
            if ( details == null )
            {
                throw new ArgumentNullException( "details" );
            }

            if ( string.IsNullOrEmpty( details.Username ) || string.IsNullOrEmpty( details.Password ) )
            {
                throw new ArgumentException( "LogOn requires a username and password to be set in 'details'." );
            }

            var logon = new ClientMsgProtobuf<CMsgClientLogon>( EMsg.ClientLogon );

            SteamID gsId = new SteamID( 0, 0, Client.ConnectedUniverse, EAccountType.GameServer );

            logon.ProtoHeader.client_sessionid = 0;
            logon.ProtoHeader.steamid = gsId.ConvertToUInt64();

            uint localIp = NetHelpers.GetIPAddress( this.Client.LocalIP );
            logon.Body.obfustucated_private_ip = localIp ^ MsgClientLogon.ObfuscationMask;

            logon.Body.protocol_version = MsgClientLogon.CurrentProtocol;

            logon.Body.client_os_type = ( uint )Utils.GetOSType();
            logon.Body.game_server_app_id = ( int )details.AppID;
            logon.Body.machine_id = Utils.GenerateMachineID();

            logon.Body.account_name = details.Username;
            logon.Body.password = details.Password;

            this.Client.Send( logon );
        }
Exemplo n.º 3
0
        /// <summary>
        /// Starts the process interactively asynchronous different user.
        /// </summary>
        /// <param name="hProcess">The authentication process.</param>
        /// <param name="hPToken">The authentication application token.</param>
        /// <param name="hUserTokenDup">The authentication user token dup.</param>
        /// <param name="logonInfo">The logon information.</param>
        /// <param name="sa">The sa.</param>
        /// <param name="si">The si.</param>
        /// <param name="procInfo">The proc information.</param>
        /// <param name="imageName">Name of the image.</param>
        /// <returns></returns>
        private bool StartProcessInteractivelyAsDifferentUser(ref IntPtr hProcess, ref IntPtr hPToken, ref IntPtr hUserTokenDup,
                                                              LogOnDetails logonInfo, ref SecurityAttributes sa, ref StartUpInfo si, ref ProcessInformation procInfo, string imageName)
        {
            //TODO: This method needs to be revised because WDM is killing the process
            var retval = false;

            if (LogonUser(logonInfo.UserName, logonInfo.Domain, logonInfo.Password, Logon32LogonInteractive, Logon32ProviderDefault, ref hUserTokenDup))
            {
                var luid      = new Luid();
                var sessionId = WTSGetActiveConsoleSessionId();
                if (LookupPrivilegeValue(IntPtr.Zero, SeDebugName, ref luid))
                {
                    if (SetTokenInformation(hUserTokenDup, TokenInformationClass.TokenSessionId, ref sessionId, (UInt32)IntPtr.Size))
                    {
                        var tp = new TokenPrivileges()
                        {
                            PrivilegeCount = 1,
                            Privileges     = new int[] { luid.LowPart, luid.HighPart, SePrivilegeEnabled }
                        };

                        if (AdjustTokenPrivileges(hUserTokenDup, false, ref tp, Marshal.SizeOf(tp), IntPtr.Zero, IntPtr.Zero))
                        {
                            retval = CreateProcessAsUser(hUserTokenDup, null, imageName, ref sa, ref sa,
                                                         false, CreationFlags, IntPtr.Zero, null, ref si, out procInfo);
                        }
                    }
                }
            }

            return(retval);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Logs the client into the Steam3 network.
        /// The client should already have been connected at this point.
        /// Results are returned in a <see cref="LoggedOnCallback"/>.
        /// </summary>
        /// <param name="details">The details to use for logging on.</param>
        /// <exception cref="ArgumentNullException">No logon details were provided.</exception>
        /// <exception cref="ArgumentException">Username or password are not set within <paramref name="details"/>.</exception>
        public void LogOn(LogOnDetails details)
        {
            if (details == null)
            {
                throw new ArgumentNullException("details");
            }
            if (string.IsNullOrEmpty(details.Username) || string.IsNullOrEmpty(details.Password))
            {
                throw new ArgumentException("LogOn requires a username and password to be set in 'details'.");
            }
            if (!this.Client.IsConnected)
            {
                this.Client.PostCallback(new LoggedOnCallback(EResult.NoConnection));
                return;
            }

            var logon = new ClientMsgProtobuf <CMsgClientLogon>(EMsg.ClientLogon);

            SteamID steamId = new SteamID(details.AccountID, details.AccountInstance, Client.ConnectedUniverse, EAccountType.Individual);

            uint localIp = NetHelpers.GetIPAddress(this.Client.LocalIP);

            logon.ProtoHeader.client_sessionid = 0;
            logon.ProtoHeader.steamid          = steamId.ConvertToUInt64();

            logon.Body.obfustucated_private_ip = localIp ^ MsgClientLogon.ObfuscationMask;

            logon.Body.account_name = details.Username;
            logon.Body.password     = details.Password;

            logon.Body.protocol_version = MsgClientLogon.CurrentProtocol;
            logon.Body.client_os_type   = ( uint )Utils.GetOSType();
            logon.Body.client_language  = "english";

            logon.Body.steam2_ticket_request = details.RequestSteam2Ticket;

            // we're now using the latest steamclient package version, this is required to get a proper sentry file for steam guard
            logon.Body.client_package_version = 1771; // todo: determine if this is still required

            // this is not a proper machine id that Steam accepts
            // but it's good enough for identifying a machine
            logon.Body.machine_id = Utils.GenerateMachineID();


            // steam guard
            logon.Body.auth_code       = details.AuthCode;
            logon.Body.two_factor_code = details.TwoFactorCode;

            logon.Body.sha_sentryfile     = details.SentryFileHash;
            logon.Body.eresult_sentryfile = ( int )(details.SentryFileHash != null ? EResult.OK : EResult.FileNotFound);


            this.Client.Send(logon);
        }
Exemplo n.º 5
0
        public Task <LoggedOnCallback> LogOnAsync(LogOnDetails details)
        {
            var tcs = new TaskCompletionSource <LoggedOnCallback>();

            IDisposable onLoggedOn     = null;
            IDisposable onDisconnected = null;

            onLoggedOn = manager.Subscribe <LoggedOnCallback>(response =>
            {
                switch (response.Result)
                {
                case EResult.OK:
                    {
                        Console.WriteLine("Logged on to Steam.");
                        tcs.SetResult(response);
                        break;
                    }

                default:
                    {
                        var ex = new Exception($"Unable to logon to Steam. {response.Result}");
                        tcs.SetException(ex);
                        break;
                    }
                }

                onLoggedOn.Dispose();
                onDisconnected.Dispose();
            });
            onDisconnected = manager.Subscribe <DisconnectedCallback>(response =>
            {
                tcs.SetException(new Exception("Unable to connect to Steam."));
                onLoggedOn.Dispose();
                onDisconnected.Dispose();
            });

            steamClient.GetHandler <SteamUser>().LogOn(details);

            return(tcs.Task);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Logs onto the Steam network as a persistent game server.
        /// The client should already have been connected at this point.
        /// Results are return in a <see cref="SteamUser.LoggedOnCallback"/>.
        /// </summary>
        /// <param name="details">The details to use for logging on.</param>
        /// <exception cref="System.ArgumentNullException">No logon details were provided.</exception>
        /// <exception cref="System.ArgumentException">Username or password are not set within <paramref name="details"/>.</exception>
        public void LogOn(LogOnDetails details)
        {
            if (details == null)
            {
                throw new ArgumentNullException("details");
            }

            if (string.IsNullOrEmpty(details.Token))
            {
                throw new ArgumentException("LogOn requires a game server token to be set in 'details'.");
            }

            if (!this.Client.IsConnected)
            {
                this.Client.PostCallback(new SteamUser.LoggedOnCallback(EResult.NoConnection));
                return;
            }

            var logon = new ClientMsgProtobuf <CMsgClientLogon>(EMsg.ClientLogonGameServer);

            SteamID gsId = new SteamID(0, 0, Client.Universe, EAccountType.GameServer);

            logon.ProtoHeader.client_sessionid = 0;
            logon.ProtoHeader.steamid          = gsId.ConvertToUInt64();

            uint localIp = NetHelpers.GetIPAddress(this.Client.LocalIP);

            logon.Body.obfustucated_private_ip = localIp ^ MsgClientLogon.ObfuscationMask;

            logon.Body.protocol_version = MsgClientLogon.CurrentProtocol;

            logon.Body.client_os_type     = ( uint )Utils.GetOSType();
            logon.Body.game_server_app_id = ( int )details.AppID;
            logon.Body.machine_id         = HardwareUtils.GetMachineID();

            logon.Body.game_server_token = details.Token;

            this.Client.Send(logon);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Logs the client into the Steam3 network.
        /// The client should already have been connected at this point.
        /// Results are returned in a <see cref="LoggedOnCallback"/>.
        /// </summary>
        /// <param name="details">The details to use for logging on.</param>
        /// <exception cref="ArgumentNullException">No logon details were provided.</exception>
        /// <exception cref="ArgumentException">Username or password are not set within <paramref name="details"/>.</exception>
        public void LogOn(LogOnDetails details)
        {
            if (details == null)
            {
                throw new ArgumentNullException("details");
            }
            if (string.IsNullOrEmpty(details.Username) || (string.IsNullOrEmpty(details.Password) && string.IsNullOrEmpty(details.LoginKey)))
            {
                throw new ArgumentException("LogOn requires a username and password to be set in 'details'.");
            }
            if (!string.IsNullOrEmpty(details.LoginKey) && !details.ShouldRememberPassword)
            {
                // Prevent consumers from screwing this up.
                // If should_remember_password is false, the login_key is ignored server-side.
                // The inverse is not applicable (you can log in with should_remember_password and no login_key).
                throw new ArgumentException("ShouldRememberPassword is required to be set to true in order to use LoginKey.");
            }
            if (!this.Client.IsConnected)
            {
                this.Client.PostCallback(new LoggedOnCallback(EResult.NoConnection));
                return;
            }

            var logon = new ClientMsgProtobuf <CMsgClientLogon>(EMsg.ClientLogon);

            SteamID steamId = new SteamID(details.AccountID, details.AccountInstance, Client.ConnectedUniverse, EAccountType.Individual);

            if (details.LoginID.HasValue)
            {
                logon.Body.obfustucated_private_ip = details.LoginID.Value;
            }
            else
            {
                uint localIp = NetHelpers.GetIPAddress(this.Client.LocalIP);
                logon.Body.obfustucated_private_ip = localIp ^ MsgClientLogon.ObfuscationMask;
            }

            logon.ProtoHeader.client_sessionid = 0;
            logon.ProtoHeader.steamid          = steamId.ConvertToUInt64();

            logon.Body.account_name             = details.Username;
            logon.Body.password                 = details.Password;
            logon.Body.should_remember_password = details.ShouldRememberPassword;

            logon.Body.protocol_version = MsgClientLogon.CurrentProtocol;
            logon.Body.client_os_type   = ( uint )details.ClientOSType;
            logon.Body.client_language  = details.ClientLanguage;
            logon.Body.cell_id          = details.CellID;

            logon.Body.steam2_ticket_request = details.RequestSteam2Ticket;

            // we're now using the latest steamclient package version, this is required to get a proper sentry file for steam guard
            logon.Body.client_package_version = 1771; // todo: determine if this is still required
            logon.Body.machine_id             = HardwareUtils.GetMachineID();

            // steam guard
            logon.Body.auth_code       = details.AuthCode;
            logon.Body.two_factor_code = details.TwoFactorCode;

            logon.Body.login_key = details.LoginKey;

            logon.Body.sha_sentryfile     = details.SentryFileHash;
            logon.Body.eresult_sentryfile = ( int )(details.SentryFileHash != null ? EResult.OK : EResult.FileNotFound);


            this.Client.Send(logon);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Logs the client into the Steam3 network.
        /// The client should already have been connected at this point.
        /// Results are returned in a <see cref="LoggedOnCallback"/>.
        /// </summary>
        /// <param name="details">The details to use for logging on.</param>
        /// <exception cref="ArgumentNullException">No logon details were provided.</exception>
        /// <exception cref="ArgumentException">Username or password are not set within <paramref name="details"/>.</exception>
        public void LogOn( LogOnDetails details )
        {
            if ( details == null )
            {
                throw new ArgumentNullException( "details" );
            }
            if ( string.IsNullOrEmpty( details.Username ) || ( string.IsNullOrEmpty( details.Password ) && string.IsNullOrEmpty( details.LoginKey ) ) )
            {
                throw new ArgumentException( "LogOn requires a username and password to be set in 'details'." );
            }
            if ( !string.IsNullOrEmpty( details.LoginKey ) && !details.ShouldRememberPassword )
            {
                // Prevent consumers from screwing this up.
                // If should_remember_password is false, the login_key is ignored server-side.
                // The inverse is not applicable (you can log in with should_remember_password and no login_key).
                throw new ArgumentException( "ShouldRememberPassword is required to be set to true in order to use LoginKey." );
            }
            if ( !this.Client.IsConnected )
            {
                this.Client.PostCallback( new LoggedOnCallback( EResult.NoConnection ) );
                return;
            }

            var logon = new ClientMsgProtobuf<CMsgClientLogon>( EMsg.ClientLogon );

            SteamID steamId = new SteamID( details.AccountID, details.AccountInstance, Client.ConnectedUniverse, EAccountType.Individual );

            if ( details.LoginID.HasValue )
            {
                logon.Body.obfustucated_private_ip = details.LoginID.Value;
            }
            else
            {
                uint localIp = NetHelpers.GetIPAddress( this.Client.LocalIP );
                logon.Body.obfustucated_private_ip = localIp ^ MsgClientLogon.ObfuscationMask;
            }

            logon.ProtoHeader.client_sessionid = 0;
            logon.ProtoHeader.steamid = steamId.ConvertToUInt64();

            logon.Body.account_name = details.Username;
            logon.Body.password = details.Password;
            logon.Body.should_remember_password = details.ShouldRememberPassword;

            logon.Body.protocol_version = MsgClientLogon.CurrentProtocol;
            logon.Body.client_os_type = ( uint )details.ClientOSType;
            logon.Body.client_language = details.ClientLanguage;
            logon.Body.cell_id = details.CellID;

            logon.Body.steam2_ticket_request = details.RequestSteam2Ticket;

            // we're now using the latest steamclient package version, this is required to get a proper sentry file for steam guard
            logon.Body.client_package_version = 1771; // todo: determine if this is still required
            logon.Body.machine_id = HardwareUtils.GetMachineID();

            // steam guard 
            logon.Body.auth_code = details.AuthCode;
            logon.Body.two_factor_code = details.TwoFactorCode;

            logon.Body.login_key = details.LoginKey;

            logon.Body.sha_sentryfile = details.SentryFileHash;
            logon.Body.eresult_sentryfile = ( int )( details.SentryFileHash != null ? EResult.OK : EResult.FileNotFound );


            this.Client.Send( logon );
        }
Exemplo n.º 9
0
        /// <summary>
        /// Logs the client into the Steam3 network.
        /// The client should already have been connected at this point.
        /// Results are returned in a <see cref="LoggedOnCallback"/>.
        /// </summary>
        /// <param name="details">The details to use for logging on.</param>
        /// <exception cref="ArgumentNullException">No logon details were provided.</exception>
        /// <exception cref="ArgumentException">Username or password are not set within <paramref name="details"/>.</exception>
        public void LogOn( LogOnDetails details )
        {
            if ( details == null )
            {
                throw new ArgumentNullException( "details" );
            }
            if ( string.IsNullOrEmpty( details.Username ) || string.IsNullOrEmpty( details.Password ) )
            {
                throw new ArgumentException( "LogOn requires a username and password to be set in 'details'." );
            }

            var logon = new ClientMsgProtobuf<CMsgClientLogon>( EMsg.ClientLogon );

            SteamID steamId = new SteamID( 0, details.AccountInstance, Client.ConnectedUniverse, EAccountType.Individual );

            uint localIp = NetHelpers.GetIPAddress( this.Client.LocalIP );

            logon.ProtoHeader.client_sessionid = 0;
            logon.ProtoHeader.steamid = steamId.ConvertToUInt64();

            logon.Body.obfustucated_private_ip = localIp ^ MsgClientLogon.ObfuscationMask;

            logon.Body.account_name = details.Username;
            logon.Body.password = details.Password;

            logon.Body.protocol_version = MsgClientLogon.CurrentProtocol;
            logon.Body.client_os_type = ( uint )Utils.GetOSType();
            logon.Body.client_language = "english";

            logon.Body.steam2_ticket_request = details.RequestSteam2Ticket;

            // we're now using the latest steamclient package version, this is required to get a proper sentry file for steam guard
            logon.Body.client_package_version = 1771; // todo: determine if this is still required

            // this is not a proper machine id that Steam accepts
            // but it's good enough for identifying a machine
            logon.Body.machine_id = Utils.GenerateMachineID();


            // steam guard 
            logon.Body.auth_code = details.AuthCode;

            logon.Body.sha_sentryfile = details.SentryFileHash;
            logon.Body.eresult_sentryfile = ( int )( details.SentryFileHash != null ? EResult.OK : EResult.FileNotFound );


            this.Client.Send( logon );
        }
Exemplo n.º 10
0
        /// <summary>
        /// Logs onto the Steam network as a persistent game server.
        /// The client should already have been connected at this point.
        /// Results are return in a <see cref="SteamUser.LoggedOnCallback"/>.
        /// </summary>
        /// <param name="details">The details to use for logging on.</param>
        /// <exception cref="System.ArgumentNullException">No logon details were provided.</exception>
        /// <exception cref="System.ArgumentException">Username or password are not set within <paramref name="details"/>.</exception>
        public void LogOn( LogOnDetails details )
        {
            if ( details == null )
            {
                throw new ArgumentNullException( "details" );
            }

            if ( string.IsNullOrEmpty( details.Token ) )
            {
                throw new ArgumentException( "LogOn requires a game server token to be set in 'details'." );
            }
            
            if ( !this.Client.IsConnected )
            {
                this.Client.PostCallback( new SteamUser.LoggedOnCallback( EResult.NoConnection ) );
                return;
            }

            var logon = new ClientMsgProtobuf<CMsgClientLogon>( EMsg.ClientLogonGameServer );

            SteamID gsId = new SteamID( 0, 0, Client.ConnectedUniverse, EAccountType.GameServer );

            logon.ProtoHeader.client_sessionid = 0;
            logon.ProtoHeader.steamid = gsId.ConvertToUInt64();

            uint localIp = NetHelpers.GetIPAddress( this.Client.LocalIP );
            logon.Body.obfustucated_private_ip = localIp ^ MsgClientLogon.ObfuscationMask;

            logon.Body.protocol_version = MsgClientLogon.CurrentProtocol;

            logon.Body.client_os_type = ( uint )Utils.GetOSType();
            logon.Body.game_server_app_id = ( int )details.AppID;
            logon.Body.machine_id = MachineIdUtils.GenerateMachineID();

            logon.Body.game_server_token = details.Token;

            this.Client.Send( logon );
        }