Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mathsoft-dev committed Jul 31, 2015
1 parent 629af01 commit 4a7046c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/johnhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ void JohnHandler::setJohnProgram(const QString &johnProgram)

void JohnHandler::start()
{
// Give a chance to terminate cleanly
if (m_john.state() != QProcess::NotRunning)
terminate();
JohnHandler::exec();
}

Expand Down
11 changes: 5 additions & 6 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ MainWindow::MainWindow(QSettings &settings)
// Settings changed by user
connect(m_ui->spinBoxTimeIntervalPickCracked,SIGNAL(valueChanged(int)),this,SLOT(applyAndSaveSettings()));
connect(m_ui->lineEditPathToJohn,SIGNAL(textEdited(QString)),this,SLOT(applyAndSaveSettings()));
connect(m_ui->lineEditPathToJohn,SIGNAL(textEdited(QString)),this,SLOT(getDefaultFormat()));
connect(m_ui->comboBoxLanguageSelection,SIGNAL(currentIndexChanged(int)),this,SLOT(applyAndSaveSettings()));

// Action buttons
Expand Down Expand Up @@ -914,10 +915,6 @@ void MainWindow::showJohnFinished(int exitCode, QProcess::ExitStatus exitStatus)

void MainWindow::callJohnShow(bool showAllFormats)
{
// Give a chance to terminate cleanly
if (m_johnShow.state() != QProcess::NotRunning)
m_johnShow.stop();

QStringList args;
// We add current format key if it is not empty.
if (!m_sessionCurrent.format().isEmpty() && !showAllFormats)
Expand Down Expand Up @@ -1230,7 +1227,9 @@ void MainWindow::setAvailabilityOfFeatures(bool isJumbo)
}
m_ui->tableView_Hashes->setColumnHidden(PasswordFileModel::FORMAT_COL, !isJumbo);
m_ui->actionFilterFormatColumn->setEnabled(isJumbo);
m_ui->lineEdit_WordlistRules->setVisible(isJumbo);
if (!isJumbo) {
m_ui->lineEdit_WordlistRules->clear();
// Add default format list supported by core john
QStringList defaultFormats;
defaultFormats << tr("Auto detect") + (m_sessionCurrent.defaultFormat().isEmpty() ? "" : " (" + m_sessionCurrent.defaultFormat() + ")")
Expand Down Expand Up @@ -1524,7 +1523,8 @@ void MainWindow::resetFilters()

void MainWindow::getDefaultFormat()
{
m_johnDefaultFormat.setJohnProgram(m_pathToJohn);
// This signal may be called 1 ms before applySettings() so use the lineEdit text
m_johnDefaultFormat.setJohnProgram(m_ui->lineEditPathToJohn->text());

This comment has been minimized.

Copy link
@shinnok

shinnok Aug 1, 2015

We should usually use the stored setting and not UI values.

This comment has been minimized.

Copy link
@mathsoft-dev

mathsoft-dev Aug 1, 2015

Author Owner

As I commented in the code, SLOTS applySettings() and getDefaultFormat() are both linked to the textEdited signal of the lineEdit. Using the UI value in that specific case guarantee that we'll get the right john path in the case getDefaultFormat slot is triggered before applySettings one.

This comment has been minimized.

Copy link
@shinnok

shinnok Aug 3, 2015

This will change when we handle openwall#75. textEdited() will be connected to johnVersion handler, which upon success calls applySettings, reconsiderUi, startSession and then getDefaultFormat. As discussed elsewhere, when john path is successfully changed, we'll have to start a new session with the existing password files, if any.

QStringList args;
args << "-stdin";
args << "--session=defaultFormat";
Expand Down Expand Up @@ -1556,5 +1556,4 @@ void MainWindow::getDefaultFormatFinished(int exitCode, QProcess::ExitStatus exi

m_ui->formatComboBox->setItemText(0, tr("Auto detect") + (defaultFormat.isEmpty() ? "" : " (" + defaultFormat + ")"));
callJohnShow(true);

}

0 comments on commit 4a7046c

Please sign in to comment.