EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Development::Development (https://www.eqemulator.org/forums/forumdisplay.php?f=590)
-   -   What packet encryption is the EQEMU implementing? (https://www.eqemulator.org/forums/showthread.php?t=25156)

mcox05 05-01-2008 08:33 PM

What packet encryption is the EQEMU implementing?
 
I'm trying to decode text being sent from one user to another inside of the game world. It seems that all chat has been encrypted for transmission. Can anyone point me in the right direction as to where this encryption / decryption algorithms are in the EQEMU source. Thanks

KLS 05-01-2008 11:01 PM

The data steam is not encrypted to my knowledge, portions of it are compressed using zlib however.

mcox05 05-01-2008 11:41 PM

where is the portion of the code where sending the packets across networks is actually done. I'm specifically trying to locate chat packets (tells, shouts, ooc, etc..). Anything would be very helpful. :)

KLS 05-02-2008 12:17 AM

I don't know offhand but I'll try to find it later tonight for ya.

mcox05 05-02-2008 12:47 AM

if you find out then you are an angel ;)

mcox05 05-06-2008 05:13 PM

Quote:

Originally Posted by KLS (Post 148198)
I don't know offhand but I'll try to find it later tonight for ya.

Any update on finding the code segments that deal with the compression? :) thanks

MNWatchdog 05-06-2008 11:51 PM

So youre trying to be able to spy on peoples conversations. How nice. Should we call you George?

People have an expectation of privacy in their communications, so you could be openning yourself to legal issues and if someone does bust you spying on them, I hope they do persue it to the fullest extent of the law.

Its bad enough our goverment is spying on us without any regards to our rights and you adding to that isnt going to gain you any friends.

mcox05 05-07-2008 04:02 AM

Quote:

Originally Posted by MNWatchdog (Post 148372)
So youre trying to be able to spy on peoples conversations. How nice. Should we call you George?

People have an expectation of privacy in their communications, so you could be openning yourself to legal issues and if someone does bust you spying on them, I hope they do persue it to the fullest extent of the law.

Its bad enough our goverment is spying on us without any regards to our rights and you adding to that isnt going to gain you any friends.

I swear people like you seem to exist in every division of this world, be it forums, family, or in the classroom.

Thank you so much for you near-sighted thoughts. How about you stick to just playing the game and not wasting my time you moron.

There are many different reasons to want to monitor chat packets on the EMU than just petty privacy theft .... (what in the world would be so important and sensitive that I would want to monitor on an emulated game anyways)! Use your wits if you have any, seriously.

Since, you lack the ability to conceive of a non-malicious purpose for monitoring chat packets; allow me to guide you to enlightenment.

I'm building a /tell based bot program to help those who want private servers and don't want to go through all the pains of macro managing multiple EQ Clients to form full groups.

But again, clearly you know my intentions better than my own. Go somewhere else to make nonsensical false allegations against people (a great place for that is in political forums since you were so ready to make a direct correlation between video gaming ethics and federal government policy) and spare us all.

Thanks :)


Anyways, does anyone have any intelligent thoughts on the matter now that my intentions have been made clear?

AndMetal 05-07-2008 04:38 AM

I'm not 100% sure, but I think this is what you're looking for:

common/EQPacket.cpp:
Code:

  390 void EQProtocolPacket::ChatDecode(unsigned char *buffer, int size, int DecodeKey)
  391 {
  392        if (buffer[1]!=0x01 && buffer[0]!=0x02 && buffer[0]!=0x1d) {
  393                int Key=DecodeKey;
  394                unsigned char *test=(unsigned char *)malloc(size);
  395                buffer+=2;
  396                size-=2;
  397
  398                int i;
  399                for (i = 0 ; i+4 <= size ; i+=4)
  400                {
  401                        int pt = (*(int*)&buffer[i])^(Key);
  402                        Key = (*(int*)&buffer[i]);
  403                        *(int*)&test[i]=pt;
  404                }
  405                unsigned char KC=Key&0xFF;
  406                for ( ; i < size ; i++)
  407                {
  408                        test[i]=buffer[i]^KC;
  409                }
  410                memcpy(buffer,test,size);
  411                free(test);
  412        }
  413 }


MNWatchdog 05-07-2008 05:13 AM

People who have a need to do what your talking about already do it with Macroquest most likely.

Ive been involved in some rather personal conversation while sitting around in EQ, after all, the name of the game is EVER QUEST, which often means tons of down time and I for one dont want you being able to listen in.

Excuse me for wanting some sense of privacy when I sending PRIVATE messages.

What your wanting to do should be done using a command prefaced with a # like all specialty commands and certainly does not need for you to modify the current chat system so you can tap into it.

mcox05 05-07-2008 05:13 AM

Quote:

Originally Posted by AndMetal (Post 148386)
I'm not 100% sure, but I think this is what you're looking for:

common/EQPacket.cpp:
Code:

  390 void EQProtocolPacket::ChatDecode(unsigned char *buffer, int size, int DecodeKey)
  391 {
  392        if (buffer[1]!=0x01 && buffer[0]!=0x02 && buffer[0]!=0x1d) {
  393                int Key=DecodeKey;
  394                unsigned char *test=(unsigned char *)malloc(size);
  395                buffer+=2;
  396                size-=2;
  397
  398                int i;
  399                for (i = 0 ; i+4 <= size ; i+=4)
  400                {
  401                        int pt = (*(int*)&buffer[i])^(Key);
  402                        Key = (*(int*)&buffer[i]);
  403                        *(int*)&test[i]=pt;
  404                }
  405                unsigned char KC=Key&0xFF;
  406                for ( ; i < size ; i++)
  407                {
  408                        test[i]=buffer[i]^KC;
  409                }
  410                memcpy(buffer,test,size);
  411                free(test);
  412        }
  413 }


You are amazing my friend ... the ironic thing is that I just found this about 20 minutes ago. Seems that the answer to my question only leaves me with more questions since I have only programmed in Java/C#.

Question: It's using a decode key which, at a glance, isn't a predefined constant. What is the decode key they are using ... does it change constantly or do they have a constant being applied to the method call?

Anyways, thanks for the help. Great work!

mcox05 05-07-2008 05:34 AM

Quote:

Originally Posted by MNWatchdog (Post 148387)
People who have a need to do what your talking about already do it with Macroquest most likely.

Ive been involved in some rather personal conversation while sitting around in EQ, after all, the name of the game is EVER QUEST, which often means tons of down time and I for one dont want you being able to listen in.

Excuse me for wanting some sense of privacy when I sending PRIVATE messages.

What your wanting to do should be done using a command prefaced with a # like all specialty commands and certainly does not need for you to modify the current chat system so you can tap into it.

Again, you fall to see. I don't want to modify the source and add 'specialty commands' as you phrase it.

As for macro quest, unless I am mistaken you have to still pay for that piece of software. Even if I don't have to pay, I want to make a bot program that meets MY needs, there is no rule that says I can't re-invent the wheel plus some, as you are making it seem.

You make it sound like there is a specific path towards my goal and that I'm veering off. I am implementing my application in the way I deem best. NO it wouldnt be best to implement it using specialty commands ... that would require adding bot functionality into the source ... I'm not even going to attempt to explain to you why that would be utterly complicated.

Having speciality commands would only solve the problem of execution, but not interpretation or management.

Out of curiousity, sense you have such a vast carnal knowledge of how to implement bots, once I implement A speciality command for casting a spell with a given spellid ... then what? What about self casting, target casting, group casting, or wait ... what if I wanted to actually allow for the functionality of reiterative statements such as "Heal me EVERY 5 seconds so i don't have to keep spamming the ingeniuous speciality cmd macro button"

Take some time to think it through, I am making a fully functional bot that can be controlled with a specific (my design and implementation) Command Language that is simplistic and powerful.

Adding a thousand specialty commands to the source along with bot functionality is not the correct approach in any way, the emu is a server not convoluted, add as you go, piece of software, it needs to remain as light-weight as possible. The only viable option, since the EQ Client doesn't have specific cmds that I need to facilitate this endevour, is to monitor chat packets to garner update info. and send synthetic packets to the server to issue commands that have no front-end access in the EQ Client.

I never knocked you for wanting a sense of privacy. I bashed on you because you simply made assumptions about my intentions. I frankly don't care if you think I'm out to monitor the entire world. That is your problem not mine.

Please stop posting back to me to salvage what is left of your e-penis. I'm interested in making a bot program and unless you have something worth-while to contribute then leave this thread alone. Thanks

AndMetal 05-07-2008 05:49 AM

Did a little more digging, and came up with this:

common/EQStream.cpp:
Code:

1003 void EQStream::Process(const unsigned char *buffer, const uint32 length)
 1004 {
 1005 static unsigned char newbuffer[2048];
 1006 uint32 newlength=0;
 1007        if (EQProtocolPacket::ValidateCRC(buffer,length,Key)) {
 1008                if (compressed) {
 1009                        newlength=EQProtocolPacket::Decompress(buffer,length,newbuffer,2048);
 1010                } else {
 1011                        memcpy(newbuffer,buffer,length);
 1012                        newlength=length;
 1013                        if (encoded)
 1014                                EQProtocolPacket::ChatDecode(newbuffer,newlength-2,Key);
 1015                }
 1016                if (buffer[1]!=0x01 && buffer[1]!=0x02 && buffer[1]!=0x1d)
 1017                        newlength-=2;
 1018                EQProtocolPacket *p = MakeProtocolPacket(newbuffer,newlength);
 1019                ProcessPacket(p);
 1020                delete p;
 1021                ProcessQueue();
 1022        } else {
 1023                _log(NET__DEBUG, _L "Incoming packet failed checksum" __L);
 1024                _hex(NET__NET_CREATE_HEX, buffer, length);
 1025        }
 1026 }

Key is defined a few times throughout EQStream.cpp, and it seems to be somewhat dependent on the type of packet. For the most part, I think it's defined as 0:
Code:

  53        Key=0;
Here is an example of where it isn't:
Code:

  299 #ifndef COLLECTOR
  300                        Key=0x11223344;
  301                        SendSessionResponse();
  302 #endif

  310                        Key=ntohl(Response->Key);

  802        Response->Key=htonl(Key);

I'd dig deeper, but it's late for me. Good luck with figuring out the encoding :-)

mcox05 05-07-2008 12:42 PM

Genius! Someone give this man a medal! Awesome I'm going to gather some packets and see if I can run them through this algorithm and I


All times are GMT -4. The time now is 04:34 PM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.