congdong007

Penetration Test、Software Developer

0%

How to compile asm to execute under Linux

Here is code snippet to show how to compile asm to execute under Linux:

shellx.asm:

1
2
3
4
5
6
7
8
9
10
11
12
13
section     .text
global _start
_start:
mov edx,len
mov ecx,msg
mov ebx,1
mov eax,4
int 0x80
mov eax,1
int 0x80
section .data
msg db 'Hello world',0xa
len equ $ - msg

let’s start

  1. First step:
1
vagrant@kali:~/Desktop/cdasm$ nasm -f elf64 shellx.asm
  1. Next step:
1
vagrant@kali:~/Desktop/cdasm$ ld -s -o shellx shellx.o
  1. Execute :
1
vagrant@kali:~/Desktop/cdasm$ ./shellx 

then output :

1
Hello world