Guest User

Untitled

a guest
Apr 19th, 2017
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.74 KB | None | 0 0
  1. var SteamCommunity = require('steamcommunity');
  2. var ReadLine = require('readline');
  3. var fs = require('fs');
  4. var SteamTotp = require('steam-totp');
  5. // var twofactor = JSON.parse(fs.readFileSync('twofactor_76561198187794161.json', 'utf8')); //Tutaj Zmienic na wlasne
  6.  
  7. // setInterval(function(){console.log(SteamTotp.generateAuthCode(twofactor.shared_secret));}, 1000);
  8. var community = new SteamCommunity();
  9. var rl = ReadLine.createInterface({
  10. "input": process.stdin,
  11. "output": process.stdout
  12. });
  13.  
  14. rl.question("Username: ", function(accountName) {
  15. rl.question("Password: ", function(password) {
  16. doLogin(accountName, password);
  17. });
  18. });
  19.  
  20. function doLogin(accountName, password, authCode) {
  21. community.login({
  22. "accountName": accountName,
  23. "password": password,
  24. "authCode": authCode
  25. }, function(err, sessionID, cookies, steamguard) {
  26. if(err) {
  27. if(err.message == 'SteamGuardMobile') {
  28. console.log("This account already has two-factor authentication enabled.");
  29. setInterval(function(){console.log(SteamTotp.generateAuthCode(twofactor.shared_secret));}, 1000);
  30. }
  31.  
  32. if(err.message == 'SteamGuard') {
  33. console.log("An email has been sent to your address at " + err.emaildomain);
  34. rl.question("Steam Guard Code: ", function(code) {
  35. doLogin(accountName, password, code);
  36. });
  37. }
  38. }else{
  39. console.log("Logged on!");
  40. community.enableTwoFactor(function(err, response) {
  41. if(err) {
  42. if(err.eresult == 2) {
  43. console.log("Error: Failed to enable two-factor authentication. Do you have a phone number attached to your account?");
  44. process.exit();
  45. return;
  46. }
  47.  
  48. if(err.eresult == 84) {
  49. console.log("Error: RateLimitExceeded. Try again later.");
  50. process.exit();
  51. return;
  52. }
  53.  
  54. console.log(err);
  55. process.exit();
  56. return;
  57. }
  58.  
  59. if(response.status != 1) {
  60. console.log("Error: Status " + response.status);
  61. process.exit();
  62. return;
  63. }
  64.  
  65. console.log("Writing secrets to twofactor_" + community.steamID.getSteamID64() + ".json");
  66. console.log("Revocation code: " + response.revocation_code);
  67. fs.writeFile("twofactor_" + community.steamID.getSteamID64() + ".json", JSON.stringify(response, null, "\t"));
  68.  
  69. promptActivationCode(response);
  70. });
  71. }
  72. });
  73. }
  74.  
  75. function promptActivationCode(response) {
  76. rl.question("SMS Code: ", function(smsCode) {
  77. community.finalizeTwoFactor(response.shared_secret, smsCode, function(err) {
  78. if(err) {
  79. if(err.message == "Invalid activation code") {
  80. console.log(err);
  81. promptActivationCode(response);
  82. return;
  83. }
  84.  
  85. console.log(err);
  86. } else {
  87. console.log("Two-factor authentication enabled!");
  88. }
  89.  
  90. process.exit();
  91. });
  92. });
  93. }
Add Comment
Please, Sign In to add comment