diff options
| author | Cyrille Bagard <nocbos@gmail.com> | 2018-09-18 20:12:26 (GMT) | 
|---|---|---|
| committer | Cyrille Bagard <nocbos@gmail.com> | 2018-09-18 20:12:26 (GMT) | 
| commit | aa3cb06f056ccf1a0467eaff8aa4b40701902f5e (patch) | |
| tree | dde8cdc10459f932235ee8709dda3ae6b164c752 /plugins/ropgadgets/select.c | |
| parent | 175e8193759e01b45b1f6d2d7970e2993ec8c364 (diff) | |
Removed the old way to load binaries.
Diffstat (limited to 'plugins/ropgadgets/select.c')
| -rw-r--r-- | plugins/ropgadgets/select.c | 249 | 
1 files changed, 1 insertions, 248 deletions
diff --git a/plugins/ropgadgets/select.c b/plugins/ropgadgets/select.c index e8ee8c3..ea679bb 100644 --- a/plugins/ropgadgets/select.c +++ b/plugins/ropgadgets/select.c @@ -39,7 +39,6 @@  #include <core/global.h>  #include <common/cpp.h>  #include <common/extstr.h> -#include <core/formats.h>  #include <core/processors.h>  #include <gui/core/global.h>  #include <gtkext/easygtk.h> @@ -83,18 +82,9 @@ static void register_input_output_panel(GtkAssistant *, GObject *);  /* Construit la sélection d'un binaire déjà chargé. */  static GtkWidget *load_and_populate_current_project_binaries(GObject *); -/* Met à jour l'accès à la sélection du type d'entrée. */ -static void on_input_type_toggle(GtkToggleButton *, GObject *); -  /* Réagit à un changement de sélection du binaire d'entrée. */  static void on_loaded_binary_selection_change(GtkComboBox *, GObject *); -/* Réagit à un changement de fichier binaire d'entrée. */ -static void on_input_filename_change(GtkEditable *, GObject *); - -/* Sélectionne ou non un nouveau fichier d'entrée. */ -static void on_input_filename_browsing_clicked(GtkButton *, GObject *); -  /* Met à jour l'accès à la définition d'un fichier de sortie. */  static void on_output_need_toggle(GtkToggleButton *, GObject *); @@ -173,9 +163,6 @@ static void push_found_rop_gadgets(GObject *, GExeFormat *, found_rop_list *, si  /* Charge un format binaire interne déjà chargé. */  static GExeFormat *load_internal_format_for_rop_gadgets(GObject *); -/* Charge un format binaire externe. */ -static GExeFormat *load_external_format_for_rop_gadgets(GObject *); -  /* Procède à la recherche de gadgets de façon séparée. */  static gpointer look_for_rop_gadgets(GObject *); @@ -401,7 +388,6 @@ static void register_input_output_panel(GtkAssistant *assistant, GObject *ref)      GtkWidget *vbox;                        /* Support principal           */      GtkWidget *frame;                       /* Support avec encadrement    */      GtkWidget *sub_vbox;                    /* Division verticale          */ -    GtkWidget *radio;                       /* Choix du type d'entrée      */      GtkWidget *combobox;                    /* Sélection du binaire interne*/      GtkWidget *sub_hbox;                    /* Division horizontale        */      GtkWidget *entry;                       /* Zone de saisie de texte     */ @@ -419,34 +405,9 @@ static void register_input_output_panel(GtkAssistant *assistant, GObject *ref)      frame = qck_create_frame(_("<b>Input binary</b>"), sub_vbox, 0, 0, 12, 8);      gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, TRUE, 0); -    radio = qck_create_radio_button(ref, "loaded_as_input", _("Use a binary from the current project:"), -                                    NULL, G_CALLBACK(on_input_type_toggle), ref); -    gtk_box_pack_start(GTK_BOX(sub_vbox), radio, FALSE, FALSE, 0); -      combobox = load_and_populate_current_project_binaries(ref);      gtk_box_pack_start(GTK_BOX(sub_vbox), combobox, TRUE, TRUE, 0); -    radio = qck_create_radio_button(ref, "extern_as_input", _("Open a new binary file:"), -                                    GTK_RADIO_BUTTON(radio), G_CALLBACK(on_input_type_toggle), ref); -    gtk_box_pack_start(GTK_BOX(sub_vbox), radio, FALSE, FALSE, 0); - -    sub_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8); -    gtk_widget_show(sub_hbox); -    gtk_box_pack_start(GTK_BOX(sub_vbox), sub_hbox, FALSE, FALSE, 0); - -    entry = qck_create_entry(ref, "input_filename", NULL); -    g_signal_connect(entry, "changed", G_CALLBACK(on_input_filename_change), ref); -    gtk_box_pack_start(GTK_BOX(sub_hbox), entry, TRUE, TRUE, 0); - -    button = qck_create_button(ref, "input_browser", _("Browse..."), -                               G_CALLBACK(on_input_filename_browsing_clicked), assistant); -    gtk_box_pack_start(GTK_BOX(sub_hbox), button, FALSE, FALSE, 0); - -    /* Actualisation des accès */ - -    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio), TRUE); -    on_input_type_toggle(GTK_TOGGLE_BUTTON(radio), ref); -      /* Fichier de sortie */      sub_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); @@ -586,61 +547,6 @@ static GtkWidget *load_and_populate_current_project_binaries(GObject *ref)  /******************************************************************************  *                                                                             * -*  Paramètres  : button = oche dont le status vient de changer.               * -*                ref    = espace de référencements inter-panneaux.            * -*                                                                             * -*  Description : Met à jour l'accès à la sélection du type d'entrée.          * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void on_input_type_toggle(GtkToggleButton *button, GObject *ref) -{ -    GtkToggleButton *internal;              /* Bouton de sélection interne */ -    gboolean state;                         /* Etat du bouton courant      */ -    GtkWidget *widget;                      /* Element dont l'accès change */ - -    internal = GTK_TOGGLE_BUTTON(g_object_get_data(ref, "loaded_as_input")); -    state = gtk_toggle_button_get_active(internal); - -    /* Elément de sélection interne */ - -    widget = GTK_WIDGET(g_object_get_data(ref, "input_binary")); - -    if (widget != NULL) -    { -        gtk_widget_set_sensitive(widget, state); - -        if (state) -            on_loaded_binary_selection_change(GTK_COMBO_BOX(widget), ref); - -    } - -    /* Elément de sélection externe */ - -    widget = GTK_WIDGET(g_object_get_data(ref, "input_filename")); - -    if (widget != NULL) -    { -        gtk_widget_set_sensitive(widget, !state); - -        if (!state) -            on_input_filename_change(GTK_EDITABLE(widget), ref); - -    } - -    widget = GTK_WIDGET(g_object_get_data(ref, "input_browser")); -    if (widget != NULL) -        gtk_widget_set_sensitive(widget, !state); - -} - - -/****************************************************************************** -*                                                                             *  *  Paramètres  : combo = composant graphique de sélection concerné.           *  *                ref   = espace de référencement principal.                   *  *                                                                             * @@ -669,77 +575,6 @@ static void on_loaded_binary_selection_change(GtkComboBox *combo, GObject *ref)  /******************************************************************************  *                                                                             * -*  Paramètres  : editable = composant graphique d'édition concerné.           * -*                ref      = espace de référencement principal.                * -*                                                                             * -*  Description : Réagit à un changement de fichier binaire d'entrée.          * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void on_input_filename_change(GtkEditable *editable, GObject *ref) -{ -    guint16 length;                         /* Taille du texte fourni      */ -    GtkWidget *page;                        /* Page de la partie terminée  */ - -    length = gtk_entry_get_text_length(GTK_ENTRY(editable)); - -    page = gtk_assistant_get_nth_page(GTK_ASSISTANT(ref), 0); - -    if (page != NULL) -        gtk_assistant_set_page_complete(GTK_ASSISTANT(ref), page, length > 0); - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : button = bouton d'édition de la sélection.                   * -*                ref    = espace de référencement principal.                  * -*                                                                             * -*  Description : Sélectionne ou non un nouveau fichier d'entrée.              * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void on_input_filename_browsing_clicked(GtkButton *button, GObject *ref) -{ -    GtkWidget *dialog;                      /* Boîte à afficher            */ -    gchar *filename;                        /* Nom du fichier à intégrer   */ -    GtkEntry *entry;                        /* Zone de saisie à maj.       */ - -    dialog = gtk_file_chooser_dialog_new(_("Choose an input filename"), GTK_WINDOW(ref), -                                         GTK_FILE_CHOOSER_ACTION_OPEN, -                                         _("_Cancel"), GTK_RESPONSE_CANCEL, -                                         _("_Open"), GTK_RESPONSE_ACCEPT, -                                         NULL); - -    entry = GTK_ENTRY(g_object_get_data(ref, "input_filename")); -    gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), gtk_entry_get_text(entry)); - -    if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) -    { -        filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); - -        gtk_entry_set_text(GTK_ENTRY(entry), filename); - -        g_free(filename); - -    } - -    gtk_widget_destroy(dialog); - -} - - -/****************************************************************************** -*                                                                             *  *  Paramètres  : button = coche dont le status vient de changer.              *  *                ref    = espace de référencements inter-panneaux.            *  *                                                                             * @@ -1310,79 +1145,6 @@ static GExeFormat *load_internal_format_for_rop_gadgets(GObject *ref)  *                                                                             *  *  Paramètres  : ref = espace de référencements inter-panneaux.               *  *                                                                             * -*  Description : Charge un format binaire externe.                            * -*                                                                             * -*  Retour      : Nouveau format au contenu à fouiller ou NULL en cas d'échec. * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static GExeFormat *load_external_format_for_rop_gadgets(GObject *ref) -{ -    GExeFormat *result;                     /* Format chargé à retourner   */ -    GtkEntry *entry;                        /* Zone de saisie de texte     */ -    const gchar *filename;                  /* Nom du fichier à charger    */ -    GBinContent *content;                   /* Contenu binaire chargé      */ -    FormatMatchStatus status;               /* Statut d'une reconnaissance */ -    char *target;                           /* Sous-traitance requise      */ -    const char *desc;                       /* Description humaine associée*/ - -    /* Récupération du nom de fichier */ - -    entry = GTK_ENTRY(g_object_get_data(ref, "input_filename")); - -    filename = gtk_entry_get_text(entry); - -    /* Récupération du contenu binaire */ - -    content = g_file_content_new(filename); -    if (content == NULL) -    { -        push_status_printing_of_rop_search_step(ref, "loading", _("unable to get the binary content"), false); -        goto leffrg_error; -    } - -    push_status_printing_of_rop_search_step(ref, "loading", _("done"), true); - -    /* Récupération du format de fichier associé */ - -    status = find_matching_format(content, NULL, &target); - -    if (status != FMS_MATCHED) -    { -        g_object_unref(G_OBJECT(content)); -        push_status_printing_of_rop_search_step(ref, "format", _("unknown binary format"), false); -        goto leffrg_error; -    } - -    desc = get_binary_format_name(target); - -    result = G_EXE_FORMAT(load_new_named_format(target, content, NULL)); - -    free(target); - -    if (result == NULL) -    { -        push_status_printing_of_rop_search_step(ref, "format", _("error while loading the binary"), false); -        goto leffrg_error; -    } - -    push_status_printing_of_rop_search_step(ref, "format", desc, true); - -    return result; - - leffrg_error: - -    return NULL; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : ref = espace de référencements inter-panneaux.               * -*                                                                             *  *  Description : Procède à la recherche de gadgets de façon séparée.          *  *                                                                             *  *  Retour      : ?                                                            * @@ -1393,8 +1155,6 @@ static GExeFormat *load_external_format_for_rop_gadgets(GObject *ref)  static gpointer look_for_rop_gadgets(GObject *ref)  { -    GtkToggleButton *internal;              /* Bouton de sélection interne */ -    gboolean state;                         /* Etat du bouton courant      */      GExeFormat *format;                     /* Format du binaire à traiter */      found_rop_list *list;                   /* Liste de gadgets ROP trouvés*/      size_t count;                           /* Nombre de ces listes        */ @@ -1402,14 +1162,7 @@ static gpointer look_for_rop_gadgets(GObject *ref)      size_t i;                               /* Boucle de parcours          */      char *msg;                              /* Message final à faire passer*/ -    internal = GTK_TOGGLE_BUTTON(g_object_get_data(ref, "loaded_as_input")); -    state = gtk_toggle_button_get_active(internal); - -    if (state) -        format = load_internal_format_for_rop_gadgets(ref); -    else -        format = load_external_format_for_rop_gadgets(ref); - +    format = load_internal_format_for_rop_gadgets(ref);      if (format == NULL) goto lfrg_unlock;      list = list_all_gadgets(format, 7, push_new_progress_fraction, ref, &count);  | 
