SHARE
TWEET

Untitled

a guest Apr 26th, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import Websocket from 'websocket'
  2. import axios from 'axios-https-proxy-fix'
  3. import querystring from 'querystring'
  4. import { machineIdSync} from 'node-machine-id'
  5.  
  6. import { client as WebSocketClient } from 'websocket'
  7.  
  8. console.log('Authorization 4game client Copyright (c)2019 by iceTeam')
  9.  
  10. console.log('Settings file: ', process.argv[2] + '.json')
  11. const settings = require('./' + process.argv[2] + '.json')
  12.  
  13. const axiosproxyConfig =  { host: settings.proxy.ip, port: settings.proxy.port, auth: {
  14.   username: settings.proxy.login,
  15.   password: settings.proxy.pass
  16. }}
  17.  
  18. var child = require('child_process').execFile
  19.  
  20. const WsClient = new WebSocketClient()
  21. const launcherFile = settings.main.launcherFile
  22. const email = settings.main.email
  23. const password = settings.main.password
  24. const useProxy = settings.main.useProxy
  25. const compName = settings.main.compName
  26. const hwID = settings.main.hwID
  27. const launchID = settings.main.launchID
  28.  
  29. let glob = {}
  30.  
  31. glob.SessToken = makeID()
  32.  
  33. const tokenRequest = async () => {
  34.     console.log('\x1b[33m%s\x1b[0m', `Sending -> password=${password}&username=${email}&secure=true&grant_type=password`)
  35.     const xReqID = makeID()
  36.     const dataToPost = {'username': email, 'password': password, 'secure': 'true', 'grant_type': 'password'}   
  37.     try {
  38.         const response  = await axios.post('https://launcherbff.ru.4game.com/connect/token',querystring.stringify(dataToPost), {
  39.             proxy: useProxy ? axiosproxyConfig : null,
  40.             timeout:10000,
  41.             headers: {
  42.                 'origin': 'https://launcher.ru.4game.com',
  43.                 'host': 'launcherbff.ru.4game.com',
  44.                 'content-type': 'application/x-www-form-urlencoded',
  45.                 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.24 Safari/537.36',
  46.                 'computer-name' : compName,
  47.                 'accept' : 'application/json, text/plain, */*',
  48.                 'hardware-id' : hwID,
  49.                 'launcher-id' : launchID,
  50.                 'x-request-id' : xReqID,
  51.                 'referer' : 'https://launcher.ru.4game.com/auth',
  52.                 'session-token' : glob.SessToken,
  53.                 'accept-encoding' : 'gzip, deflate',
  54.                 'accept-language' : 'ru-ru',
  55.                 'session-id' : '[object Object]'
  56.             }
  57.         })
  58.         console.log('\x1b[32m', 'Response <- GOOD')
  59.         glob.access_token = response.data && response.data.access_token
  60.         glob.refresh_token = response.data && response.data.refresh_token  
  61.         return true
  62.     } catch(e) {
  63.         console.log('\x1b[31m', 'Response <- Error')
  64.         if(e.response.data && e.response.data.error){
  65.             const error = e.response.data.error
  66.             glob.sessionId = e.response.data && e.response.data.error && e.response.data.error.data.sessionId
  67.             return error.code === 'guard.emailcoderequired' ? await promptCode() : false
  68.         }
  69.         console.log(e.response.data)
  70.     }
  71. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top