Sockets, Shellcode, Porting & Coding: Reverse Engineering Exploits and Tool Coding for Security Professionals

This appendix includes several descriptions of useful system calls. For more complete information about the system calls available on Linux and FreeBSD, take a look at the syscall man pages and the header files they refer to. Before trying to implement a system call in assembly, first try it out in a simple C program. That way you can become familiar with the system call s behavior, and this will allow you to write better code.
The exit system call allows you to terminate a process. It only requires one argument, an integer that will be used to represent the exit status of the program. The value given here can be used by other programs to determine whether the program terminated with an error.
Using the open call, you can open a file to read or write. Using the flags, you can specify whether the file should be created if it does not exist, whether the file should be opened read-only, and so on. The mode argument is optional and only required when you use the O_CREAT flag within the open call. The open system call returns a file descriptor that can be used to read from and write to. In addition, you can close the opened file using the file descriptor in the close system call.
The close system call requires a file descriptor as an argument. For example, this can be the file descriptor returned by an open...