OK inca o simpla demonstratie Avem urmatorul executabil in Ansi C #include <stdio.h> int main () { int hand; __asm__( "movl $0, %0" : "=a" (hand) ); printf("Please enter the serial number: "); scanf("%d",&hand); if (hand != 0x75531EE) { printf("Bad serial\n"); __asm__("mov $0x1, %eax\n" "mov $0x1, %bx\n" "int $0x80"); }else{ printf("Good serial, performing tasks!\n"); __asm__("mov $0x1, %eax\n" "mov $0x0, %ebx\n" "int $0x80"); } } Daca codul preluat din input coincide cu 123023854 programul merge inainte , daca serialul nu coincide programul iese cu un return code divers de 0 si stampeaza pe ecran Bad serial Avem urmatorul cod dezasamblat in gdb (gdb) disas main Dump of assembler code for function main: 0x08048454 <main+0>: push %ebp 0x08048455 <main+1>: mov %esp,%ebp 0x08048457 <main+3>: and $0xfffffff0,%esp 0x0804845a <main+6>: sub $0x20,%esp 0x0804845d <main+9>: mov $0x0,%eax 0x08048462 <main+14>: mov %eax,0x1c(%esp) 0x08048466 <main+18>: mov $0x8048590,%eax 0x0804846b <main+23>: mov %eax,(%esp) 0x0804846e <main+26>: call 0x8048364 <printf@plt> 0x08048473 <main+31>: mov $0x80485b1,%eax 0x08048478 <main+36>: lea 0x1c(%esp),%edx 0x0804847c <main+40>: mov %edx,0x4(%esp) 0x08048480 <main+44>: mov %eax,(%esp) 0x08048483 <main+47>: call 0x8048374 <__isoc99_scanf@plt> 0x08048488 <main+52>: mov 0x1c(%esp),%eax 0x0804848c <main+56>: cmp $0x75531ee,%eax 0x08048491 <main+61>: je 0x80484ac <main+88> 0x08048493 <main+63>: movl $0x80485b4,(%esp) 0x0804849a <main+70>: call 0x8048384 <puts@plt> 0x0804849f <main+75>: mov $0x1,%eax 0x080484a4 <main+80>: mov $0x1,%bx 0x080484a8 <main+84>: int $0x80 Vine comparat input/ul preluat de la user care a fost pus in EAX cu valoarea serialului, daca coincid vine facut un jump la adresa 0x80484ac. 0x0804848c <main+56>: cmp $0x75531ee,%eax 0x08048491 <main+61>: je 0x80484ac <main+88> la adresa 0x80484ac avem urmatoarele instructii [COLOR="#00FF00"]0x080484ac <main+88>: movl $0x80485c0,(%esp)[/COLOR] (gdb) x/s 0x80485c0 0x80485c0: "Good serial, performing tasks!" Daca rescriem je cu jne merge direct la 0x80484ac oricare ar fi serialul introdus.Va trebui sa modificam je cu valoarea in opcode pentru jne care e 75.Asadar va face un jump doar daca serialul nu este corect, in acest caz daca vine introdus serialul corect programul va iesi cu un return cod 1 si va stampa bad serial in mod contrar oricare alta valoare va fi introdusa va functiona. (gdb) x/4bx main+61 0x8048491 <main+61>: [COLOR="#00FF00"]0x74 0x19[/COLOR] 0xc7 0x04 Vom modifica acest cod 00000480 89 04 24 E8 EC FE FF FF 8B 44 24 1C 3D EE 31 55 ..$......D$.=.1U 00000490 07 [COLOR="#00FF00"]74 19[/COLOR] C7 04 24 B4 85 04 08 E8 E5 FE FF FF B8 .t...$.......... 000004A0 01 00 00 00 66 BB 01 00 CD 80 EB 18 C7 04 24 C0 ....f.........$. 000004B0 85 04 08 E8 CC FE FF FF B8 01 00 00 00 BB 00 00 ................ 000004C0 00 00 CD 80 C9 C3 90 90 90 90 90 90 90 90 90 90 ................ 000004D0 55 89 E5 5D C3 8D 74 26 00 8D BC 27 00 00 00 00 U..]..t&...'.... in acest cod 00000480 89 04 24 E8 EC FE FF FF 8B 44 24 1C 3D EE 31 55 ..$......D$.=.1U 00000490 07 [COLOR="#00FF00"]75 19[/COLOR] C7 04 24 B4 85 04 08 E8 E5 FE FF FF B8 .t...$.......... 000004A0 01 00 00 00 66 BB 01 00 CD 80 EB 18 C7 04 24 C0 ....f.........$. 000004B0 85 04 08 E8 CC FE FF FF B8 01 00 00 00 BB 00 00 ................ 000004C0 00 00 CD 80 C9 C3 90 90 90 90 90 90 90 90 90 90 ................ 000004D0 55 89 E5 5D C3 8D 74 26 00 8D BC 27 00 00 00 00 U..]..t&...'.... Daca aveti intrebari sau nelamuriri in legatura cu subiectul nu ezitati sa le faceti.