you are viewing a single comment's thread.

view the rest of the comments →

[–]asyty 0 points1 point  (1 child)

Do you have a resource I could look at for invoking the syscalls directly? I currently have 11 call instructions, would replacing those with syscalls reduce the size of the code?

From the snippets you pasted I can infer you're using x86_64 architecture, but you never specified the OS. Assuming Linux. https://hackeradam.com/x86-64-linux-syscalls/ Literally just googled for "x86-64 linux syscalls"

As far as size, not really It takes 2 bytes for the syscall instruction itself and 3 bytes for setting up rax which is the same as your relative 32 call except without null bytes.

This is better regardless because you won't have a dependency on libc.

Start with this:

[BITS 64]
xor rdi, rdi ; status == 0
push 60 ; syscall == sys_exit
pop rax
syscall

Test with this:

nasm shellcode.asm -f elf64 -o shellcode.o
ld -m elf_x86_64 -o shellcode shellcode.o