From ad13b411d166bc8ca857ed92c260367cf3321697 Mon Sep 17 00:00:00 2001 From: Syping Date: Sun, 25 Oct 2020 19:16:08 +0100 Subject: [PATCH] improve Start End output --- src/brutethread.cpp | 6 +++--- src/brutethread.h | 3 ++- src/main.cpp | 2 +- src/mainthread.cpp | 8 ++++---- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/brutethread.cpp b/src/brutethread.cpp index 13e0beb..46d3fb4 100644 --- a/src/brutethread.cpp +++ b/src/brutethread.cpp @@ -20,7 +20,7 @@ #include #include "brutethread.h" -brutethread::brutethread(const QByteArray &fileContent, quint64 length, QVector checksum_vector, QVector checksums, bool strictMatch) : checksum_vector(checksum_vector), checksums(checksums), fileContent(fileContent), strictMatch(strictMatch), length(length) {} +brutethread::brutethread(const QByteArray &fileContent, quint64 length, quint64 begin, QVector checksum_vector, QVector checksums, bool strictMatch) : checksum_vector(checksum_vector), checksums(checksums), fileContent(fileContent), strictMatch(strictMatch), length(length), begin(begin) {} void brutethread::run() { @@ -31,11 +31,11 @@ void brutethread::run() const QByteArray generatedHash = generator->generateChecksum(content); for (const QByteArray &hash : checksums) { if (!strictMatch && generatedHash.left(hash.length()) == hash) { - QTextStream(stdout) << "MATCH: " << generator->formatName() << " Checksum " << hash << " Start " << seek << " End " << seek+length << Qt::endl; + QTextStream(stdout) << "MATCH: " << generator->formatName() << " Checksum " << hash << " Start " << begin+seek << " End " << begin+seek+length << Qt::endl; emit matched(); } else if (strictMatch && generatedHash.length() == hash.length() && generatedHash == hash) { - QTextStream(stdout) << "MATCH: " << generator->formatName() << " Checksum " << hash << " Start " << seek << " End " << seek+length << Qt::endl; + QTextStream(stdout) << "MATCH: " << generator->formatName() << " Checksum " << hash << " Start " << begin+seek << " End " << begin+seek+length << Qt::endl; emit matched(); } } diff --git a/src/brutethread.h b/src/brutethread.h index d011af9..5f15b8e 100644 --- a/src/brutethread.h +++ b/src/brutethread.h @@ -33,7 +33,7 @@ class brutethread : public QThread { Q_OBJECT public: - explicit brutethread(const QByteArray &fileContent, quint64 length, QVector checksum_vector, QVector checksums, bool strictMatch); + explicit brutethread(const QByteArray &fileContent, quint64 length, quint64 begin, QVector checksum_vector, QVector checksums, bool strictMatch); void run(); private: @@ -42,6 +42,7 @@ private: QByteArray fileContent; bool strictMatch; quint64 length; + quint64 begin; signals: void matched(); diff --git a/src/main.cpp b/src/main.cpp index 6b82ae4..c7194c3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -36,7 +36,7 @@ int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); a.setApplicationName("checkbrute"); - a.setApplicationVersion("0.3.2"); + a.setApplicationVersion("0.3.3"); QCommandLineParser commandLineParser; commandLineParser.addHelpOption(); diff --git a/src/mainthread.cpp b/src/mainthread.cpp index 5364261..6a54fee 100644 --- a/src/mainthread.cpp +++ b/src/mainthread.cpp @@ -145,7 +145,7 @@ mainthread::mainthread(const QString &bruteforceFile, const QString &checksumsFi if (begin != 0 || end != (quint64)fileContent.size()) { fileContent = fileContent.mid(begin, end - begin); fileContent.squeeze(); - QTextStream(stderr) << "INFO: Partial bruteforce start " << begin << " stop " << end << Qt::endl; + QTextStream(stderr) << "INFO: Bruteforce Start " << begin << " End " << end << Qt::endl; } if (!lenghts_str.isEmpty()) { @@ -268,7 +268,7 @@ void mainthread::run() if (threads >= mthreads) eventLoop.exec(); QTextStream(stderr) << "[" << std::distance(lengths.constBegin(), it) + 1 << "/" << lengthsCount << "] [" << min << "/" << max << "] Bruteforcing...\r"; - brutethread *thread = new brutethread(fileContent, min, checksum_vector, checksums, strictHash); + brutethread *thread = new brutethread(fileContent, min, begin, checksum_vector, checksums, strictHash); QObject::connect(thread, &QThread::finished, this, &mainthread::threadFinished); QObject::connect(thread, &brutethread::matched, this, &mainthread::matched); thread->start(QThread::LowPriority); @@ -279,7 +279,7 @@ void mainthread::run() if (threads >= mthreads) eventLoop.exec(); QTextStream(stderr) << "[" << std::distance(lengths.constBegin(), it) + 1 << "/" << lengthsCount << "] [" << clength << "/" << max << "] Bruteforcing...\r"; - brutethread *thread = new brutethread(fileContent, clength, checksum_vector, checksums, strictHash); + brutethread *thread = new brutethread(fileContent, clength, begin, checksum_vector, checksums, strictHash); QObject::connect(thread, &QThread::finished, this, &mainthread::threadFinished); QObject::connect(thread, &brutethread::matched, this, &mainthread::matched); thread->start(QThread::LowPriority); @@ -291,7 +291,7 @@ void mainthread::run() if (threads >= mthreads) eventLoop.exec(); QTextStream(stderr) << "[" << std::distance(lengths.constBegin(), it) + 1 << "/" << lengthsCount << "] [" << clength << "/" << max << "] Bruteforcing...\r"; - brutethread *thread = new brutethread(fileContent, clength, checksum_vector, checksums, strictHash); + brutethread *thread = new brutethread(fileContent, clength, begin, checksum_vector, checksums, strictHash); QObject::connect(thread, &QThread::finished, this, &mainthread::threadFinished); QObject::connect(thread, &brutethread::matched, this, &mainthread::matched); thread->start(QThread::LowPriority);