• 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!

TFS 1.X+ Key.pem struggling

ralke

(҂ ͠❛ ෴ ͡❛)ᕤ
Joined
Dec 17, 2011
Messages
1,470
Solutions
27
Reaction score
844
Location
Santiago - Chile
GitHub
ralke23
Twitch
ralke23
Hi! I have some troubles linking my server and client via rsa. I use Nekiro TFS 1.4 downgrade 8.6, and trying to link to a Tibia Cipsoft 8.6 client with extended sprites.
For this, first I follow this tutorial from @Sun [Tutorial] Generate RSA keys (https://otland.net/threads/tutorial-generate-rsa-keys.261681/#post-2666061)

Then I get RSA public and private. The thing is, the Public RSA that generates openssl is shorter than the Tibia Cipsoft public RSA. This is the example:

rsakey.png

rsa comparacion.png

RSA OLD (from the 8.6 client I need to edit)
Code:
109120132967399429278860960508995541528237502902798129123468757937266291492576446330739696001110603907230888610072655818825358503429057592827629436413108566029093628212635953836686562675849720620786279431090218017681061521755056710823876476444260558147179707119674283982419152118103759076030616683978566631413

RSA GENERATED
Code:
D0D40BE9987D6093626F93658C495B66FF031ACA9CE979D6C10845C92B58224E693252C5753209AB1A4BE3282297E0E01679C98317A73C030E25AB2DD35B418172C83C80F94E8EDF36F6DB26CE7AED1C3DC9C81C3793C56CD40A7791BED6578A032FE04C913390B1E1AA2E773C95261799C29BBF7FEE4AB25BD037F04C34846B

As you can see, the second RSA that is generated by openssl is shorter, so I open a hex editor, and replace the old RSA and filled the spaces with ceros.
ceros fill (1).png

I was able to save the client .exe and start it. But when I tried to log-in I encountered the following error:
Disconnected from server. (2000002)

----Second Try
After this I took a different way, I started to try to revert the key.pem commit from TFS putting back the red lines

To do that I started to update my libraries to make them work with GMP, also deleted Crypto #includes
A lots of errors appeared (like 600 errors)
error logs.png
but it really make everything a mess. Then, the show potential fixes option suggested me to run
Code:
./bootstrap-vcpkg.bat
./vcpkg install libmysql:x64-windows
./vcpkg install lua:x64-windows
./vcpkg install boost-asio:x64-windows
etc... etc... it takes a eternity to install them all, so I better ask here to see if actually is a possibility to redo the commits or if this will be a time waste

In resume, any chance to generate a working public key for Tibia Cipsoft 8.6 client that works along with a generated private key.pem?
Thanks in advance! Hope you guys can help me on this one!
 
Last edited:
Solution
Your generated key is in hexadecimal notation, you have to convert it to decimal to make it as long as the original cip key. You can find conversion tools online.
This hex:
Code:
D0D40BE9987D6093626F93658C495B66FF031ACA9CE979D6C10845C92B58224E693252C5753209AB1A4BE3282297E0E01679C98317A73C030E25AB2DD35B418172C83C80F94E8EDF36F6DB26CE7AED1C3DC9C81C3793C56CD40A7791BED6578A032FE04C913390B1E1AA2E773C95261799C29BBF7FEE4AB25BD037F04C34846B
as dec:
Code:
146644224002136605336001361340243559017304160547491966284461208145971435291419767497544521781016198450674181245991494178120925820265329750709186684152025037060082536762809714513465202734107541957212474156743362237732022249919405576764585849195549517890482739035171086436405524231125394199835436495698526504043
Converter:

Now it has 309 letters. It's same length as original tibia key.

Generating these keys is quite complicated. I made site that generate random key pair and print it values in format for server and client:

Did not test yet, if generated client-server key pair runs fine.

EDIT:
PHP code from that post generated wrong key.pem file content. It should be PKCS#1 and code generated PKCS#8 format.
Website code is updated. Updated PHP code is available here:
 
Last edited:
So what was his solution, because he didn't post any links? 🤣

I forgot to convert to decimal. Gesior's solution is the same ;P
But what is wrong is the RSA generator, tried by using it but didn't worked well

Used mehah's otc to load the RSA and key.pem; something that can be usefull on further views is that the RSA modulus has to be placed here:

You will find something like this inside:
rsa.png
The ".." marked on red circle makes new strings without modificating the RSA

That means the RSA can be pasted inside "", or divided in "".."".."".."" to see it clearer on the notepad file.
About the Sun tutorial, it worked perfectly, generated RSA on GitBash without troubles, just don't forget to convert the INTEGER to decimal and paste the generated key.pem inside the server folder.

Regards!
 
Online RSA generator is fixed. Now it generates valid key.pem file:

Also added textarea with 'n' formatted as in OTClient, ex.:
Code:
OTSERV_RSA = "1479426533490402423164461080131944795039215444673982794834259264" ..
             "6726602649585136060973539941984272224546873064703087203995499628" ..
             "7207009926284542426252550305208574382395268391964359217452497105" ..
             "1265812757758989981206046111202425183042033667083723276003723764" ..
             "88127524107919881890011662484288403037937075469368799"

It wasn't possible with OpenSSL lib. I had to use phpseclib and some hack to get all values required for old OTSes.
Source code: GitHub - gesior/ots_rsa_generator: OTS RSA Generator - code of https://ots.me/rsa/ (https://github.com/gesior/ots_rsa_generator)
 
Back
Top