in the name of zero

February 4, 2006

more on allocators and trying out shellcoding

Filed under: hermetic studies

i found this yesterday and it has really helped me understand much of the fundamental functions of memory allocators.

i’ve also begun reading the introductory article about shellcoding for linux i’m excited about that too! infact, i’ve reached the part example 2 - saying hello world where it shows a technique on how to load a string address in a piece of code during runtime.

global _start
_start:
	
        jmp short ender
	
        starter:
	
        xor eax, eax    ;clean up the registers
        xor ebx, ebx
        xor edx, edx
        xor ecx, ecx
	
        mov al, 4       ;syscall write
        mov bl, 1       ;stdout is 1
        pop ecx         ;get the address of the string from the stack
        mov dl, 5       ;length of the string
        int 0x80
	
        xor eax, eax
        mov al, 1       ;exit the shellcode
        xor ebx,ebx
        int 0x80
	
        ender:
        call starter	;put the address of the string on the stack
        db 'hello'
the call function, pushed the return address onto the stack which happens to be byte offset (address) of the start of the string hello! nifty! then it loaded cs:ip with the byte offset (address) of starter! such a procedure is necessary because the code is run from the address space of another program, making the string address arbitrary in nature.

long weekend my friends.

Get free blog up and running in minutes with Blogsome | Theme designs available here