Example #1
0
void ProtocolLogin::sendLoginPacket()
{
    OutputMessage oMsg;

    oMsg.addU8(Proto::ClientEnterAccount);
    oMsg.addU16(Proto::OsLinux);
    oMsg.addU16(Proto::ClientVersion);

    oMsg.addU32(g_thingsType.getSignature()); // data signature
    oMsg.addU32(g_sprites.getSignature()); // sprite signature
    oMsg.addU32(Proto::PicSignature); // pic signature

    oMsg.addU8(0); // first RSA byte must be 0

    // xtea key
    generateXteaKey();
    oMsg.addU32(m_xteaKey[0]);
    oMsg.addU32(m_xteaKey[1]);
    oMsg.addU32(m_xteaKey[2]);
    oMsg.addU32(m_xteaKey[3]);

    oMsg.addString(m_accountName);
    oMsg.addString(m_accountPassword);

    // complete the 128 bytes for rsa encryption with zeros
    oMsg.addPaddingBytes(128 - (21 + m_accountName.length() + m_accountPassword.length()));
    Rsa::encrypt((char*)oMsg.getBuffer() + InputMessage::DATA_POS + oMsg.getMessageSize() - 128, 128, Proto::RSA);

    send(oMsg);
    enableXteaEncryption();
    recv();
}
void ProtocolGame::sendLoginPacket(uint timestamp, uint8 unknown)
{
    OutputMessage oMsg;

    oMsg.addU8(Proto::ClientEnterGame);
    oMsg.addU16(Proto::OsLinux);
    oMsg.addU16(Proto::ClientVersion);

    oMsg.addU8(0); // first RSA byte must be 0

    // xtea key
    generateXteaKey();
    oMsg.addU32(m_xteaKey[0]);
    oMsg.addU32(m_xteaKey[1]);
    oMsg.addU32(m_xteaKey[2]);
    oMsg.addU32(m_xteaKey[3]);

    oMsg.addU8(0); // is gm set?
    oMsg.addString(m_accountName);
    oMsg.addString(m_characterName);
    oMsg.addString(m_accountPassword);

    oMsg.addU32(timestamp);
    oMsg.addU8(unknown);

    // complete the 128 bytes for rsa encryption with zeros
    oMsg.addPaddingBytes(128 - (29 + m_accountName.length() + m_characterName.length() + m_accountPassword.length()));

    // encrypt with RSA
    Rsa::encrypt((char*)oMsg.getBuffer() + 6 + oMsg.getMessageSize() - 128, 128, Proto::RSA);

    send(oMsg);

    enableXteaEncryption();
}