mirror of
https://github.com/rizinorg/cutter.git
synced 2025-01-19 02:48:49 +00:00
* layout done for the shellcode paste function * paste shellcode functionality done * fixed a bunch of things for the comments * replaced the old qregexp with the latest one and some tweaks
This commit is contained in:
parent
eb06789958
commit
ae69dc07dd
@ -71,6 +71,11 @@ void AnalTask::runTask()
|
||||
return;
|
||||
}
|
||||
|
||||
if (!options.shellcode.isNull() && options.shellcode.size() / 2 > 0) {
|
||||
log(tr("Loading shellcode...\n"));
|
||||
Core()->cmd("wx " + options.shellcode);
|
||||
}
|
||||
|
||||
if (options.endian != InitialOptions::Endianness::Auto) {
|
||||
Core()->setEndianness(options.endian == InitialOptions::Endianness::Big);
|
||||
}
|
||||
|
@ -37,6 +37,8 @@ struct InitialOptions
|
||||
int bbsize = 0;
|
||||
|
||||
QList<QString> analCmd;
|
||||
|
||||
QString shellcode;
|
||||
};
|
||||
|
||||
class AnalTask : public AsyncTask
|
||||
|
@ -312,7 +312,7 @@ void MainWindow::addExtraWidget(QDockWidget *extraDock)
|
||||
restoreExtraDock.restoreWidth(extraDock->widget());
|
||||
}
|
||||
|
||||
void MainWindow::openNewFile(const QString &fn, int analLevel, QList<QString> advancedOptions)
|
||||
void MainWindow::openNewFile(const QString &fn, int analLevel, QList<QString> advancedOptions, const QString &shellcode)
|
||||
{
|
||||
setFilename(fn);
|
||||
|
||||
@ -330,7 +330,7 @@ void MainWindow::openNewFile(const QString &fn, int analLevel, QList<QString> ad
|
||||
}
|
||||
|
||||
/* Show analysis options dialog */
|
||||
displayAnalysisOptionsDialog(analLevel, advancedOptions, loadScript);
|
||||
displayAnalysisOptionsDialog(analLevel, advancedOptions, loadScript, shellcode);
|
||||
}
|
||||
|
||||
void MainWindow::openNewFileFailed()
|
||||
@ -361,11 +361,12 @@ void MainWindow::closeNewFileDialog()
|
||||
newFileDialog = nullptr;
|
||||
}
|
||||
|
||||
void MainWindow::displayAnalysisOptionsDialog(int analLevel, QList<QString> advancedOptions, const QString &script)
|
||||
void MainWindow::displayAnalysisOptionsDialog(int analLevel, QList<QString> advancedOptions, const QString &script, const QString &shellcode)
|
||||
{
|
||||
OptionsDialog *o = new OptionsDialog(this);
|
||||
o->setAttribute(Qt::WA_DeleteOnClose);
|
||||
o->setInitialScript(script);
|
||||
o->setShellcode(shellcode);
|
||||
o->show();
|
||||
|
||||
if (analLevel >= 0) {
|
||||
|
@ -68,10 +68,10 @@ public:
|
||||
~MainWindow();
|
||||
|
||||
void openNewFile(const QString &fn, int analLevel = -1,
|
||||
QList<QString> advancedOptions = QList<QString>());
|
||||
QList<QString> advancedOptions = QList<QString>(), const QString &shellcode = QString());
|
||||
void displayNewFileDialog();
|
||||
void closeNewFileDialog();
|
||||
void displayAnalysisOptionsDialog(int analLevel, QList<QString> advancedOptions, const QString &script);
|
||||
void displayAnalysisOptionsDialog(int analLevel, QList<QString> advancedOptions, const QString &script, const QString &shellcode = QString());
|
||||
void openProject(const QString &project_name);
|
||||
|
||||
void initUI();
|
||||
|
@ -127,6 +127,22 @@ void NewFileDialog::on_loadProjectButton_clicked()
|
||||
loadProject(item->data(Qt::UserRole).toString());
|
||||
}
|
||||
|
||||
void NewFileDialog::on_shellcodeButton_clicked()
|
||||
{
|
||||
QString shellcode = ui->shellcodeText->toPlainText();
|
||||
QString extractedCode = "";
|
||||
static const QRegularExpression rx("([0-9a-f]{2})", QRegularExpression::CaseInsensitiveOption);
|
||||
QRegularExpressionMatchIterator i = rx.globalMatch(shellcode);
|
||||
while (i.hasNext()) {
|
||||
QRegularExpressionMatch match = i.next();
|
||||
extractedCode.append(match.captured(1));
|
||||
}
|
||||
int size = extractedCode.size() / 2;
|
||||
if (size > 0) {
|
||||
loadShellcode(extractedCode, size);
|
||||
}
|
||||
}
|
||||
|
||||
void NewFileDialog::on_recentsListWidget_itemClicked(QListWidgetItem *item)
|
||||
{
|
||||
QVariant data = item->data(Qt::UserRole);
|
||||
@ -358,6 +374,14 @@ void NewFileDialog::loadProject(const QString &project)
|
||||
close();
|
||||
}
|
||||
|
||||
void NewFileDialog::loadShellcode(const QString &shellcode, const int size)
|
||||
{
|
||||
MainWindow *main = new MainWindow();
|
||||
QString ioFile = QString("malloc://%1").arg(size);
|
||||
main->openNewFile(ioFile, -1, QList<QString>(), shellcode);
|
||||
close();
|
||||
}
|
||||
|
||||
void NewFileDialog::on_tabWidget_currentChanged(int index)
|
||||
{
|
||||
Config()->setNewFileLastClicked(index);
|
||||
|
@ -23,6 +23,7 @@ private slots:
|
||||
|
||||
void on_selectProjectsDirButton_clicked();
|
||||
void on_loadProjectButton_clicked();
|
||||
void on_shellcodeButton_clicked();
|
||||
|
||||
void on_aboutButton_clicked();
|
||||
|
||||
@ -58,6 +59,7 @@ private:
|
||||
|
||||
void loadFile(const QString &filename);
|
||||
void loadProject(const QString &project);
|
||||
void loadShellcode(const QString &shellcode, const int size);
|
||||
|
||||
static const int MaxRecentFiles = 5;
|
||||
};
|
||||
|
@ -138,6 +138,7 @@
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
|
||||
<widget class="QWidget" name="filesTab">
|
||||
<attribute name="title">
|
||||
<string>Open File</string>
|
||||
@ -312,6 +313,66 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
||||
<widget class="QWidget" name="shellcodeTab">
|
||||
<attribute name="title">
|
||||
<string>Open Shellcode</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="shellcodeLayout">
|
||||
|
||||
<item>
|
||||
<widget class="QLabel" name="shellcodeLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><b>Paste Shellcode<b></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="shellcodeText">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>1</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="shellcodeLayout_1">
|
||||
<item>
|
||||
<spacer name="shellcodeSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="spacerSize" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="shellcodeButton">
|
||||
<property name="text">
|
||||
<string>Open</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
|
||||
</layout>
|
||||
</widget>>
|
||||
|
||||
<widget class="QWidget" name="projectsTab">
|
||||
<attribute name="title">
|
||||
<string>Projects</string>
|
||||
@ -456,6 +517,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -91,6 +91,11 @@ void OptionsDialog::setInitialScript(const QString &script)
|
||||
}
|
||||
}
|
||||
|
||||
void OptionsDialog::setShellcode(const QString &shellcode)
|
||||
{
|
||||
this->shellcode = shellcode;
|
||||
}
|
||||
|
||||
QString OptionsDialog::getSelectedArch()
|
||||
{
|
||||
QVariant archValue = ui->archComboBox->currentData();
|
||||
@ -199,6 +204,7 @@ void OptionsDialog::setupAndStartAnalysis(int level, QList<QString> advanced)
|
||||
InitialOptions options;
|
||||
|
||||
options.filename = main->getFilename();
|
||||
options.shellcode = this->shellcode;
|
||||
|
||||
// Where the bin header is located in the file (-B)
|
||||
if (ui->entry_loadOffset->text().length() > 0) {
|
||||
|
@ -47,11 +47,13 @@ private:
|
||||
int defaultAnalLevel;
|
||||
|
||||
QString analysisDescription(int level);
|
||||
QString shellcode;
|
||||
|
||||
void updateCPUComboBox();
|
||||
|
||||
public:
|
||||
void setInitialScript(const QString &script);
|
||||
void setShellcode(const QString &shellcode);
|
||||
|
||||
QString getSelectedArch();
|
||||
QString getSelectedCPU();
|
||||
|
@ -13,7 +13,7 @@
|
||||
<property name="windowTitle">
|
||||
<string>radare2 plugin information</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_1">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
|
Loading…
Reference in New Issue
Block a user