Compare commits
No commits in common. "master" and "0.1" have entirely different histories.
10 changed files with 49 additions and 256 deletions
|
@ -18,16 +18,13 @@ set(CHECKBRUTE_SOURCES
|
||||||
src/mainthread.cpp
|
src/mainthread.cpp
|
||||||
src/brutethread.cpp
|
src/brutethread.cpp
|
||||||
src/checksum.cpp
|
src/checksum.cpp
|
||||||
src/checksum_lib.cpp
|
|
||||||
src/checksum_qt.cpp
|
src/checksum_qt.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(CHECKBRUTE_HEADERS
|
set(CHECKBRUTE_HEADERS
|
||||||
src/mainthread.h
|
src/mainthread.h
|
||||||
src/brutethread.h
|
src/brutethread.h
|
||||||
src/checkbrute.h
|
|
||||||
src/checksum.h
|
src/checksum.h
|
||||||
src/checksum_lib.h
|
|
||||||
src/checksum_qt.h
|
src/checksum_qt.h
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -36,7 +33,6 @@ add_executable(checkbrute
|
||||||
${CHECKBRUTE_SOURCES}
|
${CHECKBRUTE_SOURCES}
|
||||||
)
|
)
|
||||||
|
|
||||||
target_compile_definitions(checkbrute PRIVATE "CHECKBRUTE_PLUGINS=\"${CMAKE_INSTALL_PREFIX}/share/checkbrute/plugins\"")
|
|
||||||
target_link_libraries(checkbrute PRIVATE Qt5::Core)
|
target_link_libraries(checkbrute PRIVATE Qt5::Core)
|
||||||
|
|
||||||
install(TARGETS checkbrute DESTINATION bin)
|
install(TARGETS checkbrute DESTINATION bin)
|
||||||
|
|
|
@ -16,11 +16,10 @@
|
||||||
* responsible for anything with use of the software, you are self responsible.
|
* responsible for anything with use of the software, you are self responsible.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include "brutethread.h"
|
#include "brutethread.h"
|
||||||
|
|
||||||
brutethread::brutethread(const QByteArray &fileContent, quint64 length, quint64 begin, QVector<checksum*> checksum_vector, QVector<QByteArray> checksums, bool strictMatch) : checksum_vector(checksum_vector), checksums(checksums), fileContent(fileContent), strictMatch(strictMatch), length(length), begin(begin) {}
|
brutethread::brutethread(const QByteArray &fileContent, quint64 length, QVector<checksum*> checksum_vector, QVector<QByteArray> checksums) : checksum_vector(checksum_vector), checksums(checksums), fileContent(fileContent), length(length) {}
|
||||||
|
|
||||||
void brutethread::run()
|
void brutethread::run()
|
||||||
{
|
{
|
||||||
|
@ -28,14 +27,10 @@ void brutethread::run()
|
||||||
for (quint64 seek = 0; seek + length < size; seek++) {
|
for (quint64 seek = 0; seek + length < size; seek++) {
|
||||||
for (checksum *generator : checksum_vector) {
|
for (checksum *generator : checksum_vector) {
|
||||||
const QByteArray content = fileContent.mid(seek, length);
|
const QByteArray content = fileContent.mid(seek, length);
|
||||||
const QByteArray generatedHash = generator->generateChecksum(content);
|
const QByteArray generatedHash = generator->generateChecksum(content).toHex();
|
||||||
for (const QByteArray &hash : checksums) {
|
for (const QByteArray &hash : checksums) {
|
||||||
if (!strictMatch && generatedHash.left(hash.length()) == hash) {
|
if (generatedHash.left(hash.length()) == hash) {
|
||||||
QTextStream(stdout) << "MATCH: " << generator->formatName() << " Checksum " << hash << " Start " << begin+seek << " End " << begin+seek+length << Qt::endl;
|
QTextStream(stdout) << "MATCH: " << generator->formatName() << " Checksum " << hash << " Start " << seek << " End " << seek+length << Qt::endl;
|
||||||
emit matched();
|
|
||||||
}
|
|
||||||
else if (strictMatch && generatedHash.length() == hash.length() && generatedHash == hash) {
|
|
||||||
QTextStream(stdout) << "MATCH: " << generator->formatName() << " Checksum " << hash << " Start " << begin+seek << " End " << begin+seek+length << Qt::endl;
|
|
||||||
emit matched();
|
emit matched();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,16 +33,14 @@ class brutethread : public QThread
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit brutethread(const QByteArray &fileContent, quint64 length, quint64 begin, QVector<checksum*> checksum_vector, QVector<QByteArray> checksums, bool strictMatch);
|
explicit brutethread(const QByteArray &fileContent, quint64 length, QVector<checksum*> checksum_vector, QVector<QByteArray> checksums);
|
||||||
void run();
|
void run();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QVector<checksum*> checksum_vector;
|
QVector<checksum*> checksum_vector;
|
||||||
QVector<QByteArray> checksums;
|
QVector<QByteArray> checksums;
|
||||||
QByteArray fileContent;
|
QByteArray fileContent;
|
||||||
bool strictMatch;
|
|
||||||
quint64 length;
|
quint64 length;
|
||||||
quint64 begin;
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void matched();
|
void matched();
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
/*****************************************************************************
|
|
||||||
* checkbrute Checksum Bruteforcing Tool
|
|
||||||
* Copyright (C) 2020 Syping
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
* are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* This software is provided as-is, no warranties are given to you, we are not
|
|
||||||
* responsible for anything with use of the software, you are self responsible.
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef CHECKBRUTE_H
|
|
||||||
#define CHECKBRUTE_H
|
|
||||||
|
|
||||||
#ifndef CHECKBRUTE_PLUGINS
|
|
||||||
#define CHECKBRUTE_PLUGINS "/usr/local/share/checkbrute/plugins"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // CHECKBRUTE_H
|
|
|
@ -1,63 +0,0 @@
|
||||||
/*****************************************************************************
|
|
||||||
* checkbrute Checksum Bruteforcing Tool
|
|
||||||
* Copyright (C) 2020 Syping
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
* are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* This software is provided as-is, no warranties are given to you, we are not
|
|
||||||
* responsible for anything with use of the software, you are self responsible.
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
#include "checksum_lib.h"
|
|
||||||
#include <iostream>
|
|
||||||
#include <cstdint>
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
checksum_lib::checksum_lib(PluginFormatFunction formatFunc, PluginHash32Function hash32Func, PluginHashSzFunction hashSzFunc) : hash32Func(hash32Func)
|
|
||||||
{
|
|
||||||
p_formatName = QString::fromUtf8(formatFunc());
|
|
||||||
p_checksumSize = hashSzFunc();
|
|
||||||
p_funcBit = 32;
|
|
||||||
}
|
|
||||||
|
|
||||||
checksum_lib::checksum_lib(PluginFormatFunction formatFunc, PluginHash64Function hash64Func, PluginHashSzFunction hashSzFunc) : hash64Func(hash64Func)
|
|
||||||
{
|
|
||||||
p_formatName = QString::fromUtf8(formatFunc());
|
|
||||||
p_checksumSize = hashSzFunc();
|
|
||||||
p_funcBit = 64;
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray checksum_lib::generateChecksum(const QByteArray &data)
|
|
||||||
{
|
|
||||||
const size_t size = data.size();
|
|
||||||
unsigned char *udata = new unsigned char[size];
|
|
||||||
std::memcpy(udata, data.constData(), size);
|
|
||||||
if (p_funcBit == 32) {
|
|
||||||
const u_int32_t hash = hash32Func(udata, size);
|
|
||||||
free(udata);
|
|
||||||
return QByteArray::number((quint32)hash, 16);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
const u_int64_t hash = hash64Func(udata, size);
|
|
||||||
free(udata);
|
|
||||||
return QByteArray::number((quint64)hash, 16);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const QString checksum_lib::formatName()
|
|
||||||
{
|
|
||||||
return p_formatName;
|
|
||||||
}
|
|
||||||
|
|
||||||
int checksum_lib::checksumSize()
|
|
||||||
{
|
|
||||||
return p_checksumSize;
|
|
||||||
}
|
|
|
@ -1,48 +0,0 @@
|
||||||
/*****************************************************************************
|
|
||||||
* checkbrute Checksum Bruteforcing Tool
|
|
||||||
* Copyright (C) 2020 Syping
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
* are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* This software is provided as-is, no warranties are given to you, we are not
|
|
||||||
* responsible for anything with use of the software, you are self responsible.
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef CHECKSUM_LIB_H
|
|
||||||
#define CHECKSUM_LIB_H
|
|
||||||
|
|
||||||
#include "checksum.h"
|
|
||||||
|
|
||||||
typedef int (*PluginHashSzFunction)();
|
|
||||||
typedef const char* (*PluginFormatFunction)();
|
|
||||||
typedef const char* (*PluginVersionFunction)();
|
|
||||||
typedef u_int32_t (*PluginHash32Function)(unsigned char*, size_t);
|
|
||||||
typedef u_int64_t (*PluginHash64Function)(unsigned char*, size_t);
|
|
||||||
|
|
||||||
class checksum_lib : public checksum
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
explicit checksum_lib(PluginFormatFunction formatFunc, PluginHash32Function hash32Func, PluginHashSzFunction hashSzFunc);
|
|
||||||
explicit checksum_lib(PluginFormatFunction formatFunc, PluginHash64Function hash64Func, PluginHashSzFunction hashSzFunc);
|
|
||||||
QByteArray generateChecksum(const QByteArray &data);
|
|
||||||
const QString formatName();
|
|
||||||
int checksumSize();
|
|
||||||
|
|
||||||
private:
|
|
||||||
PluginHash32Function hash32Func;
|
|
||||||
PluginHash64Function hash64Func;
|
|
||||||
QString p_formatName;
|
|
||||||
int p_checksumSize;
|
|
||||||
int p_funcBit;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // CHECKSUM_LIB_H
|
|
|
@ -23,7 +23,7 @@ checksum_qt::checksum_qt(QCryptographicHash::Algorithm algorithm, const QString
|
||||||
|
|
||||||
QByteArray checksum_qt::generateChecksum(const QByteArray &data)
|
QByteArray checksum_qt::generateChecksum(const QByteArray &data)
|
||||||
{
|
{
|
||||||
return QCryptographicHash::hash(data, algorithm).toHex();
|
return QCryptographicHash::hash(data, algorithm);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString checksum_qt::formatName()
|
const QString checksum_qt::formatName()
|
||||||
|
|
|
@ -36,4 +36,4 @@ private:
|
||||||
QString name;
|
QString name;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CHECKSUM_QT5_H
|
#endif // CHECKSUM_MD5_H
|
||||||
|
|
71
src/main.cpp
71
src/main.cpp
|
@ -22,21 +22,17 @@
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QLibrary>
|
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QDir>
|
|
||||||
|
|
||||||
// checkbrute includes
|
// checkbrute includes
|
||||||
#include "mainthread.h"
|
#include "mainthread.h"
|
||||||
#include "checkbrute.h"
|
|
||||||
#include "checksum_qt.h"
|
#include "checksum_qt.h"
|
||||||
#include "checksum_lib.h"
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QCoreApplication a(argc, argv);
|
QCoreApplication a(argc, argv);
|
||||||
a.setApplicationName("checkbrute");
|
a.setApplicationName("checkbrute");
|
||||||
a.setApplicationVersion("0.3.3");
|
a.setApplicationVersion("0.1");
|
||||||
|
|
||||||
QCommandLineParser commandLineParser;
|
QCommandLineParser commandLineParser;
|
||||||
commandLineParser.addHelpOption();
|
commandLineParser.addHelpOption();
|
||||||
|
@ -49,8 +45,7 @@ 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.");
|
||||||
QCommandLineOption testOption = QCommandLineOption(QStringList() << "t" << "test", "Test checkbrute plugin hashes.");
|
commandLineParser.addOptions(QList<QCommandLineOption>() << algorithmsOption << startOption << stopOption << lengthsOption << threadsOption << strictOption);
|
||||||
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;
|
||||||
|
@ -63,7 +58,6 @@ 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;
|
||||||
|
@ -91,61 +85,26 @@ int main(int argc, char *argv[])
|
||||||
std::map<std::string,checksum*> checksum_map;
|
std::map<std::string,checksum*> checksum_map;
|
||||||
checksum_map["MD4"] = new checksum_qt(QCryptographicHash::Md4, "MD4");
|
checksum_map["MD4"] = new checksum_qt(QCryptographicHash::Md4, "MD4");
|
||||||
checksum_map["MD5"] = new checksum_qt(QCryptographicHash::Md5, "MD5");
|
checksum_map["MD5"] = new checksum_qt(QCryptographicHash::Md5, "MD5");
|
||||||
checksum_map["SHA-1"] = new checksum_qt(QCryptographicHash::Sha1, "SHA-1");
|
checksum_map["SHA1"] = new checksum_qt(QCryptographicHash::Sha1, "SHA1");
|
||||||
checksum_map["SHA-224"] = new checksum_qt(QCryptographicHash::Sha224, "SHA-224");
|
checksum_map["SHA2-256"] = new checksum_qt(QCryptographicHash::Sha256, "SHA2-256");
|
||||||
checksum_map["SHA-256"] = new checksum_qt(QCryptographicHash::Sha256, "SHA-256");
|
checksum_map["SHA2-512"] = new checksum_qt(QCryptographicHash::Sha512, "SHA2-512");
|
||||||
checksum_map["SHA-384"] = new checksum_qt(QCryptographicHash::Sha384, "SHA-384");
|
|
||||||
checksum_map["SHA-512"] = new checksum_qt(QCryptographicHash::Sha512, "SHA-512");
|
|
||||||
checksum_map["SHA3-224"] = new checksum_qt(QCryptographicHash::Sha3_224, "SHA3-224");
|
|
||||||
checksum_map["SHA3-256"] = new checksum_qt(QCryptographicHash::Sha3_256, "SHA3-256");
|
checksum_map["SHA3-256"] = new checksum_qt(QCryptographicHash::Sha3_256, "SHA3-256");
|
||||||
checksum_map["SHA3-384"] = new checksum_qt(QCryptographicHash::Sha3_384, "SHA3-384");
|
|
||||||
checksum_map["SHA3-512"] = new checksum_qt(QCryptographicHash::Sha3_512, "SHA3-512");
|
checksum_map["SHA3-512"] = new checksum_qt(QCryptographicHash::Sha3_512, "SHA3-512");
|
||||||
#if QT_VERSION >= 0x050902
|
#if QT_VERSION >= 0x050902
|
||||||
checksum_map["Keccak-224"] = new checksum_qt(QCryptographicHash::Keccak_224, "Keccak-224");
|
|
||||||
checksum_map["Keccak-256"] = new checksum_qt(QCryptographicHash::Keccak_256, "Keccak-256");
|
checksum_map["Keccak-256"] = new checksum_qt(QCryptographicHash::Keccak_256, "Keccak-256");
|
||||||
checksum_map["Keccak-384"] = new checksum_qt(QCryptographicHash::Keccak_384, "Keccak-384");
|
|
||||||
checksum_map["Keccak-512"] = new checksum_qt(QCryptographicHash::Keccak_512, "Keccak-512");
|
checksum_map["Keccak-512"] = new checksum_qt(QCryptographicHash::Keccak_512, "Keccak-512");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (const QString &fileName : QDir(CHECKBRUTE_PLUGINS).entryList(QDir::Files, QDir::Name)) {
|
// 224 and 384 bit hashes are partial
|
||||||
const QString filePath = QString("%1/%2").arg(CHECKBRUTE_PLUGINS, fileName);
|
if (strictHash) {
|
||||||
if (QLibrary::isLibrary(filePath)) {
|
checksum_map["SHA2-224"] = new checksum_qt(QCryptographicHash::Sha224, "SHA2-224");
|
||||||
QTextStream(stderr) << "INFO: Load plugin " << fileName << "..." << Qt::endl;
|
checksum_map["SHA2-384"] = new checksum_qt(QCryptographicHash::Sha384, "SHA2-384");
|
||||||
QLibrary plugin(filePath);
|
checksum_map["SHA3-224"] = new checksum_qt(QCryptographicHash::Sha3_224, "SHA3-224");
|
||||||
if (plugin.load()) {
|
checksum_map["SHA3-384"] = new checksum_qt(QCryptographicHash::Sha3_384, "SHA3-384");
|
||||||
PluginHash32Function hash32Func = (PluginHash32Function)plugin.resolve("checkbrute_hash32");
|
#if QT_VERSION >= 0x050902
|
||||||
PluginHash64Function hash64Func = (PluginHash64Function)plugin.resolve("checkbrute_hash64");
|
checksum_map["Keccak-224"] = new checksum_qt(QCryptographicHash::Keccak_224, "Keccak-224");
|
||||||
PluginHashSzFunction hashSzFunc = (PluginHashSzFunction)plugin.resolve("checkbrute_hashsz");
|
checksum_map["Keccak-384"] = new checksum_qt(QCryptographicHash::Keccak_384, "Keccak-384");
|
||||||
PluginFormatFunction formatFunc = (PluginFormatFunction)plugin.resolve("checkbrute_format");
|
#endif
|
||||||
PluginVersionFunction versionFunc = (PluginVersionFunction)plugin.resolve("checkbrute_version");
|
|
||||||
if (formatFunc && hash32Func && hashSzFunc) {
|
|
||||||
QString version = "undefined";
|
|
||||||
const char *format = formatFunc();
|
|
||||||
if (versionFunc)
|
|
||||||
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";
|
|
||||||
const char *format = formatFunc();
|
|
||||||
if (versionFunc)
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
QTextStream(stderr) << "WARNING: Failed loading plugin " << fileName << "!" << Qt::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mainthread instance(bruteforceFile, checksumsFile, algorithms, start, stop, lengths, threads, strictHash, checksum_map);
|
mainthread instance(bruteforceFile, checksumsFile, algorithms, start, stop, lengths, threads, strictHash, checksum_map);
|
||||||
|
|
|
@ -26,6 +26,29 @@
|
||||||
|
|
||||||
mainthread::mainthread(const QString &bruteforceFile, const QString &checksumsFile, const QString &algorithms, const QString &start, const QString &stop, const QString &lenghts_str, const QString &threads_str, bool strictHash, const std::map<std::string,checksum*> &checksum_map) : checksum_map(checksum_map), strictHash(strictHash)
|
mainthread::mainthread(const QString &bruteforceFile, const QString &checksumsFile, const QString &algorithms, const QString &start, const QString &stop, const QString &lenghts_str, const QString &threads_str, bool strictHash, const std::map<std::string,checksum*> &checksum_map) : checksum_map(checksum_map), strictHash(strictHash)
|
||||||
{
|
{
|
||||||
|
if (!algorithms.isEmpty()) {
|
||||||
|
for (const QString &algorithm : algorithms.split(',')) {
|
||||||
|
std::map<std::string,checksum*>::const_iterator it;
|
||||||
|
it = checksum_map.find(algorithm.toUpper().toStdString());
|
||||||
|
if (it != checksum_map.end()) {
|
||||||
|
QTextStream(stderr) << "INFO: Using " << QString::fromStdString(it->first) << " algorithm" << Qt::endl;
|
||||||
|
checksum_vector << it->second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
std::map<std::string,checksum*>::const_iterator it;
|
||||||
|
for (it = checksum_map.begin(); it != checksum_map.end(); it++) {
|
||||||
|
QTextStream(stderr) << "INFO: Using " << QString::fromStdString(it->first) << " algorithm" << Qt::endl;
|
||||||
|
checksum_vector << it->second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (checksum_vector.isEmpty()) {
|
||||||
|
QTextStream(stderr) << "ERROR: No algorithms are used!" << Qt::endl;
|
||||||
|
initialised = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QFile bruteforceFileHandler(bruteforceFile);
|
QFile bruteforceFileHandler(bruteforceFile);
|
||||||
if (bruteforceFileHandler.open(QIODevice::ReadOnly)) {
|
if (bruteforceFileHandler.open(QIODevice::ReadOnly)) {
|
||||||
QTextStream(stderr) << "INFO: Reading source file " << bruteforceFile << "..." << Qt::endl;
|
QTextStream(stderr) << "INFO: Reading source file " << bruteforceFile << "..." << Qt::endl;
|
||||||
|
@ -69,46 +92,6 @@ mainthread::mainthread(const QString &bruteforceFile, const QString &checksumsFi
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!algorithms.isEmpty()) {
|
|
||||||
for (const QString &algorithm : algorithms.split(',')) {
|
|
||||||
std::map<std::string,checksum*>::const_iterator it;
|
|
||||||
it = checksum_map.find(algorithm.toUpper().toStdString());
|
|
||||||
if (it != checksum_map.end()) {
|
|
||||||
QTextStream(stderr) << "INFO: Using " << QString::fromStdString(it->first) << " algorithm" << Qt::endl;
|
|
||||||
checksum_vector << it->second;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
std::map<std::string,checksum*>::const_iterator it;
|
|
||||||
for (it = checksum_map.begin(); it != checksum_map.end(); it++) {
|
|
||||||
const int checksumSize = it->second->checksumSize();
|
|
||||||
if (!strictHash) {
|
|
||||||
for (const QByteArray &hash : checksums) {
|
|
||||||
if (checksumSize >= hash.count() / 2) {
|
|
||||||
QTextStream(stderr) << "INFO: Using " << QString::fromStdString(it->first) << " algorithm" << Qt::endl;
|
|
||||||
checksum_vector << it->second;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
for (const QByteArray &hash : checksums) {
|
|
||||||
if (checksumSize == hash.count() / 2) {
|
|
||||||
QTextStream(stderr) << "INFO: Using " << QString::fromStdString(it->first) << " algorithm" << Qt::endl;
|
|
||||||
checksum_vector << it->second;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (checksum_vector.isEmpty()) {
|
|
||||||
QTextStream(stderr) << "ERROR: No algorithms are used!" << Qt::endl;
|
|
||||||
initialised = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!start.isEmpty()) {
|
if (!start.isEmpty()) {
|
||||||
bool startOk;
|
bool startOk;
|
||||||
begin = start.toULongLong(&startOk);
|
begin = start.toULongLong(&startOk);
|
||||||
|
@ -142,10 +125,9 @@ mainthread::mainthread(const QString &bruteforceFile, const QString &checksumsFi
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear unneeded bytes
|
// Clear unneeded bytes
|
||||||
if (begin != 0 || end != (quint64)fileContent.size()) {
|
if (begin != 0 && end != (quint64)fileContent.size()) {
|
||||||
fileContent = fileContent.mid(begin, end - begin);
|
fileContent = fileContent.mid(begin, end - begin);
|
||||||
fileContent.squeeze();
|
fileContent.squeeze();
|
||||||
QTextStream(stderr) << "INFO: Bruteforce Start " << begin << " End " << end << Qt::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!lenghts_str.isEmpty()) {
|
if (!lenghts_str.isEmpty()) {
|
||||||
|
@ -268,7 +250,7 @@ void mainthread::run()
|
||||||
if (threads >= mthreads)
|
if (threads >= mthreads)
|
||||||
eventLoop.exec();
|
eventLoop.exec();
|
||||||
QTextStream(stderr) << "[" << std::distance(lengths.constBegin(), it) + 1 << "/" << lengthsCount << "] [" << min << "/" << max << "] Bruteforcing...\r";
|
QTextStream(stderr) << "[" << std::distance(lengths.constBegin(), it) + 1 << "/" << lengthsCount << "] [" << min << "/" << max << "] Bruteforcing...\r";
|
||||||
brutethread *thread = new brutethread(fileContent, min, begin, checksum_vector, checksums, strictHash);
|
brutethread *thread = new brutethread(fileContent, min, checksum_vector, checksums);
|
||||||
QObject::connect(thread, &QThread::finished, this, &mainthread::threadFinished);
|
QObject::connect(thread, &QThread::finished, this, &mainthread::threadFinished);
|
||||||
QObject::connect(thread, &brutethread::matched, this, &mainthread::matched);
|
QObject::connect(thread, &brutethread::matched, this, &mainthread::matched);
|
||||||
thread->start(QThread::LowPriority);
|
thread->start(QThread::LowPriority);
|
||||||
|
@ -279,7 +261,7 @@ void mainthread::run()
|
||||||
if (threads >= mthreads)
|
if (threads >= mthreads)
|
||||||
eventLoop.exec();
|
eventLoop.exec();
|
||||||
QTextStream(stderr) << "[" << std::distance(lengths.constBegin(), it) + 1 << "/" << lengthsCount << "] [" << clength << "/" << max << "] Bruteforcing...\r";
|
QTextStream(stderr) << "[" << std::distance(lengths.constBegin(), it) + 1 << "/" << lengthsCount << "] [" << clength << "/" << max << "] Bruteforcing...\r";
|
||||||
brutethread *thread = new brutethread(fileContent, clength, begin, checksum_vector, checksums, strictHash);
|
brutethread *thread = new brutethread(fileContent, clength, checksum_vector, checksums);
|
||||||
QObject::connect(thread, &QThread::finished, this, &mainthread::threadFinished);
|
QObject::connect(thread, &QThread::finished, this, &mainthread::threadFinished);
|
||||||
QObject::connect(thread, &brutethread::matched, this, &mainthread::matched);
|
QObject::connect(thread, &brutethread::matched, this, &mainthread::matched);
|
||||||
thread->start(QThread::LowPriority);
|
thread->start(QThread::LowPriority);
|
||||||
|
@ -291,7 +273,7 @@ void mainthread::run()
|
||||||
if (threads >= mthreads)
|
if (threads >= mthreads)
|
||||||
eventLoop.exec();
|
eventLoop.exec();
|
||||||
QTextStream(stderr) << "[" << std::distance(lengths.constBegin(), it) + 1 << "/" << lengthsCount << "] [" << clength << "/" << max << "] Bruteforcing...\r";
|
QTextStream(stderr) << "[" << std::distance(lengths.constBegin(), it) + 1 << "/" << lengthsCount << "] [" << clength << "/" << max << "] Bruteforcing...\r";
|
||||||
brutethread *thread = new brutethread(fileContent, clength, begin, checksum_vector, checksums, strictHash);
|
brutethread *thread = new brutethread(fileContent, clength, checksum_vector, checksums);
|
||||||
QObject::connect(thread, &QThread::finished, this, &mainthread::threadFinished);
|
QObject::connect(thread, &QThread::finished, this, &mainthread::threadFinished);
|
||||||
QObject::connect(thread, &brutethread::matched, this, &mainthread::matched);
|
QObject::connect(thread, &brutethread::matched, this, &mainthread::matched);
|
||||||
thread->start(QThread::LowPriority);
|
thread->start(QThread::LowPriority);
|
||||||
|
|
Loading…
Reference in a new issue