Hello,
I'm trying to code a login server in nodejs for the Nostalrius 7.7 server. However I've been struggling a couple of days now with decoding the XTEA part of the request from the client.
Im using the node-rsa package to do this and I'm pretty sure I've got the correct private RSA key.
The error that I get says that i probably have the wrong key, but I've double checked and I think its something else.
The error looks like this: Error: Error during decryption (probably incorrect key). Original error: Error: error:04099079:rsa routines:RSA_padding_check_PKCS1_OAEP_mgf1aep decoding error
And I get it as soon as I send the request from OTClient.
So I'm pretty stuck here and cant get any further before I've got this decoding issue solved. I dont want to use any existing login server, I'm doing this because I want to learn. If anyone can help me with this I would be really glad. I can pay you with Bitcoins or however you prefer. I just need this issue sorted because it's really driving me crazy. Thank you
This is my code:
I'm trying to code a login server in nodejs for the Nostalrius 7.7 server. However I've been struggling a couple of days now with decoding the XTEA part of the request from the client.
Im using the node-rsa package to do this and I'm pretty sure I've got the correct private RSA key.
The error that I get says that i probably have the wrong key, but I've double checked and I think its something else.
The error looks like this: Error: Error during decryption (probably incorrect key). Original error: Error: error:04099079:rsa routines:RSA_padding_check_PKCS1_OAEP_mgf1aep decoding error
And I get it as soon as I send the request from OTClient.
So I'm pretty stuck here and cant get any further before I've got this decoding issue solved. I dont want to use any existing login server, I'm doing this because I want to learn. If anyone can help me with this I would be really glad. I can pay you with Bitcoins or however you prefer. I just need this issue sorted because it's really driving me crazy. Thank you
This is my code:
JavaScript:
let net = require('net');
let NodeRSA = require('node-rsa');
let pkey = `-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQCbZGkDtFsHrJVlaNhzU71xZROd15QHA7A+bdB5OZZhtKg3qmBWHXzLlFL6AIBZ
SQmIKrW8pYoaGzX4sQWbcrEhJhHGFSrT27PPvuetwUKnXT11lxUJwyHFwkpb1R/UYPAbThW+sN4Z
MFKKXT8VwePL9cQB1nd+EKyqsz2+jVt/9QIDAQABAoGAQovTtTRtr3GnYRBvcaQxAvjIV9ZUnFRm
C7Y3i1KwJhOZ3ozmSLrEEOLqTgoc7R+sJ1YzEiDKbbete11EC3gohlhW56ptj0WDf+7ptKOgqiEy
Kh4qt1sYJeeGz4GiiooJoeKFGdtk/5uvMR6FDCv6H7ewigVswzf330Q3Ya7+jYECQQERBxsga6+5
x6IofXyNF6QuMqvuiN/pUgaStUOdlnWBf/T4yUpKvNS1+I4iDzqGWOOSR6RsaYPYVhj9iRABoKyx
AkEAkbNzB6vhLAWht4dUdGzaREF3p4SwNcu5bJRa/9wCLSHaS9JaTq4lljgVPp1zyXyJCSCWpFnl
0WvK3Qf6nVBIhQJBANS7rK8+ONWQbxENdZaZ7Rrx8HUTwSOS/fwhsGWBbl1Qzhdq/6/sIfEHkfeH
1hoH+IlpuPuf21MdAqvJt+cMwoECQF1LyBOYduYGcSgg6u5mKVldhm3pJCA+ZGxnjuGZEnet3qeA
eb05++112fyvO85ABUun524z9lokKNFh45NKLjUCQGshzV43P+RioiBhtEpB/QFzijiS4L2HKNu1
tdhudnUjWkaf6jJmQS/ppln0hhRMHlk9Vus/bPx7LtuDuo6VQDo=
-----END RSA PRIVATE KEY-----`;
const key = new NodeRSA();
key.setOptions({ encryptionScheme: 'pkcs1_oaep', environment: 'node'});
key.importKey(pkey);
let server = new net.createServer(function(socket){
socket.on('data', function(data){
let packetLength = data.readUInt16LE(0);
let command = data.readUInt8(2);
let os = data.readUInt16LE(3);
let version = data.readUInt16LE(5);
let spr = data.readInt32LE(7);
let dat = data.readInt32LE(11);
let pic = data.readInt32LE(15);
let encryptedBuffer = data.slice(19, data.length);
console.log(encryptedBuffer.length); // 128
console.log(key.decrypt(encryptedBuffer, 'buffer'));
});
});
server.listen(7171, '127.0.0.1');