Skip to content

Instantly share code, notes, and snippets.

@fs-c
Last active August 4, 2017 18:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fs-c/64c54b5fdfdfb154a277d461a477d0a1 to your computer and use it in GitHub Desktop.
Save fs-c/64c54b5fdfdfb154a277d461a477d0a1 to your computer and use it in GitHub Desktop.
Basic stuff. Made to fit my needs, but I feel like others will be able to have fun with it too. I run this on a server, but can be run wherever. Requires NodeJS and the steam-user and steam-totp modules.
// By default requires a JSON file with your steam account data,
// defined with the PATH variable.
// See steamdata.json for formatting.
// You can just define the accounts object yourself, just make sure
// to use the correct property names.
require('console-stamp')(console, 'HH:MM:ss.l')
const SteamUser = require('steam-user')
const steamtotp = require('steam-totp')
const fs = require('fs')
const rs = require('readline').createInterface({
input: process.stdin,
output: process.stdout
})
const PATH = 'steamdata.json'
const GAMES = [730]
let data
if (fs.existsSync(PATH)) {
data = JSON.parse(fs.readFileSync(PATH))
} else throw 'Steam account data file not found.'
function hide (client) {
client.gamesPlayed([399220, 399080, 399480])
console.log(`Attempted to hide recent games.`)
}
function login (client, account) {
client.logOn({
accountName: account.name,
password: account.password
})
}
function build (account) {
function log (msg) { console.log(`[${account.name}] ${msg}`) }
let client = new SteamUser()
client.setOption('promptSteamGuardCode', false)
login(client, account)
client.on('steamGuard', (domain, callback) => {
log(`steamGuard event received.`)
if (account.shasec) {
steamtotp.getAuthCode(account.shasec, (err, code, offset, latency) => {
if (err) throw err
log(`Got mobile auth code (${code}) with a delay of ${latency} ms.`)
callback(code)
})
} else {
rs.question(`[${account.name}] ${domain ? 'Email' : 'Mobile'} code: `, code => callback(code))
}
})
let timer
client.on('loggedOn', details => {
log(`Logged on from ${details.public_ip}.`)
hide(client)
timer = setInterval(hide, 2*60*1000, client)
})
client.on('error', err => {
clearInterval(timer)
log(`Error '${err.message}' catched, retrying in ${(i/1000)/60} minutes.`)
if (err.message === 'LoggedInElsewhere') {
setTimeout(
function() { timer = setInterval(hide, 2*60*1000, client) },
10*60*1000
)
} else {
let i = (err.message === 'RateLimitExceeded' ? 30*60*1000 : 2*60*1000)
client.logOff()
setTimeout(login, i, client)
}
})
}
for (let name in data) { build(data[name]) }
{
"main": {
"name": "fsoc",
"password": "secret",
"shasec": "even more important secret"
},
"note": "this is just an example to show the required layout"
}
@fs-c
Copy link
Author

fs-c commented Aug 4, 2017

Just as a note, the shasec (= shared secret) is a 28-place string that is used to generate your steam guard auth codes. It's somewhat tricky to get it, as it requires root access to the phone you use to generate your codes which is why the shasec property is optional.

If you leave it blank, you will be asked for your steam guard code every startup (and every time the session runs out).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment