- Add a valid phone number to your Steam account via store.steampowered.com account settings panel.
- Copy this code from this gist into a
enable-2fa.js
file and install the dependencies listed at the top. - Start with
VAPOR_ADMIN=7657xxx VAPOR_USER=username VAPOR_PASS=password node enable-2fa.js
. - Send chat message
enable
to your bot to enable 2FA. - Wait for the response from Steam servers. Full response which will include your
shared_secret
andidentity_secret
will be printed to console as well as saved to a file. - You will receive a text message.
- Send chat message
confirm CODE
to your bot. - You will see a confirmation in the console. You can now press Ctrl+C to kill the script.
Last active
September 23, 2017 13:42
-
-
Save scholtzm/354b35db333df64cb520 to your computer and use it in GitHub Desktop.
[Enable 2FA on your Steam account] #steam
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var vapor = require('vapor'); | |
var winston = require('vapor-winston-logger'); | |
var SteamUser = require('steam-user'); | |
var SteamID = require('steamid'); | |
var bot = vapor(); | |
const config = { | |
username: process.env.VAPOR_USER, | |
password: process.env.VAPOR_PASS, | |
admins: [ process.env.VAPOR_ADMIN ] | |
}; | |
bot.init(config); | |
bot.use(winston, { | |
fileLevel: 'debug' | |
}); | |
bot.use(vapor.plugins.fs); | |
bot.use(vapor.plugins.declineFriendRequests); | |
bot.use(vapor.plugins.essentials); | |
bot.use(vapor.plugins.stdinSteamGuard); | |
bot.use({ | |
name: 'enable-2fa', | |
plugin: function(API) { | |
var enableRegex = /^enable$/; | |
var confirmRegex = /^confirm ([a-zA-Z0-9]+)$/; | |
var Steam = API.getSteam(); | |
var client = API.getClient(); | |
var utils = API.getUtils(); | |
var log = API.getLogger(); | |
var fileName = API.getConfig().username + '.2fa.json'; | |
var steamUser; | |
var twoFactorResponse; | |
API.registerHandler({ | |
emitter: 'vapor', | |
event: 'ready' | |
}, function() { | |
// wait couple seconds otherwise SteamUser goes bananas | |
setTimeout(function() { | |
steamUser = new SteamUser(client, { | |
autoRelogin: false, | |
promptSteamGuardCode: false | |
}); | |
// this is derpy | |
steamUser.steamID = new SteamID(client.steamID); | |
log.info('SteamUser is ready.'); | |
}, 5000); | |
}); | |
API.registerHandler({ | |
emitter: 'steamFriends', | |
event: 'friendMsg' | |
}, function(user, message, type) { | |
if(type === Steam.EChatEntryType.ChatMsg) { | |
if(utils.isAdmin(user)) { | |
if(enableRegex.test(message)) { | |
steamUser.enableTwoFactor(function(response) { | |
log.info('enableTwoFactor response:'); | |
log.info(response); | |
twoFactorResponse = response; | |
API.emitEvent('writeFile', fileName, JSON.stringify(response, null, 2), function(error) { | |
if(error) { | |
log.error(error); | |
} else { | |
log.info('Response has been saved. Waiting for finalization.'); | |
} | |
}); | |
}); | |
return; | |
} | |
if(confirmRegex.test(message)) { | |
var match = confirmRegex.exec(message); | |
var code = match[1]; | |
log.info('Using code: %s', code); | |
steamUser.finalizeTwoFactor(twoFactorResponse.shared_secret, code, function(error) { | |
if(error) { | |
log.error(error); | |
} else { | |
log.info('2FA has been enabled successfully. You can press Ctrl+C to quit.'); | |
} | |
}); | |
return; | |
} | |
} | |
} | |
}); | |
} | |
}); | |
bot.connect(); | |
process.on('SIGINT', function() { | |
bot.disconnect(); | |
setTimeout(process.exit, 1000, 0); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment