s2ward / 469

The bonelord language in Tibia
21 stars 8 forks source link

RSA Theory #6

Open fillipesilvav360 opened 2 years ago

fillipesilvav360 commented 2 years ago

RSA is a very popular and 100% math-based way of encrypting messages. Extremely complex to calculate by hand, or in your head, and virtually impossible to crack without computing power, if you don't know the correct encryption and decryption keys.

Some questions make me believe that this 469 language has something to do with RSA.

1) 100% numeric 2) Appears to be encrypted messages 3) Language name being 469 looks like a "key" 4) Several references to complex math-based language

My theory will be explained in 3 parts: 1) What is RSA, and how I calculated all possible encryption and decryption keys 2) The problem of separating the decoding blocks 3) The final char table (i'm using ASCII for now)

Part 1 - RSA

RSA is formed by keys that start their construction by prime numbers. If you factor out the number 469, you'll see that it's made up of 7 x 67, two primes.

When I saw this I thought it was worth the test and I started trying to use the number 469 and its factors to decrypt messages on hellsgate books and npc / cip members messages.

According to this algorithm, assembling the RSA is quite simple: RSA Algorithm

RSA Algorithm Example
1) Choose p = 3 and q = 11
2) Compute n = p * q = 3 * 11 = 33
3) Compute φ(n) = (p - 1) * (q - 1) = 2 * 10 = 20
4) Choose e such that 1 < e < φ(n) and e and φ (n) are coprime. Let e = 7
5) Compute a value for d such that (d * e) % φ(n) = 1. One solution is d = 3 [(3 * 7) % 20 = 1]
6) Public key is (e, n) => (7, 33)
7) Private key is (d, n) => (3, 33)
8) The encryption of m = 2 is c = (2^7) % 33 = 29
9) The decryption of c = 29 is m = (29^3) % 33 = 2

Since 7 x 67 = 469, I started to find a connection, I used p = 7 and q = 67. So far, it fits just fine.

Now one of the problems starts, the encryption key uses "e" and there are several possibilities in choosing "e" (given that 1 < e < φ(n)). Depending on the "e" you choose to encrypt, you will need a different "d" to decode.

If language 469 rely on RSA, they could have used any possible "e", so to decode we have to try every possible "d", by try and error.

For example: p = 7 and q = 67 n = p q = 469 φ(n) = (p - 1) (q - 1) = 6 * 66 = 396 A possible value for "e" would be: e = 5 If e = 5, then: d = 317 In this example the encryption key pair would be: (5, 469) And the decryption key pair would be: (317, 469)

But the formulas are also valid if: e = 7 for e = 7, then: d = 283 In this example the encryption key pair would be: (7, 469) And the decryption key would be: (283, 469)

The good side is that the possibilities of "e" are not infinite and, knowing the "e", calculate "d" is easy. So I made a python program that calculates all possible "e" and "d" and uses all pairs to try to decrypt messages, along with 469.

So far, problem solved.

Possible pairs are on this file: possible_e_and_d_values.txt

Part 2 and 3 - Blocks and Char Table

With the keys in hand and knowing how to use them to decode the messages, the mission is now to understand what to decode.

Generally what you do to use RSA is the following: 1) Message "A B C" 2) Transform "A B C" into numbers, using a table, for example in ASCII it would be "65 66 67" 3) Apply to each of these numbers the encryption key pair (e, n), for example (5, 469) -> "102 334 268". NOTE: This would be an example of an encrypted message (like books from hellsgate) that we are trying to decrypt. 4) To decrypt, we need to apply to each of the previous numbers the key pair (317, 469), then we would have again the first sequence of numbers "65 66 67" 5) We apply the ASCII table in reverse, and retrieve the original message "A B C"

Here we have 2 problems that I still don't know how to solve and I imagine that, if RSA is the answer for the 469 language, we will need something in the game to answer us: 1) What is the best blocks separation to run decodifications? 1 by 1? 2 by 2? First 4, then the following 6, then the following 9?
2) Is there using ASCII a good guess? Is there a another char table inside Tibia Bonelord Lore that fits better?

Hope you help me find some connections on this 2 problems!

Thanks!

elkolorado commented 2 years ago

Hello I tried with RSA while ago, when Forgotten Realms connection was noticed by Lee

See the python code here:

Details can be read here

Example

We will try to decipher 3478 since we are guessing it is equal to either beholder/bonelord

Generate private & public keys using makePublicPrivateKeys.py where you specify the p & q inside that file. For example I am using: p = 7, q = 67 (primes of 469)

Specify the chartable & mode (decrypt/encrypt) in the RSA.py inside the that file. For the charset I used 66 length one: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz12345 !?. since of the the reference to spell encrypt at Forgotten Realms

Inside the encypted_file.txt, I put our ciphertext (3478) which starts with number that represents the original message length, so beholder/bonelord will both be 8 letters long, and its followed by number which represents the block size (64). I am guessing 64, due to fact that inside Tibia, books are written in font Verdana. The maximum letters that you can put in one row is dynamic, since the letters in that fon't aren't monospace (not taking the same width). However, if you would put . you can enter 64 dots per row in book in tibia. The numbers however, are monospaced, and as seen in 469 books, each row is containing 32 characters.

The blocksize of original message will be between 32 and 64. Since this is minimum and maximum characters you can put per row in book in tibia using Verdana font.

For the example lets try with 64. Yet if you think about it, since the length of beholder is 8, then its lower than block size (min 32 max 64, so our blockisze doesn't matter when trying to decipher the single word). It will be different for the whole books though. Then our encypted_file.txt looks like this: 8_64_3478

Then when we will run the RSA.py the outcome will be: Decrypted text: yBAAAAAA

RagurC commented 2 years ago

Hello,

I pretty much think the same that the bonelord language is a cyphered text. Please see a book: https://tibia.fandom.com/wiki/Book_of_Funny_Letters_I_(Book)

Isnt this reference to Latin 1? Maybe use this "alphabet" https://docs.oracle.com/cd/E29584_01/webhelp/mdex_basicDev/src/rbdv_chars_mapping.html

Book can be found in Paradox Tower with some gibberish book in the same shelf.

Have a good one