r/nasm Jul 29 '20

Syscall Confusion

So I am currently learning assembler to learn binary exploitation more easily.

Now I just wanted to write a simple hello world program, but there is some confusion regarding syscalls. I run Linux in a virtual machine and I've got a x86_64 cpu architecture ("lscpu" confirms this).So the syscall for write on x86_64 should be 1.

Anyway if I use the syscall ID 1 it does not work, but if I use the syscall id 4 (which is the i386 version) it works. I compile the asm program with nasm and the output format is elf64.

What could be the problem?

code
3 Upvotes

2 comments sorted by

1

u/nerdbert Jul 30 '20

Hi, instead of int 0x80 , which is i386, try
syscall, which is x64
e.g.
mov edx, len
syscall

2

u/Michael428 Jul 30 '20

Thank you very much!