summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2015-05-11 00:58:05 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2015-05-11 00:58:05 (GMT)
commit46bcc7f122245f22772fd3e38d16e6afa7bd5881 (patch)
treed3c2ba1a9999e373428954f24d0e60c1ea63b756 /src
parent1bda6c517d30d873ff0d92a96380946ef944c9ae (diff)
Provided a way to look for ROP gadgets in binary code.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@533 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src')
-rw-r--r--src/analysis/disass/area.c2
-rw-r--r--src/arch/arm/v7/opdefs/pop_A88131.d4
-rw-r--r--src/arch/arm/v7/opdefs/pop_A88132.d4
-rw-r--r--src/arch/processor.h12
-rw-r--r--src/arch/vmpa.c26
-rw-r--r--src/arch/vmpa.h3
-rw-r--r--src/gui/menus/Makefile.am1
-rw-r--r--src/gui/menus/menubar.c7
-rw-r--r--src/gui/menus/plugins.c65
-rw-r--r--src/gui/menus/plugins.h38
-rw-r--r--src/plugins/pglist.c2
-rw-r--r--src/plugins/plugin-int.h2
-rw-r--r--src/plugins/plugin.c7
-rw-r--r--src/plugins/plugin.h2
14 files changed, 162 insertions, 13 deletions
diff --git a/src/analysis/disass/area.c b/src/analysis/disass/area.c
index 6ed6804..2e7b46d 100644
--- a/src/analysis/disass/area.c
+++ b/src/analysis/disass/area.c
@@ -490,7 +490,7 @@ bool load_code_from_mem_area(mem_area **list, size_t *count, size_t *index, cons
- mrange_t range; /* Couverture de l'instruction */
+ mrange_t range; /* Couverture de l'instruction */
vmpa2t sym_addr; /* Adresse de nouveau symbole */
diff --git a/src/arch/arm/v7/opdefs/pop_A88131.d b/src/arch/arm/v7/opdefs/pop_A88131.d
index ef5ab25..5229af9 100644
--- a/src/arch/arm/v7/opdefs/pop_A88131.d
+++ b/src/arch/arm/v7/opdefs/pop_A88131.d
@@ -39,7 +39,6 @@
//if BitCount(registers) < 1 then UNPREDICTABLE;
//if registers<15> == '1' && InITBlock() && !LastInITBlock() then UNPREDICTABLE;
- chk_call DefineAsReturn(1)
}
@@ -61,7 +60,6 @@
//if BitCount(registers) < 2 || (P == '1' && M == '1') then UNPREDICTABLE;
//if registers<15> == '1' && InITBlock() && !LastInITBlock() then UNPREDICTABLE;
- chk_call DefineAsReturn(1)
}
@@ -83,7 +81,7 @@
@rules {
//if t == 13 || (t == 15 && InITBlock() && !LastInITBlock()) then UNPREDICTABLE;
- chk_call DefineAsReturn(1)
+ if (Rt == '1111') ; chk_call DefineAsReturn(1)
}
diff --git a/src/arch/arm/v7/opdefs/pop_A88132.d b/src/arch/arm/v7/opdefs/pop_A88132.d
index 89c51c9..1762b45 100644
--- a/src/arch/arm/v7/opdefs/pop_A88132.d
+++ b/src/arch/arm/v7/opdefs/pop_A88132.d
@@ -40,7 +40,7 @@
//if BitCount(register_list) < 2 then SEE LDM / LDMIA / LDMFD;
//if registers<13> == '1' && ArchVersion() >= 7 then UNPREDICTABLE;
- chk_call DefineAsReturn(1)
+ if (register_list & 0x8000) ; chk_call DefineAsReturn(1)
}
@@ -63,7 +63,7 @@
@rules {
//if t == 13 then UNPREDICTABLE;
- chk_call DefineAsReturn(1)
+ if (Rt == '1111') ; chk_call DefineAsReturn(1)
}
diff --git a/src/arch/processor.h b/src/arch/processor.h
index d650266..a856942 100644
--- a/src/arch/processor.h
+++ b/src/arch/processor.h
@@ -74,7 +74,17 @@ MemoryDataSize g_arch_processor_get_instruction_size(const GArchProcessor *);
GArchInstruction *g_arch_processor_decode_instruction(const GArchProcessor *, GProcContext *, const bin_t *, off_t *, off_t, vmpa_t, GBinFormat *) __attribute__ ((deprecated));
/* Désassemble une instruction dans un flux de données. */
-GArchInstruction *g_arch_processor_disassemble(const GArchProcessor *, GProcContext *, const bin_t *, vmpa2t *, phys_t);
+GArchInstruction *g_arch_processor_disassemble(const GArchProcessor *, GProcContext *, const bin_t *, vmpa2t *, phys_t) __attribute__ ((deprecated));
+
+
+
+#define g_arch_processor_disassemble_nextgen(_proc, _ctx, _cnt, _pos) \
+ ({ \
+ const bin_t *_bin_data; \
+ off_t _bin_length; \
+ _bin_data = g_binary_content_get(_cnt, &_bin_length); \
+ g_arch_processor_disassemble(_proc, _ctx, _bin_data, _pos, _bin_length); \
+ })
diff --git a/src/arch/vmpa.c b/src/arch/vmpa.c
index ad4c078..b10b007 100644
--- a/src/arch/vmpa.c
+++ b/src/arch/vmpa.c
@@ -247,6 +247,32 @@ void advance_vmpa(vmpa2t *addr, phys_t qty)
/******************************************************************************
* *
+* Paramètres : addr = élément à modifier. *
+* qty = quantité d'unités de décallage. *
+* *
+* Description : Décalle une position d'une certaine quantité. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void deminish_vmpa(vmpa2t *addr, phys_t qty)
+{
+ /* On choisit de ne pas vérifier les débordements */
+
+ if (addr->physical != VMPA_NO_PHYSICAL)
+ addr->physical -= qty;
+
+ if (addr->virtual != VMPA_NO_VIRTUAL)
+ addr->virtual -= qty;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : a = première élément à venir consulter. *
* b = second élément à traiter en parallèle. *
* *
diff --git a/src/arch/vmpa.h b/src/arch/vmpa.h
index 3e0d35c..4611ebf 100644
--- a/src/arch/vmpa.h
+++ b/src/arch/vmpa.h
@@ -111,6 +111,9 @@ int cmp_vmpa(const vmpa2t *, const vmpa2t *);
/* Décalle une position d'une certaine quantité. */
void advance_vmpa(vmpa2t *, phys_t);
+/* Décalle une position d'une certaine quantité. */
+void deminish_vmpa(vmpa2t *, phys_t);
+
/* Calcule au mieux la distance entre deux coordonnées. */
phys_t compute_vmpa_diff(const vmpa2t *, const vmpa2t *);
diff --git a/src/gui/menus/Makefile.am b/src/gui/menus/Makefile.am
index fcebcf2..d932141 100644
--- a/src/gui/menus/Makefile.am
+++ b/src/gui/menus/Makefile.am
@@ -8,6 +8,7 @@ libguimenus_la_SOURCES = \
file.h file.c \
help.h help.c \
menubar.h menubar.c \
+ plugins.h plugins.c \
project.h project.c \
view.h view.c
diff --git a/src/gui/menus/menubar.c b/src/gui/menus/menubar.c
index cc69e0d..1fc1b6f 100644
--- a/src/gui/menus/menubar.c
+++ b/src/gui/menus/menubar.c
@@ -30,6 +30,7 @@
#include "edition.h"
#include "file.h"
#include "help.h"
+#include "plugins.h"
#include "project.h"
#include "view.h"
#include "../editem-int.h"
@@ -47,6 +48,7 @@ struct _GMenuBar
GtkWidget *project; /* Menu "Projet" */
GtkWidget *binary; /* Menu "Binaire" */
GtkWidget *debug; /* Menu "Débogage" */
+ GtkWidget *plugins; /* Menu "Greffons" */
GtkWidget *help; /* Menu "Aide" */
};
@@ -239,6 +241,11 @@ GEditorItem *g_menu_bar_new(GObject *ref, GtkAccelGroup *accgroup)
result->debug = build_menu_debug(ref, accgroup);
gtk_container_add(GTK_CONTAINER(item->widget), result->debug);
+ /* Greffons */
+
+ result->plugins = build_menu_plugins(ref, accgroup);
+ gtk_container_add(GTK_CONTAINER(item->widget), result->plugins);
+
/* Aide */
result->help = build_menu_help(ref, accgroup);
diff --git a/src/gui/menus/plugins.c b/src/gui/menus/plugins.c
new file mode 100644
index 0000000..6967665
--- /dev/null
+++ b/src/gui/menus/plugins.c
@@ -0,0 +1,65 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * plugins.c - gestion du menu 'Greffons'
+ *
+ * Copyright (C) 2015 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#include "plugins.h"
+
+
+#include <string.h>
+
+
+#include <i18n.h>
+
+
+#include "../../gtkext/easygtk.h"
+
+
+
+/******************************************************************************
+* *
+* Paramètres : ref = espace de référencement global. *
+* accgroup = groupe d'accélérateurs pour les menus. *
+* *
+* Description : Construit le menu "Aide". *
+* *
+* Retour : Panneau de menus mis en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GtkWidget *build_menu_plugins(GObject *ref, GtkAccelGroup *accgroup)
+{
+ GtkWidget *result; /* Support à retourner */
+ GtkWidget *menubar; /* Support pour éléments */
+
+ result = gtk_menu_item_new_with_mnemonic(_("_Plugins"));
+ gtk_widget_show(result);
+
+ menubar = gtk_menu_new();
+ g_object_set_data(ref, "menubar_plugins", G_OBJECT(menubar));
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(result), menubar);
+
+ return result;
+
+}
diff --git a/src/gui/menus/plugins.h b/src/gui/menus/plugins.h
new file mode 100644
index 0000000..9d83f4d
--- /dev/null
+++ b/src/gui/menus/plugins.h
@@ -0,0 +1,38 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * plugins.h - prototypes pour la gestion du menu 'Greffons'
+ *
+ * Copyright (C) 2015 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#ifndef _GUI_MENUS_PLUGINS_H
+#define _GUI_MENUS_PLUGINS_H
+
+
+#include <gtk/gtk.h>
+
+
+
+/* Construit le menu "Aide". */
+GtkWidget *build_menu_plugins(GObject *, GtkAccelGroup *);
+
+
+
+#endif /* _GUI_MENUS_PLUGINS_H */
diff --git a/src/plugins/pglist.c b/src/plugins/pglist.c
index 70fc66a..f85eee7 100644
--- a/src/plugins/pglist.c
+++ b/src/plugins/pglist.c
@@ -197,7 +197,7 @@ void browse_directory_for_plugins(plugins_list *list, const char *dir)
else
{
- plugin = g_plugin_module_new(filename);
+ plugin = g_plugin_module_new(filename, _list.ref);
if (plugin != NULL)
add_plugin_to_main_list(plugin);
diff --git a/src/plugins/plugin-int.h b/src/plugins/plugin-int.h
index 41cc535..1f4e17e 100644
--- a/src/plugins/plugin-int.h
+++ b/src/plugins/plugin-int.h
@@ -37,7 +37,7 @@
/* Prend acte du [dé]chargement du greffon. */
-typedef bool (* pg_management_fc) (GPluginModule *);
+typedef bool (* pg_management_fc) (GPluginModule *, GObject *);
/* Indique si le format peut être pris en charge ici. */
typedef bool (* pg_format_is_matching) (const GPluginModule *, GBinContent **);
diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c
index 89a8040..65f3cc6 100644
--- a/src/plugins/plugin.c
+++ b/src/plugins/plugin.c
@@ -113,7 +113,7 @@ static void g_plugin_module_init(GPluginModule *plugin)
static void g_plugin_module_dispose(GPluginModule *plugin)
{
if (plugin->exit != NULL)
- plugin->exit(plugin);
+ plugin->exit(plugin, NULL /* FIXME */);
if (plugin->module != NULL)
g_module_close(plugin->module);
@@ -147,6 +147,7 @@ static void g_plugin_module_finalize(GPluginModule *plugin)
/******************************************************************************
* *
* Paramètres : filename = nom du fichier à charger. *
+* ref = espace de référencement global. *
* *
* Description : Crée un module pour un greffon donné. *
* *
@@ -156,7 +157,7 @@ static void g_plugin_module_finalize(GPluginModule *plugin)
* *
******************************************************************************/
-GPluginModule *g_plugin_module_new(const gchar *filename)
+GPluginModule *g_plugin_module_new(const gchar *filename, GObject *ref)
{
GPluginModule *result; /* Structure à retourner */
plugin_abi_version_t current; /* Version de l'ABI actuelle */
@@ -304,7 +305,7 @@ GPluginModule *g_plugin_module_new(const gchar *filename)
if (result->init != NULL)
{
- if (!result->init(result))
+ if (!result->init(result, ref))
{
log_variadic_message(LMT_ERROR,
_("Plugin '%s' failed to load itself..."), filename);
diff --git a/src/plugins/plugin.h b/src/plugins/plugin.h
index d571659..b974ca8 100644
--- a/src/plugins/plugin.h
+++ b/src/plugins/plugin.h
@@ -53,7 +53,7 @@ typedef struct _GPluginModuleClass GPluginModuleClass;
GType g_plugin_module_get_type(void);
/* Crée un module pour un greffon donné. */
-GPluginModule *g_plugin_module_new(const gchar *);
+GPluginModule *g_plugin_module_new(const gchar *, GObject *);
/* Fournit la description du greffon dans son intégralité. */
const plugin_interface *g_plugin_module_get_interface(const GPluginModule *);