add -t test function

This commit is contained in:
Syping 2020-10-25 16:35:15 +01:00
parent 9fdcba128f
commit e3b7cf162b
1 changed files with 8 additions and 2 deletions

View File

@ -36,7 +36,7 @@ int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
a.setApplicationName("checkbrute");
a.setApplicationVersion("0.3");
a.setApplicationVersion("0.3.1");
QCommandLineParser commandLineParser;
commandLineParser.addHelpOption();
@ -49,7 +49,8 @@ int main(int argc, char *argv[])
QCommandLineOption lengthsOption = QCommandLineOption("lengths", "Lengths to use for bruteforcing.", "lengths");
QCommandLineOption threadsOption = QCommandLineOption("threads", "Threads to use for bruteforcing.", "threads");
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);
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 checksumsFile = args.at(1);
const bool strictHash = commandLineParser.isSet(strictOption);
const bool testEnabled = commandLineParser.isSet(testOption);
if (strictHash) {
QTextStream(stderr) << "INFO: Strict matching enabled" << Qt::endl;
@ -123,6 +125,8 @@ int main(int argc, char *argv[])
version = QString::fromUtf8(versionFunc());
checksum_map[format] = new checksum_lib(formatFunc, hash32Func, hashSzFunc);
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) {
QString version = "undefined";
@ -131,6 +135,8 @@ int main(int argc, char *argv[])
version = QString::fromUtf8(versionFunc());
checksum_map[format] = new checksum_lib(formatFunc, hash64Func, hashSzFunc);
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 {
QTextStream(stderr) << "WARNING: Failed loading plugin " << fileName << "!" << Qt::endl;