Git Product home page Git Product logo

nostale-cryptography's Introduction

NosTale Cryptography

The NosTale Client, Server and Archive cryptographic algorithms for Node.js.

Installation

Using npm:

$ npm i nostale-cryptography

Client API

In Node.js:

NB: Arguments wrapped into square brackets are optional.

const nosCrypto = require('nostale-cryptography').Client
// or
const nosCrypto = require('nostale-cryptography/client')

const nostalePath = 'C:\\Program Files (x86)\\NosTale_IT'
const username = Buffer.from('myUsername')
const password = Buffer.from('myPassword')
const session = 123456
const versionString = '0.9.3.3087'

// To get the Login Crypto you must pass nothing.
const encryptLoginStream = nosCrypto.createCipher()
const decryptLoginStream = nosCrypto.createDecipher()

// To get the World Crypto you must pass the session number.
const encryptWorldStream = nosCrypto.createCipher(session)
const decryptWorldStream = nosCrypto.createDecipher(session)

const encryptedSession = nosCrypto.encryptSession(session)

const encryptedPassword = nosCrypto.encryptPassword(password) // NosTale Gameforge
const encryptedPasswordLegacy = nosCrypto.encryptPasswordLegacy(password) // NosTale Vendetta

const guid = 'xxxxxxxx-xxxx-4xxx-xxxx-xxxxxxxxxxxx' // GUID generated by the GF Login
/*
You can find your GUID in regedit under:
HKEY_CURRENT_USER > Software > Gameforge4d > TNTClient > MainApp, keyName: installationId
*/

// On Windows
const version = nosCrypto.createVersion(nostalePath [, directx]) // Returns a Promise

// On Linux/macOS
const version = nosCrypto.createVersion(versionString) // Returns a Promise
/*
You can find the Client version by right clicking on
NostaleClientX.exe > Properties > Details
*/

const checksumHash = nosCrypto.createChecksumHash(username, nostalePath [, directx, opengl]) // Returns a Promise

Example:

'use strict'

const { pipeline } = require('stream')
const iconv = require('iconv-lite')
const net = require('net')
const nosCrypto = require('nostale-cryptography/client')

const host = '<NosTale IP>'
const port = <NosTale Port>

const socket = net.connect(port, host, () => {
  const encryptStream = nosCrypto.createCipher()
  const decryptStream = nosCrypto.createDecipher()

  const encodingStream = iconv.encodeStream('win1252')
  const decodingStream = iconv.decodeStream('win1252')

  pipeline(
    encodingStream,
    encryptStream,
    socket,
    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', (packet) => {
      console.log(packet)

      // ...
      // Handle packet
      // ...
    })
  })
})

async function buildLoginPacket () {
  const nostalePath = 'C:\\Program Files (x86)\\NosTale_IT'
  const username = '<Your username>'
  const password = '<Your password>'

  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 = 'xxxxxxxx-xxxx-4xxx-xxxx-xxxxxxxxxxxx' // Used only by the Gameforge Client
  const version = await nosCrypto.createVersion(nostalePath)
  const checksumHash = await nosCrypto.createChecksumHash(encodedUsername, nostalePath)

  return `NoS0575 ${random} ${username} ${encryptedPassword} ${guid} ${version} 0 ${checksumHash}`
}

nostale-cryptography's People

Contributors

nicogorr avatar

Watchers

James Cloos avatar Ricardo Moya avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.