Exemple #1
0
QVector<QString> & PBSKeygen::getKeys() {
	SHA256 sha;

	QString macS = getMacAddress();
	if (macS.length() != 12) {
		throw ERROR;
	}

	char mac[6];
	bool status;
	for (int i = 0; i < 12; i += 2)
		mac[i / 2] = (macS.mid(i, 1).toInt(&status, 16) << 4)
				+ macS.mid(i + 1, 1).toInt(&status, 16);
	if (!status)
		throw ERROR;
	sha.reset();
	sha.addData(saltSHA256, (unsigned long)sizeof(saltSHA256));
	sha.addData(mac, (unsigned long)sizeof(mac));

	unsigned char hash[32];
	sha.result((unsigned char *) hash);
	QString key = "";
	for (int i = 0; i < 13; ++i) {
		key.append(lookup.at(hash[i] % lookup.length()));
	}
	results.append(key);
	return results;
}
Exemple #2
0
QVector<QString> & AliceKeygen::getKeys() {

	if (supportedAlice->isEmpty())
		throw ERROR;
	SHA256 sha;
	char hash[32];

	bool status;

	for (int j = 0; j < supportedAlice->size(); ++j) {/*For pre AGPF 4.5.0sx*/
		QString serialStr = supportedAlice->at(j)->serial + "X";
        int k = supportedAlice->at(j)->magic[0];
        int Q = supportedAlice->at(j)->magic[1];
		int serial = (getSsidName().right(8).toInt(&status, 10) - Q) / k;
		QString tmp = "";
		tmp.setNum(serial);
		for (int i = 0; i < 7 - tmp.length(); i++) {
			serialStr += "0";
		}
		serialStr += tmp;

		char mac[6];
		QString key = "";

		QString macS = getMacAddress();
		if (macS.size() == 12) {

			for (int i = 0; i < 12; i += 2)
				mac[i / 2] = (macS.mid(i, 1).toInt(&status, 16) << 4)
						+ macS.mid(i + 1, 1).toInt(&status, 16);

			/* Compute the hash */
			sha.reset();
			sha.addData(specialSeq, (unsigned long) sizeof(specialSeq));
			sha.addData(serialStr.toAscii().data(), serialStr.size());
			sha.addData(mac, (unsigned long) sizeof(mac));
			sha.result((unsigned char *) hash);

			for (int i = 0; i < 24; ++i) {
				key += preInitCharset.at(hash[i] & 0xFF);
			}
			if (!results.contains(key))
				results.append(key);
		}

		/*For post AGPF 4.5.0sx*/
		QString macEth = macS.left(6);
        for (int extraNumber = 0;extraNumber < 10; ++extraNumber) {
			QString calc = "";
			calc.setNum(extraNumber);
			calc += getSsidName().right(8);
			calc.setNum(calc.toInt(&status, 10), 16);
			calc = calc.toUpper();
			if (macEth.at(5) == calc.at(0)) {
				macEth += calc.right(6);
				break;
            }
		}

		for (int i = 0; i < 12; i += 2)
			mac[i / 2] = (macEth.mid(i, 1).toInt(&status, 16) << 4)
					+ macEth.mid(i + 1, 1).toInt(&status, 16);
		/* Compute the hash */
		sha.reset();
		sha.addData(specialSeq, (unsigned long) sizeof(specialSeq));
		sha.addData(serialStr.toAscii().data(), serialStr.size());
		sha.addData(mac, (unsigned long) sizeof(mac));
		sha.result((unsigned char *) hash);

		key = "";
		for (int i = 0; i < 24; ++i)
			key += preInitCharset.at(hash[i] & 0xFF);
		if (!results.contains(key))
			results.append(key);
	}
	return results;

}