Advertisement
Guest User

bot

a guest
May 17th, 2016
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.69 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using SteamKit2;
  7. using System.IO;
  8. using System.Threading;
  9.  
  10. namespace We_are_Coder
  11. {
  12. class Program
  13. {
  14. //Variablen
  15. static string user, pass;
  16.  
  17. static SteamClient steamClient;
  18. static CallbackManager manager;
  19. static SteamUser steamUser;
  20. static bool isRunning = false;
  21.  
  22. static string authCode;
  23.  
  24. //Informationen
  25. static void Main(string[] args)
  26. {
  27. Console.Title = "PowerByteDev";
  28. Console.WriteLine("CTRL+C quits the program.");
  29.  
  30. Console.Write("Username: ");
  31. user = Console.ReadLine();
  32. Console.Write("Password: ");
  33. pass = Console.ReadLine();
  34.  
  35. SteamLogIn();
  36.  
  37. }
  38.  
  39. //LogIn einleiten
  40. static void SteamLogIn()
  41. {
  42. steamClient = new SteamClient();
  43. manager = new CallbackManager(steamClient);
  44. steamUser = steamClient.GetHandler<SteamUser>();
  45.  
  46. new Callback<SteamClient.ConnectedCallback>(OnConnected, manager);
  47.  
  48. new Callback<SteamUser.LoggedOnCallback>(OnLoggedOn, manager);
  49.  
  50. new Callback<SteamClient.DisconnectedCallback>(OnDisconnected, manager);
  51.  
  52. new Callback<SteamUser.UpdateMachineAuthCallback>(UpdateMachineAuthCallback, manager);
  53.  
  54. isRunning = true;
  55.  
  56. Console.WriteLine("\nConnecting to steam...\n");
  57.  
  58. steamClient.Connect();
  59.  
  60.  
  61. while (isRunning)
  62. {
  63. manager.RunWaitCallbacks(TimeSpan.FromSeconds(1));
  64. }
  65. Console.ReadKey();
  66. }
  67.  
  68. //Verbinden
  69. static void OnConnected(SteamClient.ConnectedCallback callback)
  70. {
  71. if (callback.Result != EResult.OK)
  72. {
  73. Console.WriteLine("Unable to connect to Steam{0}", callback.Result);
  74. isRunning = false;
  75. return;
  76. }
  77. Console.WriteLine("Connected to Steam. \nLogging in {0}...\n", user);
  78.  
  79. byte[] sentryHash = null;
  80.  
  81. if (File.Exists("sentry.bin"))
  82. {
  83. byte[] sentryFile = File.ReadAllBytes("sentry.bin");
  84.  
  85. sentryHash = CryptoHelper.SHAHash(sentryFile);
  86. }
  87.  
  88. steamUser.LogOn(new SteamUser.LogOnDetails
  89. {
  90. Username = user,
  91. Password = pass,
  92.  
  93. AuthCode = authCode,
  94.  
  95. SentryFileHash = sentryHash,
  96. });
  97. }
  98.  
  99. //Hast du dich eingeloggt oder brauchst du einen Auth Code?
  100. static void OnLoggedOn(SteamUser.LoggedOnCallback callback)
  101. {
  102. if (callback.Result != EResult.AccountLogonDenied)
  103. {
  104. Console.WriteLine("This account is SteamGuard protected.");
  105.  
  106. Console.Write("Please enter the auth code sent to the email at {0}: ", callback.EmailDomain);
  107.  
  108. authCode = Console.ReadLine();
  109.  
  110. return;
  111. }
  112. if (callback.Result != EResult.OK)
  113. {
  114. Console.WriteLine("Unable to log in to Steam {0}\n", callback);
  115. isRunning = false;
  116. return;
  117. }
  118. Console.WriteLine("{0} succesfully logged in!", user);
  119. }
  120.  
  121. //Speicher den Authcode in die sentry.bin
  122. static void UpdateMachineAuthCallback(SteamUser.UpdateMachineAuthCallback callback)
  123. {
  124. Console.WriteLine("Updating sentry file...");
  125.  
  126. byte[] sentryHash = CryptoHelper.SHAHash(callback.Data);
  127.  
  128. File.WriteAllBytes("sentry.bin", callback.Data);
  129.  
  130. steamUser.SendMachineAuthResponse(new SteamUser.MachineAuthDetails
  131. {
  132. JobID = callback.JobID,
  133. FileName = callback.FileName,
  134. BytesWritten = callback.BytesToWrite,
  135. FileSize = callback.Data.Length,
  136. Offset = callback.Offset,
  137. Result = EResult.OK,
  138. LastError = 0,
  139. OneTimePassword = callback.OneTimePassword,
  140. SentryFileHash = sentryHash,
  141. });
  142.  
  143. Console.WriteLine("Done.");
  144. }
  145.  
  146. //Wenn du die Verbindung verlierst
  147. static void OnDisconnected(SteamClient.DisconnectedCallback callback)
  148. {
  149. Console.WriteLine("\n{0} disconnected from Steam, reconnecting in 5 Seconds...\n", user);
  150.  
  151. Thread.Sleep(TimeSpan.FromSeconds(5));
  152.  
  153. steamClient.Connect();
  154. }
  155. }
  156. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement