This repo contains 3 parts
- DGDATA
- NK's
Profile.save
- NK's
sig
s andnonce
s
for a npm project simply use
npm i nksku
- NKsku
- Installation
- Credit where credit is due
- DGDATA - Data Scheme
- Profile.save
- signatures and nonces
- Extras
DGDATA code was from this npm package before it became a rickroll
Profile.save decryption was heavily referenced from averysumener's c++ Profile.save thingy and BowDown097's provided c# code. This would not have been possible without them.
sig
and nonce
formulas would not be available would not have been possible without Woob and Coral#0762
Primitively, you can just fetch
the url
const nksku = require('nksku');
const url = "https://";
request(url, { encoding: null }, (err, res, body) => {
if (err) {
// handle error code
}
let decodedBody = nksku.dgdata.decode(body).toString('utf-8');
let json = JSON.parse(decodedBody);
}
(Formerly known as NKTools)
Converts an array of bytes to text
Parameters
array
An
array array of utf-8 bytes
Returns string A string
Converts a string to a utf-8 array
Parameters
str
A
str string
Returns Array Returns an array of numbers
Decodes a string or array of DGData Arrays work best, as strings loose data due to utf-8 / unicode
Parameters
data
This
data is the data to be decoded
Returns string This is the result of the data
Encodes a string of data
Parameters
data
Data
data to be encoded
Returns array An array of bytes
Encodes a number - You really shouldn't have to deal with this
Parameters
number
The
number number to be encoded
Returns number The result
Hashes some data - You really shouldn't have to deal with this unless you want to manually verify the program
Parameters
data
Some
data data - it's a string
Returns array An array of bytes
just some standard stuff, did something a bit different using promisify in this example
const { nksave } = require('nksku');
const fs = require('fs');
const { promisify } = require('util');
const readFile = promisify(fs.readFile);
async function main() {
let bytes = await readFile('./path/to/Profile.save', null);
let json = nksave.unpack(bytes);
// log it, write to file, etc
}
main();
similar to above example
const { nksave } = require('nksku');
const fs = require('fs');
const { promisify } = require('util');
const readFile = promisify(fs.readFile);
const writeFile = promisify(fs.readFile);
async function main() {
let bytes = await readFile('./path/to/editedfile.json', null);
let encoded = nksave.pack(bytes);
await writeFile('./path/to/Profile.save', encoded);
}
main();
Decrypts a given Buffer of an NK save file
Parameters
bytes
- A Buffer of the
Profile.save
file
Returns string string containing the decrypted text in Profile.save
Encrypts a given Buffer the same way as NK encrypts its Profile.save
Parameters
json
- A Buffer of any text
Returns Buffer buffer to write data to a .save
file
For manual generation of sig
see https://signonce.netlify.app/
const { signonce } = require('nksku');
// generate a nonce
let nonce = signonce.generate64BitNonce();
// signature finder
// example 1: let it generate from a string
let obj = '{}';
let sig = signonce.sign(obj, nonce);
// example 1.5: let it generate w/o a nonce, used for validating responses
let obj = '{}';
let sig = signonce.sign(obj);
// example 2: sign from an obj
let obj = {};
let sig = signonce.sign(obj, nonce);
// example 2.5: let it generate w/o a nonce, used for validating responses
let obj = {};
let sig = signonce.sign(obj);
// example 3: sign from a whole request (probably for checking)
let obj = {
data: '{}',
auth: {
session: null,
appID: 11,
skuID: 35,
device: 'vrej'
},
sig: 'dc1027f28bc1ba12f6ef770588cdd1f4',
nonce: '6129188331007147111'
};
let sig = signonce.sign(obj); // undefined nonce = use object's nonce
// example 4: same as example 3 but for some reason u put in a nonce
let obj = {
data: '{}',
auth: {
session: null,
appID: 11,
skuID: 35,
device: 'vrej'
},
sig: 'dc1027f28bc1ba12f6ef770588cdd1f4',
nonce: '6129188331007147111'
};
let nonce = obj.nonce;
let sig = signonce.sign(obj, nonce);
./nk-server-code
contains NK's actual server code (not all of them, and not in correct folder structure)