44 lines
2.3 KiB
C++
44 lines
2.3 KiB
C++
/*****************************************************************************
|
|
* 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 <QDebug>
|
|
#include <QTextStream>
|
|
#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) {}
|
|
|
|
void brutethread::run()
|
|
{
|
|
quint64 size = fileContent.size();
|
|
for (quint64 seek = 0; seek + length < size; seek++) {
|
|
for (checksum *generator : checksum_vector) {
|
|
const QByteArray content = fileContent.mid(seek, length);
|
|
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 " << 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 " << begin+seek << " End " << begin+seek+length << Qt::endl;
|
|
emit matched();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|