Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using SteamKit2;
- using System.IO;
- using System.Threading;
- namespace We_are_Coder
- {
- class Program
- {
- //Variablen
- static string user, pass;
- static SteamClient steamClient;
- static CallbackManager manager;
- static SteamUser steamUser;
- static bool isRunning = false;
- static string authCode;
- //Informationen
- static void Main(string[] args)
- {
- Console.Title = "PowerByteDev";
- Console.WriteLine("CTRL+C quits the program.");
- Console.Write("Username: ");
- user = Console.ReadLine();
- Console.Write("Password: ");
- pass = Console.ReadLine();
- SteamLogIn();
- }
- //LogIn einleiten
- static void SteamLogIn()
- {
- steamClient = new SteamClient();
- manager = new CallbackManager(steamClient);
- steamUser = steamClient.GetHandler<SteamUser>();
- new Callback<SteamClient.ConnectedCallback>(OnConnected, manager);
- new Callback<SteamUser.LoggedOnCallback>(OnLoggedOn, manager);
- new Callback<SteamClient.DisconnectedCallback>(OnDisconnected, manager);
- new Callback<SteamUser.UpdateMachineAuthCallback>(UpdateMachineAuthCallback, manager);
- isRunning = true;
- Console.WriteLine("\nConnecting to steam...\n");
- steamClient.Connect();
- while (isRunning)
- {
- manager.RunWaitCallbacks(TimeSpan.FromSeconds(1));
- }
- Console.ReadKey();
- }
- //Verbinden
- static void OnConnected(SteamClient.ConnectedCallback callback)
- {
- if (callback.Result != EResult.OK)
- {
- Console.WriteLine("Unable to connect to Steam{0}", callback.Result);
- isRunning = false;
- return;
- }
- Console.WriteLine("Connected to Steam. \nLogging in {0}...\n", 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,
- SentryFileHash = sentryHash,
- });
- }
- //Hast du dich eingeloggt oder brauchst du einen Auth Code?
- static void OnLoggedOn(SteamUser.LoggedOnCallback callback)
- {
- if (callback.Result != EResult.AccountLogonDenied)
- {
- Console.WriteLine("This account is SteamGuard protected.");
- 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 log in to Steam {0}\n", callback);
- isRunning = false;
- return;
- }
- Console.WriteLine("{0} succesfully logged in!", user);
- }
- //Speicher den Authcode in die sentry.bin
- static void UpdateMachineAuthCallback(SteamUser.UpdateMachineAuthCallback callback)
- {
- Console.WriteLine("Updating sentry file...");
- byte[] sentryHash = CryptoHelper.SHAHash(callback.Data);
- File.WriteAllBytes("sentry.bin", callback.Data);
- steamUser.SendMachineAuthResponse(new SteamUser.MachineAuthDetails
- {
- JobID = callback.JobID,
- FileName = callback.FileName,
- BytesWritten = callback.BytesToWrite,
- FileSize = callback.Data.Length,
- Offset = callback.Offset,
- Result = EResult.OK,
- LastError = 0,
- OneTimePassword = callback.OneTimePassword,
- SentryFileHash = sentryHash,
- });
- Console.WriteLine("Done.");
- }
- //Wenn du die Verbindung verlierst
- static void OnDisconnected(SteamClient.DisconnectedCallback callback)
- {
- Console.WriteLine("\n{0} disconnected from Steam, reconnecting in 5 Seconds...\n", user);
- Thread.Sleep(TimeSpan.FromSeconds(5));
- steamClient.Connect();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement