Recently, the company needs to complete security testing, resulting in the need for more in-depth study of attack methods and vulnerability analysis of the technology, the total feel a bit like a hacker:), but not only to know some of the security testing tools and tools to use, but also need basic Kung Fu, first from the University of the Assembly language (hehe, university lessons, For a long time did not use most of the teachers had to start.
1. Download NASM installation package
#wget http://www.nasm.us/pub/nasm/releasebuilds/2.11.08/nasm-2.11.08.tar.gz
2, decompression installation NASM
#tar-XZVF nasm-2.11.08.tar.gz
#cd nasm-2.11.08
#./configure
#make
#make Install
3, Write Hello.asm
Section. Data;Section DeclarationMSG db"Hello, world!.", 0xA;Our Dear stringLen Equ $-Msg;length of our dear stringSection. Text;Section Declaration ;We must export the entry point to the ELF linker orGlobal _start;Loader. They conventionally recognize _start as their ;entry point. Use ld-e foo to override the default._start:;write our string to stdout moveax4 ;system call Number (Sys_write) movEbx1 ;First Argument:file handle (stdout) movEcx,msg;second argument:pointer to message to write movEdx,len;Third Argument:message length int0x80;Call kernel;and exit moveax1 ;system call Number (Sys_exit) XOREbx,ebx;First syscall argument:exit code int0x80;Call kernel
4. Compile the connection
#nasm-F elf64 hello.asm (Linux is 64-bit, if 32, use ELF32)
#ld-S-o Hello hello.o
#ls Hello
Hello
5. Execution procedure
#./hello
Hello, world!.
Finally write a simple Hello world, recall some of the functions of common instructions and registers, only in the later security testing and C language to compile, the knowledge of the assembly, knowledge to time to hate less, or more to prepare some knowledge: refueling ~ ~ ~
Using assembly language to write Hello world! under Linux Program