Upgrading Alchemy Proxy

06/25/2013 14:17 miketheking#1
So im trying to upgrade p4n's alchemy proxy to work with the 5700+ pservers everything works fine until the client's DH pack is received its encrypted into bullshit by the proxy and i really have no idea why is that happening
06/25/2013 15:09 pro4never#2
If it's getting to game server then you have everything working as far as login server is concerned.

You simply need to upgrade the dhkey exchange packets (client and server) as well as the encryption itself.
06/25/2013 16:46 miketheking#3
Quote:
Originally Posted by pro4never View Post
If it's getting to game server then you have everything working as far as login server is concerned.

You simply need to upgrade the dhkey exchange packets (client and server) as well as the encryption itself.
i did both but after some research i found out the the problem isn't in the cryptography anyway its possibly in the way the proxy handles the client DHkey pack not the structure itself ill try and figure this out now thnx anyway

Edit:everything seems to work fine even after the DHkey exchange but then the Packets sent from the server are fucked up don't know what's wrong i logged the lengths of the game packets identified in them they are always like 12252 and some random big numbers
06/25/2013 17:31 Arby#4
#moved
06/25/2013 18:09 pro4never#5
Quote:
Originally Posted by miketheking View Post
i did both but after some research i found out the the problem isn't in the cryptography anyway its possibly in the way the proxy handles the client DHkey pack not the structure itself ill try and figure this out now thnx anyway

Edit:everything seems to work fine even after the DHkey exchange but then the Packets sent from the server are fucked up don't know what's wrong i logged the lengths of the game packets identified in them they are always like 12252 and some random big numbers


This means you've not structured the DHKey packet structures properly. Their packet structures are not obvious as they are trying to hide data inside of them.

Look at an updated pserver source to get an idea for how the packets should be structured. Much of it is 'junk' data just there to hide the real information you're looking for.
06/25/2013 19:13 miketheking#6
Quote:
Originally Posted by pro4never View Post
This means you've not structured the DHKey packet structures properly. Their packet structures are not obvious as they are trying to hide data inside of them.

Look at an updated pserver source to get an idea for how the packets should be structured. Much of it is 'junk' data just there to hide the real information you're looking for.
before i started this i tested a pserver source on the client and it worked i have been using that source as a reference for cryptography and packet structures and i checked the DHkey packs in the proxy multiple times and im also logging the keys to see if it works every time i run the proxy and till now every time it worked correctly so i don't think that the packet structures are the problem but i'll check again thnx for your help :)

Edit:Checked again and i couldn't find any problem with the DHpackets structures
06/25/2013 19:48 pro4never#7
The first packets you receive are the exchange keys. You need to read the correect offsets to pull the key from them and if you are not getting the correct key then either.

A: You are not using the correct encryption (which you should have already updated)
B: You are not reading the packet structure properly

Once you have the key you need to generate your own custom client exchange packet and server exchange packet using the proper structures to complete the man in the middle attack and finalize both sets of encryption.


So yes.. the only things that CAN go wrong assuming you've hit the game server is the game encryption or the exchange process.
06/25/2013 20:05 miketheking#8
Quote:
Originally Posted by pro4never View Post
The first packets you receive are the exchange keys. You need to read the correect offsets to pull the key from them and if you are not getting the correct key then either.

A: You are not using the correct encryption (which you should have already updated)
B: You are not reading the packet structure properly

Once you have the key you need to generate your own custom client exchange packet and server exchange packet using the proper structures to complete the man in the middle attack and finalize both sets of encryption.


So yes.. the only things that CAN go wrong assuming you've hit the game server is the game encryption or the exchange process.
well since i log all the keys and they always return meaningful strings then i don't think there is a problem with the cryptography or the packet struct
06/25/2013 20:55 pro4never#9
If it's returning the same keys then there's no problem. If not then the structures and handling are incorrect.
06/25/2013 21:11 miketheking#10
im guessing the problem is with this part but i can't tell since its a bit confusing anyway ill run the source code i have locally and see if it returns the same keys
Code:
 static void SetUpCrypto(Client C)
        {
            try
            {
                BigNumber RealClientPublicKey = BigNumber.FromHexString(C.ClientDataDHP.Client_PubKey);
                BigNumber RealServerPublicKey = BigNumber.FromHexString(C.ServerDataDHP.Server_PubKey);

                GameCrypto ClientCrypto = new GameCrypto((C.ClientCrypt).DH.ComputeKey(RealServerPublicKey));
                GameCrypto ServerCrypto = new GameCrypto((C.ServerCrypt).DH.ComputeKey(RealClientPublicKey));

                ClientCrypto.Blowfish.EncryptIV = C.ServerDataDHP.ClientIV;
                ClientCrypto.Blowfish.DecryptIV = C.ServerDataDHP.ServerIV;

                ServerCrypto.Blowfish.EncryptIV = C.ServerDataDHP.ServerIV;
                ServerCrypto.Blowfish.DecryptIV = C.ServerDataDHP.ClientIV;

                C.ClientCrypt = ClientCrypto;
                C.ServerCrypt = ServerCrypto;
                C.Exchanging = false;
            }
            catch { }
        }
Edit:tested it locally and had no problems with the exchange packs probably the handling then
Edit:And not the handling so WTF

Edit:Found the problem this it was supposed to be like this
Code:
static void SetUpCrypto(Client C)
        {
            try
            {
                BigNumber RealClientPublicKey = BigNumber.FromHexString(C.ClientDataDHP.Client_PubKey);
                BigNumber RealServerPublicKey = BigNumber.FromHexString(C.ServerDataDHP.Server_PubKey);

                GameCrypto ClientCrypto = new GameCrypto((C.ClientCrypt).DH.ComputeKey(RealServerPublicKey));
                GameCrypto ServerCrypto = new GameCrypto(C.ClientDataDHP.DHKey((C.ServerCrypt).DH.ComputeKey(RealClientPublicKey)));
                ClientCrypto.Blowfish.EncryptIV = C.ServerDataDHP.ClientIV;
                ClientCrypto.Blowfish.DecryptIV = C.ServerDataDHP.ServerIV;

                ServerCrypto.Blowfish.EncryptIV = C.ServerDataDHP.ServerIV;
                ServerCrypto.Blowfish.DecryptIV = C.ServerDataDHP.ClientIV;

                C.ClientCrypt = ClientCrypto;
                C.ServerCrypt = ServerCrypto;
                C.Exchanging = false;
            }
            catch { }
        }
but still the client isn't loading but i'll assume the crypto is setup correctly for now well that's one problem dealt with
Edit:i was wrong there is a problem with the client crypto

Edit:Changing
Code:
   GameCrypto ClientCrypto = new GameCrypto((C.ClientCrypt).DH.ComputeKey(RealServerPublicKey));
to

Code:
  GameCrypto ClientCrypto = new GameCrypto(C.ServerDataDHP.DHKey((C.ClientCrypt).DH.ComputeKey(RealServerPublicKey)));
fixed the problem now it works thnx for your help and your amazing yet a bit confusing proxy :)