diff options
Diffstat (limited to 'plugins')
| -rw-r--r-- | plugins/Makefile.am | 2 | ||||
| -rw-r--r-- | plugins/dexresolver/Makefile.am | 16 | ||||
| -rw-r--r-- | plugins/dexresolver/context.c | 321 | ||||
| -rw-r--r-- | plugins/dexresolver/context.h | 57 | ||||
| -rw-r--r-- | plugins/dexresolver/operand.c | 306 | ||||
| -rw-r--r-- | plugins/dexresolver/operand.h | 70 | ||||
| -rw-r--r-- | plugins/dexresolver/plugin.c | 120 | ||||
| -rw-r--r-- | plugins/dexresolver/plugin.h | 49 | ||||
| -rw-r--r-- | plugins/pychrysa/analysis/Makefile.am | 3 | ||||
| -rw-r--r-- | plugins/pychrysa/analysis/exporter-int.h | 53 | ||||
| -rw-r--r-- | plugins/pychrysa/analysis/exporter.c | 284 | ||||
| -rw-r--r-- | plugins/pychrysa/analysis/exporter.h | 44 | ||||
| -rw-r--r-- | plugins/pychrysa/analysis/line.c | 793 | ||||
| -rw-r--r-- | plugins/pychrysa/analysis/line.h | 61 | ||||
| -rw-r--r-- | plugins/stackvars/operand.c | 5 | ||||
| -rw-r--r-- | plugins/stackvars/stackvars.c | 4 | ||||
| -rw-r--r-- | plugins/stackvars/stackvars.h | 4 | ||||
| -rw-r--r-- | plugins/theseus/Makefile.am | 14 | ||||
| -rw-r--r-- | plugins/theseus/theseus.c | 620 | ||||
| -rw-r--r-- | plugins/theseus/theseus.h | 49 | 
20 files changed, 5 insertions, 2870 deletions
| diff --git a/plugins/Makefile.am b/plugins/Makefile.am index be5740c..b789239 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -1,2 +1,2 @@ -SUBDIRS = dexresolver pychrysa python stackvars theseus +SUBDIRS = pychrysa python stackvars diff --git a/plugins/dexresolver/Makefile.am b/plugins/dexresolver/Makefile.am deleted file mode 100644 index f290a99..0000000 --- a/plugins/dexresolver/Makefile.am +++ /dev/null @@ -1,16 +0,0 @@ - -lib_LTLIBRARIES = libdexresolver.la - -libdexresolver_la_SOURCES =				\ -	context.h context.c					\ -	operand.h operand.c					\ -	plugin.h plugin.c - -libdexresolver_la_CFLAGS = $(AM_CFLAGS) - - -INCLUDES = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) -I../../src - -AM_CPPFLAGS =  - -AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) diff --git a/plugins/dexresolver/context.c b/plugins/dexresolver/context.c deleted file mode 100644 index b63ccf3..0000000 --- a/plugins/dexresolver/context.c +++ /dev/null @@ -1,321 +0,0 @@ - -/* OpenIDA - Outil d'analyse de fichiers binaires - * context.h - prototypes pour les instances d'actions du présent greffon - * - * Copyright (C) 2010 Cyrille Bagard - * - *  This file is part of OpenIDA. - * - *  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 "context.h" - - -#include <analysis/line_code.h> -#include <arch/dalvik/operand.h> -#include <glibext/delayed-int.h> -#include <plugins/context-int.h> - - -#include "operand.h" - - - -/* ---------------------------- REMPLACEMENT D'OPERANDES ---------------------------- */ - - -#define G_TYPE_DEX_RESOLVER_WORK               g_dex_resolver_work_get_type() -#define G_DEX_RESOLVER_WORK(obj)               (G_TYPE_CHECK_INSTANCE_CAST((obj), g_dex_resolver_work_get_type(), GDelayedDisassembly)) -#define G_IS_DEX_RESOLVER_WORK(obj)            (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_dex_resolver_work_get_type())) -#define G_DEX_RESOLVER_WORK_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_DEX_RESOLVER_WORK, GDelayedDisassemblyClass)) -#define G_IS_DEX_RESOLVER_WORK_CLASS(klass)    (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_DEX_RESOLVER_WORK)) -#define G_DEX_RESOLVER_WORK_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_DEX_RESOLVER_WORK, GDelayedDisassemblyClass)) - - -/* Instance du greffon pour OpenIDA (instance) */ -typedef struct _GDexResolverWork -{ -    GDelayedWork parent;                    /* A laisser en premier        */ - -    GLoadedBinary *binary;                  /* Destinataire final          */ - -} GDexResolverWork; - - -/* Instance du greffon pour OpenIDA (classe) */ -typedef struct _GDexResolverWorkClass -{ -    GDelayedWorkClass parent;               /* A laisser en premier        */ - -} GDexResolverWorkClass; - - -/* Indique le type défini pour les tâches de résolutions différées. */ -static GType g_dex_resolver_work_get_type(void); - -/* Initialise la classe des résolutions d'opérandes différées. */ -static void g_dex_resolver_work_class_init(GDexResolverWorkClass *); - -/* Initialise une tâche de résolution d'opérandes différée. */ -static void g_dex_resolver_work_init(GDexResolverWork *); - -/* Crée une tâche de résolution d'opérandes différée. */ -static GDexResolverWork *g_dex_resolver_work_new(GLoadedBinary *); - -/* Assure la résolution d'opérandes en différé. */ -static void g_dex_resolver_work_process(GDexResolverWork *, GtkExtStatusBar *); - - - -/* -------------------------- TACHE DIFFEREE DANS LE TEMPS -------------------------- */ -/* -------------------------- TACHE DIFFEREE DANS LE TEMPS -------------------------- */ - - - -/* Instance du greffon pour OpenIDA (instance) */ -struct _GDexResolverContext -{ -    GPluginContext parent;                  /* A laisser en premier        */ - -}; - - -/* Instance du greffon pour OpenIDA (classe) */ -struct _GDexResolverContextClass -{ -    GPluginContextClass parent;             /* A laisser en premier        */ - -}; - - - -/* Initialise la classe des instances de greffon. */ -static void g_dex_resolver_context_class_init(GDexResolverContextClass *); - -/* Initialise une instance d'instance de greffon. */ -static void g_dex_resolver_context_init(GDexResolverContext *); - - - - - - -/* ---------------------------------------------------------------------------------- */ -/*                              REMPLACEMENT D'OPERANDES                              */ -/* ---------------------------------------------------------------------------------- */ - - -/* Indique le type défini pour les tâches de résolutions différées. */ -G_DEFINE_TYPE(GDexResolverWork, g_dex_resolver_work, G_TYPE_DELAYED_WORK); - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : klass = classe à initialiser.                                * -*                                                                             * -*  Description : Initialise la classe des résolutions d'opérandes différées.  * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_dex_resolver_work_class_init(GDexResolverWorkClass *klass) -{ - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : disass = instance à initialiser.                             * -*                                                                             * -*  Description : Initialise une tâche de résolution d'opérandes différée.     * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_dex_resolver_work_init(GDexResolverWork *disass) -{ -    G_DELAYED_WORK(disass)->run = (run_task_fc)g_dex_resolver_work_process; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : binary = binaire chargé en attente des résultats.            * -*                                                                             * -*  Description : Crée une tâche de résolution d'opérandes différée.           * -*                                                                             * -*  Retour      : Tâche créée.                                                 * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static GDexResolverWork *g_dex_resolver_work_new(GLoadedBinary *binary) -{ -    GDexResolverWork *result;               /* Tâche à retourner           */ - -    result = g_object_new(G_TYPE_DEX_RESOLVER_WORK, NULL); - -    result->binary = binary; - -    return result; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : work      = analyse à mener.                                 * -*                statusbar = barre de statut à tenir informée.                * -*                                                                             * -*  Description : Assure la résolution d'opérandes en différé.                 * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_dex_resolver_work_process(GDexResolverWork *work, GtkExtStatusBar *statusbar) -{ -    GDexFormat *format;                     /* Format du binaire utilisé   */ -    GRenderingLine *lines;                  /* Lignes désassemblées        */ -    GRenderingLine *iter;                   /* Boucle de parcours          */ -    GArchInstruction *instr;                /* Instruction à ausculter     */ -    size_t count;                           /* Quantité d'opérandes        */ -    size_t i;                               /* Boucle de parcours          */ -    const GArchOperand *op;                 /* Opérande à analyser         */ -    GArchOperand *new;                      /* Nouvel opérande à afficher  */ - -    format = G_DEX_FORMAT(g_loaded_binary_get_format(work->binary)); - -    lines = g_loaded_binary_get_lines(work->binary); - -    for (iter = lines; -         iter != NULL; -         iter = g_rendering_line_get_next_iter(lines, iter, NULL)) -    { -        /* On ne traite que du code ici ! */ -        if (!G_IS_CODE_LINE(iter)) continue; - -        instr = g_code_line_get_instruction(G_CODE_LINE(iter)); -        count = g_arch_instruction_count_operands(instr); - -        /* FIXME : l'opérande recherchée est à position fixe ! */ -        for (i = 0; i < count; i++) -        { -            op = g_arch_instruction_get_operand(instr, i); - -            if (G_IS_DALVIK_POOL_OPERAND(op)) -            { -                new = g_dalvik_hpool_operand_new(format, G_DALVIK_POOL_OPERAND(op)); - -                if (new != NULL) -                    g_arch_instruction_replace_operand(instr, new, op); - -            } - -        } - -    } - -} - - - -/* ---------------------------------------------------------------------------------- */ -/*                              REMPLACEMENT D'OPERANDES                              */ -/*                              REMPLACEMENT D'OPERANDES                              */ -/* ---------------------------------------------------------------------------------- */ - - -/* Indique le type défini pour une instance de greffon. */ -G_DEFINE_TYPE(GDexResolverContext, g_dex_resolver_context, G_TYPE_PLUGIN_CONTEXT); - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : klass = classe à initialiser.                                * -*                                                                             * -*  Description : Initialise la classe des instances de greffon.               * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_dex_resolver_context_class_init(GDexResolverContextClass *klass) -{ - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : context = instance à initialiser.                            * -*                                                                             * -*  Description : Initialise une instance d'instance de greffon.               * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_dex_resolver_context_init(GDexResolverContext *context) -{ - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : binary = contenu binaire chargé à traiter.                   * -*                                                                             * -*  Description : Lance l'exécution d'une action du greffon.                   * -*                                                                             * -*  Retour      : Instance d'exécution du greffon.                             * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -GPluginContext *g_dex_resolver_context_new(GLoadedBinary *binary) -{ -    GPluginContext *result;                 /* Bilan d'exécution à renvoyer*/ -    GDexResolverWork *work;                 /* Tâche de parcours de lignes */ - -    result = g_object_new(G_TYPE_DEX_RESOLVER_CONTEXT, NULL); - -    work = g_dex_resolver_work_new(binary); - -    g_signal_connect(work, "work-completed", G_CALLBACK(g_object_unref), NULL); - -    g_work_queue_schedule_work(get_work_queue(), G_DELAYED_WORK(work)); - -    return result; - -} diff --git a/plugins/dexresolver/context.h b/plugins/dexresolver/context.h deleted file mode 100644 index bcc4f19..0000000 --- a/plugins/dexresolver/context.h +++ /dev/null @@ -1,57 +0,0 @@ - -/* OpenIDA - Outil d'analyse de fichiers binaires - * context.h - prototypes pour les instances d'actions du présent greffon - * - * Copyright (C) 2010 Cyrille Bagard - * - *  This file is part of OpenIDA. - * - *  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 _PLUGINS_DEXRESOLVER_CONTEXT_H -#define _PLUGINS_DEXRESOLVER_CONTEXT_H - - -#include <analysis/binary.h> -#include <plugins/context.h> - - - -/* Instance du greffon pour OpenIDA (instance) */ -typedef struct _GDexResolverContext GDexResolverContext; - -/* Instance du greffon pour OpenIDA (classe) */ -typedef struct _GDexResolverContextClass GDexResolverContextClass; - - -#define G_TYPE_DEX_RESOLVER_CONTEXT                (g_dex_resolver_context_get_type()) -#define G_DEX_RESOLVER_CONTEXT(obj)                (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_DEX_RESOLVER_CONTEXT, GDexResolverContext)) -#define G_IS_DEX_RESOLVER_CONTEXT(obj)             (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_DEX_RESOLVER_CONTEXT)) -#define G_DEX_RESOLVER_CONTEXT_CLASS(klass)        (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_DEX_RESOLVER_CONTEXT, GDexResolverContextClass)) -#define G_IS_DEX_RESOLVER_CONTEXT_CLASS(klass)     (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_DEX_RESOLVER_CONTEXT)) -#define G_DEX_RESOLVER_CONTEXT_GET_CLASS(obj)      (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_DEX_RESOLVER_CONTEXT, GDexResolverContextClass)) - - -/* Indique le type défini pour une instance de greffon. */ -GType g_dex_resolver_context_get_type(void); - -/* Lance l'exécution d'une action du greffon. */ -GPluginContext *g_dex_resolver_context_new(GLoadedBinary *); - - - -#endif  /* _PLUGINS_DEXRESOLVER_CONTEXT_H */ diff --git a/plugins/dexresolver/operand.c b/plugins/dexresolver/operand.c deleted file mode 100644 index 7293599..0000000 --- a/plugins/dexresolver/operand.c +++ /dev/null @@ -1,306 +0,0 @@ - -/* OpenIDA - Outil d'analyse de fichiers binaires - * operand.c - remplacement d'opérandes par d'autres plus explicites - * - * Copyright (C) 2010 Cyrille Bagard - * - *  This file is part of OpenIDA. - * - *  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 Foobar.  If not, see <http://www.gnu.org/licenses/>. - */ - - -#include "operand.h" - - -#include <string.h> - - -#include <arch/operand-int.h> -#include <format/dex/pool.h> - - - -/* ----------------- OPERANDES POINTANT VERS LA TABLE DE CONSTANTES ----------------- */ - - -/* Définition d'un opérande visant un élément de table de constantes Dalvik (instance) */ -struct _GDalvikHPoolOperand -{ -    GArchOperand parent;                    /* Instance parente            */ - -    const GDexFormat *format;               /* Format de binaire utilisé   */ -    const GDalvikPoolOperand *child;        /* Opérande encapsulé          */ - -    union -    { -        GBinVariable *field;                /* Champ à représenter         */ -        GBinRoutine *method;                /* Méthode à représenter       */ - -    } cache; - -}; - - -/* Définition d'un opérande visant un élément de table de constantes Dalvik (classe) */ -struct _GDalvikHPoolOperandClass -{ -    GArchOperandClass parent;               /* Classe parente              */ - -}; - - -/* Initialise la classe des opérandes de constante Dalvik. */ -static void g_dalvik_hpool_operand_class_init(GDalvikHPoolOperandClass *); - -/* Initialise une instance d'opérande de constante Dalvik. */ -static void g_dalvik_hpool_operand_init(GDalvikHPoolOperand *); - -/* Ajoute du texte simple à un fichier ouvert en écriture. */ -static void g_dalvik_hpool_operand_add_text(const GDalvikHPoolOperand *, GRenderingOptions *, MainRendering, FILE *); - -/* Ajoute à un tampon GLib le contenu de l'instance spécifiée. */ -static void g_dalvik_hpool_operand_to_buffer(/*const */GDalvikHPoolOperand *, GBufferLine *, GRenderingOptions *); - - - - - - - - - - - -/* ---------------------------------------------------------------------------------- */ -/*                   OPERANDES POINTANT VERS LA TABLE DE CONSTANTES                   */ -/* ---------------------------------------------------------------------------------- */ - - -/* Indique le type défini par la GLib pour un un élément de table de constantes Dalvik. */ -G_DEFINE_TYPE(GDalvikHPoolOperand, g_dalvik_hpool_operand, G_TYPE_ARCH_OPERAND); - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : klass = classe à initialiser.                                * -*                                                                             * -*  Description : Initialise la classe des opérandes de constante Dalvik.      * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_dalvik_hpool_operand_class_init(GDalvikHPoolOperandClass *klass) -{ - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : operand = instance à initialiser.                            * -*                                                                             * -*  Description : Initialise une instance d'opérande de constante Dalvik.      * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_dalvik_hpool_operand_init(GDalvikHPoolOperand *operand) -{ -    GContentExporter *parent;               /* Instance parente            */ - -    parent = G_CONTENT_EXPORTER(operand); - -    parent->add_text = (add_text_fc)g_dalvik_hpool_operand_add_text; -    parent->export_buffer = (export_buffer_fc)g_dalvik_hpool_operand_to_buffer; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : format = représentation interne du format DEX à consulter.   * -*                child  = instance existante à encapsuler.                    * -*                                                                             * -*  Description : Crée un opérande explicitant l'usage d'un élément constant.  * -*                                                                             * -*  Retour      : Opérande mis en place ou NULL si soucis.                     * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -GArchOperand *g_dalvik_hpool_operand_new(const GDexFormat *format, const GDalvikPoolOperand *child) -{ -    GDalvikHPoolOperand *result;            /* Structure à retourner       */ - -    if (g_dalvik_pool_operand_get_pool_type(child) == DPT_NONE) -        return NULL; - -    result = g_object_new(G_TYPE_DALVIK_HPOOL_OPERAND, NULL); - -    result->format = format; -    result->child = child; - -    return G_ARCH_OPERAND(result); - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : operand   = opérande à transcrire.                           * -*                options   = options de rendu.                                * -*                rendering = support effectif final des lignes de code.       * -*                stream    = flux ouvert en écriture.                         * -*                                                                             * -*  Description : Ajoute du texte simple à un fichier ouvert en écriture.      * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_dalvik_hpool_operand_add_text(const GDalvikHPoolOperand *operand, GRenderingOptions *options, MainRendering rendering, FILE *stream) -{ -    //g_content_exporter_add_text(G_CONTENT_EXPORTER(operand->reg), options, rendering, stream); - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : operand = opérande à transcrire.                             * -*                buffer  = espace où placer ledit contenu.                    * -*                options = options de rendu.                                  * -*                                                                             * -*  Description : Ajoute à un tampon GLib le contenu de l'instance spécifiée.  * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_dalvik_hpool_operand_to_buffer(/*const */GDalvikHPoolOperand *operand, GBufferLine *buffer, GRenderingOptions *options) -{ -    GContentExporter *exporter;             /* Autre vision de l'opérande  */ -    uint32_t index;                         /* Indice de l'élément visé    */ -    const char *string;                     /* Chaîne à afficher           */ -    GDataType *type;                        /* Type quelconque             */ -    char *tmp;                              /* Chaîne à afficher & libérer */ - -    exporter = G_CONTENT_EXPORTER(operand); - -    index = g_dalvik_pool_operand_get_index(operand->child); - -    switch (g_dalvik_pool_operand_get_pool_type(operand->child)) -    { -        case DPT_STRING: - -            string = get_string_from_dex_pool(operand->format, index); - -            if (string == NULL) -                g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY, -                                                      "<bad_string_index>", 18, RTT_STRING); -            else -            { -                g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY, -                                                      "\"", 1, RTT_STRING); - -                g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY, -                                                      string, strlen(string), RTT_STRING); - -                g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY, -                                                      "\"", 1, RTT_STRING); - -            } - -            break; - -        case DPT_FIELD: - -            if (operand->cache.field == NULL) -                operand->cache.field = get_field_from_dex_pool(operand->format, index); - -            if (operand->cache.field == NULL) -                g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY, -                                                      "<bad_field_index>", 17, RTT_VAR_NAME); - -            else -            { -                type = g_binary_variable_get_vtype(operand->cache.field); -                tmp = g_data_type_to_string(type); - -                g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY, -                                                      tmp, strlen(tmp), RTT_VAR_NAME); - -                free(tmp); - -                g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY, -                                                      "->", 2, RTT_LTGT); - -                string = g_binary_variable_get_name(operand->cache.field); - -                g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY, -                                                      string, strlen(string), RTT_VAR_NAME); - -            } - -            break; - -        case DPT_METHOD: - -            if (operand->cache.method == NULL) -                operand->cache.method = get_routine_from_dex_pool(operand->format, index); - -            if (operand->cache.method == NULL) -                g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY, -                                                      "<bad_method_index>", 18, RTT_VAR_NAME); - -            else -            { -                tmp = g_binary_routine_to_string(operand->cache.method); - -                g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY, -                                                      tmp, strlen(tmp), RTT_VAR_NAME); - -                free(tmp); - -            } - -            break; - -        default: -            g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY, -                                                  "<-?->", 5, RTT_SECTION); -            break; - -    } - - - - -} - - - - diff --git a/plugins/dexresolver/operand.h b/plugins/dexresolver/operand.h deleted file mode 100644 index f5e9ef9..0000000 --- a/plugins/dexresolver/operand.h +++ /dev/null @@ -1,70 +0,0 @@ - -/* OpenIDA - Outil d'analyse de fichiers binaires - * operand.h - prototypes pour le remplacement d'opérandes par d'autres plus explicites - * - * Copyright (C) 2010 Cyrille Bagard - * - *  This file is part of OpenIDA. - * - *  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 Foobar.  If not, see <http://www.gnu.org/licenses/>. - */ - - -#ifndef _PLUGINS_DEXRESOLVER_OPERAND_H -#define _PLUGINS_DEXRESOLVER_OPERAND_H - - -#include <glib-object.h> - - -#include <arch/dalvik/operand.h> -#include <format/dex/dex.h> - - - -/* ----------------- OPERANDES POINTANT VERS LA TABLE DE CONSTANTES ----------------- */ - - - -#define G_TYPE_DALVIK_HPOOL_OPERAND                  g_dalvik_hpool_operand_get_type() -#define G_DALVIK_HPOOL_OPERAND(obj)                  (G_TYPE_CHECK_INSTANCE_CAST((obj), g_dalvik_hpool_operand_get_type(), GDalvikHpoolOperand)) -#define G_IS_DALVIK_HPOOL_OPERAND(obj)               (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_dalvik_hpool_operand_get_type())) -#define G_DALVIK_HPOOL_OPERAND_GET_IFACE(inst)       (G_TYPE_INSTANCE_GET_INTERFACE((inst), g_dalvik_hpool_operand_get_type(), GDalvikHpoolOperandIface)) - - -/* Définition d'un opérande visant un élément de table de constantes Dalvik (instance) */ -typedef struct _GDalvikHPoolOperand GDalvikHPoolOperand; - -/* Définition d'un opérande visant un élément de table de constantes Dalvik (classe) */ -typedef struct _GDalvikHPoolOperandClass GDalvikHPoolOperandClass; - - -/* Indique le type défini par la GLib pour un un élément de table de constantes Dalvik. */ -GType g_dalvik_hpool_operand_get_type(void); - -/* Crée un opérande explicitant l'usage d'un élément constant. */ -GArchOperand *g_dalvik_hpool_operand_new(const GDexFormat *, const GDalvikPoolOperand *); - - - - - - - - - - - - -#endif  /* _PLUGINS_DEXRESOLVER_OPERAND_H */ diff --git a/plugins/dexresolver/plugin.c b/plugins/dexresolver/plugin.c deleted file mode 100644 index 7a2fe77..0000000 --- a/plugins/dexresolver/plugin.c +++ /dev/null @@ -1,120 +0,0 @@ - -/* OpenIDA - Outil d'analyse de fichiers binaires - * plugin.c - résolution des références avec le format DEX - * - * Copyright (C) 2010 Cyrille Bagard - * - *  This file is part of OpenIDA. - * - *  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 Foobar.  If not, see <http://www.gnu.org/licenses/>. - */ - - -#include "plugin.h" - - -#include "context.h" - - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : ref = espace de référencement global.                        * -*                                                                             * -*  Description : Initialise le greffon pour les bornes de routine.            * -*                                                                             * -*  Retour      : true.                                                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -G_MODULE_EXPORT bool init_plugin(GObject *ref) -{ -    return true; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Fournit une indication sur le(s) type(s) du greffon présent. * -*                                                                             * -*  Retour      : Description d'un greffon.                                    * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -G_MODULE_EXPORT PluginType get_plugin_type(void) -{ -    return PGT_BINARY; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Fournit une indication sur le type d'opération(s) menée(s).  * -*                                                                             * -*  Retour      : Description d'une action.                                    * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -G_MODULE_EXPORT PluginAction get_plugin_action(void) -{ -    return PGA_CODE_PROCESS; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : binary = représentation binaire à traiter.                   * -*                action = action attendue.                                    * -*                                                                             * -*  Description : Exécute une action définie sur un binaire chargé.            * -*                                                                             * -*  Retour      : true si une action a été menée, false sinon.                 * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -G_MODULE_EXPORT bool execute_action_on_binary(GLoadedBinary *binary, PluginAction action) -{ -    bool result;                            /* Bilan à retourner           */ - - - - -    GPluginContext *context; - - -    context = g_dex_resolver_context_new(binary); - -    printf("Run it !!!\n"); - -    result = true; - - -    return result; - -} diff --git a/plugins/dexresolver/plugin.h b/plugins/dexresolver/plugin.h deleted file mode 100644 index c5a1a97..0000000 --- a/plugins/dexresolver/plugin.h +++ /dev/null @@ -1,49 +0,0 @@ - -/* OpenIDA - Outil d'analyse de fichiers binaires - * plugin.h - prototypes pour la résolution des références avec le format DEX - * - * Copyright (C) 2010 Cyrille Bagard - * - *  This file is part of OpenIDA. - * - *  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 Foobar.  If not, see <http://www.gnu.org/licenses/>. - */ - - -#ifndef _PLUGINS_DEXRESOLVER_PLUGIN_H -#define _PLUGINS_DEXRESOLVER_PLUGIN_H - - -#include <gmodule.h> - - -#include <plugins/plugin-def.h> - - - -/* Initialise le greffon pour les bornes de routine. */ -G_MODULE_EXPORT bool init_plugin(GObject *); - -/* Fournit une indication sur le(s) type(s) du greffon présent. */ -G_MODULE_EXPORT PluginType get_plugin_type(void); - -/* Fournit une indication sur le type d'opération(s) menée(s). */ -G_MODULE_EXPORT PluginAction get_plugin_action(void); - -/* Exécute une action définie sur un binaire chargé. */ -G_MODULE_EXPORT bool execute_action_on_binary(GLoadedBinary *, PluginAction); - - - -#endif  /* _PLUGINS_DEXRESOLVER_PLUGIN_H */ diff --git a/plugins/pychrysa/analysis/Makefile.am b/plugins/pychrysa/analysis/Makefile.am index 123279b..f5322e8 100644 --- a/plugins/pychrysa/analysis/Makefile.am +++ b/plugins/pychrysa/analysis/Makefile.am @@ -3,9 +3,6 @@ noinst_LTLIBRARIES = libpychrysaanalysis.la  libpychrysaanalysis_la_SOURCES =		\  	binary.h binary.c					\ -	exporter-int.h						\ -	exporter.h exporter.c				\ -	line.h line.c						\  	module.h module.c					\  	roptions.h roptions.c diff --git a/plugins/pychrysa/analysis/exporter-int.h b/plugins/pychrysa/analysis/exporter-int.h deleted file mode 100644 index 2498d4b..0000000 --- a/plugins/pychrysa/analysis/exporter-int.h +++ /dev/null @@ -1,53 +0,0 @@ - -/* OpenIDA - Outil d'analyse de fichiers binaires - * exporter-int.h - prototypes internes pour l'équivalent Python du fichier "analysis/exporter.h" - * - * Copyright (C) 2010 Cyrille Bagard - * - *  This file is part of OpenIDA. - * - *  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 _PLUGINS_PYOIDA_ANALYSIS_EXPORTER_INT_H -#define _PLUGINS_PYOIDA_ANALYSIS_EXPORTER_INT_H - - -#include <Python.h> - -#include <analysis/exporter.h> - - - -/* Classe 'analysis.exporter' pour Python */ -typedef struct _py_exporter -{ -    PyObject_HEAD - -    GContentExporter *glib;                 /* Interface version GLib      */ - -} py_exporter; - - -#define PY_EXPORTER(exp) ((py_exporter *)exp) - - -/* Fournit le type d'objet 'analysis.exporter' pour Python. */ -PyTypeObject *get_analysis_exporter_type(void); - - - -#endif  /* _PLUGINS_PYOIDA_ANALYSIS_EXPORTER_INT_H */ diff --git a/plugins/pychrysa/analysis/exporter.c b/plugins/pychrysa/analysis/exporter.c deleted file mode 100644 index 8c49542..0000000 --- a/plugins/pychrysa/analysis/exporter.c +++ /dev/null @@ -1,284 +0,0 @@ - -/* OpenIDA - Outil d'analyse de fichiers binaires - * exporter.c - équivalent Python du fichier "analysis/exporter.h" - * - * Copyright (C) 2010 Cyrille Bagard - * - *  This file is part of OpenIDA. - * - *  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 "exporter.h" - - -#include <fcntl.h> -#include <stdio.h> -#include <unistd.h> - - -#include "exporter-int.h" -#include "../analysis/roptions.h" - - - - -#define PY_EXPORT_TEXT_BUFLEN   64 - - -/* Crée un nouvel objet Python de type 'py_exporter'. */ -static PyObject *py_exporter_new(PyTypeObject *, PyObject *, PyObject *); - - - - -/* Fournit le texte correspondant à un contenu rendu. */ -static PyObject *py_exporter_get_text(py_exporter *, PyObject *); - - - - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : type = type de l'objet à instancier.                         * -*                args = arguments fournis à l'appel.                          * -*                kwds = arguments de type key=val fournis.                    * -*                                                                             * -*  Description : Crée un nouvel objet Python de type 'py_exporter'.           * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static PyObject *py_exporter_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ -    py_exporter *result;                    /* Instance à retourner        */ - -    result = (py_exporter *)type->tp_alloc(type, 0); - -    return (PyObject *)result; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : exporter = objet GLib existant à transposer.                 * -*                                                                             * -*  Description : Crée un nouvel objet Python de type 'py_exporter'.           * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -PyObject *py_exporter_new_from_existing(GContentExporter *exporter) -{ -    py_exporter *result;                    /* Instance à retourner        */ -    PyTypeObject *type;                     /* Type Python à instancier    */ - -    result = (py_exporter *)g_object_get_data(G_OBJECT(exporter), "python_object"); - -    if (result == NULL) -    { -        type = get_analysis_exporter_type(); - -        result = (py_exporter *)type->tp_alloc(type, 0); - -        result->glib = exporter; -        g_object_ref(exporter); - -        g_object_set_data(G_OBJECT(exporter), "python_object", result); - -    } -    else Py_INCREF((PyObject *)result); - -    return (PyObject *)result; - -} - - - - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : self = instance manipulée à traiter.                         * -*                args = arguments fournis à l'appel.                          * -*                                                                             * -*  Description : Fournit le texte correspondant à un contenu rendu.           * -*                                                                             * -*  Retour      : Chaîne de caractères Python.                                 * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static PyObject *py_exporter_get_text(py_exporter *self, PyObject *args) -{ -    PyObject *result;                       /* Liste à retourner           */ -    PyObject *roptions;                     /* Options de rendu jointes    */ -    int ret;                                /* Bilan de lecture des args.  */ -    GRenderingOptions *_roptions;           /* Version GLib des options    */ -    int fd[2];                              /* Tube pour récupérer le code */ -    FILE *stream;                           /* Flux (ré)ouvert en écriture */ -    char buffer[PY_EXPORT_TEXT_BUFLEN];     /* Tampon pour la lecture      */ -    ssize_t len;                            /* Nombre de caractères lus    */ -    PyObject *src;                          /* Source ajoutée au résultat  */ - -    ret = PyArg_ParseTuple(args, "O", &roptions); -    if (!ret) return Py_None; - -    _roptions = py_rendering_options_get_glib_instance(roptions); - -    result = Py_None; - -    ret = pipe2(fd, O_NONBLOCK); -    //if (ret ... perror("pipe"); goto pegt_pipe_error; - - -    stream = fdopen(fd[1], "w"); -    if (stream == NULL) -    { -        perror("stream"); -        goto pegt_stream_error; -    } - -    g_content_exporter_add_text(self->glib, _roptions, MRD_BLOCK/* FIXME*/, stream); -    fflush(stream); - -    do -    { -        memset(buffer, 0, PY_EXPORT_TEXT_BUFLEN); -        len = read(fd[0], buffer, PY_EXPORT_TEXT_BUFLEN); - -        src = PyString_FromString(buffer); - -        if (result == Py_None) result = src; -        else PyString_ConcatAndDel(&result, src); - -    } -    while (len > 0); - -    fclose(stream); - - pegt_stream_error: - -    close(fd[0]); -    //close(fd[1]); - - pegt_pipe_error: - -    return result; - -} - - - - - - - - - - - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Fournit le type d'objet 'analysis.exporter' pour Python.     * -*                                                                             * -*  Retour      : Adresse du type vivant à manipuler.                          * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -PyTypeObject *get_analysis_exporter_type(void) -{ -    static PyTypeObject *result = NULL;     /* Type pour objet à retourner */ - -    static PyMethodDef py_exporter_methods[] = { -        { -            "get_text", (PyCFunction)py_exporter_get_text, -            METH_VARARGS, -            "Provide the text version of the rendered content." -        }, -        { NULL } -    }; - -    static PyGetSetDef py_exporter_getset[] = { -        { NULL } -    }; - -    static PyTypeObject py_exporter_type = { - -        PyObject_HEAD_INIT(NULL) - -        .tp_name        = "pyoida.analysis.Exporter", -        .tp_basicsize   = sizeof(py_exporter), - -        .tp_flags       = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - -        .tp_doc         = "PyOIDA exporter interface", - -        .tp_methods     = py_exporter_methods, -        .tp_getset      = py_exporter_getset, -        .tp_new         = (newfunc)py_exporter_new - -    }; - -    if (result == NULL) result = &py_exporter_type; - -    return result; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : module = module dont la définition est à compléter.          * -*                                                                             * -*  Description : Ajoute l'objet 'analysis.exporter' au module Python.         * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -bool add_analysis_exporter_to_python_module(PyObject *module) -{ -    PyTypeObject *py_exporter_type;         /* Type défini pour Python     */ -    int ret;                                /* Bilan d'un appel            */ - -    py_exporter_type = get_analysis_exporter_type(); - -    if (PyType_Ready(py_exporter_type) < 0) -        return false; - -    Py_INCREF(py_exporter_type); -    ret = PyModule_AddObject(module, "Exporter", (PyObject *)py_exporter_type); - -    return (ret == 0); - -} diff --git a/plugins/pychrysa/analysis/exporter.h b/plugins/pychrysa/analysis/exporter.h deleted file mode 100644 index 4668934..0000000 --- a/plugins/pychrysa/analysis/exporter.h +++ /dev/null @@ -1,44 +0,0 @@ - -/* OpenIDA - Outil d'analyse de fichiers binaires - * exporter.h - prototypes pour l'équivalent Python du fichier "analysis/exporter.h" - * - * Copyright (C) 2010 Cyrille Bagard - * - *  This file is part of OpenIDA. - * - *  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 _PLUGINS_PYOIDA_ANALYSIS_EXPORTER_H -#define _PLUGINS_PYOIDA_ANALYSIS_EXPORTER_H - - -#include <Python.h> -#include <stdbool.h> - -#include <analysis/exporter.h> - - - -/* Crée un nouvel objet Python de type 'py_exporter'. */ -PyObject *py_exporter_new_from_existing(GContentExporter *); - -/* Ajoute l'objet 'analysis.exporter' au module Python. */ -bool add_analysis_exporter_to_python_module(PyObject *); - - - -#endif  /* _PLUGINS_PYOIDA_ANALYSIS_EXPORTER_H */ diff --git a/plugins/pychrysa/analysis/line.c b/plugins/pychrysa/analysis/line.c deleted file mode 100644 index fd697e2..0000000 --- a/plugins/pychrysa/analysis/line.c +++ /dev/null @@ -1,793 +0,0 @@ - -/* OpenIDA - Outil d'analyse de fichiers binaires - * line.c - équivalent Python du fichier "analysis/line.h" - * - * Copyright (C) 2010 Cyrille Bagard - * - *  This file is part of OpenIDA. - * - *  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 "line.h" - - -#include "exporter-int.h" -#include "../arch/archbase.h" - - - - - - - -/* Classe 'analysis.line' pour Python */ -typedef struct _py_line -{ -    py_exporter parent;                     /* A laisser en premier        */ - -    GRenderingLine *line;                   /* Référence GLib              */ - -} py_line; - - - - -/* Crée un nouvel objet Python de type 'py_line'. */ -static PyObject *py_line_new(PyTypeObject *, PyObject *, PyObject *); - - - - - - -/* Fournit le type d'objet 'analysis.line' pour Python. */ -static PyTypeObject *get_analysis_line_type(void); - - - -/* Prépare un parcours de lignes. */ -static PyObject *py_line_get_iter(py_line *); - -/* Prépare un parcours de lignes en sens inverse. */ -static PyObject *py_line_get_riter(py_line *); - - - -/* Fournit l'adresse physique ou en mémoire d'une ligne. */ -static PyObject *py_line_get_address(py_line *, void *); - -/* Fournit le commentaire associé à la ligne s'il existe. */ -static PyObject *py_line_get_comment(py_line *, void *); - -/* Définit ou supprime un commentaire pour la ligne indiquée. */ -static int py_line_set_comment(py_line *, PyObject *, void *); - - - - - -/* ---------------------- ITERATEUR POUR LE PARCOURS DE LIGNES ---------------------- */ - - -/* Itérateur pour lignes de rendu */ -typedef struct _py_line_iter -{ -    PyObject_HEAD                           /* A laisser en premier        */ - -    GRenderingLine *head;                   /* Liste à parcourir           */ -    GRenderingLine *cur;                    /* Point de parcours courant   */ - -} py_line_iter; - - -/* Fournit le type d'objet 'analysis.LineIter' pour Python. */ -static PyTypeObject *get_analysis_line_iter_type(void); - -/* Prépare l'itérateur pour un parcours de lignes de rendu. */ -static PyObject *py_line_iter_new(GRenderingLine *); - -/* Libère la mémoire occupée par un itérateur de 'py_line'. */ -static void py_line_iter_dealloc(py_line_iter *); - -/* Fournit l'élément suivant dans un parcours de lignes. */ -static PyObject *py_line_iter_get_next(py_line_iter *); - - - -/* ---------------------- ITERATEUR POUR LE PARCOURS DE LIGNES ---------------------- */ - - -/* Itérateur pour lignes de rendu */ -typedef py_line_iter py_line_riter; - - -/* Fournit le type d'objet 'analysis.LineRevIter' pour Python. */ -static PyTypeObject *get_analysis_line_riter_type(void); - -/* Prépare l'itérateur pour un parcours de lignes de rendu. */ -static PyObject *py_line_riter_new(GRenderingLine *); - -/* Libère la mémoire occupée par un itérateur de 'py_line'. */ -static void py_line_riter_dealloc(py_line_riter *); - -/* Fournit l'élément précédant dans un parcours de lignes. */ -static PyObject *py_line_riter_get_prev(py_line_riter *); - - - - - - - - - - - - - - - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : type = type de l'objet à instancier.                         * -*                args = arguments fournis à l'appel.                          * -*                kwds = arguments de type key=val fournis.                    * -*                                                                             * -*  Description : Crée un nouvel objet Python de type 'py_line'.               * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static PyObject *py_line_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ -    py_line *result;                        /* Instance à retourner        */ - -    result = (py_line *)type->tp_alloc(type, 0); - -    return (PyObject *)result; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : line = objet GLib existant à transposer.                     * -*                                                                             * -*  Description : Crée un nouvel objet Python de type 'py_line'.               * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -PyObject *py_line_new_from_existing(GRenderingLine *line) -{ -    py_line *result;                        /* Instance à retourner        */ -    PyTypeObject *type;                     /* Type Python à instancier    */ - -    result = (py_line *)g_object_get_data(G_OBJECT(line), "python_object"); - -    if (result == NULL) -    { -        type = get_analysis_line_type(); - -        result = (py_line *)type->tp_alloc(type, 0); - -        PY_EXPORTER(result)->glib = G_CONTENT_EXPORTER(line);   /* TODO : move me ! */ - -        result->line = line; -        g_object_ref(line); - -        g_object_set_data(G_OBJECT(line), "python_object", result); - -    } -    else Py_INCREF((PyObject *)result); - -    return (PyObject *)result; - -} - - - - - - - - - - - - - - - - - - - - - - - - - - - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Fournit le type d'objet 'analysis.line' pour Python.         * -*                                                                             * -*  Retour      : Adresse du type vivant à manipuler.                          * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static PyTypeObject *get_analysis_line_type(void) -{ -    static PyTypeObject *result = NULL;     /* Type pour objet à retourner */ - -    static PyMethodDef py_line_methods[] = { -        { -            "__reversed__", (PyCFunction)py_line_get_riter, -            METH_NOARGS, -            "Return a reverse iterator over the rendering lines." -        }, -        { NULL } -    }; - -    static PyGetSetDef py_line_getset[] = { -        { -            "address", -            (getter)py_line_get_address, -            (setter)NULL, -            "Get the physical or virtual address relative to the line." -        }, -        { -            "comment", -            (getter)py_line_get_comment, -            (setter)py_line_set_comment, -            "Get or set a comment for the rendering line." -        }, -        { NULL } -    }; - -    static PyTypeObject py_line_type = { - -        PyObject_HEAD_INIT(NULL) - -        .tp_name        = "pyoida.analysis.Line", -        .tp_basicsize   = sizeof(py_line), - -        .tp_flags       = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - -        .tp_doc         = "PyOIDA rendering line", - -        .tp_iter        = (getiterfunc)py_line_get_iter, - -        .tp_methods     = py_line_methods, -        .tp_getset      = py_line_getset, -        .tp_new         = (newfunc)py_line_new - -    }; - -    if (result == NULL) -    { -        py_line_type.tp_base = get_analysis_exporter_type(); -        result = &py_line_type; -    } - -    return result; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : module = module dont la définition est à compléter.          * -*                                                                             * -*  Description : Ajoute l'objet 'analysis.line' au module Python.             * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -bool add_analysis_line_to_python_module(PyObject *module) -{ -    PyTypeObject *py_line_type;             /* Type défini pour Python     */ -    int ret;                                /* Bilan d'un appel            */ - -    py_line_type = get_analysis_line_type(); - -    if (PyType_Ready(py_line_type) < 0) -        return false; - -    Py_INCREF(py_line_type); -    ret = PyModule_AddObject(module, "Line", (PyObject *)py_line_type); - -    return (ret == 0); - -} - - - - - - - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : self = instance manipulée à traiter.                         * -*                                                                             * -*  Description : Prépare un parcours de lignes.                               * -*                                                                             * -*  Retour      : Point de départ d'un parcours.                               * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static PyObject *py_line_get_iter(py_line *self) -{ -    return (PyObject *)py_line_iter_new(self->line); - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : self = instance manipulée à traiter.                         * -*                                                                             * -*  Description : Prépare un parcours de lignes en sens inverse.               * -*                                                                             * -*  Retour      : Point de départ d'un parcours.                               * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static PyObject *py_line_get_riter(py_line *self) -{ -    return (PyObject *)py_line_riter_new(self->line); - -} - - - - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : self = classe présentant une ligne de rendu.                 * -*                data = adresse non utilisée ici.                             * -*                                                                             * -*  Description : Fournit l'adresse physique ou en mémoire d'une ligne.        * -*                                                                             * -*  Retour      : Position physique ou en mémoire associée à la ligne.         * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static PyObject *py_line_get_address(py_line *self, void *data) -{ -    vmpa_t value;                           /* Adresse à convertir         */ - -    value = get_rendering_line_address(self->line); - -    return py_vmpa_new_from_existing(value); - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : self = classe présentant une ligne de rendu.                 * -*                data = adresse non utilisée ici.                             * -*                                                                             * -*  Description : Fournit le commentaire associé à la ligne s'il existe.       * -*                                                                             * -*  Retour      : Chaîne de caractères ou NULL.                                * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static PyObject *py_line_get_comment(py_line *self, void *data) -{ -    const char *comment;                    /* Commentaire à transmettre   */ - -    comment = get_rendering_line_comment(self->line); - -    return Py_BuildValue("s", comment); - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : self  = classe présentant des options de représentation.     * -*                value = nouvelle valeur affectée.                            * -*                data  = adresse non utilisée ici.                            * -*                                                                             * -*  Description : Définit ou supprime un commentaire pour la ligne indiquée.   * -*                                                                             * -*  Retour      : Bilan de la mise à jour.                                     * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static int py_line_set_comment(py_line *self, PyObject *value, void *data) -{ -    char *comment;                          /* Commentaire à définir       */ - -    comment = PyString_AsString(value); -    /* FIXME : nil pour supprimer ? */ - -    set_rendering_line_comment(self->line, comment); - -    return 0; - -} - - - - - - - - - - - - - - - -/* ---------------------------------------------------------------------------------- */ -/*                        ITERATEUR POUR LE PARCOURS DE LIGNES                        */ -/* ---------------------------------------------------------------------------------- */ - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Fournit le type d'objet 'analysis.LineIter' pour Python.     * -*                                                                             * -*  Retour      : Adresse du type vivant à manipuler.                          * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static PyTypeObject *get_analysis_line_iter_type(void) -{ -    static PyTypeObject *result = NULL;     /* Type pour objet à retourner */ - -    static PyTypeObject py_line_iter_type = { - -        PyObject_HEAD_INIT(NULL) - -        .tp_name        = "pyoida.analysis.LineIter", -        .tp_basicsize   = sizeof(py_line_iter), - -        .tp_flags       = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - -        .tp_doc         = "PyOIDA iterator for rendering lines", - -        .tp_iter        = PyObject_SelfIter, -        .tp_iternext    = (iternextfunc)py_line_iter_get_next - -    }; - -    if (result == NULL) result = &py_line_iter_type; - -    return result; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : module = module dont la définition est à compléter.          * -*                                                                             * -*  Description : Ajoute l'objet 'analysis.LineIter' au module Python.         * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -bool add_analysis_line_iter_to_python_module(PyObject *module) -{ -    PyTypeObject *py_line_iter_type;        /* Type défini pour Python     */ -    int ret;                                /* Bilan d'un appel            */ - -    py_line_iter_type = get_analysis_line_iter_type(); - -    if (PyType_Ready(py_line_iter_type) < 0) -        return false; - -    Py_INCREF(py_line_iter_type); -    ret = PyModule_AddObject(module, "Iter", (PyObject *)py_line_iter_type); - -    return (ret == 0); - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : head = liste à parcourir.                                    * -*                                                                             * -*  Description : Prépare l'itérateur pour un parcours de lignes de rendu.     * -*                                                                             * -*  Retour      : Instance d'itérateur prête à emploi.                         * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static PyObject *py_line_iter_new(GRenderingLine *head) -{ -    py_line_iter *result;                   /* Nouvelle instance à renvoyer*/ -    PyTypeObject *type;                     /* Type d'objet à créer        */ - -    type = get_analysis_line_iter_type(); - -    result = (py_line_iter *)type->tp_alloc(type, 0); - -    if (result != NULL) -    { -        result->head = head; -        result->cur = NULL; -    } - -    return (PyObject *)result; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : self = instance d'objet à supprimer.                         * -*                                                                             * -*  Description : Libère la mémoire occupée par un itérateur de 'py_line'.     * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void py_line_iter_dealloc(py_line_iter *self) -{ -#if PY_VERSION_HEX < 0x03000000 -    self->ob_type->tp_free((PyObject *)self); -#else -    Py_TYPE(self)->tp_free((PyObject *)self); -#endif - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : self = instance manipulée à traiter.                         * -*                                                                             * -*  Description : Fournit l'élément suivant dans un parcours de lignes.        * -*                                                                             * -*  Retour      : Point suivant du parcours ou NULL.                           * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static PyObject *py_line_iter_get_next(py_line_iter *self) -{ -    PyObject *result;                       /* Elément à retourner         */ -    GRenderingLine *next;                   /* Elément réel suivant        */ - -    if (self->cur == NULL) next = self->head; -    else next = g_rendering_line_get_next_iter(self->head, self->cur, NULL); - -    if (next != NULL) -    { -        self->cur = next; -        result = py_line_new_from_existing(next); -        Py_INCREF(result); -    } -    else result = NULL; - -    return (PyObject *)result; - -} - -/* ---------------------------------------------------------------------------------- */ -/*                        ITERATEUR POUR LE PARCOURS DE LIGNES                        */ -/* ---------------------------------------------------------------------------------- */ - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Fournit le type d'objet 'analysis.LineRevIter' pour Python.  * -*                                                                             * -*  Retour      : Adresse du type vivant à manipuler.                          * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static PyTypeObject *get_analysis_line_riter_type(void) -{ -    static PyTypeObject *result = NULL;     /* Type pour objet à retourner */ - -    static PyTypeObject py_line_riter_type = { - -        PyObject_HEAD_INIT(NULL) - -        .tp_name        = "pyoida.analysis.LineRevIter", -        .tp_basicsize   = sizeof(py_line_riter), - -        .tp_flags       = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - -        .tp_doc         = "PyOIDA iterator for rendering lines", - -        .tp_iter        = PyObject_SelfIter, -        .tp_iternext    = (iternextfunc)py_line_riter_get_prev - -    }; - -    if (result == NULL) result = &py_line_riter_type; - -    return result; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : module = module dont la définition est à compléter.          * -*                                                                             * -*  Description : Ajoute l'objet 'analysis.LineRevIter' au module Python.      * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -bool add_analysis_line_riter_to_python_module(PyObject *module) -{ -    PyTypeObject *py_line_riter_type;       /* Type défini pour Python     */ -    int ret;                                /* Bilan d'un appel            */ - -    py_line_riter_type = get_analysis_line_riter_type(); - -    if (PyType_Ready(py_line_riter_type) < 0) -        return false; - -    Py_INCREF(py_line_riter_type); -    ret = PyModule_AddObject(module, "RevIter", (PyObject *)py_line_riter_type); - -    return (ret == 0); - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : head = liste à parcourir.                                    * -*                                                                             * -*  Description : Prépare l'itérateur pour un parcours de lignes de rendu.     * -*                                                                             * -*  Retour      : Instance d'itérateur prête à emploi.                         * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static PyObject *py_line_riter_new(GRenderingLine *head) -{ -    py_line_riter *result;                  /* Nouvelle instance à renvoyer*/ -    PyTypeObject *type;                     /* Type d'objet à créer        */ - -    type = get_analysis_line_riter_type(); - -    result = (py_line_riter *)type->tp_alloc(type, 0); - -    if (result != NULL) -    { -        result->head = head; -        result->cur = NULL; -    } - -    return (PyObject *)result; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : self = instance d'objet à supprimer.                         * -*                                                                             * -*  Description : Libère la mémoire occupée par un itérateur de 'py_line'.     * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void py_line_riter_dealloc(py_line_riter *self) -{ -#if PY_VERSION_HEX < 0x03000000 -    self->ob_type->tp_free((PyObject *)self); -#else -    Py_TYPE(self)->tp_free((PyObject *)self); -#endif - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : self = instance manipulée à traiter.                         * -*                                                                             * -*  Description : Fournit l'élément précédant dans un parcours de lignes.      * -*                                                                             * -*  Retour      : Point suivant du parcours ou NULL.                           * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static PyObject *py_line_riter_get_prev(py_line_riter *self) -{ -    PyObject *result;                       /* Elément à retourner         */ -    GRenderingLine *prev;                   /* Elément réel précédant      */ - -    if (self->cur == NULL) prev = g_rendering_line_get_last_iter(self->head, NULL); -    else prev = g_rendering_line_get_prev_iter(self->head, self->cur, NULL); - -    if (prev != NULL) -    { -        self->cur = prev; -        result = py_line_new_from_existing(prev); -        Py_INCREF(result); -    } -    else result = NULL; - -    return (PyObject *)result; - -} diff --git a/plugins/pychrysa/analysis/line.h b/plugins/pychrysa/analysis/line.h deleted file mode 100644 index e71596c..0000000 --- a/plugins/pychrysa/analysis/line.h +++ /dev/null @@ -1,61 +0,0 @@ - -/* OpenIDA - Outil d'analyse de fichiers binaires - * line.h - prototypes pour l'équivalent Python du fichier "analysis/line.h" - * - * Copyright (C) 2010 Cyrille Bagard - * - *  This file is part of OpenIDA. - * - *  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 _PLUGINS_PYOIDA_ANALYSIS_LINE_H -#define _PLUGINS_PYOIDA_ANALYSIS_LINE_H - - -#include <Python.h> -#include <stdbool.h> - -#include <analysis/line.h> - - - -/* Crée un nouvel objet Python de type 'py_line'. */ -PyObject *py_line_new_from_existing(GRenderingLine *); - -/* Ajoute l'objet 'analysis.line' au module Python. */ -bool add_analysis_line_to_python_module(PyObject *); - - - - -/* ---------------------- ITERATEUR POUR LE PARCOURS DE LIGNES ---------------------- */ - - -/* Ajoute l'objet 'analysis.LineIter' au module Python. */ -bool add_analysis_line_iter_to_python_module(PyObject *); - - - -/* ---------------------- ITERATEUR POUR LE PARCOURS DE LIGNES ---------------------- */ - - -/* Ajoute l'objet 'analysis.LineRevIter' au module Python. */ -bool add_analysis_line_riter_to_python_module(PyObject *); - - - -#endif  /* _PLUGINS_PYOIDA_ANALYSIS_LINE_H */ diff --git a/plugins/stackvars/operand.c b/plugins/stackvars/operand.c index 77ea43d..c8028d1 100644 --- a/plugins/stackvars/operand.c +++ b/plugins/stackvars/operand.c @@ -95,11 +95,6 @@ static void g_stack_var_operand_class_init(GStackVarOperandClass *klass)  static void g_stack_var_operand_init(GStackVarOperand *operand)  { -    GContentExporter *parent;               /* Instance parente            */ - -    parent = G_CONTENT_EXPORTER(operand); - -    //parent->add_arch_to_gtk_buffer = (add_arch_to_gtk_buffer_fc)g_stack_var_operand_add_to_gtk_buffer;  } diff --git a/plugins/stackvars/stackvars.c b/plugins/stackvars/stackvars.c index 1e18f28..26d9e11 100644 --- a/plugins/stackvars/stackvars.c +++ b/plugins/stackvars/stackvars.c @@ -23,8 +23,7 @@  #include "stackvars.h" - -#include <analysis/line_code.h> +#if 0  #include <analysis/routine.h>  #include <arch/x86/operand.h>  #include <format/executable.h> @@ -277,3 +276,4 @@ static bool replace_stack_var_in_operand(const GArchOperand *operand, GBinRoutin      return result;  } +#endif diff --git a/plugins/stackvars/stackvars.h b/plugins/stackvars/stackvars.h index bf3e42e..accd5a4 100644 --- a/plugins/stackvars/stackvars.h +++ b/plugins/stackvars/stackvars.h @@ -24,7 +24,7 @@  #ifndef _PLUGINS_STACKVARS_STACKVARS_H  #define _PLUGINS_STACKVARS_STACKVARS_H - +#if 0  #include <glib-object.h>  #include <gmodule.h>  #include <stdbool.h> @@ -43,7 +43,7 @@ G_MODULE_EXPORT PluginAction get_plugin_action(void);  /* Exécute une action définie sur un binaire chargé. */  G_MODULE_EXPORT bool execute_action_on_binary(GLoadedBinary *, PluginAction); - +#endif  #endif  /* _PLUGINS_STACKVARS_STACKVARS_H */ diff --git a/plugins/theseus/Makefile.am b/plugins/theseus/Makefile.am deleted file mode 100644 index 8040bb4..0000000 --- a/plugins/theseus/Makefile.am +++ /dev/null @@ -1,14 +0,0 @@ - -lib_LTLIBRARIES = libtheseus.la - -libtheseus_la_SOURCES =					\ -	theseus.h theseus.c - -libtheseus_la_CFLAGS = $(AM_CFLAGS) - - -INCLUDES = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) -I../../src - -AM_CPPFLAGS =  - -AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) diff --git a/plugins/theseus/theseus.c b/plugins/theseus/theseus.c deleted file mode 100644 index ea119ef..0000000 --- a/plugins/theseus/theseus.c +++ /dev/null @@ -1,620 +0,0 @@ - -/* OpenIDA - Outil d'analyse de fichiers binaires - * theseus.c - décompilation en fonction du flot d'exécution - * - * Copyright (C) 2010-2012 Cyrille Bagard - * - *  This file is part of OpenIDA. - * - *  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 Foobar.  If not, see <http://www.gnu.org/licenses/>. - */ - - -#include "theseus.h" - - -#include <analysis/exporter.h> -#include <analysis/line_code.h> -#include <arch/artificial.h> - - -/* Traite en premier lieu les adresses marquées "impératives". */ -static bool register_white_list(GLoadedBinary *); - -/* Indique si une ligne peut faire l'objet d'un nouveau suivi. */ -static bool can_line_be_followed(const GRenderingLine *); - -/* Indique si une ligne a déjà été traitée lors d'un suivi. */ -static bool can_line_be_processed(const GRenderingLine *); - -/* Marque une ligne comme ayant été traitée. */ -static void mark_line_as_done(GRenderingLine *, bool); - -/* Suit le flot d'exécution à partir d'un point donné. */ -static bool follow_flow_from_line(GLoadedBinary *, vmpa_t); - -/* Désassemble une nouvelle instruction à partir d'une adresse. */ -static GRenderingLine *disassemble_target_address(GLoadedBinary *, GRenderingLine *, vmpa_t); - -/* Insère dans le flux existant les nouvelles lignes crées. */ -static bool insert_new_lines_into_flow(GLoadedBinary *, GRenderingLine *, GRenderingLine *); - - - - - -/* -mov	edx, 0x80480fb -call	[edx] -mov	edx, 0x80480fb -add	edx, 0x8 -call	[edx] -mov	edx, 0x80480fb -add	edx, 0x10 -call	[edx] -mov	edx, 0x80480fb -add	edx, 0xc -call	[edx] -mov	edx, 0x80480fb -add	edx, 0x14 -call	[edx] -mov	edx, 0x80480fb -add	edx, 0x4 -call	[edx] -*/ - - -static const vmpa_t _white_list[] = { -    0x80480fbull, -    0x8048103ull, -    0x804810bull, -    0x8048107ull, -    0x804810full, -    0x80480ffull -}; - -static const size_t _white_list_count = 6; - - - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : ref = espace de référencement global.                        * -*                                                                             * -*  Description : Initialise le greffon pour les bornes de routine.            * -*                                                                             * -*  Retour      : true.                                                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -G_MODULE_EXPORT bool init_plugin(GObject *ref) -{ -    return true; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Fournit une indication sur le type d'opération(s) menée(s).  * -*                                                                             * -*  Retour      : Description d'une action.                                    * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -G_MODULE_EXPORT PluginAction get_plugin_action(void) -{ -    return PGA_CODE_PROCESS; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : binary = représentation binaire à traiter.                   * -*                action = action attendue.                                    * -*                                                                             * -*  Description : Exécute une action définie sur un binaire chargé.            * -*                                                                             * -*  Retour      : true si une action a été menée, false sinon.                 * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -G_MODULE_EXPORT bool execute_action_on_binary(GLoadedBinary *binary, PluginAction action) -{ -    bool result;                            /* Bilan à retourner           */ -    GRenderingLine *lines;                  /* Lignes désassemblées        */ -    GExeFormat *format;                     /* Format du binaire traité    */ -    vmpa_t start;                           /* Point de départ de l'action */ - - - -    GRenderingOptions *options; -    GRenderingLine *iter; - - -    lines = g_loaded_binary_get_lines(binary); - - - - -    format = g_loaded_binary_get_format(binary); - -    start = g_exe_format_get_entry_point(format); - -    result = register_white_list(binary); - -    result &= follow_flow_from_line(binary, start); - - -    //follow_flow_from_line(binary, 0x0804810bull); - - - - - -    options = g_loaded_binary_get_options(binary); - -    for (iter = lines; iter != NULL; iter = g_rendering_line_get_next_iter(lines, iter, NULL)) -    { - -        printf(" >>>>>> %c%c  ", -               g_object_get_data(G_OBJECT(iter), "theseus_white") != NULL ? '!' : ' ', -               g_object_get_data(G_OBJECT(iter), "theseus_done") != NULL ? '*' : ' '); -        g_content_exporter_add_text(G_CONTENT_EXPORTER(iter), options, 0/*MRD_BLOCK*/, stdout); -        fflush(stdout); -        printf("\n"); - - -    } - - - -    //exit(-1); - - - - -    return result; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : binary = représentation binaire à traiter.                   * -*                                                                             * -*  Description : Traite en premier lieu les adresses marquées "impératives".  * -*                                                                             * -*  Retour      : true si le déroulement s'est bien effectué, false sinon.     * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static bool register_white_list(GLoadedBinary *binary) -{ -    bool result;                            /* Bilan à retourner           */ -    GRenderingLine *lines;                  /* Lignes désassemblées        */ -    size_t i;                               /* Boucle de parcours          */ -    GRenderingLine *target;                 /* Ligne à transformer ?       */ -    GRenderingLine *last;                   /* Nouvelle ligne principale   */ -    GRenderingLine *new;                    /* Nouvelles lignes de rendu   */ - -    result = true; - -    lines = g_loaded_binary_get_lines(binary); - -    for (i = 0; i < _white_list_count && result; i++) -    { -        target = g_rendering_line_find_by_address(lines, NULL, _white_list[i]); -        target = g_rendering_line_loop_for_code(target, NULL); - -        new = disassemble_target_address(binary, target, _white_list[i]); - -        last = g_rendering_line_get_last_iter(new, NULL); -        mark_line_as_done(last, true); - -        result = insert_new_lines_into_flow(binary, target, new); - -        result &= follow_flow_from_line(binary, _white_list[i]); - -    } - -    return result; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : line = ligne de rendu à analyser.                            * -*                                                                             * -*  Description : Indique si une ligne peut faire l'objet d'un nouveau suivi.  * -*                                                                             * -*  Retour      : true si le suivi peut continuer, false sinon.                * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static bool can_line_be_followed(const GRenderingLine *line) -{ -    bool result;                            /* Bilan d'analyse à renvoyer  */ - -    result = true; - -    if (g_object_get_data(G_OBJECT(line), "theseus_done") != NULL) -        result = (g_object_get_data(G_OBJECT(line), "theseus_white") != NULL); - -    return result; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : line = ligne de rendu à analyser.                            * -*                                                                             * -*  Description : Indique si une ligne a déjà été traitée lors d'un suivi.     * -*                                                                             * -*  Retour      : true si le suivi peut continuer, false sinon.                * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static bool can_line_be_processed(const GRenderingLine *line) -{ -    return (g_object_get_data(G_OBJECT(line), "theseus_done") == NULL); - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : line  = ligne de rendu à traiter.                            * -*                white = type de marquage à apposer (liste blanche ou normal).* -*                                                                             * -*  Description : Marque une ligne comme ayant été traitée.                    * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void mark_line_as_done(GRenderingLine *line, bool white) -{ -    if (white) -        g_object_set_data(G_OBJECT(line), "theseus_white", line); -    else -        g_object_set_data(G_OBJECT(line), "theseus_done", line); - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : binary = représentation binaire à traiter.                   * -*                start  = point de départ de la procédure.                    * -*                                                                             * -*  Description : Suit le flot d'exécution à partir d'un point donné.          * -*                                                                             * -*  Retour      : true si le déroulement s'est bien effectué, false sinon.     * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static bool follow_flow_from_line(GLoadedBinary *binary, vmpa_t start) -{ -    bool result;                            /* Bilan de opérations         */ -    GRenderingLine *lines;                  /* Lignes désassemblées        */ -    GRenderingLine *first;                  /* Première ligne à traiter    */ -    vmpa_t addr;                            /* Adresse référencée          */ -    GRenderingLine *new;                    /* Nouvelles lignes de rendu   */ -    GRenderingLine *iter;                   /* Boucle de parcours          */ -    GArchInstruction *instr;                /* Instruction à ausculter     */ -    InstructionLinkType type;               /* Type de référence           */ -    GRenderingLine *target;                 /* Ligne visée par la référence*/ - -    lines = g_loaded_binary_get_lines(binary); - -    first = g_rendering_line_find_by_address(lines, NULL, start); -    first = g_rendering_line_loop_for_code(first, NULL); - -    if (!can_line_be_followed(first)) -        return true; - -    //if (start != 0x0804810bull) return true; - -    printf("###################################### Passage\n"); - -    /* Alignement sur le point d'entrée */ - -    result = true; - -    addr = get_rendering_line_address(first); - -    if (addr < start) -    { -        new = disassemble_target_address(binary, first, start); - -        result = insert_new_lines_into_flow(binary, target, new); - -        first = g_rendering_line_find_by_address(lines, NULL, start); - -        //return true; - -    } -    else g_object_set_data(G_OBJECT(first), "theseus_done", binary); - - - - -    printf("Analyse :: 0x%016llx\n", get_rendering_line_address(first)); - - - - - -    /* Poursuite du suivi du flot... */ - -    for (iter = g_rendering_line_get_next_iter(lines, first, NULL); -         iter != NULL/* && result*/; -         iter = g_rendering_line_get_next_iter(lines, iter, NULL)) -    { -        /* On ne traite que du code ici ! */ -        if (!G_IS_CODE_LINE(iter)) continue; - -        /* -        printf("testing... 0x%08llx => %d\n", -               get_rendering_line_address(iter), -               can_line_be_processed(iter)); -        */ - -        if (!can_line_be_processed(iter)) -            break; - -        instr = g_code_line_get_instruction(G_CODE_LINE(iter)); - -        /* Si le code n'es pas désassemblé ! */ -        if (G_IS_DB_INSTRUCTION(instr)) -        { -            new = disassemble_target_address(binary, iter, get_rendering_line_address(iter)); -            result = insert_new_lines_into_flow(binary, iter, new); - -            if (!result) -            { -                mark_line_as_done(iter, false); -                break; -            } -            else -            { -                iter = new; -                mark_line_as_done(iter, false); - -                instr = g_code_line_get_instruction(G_CODE_LINE(iter)); -                if (!G_IS_DB_INSTRUCTION(instr)) break; - -            } - -        } -        else mark_line_as_done(iter, false); - -        type = g_arch_instruction_get_link(instr, &addr); - -        if (get_rendering_line_address(iter) ==  0x0804811aull) -            printf(" == got it !! ==\n"); - - -        switch (type) -        { -            case ILT_JUMP: -            case ILT_JUMP_IF_FALSE: -            case ILT_JUMP_IF_TRUE: -                result = follow_flow_from_line(binary, addr); -                break; - -           default: -               break; - -        } - -        if (get_rendering_line_address(iter) ==  0x0804811aull) -            printf(" == continue ? %d\n", result); - -    } - -    return result; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : binary = représentation binaire à traiter.                   * -*                old    = ligne contenant l'adresse visée à remplacer.        * -*                target = adresse de la nouvelle instruction à voir.          * -*                                                                             * -*  Description : Désassemble une nouvelle instruction à partir d'une adresse. * -*                                                                             * -*  Retour      : Nouvelle(s) ligne(s) en place ou NULL en cas d'échec.        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static GRenderingLine *disassemble_target_address(GLoadedBinary *binary, GRenderingLine *old, vmpa_t target) -{ -    GRenderingLine *result;                 /* Lignes en place à renvoyer  */ -    GExeFormat *format;                     /* Format du binaire fourni    */ -    GArchProcessor *proc;                   /* Architecture du binaire     */ -    GRenderingOptions *options;             /* Options de désassemblage    */ -    bin_t *data;                            /* Données binaires chargées   */ -    off_t length;                           /* Taille du code binaire      */ -    vmpa_t old_addr;                        /* Adresse de ligne à casser   */ -    off_t offset;                           /* Position dans le contenu    */ -    vmpa_t i;                               /* Boucle de parcours          */ -    GArchInstruction *instr;                /* Instruction décodée         */ -    GRenderingLine *line;                   /* Nouvelle ligne de rendu     */ - -    result = NULL; - -    format = g_loaded_binary_get_format(binary); -    proc = get_arch_processor_from_format(format); -    options = g_loaded_binary_get_options(binary); - -    data = g_loaded_binary_get_data(binary, &length); - -    old_addr = get_rendering_line_address(old); -    if (!g_exe_format_translate_address_into_offset(format, old_addr, &offset)) -        return NULL; - -    /* Si on doit laisser sur le carreau quelques octets perdus... */ -    for (i = 0; i < (target - old_addr); i++) -    { -        instr = g_db_instruction_new_from_data(data, &offset, length, 0/*base*/, proc); -        g_arch_instruction_set_location(instr, 0/*base*/ + offset - 1, 1, old_addr + i); - -        line = g_code_line_new(old_addr + i, instr, options); -        g_rendering_line_add_to_lines(&result, line); - -    } - -    /* Décodage des instructions */ - -    instr = g_arch_processor_decode_instruction(proc, NULL /*FIXME*/, data, -                                                &offset, length, 0/*offset*/, target, NULL/*FIXME*/); - -    line = g_code_line_new(target, instr, options); -    g_rendering_line_add_to_lines(&result, line); - -    mark_line_as_done(line, false); - -    return result; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : binary = représentation binaire à traiter.                   * -*                old    = ancienne ligne, point de départ des remplacements.  * -*                new    = nouvelle(s) ligne(s) de représentation.             * -*                                                                             * -*  Description : Insère dans le flux existant les nouvelles lignes crées.     * -*                                                                             * -*  Retour      : Bilan de l'opération.                                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static bool insert_new_lines_into_flow(GLoadedBinary *binary, GRenderingLine *old, GRenderingLine *new) -{ -    bool result;                            /* Bilan de opérations         */ -    GExeFormat *format;                     /* Format du binaire fourni    */ -    GArchProcessor *proc;                   /* Architecture du binaire     */ -    GRenderingOptions *options;             /* Options de désassemblage    */ -    bin_t *data;                            /* Données binaires chargées   */ -    off_t length;                           /* Taille du code binaire      */ -    GRenderingLine **root;                  /* Racine des lignes de rendu  */ -    GRenderingLine *iter;                   /* Boucle de parcours          */ -    vmpa_t start;                           /* Adresse de début du bloc    */ -    vmpa_t end;                             /* Adresse de fin du bloc      */ -    vmpa_t max;                             /* Adresse de fin de ligne     */ -    vmpa_t i;                               /* Boucle de parcours          */ -    off_t offset;                           /* Position dans le contenu    */ -    GArchInstruction *instr;                /* Instruction décodée         */ -    GRenderingLine *line;                   /* Nouvelle ligne de rendu     */ -    GRenderingLine *last;                   /* Dernière ligne à vérifier   */ - -    format = g_loaded_binary_get_format(binary); -    proc = get_arch_processor_from_format(format); -    options = g_loaded_binary_get_options(binary); - -    data = g_loaded_binary_get_data(binary, &length); - -    /* Etendue du bloc de remplacement */ - -    iter = g_rendering_line_get_last_iter(new, NULL); - -    start = get_rendering_line_address(new); - -    end = get_rendering_line_address(iter); -    end += get_rendering_line_length(iter) - 1; - -    /* Bourrage nécessaire ? */ - -    root = g_loaded_binary_get_lines_root(binary); - -    iter = g_rendering_line_find_by_address(*root, NULL, end); - -    max = get_rendering_line_address(iter); -    max += get_rendering_line_length(iter); - -    for (i = end + 1; i < max; i++) -    { -        if (!g_exe_format_translate_address_into_offset(format, i, &offset)) -            /** -             * Comme les adresses proviennent à l'origine de partie valide, -             * on considère que l'appel est toujours un succès. -             * Cela permet d'avoir deux bilan possible : procédure bien déroulée, -             * ou bien remplacement impossible pour cause de place déjà prise. -             */ -            /*return false*/; - -        instr = g_db_instruction_new_from_data(data, &offset, length, 0/*base*/, proc); -        g_arch_instruction_set_location(instr, 0/*base*/ + offset - 1, 1, i); - -        line = g_code_line_new(i, instr, options); -        g_rendering_line_add_to_lines(&new, line); - -    } - -    /* S'assure qu'on ne touche à rien de sacré */ - -    result = true; - -    last = g_rendering_line_find_by_address(*root, NULL, end); - -    for (iter = g_rendering_line_find_by_address(*root, NULL, start); -         iter != NULL && result; -         iter = g_rendering_line_get_next_iter(*root, iter, last)) -    { -        result = can_line_be_processed(iter); -    } - -    /* Remplacement en bonne et due forme */ - -    if (result) -    { -        g_rendering_line_remove_range(root, start, end); -        g_rendering_line_insert_lines(root, &new); -    } - -    return result; - -} diff --git a/plugins/theseus/theseus.h b/plugins/theseus/theseus.h deleted file mode 100644 index e1a6f36..0000000 --- a/plugins/theseus/theseus.h +++ /dev/null @@ -1,49 +0,0 @@ - -/* OpenIDA - Outil d'analyse de fichiers binaires - * theseus.h - prototypes pour la décompilation en fonction du flot d'exécution - * - * Copyright (C) 2010 Cyrille Bagard - * - *  This file is part of OpenIDA. - * - *  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 Foobar.  If not, see <http://www.gnu.org/licenses/>. - */ - - -#ifndef _PLUGINS_THESEUS_THESEUS_H -#define _PLUGINS_THESEUS_THESEUS_H - - -#include <glib-object.h> -#include <gmodule.h> -#include <stdbool.h> - - -#include <analysis/binary.h> -#include <plugins/plugin-def.h> - - - -/* Initialise le greffon pour les bornes de routine. */ -G_MODULE_EXPORT bool init_plugin(GObject *); - -/* Fournit une indication sur le type d'opération(s) menée(s). */ -G_MODULE_EXPORT PluginAction get_plugin_action(void); - -/* Exécute une action définie sur un binaire chargé. */ -G_MODULE_EXPORT bool execute_action_on_binary(GLoadedBinary *, PluginAction); - - - -#endif  /* _PLUGINS_THESEUS_THESEUS_H */ | 
