Advertisement
Guest User

Untitled

a guest
Aug 5th, 2016
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.89 KB | None | 0 0
  1. var crypto = require( "crypto" );
  2. var csgo = require( "csgo" );
  3. var fs = require( "fs" );
  4. var readlineSync = require( "readline-sync" );
  5. var Steam = require( "steam" );
  6.  
  7. var SteamClient = new Steam.SteamClient();
  8. var SteamFriends = new Steam.SteamFriends( SteamClient );
  9. var SteamGameCoordinator = new Steam.SteamGameCoordinator( SteamClient, 730 );
  10. var SteamUser = new Steam.SteamUser( SteamClient );
  11.  
  12. var CSGOClient = new csgo.CSGOClient( SteamUser, SteamGameCoordinator, false );
  13.  
  14. var args = process.argv.slice( 2 );
  15.  
  16. var username = args[0];
  17. var password = args[1];
  18. var auth_code = args[2];
  19. var two_factor_code = "";
  20.  
  21. var sentryfile = username + ".sentryfile";
  22.  
  23. SteamClient.connect();
  24. SteamClient.on( "connected", function() {
  25. if ( fs.existsSync( sentryfile ) )
  26. {
  27. var logOnOptions = {
  28. account_name: username,
  29. password: password,
  30. sha_sentryfile: getSHA1( fs.readFileSync( sentryfile ) )
  31. };
  32.  
  33. if ( two_factor_code == "" )
  34. console.log( "Logging in with a sentry file..." );
  35. else
  36. logOnOptions["two_factor_code"] = two_factor_code;
  37.  
  38. SteamUser.logOn( logOnOptions );
  39. }
  40. else
  41. {
  42. console.log( "Logging in without a sentry file..." );
  43.  
  44. var logOnOptions = {
  45. account_name: username,
  46. password: password
  47. };
  48.  
  49. if ( auth_code != "" )
  50. logOnOptions["auth_code"] = auth_code;
  51.  
  52. if ( two_factor_code != "" )
  53. logOnOptions["two_factor_code"] = two_factor_code;
  54.  
  55. SteamUser.logOn( logOnOptions );
  56. }
  57. } );
  58.  
  59. SteamClient.on( "logOnResponse", function( e ) {
  60. if ( e.eresult == Steam.EResult.OK )
  61. {
  62. console.log( "Logged in!" );
  63.  
  64. SteamFriends.setPersonaState( Steam.EPersonaState.Offline );
  65.  
  66. CSGOClient.launch();
  67. CSGOClient.on( "ready", function() {
  68. console.log( "node-csgo is ready!\n" );
  69.  
  70. var Command = args[3];
  71. var SteamID = parseInt( args[4], 10 );
  72.  
  73. if ( Command == "report" )
  74. {
  75. console.log( "Reporting " + SteamID + "..." );
  76.  
  77. CSGOClient.reportPlayer( SteamID, 1, 1, 1, 1, 1, 1, 0 );
  78. }
  79. else if ( Command == "commend" )
  80. {
  81. console.log( "Commending " + SteamID + "..." );
  82.  
  83. CSGOClient.commendPlayer( SteamID, 0, 1, 1, 1, 0 );
  84. }
  85. else
  86. {
  87. console.log( Command + " is not a valid command. Valid commands are report and commend." );
  88.  
  89. // Use setTimeout?
  90. SteamClient.disconnect();
  91. }
  92. } );
  93. }
  94. else if ( e.eresult == Steam.EResult.InvalidPassword )
  95. console.log( "Login failed: Invalid password." );
  96. else if ( e.eresult == Steam.EResult.AlreadyLoggedInElsewhere )
  97. console.log( "Login failed: Already logged in elsewhere." );
  98. else if ( e.eresult == Steam.EResult.AccountLogonDenied )
  99. console.log( "Login failed: No SteamGuard code." );
  100. else if ( e.eresult == Steam.EResult.InvalidLoginAuthCode )
  101. console.log( "Login failed: Invalid SteamGuard code." );
  102. else if ( e.eresult == Steam.EResult.AccountLogonDeniedNeedTwoFactorCode )
  103. {
  104. two_factor_code = readlineSync.question( "Mobile auth code needed for " + username + ". Type it here: " );
  105.  
  106. SteamClient.connect();
  107. }
  108. else
  109. console.log( "Login failed: " + e.eresult );
  110. } );
  111.  
  112. CSGOClient.on( "reportResponse", function( message )
  113. {
  114. var Command = "commend player.";
  115. if ( message.response_type == csgo.ECSGOCMsg.k_EMsgGCCStrike15_v2_ClientReportPlayer )
  116. Command = "report player.";
  117.  
  118. if ( message.response_result )
  119. console.log( "Succeeded to " + Command );
  120. else
  121. console.log( "Failed to " + Command );
  122.  
  123. // Use setTimeout?
  124. SteamClient.disconnect();
  125. } );
  126.  
  127. SteamClient.on( "error", function( e ) {
  128. } );
  129.  
  130. SteamUser.on( "updateMachineAuth", function( sentry, callback ) {
  131. fs.writeFileSync( sentryfile, sentry.bytes );
  132.  
  133. console.log( "Saved the sentry file." );
  134.  
  135. callback( {
  136. sha_file: getSHA1( sentry.bytes )
  137. } );
  138. } );
  139.  
  140. function getSHA1( bytes ) {
  141. var hash = crypto.createHash( "sha1" );
  142. hash.update( bytes );
  143. return hash.digest();
  144. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement