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

This chapter examines the multitudes of coding particulars that are used to create applications that will both compile and run on different operating systems. It also serves as a resource for finding the more popular features within a program and utilizing the presented examples.
The first step in writing a program that runs on multiple systems and distinguishes which function to use (or more problematic, when to use differentiating platform-specific parameters with the same function), is to determine the underlying platform. A few of the more interesting methods for determining the operating system and using it to consistently direct the program are also discussed.
After determining the operating system, process creation and management are discussed. UNIX forking and the Microsoft equivalent and file and directory handling and library usage are also analyzed.
| Note | All of the example source code in this chapter was written and compiled using OpenBSD 3.2/x86 using the GNU C compiler version 2.95.3, the tcsh command shell version 6.12.00, and Microsoft Windows XP using Microsoft Visual Studio.NET 2002. |
This section examines a number of UNIX application programming interfaces (APIs) and how to port them to the Windows platform. Emphasis is placed on porting APIs rather than the complete documentation of equivalent APIs for both platforms. Preference is given to APIs that are cross-platform-compatible rather than platform-dependent. The selection of APIs is geared toward the development and porting of network and host security tools.
The topics discussed include process creation and...