I wrote assembly code to test the shellcode example. However, I got the following errors when I compile assembly code. I've tried to compile assembly code as .S and .s too. also, I tried to compile as "gcc -nostdlib -static shellcode.s -o shellcode-elf" and "as shellcode.s -o shellcode.o" too.
Can anyone please help me with compiling simple assembly code on by Ubuntu ?(Using mac M1 chip)
uname -a :
Linux ubuntu 5.8.0-49-generic #55~20.04.1-Ubuntu SMP Fri Mar 26 01:00:41 UTC 2021 aarch64 aarch64 aarch64 GNU/Linux
Errors:
shellcode.s: Assembler messages:
shellcode.s:6: Error: operand 1 must be an integer register -- `mov rax,59'
shellcode.s:7: Error: unknown mnemonic `lea' -- `lea rdi,[rip+binsh]'
shellcode.s:8: Error: operand 1 must be an integer register -- `mov rsi,0'
shellcode.s:9: Error: operand 1 must be an integer register -- `mov rdx,0'
shellcode.s:10: Error: unknown mnemonic `syscall' -- `syscall'
Assembly code:
global _start
_start:
xor %eax, %eax
xor %edx, %edx
push %eax
push $0x68732f2f
push $0x6e69622f
mov %esp, %ebx
push %edx
push %ebx
mov %esp, %ecx
movb $0x0B, %al
int $0x80