Analysis Menu-Cursor changes Issue #124 (#189)

* Add relro in the dashboard #105
This commit is contained in:
sergiodmn - kms 2017-07-24 13:05:28 +02:00 committed by radare
parent 6c8adef74b
commit 76bc053a8c
9 changed files with 218 additions and 44 deletions

View File

@ -18,10 +18,11 @@ AnalThread::~AnalThread()
} }
} }
void AnalThread::start(IaitoRCore *core, int level) void AnalThread::start(IaitoRCore *core, int level, QList<QString> advanced)
{ {
this->core = core; this->core = core;
this->level = level; this->level = level;
this->advanced = advanced;
QThread::start(); QThread::start();
} }
@ -30,5 +31,5 @@ void AnalThread::start(IaitoRCore *core, int level)
void AnalThread::run() void AnalThread::run()
{ {
//qDebug() << "Anal level: " << this->level; //qDebug() << "Anal level: " << this->level;
core->analyze(this->level); core->analyze(this->level, this->advanced);
} }

View File

@ -12,7 +12,7 @@ public:
explicit AnalThread(QWidget *parent = 0); explicit AnalThread(QWidget *parent = 0);
~AnalThread(); ~AnalThread();
void start(IaitoRCore *core, int level); void start(IaitoRCore *core, int level, QList<QString> advanced);
protected: protected:
void run(); void run();
@ -22,6 +22,7 @@ protected:
private: private:
IaitoRCore *core; IaitoRCore *core;
int level; int level;
QList<QString> advanced;
}; };
#endif // ANALTHREAD_H #endif // ANALTHREAD_H

View File

@ -191,7 +191,7 @@ public:
void setOptions(QString key); void setOptions(QString key);
bool loadFile(QString path, uint64_t loadaddr = 0LL, uint64_t mapaddr = 0LL, bool rw = false, int va = 0, int idx = 0, bool loadbin = false); bool loadFile(QString path, uint64_t loadaddr = 0LL, uint64_t mapaddr = 0LL, bool rw = false, int va = 0, int idx = 0, bool loadbin = false);
bool tryFile(QString path, bool rw); bool tryFile(QString path, bool rw);
void analyze(int level); void analyze(int level, QList<QString> advanced);
void seek(QString addr); void seek(QString addr);
void seek(ut64 offset); void seek(ut64 offset);
ut64 math(const QString &expr); ut64 math(const QString &expr);

View File

@ -286,17 +286,17 @@ void MainWindow::initUI()
connect(refresh_shortcut, SIGNAL(activated()), this, SLOT(refreshVisibleDockWidgets())); connect(refresh_shortcut, SIGNAL(activated()), this, SLOT(refreshVisibleDockWidgets()));
} }
void MainWindow::openFile(const QString &fn, int anal_level) void MainWindow::openFile(const QString &fn, int anal_level, QList<QString> advanced)
{ {
QString project_name = qhelpers::uniqueProjectName(fn); QString project_name = qhelpers::uniqueProjectName(fn);
if (core->getProjectNames().contains(project_name)) if (core->getProjectNames().contains(project_name))
openProject(project_name); openProject(project_name);
else else
openNewFile(fn, anal_level); openNewFile(fn, anal_level, advanced);
} }
void MainWindow::openNewFile(const QString &fn, int anal_level) void MainWindow::openNewFile(const QString &fn, int anal_level, QList<QString> advanced)
{ {
setFilename(fn); setFilename(fn);
@ -305,7 +305,7 @@ void MainWindow::openNewFile(const QString &fn, int anal_level)
o->show(); o->show();
if (anal_level >= 0) if (anal_level >= 0)
o->setupAndStartAnalysis(anal_level); o->setupAndStartAnalysis(anal_level, advanced);
} }
void MainWindow::openProject(const QString &project_name) void MainWindow::openProject(const QString &project_name)

View File

@ -54,7 +54,7 @@ public:
explicit MainWindow(QWidget *parent = 0); explicit MainWindow(QWidget *parent = 0);
~MainWindow(); ~MainWindow();
void openFile(const QString &fn, int anal_level = -1); void openFile(const QString &fn, int anal_level = -1, QList<QString> advanced = QList<QString>());
void initUI(); void initUI();
void finalizeOpen(); void finalizeOpen();
@ -210,7 +210,7 @@ private:
RVA cursor_address; RVA cursor_address;
void openProject(const QString &project_name); void openProject(const QString &project_name);
void openNewFile(const QString &fn, int anal_level); void openNewFile(const QString &fn, int anal_level, QList<QString> advanced);
void toggleDockWidget(DockWidget *dock_widget); void toggleDockWidget(DockWidget *dock_widget);

View File

@ -17,7 +17,7 @@ OptionsDialog::OptionsDialog(MainWindow *main):
ui(new Ui::OptionsDialog), ui(new Ui::OptionsDialog),
analThread(this), analThread(this),
main(main), main(main),
defaultAnalLevel(3) defaultAnalLevel(1)
{ {
ui->setupUi(this); ui->setupUi(this);
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint)); setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
@ -41,6 +41,7 @@ OptionsDialog::OptionsDialog(MainWindow *main):
ui->spacyCheckBox->setChecked(settings.value("bbline").toBool()); ui->spacyCheckBox->setChecked(settings.value("bbline").toBool());
ui->hideFrame->setVisible(false); ui->hideFrame->setVisible(false);
ui->analoptionsFrame->setVisible(false);
// Add this so the dialog resizes when widgets are shown/hidden // Add this so the dialog resizes when widgets are shown/hidden
//this->layout()->setSizeConstraint(QLayout::SetFixedSize); //this->layout()->setSizeConstraint(QLayout::SetFixedSize);
@ -57,7 +58,7 @@ OptionsDialog::~OptionsDialog()
delete ui; delete ui;
} }
void OptionsDialog::setupAndStartAnalysis(int level) void OptionsDialog::setupAndStartAnalysis(int level, QList<QString> advanced)
{ {
ui->analSlider->setValue(level); ui->analSlider->setValue(level);
@ -143,7 +144,7 @@ void OptionsDialog::setupAndStartAnalysis(int level)
// Threads stuff // Threads stuff
// connect signal/slot // connect signal/slot
analThread.start(main->core, level); analThread.start(main->core, level, advanced);
} }
void OptionsDialog::on_closeButton_clicked() void OptionsDialog::on_closeButton_clicked()
@ -153,7 +154,44 @@ void OptionsDialog::on_closeButton_clicked()
void OptionsDialog::on_okButton_clicked() void OptionsDialog::on_okButton_clicked()
{ {
setupAndStartAnalysis(ui->analSlider->value()); QList<QString> advanced = QList<QString>();
if (ui->analSlider->value() == 3){
if (ui->aa_symbols->isChecked()){
advanced << "aa";
}
if (ui->aar_references->isChecked()){
advanced << "aar";
}
if (ui->aac_calls->isChecked()){
advanced << "aac";
}
if (ui->aan_rename->isChecked()){
advanced << "aan";
}
if (ui->aae_emulate->isChecked()){
advanced << "aae";
}
if (ui->aat_consecutive->isChecked()){
advanced << "aat";
}
if (ui->afta_typeargument->isChecked()){
advanced << "afta";
}
if (ui->aaT_aftertrap->isChecked()){
advanced << "aaT";
}
if (ui->aap_preludes->isChecked()){
advanced << "aap";
}
if (ui->jmptbl->isChecked()){
advanced << "e! anal.jmptbl";
}
if (ui->pushret->isChecked()){
advanced << "e! anal.pushret";
}
}
setupAndStartAnalysis(ui->analSlider->value(), advanced);
} }
void OptionsDialog::anal_finished() void OptionsDialog::anal_finished()
@ -192,15 +230,13 @@ QString OptionsDialog::analysisDescription(int level)
switch (level) switch (level)
{ {
case 0: case 0:
return tr("-"); return tr("No analysis");
case 1: case 1:
return tr("Minimum"); return tr("Auto-Analysis (aaa)");
case 2: case 2:
return tr("Basic"); return tr("Auto-Analysis Experimental (aaaa)");
case 3: case 3:
return tr("Medium"); return tr("Advanced");
case 4:
return tr("Full <font color='red'><b>(Experimental)</b></font>");
default: default:
return tr("Unknown"); return tr("Unknown");
} }
@ -218,6 +254,14 @@ void OptionsDialog::on_analSlider_valueChanged(int value)
{ {
ui->analCheckBox->setChecked(true); ui->analCheckBox->setChecked(true);
ui->analCheckBox->setText("Analysis: Enabled"); ui->analCheckBox->setText("Analysis: Enabled");
if (value==3)
{
ui->analoptionsFrame->setVisible(true);
}
else
{
ui->analoptionsFrame->setVisible(false);
}
} }
} }

View File

@ -24,7 +24,7 @@ public:
RAnalFunction functionAt(ut64 addr); RAnalFunction functionAt(ut64 addr);
QStringList asm_plugins; QStringList asm_plugins;
void setupAndStartAnalysis(int level); void setupAndStartAnalysis(int level, QList<QString> advanced);
private slots: private slots:
void on_closeButton_clicked(); void on_closeButton_clicked();

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>414</width> <width>576</width>
<height>657</height> <height>1167</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -188,10 +188,20 @@
<number>5</number> <number>5</number>
</property> </property>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_8"> <layout class="QVBoxLayout" name="verticalLayout_4">
<property name="spacing"> <property name="spacing">
<number>5</number> <number>5</number>
</property> </property>
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item> <item>
<widget class="QCheckBox" name="analCheckBox"> <widget class="QCheckBox" name="analCheckBox">
<property name="sizePolicy"> <property name="sizePolicy">
@ -214,13 +224,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item> <item>
<widget class="QLabel" name="analDescription"> <widget class="QLabel" name="analDescription">
<property name="sizePolicy"> <property name="sizePolicy">
@ -248,7 +251,7 @@
<number>0</number> <number>0</number>
</property> </property>
<property name="maximum"> <property name="maximum">
<number>4</number> <number>3</number>
</property> </property>
<property name="pageStep"> <property name="pageStep">
<number>1</number> <number>1</number>
@ -267,6 +270,132 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QFrame" name="analoptionsFrame">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item>
<widget class="QCheckBox" name="aa_symbols">
<property name="text">
<string>Analyze all symbols (aa)</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="aar_references">
<property name="text">
<string>Analyze for references (aar)</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="aac_calls">
<property name="text">
<string>Analyze function calls (aac)</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="aan_rename">
<property name="text">
<string>Autorename functions based on context (aan)</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Experimental:</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="aae_emulate">
<property name="text">
<string>Emulate code to find computed references (aae)</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="aat_consecutive">
<property name="text">
<string>Analyze for consecutive function (aat)</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="afta_typeargument">
<property name="text">
<string>Type and Argument matching analysis (afta)</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="aaT_aftertrap">
<property name="text">
<string>Analyze code after trap-sleds (aaT)</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="aap_preludes">
<property name="text">
<string>Analyze function preludes (aap)</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="jmptbl">
<property name="text">
<string>Analyze jump tables in switch statements (e! anal.jmptbl)</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="pushret">
<property name="text">
<string>Analyze push+ret as jmp (e! anal.pushret)</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout> </layout>
</item> </item>
<item> <item>
@ -289,6 +418,9 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255); <string notr="true">background-color: rgb(255, 255, 255);
color: rgb(0, 0, 0);</string> color: rgb(0, 0, 0);</string>

View File

@ -292,32 +292,28 @@ bool IaitoRCore::loadFile(QString path, uint64_t loadaddr, uint64_t mapaddr, boo
return true; return true;
} }
void IaitoRCore::analyze(int level) void IaitoRCore::analyze(int level, QList<QString> advanced)
{ {
CORE_LOCK(); CORE_LOCK();
/* /*
* Levels * Levels
* Nivel 1: afr @ entry0 y main (afr@entry0;afr@main) * Nivel 1: aaa
* Nivel 2: aa * Nivel 2: aaaa
* Nivel 3: aaa
* Nivel 4: aaaa
*/ */
if (level == 1) if (level == 1)
{ {
r_core_cmd0(core_, "afr@entry0;afr@main"); r_core_cmd0(core_, "aaa");
} }
else if (level == 2) else if (level == 2)
{ {
r_core_cmd0(core_, "aa"); r_core_cmd0(core_, "aaaa");
} }
else if (level == 3) else if (level == 3)
{ {
r_core_cmd0(core_, "aaa"); foreach(QString option, advanced){
} r_core_cmd0(core_, option.toStdString().c_str());
else if (level == 4) }
{
r_core_cmd0(core_, "aaaa");
} }
} }