Skip to main content

A reverse engineered packet cryptography - encryption and decryption routines to emulate NosTale client or server

Project description

NosCrypto

A reverse engineered packet cryptography - encryption and decryption routines to emulate NosTale client or server.

Abstract

The goal of this project is to recreate an algorithm that is used to encrypt/decrypt net packets that are exchanged between NosTale client and server. I've seen many public cryptos but I think none of them were producing exactly the same output as real client or server (especially when it comes to special characters like ąśżź etc). The problem of a majority of those libraries is an incorrect mask generation algorithm. If you ever encounter output produced by this library that is different from the original produced by game client or server, please report it immediately.

Installation

Please use pypi to install this library:

pip install noscrypto

Tests

Unit tests are available under noscrypto/tests

Usage

All the functions accept bytes as input and return bytes as output. Keep in mind that each function should accept and output only single packet. It is extremely important when you are, for example decrypting world packets as a client, because sometime the server sends multiple packets in one call (they are splited by 0xFF, and you should decrypt the packets chunk by chunk)

Client

Functions can be imported like

from noscrypto import Client

Client.LoginEncrypt

Encrypts your packet so the login server can read it. Automatically adds the \n character at the end of packet if not present.

>>> Client.LoginEncrypt("hey".encode("ascii"))
b'\xba\xb5\xc9\xd8'

Client.LoginDecrypt

Decrypts your login result packet, so you can read it

>>> Client.LoginDecrypt(b'\x75\x70\x78\x7B\x72\x2F\x44\x19').decode("ascii")
'failc 5\n'

Client.WorldEncrypt

Encrypts your pakcet so the world server can read it. Beside packet you also need to supply your session (that one you received from login server). The last parameter is_first_packet (default False) must be set to True only if you are sending your first packet to the world server (the session packet)

>>> Client.WorldEncrypt("hey!".encode("ascii"), 1337, False)
b'}\x10\x13\xffWx'

Client.WorldDecrypt

Decrypts your wolrd packet sent by server, so you can read it

>>> Client.WorldDecrypt(b'\x04\x8C\x8B\x9E\x8B\x96\x16\x65\x16\x65\x1A\x41\xA4\x14\x15\x46\x8E\xFF')
b'stat 221 221 60 60 0 1024\n'

Server

Functions can be imported like

from noscrypto import Server

Server.LoginEncrypt

Encrypts your packet so the client can read it. Automatically adds the \n character at the end of packet if not present.

>>> Server.LoginEncrypt("hello world".encode("ascii"))
b'wt{{~/\x86~\x81{s\x19'

Server.LoginDecrypt

Decrypts login packet from client, so you can read it

>>> Server.LoginDecrypt(b'\xba\xb5\xc9\xd8').decode("ascii")
'hey\n'

Server.WorldEncrypt

Encrypt world packet, so the client can read it

>>> Server.WorldEncrypt("stat 221 221 60 60 0 1024\n".encode("ascii"))
b'\x04\x8c\x8b\x9e\x8b\x96\x16e\x16e\x1aA\xa4\x14\x15F\x8e\xff'

Server.WorldDecrypt

Decrypts client pakcet so the world server can read it. Beside packet you also need to supply client session. The last parameter is_first_packet (default False) must be set to True only if you didn't recv the first packet from client yet (the session packet).

>>> Server.WorldDecrypt(b'}\x10\x13\xffWx', 1337, False).decode("ascii")
'hey!'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

noscrypto-0.1.2.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

noscrypto-0.1.2-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file noscrypto-0.1.2.tar.gz.

File metadata

  • Download URL: noscrypto-0.1.2.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.40.1 CPython/3.7.4

File hashes

Hashes for noscrypto-0.1.2.tar.gz
Algorithm Hash digest
SHA256 1ed83a14ca55d8c1be12a7cc79ccd7812c5eda0c6c085a8c316689e1e6408ca7
MD5 6c9f4804b724fa0557869c9ab8ef0924
BLAKE2b-256 b3caf5218102b234e8798618cb69c184c97905a6909ee01a2d29a5e4102feafb

See more details on using hashes here.

File details

Details for the file noscrypto-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: noscrypto-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.40.1 CPython/3.7.4

File hashes

Hashes for noscrypto-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4328c15555b19cbeaa6494fcfeb132dcd088548acbd5026f3ca43aa328e07e33
MD5 6fc51cbf7573faa6c9ba2192701f2f21
BLAKE2b-256 5ceaf75a96835ef47088244c5e9693e2c533a8362a45de66ffb38af94af31ca1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page