Beispiel #1
0
    def __init__(self, debug=False):
        """
        Initialize Installer.

        Args:
            debug (bool): Log on terminal or not

        Raises:
            None

        Returns:
            None
        """
        # Initialize logger
        self.logger = PatchLogger(__name__, debug=debug)

        # Command configuraton path
        self._COMMAND_PATH = "securetea/lib/auto_server_patcher/configs/commands.json"
        # Load configuraton data
        self.config_data = self.open_json(self._COMMAND_PATH)

        # Categorize OS
        self.os_name = utils.categorize_os()
        if self.os_name:
            try:
                self.os_config_data = self.config_data[self.os_name]
            except KeyError:
                self.logger.log("Could not load OS configuraton data.",
                                logtype="error")
        else:
            self.logger.log("Could not determine OS specific config.")
    def __init__(self, debug=False, url=None):
        """
        Initialize SSLScanner.

        Args:
            debug (bool): Log on terminal or not

        Raises:
            None

        Returns:
            None
        """
        # Initialize logger
        self.logger = PatchLogger(__name__, debug=debug)

        # API URL
        self._API_URL = "https://api.ssllabs.com/api/v3/analyze/"

        self.analyze_payload = {
            'startNew': 'on',
            'publish': 'off',
            'all': 'done',
            'ignoreMismatch': 'on'
        }

        # URL / website to scan
        self.url = str(url)
Beispiel #3
0
    def __init__(self, debug=False, cred=None):
        """
        Initialize SecureTeaAutoServerPatcher.

        Args:
            debug (bool): Log on terminal or not
            url (str): URL to scan for SSL vulnerabilites

        Raises:
            None

        Returns:
            None
        """
        # Initialize logger
        self.logger = PatchLogger(__name__, debug=debug)

        if not utils.check_root():
            self.logger.log("Please run as root, exiting.", logtype="error")
            sys.exit(0)

        if not cred:
            self.logger.log("No credentials specified.", logtype="error")
            sys.exit(0)

        # List of files to patch
        self.to_patch = list()

        url = cred['url']
        apache = int(cred['apache'])
        ssh = int(cred['ssh'])
        login = int(cred['login'])
        sysctl = int(cred['sysctl'])

        # Determine which file to patch
        if apache == 1:
            self.to_patch.append("apache")
        if ssh == 1:
            self.to_patch.append("ssh")
        if login == 1:
            self.to_patch.append("login")
        if sysctl == 1:
            self.to_patch.append("sysctl")

        if url and url != "XXXX":  # if valid URL
            self.url = url
        else:
            self.url = None

        # Create Installer object
        self.installer = Installer(debug=debug)
        # Create Patcher object
        self.patcher = ConfigPatcher(debug=debug, to_patch=self.to_patch)
        if self.url:
            # Create SSLScanner object
            self.ssl_scanner = SSLScanner(debug=debug, url=self.url)
Beispiel #4
0
    def __init__(self, debug=False, to_patch=None):
        """
        Initialize ConfigPatcher.

        Args:
            debug (bool): Log on terminal or not

        Raises:
            None

        Returns:
            None
        """
        # Initialize logger
        self.logger = PatchLogger(__name__, debug=debug)

        # Configuration file path
        self._CONFIG_PATH = "/etc/securetea/asp/config.json"
        # Load configuration
        self.config_data = self.open_json(self._CONFIG_PATH)
        # Categorize OS
        os_name = utils.categorize_os()

        if os_name:
            try:
                self.os_config_data = self.config_data[
                    os_name]  # if OS in configuration
            except KeyError:
                self.logger.log("Could not load OS specific configuration.",
                                logtype="error")
        else:
            self.logger.log("Operating system cannot be determined.",
                            logtype="error")
            sys.exit(0)

        # List of files to patch
        if to_patch:
            self.to_patch = to_patch
        else:
            self.to_patch = []