Advertisement
Guest User

Probier mal aus

a guest
May 17th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.34 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. static string user, pass;
  15.  
  16. static SteamClient steamClient;
  17. static CallbackManager manager;
  18. static SteamUser steamUser;
  19.  
  20. static bool isRunning = false;
  21.  
  22. static string authCode;
  23.  
  24. static void Main(string[] args)
  25. {
  26. Console.Title = "PowerByteDev";
  27. Console.WriteLine("CTRL+C quits the program");
  28.  
  29. Console.Write("Username: ");
  30. user = Console.ReadLine();
  31.  
  32. Console.Write("Password: ");
  33. pass = Console.ReadLine();
  34.  
  35. SteamLogIn();
  36. }
  37.  
  38. static void SteamLogIn()
  39. {
  40. steamClient = new SteamClient();
  41.  
  42. manager = new CallbackManager(steamClient);
  43.  
  44. steamUser = steamClient.GetHandler<SteamUser>();
  45.  
  46. manager.Subscribe<SteamClient.ConnectedCallback>(OnConnected);
  47.  
  48. manager.Subscribe<SteamUser.LoggedOnCallback>(OnLoggedOn);
  49.  
  50. manager.Subscribe<SteamClient.DisconnectedCallback>(OnDisconnected);
  51.  
  52. manager.Subscribe<SteamUser.UpdateMachineAuthCallback>(UpdateMachineAuthCallback);
  53.  
  54. steamClient.Connect();
  55.  
  56. steamClient.Connect();
  57.  
  58. isRunning = true;
  59. while (isRunning)
  60. {
  61. manager.RunWaitCallbacks(TimeSpan.FromSeconds(1));
  62. }
  63. Console.ReadKey();
  64. }
  65. static void OnConnected(SteamClient.ConnectedCallback callback)
  66. {
  67. if (callback.Result != EResult.OK)
  68. {
  69. Console.WriteLine("Unable to connect to Steam: {0}", callback.Result);
  70. isRunning = false;
  71. return;
  72. }
  73.  
  74. Console.WriteLine("Connected to Steam. \nLogging in {0}...\n", user);
  75.  
  76. byte[] sentryHash = null;
  77.  
  78. if (File.Exists("sentry.bin"))
  79. {
  80. byte[] sentryFile = File.ReadAllBytes("sentry.bin");
  81.  
  82. sentryHash = CryptoHelper.SHAHash(sentryFile);
  83. }
  84.  
  85. steamUser.LogOn(new SteamUser.LogOnDetails
  86. {
  87. Username = user,
  88. Password = pass,
  89.  
  90. AuthCode = authCode,
  91. });
  92. }
  93.  
  94. static void OnLoggedOn(SteamUser.LoggedOnCallback callback)
  95. {
  96. if (callback.Result == EResult.AccountLogonDenied)
  97. {
  98. Console.WriteLine("This account is SteamGuard protected.");
  99.  
  100. Console.Write("Please enter the auth code sent to the email at {0}", callback.EmailDomain);
  101.  
  102. authCode = Console.ReadLine();
  103.  
  104. return;
  105. }
  106. if (callback.Result != EResult.OK)
  107. {
  108. Console.WriteLine("Unable to log in to Steam: {0}\n", callback.Result);
  109. isRunning = false;
  110. return;
  111. }
  112. Console.WriteLine("{0} successfully Logged in!", user);
  113. }
  114.  
  115. static void UpdateMachineAuthCallback(SteamUser.UpdateMachineAuthCallback callback)
  116. {
  117. Console.WriteLine("Updating sentry file...");
  118. byte[] sentryHash = CryptoHelper.SHAHash(callback.Data);
  119. File.WriteAllBytes("sentry.bin", callback.Data);
  120. steamUser.SendMachineAuthResponse(new SteamUser.MachineAuthDetails
  121. {
  122. JobID = callback.JobID,
  123. FileName = callback.FileName,
  124. BytesWritten = callback.BytesToWrite,
  125. FileSize = callback.Data.Length,
  126. Offset = callback.Offset,
  127. Result = EResult.OK,
  128. LastError = 0,
  129. OneTimePassword = callback.OneTimePassword,
  130. SentryFileHash = sentryHash,
  131. });
  132. Console.WriteLine("Done!");
  133. }
  134.  
  135. static void OnDisconnected(SteamClient.DisconnectedCallback callback)
  136. {
  137. Console.WriteLine("\n{0} disconnected from steam reconnecting in 5...\n", user);
  138.  
  139. Thread.Sleep(TimeSpan.FromSeconds(5));
  140.  
  141. steamClient.Connect();
  142. }
  143. }
  144. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement