improve Start End output
This commit is contained in:
parent
1523aff981
commit
ad13b411d1
4 changed files with 10 additions and 9 deletions
|
@ -20,7 +20,7 @@
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include "brutethread.h"
|
#include "brutethread.h"
|
||||||
|
|
||||||
brutethread::brutethread(const QByteArray &fileContent, quint64 length, QVector<checksum*> checksum_vector, QVector<QByteArray> 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*> checksum_vector, QVector<QByteArray> checksums, bool strictMatch) : checksum_vector(checksum_vector), checksums(checksums), fileContent(fileContent), strictMatch(strictMatch), length(length), begin(begin) {}
|
||||||
|
|
||||||
void brutethread::run()
|
void brutethread::run()
|
||||||
{
|
{
|
||||||
|
@ -31,11 +31,11 @@ void brutethread::run()
|
||||||
const QByteArray generatedHash = generator->generateChecksum(content);
|
const QByteArray generatedHash = generator->generateChecksum(content);
|
||||||
for (const QByteArray &hash : checksums) {
|
for (const QByteArray &hash : checksums) {
|
||||||
if (!strictMatch && generatedHash.left(hash.length()) == hash) {
|
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();
|
emit matched();
|
||||||
}
|
}
|
||||||
else if (strictMatch && generatedHash.length() == hash.length() && generatedHash == hash) {
|
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();
|
emit matched();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ class brutethread : public QThread
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit brutethread(const QByteArray &fileContent, quint64 length, QVector<checksum*> checksum_vector, QVector<QByteArray> checksums, bool strictMatch);
|
explicit brutethread(const QByteArray &fileContent, quint64 length, quint64 begin, QVector<checksum*> checksum_vector, QVector<QByteArray> checksums, bool strictMatch);
|
||||||
void run();
|
void run();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -42,6 +42,7 @@ private:
|
||||||
QByteArray fileContent;
|
QByteArray fileContent;
|
||||||
bool strictMatch;
|
bool strictMatch;
|
||||||
quint64 length;
|
quint64 length;
|
||||||
|
quint64 begin;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void matched();
|
void matched();
|
||||||
|
|
|
@ -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.2");
|
a.setApplicationVersion("0.3.3");
|
||||||
|
|
||||||
QCommandLineParser commandLineParser;
|
QCommandLineParser commandLineParser;
|
||||||
commandLineParser.addHelpOption();
|
commandLineParser.addHelpOption();
|
||||||
|
|
|
@ -145,7 +145,7 @@ mainthread::mainthread(const QString &bruteforceFile, const QString &checksumsFi
|
||||||
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: Partial bruteforce start " << begin << " stop " << end << Qt::endl;
|
QTextStream(stderr) << "INFO: Bruteforce Start " << begin << " End " << end << Qt::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!lenghts_str.isEmpty()) {
|
if (!lenghts_str.isEmpty()) {
|
||||||
|
@ -268,7 +268,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, 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, &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 +279,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, 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, &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 +291,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, 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, &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