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.
current version: 0.7.0 - PREDATOR
home > documentation > modules > Carnivore module creation part 4
In part four you will learn how to use screen files and tasks in your modules.
author: Remco Kouw
created: 27-Mar-2024
updated: 19-Aug-2024

Carnivore Module Creation Part 4

Now that we have created a basic module, we may want to add some functionality. In modules, there are two files visible to the end user: index.php (essentially the form) and screen.php (output within the frame).

In the root of the module we created earlier, locate the screen.php file and open it in your preferred editor or the Carnivore editor. The file should look like the following:

Depending on the settings you select, your module's code may vary. The example shown contains the minimum code necessary for a screen file.

As you can see, this code will display a Test message when a form is submitted; otherwise, it will simply display the module's settings.

  1. set_time_limit(0); This setting allows for infinite execution time, which is particularly useful for scripts like brute-forcers that may take a long time to complete.
  2. $_MODULE_C = "thc_xi"; This variable is mandatory if you want to be able to set this module as a task.
  3. $_CONTEXT['thc_xi'] = array(); This variable is required if you want this module to interact with ModGlue.
  4. include_once("../../Includes/screen_header.php"); This includes a basic header for screen files that incorporates essential functionality.
  5. include_once($_PATHS['style_root']."/screen.php"); This includes two variables used for displaying HTML content. The $sOut variable contains the HTML up to the body tag and includes some basic CSS styling. The $sEnd variable contains the closing body and HTML tags. These variables function like the buns of a hamburger, with the content created in the screen file being the meat.
  6. include_once($_PATHS['functions_root']."/scrn.php"); This includes the screen function, which is used to display the output, if desired.
  7. $sOptions = "..."; This variable represents Carnivore's settings for displaying content within the iframe.
  8. switch($_POST['submit']) In Carnivore screen files, switch statements are often used to check the state of the submit button. This is crucial because ModGlue analyzes screen files and checks for these statements. If they are missing, ModGlue will be unable to extract the necessary data for communication with other modules.

Tasks

Modules offer two features that are not available by default in native tools and apps: ModGlue (which will be discussed later in this module creation tutorial) and tasks.

Tasks are only applicable in screen files within modules and require the inclusion of two files from the Includes folder:

  1. task_start.php: This file should be used after validation is complete, with the variable $_MODULE_C set, and before any headers are sent to the browser. It creates a new entry in the task file.
  2. task_end.php: This task file must be included after the script execution is complete, as it updates the task file with the necessary data.

Here's an example of what the script will look like after implementing these changes:

Always ensure that a task is properly ended after it has been started. If something unexpected occurs before the script execution completes, you can handle it as follows:

Next, we will add additional files to the module, including data files, functions, and include files.

Created by Remco Kouw: 2008-2024