x86 - Looking for help: Explaining assembly code generated by C compiler -
i trying understand assembly instructions generated following c code:
#include<stdio.h> #include<unistd.h> int main() { char *happy[2]; happy[0] = "/bin/sh"; happy[1] = null; execve(happy[0],happy,null); }
unfortunately can't understand assembly code.
can explain code me? can figure out rax
contains address of /bin/sh
, don't know use of rsi
register here.
dump of assembler code function main: 0x0000000000400a0d <+0>: push %rbp 0x0000000000400a0e <+1>: mov %rsp,%rbp 0x0000000000400a11 <+4>: sub $0x20,%rsp 0x0000000000400a15 <+8>: mov %fs:0x28,%rax 0x0000000000400a1e <+17>: mov %rax,-0x8(%rbp) 0x0000000000400a22 <+21>: xor %eax,%eax 0x0000000000400a24 <+23>: lea 0x8c4d9(%rip),%rax # 0x48cf04 0x0000000000400a2b <+30>: mov %rax,-0x20(%rbp) 0x0000000000400a2f <+34>: movq $0x0,-0x18(%rbp) 0x0000000000400a37 <+42>: mov -0x20(%rbp),%rax 0x0000000000400a3b <+46>: lea -0x20(%rbp),%rcx 0x0000000000400a3f <+50>: mov $0x0,%edx 0x0000000000400a44 <+55>: mov %rcx,%rsi 0x0000000000400a47 <+58>: mov %rax,%rdi 0x0000000000400a4a <+61>: callq 0x432b10 <execve> 0x0000000000400a4f <+66>: mov $0x0,%eax 0x0000000000400a54 <+71>: mov -0x8(%rbp),%rdx 0x0000000000400a58 <+75>: xor %fs:0x28,%rdx 0x0000000000400a61 <+84>: je 0x400a68 <main+91> 0x0000000000400a63 <+86>: callq 0x435730 <__stack_chk_fail_local> 0x0000000000400a68 <+91>: leaveq 0x0000000000400a69 <+92>: retq end of assembler dump. `
Comments
Post a Comment