Hi there
I'm currently doing practices under Linux w/ blah crackmes:
Link: crackmes.de
This is the dump result:
Code:
blah: file format elf32-i386
Disassembly of section .text:
08048094 <.text>:
8048094: 31 c0 xor %eax,%eax
8048096: b8 2f 00 00 00 mov $0x2f,%eax
804809b: cd 80 int $0x80
804809d: 3d ad de 00 00 cmp $0xdead,%eax
80480a2: 75 16 jne 0x80480ba <-- I want to NOP this line
80480a4: b8 04 00 00 00 mov $0x4,%eax
80480a9: bb 01 00 00 00 mov $0x1,%ebx
80480ae: b9 c4 90 04 08 mov $0x80490c4,%ecx
80480b3: ba 06 00 00 00 mov $0x6,%edx
80480b8: cd 80 int $0x80
80480ba: 31 c0 xor %eax,%eax
80480bc: 40 inc %eax
80480bd: 31 db xor %ebx,%ebx
80480bf: cd 80 int $0x80
As I comment above, I want to patch that line by 2 - NOP bytes.
I wrote this code:
Code:
#include <stdio.h>
int
main( int argc, char *argv[] )
{
int offset[2] = { 0x75, 0x16 }; /* origin */
char patch[2] = { 0x90, 0x90 }; /* nop */
FILE *file;
int i;
file = fopen( "blah", "rb+" );
if( file != NULL ) {
for( i = 0; i < 2; ++i ) {
fseek( file, offset[i], SEEK_SET ); /* search */
fprintf( file, "%c", patch[i] ); /* patch */
}
printf("Patched Done.\n");
} else {
printf("[Error]: file not found. \n");
}
fclose( file );
return 0;
}
However, I don't know why it doesn't work???
[Note: if I change different offsets, source works; only the above offset occurs error]
May some1 help me this?