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 = {'password': password, 'username': email, 'grant_type': 'password', 'secure': 'true'}
- try {
- const response = await axios.post('https://launcherbff.ru.4game.com/connect/token',querystring.stringify(dataToPost), {
- proxy: useProxy ? axiosproxyConfig : null,
- 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 6.1; 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'
- }
- })
- 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
- }
- }
- }
- const promptCode = async () => {
- const readline = require('readline');
- const rl = readline.createInterface({input: process.stdin,output: process.stdout});
- rl.question('ENTER THE 5 NUM CODE:', async (emailCode)=>{
- glob.email_code = emailCode
- rl.close();
- return await sendEmailCode()
- });
- }
- const sendEmailCode = async () => {
- console.log('\x1b[33m%s\x1b[0m', `Sending -> sessionId=${glob.sessionId}&code=${glob.email_code}`)
- const xReqID = makeID()
- const dataToPost = {'sessionId': glob.sessionId, 'code': glob.email_code}
- try {
- const response = await axios.post('https://launcherbff.ru.4game.com/api/guard/accesscodes/activate',dataToPost, {
- proxy: useProxy ? axiosproxyConfig : null,
- headers: {
- 'Origin': 'https://launcher.ru.4game.com',
- 'Content-Type': 'application/json;charset=UTF-8',
- 'authorization' : `Bearer ${glob.access_token}`,
- 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; 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'
- }
- })
- console.log('\x1b[32m', 'Response <- GOOD')
- console.log('isActivated: ', response.data.data.userSession.isActivated)
- console.log('session-token: ', response.data.data.userSession.token)
- glob.SessToken = response.data && response.data.data.userSession.token
- return await tokenRequest()
- } catch(e) {
- console.log('\x1b[31m', 'Response <- Error')
- console.log(e)
- const error = e.response.data.error
- console.log(error)
- return error.code === 'guard.mismatchaccesscode' ? await promptCode() : false
- }
- }
- const getRelevantTokens = async () => {
- console.log('\x1b[33m%s\x1b[0m', `Sending -> grant_type=refresh_token&refresh_token=${glob.refresh_token}`)
- const xReqID = makeID()
- const dataToPost = {'grant_type': 'refresh_token', 'refresh_token': glob.refresh_token}
- try {
- const response = await axios.post('https://launcherbff.ru.4game.com/connect/token',querystring.stringify(dataToPost), {
- proxy: useProxy ? axiosproxyConfig : null,
- headers: {
- 'Origin': 'https://launcher.ru.4game.com',
- 'Host': 'launcherbff.ru.4game.com',
- 'authorization' : `Bearer ${glob.access_token}`,
- 'Content-Type': 'application/x-www-form-urlencoded',
- 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; 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'
- }
- })
- 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')
- console.log(e.response)
- return false
- }
- }
- const WsConnect = async () => {
- WsClient.on('connectFailed', function(error) {
- console.log('Connect Error: ' + error.toString());
- });
- WsClient.on('connect', function(connection) {
- console.log('\x1b[33m%s\x1b[0m', 'WebSocket Client Connected');
- connection.on('error', function(error) {
- console.log("Connection Error: " + error.toString());
- });
- connection.on('close', function() {
- console.log('echo-protocol Connection Closed');
- });
- connection.on('message', function(message) {
- const data = JSON.parse(message.utf8Data)
- parseWsRequests(data, connection)
- });
- getAuthProfile(connection)
- })
- WsClient.connect(`wss://launcherbff.ru.4game.com/?token=${glob.access_token}&hardware-id=${hwID}&launcher-id=${launchID}&computer-name=${compName}`);
- }
- const getAuthProfile = (connection) => { //Шлём для получения UserID
- console.log('\x1b[32m', ' Process -> getAuthProfile')
- glob.getAuthProfileID = makeID()
- connection.send(`{"jsonrpc":"2.0","method":"getAuthProfile","params":null,"id":"${glob.getAuthProfileID}"}`);
- }
- const getLogin = (connection) => {
- console.log('\x1b[32m', ' Process -> getLogin')
- glob.getLoginID = makeID()
- connection.send(`{"jsonrpc":"2.0","method":"getGameAccount","params":{"masterId":${glob.userID},"toPartnerId":"ro-ru"},"id":"${glob.getLoginID}"}`);
- }
- const acceptLicense = (connection) => {
- console.log('\x1b[32m', ' Process -> acceptLicense')
- glob.acceptLicenseID = makeID()
- connection.send(`{"jsonrpc":"2.0","method":"createGameAccount","params":{"masterId":${glob.userID},"toPartnerId":"ro-ru","fromPartnerId":"forgame-ru","acceptLicense":true},"id":"${glob.acceptLicenseID}"}`);
- }
- const createGameTokenCode = (connection) => {
- console.log('\x1b[32m', ' Process -> createGameTokenCode')
- glob.GameTokenCodeID = makeID()
- connection.send(JSON.stringify({
- "jsonrpc":"2.0",
- "method":"createGameTokenCode",
- "params":{
- "accessToken":glob.access_token,
- "fromPartnerId":"forgame-eu",
- "ignoreLicenseAcceptance":true,
- "login":glob.login,
- "masterId":glob.userID,
- "toPartnerId":"ro-ru"
- },
- "id":glob.GameTokenCodeID
- }))
- }
- const parseWsRequests = async (data, connection) => {
- switch (data.id) {
- case `${glob.getAuthProfileID}`:
- glob.userID = data.result.id
- getLogin(connection)
- break;
- case `${glob.getLoginID}`:
- if (data.error && data.error.code === "gameauth.gameaccountsnotfound") {
- acceptLicense(connection)
- return
- }
- glob.login = data.result[0].login
- createGameTokenCode(connection)
- break;
- case `${glob.acceptLicenseID}`:
- if (data.error && data.error.code) {
- return
- }
- getLogin(connection)
- break;
- case `${glob.GameTokenCodeID}`:
- if (data.result) {
- launchFrost(data.result.login, data.result.password)
- }
- break;
- default:
- // statements_def
- console.log('\x1b[31m', 'Error:')
- console.log(data)
- break;
- }
- }
- const doRequests = async () => {
- await tokenRequest() && await getRelevantTokens() && WsConnect()
- }
- const launchFrost = (login, pass) => {
- // id:%LOGIN% pw:%PASS%
- const params = [login, pass]
- child(launcherFile, params, function(err, data) {
- console.log(err)
- console.log(data.toString());
- });
- }
- doRequests()
- function makeID() {
- var text = ""
- var possible = "abcdef1234567890"
- for( var i=1; i <= 8; i++ ) {
- text += possible.charAt(Math.floor(Math.random() * possible.length));
- }
- text += "-"
- for( var i=1; i <= 4; i++ ) {
- text += possible.charAt(Math.floor(Math.random() * possible.length));
- }
- text += "-"
- for( var i=1; i <= 4; i++ ) {
- text += possible.charAt(Math.floor(Math.random() * possible.length));
- }
- text += "-"
- for( var i=1; i <= 4; i++ ) {
- text += possible.charAt(Math.floor(Math.random() * possible.length));
- }
- text += "-"
- for( var i=1; i <= 12; i++ ) {
- text += possible.charAt(Math.floor(Math.random() * possible.length));
- }
- return text
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement