diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2016-04-09 22:59:38 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2016-04-09 22:59:38 (GMT) |
commit | 5ad85cf30b2355ca727904d1a0d25240283813b3 (patch) | |
tree | 1e1fdce3b7be4bf878161b4e9001686dd0d89ba3 /src/analysis/binary.c | |
parent | 865be356c53afc3bdeae21c640bf0c3d5433fc4b (diff) |
Signed and verified the MD5 hash of a given user name.
Diffstat (limited to 'src/analysis/binary.c')
-rw-r--r-- | src/analysis/binary.c | 120 |
1 files changed, 112 insertions, 8 deletions
diff --git a/src/analysis/binary.c b/src/analysis/binary.c index d934c76..c71bc84 100644 --- a/src/analysis/binary.c +++ b/src/analysis/binary.c @@ -41,6 +41,7 @@ #include "disass/disassembler.h" #include "../common/extstr.h" #include "../common/cpp.h" +#include "../common/xdg.h" #include "../core/collections.h" #include "../core/formats.h" #include "../core/params.h" @@ -127,6 +128,12 @@ static bool g_loaded_binary_load_storage(GLoadedBinary *, xmlXPathContextPtr, co /* Ecrit les formes d'enregistrement du binaire dans du XML. */ static bool g_loaded_binary_save_storage(const GLoadedBinary *, xmlDocPtr, xmlXPathContextPtr, const char *); +/* Etablit une connexion au serveur interne en tant que client. */ +static bool g_loaded_binary_connect_internal(GLoadedBinary *); + +/* Etablit une connexion à un serveur distant comme client. */ +static bool g_loaded_binary_connect_remote(GLoadedBinary *); + /* -------------------------- MANIPULATION DES COLLECTIONS -------------------------- */ @@ -980,7 +987,7 @@ void g_loaded_binary_set_storage(GLoadedBinary *binary, DBFeatures feature, DBSt * * * Paramètres : binary = élément binaire à manipuler. * * * -* Description : Etablit une connexion à un serveur en tant que client. * +* Description : Etablit une connexion au serveur interne en tant que client. * * * * Retour : Bilan de l'opération. * * * @@ -988,44 +995,141 @@ void g_loaded_binary_set_storage(GLoadedBinary *binary, DBFeatures feature, DBSt * * ******************************************************************************/ -bool g_loaded_binary_connect(GLoadedBinary *binary) +static bool g_loaded_binary_connect_internal(GLoadedBinary *binary) { bool result; /* Bilan à retourner */ - + const char *tmp; /* Stockage temporaire */ + char *author; /* Identification à diffuser */ + char *priv; /* Chemin de la clef privée */ GBinContent *content; /* Contenu bianire manipulé */ const gchar *checksum; /* Identifiant de binaire */ + + char *host; /* Nom du serveur à contacter */ int port; /* Numéro du port associé */ - char *author; /* Identification à diffuser */ + result = false; + + /* Utilisateur représenté */ + + if (!g_generic_config_get_value(get_main_configuration(), MPK_AUTHOR_NAME, &tmp)) + goto glbcl_exit; + + author = strdup(tmp); + + /* Chemin vers la clef privée */ + + priv = get_xdg_config_dir("chrysalide" G_DIR_SEPARATOR_S "id_rsa.priv"); /* Détermination de l'identifiant */ + content = g_binary_format_get_content(G_BIN_FORMAT(binary->format)); checksum = g_binary_content_get_cheksum(content); g_object_unref(G_OBJECT(content)); - binary->local = g_db_client_new(g_loaded_binary_get_name(binary, false), + /* Tentative de connexion */ + + binary->local = g_db_client_new(author, priv, + g_loaded_binary_get_name(binary, false), checksum, binary->collections); + + if (!g_generic_config_get_value(get_main_configuration(), MPK_LOCAL_HOST, &host)) /* ... */; if (!g_generic_config_get_value(get_main_configuration(), MPK_LOCAL_PORT, &port)) /* ... */; - if (!g_generic_config_get_value(get_main_configuration(), MPK_AUTHOR_NAME, &author)) + + result = g_db_client_start(binary->local, host, port); + + printf("DB status :: %d\n", result); + + + glbcl_exit: + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : binary = élément binaire à manipuler. * +* * +* Description : Etablit une connexion à un serveur distant comme client. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static bool g_loaded_binary_connect_remote(GLoadedBinary *binary) +{ + bool result; /* Bilan à retourner */ + const char *tmp; /* Stockage temporaire */ + char *author; /* Identification à diffuser */ + char *priv; /* Chemin de la clef privée */ + GBinContent *content; /* Contenu bianire manipulé */ + const gchar *checksum; /* Identifiant de binaire */ + + + + char *host; /* Nom du serveur à contacter */ + int port; /* Numéro du port associé */ + + + + result = false; + + /* Utilisateur représenté */ + + if (!g_generic_config_get_value(get_main_configuration(), MPK_AUTHOR_NAME, &tmp)) + goto glbcl_exit; + + author = strdup(tmp); + + /* Chemin vers la clef privée */ + + priv = get_xdg_config_dir("chrysalide" G_DIR_SEPARATOR_S "id_rsa.priv"); + + /* Détermination de l'identifiant */ + + content = g_binary_format_get_content(G_BIN_FORMAT(binary->format)); + checksum = g_binary_content_get_cheksum(content); + g_object_unref(G_OBJECT(content)); + + /* Tentative de connexion */ + + binary->local = g_db_client_new(author, priv, + g_loaded_binary_get_name(binary, false), + checksum, + binary->collections); + + + + + if (!g_generic_config_get_value(get_main_configuration(), MPK_LOCAL_HOST, &host)) + /* ... */; + + if (!g_generic_config_get_value(get_main_configuration(), MPK_LOCAL_PORT, &port)) /* ... */; - result = g_db_client_start(binary->local, host, port, author); + result = g_db_client_start(binary->local, host, port); printf("DB status :: %d\n", result); + + glbcl_exit: + return result; } @@ -1519,7 +1623,7 @@ void ack_completed_disassembly(GDelayedDisassembly *disass, GLoadedBinary *binar g_object_unref(G_OBJECT(disass)); - g_loaded_binary_connect(binary); + /* ... = */g_loaded_binary_connect_internal(binary); /* Décompilation... */ |