My main section is defined as section .code write
I deliberately removed the exec
parameter, and noticed that, after assembling and linking, the program runs fine.
objdump -d myprogram
is empty.
And gdb cannot debug it : break _start
says "Function _start not defined", but info variables
shows _start
.
But the program still runs. How's that possible ?
Architecture is intel 32-bit, on linux (ubuntu 12).
The probram is doing an execve syscall, opening a /bin/sh shell.
The nasm program :
global _start
section .code write
_start:
jmp short call_shellcode
shellcode:
pop esi
xor ebx, ebx
mov byte [esi +7], bl
mov dword [esi +8], esi
mov dword [esi +12], ebx
lea ebx, [esi]
lea ecx, [esi +8]
lea edx, [esi +12]
xor eax, eax
mov al, 0xb
int 0x80
call_shellcode:
call shellcode
message db "/bin/shABBBBCCCC"