Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Websocket from 'websocket'
- import axios from 'axios-https-proxy-fix'
- import querystring from 'querystring'
- import { machineIdSync} from 'node-machine-id'
- import { client as WebSocketClient } from 'websocket'
- console.log('Authorization 4game client Copyright (c)2019 by iceTeam')
- console.log('Settings file: ', process.argv[2] + '.json')
- const settings = require('./' + process.argv[2] + '.json')
- const axiosproxyConfig = { host: settings.proxy.ip, port: settings.proxy.port, auth: {
- username: settings.proxy.login,
- password: settings.proxy.pass
- }}
- var child = require('child_process').execFile
- const WsClient = new WebSocketClient()
- const launcherFile = settings.main.launcherFile
- const email = settings.main.email
- const password = settings.main.password
- const useProxy = settings.main.useProxy
- const compName = settings.main.compName
- const hwID = settings.main.hwID
- const launchID = settings.main.launchID
- let glob = {}
- glob.SessToken = makeID()
- const tokenRequest = async () => {
- console.log('\x1b[33m%s\x1b[0m', `Sending -> password=${password}&username=${email}&secure=true&grant_type=password`)
- const xReqID = makeID()
- const dataToPost = {'username': email, 'password': password, 'secure': 'true', 'grant_type': 'password'}
- try {
- const response = await axios.post('https://launcherbff.ru.4game.com/connect/token',querystring.stringify(dataToPost), {
- proxy: useProxy ? axiosproxyConfig : null,
- timeout:10000,
- headers: {
- 'origin': 'https://launcher.ru.4game.com',
- 'host': 'launcherbff.ru.4game.com',
- 'content-type': 'application/x-www-form-urlencoded',
- 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.24 Safari/537.36',
- 'computer-name' : compName,
- 'accept' : 'application/json, text/plain, */*',
- 'hardware-id' : hwID,
- 'launcher-id' : launchID,
- 'x-request-id' : xReqID,
- 'referer' : 'https://launcher.ru.4game.com/auth',
- 'session-token' : glob.SessToken,
- 'accept-encoding' : 'gzip, deflate',
- 'accept-language' : 'ru-ru',
- 'session-id' : '[object Object]'
- }
- })
- console.log('\x1b[32m', 'Response <- GOOD')
- glob.access_token = response.data && response.data.access_token
- glob.refresh_token = response.data && response.data.refresh_token
- return true
- } catch(e) {
- console.log('\x1b[31m', 'Response <- Error')
- if(e.response.data && e.response.data.error){
- const error = e.response.data.error
- glob.sessionId = e.response.data && e.response.data.error && e.response.data.error.data.sessionId
- return error.code === 'guard.emailcoderequired' ? await promptCode() : false
- }
- console.log(e.response.data)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement