Writing Security Tools and Exploits

Appendix B: Syscall Reference

Overview

Appendix B includes descriptions of several useful system calls. For complete information about the system calls available on Linux and FreeBSD, read the syscall man pages and the header files that they refer to. Before trying to implement a system call in an assembly, test it in a simple C program. This will help you become familiar with the system call's behavior, thus allowing you to write better code.

exit( int status )

The exit system call allows you to terminate a process. It requires one argument (an integer) that is used to represent the exit status of the program, which is used by other programs to determine if the program terminated because of an error.

open( file, flags, mode )

You can open a file to read or write using the open call. Using the flags, you can specify whether the file should be created if it does not exist, whether it 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.

close( filedescriptor )

The close system call uses a file descriptor as an argument (e.g., the file descriptor returned by an open system call).

read( filedescriptor, pointer to buffer, amount...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Cluster Software and Tools
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.