SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 286 | Next

Shon Harris, Allen Harper, Chris Eagle, and Jonathan Ness

"Gray Hat Hacking, Second Edition"


mov [di], ecx
Based Relative The effective address to be manipulated is
calculated by using ebx or ebp plus an offset
value.
mov edx, 20[ebx]
Indexed Relative Same as Based Relative, but edi and esi are used
to hold the offset.
mov ecx, 20[esi]
Based Indexed-Relative The effective address is found by combining
based and indexed modes.
mov ax, [bx][si]+1
Table 6-5 Addressing Modes
mov eax,4 ;system call number (4=sys_write)
int 0x80 ;call kernel interrupt and exit
mov ebx,0 ;load first syscall argument (exit code)
mov eax,1 ;system call number (1=sys_exit)
int 0x80 ;call kernel interrupt and exit
Assembling
The first step in assembling is to make the object code:
$ nasm -f elf hello.asm
Next you will invoke the linker to make the executable:
$ ld -s -o hello hello.o
Finally you can run the executable:
$ ./hello
Hello, haxor!
References
Art of Assembly Language Programming http://webster.cs.ucr.edu/
Notes on x86 Assembly www.ccntech.com/code/x86asm.txt
Debugging with gdb
When programming with C on Unix systems, the debugger of choice is gdb. It provides a
robust command-line interface, allowing you to run a program while maintaining full
control. For example, you may set breakpoints in the execution of the program and
monitor the contents of memory or registers at any point you like.


Pages:
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298