#include "LoginServ.h" #include "../../src/CompiledPacket.h" #include "../../src/Utility.h" #include void CheckAuthorization(uchar* pAuthData, ClientData* pMyClient) { //Check the authorization stuff. if (pAuthData!=0 && pAuthData[0]!=0) { bool authorization_fail=false; //Get the authData unsigned char auth_data[70]; memcpy(auth_data, pAuthData, 70); //Decrypt the authData for (int i=0; i<70; i++) { auth_data[i]=auth_data[i] ^ pMyClient->compHash[i%32]; } //Check the time stamp time_t current_time=time(NULL); time_t stamp_time; memcpy(&stamp_time, auth_data, 4); if (difftime(current_time, stamp_time)<(60*60)*10) { //Decrypt the campaigns and eotn values unsigned char campaigns=auth_data[4]^2; unsigned char owns_eotn=auth_data[5]^2; unsigned char owns[2]; owns[0]=campaigns; owns[1]=owns_eotn; //Extract the hashes CompiledPacket comp_hash(true); CompiledPacket secret_hash(true); for (int i=0; i<64; i+=2) { comp_hash.AddByte(auth_data[i+6]^owns[1-((i/2)%2)]); secret_hash.AddByte(auth_data[i+6+1]^owns[0+((i/2)%2)]); } int ds=0; unsigned char *pC_hash=comp_hash.GetString(&ds); unsigned char *pS_hash=secret_hash.GetString(&ds); //Check the computer hash against this computer's hash if (memcmp(pC_hash, pMyClient->compHash, 32)==0) { int key=5; //Generate the secret hash CompiledPacket pck_secret_hash(true); pck_secret_hash.AddByte(0x14^key); pck_secret_hash.Fill(0, 13); pck_secret_hash.AddByte(owns[0]); pck_secret_hash.Fill(0, 9); pck_secret_hash.AddByte(owns[1]); pck_secret_hash.Add(pMyClient->compHash, 32, false); unsigned char shHash[32]; ds=0; unsigned char *secret_hash_data=pck_secret_hash.GetString(&ds); Util::Hash(secret_hash_data, shHash, ds); //Check the secret hashes to make sure they match if (memcmp(shHash, pS_hash, 32)==0) { pMyClient->ownsEotn=owns[1]; pMyClient->ownedCampaigns=owns[0]; } else { authorization_fail=true; } } else { authorization_fail=true; } } else { authorization_fail=true; } if (authorization_fail) { pMyClient->ownedCampaigns=0; pMyClient->ownsEotn=0; } } else { pMyClient->ownedCampaigns=0; pMyClient->ownsEotn=0; } }