add -t test function

This commit is contained in:
Syping 2020-10-25 16:35:15 +01:00
parent 9fdcba128f
commit e3b7cf162b

View file

@ -36,7 +36,7 @@ int main(int argc, char *argv[])
{ {
QCoreApplication a(argc, argv); QCoreApplication a(argc, argv);
a.setApplicationName("checkbrute"); a.setApplicationName("checkbrute");
a.setApplicationVersion("0.3"); a.setApplicationVersion("0.3.1");
QCommandLineParser commandLineParser; QCommandLineParser commandLineParser;
commandLineParser.addHelpOption(); commandLineParser.addHelpOption();
@ -49,7 +49,8 @@ int main(int argc, char *argv[])
QCommandLineOption lengthsOption = QCommandLineOption("lengths", "Lengths to use for bruteforcing.", "lengths"); QCommandLineOption lengthsOption = QCommandLineOption("lengths", "Lengths to use for bruteforcing.", "lengths");
QCommandLineOption threadsOption = QCommandLineOption("threads", "Threads to use for bruteforcing.", "threads"); QCommandLineOption threadsOption = QCommandLineOption("threads", "Threads to use for bruteforcing.", "threads");
QCommandLineOption strictOption = QCommandLineOption(QStringList() << "s" << "strict", "Match checksums strict."); QCommandLineOption strictOption = QCommandLineOption(QStringList() << "s" << "strict", "Match checksums strict.");
commandLineParser.addOptions(QList<QCommandLineOption>() << algorithmsOption << startOption << stopOption << lengthsOption << threadsOption << strictOption); QCommandLineOption testOption = QCommandLineOption(QStringList() << "t" << "test", "Test checkbrute plugin hashes.");
commandLineParser.addOptions(QList<QCommandLineOption>() << algorithmsOption << startOption << stopOption << lengthsOption << threadsOption << strictOption << testOption);
commandLineParser.process(a); commandLineParser.process(a);
QTextStream(stderr) << "INFO: Launch " << a.applicationName() << " " << a.applicationVersion() << "..." << Qt::endl; QTextStream(stderr) << "INFO: Launch " << a.applicationName() << " " << a.applicationVersion() << "..." << Qt::endl;
@ -62,6 +63,7 @@ int main(int argc, char *argv[])
const QString bruteforceFile = args.at(0); const QString bruteforceFile = args.at(0);
const QString checksumsFile = args.at(1); const QString checksumsFile = args.at(1);
const bool strictHash = commandLineParser.isSet(strictOption); const bool strictHash = commandLineParser.isSet(strictOption);
const bool testEnabled = commandLineParser.isSet(testOption);
if (strictHash) { if (strictHash) {
QTextStream(stderr) << "INFO: Strict matching enabled" << Qt::endl; QTextStream(stderr) << "INFO: Strict matching enabled" << Qt::endl;
@ -123,6 +125,8 @@ int main(int argc, char *argv[])
version = QString::fromUtf8(versionFunc()); version = QString::fromUtf8(versionFunc());
checksum_map[format] = new checksum_lib(formatFunc, hash32Func, hashSzFunc); checksum_map[format] = new checksum_lib(formatFunc, hash32Func, hashSzFunc);
QTextStream(stderr) << "INFO: " << format << " plugin " << fileName << " loaded" << Qt::endl; QTextStream(stderr) << "INFO: " << format << " plugin " << fileName << " loaded" << Qt::endl;
if (testEnabled)
QTextStream(stderr) << "TEST: " << format << " checkbrute -> " << QString::number(hash32Func((unsigned char*)"checkbrute", 7), 16) << Qt::endl;
} }
else if (formatFunc && hash64Func && hashSzFunc) { else if (formatFunc && hash64Func && hashSzFunc) {
QString version = "undefined"; QString version = "undefined";
@ -131,6 +135,8 @@ int main(int argc, char *argv[])
version = QString::fromUtf8(versionFunc()); version = QString::fromUtf8(versionFunc());
checksum_map[format] = new checksum_lib(formatFunc, hash64Func, hashSzFunc); checksum_map[format] = new checksum_lib(formatFunc, hash64Func, hashSzFunc);
QTextStream(stderr) << "INFO: " << format << " plugin " << fileName << " loaded" << Qt::endl; QTextStream(stderr) << "INFO: " << format << " plugin " << fileName << " loaded" << Qt::endl;
if (testEnabled)
QTextStream(stderr) << "TEST: " << format << " checkbrute -> " << QString::number(hash64Func((unsigned char*)"checkbrute", 7), 16) << Qt::endl;
} }
else { else {
QTextStream(stderr) << "WARNING: Failed loading plugin " << fileName << "!" << Qt::endl; QTextStream(stderr) << "WARNING: Failed loading plugin " << fileName << "!" << Qt::endl;