- Carnivore - Predator
- Formerly known as THC HackSuite, Carnivore - Predator stands at the forefront of cutting-edge cybersecurity tools, redefining the landscape of penetration testing with unparalleled innovation. Designed to empower ethical hackers, security professionals, and enthusiasts alike, Carnivore - Predator is the ultimate Pentest CMS that puts you in command.
Carnivore Module Creation Part 5
In this section, we will discuss data files and how to utilize them within Carnivore.
In Carnivore, many modules either have a folder where result files are stored or a single data file that contains results from previous sessions.
The most common type of result file in Carnivore is a plain text file. Here's an example:
This example is a data dump from the SpeedtouchBrute module, containing three values (timestamp, BSSID, WPA key) separated by a pipe character, with each entry on a new line. In Carnivore, this is a preferred way to store data because it is easy to manage, incurs minimal overhead, and keeps result files as compact as possible.
The best method to store data depends on what you need to store. In some cases, serialized data is preferred, while in others, creating an array that can be included in other files might be the best approach. However, this method is prone to errors, so always exercise caution when validating data to avoid potential issues with Carnivore itself.
If you need to store a large amount of data, you may consider using a folder to store session data in separate files. I personally recommend naming files after a session identifier, combined with a timestamp if necessary. In the example above, a single file suffices because each entry in the data file typically consists of only a few bytes.
Handling Files and Folders
To work efficiently with files and folders in Carnivore, you need to be familiar with five key functions, all of which can be found in the Functions folder:
- RawToArray: RawToArray($sFile,$sSeparate="|")
- GetFileData: GetFileData($sFile)
- GetFilesByDirectory: GetFilesByDirectory($sDir)
- GetDirByDir: GetDirByDir($sParentDir,$iAbsolute=1)
- WriteF: WriteF($sDest,$sWrite,$sMode="a")
Reading From Files
There are multiple ways to read data files, depending on the content structure. For files where content is separated by a pipe or another character, with each record on a new line, the RawToArray function is best suited, as it is specifically designed to handle this type of content.
Another option is to retrieve the entire file as a string using the GetFileData function:
While you might consider using fopen(), file(), or file_get_contents() to load data from files, Carnivore functions offer the added advantage of setting error properties, which can be used for logging and error handling.
Reading From Folders
There are two functions for reading files and folders from directories. One retrieves folder names or locations from directories, while the other collects all file locations within a directory.
The GetFilesByDirectory function is useful for fetching files from a folder, returning an array with absolute paths to the files in the directory.
The GetDirByDir function can be used to obtain an array of folders within a directory, with results varying depending on the second parameter, which returns either full paths or folder names.
Writing To Files
In Carnivore, there is only one function available for writing content to files:
The WriteF function operates similarly to PHP's fwrite() function, with the added benefit of setting errors when they occur.
In the final part of this module documentation, we will add ModGlue documentation to the screen file.