Steamkit2 LoginID

ZeCke

Honorable
7 Jan 2015
4,074
3,291
#1
Guten Abend,
nach der Diskussion heute zum Thema server side Medal changer hab ich mir was zusammengepasted aus dem Thread den Radat verlinkt hat (https://www.unknowncheats.me/forum/counterstrike-global-offensive/206569-setmymedals.html) und dem sample von Steamkit für 2FA accounts.
Code:
using System;
using System.IO;
using System.Security.Cryptography;
using System.Threading;

using SteamKit2;
using SteamKit2.Internal;
using SteamKit2.GC;
using System.Linq;
using SteamKit2.GC.CSGO.Internal;


namespace Sample5_SteamGuard
{
    class Program
    {
        static SteamClient steamClient;
        static CallbackManager manager;

        static SteamGameCoordinator coordinator;

        static SteamUser steamUser;

        static bool isRunning;

        static string user, pass;
        static string authCode, twoFactorAuth;


        static void Main(string[] args)
        {
            if (args.Length < 2)
            {
                Console.WriteLine("Sample5: No username and password specified!");
                return;
            }
           
            user = args[0];
            pass = args[1];
           
            steamClient = new SteamClient();
            manager = new CallbackManager(steamClient);
           
            steamUser = steamClient.GetHandler<SteamUser>();
            coordinator = steamClient.GetHandler<SteamGameCoordinator>();
           
            manager.Subscribe<SteamClient.ConnectedCallback>(OnConnected);
            manager.Subscribe<SteamClient.DisconnectedCallback>(OnDisconnected);

            manager.Subscribe<SteamUser.LoggedOnCallback>(OnLoggedOn);
            manager.Subscribe<SteamUser.LoggedOffCallback>(OnLoggedOff);

            manager.Subscribe<SteamGameCoordinator.MessageCallback>(coordinatorCallback);
           
            manager.Subscribe<SteamUser.UpdateMachineAuthCallback>(OnMachineAuth);

            isRunning = true;

            Console.WriteLine("Connecting to Steam...");
           
            steamClient.Connect();
           
            while (isRunning)
                manager.RunWaitCallbacks(TimeSpan.FromSeconds(1));
        }

        private static void coordinatorCallback(SteamGameCoordinator.MessageCallback callback)
        {
            Console.WriteLine(callback);
        }

        static void OnConnected(SteamClient.ConnectedCallback callback)
        {
            Console.WriteLine("Connected to Steam! Logging in '{0}'...", user);

            byte[] sentryHash = null;
            if (File.Exists("sentry.bin"))
            {
                byte[] sentryFile = File.ReadAllBytes("sentry.bin");
                sentryHash = CryptoHelper.SHAHash(sentryFile);
            }

            steamUser.LogOn(new SteamUser.LogOnDetails
            {
                Username = user,
                Password = pass,

                AuthCode = authCode,

                TwoFactorCode = twoFactorAuth,

                SentryFileHash = sentryHash,

                //LoginID = 1337,
            });
        }

        static void OnDisconnected(SteamClient.DisconnectedCallback callback)
        {

            Console.WriteLine("Disconnected from Steam, reconnecting in 3...");

            Thread.Sleep(TimeSpan.FromSeconds(3));

            steamClient.Connect();
        }

        static void OnLoggedOn(SteamUser.LoggedOnCallback callback)
        {
            bool isSteamGuard = callback.Result == EResult.AccountLogonDenied;
            bool is2FA = callback.Result == EResult.AccountLoginDeniedNeedTwoFactor;

            if (isSteamGuard || is2FA)
            {
                Console.WriteLine("This account is SteamGuard protected!");

                if (is2FA)
                {
                    Console.Write("Please enter your 2 factor auth code from your authenticator app: ");
                    twoFactorAuth = Console.ReadLine();
                }
                else
                {
                    Console.Write("Please enter the auth code sent to the email at {0}: ", callback.EmailDomain);
                    authCode = Console.ReadLine();
                }

                return;
            }

            if (callback.Result != EResult.OK)
            {
                Console.WriteLine("Unable to logon to Steam: {0} / {1}", callback.Result, callback.ExtendedResult);

                isRunning = false;
                return;
            }

            Console.WriteLine("Successfully logged on!");

            change();
        }

        static void OnLoggedOff(SteamUser.LoggedOffCallback callback)
        {
            Console.WriteLine("Logged off of Steam: {0}", callback.Result);
        }

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

            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);
                }
            }
            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!");
        }

        static void change()
        {
            var kickSession = new ClientMsgProtobuf<CMsgClientKickPlayingSession>(EMsg.ClientKickPlayingSession);
            kickSession.Body.only_stop_game = false;
            steamClient.Send(kickSession);
            var ClientToGC = new ClientGCMsgProtobuf<PlayerMedalsInfo>((uint)ECsgoGCMsg.k_EMsgGCCStrike15_v2_SetMyMedalsInfo);
            ClientToGC.Body.medal_global = 2;
            ClientToGC.Body.medal_arms = 3;
            ClientToGC.Body.medal_combat = 3;
            ClientToGC.Body.medal_weapon = 2;
            ClientToGC.Body.medal_team = 3;
            ClientToGC.Body.featured_display_item_defidx = 892;
            string[] medals = null;
            try
            {
                medals = File.ReadAllLines("medals.txt");
            }
            catch (Exception)
            {
                File.WriteAllText("medals.txt", "941");
                medals = File.ReadAllLines("medals.txt");
            }
            for (int i = 0; i < medals.Count(); i++)
            {
                ClientToGC.Body.display_items_defidx.Add(Convert.ToUInt16(medals[i]));
            }
            coordinator.Send(ClientToGC, 730);
            Console.WriteLine("Changed");
        }
    }
}
Der Code funktioniert auch wunderbar, meine Medals werden gepatcht aber kurz danach bekomme ich einen Kick wegen NoSteamLogon...
Das ganze liegt wohl daran, dass nur eine Connection pro localIP zulässig ist und daher die LoginID bei LogOnDetails genutzt werden soll. Allerdings funktioniert es dann nicht mehr und ich muss mich erneut anmelden weil ein anderer PC diesen Account nutzt. Das passiert auch wenn ich es über einen zweiten PC laufen lasse.
Gibt es eine Möglichkeit die LoginID so zu setzen dass ich das ohne Probleme auf meinem PC laufen lassen kann oder muss ich das komplett anders machen?
E: bzw der Fehler ist mit loginID dass sich die Anmeldedaten geändert hätten... ;(
 
Last edited:
Likes: Heckler

Logxn

Honorable
22 Jul 2016
1,477
1,766
#3
Das wird so nicht funktionieren und meines wissens nach gibts da auch kein workaround.

Wie dem auch sei, eigentlich sollte dich steam nicht rausschmeißen wenn du dein Steamkit tool auf nem anderen PC used.