added hash check
This commit is contained in:
parent
2fe73c3be3
commit
ce485a0902
1 changed files with 29 additions and 1 deletions
|
|
@ -106,6 +106,30 @@ int fakemain(int argc, wchar_t *argv[]) {
|
||||||
* MOTEUR D'OBFUSCATION BRANCHLESS (POINT-FUNCTION OBFUSCATION)
|
* MOTEUR D'OBFUSCATION BRANCHLESS (POINT-FUNCTION OBFUSCATION)
|
||||||
* ==============================================================================
|
* ==============================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
void fake_exit(char* msg){
|
||||||
|
printf("%s\n",msg);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_hash(unsigned char hash [32]){
|
||||||
|
for(int i = 0; i < 32; i++){
|
||||||
|
printf("%x",hash[i]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Vérifie la checksum des instructions entre gf_mul et le main
|
||||||
|
bool verif_checksum_prog(){
|
||||||
|
const unsigned char* start = (const unsigned char*)gf_mul;
|
||||||
|
const unsigned char* end = (const unsigned char*)verif_checksum_prog;
|
||||||
|
long size = end-start;
|
||||||
|
unsigned char hash [32];
|
||||||
|
lonesha256(hash, start, size);
|
||||||
|
print_hash(hash);
|
||||||
|
return memcmp(hash, hash, 32) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t (*evaluate_polynomial)(uint8_t x, const uint8_t coeffs[8]);
|
uint8_t (*evaluate_polynomial)(uint8_t x, const uint8_t coeffs[8]);
|
||||||
void *(*memcpy)(void *__restrict __dest, const void *__restrict __src,
|
void *(*memcpy)(void *__restrict __dest, const void *__restrict __src,
|
||||||
|
|
@ -125,6 +149,10 @@ int main(int argc, char *argv[]) {
|
||||||
FuncList2 list = {evaluate_polynomial, stdfunclist->obfusc_memcpy, lonesha256};
|
FuncList2 list = {evaluate_polynomial, stdfunclist->obfusc_memcpy, lonesha256};
|
||||||
|
|
||||||
fakemain(argc, (wchar_t **)argv);
|
fakemain(argc, (wchar_t **)argv);
|
||||||
|
bool valid = verif_checksum_prog();
|
||||||
|
if(!valid){
|
||||||
|
fake_exit(argv[1]);
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t input[8];
|
uint8_t input[8];
|
||||||
list.memcpy(input, argv[1], 8);
|
list.memcpy(input, argv[1], 8);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue