Writing Security Tools and Exploits

Once a dissector is set up and callable by Ethereal, work on the dissection part can begin. To write this part, we need to know how to retrieve the packet data and manipulate it. We must then format it and add it to the data structures that Ethereal provides to create the packet summary and protocol tree that Ethereal displays to the user.
To program a dissector for Ethereal, we must be familiar with the basic data types that the glib library provides. The glib library is a platform-independent library of data types and functions that can form the basis of any cross-platform C program. The GTK+ library and GNU Image Manipulation Program (GIMP) use the glib library, as does the GNU Network Object Model Environment (GNOME) desktop environment. Although it is closely associated with GTK+ and GNOME, the glib library itself has nothing to do with GUIs; it is only concerned with low-level C routines.
We can peruse the data types and functions that are supplied by glib. Look in the header files for glib, which are installed if we installed glib from source. If we installed it from a binary package, we might have to install a separate glib-dev package, depending on the operating system distribution. Look in /usr/include/glib-${ VERSION} /glib.h, where ${ VERSION} is the version of glib that is installed. g lib version 1.x has one big header file, and glib version 2.x has a header...