Etape 3 (partie 1)

This commit is contained in:
SombrAbsol 2024-01-23 19:44:34 +01:00
parent 1ff1b7d0dc
commit ca57df0a07
3 changed files with 82 additions and 0 deletions

BIN
a.exe

Binary file not shown.

40
a.exe.stackdump Normal file
View File

@ -0,0 +1,40 @@
Exception: STATUS_INTEGER_DIVIDE_BY_ZERO at rip=0001004010E2
rax=000000000000004F rbx=0000000A00000410 rcx=0000000A00000010
rdx=0000000000000000 rsi=0000000A000003B0 rdi=00000007FFFFCC60
r8 =00000007FFFFCB1C r9 =00000001800A4F70 r10=0000000800000000
r11=000000010040115D r12=00000007FFFFCC8D r13=0000000000000000
r14=0000000000000000 r15=00000007FFFFCC60
rbp=00000007FFFFCC10 rsp=00000007FFFFCBB0
program=C:\Users\benja\Documents\UPEC\decodages\a.exe, pid 1692, thread main
cs=0033 ds=002B es=002B fs=0053 gs=002B ss=002B
Stack trace:
Frame Function Args
0007FFFFCC10 0001004010E2 (0007FFFFCC60, 000000000000, 000000000030, 000700000000) a.exe+0x10E2
0007FFFFCD30 000180047ED1 (000000000000, 000000000000, 000000000000, 000000000000) msys-2.0.dll+0x7ED1
000000000000 000180045AC3 (000000000000, 000000000000, 000000000000, 000000000000) msys-2.0.dll+0x5AC3
0007FFFFFFF0 000180045B74 (000000000000, 000000000000, 000000000000, 000000000000) msys-2.0.dll+0x5B74
End of stack trace
Loaded modules:
000100400000 a.exe
7FFC94C70000 ntdll.dll
7FFC93430000 KERNEL32.DLL
7FFC921F0000 KERNELBASE.dll
000180040000 msys-2.0.dll
7FFC93500000 advapi32.dll
7FFC93FC0000 msvcrt.dll
7FFC93230000 sechost.dll
7FFC921C0000 bcrypt.dll
7FFC94070000 RPCRT4.dll
7FFC91740000 CRYPTBASE.DLL
7FFC92020000 bcryptPrimitives.dll
7FFC6FA40000 netapi32.dll
7FFC8C9A0000 SAMCLI.DLL
7FFC920A0000 ucrtbase.dll
7FFC8CF20000 SAMLIB.dll
7FFC90A00000 NETUTILS.DLL
7FFC94190000 user32.dll
7FFC925A0000 win32u.dll
7FFC93C90000 GDI32.dll
7FFC92670000 gdi32full.dll
7FFC925D0000 msvcp_win.dll
7FFC93960000 IMM32.DLL

View File

@ -0,0 +1,42 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
long long int calculmodulo(long long int nb, long long int d, long long int n) {
long long int resultat = 1;
// Utilisation de l'algorithme d'exponentiation rapide pour gerer les grands nombres
while (d > 0) {
// Si le bit de droite de d est 1 (d est impair)
if (d % 2 == 1) {
resultat = (resultat * nb) % n; // Multiplier le resultat par nb et prendre le modulo n
}
d = d / 2; // Diviser d par 2 (decalage d'octets vers la droite)
nb = (nb * nb) % n; // elever nb au carre et prendre le modulo n
// Lignes ajoutées pour illustrer le processus
printf("d = %lld, nb = %lld, resultat = %lld\n", d, nb, resultat);
}
return resultat;
}
int main(void) {
/*Parametres RSA*/
long long n = 6554179;
long long e = 689149;
long long d = 55621;
FILE* stream = fopen("Etape4.bin","r");
/*Variable pour caracteres*/
long long int nb;
/*Tant que la fin du fichier n'est pas atteinte, dechiffrer chaque caractere*/
/*en calculant le modulo de la valeur numerique de chacun*/
while (fread(&nb, sizeof(long long int), 1, stream) != 0) {
long long int dechiffre = calculmodulo(nb, d, n);
printf("%c", (char)dechiffre);
}
fclose(stream);
}