Пример #1
0
bool Protocol79::CharlistLogin(const char *username, const char *password) {
    NetworkMessage nm;

    ONThreadSafe(threadsafe);

    connectiontype = CHARLIST;

    nm.AddU8(0x01); // protocol id
    nm.AddU16(0x02); // client OS
    nm.AddU16(protocolversion);

    nm.AddU32(fingerprints[FINGERPRINT_TIBIADAT]); // tibia.dat
    nm.AddU32(fingerprints[FINGERPRINT_TIBIASPR]); // tibia.spr
    nm.AddU32(fingerprints[FINGERPRINT_TIBIAPIC]); // tibia.pic

    nm.RSABegin();


    // encryption keys
    for (int i = 0 ; i < 4 ; i++) {
        nm.AddU32(key[i]);
    }

    // account number and password
    nm.AddU32(atol((this->username = username).c_str()));
    nm.AddString(this->password = password);


    nm.RSAEncrypt();


    if (!nm.Dump(s)) {
        this->errormsg = "Could not write to socket.\nPossible it's a premature disconnect.\n\nCheck you typed in the correct protocol!";
        ONThreadUnsafe(threadsafe);
        return false;
    }

    nm.Clean();
    if (!nm.FillFromSocket(s)) {
        this->errormsg = "Could not read from socket.\nPossibly it's a premature disconnect.\n\nCheck you typed in the correct protocol!";
        ONThreadUnsafe(threadsafe);
        return false;
    }
	printf("Okies, lets decrypt\n");
//    this->Close();

    nm.XTEADecrypt(key);
	printf("Ok, decoded\n");
    logonsuccessful = true;
    while ((signed int)(nm.GetSize())>0 && ParsePacket(&nm));
    if ((signed int)(nm.GetSize())>0) printf("++++++++++++++++++++DIDNT EMPTY UP THE NETWORKMESSAGE!++++++++++++++++++\n");

    ONThreadUnsafe(threadsafe);
    return logonsuccessful;
}
Пример #2
0
bool Protocol77::GameworldLogin () {
    // this is valid for 7.7!
    // 7.72 has a bit different order of stuff! check out old outcast's sources
    NetworkMessage nm;

    connectiontype = GAMEWORLD;

    nm.AddU8(0x0A); // protocol id


    nm.RSABegin();

    // encryption keys
    for (int i = 0 ; i < 4 ; i++) {
        nm.AddU32(key[i]);
    }


    // in 7.72 onwards move this BEFORE the keys and BEFORE the encryption
    nm.AddU16(0x02); // client OS
    nm.AddU16(protocolversion);


    // are we a gamemaster
    nm.AddChar(0);

    // account number and password
    nm.AddU32(atol(this->username.c_str())); // this does NOT exist before 7.4
    nm.AddString(this->charlist[this->charlistselected]->charactername);
    nm.AddString(this->password);



    nm.RSAEncrypt();

    // FIXME inside dump, we should check whether or not socket is still open
    // or after dump, at least
    nm.Dump(s);

    nm.Clean();
    nm.FillFromSocket(s );

    nm.XTEADecrypt(key);

    logonsuccessful = true;
    while ((signed int)(nm.GetSize())>0 && ParsePacket(&nm));
    if ((signed int)(nm.GetSize())!=0) printf("++++++++++++++++++++DIDNT EMPTY UP THE NETWORKMESSAGE!++++++++++++++++++\n");

    if (logonsuccessful) active = true;

    return logonsuccessful;
}
Пример #3
0
bool Protocol77::CharlistLogin(const char *username, const char *password) {

    NetworkMessage nm;

    connectiontype = CHARLIST;

    nm.AddU8(0x01); // protocol id
    nm.AddU16(0x02); // client OS
    nm.AddU16(protocolversion);

    nm.AddU32(fingerprints[FINGERPRINT_TIBIADAT]); // tibia.dat
    nm.AddU32(fingerprints[FINGERPRINT_TIBIASPR]); // tibia.spr
    nm.AddU32(fingerprints[FINGERPRINT_TIBIAPIC]); // tibia.pic

    nm.RSABegin();

    // encryption keys
    for (int i = 0 ; i < 4 ; i++) {
        nm.AddU32(key[i]);
    }

    // account number and password
    nm.AddU32(atol((this->username = username).c_str()));
    nm.AddString(this->password = password);

    nm.RSAEncrypt();

    // FIXME inside dump, we should check whether or not socket is still open
    // or after dump, at least
    nm.Dump(s);

    nm.Clean();
    nm.FillFromSocket(s);

    nm.XTEADecrypt(key);

    logonsuccessful = true;
    while ((signed int)(nm.GetSize())>0 && ParsePacket(&nm));
    if ((signed int)(nm.GetSize())>0) printf("++++++++++++++++++++DIDNT EMPTY UP THE NETWORKMESSAGE!++++++++++++++++++\n");

    Close();


    return logonsuccessful;
}
Пример #4
0
bool Protocol79::GameworldLogin () {
    // this is valid for 7.9!
    // 7.7 has a bit different order of stuff! check out old outcast's sources
    NetworkMessage nm;

    SetProtocolStatus("Preparing to transfer logon data...");
    connectiontype = GAMEWORLD;

    nm.AddU8(0x0A); // protocol id

    // in 7.72 onwards move this BEFORE the keys and BEFORE the encryption
    nm.AddU16(0x02); // client OS
    nm.AddU16(protocolversion);

    SetProtocolStatus("RSA encryption...");
    nm.RSABegin();

    //key[3] = 92;
    // encryption keys
    for (int i = 0 ; i < 4 ; i++) {
        nm.AddU32(key[i]);
        //printf("KEY %d - %d\n", i, key[i]);
    }


    // are we a gamemaster
    nm.AddChar(0);

    // account number and password
    nm.AddU32(atol(this->username.c_str())); // this does NOT exist before 7.4
    nm.AddString(this->charlist[this->charlistselected]->charactername);
    nm.AddString(this->password);



    nm.RSAEncrypt();

    SetProtocolStatus("Transmitting logon data...");

    if (!nm.Dump(s)) {
        this->errormsg = "Could not write to socket.\nPossible it's a premature disconnect.\n\nCheck you typed in the correct protocol!";
        return false;
    }


//    SetStance(DEFENSIVE, STAND);

    SetProtocolStatus("Waiting for response...");
    //nm.Clean();
    NetworkMessage nm2;
    //nm.FillFromSocket(s);
    if (!nm2.FillFromSocket(s )) {
        this->errormsg = "Could not read from socket.\nPossibly it's a premature disconnect.\n\nCheck you typed in the correct protocol!";
        return false;
    }
    nm2.XTEADecrypt(key);
    logonsuccessful = true;
    while ((signed int)(nm2.GetSize())>0 && ParsePacket(&nm2));
    if ((signed int)(nm2.GetSize())!=0) printf("++++++++++++++++++++DIDNT EMPTY UP THE NETWORKMESSAGE!++++++++++++++++++\n");

    if (logonsuccessful) active = true;

    return logonsuccessful;
}