Jump to content

Problems with en-/decryption


Recommended Posts

Posted

Hello everyone!

In order to improve my skills in C/C++ (which i plan to use for mangos :P) i gave myself the goal to program a logonserver and a worldserver, but only till the point where the characters are displayed. Dont have enough time to get further.

Until yet everything worked perfectly, logonserver does what it should (and yes, it does it effective :D), same to the worldserver, but - if you belive or not - i get stucked at cmsg_char_enum :(. That means just one step before i would have got my goal :mellow:.

So, why do i get stucked? Actually i cant really tell you in detail, but after i haved decrypted cmsg_char_enum (there the decryption still works perfectly) all the cryptingstuff messes up. I cant even decrypt the clients ping-packets.

So if i dont let the client get to cmsg_char_enum (e.g. if i dont send the smsg_addon_info) all is in perfect order, cmsg_ping is handled. And if i go one step further everything gets out of control. Serverpackets have no effect, clientpackets are nonsense.

My first thinking was, that i may have messed up with the key of AuthCrypt, but this one stays the same all the time, so it cant be, that i changed it. Im working on that shit now since about 1 week and i still have no clue, why this all is happening.

Here is what i do:

---Logonserver:

- authenticating and saving the sessionkey

- displaying the realms

--World

- sending auth_challenge with random seed

- handling cmsg_auth_session

- asking logonserver for sessionkey

- initalising AuthCrypt

- sending smsg_auth_session

- sending smsg_addon_info

- handling cmsg_char_enum (that is decrypted well)

- ??

It would be really nice, if someone could help me out with that last little step. :)

Greetings

Cromon

Posted

So, hm, here are some more info: I use the 9551 client and not the 3.1.

Here are some details about the packethandling:

WorldPacket packet = WorldPacket();
packet << ui16(ntohs(13)) << ui16(SMSG_AUTH_RESPONSE) << "\\x0C\\x30\\x78\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x02";
SendPacket(packet);

Here the addoninfo:

void Session::AddonRequest()
{
   if(m_authpacket == NULL)
       return;
   ui32 size;
   try{
   *m_authpacket >> size;
   }
   catch(...){
       return;
   }
   if(m_authpacket->GetSize() < 4 || size == 0)
       return;
   WorldPacket uncompressed = WorldPacket();
   uncompressed.Resize(size);
   uLongf rsz = size;
   int res = uncompress(uncompressed.Contents(), &rsz, m_authpacket->Contents(), m_authpacket->GetSize());
   if(res != Z_OK)
   {
       return;
   }
   ui32 addoncount;
   uncompressed >> addoncount;
   char* addonname = new char[500];
   ui8 enabled = 0;
   ui32 unknown = 0;
   ui32 crc = 0;
   WorldPacket returnpacket;
   returnpacket << ui16(0) << ui16(SMSG_ADDON_INFO);
   for(register ui32 i = 0; i < addoncount; ++i)
   {
       if(!uncompressed.GetSize() || uncompressed.GetSize() < 10)
           break;
       uncompressed >> addonname >> enabled >> crc >> unknown;
       if(crc != 0x4C1C776D)
           returnpacket.Append(PublicKey, 264);
       else
           returnpacket << ui8(0x02) << ui8(0x01) << ui8(0x00) << ui32(0) << ui8(0);
   }
   returnpacket << ui32(0);
   ui16* b = (ui16*)returnpacket.Contents();
   *b = ntohs(returnpacket.GetSize() - 2);
   SendPacket(returnpacket);
   delete [] addonname;
}

That all works fine and is encrypted fine, but after the addon_info the client sends char_enum and finished, encryption doesnt work anymore.

ps:

sometimes the client sends 0x38C right after char_enum. this one i also get correctly.

//Edit:

Tested some more things:

If i dont send the smsg_char_enum everything stays just as it should. So if i now click on "cancle" at the client and back at the realmlist also cancle i get to the the char-list. If i create a new character i correctly get 0x36 from the client and i send char_create everything works fine (except that the client doesnt create the character).

So it seems, that all gets wrong when i send smsg_char_enum...

Posted

Argh, damn it, found the error:

RealmPacket& operator<<(char* data)
   {
       ui8* d = (ui8*)data;
       ui16 len = strlen(data);
       for(int i = 0; i < len; ++i)
           _data.push_back(*(d + i));
       _data.push_back('\\0');
       return (*this);
   }

Combined with that:

"\\x0C\\x30\\x78\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x02" // Pay attention on the \\x00

resulted in some wrong things :S. The operator stopped at the first \\x00 but should have to continue till the end. So changed that to pack.Append("....", 11) and now it works, FINALLY :D

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use