Shadow space example

The shadow space must be provided directly previous to the call. Imagine the shadow space as a relic from the old stdcall/cdecl convention: For WriteFile you needed five pushes. The shadow space stands for the last four pushes (the first four arguments). Now you need four registers, the shadow space (just the space, contents don’t … Read more

What’s the real meaning of $$ in nasm

$$ is the address of the beginning of the current section. It is a relocatable value (not “scalar” – a word you will find in an error message, but not in the Manual). It is an offset, so doesn’t care what’s in a segment register. Documentation: https://www.nasm.us/doc/nasmdoc3.html#section-3.5 example use case for a boot sector: https://www.nasm.us/doc/nasmdo13.html#section-13.1.3 … Read more

Printf without newline in assembly

fflush() flushes buffered output in line or full-buffered stdio streams: extern fflush … xor edi, edi ; RDI = 0 call fflush ; fflush(NULL) flushes all streams … Alternatively, mov rdi, [stdout] / call fflush also works to flush only that stream. (Use default rel for efficient RIP-relative addressing, and you’ll need extern stdout as … Read more

Linux Shellcode “Hello, World!”

When you inject this shellcode, you don’t know what is at message: mov ecx, message in the injected process, it can be anything but it will not be “Hello world!\r\n” since it is in the data section while you are dumping only the text section. You can see that your shellcode doesn’t have “Hello world!\r\n”: … Read more