summaryrefslogtreecommitdiff
path: root/plugins/apihashing/classics
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/apihashing/classics')
-rw-r--r--plugins/apihashing/classics/Makefile.am14
-rw-r--r--plugins/apihashing/classics/crc32.c332
-rw-r--r--plugins/apihashing/classics/crc32.h58
-rw-r--r--plugins/apihashing/classics/djb2.c323
-rw-r--r--plugins/apihashing/classics/djb2.h58
-rw-r--r--plugins/apihashing/classics/ror13.c323
-rw-r--r--plugins/apihashing/classics/ror13.h58
7 files changed, 1166 insertions, 0 deletions
diff --git a/plugins/apihashing/classics/Makefile.am b/plugins/apihashing/classics/Makefile.am
new file mode 100644
index 0000000..9f97b47
--- /dev/null
+++ b/plugins/apihashing/classics/Makefile.am
@@ -0,0 +1,14 @@
+
+noinst_LTLIBRARIES = libapihashingclassics.la
+
+libapihashingclassics_la_SOURCES = \
+ crc32.h crc32.c \
+ djb2.h djb2.c \
+ ror13.h ror13.c
+
+libapihashingclassics_la_CFLAGS = $(TOOLKIT_CFLAGS) $(LIBXML_CFLAGS) -I$(top_srcdir)/src
+
+
+devdir = $(includedir)/chrysalide-$(subdir)
+
+dev_HEADERS = $(libapihashingclassics_la_SOURCES:%c=)
diff --git a/plugins/apihashing/classics/crc32.c b/plugins/apihashing/classics/crc32.c
new file mode 100644
index 0000000..98f9a6b
--- /dev/null
+++ b/plugins/apihashing/classics/crc32.c
@@ -0,0 +1,332 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * crc32.c - transormation en empreinte d'API crc32
+ *
+ * Copyright (C) 2023 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide 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.
+ *
+ * Chrysalide 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 "crc32.h"
+
+
+#include <malloc.h>
+#include <string.h>
+
+
+#include <analysis/scan/patterns/modifier-int.h>
+
+
+
+
+/* ----------------------- RECHERCHE D'UN MOTIF DE TEXTE BRUT ----------------------- */
+
+
+/* Initialise la classe des transmissions en empreintes crc32. */
+static void g_scan_crc32_modifier_class_init(GScanCrc32ModifierClass *klass);
+
+/* Initialise une instance de transmission en empreinte crc32. */
+static void g_scan_crc32_modifier_init(GScanCrc32Modifier *);
+
+/* Supprime toutes les références externes. */
+static void g_scan_crc32_modifier_dispose(GScanCrc32Modifier *);
+
+/* Procède à la libération totale de la mémoire. */
+static void g_scan_crc32_modifier_finalize(GScanCrc32Modifier *);
+
+
+
+/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */
+
+
+/* Fournit le nom d'appel d'un modificateur pour motif. */
+static char *g_scan_crc32_modifier_get_name(const GScanCrc32Modifier *);
+
+/* Calcule l'empreinte crc32 d'un motif de recherche. */
+static uint32_t compute_crc32(const sized_binary_t *);
+
+/* Transforme une séquence d'octets pour motif de recherche. */
+static bool g_scan_crc32_modifier_transform(const GScanCrc32Modifier *, const sized_binary_t *, size_t, sized_binary_t **, size_t *);
+
+/* Retrouve l'origine d'une correspondance à partir d'un indice. */
+static char *g_scan_crc32_modifier_get_path(const GScanCrc32Modifier *, size_t *);
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* RECHERCHE D'UN MOTIF DE TEXTE BRUT */
+/* ---------------------------------------------------------------------------------- */
+
+
+/* Indique le type défini pour une transormation en encodage Crc32. */
+G_DEFINE_TYPE(GScanCrc32Modifier, g_scan_crc32_modifier, G_TYPE_API_HASH_MODIFIER);
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe des transmissions en empreintes crc32. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_crc32_modifier_class_init(GScanCrc32ModifierClass *klass)
+{
+ GObjectClass *object; /* Autre version de la classe */
+ GScanTokenModifierClass *modifier; /* Version de classe parente */
+
+ object = G_OBJECT_CLASS(klass);
+
+ object->dispose = (GObjectFinalizeFunc/* ! */)g_scan_crc32_modifier_dispose;
+ object->finalize = (GObjectFinalizeFunc)g_scan_crc32_modifier_finalize;
+
+ modifier = G_SCAN_TOKEN_MODIFIER_CLASS(klass);
+
+ modifier->get_name = (get_scan_modifier_name_fc)g_scan_crc32_modifier_get_name;
+
+ modifier->transform = (transform_scan_token_fc)g_scan_crc32_modifier_transform;
+ modifier->get_path = (get_modifier_path)g_scan_crc32_modifier_get_path;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = instance à initialiser. *
+* *
+* Description : Initialise une instance de transmission en empreinte crc32. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_crc32_modifier_init(GScanCrc32Modifier *modifier)
+{
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_crc32_modifier_dispose(GScanCrc32Modifier *modifier)
+{
+ G_OBJECT_CLASS(g_scan_crc32_modifier_parent_class)->dispose(G_OBJECT(modifier));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = instance d'objet GLib à traiter. *
+* *
+* Description : Procède à la libération totale de la mémoire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_crc32_modifier_finalize(GScanCrc32Modifier *modifier)
+{
+ G_OBJECT_CLASS(g_scan_crc32_modifier_parent_class)->finalize(G_OBJECT(modifier));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Construit un modificateur livrant des empreintes crc32. *
+* *
+* Retour : Mécanisme mis en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GScanTokenModifier *g_scan_crc32_modifier_new(void)
+{
+ GScanTokenModifier *result; /* Structure à retourner */
+
+ result = g_object_new(G_TYPE_SCAN_CRC32_MODIFIER, NULL);
+
+ return result;
+
+}
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* IMPLEMENTATION DES FONCTIONS DE CLASSE */
+/* ---------------------------------------------------------------------------------- */
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = modificateur à consulter. *
+* *
+* Description : Fournit le nom d'appel d'un modificateur pour motif. *
+* *
+* Retour : Désignation humaine. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static char *g_scan_crc32_modifier_get_name(const GScanCrc32Modifier *modifier)
+{
+ char *result; /* Désignation à retourner */
+
+ result = strdup("crc32");
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : src = séquence d'octets à traiter. *
+* *
+* Description : Calcule l'empreinte crc32 d'un motif de recherche. *
+* *
+* Retour : Valeur entière de l'empreinte déterminée. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static uint32_t compute_crc32(const sized_binary_t *src)
+{
+ uint32_t result; /* Valeur à retourner */
+ size_t i; /* Boucle de parcours #1 */
+ size_t k; /* Boucle de parcours #2 */
+
+ result = 0xffffffff;
+
+ for (i = 0; i < src->len; i++)
+ {
+ result ^= src->data[i];
+
+ for (k = 0; k < 8; k++)
+ result = result & 1 ? (result >> 1) ^ 0xedb88320 : result >> 1;
+
+ }
+
+ result = ~result;
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = modificateur à solliciter. *
+* src = séquences d'octets à traiter. *
+* scount = quantité de ces séquences. *
+* dest = nouvelle(s) séquence(s) d'octets obtenue(s) [OUT] *
+* dcount = quantité de ces séquences. *
+* *
+* Description : Transforme une séquence d'octets pour motif de recherche. *
+* *
+* Retour : Bilan de l'opération : succès ou échec. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool g_scan_crc32_modifier_transform(const GScanCrc32Modifier *modifier, const sized_binary_t *src, size_t scount, sized_binary_t **dest, size_t *dcount)
+{
+ bool result; /* Bilan d'opération à renvoyer*/
+ sized_binary_t *binary; /* Raccourci vers le stockage */
+ size_t i; /* Boucle de parcours #1 */
+ const sized_binary_t *_src; /* Source courante */
+ uint32_t hash; /* Valeur d'empreinte calculée */
+
+ result = true;
+
+ *dcount = scount;
+ *dest = calloc(*dcount, sizeof(sized_binary_t));
+
+ binary = &(*dest)[0];
+
+ for (i = 0; i < scount; i++, binary++)
+ {
+ _src = src + i;
+
+ hash = compute_crc32(_src);
+
+ binary->data = malloc(sizeof(hash) * sizeof(bin_t));
+ binary->len = sizeof(hash);
+
+ memcpy(binary->data, &hash, sizeof(hash));
+
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = modificateur à consulter. *
+* index = indice de la combinaison ciblée. [OUT] *
+* *
+* Description : Retrouve l'origine d'une correspondance à partir d'un indice.*
+* *
+* Retour : Version humainement lisible de la combinaison. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static char *g_scan_crc32_modifier_get_path(const GScanCrc32Modifier *modifier, size_t *index)
+{
+ char *result; /* Combinaison à retourner */
+
+ if (*index > 0)
+ {
+ result = NULL;
+ (*index)--;
+ }
+
+ else
+ result = strdup("crc32");
+
+ return result;
+
+}
diff --git a/plugins/apihashing/classics/crc32.h b/plugins/apihashing/classics/crc32.h
new file mode 100644
index 0000000..0198c5d
--- /dev/null
+++ b/plugins/apihashing/classics/crc32.h
@@ -0,0 +1,58 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * crc32.h - prototypes pour la transormation en empreinte d'API crc32
+ *
+ * Copyright (C) 2023 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide 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.
+ *
+ * Chrysalide 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_APIHASHING_CLASSICS_CRC32_H
+#define _PLUGINS_APIHASHING_CLASSICS_CRC32_H
+
+
+#include <glib-object.h>
+
+
+#include "../apihash.h"
+
+
+
+#define G_TYPE_SCAN_CRC32_MODIFIER g_scan_crc32_modifier_get_type()
+#define G_SCAN_CRC32_MODIFIER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_SCAN_CRC32_MODIFIER, GScanCrc32Modifier))
+#define G_IS_SCAN_CRC32_MODIFIER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_SCAN_CRC32_MODIFIER))
+#define G_SCAN_CRC32_MODIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_SCAN_CRC32_MODIFIER, GScanCrc32ModifierClass))
+#define G_IS_SCAN_CRC32_MODIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_SCAN_CRC32_MODIFIER))
+#define G_SCAN_CRC32_MODIFIER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_SCAN_CRC32_MODIFIER, GScanCrc32ModifierClass))
+
+
+/* Transormation en empreinte d'API crc32 (instance) */
+typedef GApiHashModifier GScanCrc32Modifier;
+
+/* Transormation en empreinte d'API crc32 (classe) */
+typedef GApiHashModifierClass GScanCrc32ModifierClass;
+
+
+/* Indique le type défini pour une transormation en empreinte crc32. */
+GType g_scan_crc32_modifier_get_type(void);
+
+/* Construit un modificateur livrant des empreintes crc32. */
+GScanTokenModifier *g_scan_crc32_modifier_new(void);
+
+
+
+#endif /* _PLUGINS_APIHASHING_CLASSICS_CRC32_H */
diff --git a/plugins/apihashing/classics/djb2.c b/plugins/apihashing/classics/djb2.c
new file mode 100644
index 0000000..524218f
--- /dev/null
+++ b/plugins/apihashing/classics/djb2.c
@@ -0,0 +1,323 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * djb2.c - transormation en empreinte d'API djb2
+ *
+ * Copyright (C) 2023 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide 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.
+ *
+ * Chrysalide 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 "djb2.h"
+
+
+#include <malloc.h>
+#include <string.h>
+
+
+#include <analysis/scan/patterns/modifier-int.h>
+
+
+
+
+/* ----------------------- RECHERCHE D'UN MOTIF DE TEXTE BRUT ----------------------- */
+
+
+/* Initialise la classe des transmissions en empreintes djb2. */
+static void g_scan_djb2_modifier_class_init(GScanDjb2ModifierClass *klass);
+
+/* Initialise une instance de transmission en empreinte djb2. */
+static void g_scan_djb2_modifier_init(GScanDjb2Modifier *);
+
+/* Supprime toutes les références externes. */
+static void g_scan_djb2_modifier_dispose(GScanDjb2Modifier *);
+
+/* Procède à la libération totale de la mémoire. */
+static void g_scan_djb2_modifier_finalize(GScanDjb2Modifier *);
+
+
+
+/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */
+
+
+/* Fournit le nom d'appel d'un modificateur pour motif. */
+static char *g_scan_djb2_modifier_get_name(const GScanDjb2Modifier *);
+
+/* Calcule l'empreinte djb2 d'un motif de recherche. */
+static uint32_t compute_djb2(const sized_binary_t *);
+
+/* Transforme une séquence d'octets pour motif de recherche. */
+static bool g_scan_djb2_modifier_transform(const GScanDjb2Modifier *, const sized_binary_t *, size_t, sized_binary_t **, size_t *);
+
+/* Retrouve l'origine d'une correspondance à partir d'un indice. */
+static char *g_scan_djb2_modifier_get_path(const GScanDjb2Modifier *, size_t *);
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* RECHERCHE D'UN MOTIF DE TEXTE BRUT */
+/* ---------------------------------------------------------------------------------- */
+
+
+/* Indique le type défini pour une transormation en encodage Djb2. */
+G_DEFINE_TYPE(GScanDjb2Modifier, g_scan_djb2_modifier, G_TYPE_API_HASH_MODIFIER);
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe des transmissions en empreintes djb2. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_djb2_modifier_class_init(GScanDjb2ModifierClass *klass)
+{
+ GObjectClass *object; /* Autre version de la classe */
+ GScanTokenModifierClass *modifier; /* Version de classe parente */
+
+ object = G_OBJECT_CLASS(klass);
+
+ object->dispose = (GObjectFinalizeFunc/* ! */)g_scan_djb2_modifier_dispose;
+ object->finalize = (GObjectFinalizeFunc)g_scan_djb2_modifier_finalize;
+
+ modifier = G_SCAN_TOKEN_MODIFIER_CLASS(klass);
+
+ modifier->get_name = (get_scan_modifier_name_fc)g_scan_djb2_modifier_get_name;
+
+ modifier->transform = (transform_scan_token_fc)g_scan_djb2_modifier_transform;
+ modifier->get_path = (get_modifier_path)g_scan_djb2_modifier_get_path;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = instance à initialiser. *
+* *
+* Description : Initialise une instance de transmission en empreinte djb2. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_djb2_modifier_init(GScanDjb2Modifier *modifier)
+{
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_djb2_modifier_dispose(GScanDjb2Modifier *modifier)
+{
+ G_OBJECT_CLASS(g_scan_djb2_modifier_parent_class)->dispose(G_OBJECT(modifier));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = instance d'objet GLib à traiter. *
+* *
+* Description : Procède à la libération totale de la mémoire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_djb2_modifier_finalize(GScanDjb2Modifier *modifier)
+{
+ G_OBJECT_CLASS(g_scan_djb2_modifier_parent_class)->finalize(G_OBJECT(modifier));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Construit un modificateur livrant des empreintes djb2. *
+* *
+* Retour : Mécanisme mis en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GScanTokenModifier *g_scan_djb2_modifier_new(void)
+{
+ GScanTokenModifier *result; /* Structure à retourner */
+
+ result = g_object_new(G_TYPE_SCAN_DJB2_MODIFIER, NULL);
+
+ return result;
+
+}
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* IMPLEMENTATION DES FONCTIONS DE CLASSE */
+/* ---------------------------------------------------------------------------------- */
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = modificateur à consulter. *
+* *
+* Description : Fournit le nom d'appel d'un modificateur pour motif. *
+* *
+* Retour : Désignation humaine. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static char *g_scan_djb2_modifier_get_name(const GScanDjb2Modifier *modifier)
+{
+ char *result; /* Désignation à retourner */
+
+ result = strdup("djb2");
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : src = séquence d'octets à traiter. *
+* *
+* Description : Calcule l'empreinte djb2 d'un motif de recherche. *
+* *
+* Retour : Valeur entière de l'empreinte déterminée. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static uint32_t compute_djb2(const sized_binary_t *src)
+{
+ uint32_t result; /* Valeur à retourner */
+ size_t i; /* Boucle de parcours */
+
+ result = 0x1505; /* 5381 */
+
+ for (i = 0; i < src->len; i++)
+ result = ((result << 5) + result) + src->data[i]; /* hash * 33 + c */
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = modificateur à solliciter. *
+* src = séquences d'octets à traiter. *
+* scount = quantité de ces séquences. *
+* dest = nouvelle(s) séquence(s) d'octets obtenue(s) [OUT] *
+* dcount = quantité de ces séquences. *
+* *
+* Description : Transforme une séquence d'octets pour motif de recherche. *
+* *
+* Retour : Bilan de l'opération : succès ou échec. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool g_scan_djb2_modifier_transform(const GScanDjb2Modifier *modifier, const sized_binary_t *src, size_t scount, sized_binary_t **dest, size_t *dcount)
+{
+ bool result; /* Bilan d'opération à renvoyer*/
+ sized_binary_t *binary; /* Raccourci vers le stockage */
+ size_t i; /* Boucle de parcours #1 */
+ const sized_binary_t *_src; /* Source courante */
+ uint32_t hash; /* Valeur d'empreinte calculée */
+
+ result = true;
+
+ *dcount = scount;
+ *dest = calloc(*dcount, sizeof(sized_binary_t));
+
+ binary = &(*dest)[0];
+
+ for (i = 0; i < scount; i++, binary++)
+ {
+ _src = src + i;
+
+ hash = compute_djb2(_src);
+
+ binary->data = malloc(sizeof(hash) * sizeof(bin_t));
+ binary->len = sizeof(hash);
+
+ memcpy(binary->data, &hash, sizeof(hash));
+
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = modificateur à consulter. *
+* index = indice de la combinaison ciblée. [OUT] *
+* *
+* Description : Retrouve l'origine d'une correspondance à partir d'un indice.*
+* *
+* Retour : Version humainement lisible de la combinaison. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static char *g_scan_djb2_modifier_get_path(const GScanDjb2Modifier *modifier, size_t *index)
+{
+ char *result; /* Combinaison à retourner */
+
+ if (*index > 0)
+ {
+ result = NULL;
+ (*index)--;
+ }
+
+ else
+ result = strdup("djb2");
+
+ return result;
+
+}
diff --git a/plugins/apihashing/classics/djb2.h b/plugins/apihashing/classics/djb2.h
new file mode 100644
index 0000000..04df1df
--- /dev/null
+++ b/plugins/apihashing/classics/djb2.h
@@ -0,0 +1,58 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * djb2.h - prototypes pour la transormation en empreinte d'API djb2
+ *
+ * Copyright (C) 2023 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide 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.
+ *
+ * Chrysalide 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_APIHASHING_CLASSICS_DJB2_H
+#define _PLUGINS_APIHASHING_CLASSICS_DJB2_H
+
+
+#include <glib-object.h>
+
+
+#include "../apihash.h"
+
+
+
+#define G_TYPE_SCAN_DJB2_MODIFIER g_scan_djb2_modifier_get_type()
+#define G_SCAN_DJB2_MODIFIER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_SCAN_DJB2_MODIFIER, GScanDjb2Modifier))
+#define G_IS_SCAN_DJB2_MODIFIER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_SCAN_DJB2_MODIFIER))
+#define G_SCAN_DJB2_MODIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_SCAN_DJB2_MODIFIER, GScanDjb2ModifierClass))
+#define G_IS_SCAN_DJB2_MODIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_SCAN_DJB2_MODIFIER))
+#define G_SCAN_DJB2_MODIFIER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_SCAN_DJB2_MODIFIER, GScanDjb2ModifierClass))
+
+
+/* Transormation en empreinte d'API DJB2 (instance) */
+typedef GApiHashModifier GScanDjb2Modifier;
+
+/* Transormation en empreinte d'API DJB2 (classe) */
+typedef GApiHashModifierClass GScanDjb2ModifierClass;
+
+
+/* Indique le type défini pour une transormation en empreinte djb2. */
+GType g_scan_djb2_modifier_get_type(void);
+
+/* Construit un modificateur livrant des empreintes djb2. */
+GScanTokenModifier *g_scan_djb2_modifier_new(void);
+
+
+
+#endif /* _PLUGINS_APIHASHING_CLASSICS_DJB2_H */
diff --git a/plugins/apihashing/classics/ror13.c b/plugins/apihashing/classics/ror13.c
new file mode 100644
index 0000000..e557804
--- /dev/null
+++ b/plugins/apihashing/classics/ror13.c
@@ -0,0 +1,323 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * ror13.c - transormation en empreinte d'API ror13
+ *
+ * Copyright (C) 2023 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide 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.
+ *
+ * Chrysalide 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 "ror13.h"
+
+
+#include <malloc.h>
+#include <string.h>
+
+
+#include <analysis/scan/patterns/modifier-int.h>
+
+
+
+
+/* ----------------------- RECHERCHE D'UN MOTIF DE TEXTE BRUT ----------------------- */
+
+
+/* Initialise la classe des transmissions en empreintes ror13. */
+static void g_scan_ror13_modifier_class_init(GScanRor13ModifierClass *klass);
+
+/* Initialise une instance de transmission en empreinte ror13. */
+static void g_scan_ror13_modifier_init(GScanRor13Modifier *);
+
+/* Supprime toutes les références externes. */
+static void g_scan_ror13_modifier_dispose(GScanRor13Modifier *);
+
+/* Procède à la libération totale de la mémoire. */
+static void g_scan_ror13_modifier_finalize(GScanRor13Modifier *);
+
+
+
+/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */
+
+
+/* Fournit le nom d'appel d'un modificateur pour motif. */
+static char *g_scan_ror13_modifier_get_name(const GScanRor13Modifier *);
+
+/* Calcule l'empreinte ror13 d'un motif de recherche. */
+static uint32_t compute_ror13(const sized_binary_t *);
+
+/* Transforme une séquence d'octets pour motif de recherche. */
+static bool g_scan_ror13_modifier_transform(const GScanRor13Modifier *, const sized_binary_t *, size_t, sized_binary_t **, size_t *);
+
+/* Retrouve l'origine d'une correspondance à partir d'un indice. */
+static char *g_scan_ror13_modifier_get_path(const GScanRor13Modifier *, size_t *);
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* RECHERCHE D'UN MOTIF DE TEXTE BRUT */
+/* ---------------------------------------------------------------------------------- */
+
+
+/* Indique le type défini pour une transormation en empreinte ror13. */
+G_DEFINE_TYPE(GScanRor13Modifier, g_scan_ror13_modifier, G_TYPE_API_HASH_MODIFIER);
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe des transmissions en empreintes ror13. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_ror13_modifier_class_init(GScanRor13ModifierClass *klass)
+{
+ GObjectClass *object; /* Autre version de la classe */
+ GScanTokenModifierClass *modifier; /* Version de classe parente */
+
+ object = G_OBJECT_CLASS(klass);
+
+ object->dispose = (GObjectFinalizeFunc/* ! */)g_scan_ror13_modifier_dispose;
+ object->finalize = (GObjectFinalizeFunc)g_scan_ror13_modifier_finalize;
+
+ modifier = G_SCAN_TOKEN_MODIFIER_CLASS(klass);
+
+ modifier->get_name = (get_scan_modifier_name_fc)g_scan_ror13_modifier_get_name;
+
+ modifier->transform = (transform_scan_token_fc)g_scan_ror13_modifier_transform;
+ modifier->get_path = (get_modifier_path)g_scan_ror13_modifier_get_path;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = instance à initialiser. *
+* *
+* Description : Initialise une instance de transmission en empreinte ror13. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_ror13_modifier_init(GScanRor13Modifier *modifier)
+{
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_ror13_modifier_dispose(GScanRor13Modifier *modifier)
+{
+ G_OBJECT_CLASS(g_scan_ror13_modifier_parent_class)->dispose(G_OBJECT(modifier));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = instance d'objet GLib à traiter. *
+* *
+* Description : Procède à la libération totale de la mémoire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_ror13_modifier_finalize(GScanRor13Modifier *modifier)
+{
+ G_OBJECT_CLASS(g_scan_ror13_modifier_parent_class)->finalize(G_OBJECT(modifier));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Construit un modificateur livrant des empreintes ror13. *
+* *
+* Retour : Mécanisme mis en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GScanTokenModifier *g_scan_ror13_modifier_new(void)
+{
+ GScanTokenModifier *result; /* Structure à retourner */
+
+ result = g_object_new(G_TYPE_SCAN_ROR13_MODIFIER, NULL);
+
+ return result;
+
+}
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* IMPLEMENTATION DES FONCTIONS DE CLASSE */
+/* ---------------------------------------------------------------------------------- */
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = modificateur à consulter. *
+* *
+* Description : Fournit le nom d'appel d'un modificateur pour motif. *
+* *
+* Retour : Désignation humaine. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static char *g_scan_ror13_modifier_get_name(const GScanRor13Modifier *modifier)
+{
+ char *result; /* Désignation à retourner */
+
+ result = strdup("ror13");
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : src = séquence d'octets à traiter. *
+* *
+* Description : Calcule l'empreinte ror13 d'un motif de recherche. *
+* *
+* Retour : Valeur entière de l'empreinte déterminée. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static uint32_t compute_ror13(const sized_binary_t *src)
+{
+ uint32_t result; /* Valeur à retourner */
+ size_t i; /* Boucle de parcours */
+
+ result = 0;
+
+ for (i = 0; i < src->len; i++)
+ result = src->data[i] + ((result << 19) | (result >> 13));
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = modificateur à solliciter. *
+* src = séquences d'octets à traiter. *
+* scount = quantité de ces séquences. *
+* dest = nouvelle(s) séquence(s) d'octets obtenue(s) [OUT] *
+* dcount = quantité de ces séquences. *
+* *
+* Description : Transforme une séquence d'octets pour motif de recherche. *
+* *
+* Retour : Bilan de l'opération : succès ou échec. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool g_scan_ror13_modifier_transform(const GScanRor13Modifier *modifier, const sized_binary_t *src, size_t scount, sized_binary_t **dest, size_t *dcount)
+{
+ bool result; /* Bilan d'opération à renvoyer*/
+ sized_binary_t *binary; /* Raccourci vers le stockage */
+ size_t i; /* Boucle de parcours #1 */
+ const sized_binary_t *_src; /* Source courante */
+ uint32_t hash; /* Valeur d'empreinte calculée */
+
+ result = true;
+
+ *dcount = scount;
+ *dest = calloc(*dcount, sizeof(sized_binary_t));
+
+ binary = &(*dest)[0];
+
+ for (i = 0; i < scount; i++, binary++)
+ {
+ _src = src + i;
+
+ hash = compute_ror13(_src);
+
+ binary->data = malloc(sizeof(hash) * sizeof(bin_t));
+ binary->len = sizeof(hash);
+
+ memcpy(binary->data, &hash, sizeof(hash));
+
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = modificateur à consulter. *
+* index = indice de la combinaison ciblée. [OUT] *
+* *
+* Description : Retrouve l'origine d'une correspondance à partir d'un indice.*
+* *
+* Retour : Version humainement lisible de la combinaison. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static char *g_scan_ror13_modifier_get_path(const GScanRor13Modifier *modifier, size_t *index)
+{
+ char *result; /* Combinaison à retourner */
+
+ if (*index > 0)
+ {
+ result = NULL;
+ (*index)--;
+ }
+
+ else
+ result = strdup("ror13");
+
+ return result;
+
+}
diff --git a/plugins/apihashing/classics/ror13.h b/plugins/apihashing/classics/ror13.h
new file mode 100644
index 0000000..43480bd
--- /dev/null
+++ b/plugins/apihashing/classics/ror13.h
@@ -0,0 +1,58 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * ror13.h - prototypes pour la transormation en empreinte d'API ror13
+ *
+ * Copyright (C) 2023 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide 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.
+ *
+ * Chrysalide 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_APIHASHING_CLASSICS_ROR13_H
+#define _PLUGINS_APIHASHING_CLASSICS_ROR13_H
+
+
+#include <glib-object.h>
+
+
+#include "../apihash.h"
+
+
+
+#define G_TYPE_SCAN_ROR13_MODIFIER g_scan_ror13_modifier_get_type()
+#define G_SCAN_ROR13_MODIFIER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_SCAN_ROR13_MODIFIER, GScanRor13Modifier))
+#define G_IS_SCAN_ROR13_MODIFIER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_SCAN_ROR13_MODIFIER))
+#define G_SCAN_ROR13_MODIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_SCAN_ROR13_MODIFIER, GScanRor13ModifierClass))
+#define G_IS_SCAN_ROR13_MODIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_SCAN_ROR13_MODIFIER))
+#define G_SCAN_ROR13_MODIFIER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_SCAN_ROR13_MODIFIER, GScanRor13ModifierClass))
+
+
+/* Transormation en empreinte d'API ror13 (instance) */
+typedef GApiHashModifier GScanRor13Modifier;
+
+/* Transormation en empreinte d'API ror13 (classe) */
+typedef GApiHashModifierClass GScanRor13ModifierClass;
+
+
+/* Indique le type défini pour une transormation en empreinte ror13. */
+GType g_scan_ror13_modifier_get_type(void);
+
+/* Construit un modificateur livrant des empreintes ror13. */
+GScanTokenModifier *g_scan_ror13_modifier_new(void);
+
+
+
+#endif /* _PLUGINS_APIHASHING_CLASSICS_ROR13_H */