Commit f3120ceb authored by Hans-Christian Ebke's avatar Hans-Christian Ebke
Browse files

Added function to keygen that allows mangling new plugin fingerprints into...

Added function to keygen that allows mangling new plugin fingerprints into existing hardware hashes.


git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@17433 383ad7c9-94d9-4d36-a494-682f7c89f535
parent caff066b
......@@ -2,11 +2,29 @@
<ui version="4.0">
<class>keyWindow</class>
<widget class="QMainWindow" name="keyWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1200</width>
<height>900</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QWidget" name="mainWidget">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="generator_tab">
<attribute name="title">
<string>License Generator</string>
</attribute>
<layout class="QVBoxLayout" name="generator_tab_vl">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
......@@ -289,6 +307,73 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="mangler_tab">
<attribute name="title">
<string>License Request Mangler</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label_13">
<property name="text">
<string>License Request to extract Hardware Hashes from:</string>
</property>
</widget>
</item>
<item>
<widget class="QTextEdit" name="hardwareHashDump_te"/>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="label_14">
<property name="text">
<string>License Request(s) to extract Plugin Hashes from:</string>
</property>
</widget>
</item>
<item>
<widget class="QTextEdit" name="pluginHashDump_te"/>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="mangle_pb">
<property name="text">
<string>Mangle and Copy To Request Data in License Generator Tab</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
......
......@@ -64,18 +64,25 @@ KeyGen::KeyGen(QString n, QString cHash, QString pHash, QString cpHash, QString
requestSig = request;
}
bool KeyGen::isValid() const
{
QString KeyGen::computeSignature() const {
// Get the salts
QString saltPre;
ADD_SALT_PRE(saltPre);
QString saltPost;
ADD_SALT_POST(saltPost);
QString keyRequest = saltPre + name + coreHash + pluginHash + cpuHash + productHash + macHashes.join("") + saltPost;
QString requestSigCheck = QCryptographicHash::hash ( keyRequest.toAscii() , QCryptographicHash::Sha1 ).toHex();
QString keyRequest = saltPre + name + coreHash + pluginHash + cpuHash
+ productHash + macHashes.join("") + saltPost;
QString requestSigCheck =
QCryptographicHash::hash(keyRequest.toAscii(),
QCryptographicHash::Sha1).toHex();
return requestSigCheck;
}
return requestSig == requestSigCheck;
bool KeyGen::isValid() const
{
return requestSig == computeSignature();
}
QString KeyGen::Generate(QString expiryDate) const
......@@ -174,6 +181,11 @@ KeyGenWidget::KeyGenWidget(QMainWindow *parent)
connect(months,SIGNAL(valueChanged(int)),this,SLOT(slotDate()));
connect(years ,SIGNAL(valueChanged(int)),this,SLOT(slotDate()));
/*
* Mangle Tab
*/
connect(mangle_pb, SIGNAL(clicked()), this, SLOT(slotMangle()));
// Automatically set expire date to current date
// For security reasons no default span is set here!
expires->setDate( QDate::currentDate());
......@@ -182,6 +194,35 @@ KeyGenWidget::KeyGenWidget(QMainWindow *parent)
generateAllButton->setVisible(false);
}
void KeyGenWidget::slotMangle() {
const QString hardwareHash_raw = hardwareHashDump_te->toPlainText();
const QString pluginHashes_raw = pluginHashDump_te->toPlainText();
const std::vector<KeyGen> hardwareKeygens = KeyGen::CreateFromMessyString(hardwareHash_raw);
if (hardwareKeygens.empty()) {
QMessageBox::critical(this, tr("Unable to Mangle"), tr("No valid request found in hardware textbox."));
return;
}
KeyGen hardwareKeygen = hardwareKeygens.front();
std::vector<KeyGen> pluginKeygens = KeyGen::CreateFromMessyString(pluginHashes_raw);
if (pluginKeygens.empty()) {
QMessageBox::critical(this, tr("Unable to Mangle"), tr("No valid request found in plugins textbox."));
return;
}
QString generatedRequest;
for (std::vector<KeyGen>::iterator it = pluginKeygens.begin(), it_end = pluginKeygens.end();
it != it_end; ++it) {
it->copyHardwareHashesFrom(hardwareKeygen);
generatedRequest += it->generateRequest();
}
requestData->setPlainText(generatedRequest);
}
void KeyGenWidget::slotDate() {
QDate today = QDate::currentDate();
today = today.addDays(days->value());
......
......@@ -61,8 +61,25 @@ class KeyGen
//returns string containing the key
QString Generate(QString expiryDate) const;
//finds all occurrences of info in messy string
QString computeSignature() const;
bool isValid() const;
void copyHardwareHashesFrom(const KeyGen &rhs) {
cpuHash = rhs.cpuHash;
macHashes = rhs.macHashes;
}
QString generateRequest() {
return QString("%1\n%2\n%3\n%4\n%5\n%6\n%7\n\n")
.arg(name)
.arg(coreHash)
.arg(pluginHash)
.arg(cpuHash)
.arg(productHash)
.arg(macHashes.join("\n"))
.arg(computeSignature());
}
static std::vector<KeyGen> CreateFromMessyString(QString info);
static QString filterString(QString in);
......@@ -92,6 +109,8 @@ public slots:
void handleSelectionChanged(const QItemSelection& selection);
void slotMangle();
private:
void toFile(const KeyGen* gen);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment