/** Checks equality between a clear password \e clear and
 * a crypted password (in base64 encoding) \e cryptedBase64.
 * The crypted password must have been created using the
 * cryptPassword().
 */
bool PasswordCrypter::checkPassword(const QString &clear, const QString &cryptedBase64)
{
    // Get the prefixed algorithm
    Algorithm algo = SHA1;
    if (cryptedBase64.contains(":")) {
        algo = extractHashAlgorithm(cryptedBase64);
    }
    QString crypted = cryptPassword(clear, algo);
    return (crypted.compare(cryptedBase64) == 0);
}
示例#2
0
/** Checks equality between a clear password \e clear and
 * a encrypted password (in base64 encoding) \e cryptedBase64.
 * The encrypted password must have been created using the
 * cryptPassword().
 */
bool PasswordCrypter::checkPassword(const QString &clear, const QString &cryptedBase64)
{
    if (DebugCheckPassword)
        WARN_FUNC;
    // Get the prefixed algorithm
    Algorithm algo = SHA1;
    if (cryptedBase64.contains(":")) {
        algo = extractHashAlgorithm(cryptedBase64);
    }
    QString crypted = cryptPassword(clear, algo);
    if (DebugCheckPassword) {
        qDebug() << QString("clear: %1; crypted: %2\nhash: %3; comparison: %4")
                    .arg(clear).arg(cryptedBase64).arg(algo).arg(crypted);
    }
    return (crypted.compare(cryptedBase64) == 0);
}
示例#3
0
文件: setup.cpp 项目: icefox/kinkatta
void setup::savePassword(const QString &user, const QString &password){
	if(user.isEmpty() || (user == QString("<new user>")) || password.isEmpty())
		return;

	QString crypted = cryptPassword(password);

  QString settingsFileXml = KINKATTA_DIR;
  settingsFileXml += user.lower();
  settingsFileXml += ".xml";

	Preferences prefs(settingsFileXml, QString("kinkatta user prefs"), QString("1.0"));

	prefs.setGroup("password");
	prefs.setCDATA("password", crypted);

	prefs.flush();
}
示例#4
0
void ICQClient::chn_login()
{
    if (m_cookie.size()){
        flap(ICQ_CHNxNEW);
        m_socket->writeBuffer << 0x00000001L;
        m_socket->writeBuffer.tlv(6, m_cookie.data(), (unsigned short)(m_cookie.size()));
        m_cookie.init(0);
        sendPacket();
        return;
    }
    if (data.owner.Uin.value){
        string pswd = cryptPassword();
        log(L_DEBUG, "Login %lu [%s]", data.owner.Uin, pswd.c_str());
        char uin[20];
        sprintf(uin, "%lu", data.owner.Uin.value);

        flap(ICQ_CHNxNEW);
        m_socket->writeBuffer << 0x00000001L;
        m_socket->writeBuffer.tlv(0x0001, uin);
        m_socket->writeBuffer.tlv(0x0002, pswd.c_str(), pswd.length());
        m_socket->writeBuffer.tlv(0x0003, "3ICQ Inc. - Product of ICQ (TM).2003b.5.56.1.3916.85");
        m_socket->writeBuffer.tlv(0x0016, 0x010A);
        m_socket->writeBuffer.tlv(0x0017, 0x0002);
        m_socket->writeBuffer.tlv(0x0018, 0x0038);
        m_socket->writeBuffer.tlv(0x0019, 0x0001);
        m_socket->writeBuffer.tlv(0x001A, 0x0F4C);
        m_socket->writeBuffer.tlv(0x0014, 0x00000055L);
        m_socket->writeBuffer.tlv(0x000f, "en");
        m_socket->writeBuffer.tlv(0x000e, "us");
        sendPacket();
        return;
    }
    if (data.owner.Screen.ptr && *data.owner.Screen.ptr){
        flap(ICQ_CHNxNEW);
        m_socket->writeBuffer << 0x00000001L;
        sendPacket();
        snac(ICQ_SNACxFAM_LOGIN, ICQ_SNACxLOGIN_AUTHxREQUEST, false, false);
        m_socket->writeBuffer.tlv(0x0001, data.owner.Screen.ptr);
        m_socket->writeBuffer.tlv(0x004B);
        m_socket->writeBuffer.tlv(0x005A);
        sendPacket();
        return;
    }

    flap(ICQ_CHNxNEW);
    m_socket->writeBuffer << 0x00000001L;
    sendPacket();
    snac(ICQ_SNACxFAM_LOGIN, ICQ_SNACxLOGIN_REGISTERxREQ);
    Buffer msg;
    msg
    << 0x00000000L << 0x28000300L << 0x00000000L
    << 0x00000000L << 0x94680000L << 0x94680000L
    << 0x00000000L << 0x00000000L << 0x00000000L
    << 0x00000000L;
    string pswd = getContacts()->fromUnicode(NULL, getPassword());
    unsigned short len = (unsigned short)(pswd.length() + 1);
    msg.pack(len);
    msg.pack(pswd.c_str(), len);
    msg << 0x94680000L << 0x00000602L;
    m_socket->writeBuffer.tlv(0x0001, msg);
    sendPacket();
}
示例#5
0
 bool Client::serialize(QDomElement& element)
 {
     PropertyHubPtr hub = PropertyHub::create();
     hub->setValue("Password", cryptPassword(password()));
     return hub->serialize(element);
 }
示例#6
0
void ICQClient::chn_login()
{
    if (m_cookie.size()){
        flap(ICQ_CHNxNEW);
        m_socket->writeBuffer << 0x00000001L;
        m_socket->writeBuffer.tlv(6, m_cookie.data(), (unsigned short)(m_cookie.size()));
        m_cookie.init(0);
        sendPacket();
        return;
    }
    if (data.owner.Uin){
        string pswd = cryptPassword();
        log(L_DEBUG, "Login %lu [%s]", data.owner.Uin, pswd.c_str());
        char uin[20];
        sprintf(uin, "%lu", data.owner.Uin);

        flap(ICQ_CHNxNEW);
        unsigned short n = 0;
        char pass[16];
        for (const char *p = pswd.c_str(); *p && n < 16; p++){
            if (*p != '\\'){
                pass[n++] = *p;
                continue;
            }
            char c = *(++p);
            if (c == '0') c = 0;
            pass[n++] = c;
        }
        m_socket->writeBuffer << 0x00000001L;
        m_socket->writeBuffer.tlv(0x0001, uin);
        m_socket->writeBuffer.tlv(0x0002, pass, n);
        m_socket->writeBuffer.tlv(0x0003, "ICQBasic");
        m_socket->writeBuffer.tlv(0x0016, 0x010A);
        m_socket->writeBuffer.tlv(0x0017, 0x0014);
        m_socket->writeBuffer.tlv(0x0018, 0x0009);
        m_socket->writeBuffer.tlv(0x0019, 0x0000);
        m_socket->writeBuffer.tlv(0x001A, 0x0515);
        m_socket->writeBuffer.tlv(0x0014, 0x0000043DL);
        m_socket->writeBuffer.tlv(0x000f, "en");
        m_socket->writeBuffer.tlv(0x000e, "us");
        sendPacket();
        return;
    }
    if (data.owner.Screen && *data.owner.Screen){
        flap(ICQ_CHNxNEW);
        m_socket->writeBuffer << 0x00000001L;
        sendPacket();
        snac(ICQ_SNACxFAM_LOGIN, ICQ_SNACxLOGIN_AUTHxREQUEST, false, false);
        m_socket->writeBuffer.tlv(0x0001, data.owner.Screen);
        m_socket->writeBuffer.tlv(0x004B);
        m_socket->writeBuffer.tlv(0x005A);
        sendPacket();
        return;
    }

    flap(ICQ_CHNxNEW);
    m_socket->writeBuffer << 0x00000001L;
    sendPacket();
    snac(ICQ_SNACxFAM_LOGIN, ICQ_SNACxLOGIN_REGISTERxREQ);
    Buffer msg;
    msg
    << 0x00000000L << 0x28000300L << 0x00000000L
    << 0x00000000L << 0x94680000L << 0x94680000L
    << 0x00000000L << 0x00000000L << 0x00000000L
    << 0x00000000L;
    string pswd = fromUnicode(getPassword(), &data.owner);
    unsigned short len = (unsigned short)(pswd.length() + 1);
    msg.pack(len);
    msg.pack(pswd.c_str(), len);
    msg << 0x94680000L << 0x00000602L;
    m_socket->writeBuffer.tlv(0x0001, msg);
    sendPacket();
}
示例#7
0
文件: setup.cpp 项目: icefox/kinkatta
/*
 * Decrypt a password.  Since the algorithm is circular, this is just a helper
 * function for the below.  It does the same thing.
 */
QString setup::decryptPassword(const QString &cryptedPass){
	return cryptPassword(cryptedPass);
}
示例#8
0
void ICQClient::chn_login()
{
    if (m_cookie.size()){
        flap(ICQ_CHNxNEW);
        m_socket->writeBuffer << 0x00000001L;
        m_socket->writeBuffer.tlv(6, m_cookie.data(), (unsigned short)(m_cookie.size()));
        m_cookie.init(0);
        sendPacket(true);
        return;
    }
    if (data.owner.Uin.value && ! getUseMD5()){
        string pswd = cryptPassword();
        log(L_DEBUG, "Login %lu [%s]", data.owner.Uin.value, pswd.c_str());
        char uin[20];
        sprintf(uin, "%lu", data.owner.Uin.value);

        flap(ICQ_CHNxNEW);
        m_socket->writeBuffer << 0x00000001L;
        m_socket->writeBuffer.tlv(0x0001, uin);
        m_socket->writeBuffer.tlv(0x0002, pswd.c_str(), pswd.length());
        // m_socket->writeBuffer.tlv(0x0003, "ICQ Inc. - Product of ICQ (TM).2003b.5.56.1.3916.85");
        m_socket->writeBuffer.tlv(0x0003, "ICQ Client");
        m_socket->writeBuffer.tlv(0x0016, 0x010A);
        m_socket->writeBuffer.tlv(0x0017, 0x0002);
        m_socket->writeBuffer.tlv(0x0018, 0x0038);
        m_socket->writeBuffer.tlv(0x0019, 0x0001);
        m_socket->writeBuffer.tlv(0x001A, 0x0F4C);
        m_socket->writeBuffer.tlv(0x0014, 0x00000055L);
        //m_socket->writeBuffer.tlv(0x000f, "de");  // This is an example, should be specified for other countries
        //m_socket->writeBuffer.tlv(0x000e, "de");
        m_socket->writeBuffer.tlv(0x000f, "en");
        m_socket->writeBuffer.tlv(0x000e, "us");
        sendPacket(true);
        return;
    }
    if (data.owner.Screen.ptr && *data.owner.Screen.ptr || getUseMD5()){
        log(L_DEBUG, "Requesting MD5 salt");
        flap(ICQ_CHNxNEW);
        m_socket->writeBuffer << 0x00000001L;
        sendPacket(true);
        snac(ICQ_SNACxFAM_LOGIN, ICQ_SNACxLOGIN_AUTHxREQUEST, false, false);
	if (data.owner.Uin.value){
            char uin[20];
            sprintf(uin, "%lu", data.owner.Uin.value);
	    m_socket->writeBuffer.tlv(0x0001, uin);
	}else{
	    m_socket->writeBuffer.tlv(0x0001, data.owner.Screen.ptr);
	}
        m_socket->writeBuffer.tlv(0x004B);
        m_socket->writeBuffer.tlv(0x005A);
        sendPacket(true);
        return;
    }
    if (m_bVerifying){
        log(L_DEBUG, "Requesting verification picture");
        flap(ICQ_CHNxNEW);
        m_socket->writeBuffer << 0x00000001L;
        sendPacket(true);
        snac(ICQ_SNACxFAM_LOGIN, ICQ_SNACxLOGIN_REGISTERxREQ_IMG);
        sendPacket(true);
        return;
    }
    flap(ICQ_CHNxNEW);
    m_socket->writeBuffer << 0x00000001L;
    sendPacket(true);
    // first try the old registration scheme
    snac(ICQ_SNACxFAM_LOGIN, ICQ_SNACxLOGIN_REGISTERxREQ);
    Buffer msg;
    msg
    << 0x00000000L << 0x28000300L << 0x00000000L
    << 0x00000000L << 0x94680000L << 0x94680000L
    << 0x00000000L << 0x00000000L << 0x00000000L
    << 0x00000000L;
    string pswd = getContacts()->fromUnicode(NULL, getPassword());
    unsigned short len = (unsigned short)(pswd.length() + 1);
    msg.pack(len);
    msg.pack(pswd.c_str(), len);
    msg << 0x94680000L << 0x00000602L;
    m_socket->writeBuffer.tlv(0x0001, msg);
    sendPacket(true);
}