summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mobicore/mclf.c42
-rw-r--r--plugins/ropgadgets/finder.c31
2 files changed, 48 insertions, 25 deletions
diff --git a/plugins/mobicore/mclf.c b/plugins/mobicore/mclf.c
index edb6a4a..3cab4a6 100644
--- a/plugins/mobicore/mclf.c
+++ b/plugins/mobicore/mclf.c
@@ -54,7 +54,7 @@ static void g_mclf_format_finalize(GMCLFFormat *);
static const char *g_mclf_format_get_target_machine(const GMCLFFormat *);
/* Etend la définition des portions au sein d'un binaire. */
-static void g_mclf_format_refine_portions(const GMCLFFormat *, GPortionLayer *);
+static void g_mclf_format_refine_portions(GMCLFFormat *);
@@ -262,7 +262,6 @@ static const char *g_mclf_format_get_target_machine(const GMCLFFormat *format)
/******************************************************************************
* *
* Paramètres : format = informations chargées à consulter. *
-* main = couche de portions principale à raffiner. *
* *
* Description : Etend la définition des portions au sein d'un binaire. *
* *
@@ -272,59 +271,54 @@ static const char *g_mclf_format_get_target_machine(const GMCLFFormat *format)
* *
******************************************************************************/
-static void g_mclf_format_refine_portions(const GMCLFFormat *format, GPortionLayer *main)
+static void g_mclf_format_refine_portions(GMCLFFormat *format)
{
- GPortionLayer *layer; /* Couche à mettre en place */
+ GExeFormat *exe_format; /* Autre version du format */
+ vmpa2t addr; /* Emplacement dans le binaire */
GBinPortion *new; /* Nouvelle portion définie */
char desc[MAX_PORTION_DESC]; /* Description d'une portion */
phys_t length; /* Taille de portion globale */
- vmpa2t addr; /* Emplacement dans le binaire */
-
- layer = g_portion_layer_new(NO_LENGTH_YET, _("Segment"));
- g_portion_layer_attach_sub(main, layer);
+ exe_format = G_EXE_FORMAT(format);
/* Segment de code */
- new = g_binary_portion_new(BPC_CODE);
+ init_vmpa(&addr, 0, format->header.v1.text.start);
+
+ new = g_binary_portion_new(BPC_CODE, &addr, format->header.v1.text.len);
sprintf(desc, "%s \"%s\"", _("Segment"), "text");
g_binary_portion_set_desc(new, desc);
- init_vmpa(&addr, 0, format->header.v1.text.start);
- g_binary_portion_set_values(new, &addr, format->header.v1.text.len);
-
g_binary_portion_set_rights(new, PAC_WRITE | PAC_EXEC);
- g_portion_layer_include(layer, new);
+ g_exe_format_include_portion(exe_format, new);
/* Segment de données */
- new = g_binary_portion_new(BPC_DATA);
+ init_vmpa(&addr, format->header.v1.text.len, format->header.v1.data.start);
+
+ new = g_binary_portion_new(BPC_DATA, &addr, format->header.v1.data.len);
sprintf(desc, "%s \"%s\"", _("Segment"), "data");
g_binary_portion_set_desc(new, desc);
- init_vmpa(&addr, format->header.v1.text.len, format->header.v1.data.start);
- g_binary_portion_set_values(new, &addr, format->header.v1.data.len);
-
g_binary_portion_set_rights(new, PAC_READ | PAC_WRITE);
- g_portion_layer_include(layer, new);
+ g_exe_format_include_portion(exe_format, new);
/* Signature finale */
- new = g_binary_portion_new(BPC_DATA);
+ length = g_binary_content_compute_size(G_BIN_FORMAT(format)->content);
+ init_vmpa(&addr, length - 521, VMPA_NO_VIRTUAL); /* FIXME */
+
+ new = g_binary_portion_new(BPC_DATA, &addr, 521);
sprintf(desc, "%s \"%s\"", _("Segment"), "sig");
g_binary_portion_set_desc(new, desc);
- length = g_binary_content_compute_size(G_BIN_FORMAT(format)->content);
- init_vmpa(&addr, length - 521, VMPA_NO_VIRTUAL); /* FIXME */
- g_binary_portion_set_values(new, &addr, 521);
-
g_binary_portion_set_rights(new, PAC_READ | PAC_WRITE);
- g_portion_layer_include(layer, new);
+ g_exe_format_include_portion(exe_format, new);
}
diff --git a/plugins/ropgadgets/finder.c b/plugins/ropgadgets/finder.c
index 6a2283c..98871b5 100644
--- a/plugins/ropgadgets/finder.c
+++ b/plugins/ropgadgets/finder.c
@@ -323,6 +323,7 @@ found_rop_list *list_all_gadgets(GExeFormat *format, unsigned int max_depth, upd
found_rop_list *result; /* Liste de listes à renvoyer */
const char *target; /* Sous-traitance requise */
search_domain domain; /* Outils pour la recherche */
+ GBinPortion *portions; /* Couche première de portions */
GProcContext **contexts; /* Contextes pour recherches */
char **names; /* Désignations humaines liées */
size_t i; /* Boucle de parcours */
@@ -337,7 +338,35 @@ found_rop_list *list_all_gadgets(GExeFormat *format, unsigned int max_depth, upd
target = g_exe_format_get_target_machine(format);
domain.proc = get_arch_processor_for_type(target);
- domain.exe_ranges = g_exe_format_get_x_ranges(format, &domain.exe_count);
+ bool collect_x_ranges(GBinPortion *portion, GBinPortion *parent, BinaryPortionVisit visit, void *unused)
+ {
+ const mrange_t *range;
+
+ if (visit == BPV_SHOW)
+ {
+ if (g_binary_portion_get_rights(portion) & PAC_EXEC)
+ {
+ range = g_binary_portion_get_range(portion);
+
+ domain.exe_ranges = (mrange_t *)realloc(domain.exe_ranges, ++domain.exe_count * sizeof(mrange_t));
+ copy_mrange(&domain.exe_ranges[domain.exe_count - 1], range);
+
+ }
+
+ }
+
+ return true;
+
+ }
+
+ domain.exe_ranges = NULL;
+ domain.exe_count = 0;
+
+ portions = g_exe_format_get_portions(format);
+
+ g_binary_portion_visit(portions, (visit_portion_fc)collect_x_ranges, NULL);
+
+ g_object_unref(G_OBJECT(portions));
/* Récupération des différents contextes */