I have managed to set up properly packet relay mechanism between client and server, so i am moving on to deciphering the packets. Right now i am stuck with the DH key packet sent by the server. I have read and re-read korvac's conquer wiki many times, but the codes are not documented, and is not self documenting to a java learner like myself, lol.
My understanding of CO cipher is that client receives DH key packet from server, client then performs initial cipher uses blowfish algorithm to decipher the packet to obtain the p,g,A keys. The key used for initial cipher is "DR654dt34trg4UI6". After obtaining p,g,A keys, a new shared public key is generated and will be used for future(starting from the second) packet ciphers.
[Problem description] Under the presumption that my understanding of the cipher is correct. I need THREE things to initialize my cipher object. (i) a key = "DR654dt34trg4UI6", (ii) an algorithm name = "Blowfish", (iii) an initial vector!!! Initial Vector is the problem i am having. combing through the codes on conquer wiki, (i might have overlooked)i have not seen the EncryptIV ever being initialized. Seems to me that it's always left as a new array of eight zeros.
[Request] May i know what the initial vector supposed to be, and i'd deeply appreciate if supporting knowledge is being shared.
[EDIT] Now i am wondering if my understanding is wrong or if i am using the wrong padding scheme or mode. Inferring from the wiki source("BF_cfb64_encrypt"), i believe CipherFeedBack mode is used, though i dont really understand what 64_encrypt means, but i am guessing it has something to do with 8bytes of data/IV.
Action speaks louder than words.. so i gave it a shot on by writing a little util tool that deciphers server key packet. here is a code snipplet in java
I have never had any prior knowledge of cryptography, so i am not too sure of the decryption mode and paddings. Logically speaking, since blowfish is a 64bit block cipher, and the sizes of p,g,A varies with every generation, some form of paddings has to be done. The output of the above piece of code is a complete mess. So i do ponder if there is an encryption or not, or where did i do wrong to obtain current wrong result?
[End of Edit]
The following is a sample of what i currently being getting. High lighted in green is the dh key packet from server. I have also noticed this packet size always varies.
My understanding of CO cipher is that client receives DH key packet from server, client then performs initial cipher uses blowfish algorithm to decipher the packet to obtain the p,g,A keys. The key used for initial cipher is "DR654dt34trg4UI6". After obtaining p,g,A keys, a new shared public key is generated and will be used for future(starting from the second) packet ciphers.
[Problem description] Under the presumption that my understanding of the cipher is correct. I need THREE things to initialize my cipher object. (i) a key = "DR654dt34trg4UI6", (ii) an algorithm name = "Blowfish", (iii) an initial vector!!! Initial Vector is the problem i am having. combing through the codes on conquer wiki, (i might have overlooked)i have not seen the EncryptIV ever being initialized. Seems to me that it's always left as a new array of eight zeros.
[Request] May i know what the initial vector supposed to be, and i'd deeply appreciate if supporting knowledge is being shared.
[EDIT] Now i am wondering if my understanding is wrong or if i am using the wrong padding scheme or mode. Inferring from the wiki source("BF_cfb64_encrypt"), i believe CipherFeedBack mode is used, though i dont really understand what 64_encrypt means, but i am guessing it has something to do with 8bytes of data/IV.
Action speaks louder than words.. so i gave it a shot on by writing a little util tool that deciphers server key packet. here is a code snipplet in java
Code:
Cipher cipherOut = Cipher.getInstance("Blowfish/CFB/NoPadding");
byte[] key = "DR654dt34trg4UI6".getBytes();
byte[] encryptedData = inputTextArea.getText().trim().getBytes(); //get the encrypted string without trailing and leading white spaces
byte[] iv = new byte[8]; //never see iv being initialized in wiki sources, so i'll just follow
IvParameterSpec ivs = new IvParameterSpec(iv);
SecretKeySpec keySpec = new SecretKeySpec(key,"Blowfish");
cipherOut.init (Cipher.DECRYPT_MODE,keySpec,ivs); //set cipher mode
encryptedData = cipherOut.doFinal(encryptedData); //perform cipher
outputTextArea.setText(new String(encryptedData)); //output result
[End of Edit]
The following is a sample of what i currently being getting. High lighted in green is the dh key packet from server. I have also noticed this packet size always varies.
Code:
run: Proxy Started : Listening for connection on port 9959 [GameProxy] : Thread started - Listening on 0.0.0.0/0.0.0.0:5816 @Auth Proxy : Client connected [AuthProxy] Connecting to :208.96.34.46 on port 9959 [AuthProxy] Obtain password seed :complete [AuthProxy] Sending authorization request :complete [AuthProxy] Authorization response :complete [AuthProxy] Extracting game server info : 216.93.183.196 [AuthProxy] Final reply to auth server :Complete. 80 [AuthProxy] Auth Relay Complete [GameProxy] : Client connected Starting up/down stream services @downStreamService Constructor : prox2serv true creating service threads @upstreamservice: updown streams obtained @downstreamservice: updown streams obtained @downStreamService: relaypacket started. [down:331][COLOR="SeaGreen"]29 D6 E5 9D 62 7C 94 D4 ED CC 97 56 A3 FD FC 85 26 D B7 57 3C A7 14 D4 B0 7C 7B E9 E7 35 63 D4 44 52 B8 29 C6 9C A7 52 9E 95 C6 EC F9 AA 93 AF 22 DC 26 BB DA 36 A9 C4 10 56 26 69 DE ED E0 1C 90 CD EE 5 27 5B E F4 18 B6 A4 1D D5 B B6 94 9B 68 B8 8F A5 59 9E F3 E4 A3 D5 74 52 52 69 8B FD 36 C7 29 38 51 30 D7 F9 7E B0 4 E5 25 CE BD D7 A7 18 83 60 19 F5 A5 D8 53 C2 95 9A B6 52 9D 75 79 32 A0 5E 1B 8 FB F7 78 DA E4 DD CD CE CC 1D 6 1B E9 45 A5 20 E7 AD 2F 66 EF F5 EC 18 33 9D 87 73 49 7 86 4C BA B9 46 25 B8 DA 13 B1 AB 2B C3 1B A6 30 13 11 B6 7 DF 7D 33 9B 6C D0 E3 5E 42 57 EC 7E ED D5 28 16 CB F 5B A0 5A FB 4F 16 31 37 84 4E BB 87 1E 70 1D 3B 66 88 5A A8 73 36 CA 33 95 D9 1E A2 4D 39 EC 7D 9B EF F9 B2 20 32 5 57 5C 2F AC C4 3F 31 D7 70 A D4 27 9A 6F AB 26 C9 48 84 54 41 62 5A 43 2 5B F4 66 93 CE FD 29 3F 4A E9 88 6B B2 97 6A 24 DD 48 40 36 4F 76 EB E1 27 8A 45 A 53 F4 19 67 8C B6 67 3A 61 25 3F B4 F4 55 C4 3F 32 E3 BF D6 DB 23 90 DE DD 3A 6F 62 5 C 66 F 31 61 45 87 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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