TibiaAPI icon indicating copy to clipboard operation
TibiaAPI copied to clipboard

RSA Decryption Fails Using 'Record' App with latest client version

Open GPRicci opened this issue 5 years ago • 6 comments

I've just started checking out this API, so I'm not too sure on how to proceed with this error. I ran the 'Record' app, then started the client (loginWebService modified to http://127.0.0.1:7171/). I get my character list without issues, however when I try to connect to the game world with a character the following error pops up in the console:

ERROR System.Exception: [Connection.BeginReceiveClientCallback] RSA decryption failed.
   at OXGaming.TibiaAPI.Network.Connection.BeginReceiveClientCallback(IAsyncResult ar) in /home/dev/Documents/TibiaAPI/TibiaAPI/Network/Connection.cs:line 804
ERROR Data: 9D 00 00 00 00 00 0A 07 00 E7 04 E7 04 00 00 0B 00 31 32 2E 35 35 2E 31 30 34 35 34 DA 67 01 13 40 1E E1 B8 5F EB 1F DF 26 2B E2 B7 14 A6 7C EA 0E CA E7 2F B0 75 91 83 EA 26 C2 E0 07 F4 F5 19 DA 17 80 A7 2A 2D 4C 75 45 95 91 EB 3D EC 6E 11 76 EE 20 46 D8 44 32 CF D8 78 53 BC D4 1C FC FA AD FD DB 53 C5 7F 08 1F F1 B8 1C DA 0D 15 19 8E C3 A0 D9 5D 9C 0D E5 26 D9 71 BB CF 33 D4 01 B1 89 88 ED BA 8D E2 E3 50 35 CF 92 50 FD A5 35 18 A2 4D 1D C1 3C B3 D0 1F 2D 4B F7 EB E2 43 A8

I'm logging in to official Tibia servers using the official and latest client. Perhaps something changed in the latest version regarding the encryption of packets? RSA key changed? Thank you beforehand.

GPRicci avatar Nov 24 '20 23:11 GPRicci

Testing Record app on party-hunt branch throws this error when selecting a character from the character list:

ERROR Org.BouncyCastle.Crypto.DataLengthException: input too large for RSA cipher.
   at Org.BouncyCastle.Crypto.Engines.RsaCoreEngine.ConvertInput(Byte[] inBuf, Int32 inOff, Int32 inLen) in /_/crypto/src/crypto/engines/RSACoreEngine.cs:line 101
   at Org.BouncyCastle.Crypto.Engines.RsaEngine.ProcessBlock(Byte[] inBuf, Int32 inOff, Int32 inLen) in /_/crypto/src/crypto/engines/RsaEngine.cs:line 81
   at OXGaming.TibiaAPI.Network.Rsa.ProcessBlock(NetworkMessage message, Int32 index, RsaEngine engine) in /home/dev/Documents/TibiaAPI/TibiaAPI/Network/Rsa.cs:line 104
   at OXGaming.TibiaAPI.Network.Rsa.OpenTibiaDecrypt(NetworkMessage message, Int32 index) in /home/dev/Documents/TibiaAPI/TibiaAPI/Network/Rsa.cs:line 62
   at OXGaming.TibiaAPI.Network.Connection.BeginReceiveClientCallback(IAsyncResult ar) in /home/dev/Documents/TibiaAPI/TibiaAPI/Network/Connection.cs:line 797
ERROR Data: 9D 00 00 00 00 00 0A 07 00 E7 04 E7 04 00 00 0B 00 31 32 2E 35 35 2E 31 30 34 35 34 DA 67 01 BA 02 41 67 2F C2 58 BD 14 95 58 59 CA B8 31 F4 6A AB CD 50 83 56 34 14 10 D4 C0 52 A1 54 50 3D 5E 4D AA 58 C9 3D 07 2E D4 C2 09 C6 CB 2A 16 8B 0A F7 41 8C 45 B6 8E D8 BC FE 6C 35 3D 3E 66 83 9A 3C 27 9A 34 C4 BD 22 53 83 D8 8D D9 8D 27 39 5D 39 5B EC 09 F2 A1 98 F3 C7 3A D4 49 9A 41 B2 A0 0D 6F F4 58 7A CC 68 25 BB 70 6B 40 BC 15 98 42 8A 69 38 55 52 45 59 EE F0 60 EB 71 66 30 69

GPRicci avatar Nov 25 '20 00:11 GPRicci

They dont support 12.55, stoppeds work on 12.51. new packets.

Berzekz avatar Nov 26 '20 21:11 Berzekz

I see. That's a shame. But I can imagine the amount of work this project required was probably formidable. Thank you for the heads-up!

GPRicci avatar Nov 27 '20 01:11 GPRicci

@GPRicci thanks for the report. Unless someone else submits a PR before me, it may be some time before I update it for the latest update as I am quite busy IRL.

jo3bingham avatar Dec 02 '20 20:12 jo3bingham

Thank you for your answer, Joe! It's ok. RL comes first. I wish I had the knowledge to colaborate with an update.

GPRicci avatar Dec 03 '20 13:12 GPRicci

@GPRicci I managed to make it work with client version 12.66.10792 (latest) It seems like you did not change the RSA key to use the Open Tibia RSA.. Even though you are connecting to the official Tibia™, you still need to change the RSA Key because it's an asymmetric cryptography. So the tool can encrypt using the Tibia™ RSA, but it can't decrypt. If it's not able to decrypt, it's not able to store it in the .oxr file.

RafaeLeal avatar May 14 '21 03:05 RafaeLeal