I'm learning reversing and for that I use Ghidra.
There is program I'm trying to modify so I can recompile it and make it work.
I have a code that ghidra decompile like this: data=function(4)
Going inside the function I think to make it work I need to pass a zero.
In the assembly I can read:
PUSH RBP
MOV RBP,RSP
MOV EDI,0x4
CALL function
MOV qword ptr [data],RAX
What I understand from that (and I'm propably wrong)
is that the MOV EDI,0x4
is the 4 given in the function so I tried to rewrite it in Ghidra with 0x0
and it replace the:
bf 04 00 00 00 with bf 00 00 00 00
I thought it would be enough and I exported as an ELF but when I start the program I get a segmentation fault so I guess I'm doing something wrong with the memory.
(gdb) x/10xi $rip
=> 0x555555401888: mov (%rax),%rax
0x55555540188b: test %rax,%rax
0x55555540188e: jne 0x55555540189a
0x555555401890: mov $0x0,%eax
0x555555401895: jmp 0x55555540199d
0x55555540189a: movq $0x0,-0x50(%rbp)
0x5555554018a2: mov -0x60(%rbp),%rax
0x5555554018a6: mov %rax,%rdi
0x5555554018a9: call 0x5555554008f0 <strlen@plt>
0x5555554018ae: mov %rax,-0x48(%rbp)
I would like some help to understand what I'm doing wrong.
thanks