main + obfuscations
This commit is contained in:
parent
5378e7ad26
commit
6d8cf617a5
2 changed files with 196 additions and 175 deletions
3
.clang-format
Normal file
3
.clang-format
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
IndentWidth: 4
|
||||||
|
ColumnLimit: 80
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
#pragma clang diagnostic ignored "-Wwritable-strings"
|
#pragma clang diagnostic ignored "-Wwritable-strings"
|
||||||
#include "stdafx.h" // IWYU pragma: keep
|
#include "stdafx.h" // IWYU pragma: keep
|
||||||
#include "functions.h"
|
|
||||||
#include "lonesha256.h"
|
|
||||||
#include "tables_poly.h"
|
|
||||||
#include "encryption.h"
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "encryption.h"
|
||||||
|
#include "functions.h"
|
||||||
|
#include "lonesha256.h"
|
||||||
|
#include "tables_poly.h"
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -76,8 +77,10 @@ int fakemain(int argc, wchar_t *argv[]) {
|
||||||
Obfuscated_stdFunclist *stdfunclist = new Obfuscated_stdFunclist();
|
Obfuscated_stdFunclist *stdfunclist = new Obfuscated_stdFunclist();
|
||||||
|
|
||||||
FuncList list = {this_is_useful_fr_dont_miss_it, cmp_hash};
|
FuncList list = {this_is_useful_fr_dont_miss_it, cmp_hash};
|
||||||
// char* encoded = "Salut a tous les amis, gg pour avoir dechiffre ce string";
|
// char* encoded = "Salut a tous les amis, gg pour avoir dechiffre ce
|
||||||
char *encoded = "\x64\x55\x56\x41\x43\x14\x56\x13\x46\x5b\x47\x40\x14\x5e\x52"
|
// string";
|
||||||
|
char *encoded =
|
||||||
|
"\x64\x55\x56\x41\x43\x14\x56\x13\x46\x5b\x47\x40\x14\x5e\x52"
|
||||||
"\x47\x13\x56\x5e\x5d\x40\x1f\x13\x53\x54\x14\x42\x5b\x41\x40"
|
"\x47\x13\x56\x5e\x5d\x40\x1f\x13\x53\x54\x14\x42\x5b\x41\x40"
|
||||||
"\x13\x53\x47\x58\x5d\x46\x14\x53\x51\x54\x5b\x5b\x52\x54\x41"
|
"\x13\x53\x47\x58\x5d\x46\x14\x53\x51\x54\x5b\x5b\x52\x54\x41"
|
||||||
"\x51\x12\x54\x51\x13\x44\x47\x46\x5a\x5d\x54";
|
"\x51\x12\x54\x51\x13\x44\x47\x46\x5a\x5d\x54";
|
||||||
|
|
@ -103,7 +106,19 @@ int fakemain(int argc, wchar_t *argv[]) {
|
||||||
* MOTEUR D'OBFUSCATION BRANCHLESS (POINT-FUNCTION OBFUSCATION)
|
* MOTEUR D'OBFUSCATION BRANCHLESS (POINT-FUNCTION OBFUSCATION)
|
||||||
* ==============================================================================
|
* ==============================================================================
|
||||||
*/
|
*/
|
||||||
|
typedef struct {
|
||||||
|
uint8_t (*evaluate_polynomial)(uint8_t x, const uint8_t coeffs[8]);
|
||||||
|
void *(*memcpy)(void *__restrict __dest, const void *__restrict __src,
|
||||||
|
size_t __n);
|
||||||
|
int (*lonesha256)(unsigned char out[32], const unsigned char *in,
|
||||||
|
size_t len);
|
||||||
|
} FuncList2;
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
// Init des struct d'obfuscation d'appel de fonction
|
||||||
|
Obfuscated_stdFunclist *stdfunclist = new Obfuscated_stdFunclist();
|
||||||
|
FuncList2 list = {evaluate_polynomial, memcpy, lonesha256};
|
||||||
|
|
||||||
if (argc < 2 || strlen(argv[1]) > 8) {
|
if (argc < 2 || strlen(argv[1]) > 8) {
|
||||||
printf("Arguments invalides.\n");
|
printf("Arguments invalides.\n");
|
||||||
return 1;
|
return 1;
|
||||||
|
|
@ -112,7 +127,7 @@ int main(int argc, char *argv[]) {
|
||||||
fakemain(argc, (wchar_t **)argv);
|
fakemain(argc, (wchar_t **)argv);
|
||||||
|
|
||||||
uint8_t input[8];
|
uint8_t input[8];
|
||||||
memcpy(input, argv[1], 8);
|
list.memcpy(input, argv[1], 8);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------
|
||||||
* 1. EXPANSION SPATIALE (FORWARD-COMPUTATION)
|
* 1. EXPANSION SPATIALE (FORWARD-COMPUTATION)
|
||||||
|
|
@ -124,8 +139,8 @@ int main(int argc, char *argv[]) {
|
||||||
* S_{c, i+1} = P_{c, i}(S_{c, i} \oplus x_i)
|
* S_{c, i+1} = P_{c, i}(S_{c, i} \oplus x_i)
|
||||||
* où:
|
* où:
|
||||||
* - c : Index de la chaîne d'évaluation parallèle (de 0 à 7).
|
* - c : Index de la chaîne d'évaluation parallèle (de 0 à 7).
|
||||||
* - i : Index du caractère de l'entrée en cours de traitement (de 0 à
|
* - i : Index du caractère de l'entrée en cours de traitement (de 0
|
||||||
* 7).
|
* à 7).
|
||||||
* - S_{c, i} : État interne de la chaîne 'c' à l'étape 'i'.
|
* - S_{c, i} : État interne de la chaîne 'c' à l'étape 'i'.
|
||||||
* - x_i : i-ème octet (caractère) de l'entrée fournie.
|
* - x_i : i-ème octet (caractère) de l'entrée fournie.
|
||||||
* - P_{c, i} : Polynôme de transition aléatoire sur GF(2^8) spécifique à
|
* - P_{c, i} : Polynôme de transition aléatoire sur GF(2^8) spécifique à
|
||||||
|
|
@ -138,7 +153,8 @@ int main(int argc, char *argv[]) {
|
||||||
uint8_t state = INITIAL_STATES[c];
|
uint8_t state = INITIAL_STATES[c];
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
// Mélange non-linéaire du caractère d'entrée avec l'état courant
|
// Mélange non-linéaire du caractère d'entrée avec l'état courant
|
||||||
state = evaluate_polynomial(state ^ input[i], POLY_COEFFS[c][i]);
|
state =
|
||||||
|
list.evaluate_polynomial(state ^ input[i], POLY_COEFFS[c][i]);
|
||||||
// Capture de la trace pour former le bloc final
|
// Capture de la trace pour former le bloc final
|
||||||
super_bloc[c * 8 + i] = state;
|
super_bloc[c * 8 + i] = state;
|
||||||
}
|
}
|
||||||
|
|
@ -150,7 +166,7 @@ int main(int argc, char *argv[]) {
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
unsigned char h1[32];
|
unsigned char h1[32];
|
||||||
lonesha256(h1, super_bloc, 64);
|
list.lonesha256(h1, super_bloc, 64);
|
||||||
|
|
||||||
// Accumulation des erreurs bit-à-bit par rapport à la cible cryptographique
|
// Accumulation des erreurs bit-à-bit par rapport à la cible cryptographique
|
||||||
// Diff = \bigvee_{k=0}^{31} (H_1[k] ^ H_{cible}[k])
|
// Diff = \bigvee_{k=0}^{31} (H_1[k] ^ H_{cible}[k])
|
||||||
|
|
@ -179,12 +195,14 @@ int main(int argc, char *argv[]) {
|
||||||
/* --------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------
|
||||||
* 4. DÉRIVATION DE LA CLÉ DE LEURRE (COMPORTEMENT GOODWARE)
|
* 4. DÉRIVATION DE LA CLÉ DE LEURRE (COMPORTEMENT GOODWARE)
|
||||||
* K_G = SHA256(L)_{[0..7]} où L est une chaîne d'apparence inoffensive.
|
* K_G = SHA256(L)_{[0..7]} où L est une chaîne d'apparence inoffensive.
|
||||||
* Permet une indistinguabilité totale lors d'une analyse statique (strings).
|
* Permet une indistinguabilité totale lors d'une analyse statique
|
||||||
|
* (strings).
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
unsigned char leurre[] = "Microsoft_CRT_Initialization";
|
unsigned char leurre[] = "Microsoft_CRT_Initialization";
|
||||||
unsigned char h_leurre[32];
|
unsigned char h_leurre[32];
|
||||||
lonesha256(h_leurre, leurre, 28); // K_G correspond aux 8 premiers octets
|
list.lonesha256(h_leurre, leurre,
|
||||||
|
28); // K_G correspond aux 8 premiers octets
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------
|
||||||
* 5. SÉPARATION DES DOMAINES (DOMAIN SEPARATION)
|
* 5. SÉPARATION DES DOMAINES (DOMAIN SEPARATION)
|
||||||
|
|
@ -196,11 +214,11 @@ int main(int argc, char *argv[]) {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
unsigned char buffer_h2[74]; // 64 octets (SB) + 10 octets (Sel)
|
unsigned char buffer_h2[74]; // 64 octets (SB) + 10 octets (Sel)
|
||||||
memcpy(buffer_h2, super_bloc, 64);
|
list.memcpy(buffer_h2, super_bloc, 64);
|
||||||
memcpy(buffer_h2 + 64, "DERIVATION", 10);
|
list.memcpy(buffer_h2 + 64, "DERIVATION", 10);
|
||||||
|
|
||||||
unsigned char h2[32];
|
unsigned char h2[32];
|
||||||
lonesha256(h2, buffer_h2, 74);
|
list.lonesha256(h2, buffer_h2, 74);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------
|
||||||
* 6. RÉSOLUTION ALGÉBRIQUE ET DÉCHIFFREMENT
|
* 6. RÉSOLUTION ALGÉBRIQUE ET DÉCHIFFREMENT
|
||||||
|
|
@ -230,7 +248,7 @@ int main(int argc, char *argv[]) {
|
||||||
* 7. EXÉCUTION DU PAYLOAD DÉCHIFFRÉ
|
* 7. EXÉCUTION DU PAYLOAD DÉCHIFFRÉ
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
printf((char *)payload, argv[1]);
|
stdfunclist->obfusc_printf((char *)payload, argv[1]);
|
||||||
|
|
||||||
// Boucle infinie demandée pour suspendre le processus
|
// Boucle infinie demandée pour suspendre le processus
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue