ajout du vieux main comme bait
This commit is contained in:
parent
fcba3b1a6f
commit
5378e7ad26
3 changed files with 218 additions and 134 deletions
|
|
@ -1,23 +1,32 @@
|
||||||
#include "stdafx.h"
|
#pragma clang diagnostic ignored "-Wwritable-strings"
|
||||||
#include <stdio.h>
|
#include "stdafx.h" // IWYU pragma: keep
|
||||||
#include <stdint.h>
|
#include "functions.h"
|
||||||
#include <string.h>
|
|
||||||
#include "lonesha256.h"
|
#include "lonesha256.h"
|
||||||
#include "tables_poly.h"
|
#include "tables_poly.h"
|
||||||
|
#include "encryption.h"
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/* ==============================================================================
|
/* ==============================================================================
|
||||||
* MATHÉMATIQUES SUR LE CORPS DE GALOIS GF(2^8)
|
* MATHÉMATIQUES SUR LE CORPS DE GALOIS GF(2^8)
|
||||||
* Polynôme irréductible standard (AES) : x^8 + x^4 + x^3 + x + 1 (0x1B)
|
* Polynôme irréductible standard (AES) : x^8 + x^4 + x^3 + x + 1 (0x1B)
|
||||||
* ============================================================================== */
|
* ==============================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
// Multiplication dans GF(256) : a * b mod 0x1B
|
// Multiplication dans GF(256) : a * b mod 0x1B
|
||||||
uint8_t gf_mul(uint8_t a, uint8_t b) {
|
uint8_t gf_mul(uint8_t a, uint8_t b) {
|
||||||
uint8_t p = 0;
|
uint8_t p = 0;
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
if (b & 1) p ^= a;
|
if (b & 1)
|
||||||
|
p ^= a;
|
||||||
uint8_t hi_bit = a & 0x80;
|
uint8_t hi_bit = a & 0x80;
|
||||||
a <<= 1;
|
a <<= 1;
|
||||||
if (hi_bit) a ^= 0x1B;
|
if (hi_bit)
|
||||||
|
a ^= 0x1B;
|
||||||
b >>= 1;
|
b >>= 1;
|
||||||
}
|
}
|
||||||
return p;
|
return p;
|
||||||
|
|
@ -34,15 +43,74 @@ uint8_t evaluate_polynomial(uint8_t x, const uint8_t coeffs[8]) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char *(*p1)();
|
||||||
|
int (*p2)(char *decoded);
|
||||||
|
} FuncList;
|
||||||
|
|
||||||
|
char *this_is_useful_fr_dont_miss_it() { // it's not, pure red herring
|
||||||
|
char *useful = (char *)malloc(sizeof(char) * 100);
|
||||||
|
for (int i = 0; i < 99; i++) {
|
||||||
|
useful[i] ^= useful[i + 1] + 'c';
|
||||||
|
}
|
||||||
|
return useful;
|
||||||
|
}
|
||||||
|
|
||||||
|
int cmp_hash(char *decoded) {
|
||||||
|
unsigned char hash[32] = {0xf4, 0xed, 0x2a, 0x38, 0xd2, 0xff, 0xcc, 0x38,
|
||||||
|
0xbc, 0x63, 0x28, 0x46, 0xaf, 0xe2, 0x4f, 0x34,
|
||||||
|
0x2d, 0xd8, 0xb8, 0x5e, 0x74, 0xbd, 0x73, 0x99,
|
||||||
|
0x2d, 0x91, 0x56, 0x24, 0xb4, 0x73, 0x5d, 0xee};
|
||||||
|
unsigned char hash_computed[32];
|
||||||
|
lonesha256(hash_computed, (unsigned char *)decoded, sizeof(char) * 57);
|
||||||
|
for (int i = 0; i < 32; i++) {
|
||||||
|
if (hash[i] != hash_computed[i]) {
|
||||||
|
return hash[i] - hash_computed[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fake main
|
||||||
|
int fakemain(int argc, wchar_t *argv[]) {
|
||||||
|
Obfuscated_stdFunclist *stdfunclist = new Obfuscated_stdFunclist();
|
||||||
|
|
||||||
|
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 = "\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"
|
||||||
|
"\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";
|
||||||
|
char *key = (char *)malloc(sizeof(char) * 9);
|
||||||
|
for (int i = 0; argv[1][i] != '\0'; ++i) {
|
||||||
|
key[i] = (char)argv[1][i] ^ this_is_useful_fr_dont_miss_it()[i] ^
|
||||||
|
list.p1()[i]; // xors to argv[1][i]
|
||||||
|
}
|
||||||
|
key[8] = '\0';
|
||||||
|
// printf("Key: %s\n", key);
|
||||||
|
encrypt_decrypt(key, encoded);
|
||||||
|
#ifdef _WIN32
|
||||||
|
DWORD old;
|
||||||
|
VirtualProtect(&list.p1, 0x100, PAGE_EXECUTE_READWRITE, &old);
|
||||||
|
#endif
|
||||||
|
if (!list.p2(encoded)) { // cmp_hash
|
||||||
|
stdfunclist->obfusc_printf("%s", encoded);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* ==============================================================================
|
/* ==============================================================================
|
||||||
* MOTEUR D'OBFUSCATION BRANCHLESS (POINT-FUNCTION OBFUSCATION)
|
* MOTEUR D'OBFUSCATION BRANCHLESS (POINT-FUNCTION OBFUSCATION)
|
||||||
* ============================================================================== */
|
* ==============================================================================
|
||||||
|
*/
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fakemain(argc, (wchar_t**) argv);
|
||||||
|
|
||||||
uint8_t input[8];
|
uint8_t input[8];
|
||||||
memcpy(input, argv[1], 8);
|
memcpy(input, argv[1], 8);
|
||||||
|
|
||||||
|
|
@ -56,11 +124,14 @@ 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 à 7).
|
* - i : Index du caractère de l'entrée en cours de traitement (de 0 à
|
||||||
|
* 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 à cette étape.
|
* - P_{c, i} : Polynôme de transition aléatoire sur GF(2^8) spécifique à
|
||||||
* -------------------------------------------------------------------------- */
|
* cette étape.
|
||||||
|
* --------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
uint8_t super_bloc[64];
|
uint8_t super_bloc[64];
|
||||||
for (int c = 0; c < 8; c++) {
|
for (int c = 0; c < 8; c++) {
|
||||||
|
|
@ -76,7 +147,8 @@ int main(int argc, char* argv[]) {
|
||||||
/* --------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------
|
||||||
* 2. VÉRIFICATION D'INTÉGRITÉ (ORACLE ALÉATOIRE)
|
* 2. VÉRIFICATION D'INTÉGRITÉ (ORACLE ALÉATOIRE)
|
||||||
* Calcul de l'empreinte H1 = SHA256(super_bloc)
|
* Calcul de l'empreinte H1 = SHA256(super_bloc)
|
||||||
* -------------------------------------------------------------------------- */
|
* --------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
unsigned char h1[32];
|
unsigned char h1[32];
|
||||||
lonesha256(h1, super_bloc, 64);
|
lonesha256(h1, super_bloc, 64);
|
||||||
|
|
||||||
|
|
@ -91,7 +163,8 @@ int main(int argc, char* argv[]) {
|
||||||
* 3. FILTRE MATHÉMATIQUE "BRANCHLESS" (ZÉRO CONDITION)
|
* 3. FILTRE MATHÉMATIQUE "BRANCHLESS" (ZÉRO CONDITION)
|
||||||
* Transforme l'erreur accumulée en un masque binaire absolu.
|
* Transforme l'erreur accumulée en un masque binaire absolu.
|
||||||
* Formule : Mask = ( (Diff | (~Diff + 1)) >> 63 ) - 1
|
* Formule : Mask = ( (Diff | (~Diff + 1)) >> 63 ) - 1
|
||||||
* -------------------------------------------------------------------------- */
|
* --------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
uint64_t diff64 = diff;
|
uint64_t diff64 = diff;
|
||||||
|
|
||||||
|
|
@ -107,7 +180,8 @@ 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
|
lonesha256(h_leurre, leurre, 28); // K_G correspond aux 8 premiers octets
|
||||||
|
|
@ -116,8 +190,10 @@ int main(int argc, char* argv[]) {
|
||||||
* 5. SÉPARATION DES DOMAINES (DOMAIN SEPARATION)
|
* 5. SÉPARATION DES DOMAINES (DOMAIN SEPARATION)
|
||||||
* Calcul de l'empreinte de dérivation H2.
|
* Calcul de l'empreinte de dérivation H2.
|
||||||
* H_2 = SHA256(super_bloc \parallel \text{"DERIVATION"})
|
* H_2 = SHA256(super_bloc \parallel \text{"DERIVATION"})
|
||||||
* Garantit l'indépendance mathématique entre la vérification (H1) et le déchiffrement (H2).
|
* Garantit l'indépendance mathématique entre la vérification (H1) et le
|
||||||
* -------------------------------------------------------------------------- */
|
* déchiffrement (H2).
|
||||||
|
* --------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
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);
|
memcpy(buffer_h2, super_bloc, 64);
|
||||||
|
|
@ -130,8 +206,10 @@ int main(int argc, char* argv[]) {
|
||||||
* 6. RÉSOLUTION ALGÉBRIQUE ET DÉCHIFFREMENT
|
* 6. RÉSOLUTION ALGÉBRIQUE ET DÉCHIFFREMENT
|
||||||
* Formule maîtresse : K_{finale} = K_G ^ ( (E_\Delta ^ H_2) \ \& \ Mask )
|
* Formule maîtresse : K_{finale} = K_G ^ ( (E_\Delta ^ H_2) \ \& \ Mask )
|
||||||
* - Si Mask == 0x00 : K_{finale} = K_G ^ 0 = K_G (Goodware)
|
* - Si Mask == 0x00 : K_{finale} = K_G ^ 0 = K_G (Goodware)
|
||||||
* - Si Mask == 0xFF : K_{finale} = K_G ^ \Delta = K_G ^ (K_M ^ K_G) = K_M (Malware)
|
* - Si Mask == 0xFF : K_{finale} = K_G ^ \Delta = K_G ^ (K_M ^ K_G) = K_M
|
||||||
* -------------------------------------------------------------------------- */
|
* (Malware)
|
||||||
|
* --------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
unsigned char derived_key[8];
|
unsigned char derived_key[8];
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
// Tentative de déchiffrement du secret (\Delta)
|
// Tentative de déchiffrement du secret (\Delta)
|
||||||
|
|
@ -150,11 +228,13 @@ 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]);
|
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) {
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -133,6 +133,7 @@
|
||||||
<ClInclude Include="functions.h" />
|
<ClInclude Include="functions.h" />
|
||||||
<ClInclude Include="lonesha256.h" />
|
<ClInclude Include="lonesha256.h" />
|
||||||
<ClInclude Include="stdafx.h" />
|
<ClInclude Include="stdafx.h" />
|
||||||
|
<ClInclude Include="tables_poly.h" />
|
||||||
<ClInclude Include="targetver.h" />
|
<ClInclude Include="targetver.h" />
|
||||||
<ClInclude Include="tree.h" />
|
<ClInclude Include="tree.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,9 @@
|
||||||
<ClInclude Include="functions.h">
|
<ClInclude Include="functions.h">
|
||||||
<Filter>Fichiers d%27en-tête</Filter>
|
<Filter>Fichiers d%27en-tête</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="tables_poly.h">
|
||||||
|
<Filter>Fichiers d%27en-tête</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="stdafx.cpp">
|
<ClCompile Include="stdafx.cpp">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue