• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

NODE.js Grabbing RSA KEY of TIBIA-10

Snavy

Bakasta
Senator
Joined
Apr 1, 2012
Messages
1,249
Solutions
71
Reaction score
621
Location
Hell
I have followed This Tutorial and did everything that it says. But I am receiving an error message which im not able to find a solution for:

Code:
Nedims-Air:shivera nedimkanat$ node findRSAkey.js

test1 // This was to see where the code was giving error
buffer.js:191
    throw new TypeError('"encoding" must be a valid string encoding');
    ^

TypeError: "encoding" must be a valid string encoding
    at fromString (buffer.js:191:11)
    at Function.Buffer.from (buffer.js:99:12)
    at new Buffer (buffer.js:80:17)
    at binString (/Users/nedimkanat/Desktop/shivera/node_modules/binstring/lib/binstring.js:28:14)
    at Object.<anonymous> (/Users/nedimkanat/Desktop/shivera/findRSAkey.js:23:17)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)

Error line is 24
in This file:

Code:
// import dependencies
var fs = require('fs-sync');
var binstring = require('binstring');

// define all options here
var options = {
    // where to save RSA key
    outputFile: 'RSA.txt',

    // where is your Tibia client
    inputFile: '/Users/nedimkanat/Downloads/Tibia/Tibia.exe',
    // convert binary file to human readable utf8 format
    conversionOptions: { in: 'bin', out:'utf8' },

    // this is most important, it assumes that RSA key is string of 245 digits long or
    // longer and no other string is so long like this one,
    // if there will be more matches like this we have a problem
    RSApattern: /\d{245,}/g
};

// humanize
console.log("test1");
var humanData = binstring(fs.read(options.inputFile), options.conversionOptions);

console.log("test2");
// extract RSA with RegEXP
var RSA = humanData.match(options.RSApattern);

// assume only 1 match found
try {
    RSA[0] ? RSA = RSA[0] : null;
} catch(Error) {
    console.log('no match');
}
// save it to output file
fs.write(options.outputFile, RSA);

// confirm by outputing result to console
console.log(RSA);
[code]
 
Solution
after a fast read on a forum I found out whats the problem.
binstring conversion options are wrong (just one), you can check it here, anyways the solution is this
change
JavaScript:
conversionOptions: { in: 'bin', out:'utf8' },
to
JavaScript:
conversionOptions: { in: 'binary', out:'utf8' },
after a fast read on a forum I found out whats the problem.
binstring conversion options are wrong (just one), you can check it here, anyways the solution is this
change
JavaScript:
conversionOptions: { in: 'bin', out:'utf8' },
to
JavaScript:
conversionOptions: { in: 'binary', out:'utf8' },
 
Solution
Back
Top