Bonjour à tous, je suis en train de faire un projet sécu pour l'école, et j'ai une petite difficulté à reproduire exactement le même comportement que le binaire de base.
Voici la fonction qui me pose problème :
J'ai un probleme avec la ligne p+30. Dans mon code elle n'y est pas.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 0x080484d4 <+0>: push ebp 0x080484d5 <+1>: mov ebp,esp 0x080484d7 <+3>: sub esp,0x68 0x080484da <+6>: mov eax,ds:0x8049860 0x080484df <+11>: mov DWORD PTR [esp],eax 0x080484e2 <+14>: call 0x80483b0 <fflush@plt> 0x080484e7 <+19>: lea eax,[ebp-0x4c] 0x080484ea <+22>: mov DWORD PTR [esp],eax 0x080484ed <+25>: call 0x80483c0 <gets@plt> 0x080484f2 <+30>: mov eax,DWORD PTR [ebp+0x4] 0x080484f5 <+33>: mov DWORD PTR [ebp-0xc],eax 0x080484f8 <+36>: mov eax,DWORD PTR [ebp-0xc] 0x080484fb <+39>: and eax,0xb0000000 0x08048500 <+44>: cmp eax,0xb0000000 0x08048505 <+49>: jne 0x8048527 <p+83> 0x08048507 <+51>: mov eax,0x8048620 0x0804850c <+56>: mov edx,DWORD PTR [ebp-0xc] 0x0804850f <+59>: mov DWORD PTR [esp+0x4],edx 0x08048513 <+63>: mov DWORD PTR [esp],eax 0x08048516 <+66>: call 0x80483a0 <printf@plt> 0x0804851b <+71>: mov DWORD PTR [esp],0x1 0x08048522 <+78>: call 0x80483d0 <_exit@plt> 0x08048527 <+83>: lea eax,[ebp-0x4c] 0x0804852a <+86>: mov DWORD PTR [esp],eax 0x0804852d <+89>: call 0x80483f0 <puts@plt> 0x08048532 <+94>: lea eax,[ebp-0x4c] 0x08048535 <+97>: mov DWORD PTR [esp],eax 0x08048538 <+100>: call 0x80483e0 <strdup@plt> 0x0804853d <+105>: leave 0x0804853e <+106>: ret
Voici mon code c :
Code C : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 #include <stdio.h> #include <stdlib.h> #include <string.h> //gcc -fno-stack-protector -z execstack -Wl,-z,norelro source.c void p(void) { char str[0x40]; char *ptr; fflush(stdin); ptr = gets(str); if (((unsigned int)ptr & 0xb0000000) == 0xb0000000) { printf("(%p)\n", ptr); exit(0x1); } puts(str); strdup(str); } int main(void) { p(); }
Je n'arrive pas à comprendre correctement ce qui se passe ligne p+30 a p+33...
Pouvez-vous me donner un coup de main svp ?
Pour info, voici mon résultat quand je désassemble ma fonction p
Merci beaucoup
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 0x080484d4 <+0>: push ebp 0x080484d5 <+1>: mov ebp,esp 0x080484d7 <+3>: sub esp,0x68 0x080484da <+6>: mov eax,ds:0x804985c 0x080484df <+11>: mov DWORD PTR [esp],eax 0x080484e2 <+14>: call 0x80483b0 <fflush@plt> 0x080484e7 <+19>: lea eax,[ebp-0x4c] 0x080484ea <+22>: mov DWORD PTR [esp],eax 0x080484ed <+25>: call 0x80483c0 <gets@plt> 0x080484f2 <+30>: mov DWORD PTR [ebp-0xc],eax 0x080484f5 <+33>: mov eax,DWORD PTR [ebp-0xc] 0x080484f8 <+36>: and eax,0xb0000000 0x080484fd <+41>: cmp eax,0xb0000000 0x08048502 <+46>: jne 0x8048524 <p+80> 0x08048504 <+48>: mov eax,0x8048620 0x08048509 <+53>: mov edx,DWORD PTR [ebp-0xc] 0x0804850c <+56>: mov DWORD PTR [esp+0x4],edx 0x08048510 <+60>: mov DWORD PTR [esp],eax 0x08048513 <+63>: call 0x80483a0 <printf@plt> 0x08048518 <+68>: mov DWORD PTR [esp],0x1 0x0804851f <+75>: call 0x8048400 <exit@plt> 0x08048524 <+80>: lea eax,[ebp-0x4c] 0x08048527 <+83>: mov DWORD PTR [esp],eax 0x0804852a <+86>: call 0x80483e0 <puts@plt> 0x0804852f <+91>: lea eax,[ebp-0x4c] 0x08048532 <+94>: mov DWORD PTR [esp],eax 0x08048535 <+97>: call 0x80483d0 <strdup@plt> 0x0804853a <+102>: leave 0x0804853b <+103>: ret
Partager