Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const net = require('net');
- const { pipeline } = require('stream');
- const iconv = require('iconv-lite');
- const sleep = require('system-sleep');
- const nbind = require('nbind');
- const lib = nbind.init().lib;
- const Crypto = new lib.Crypto();
- let session = 0;
- let packetId = Math.floor(Math.random() * 9999999);
- const username = 'xxxxxxxx';
- const password = 'xxxxxxxxxxx';
- const nosCrypto = require('nostale-cryptography/client');
- let client = new net.Socket();
- const hostLogin = '79.110.84.75';
- const portLogin = 4002;
- const socketLogin = client.connect(portLogin, hostLogin);
- client.on('connect', function () {
- const encryptStream = nosCrypto.createCipher();
- const decryptStream = nosCrypto.createDecipher();
- const encodingStream = iconv.encodeStream('win1252');
- const decodingStream = iconv.decodeStream('win1252');
- pipeline(
- encodingStream,
- encryptStream,
- socketLogin,
- decryptStream,
- decodingStream,
- (err) => {
- if (err) {
- throw err
- }
- console.log('Game closed because stream pipeline closed.')
- }
- );
- buildLoginPacket().then((loginPacket) => {
- console.log(loginPacket);
- encodingStream.write(loginPacket);
- decodingStream.on('data', (packetLogin) => {
- console.log(packetLogin);
- session = parseInt(packetLogin.split(' ')[2]);
- })
- });
- });
- client.on('close', function() {
- let clientWorld = new net.Socket();
- const hostWorld = '79.110.84.37';
- const oortWorld = 4015;
- const socketWorld = clientWorld.connect(oortWorld, hostWorld);
- clientWorld.on('connect', function () {
- const encryptStream = nosCrypto.createCipher(session);
- const decryptStream = nosCrypto.createDecipher(session);
- const encodingStream = iconv.encodeStream('win1252');
- const decodingStream = iconv.decodeStream('win1252');
- pipeline(
- encodingStream,
- encryptStream,
- socketWorld,
- decryptStream,
- decodingStream,
- (err) => {
- if (err) {
- throw err
- }
- console.log('Game closed because stream pipeline closed.')
- }
- );
- clientWorld.write(Buffer.from(Crypto.encryptGamePacket(buildSessionWorldPacket(), session, true)));
- setTimeout(() => clientWorld.write(Buffer.from(Crypto.encryptGamePacket(buildLoginWorldPacket(), session, false).concat(Crypto.encryptGamePacket(buildPasswordWorldPacket(), session, false)))), 200);
- decodingStream.on('data', (data) => {
- console.log(data);
- });
- });
- });
- async function buildLoginPacket () {
- const nostalePath = 'C:\\Program Files (x86)\\NosTale_FR';
- const encodedUsername = iconv.encode(username, 'win1252');
- const encodedPassword = iconv.encode(password, 'win1252');
- const random = Math.floor(Math.random() * 9999999);
- const encryptedPassword = nosCrypto.encryptPassword(encodedPassword);
- const guid = '12d45678-123d-422a-a223-25bde24865dc';
- const version = await nosCrypto.createVersion(nostalePath);
- const checksumHash = await nosCrypto.createChecksumHash(encodedUsername, nostalePath);
- return `NoS0575 ${random} ${username} ${encryptedPassword} ${guid} ${version} 0 ${checksumHash}`;
- }
- function buildSessionWorldPacket() {
- let packet = packetId + ' ' + session;
- packetId += 1;
- console.log(packet);
- return packet;
- }
- function buildLoginWorldPacket() {
- let packet = packetId + ' ' + username;
- packetId += 1;
- console.log(packet);
- return packet;
- }
- function buildPasswordWorldPacket() {
- let packet = packetId + ' ' + password;
- packetId += 1;
- console.log(packet);
- return packet;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement