This post on windows shellcoding that i came across shows how to make a simple shellcode for Sleep function that is located in kernel32.dll. I understand the code but it seems as though that you can't call the function without knowing the exact address of the function in the library for which you have to use arwin32.exe that's provided by the author of the post.
;sleep.asm
[SECTION .text]
global _start
_start:
xor eax,eax
mov ebx, 0x77e61bea ;address of Sleep
mov ax, 5000 ;pause for 5000ms
push eax
call ebx ;Sleep(ms);
Shellcoding for Linux and Windows
In MASM32, one simply includes the libraries and dll's but I don't know if this is the same case in NASM, i tried to include kernel32.lib using RadAasm but got error.
Undefined Reference to Sleep.
My question is: How would one call the Sleep function in NASM without knowing the exact address of any of the functions, neither GetProcAddress or the like.
NOTE: Even the other examples, he provides absolute addresses for the functions.
nasm -f bin source.asm? (or win32 for windows) - David C. Rankin