- Joined
- Apr 1, 2012
- Messages
- 1,249
- Solutions
- 71
- Reaction score
- 621
- Location
- Hell
- GitHub
- idontreallywolf
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:
Error line is 24
in This file:
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]