Ejemplo n.º 1
0
    def banner():
        """
        Load application banner

        :raise PackageError
        :return: str
        """

        try:

            banner = CoreConfig.get('banner').format(
                tpl.line('Directories: {0}'.format(
                    Package.__directories_count()),
                         color='blue'),
                tpl.line('Subdomains: {0}'.format(
                    Package.__subdomains_count()),
                         color='blue'),
                tpl.line('Browsers: {0}'.format(Package.__browsers_count()),
                         color='blue'),
                tpl.line('Proxies: {0}'.format(Package.__proxies_count()),
                         color='blue'),
                tpl.line(Package.__license(), color='blue'))

            return banner

        except (FileSystemError, CoreSystemError, PackageError) as error:
            raise PackageError(error)
Ejemplo n.º 2
0
    def update():
        """
        Check for update
        :raise PackageError
        :return: str
        """

        try:
            if False is sys().is_windows:
                status = process.execute(CoreConfig.get('command').get('cvsupdate'))
                upd_status = tpl.line(status, color='green')
                msg = CoreConfig.get('update').format(status=upd_status)
            else:
                msg = CoreConfig.get('update').format(status=tpl.line(key='upd_win_stat'))
            return msg
        except (AttributeError, CoreSystemError) as error:
            raise PackageError(error)
Ejemplo n.º 3
0
    def examples():
        """
        Load examples of usage
        :return: str
        """

        examples = CoreConfig.get('examples')
        return examples
Ejemplo n.º 4
0
def exception_log():
    """
    Get exception log path
    :return: string
    """

    exception_filelog = CoreConfig.get('data').get('exceptions_log')
    return filesystem.getabsname(exception_filelog)
Ejemplo n.º 5
0
    def examples():
        """
        Load examples of usage
        :return: str
        """

        examples = CoreConfig.get('examples')
        return examples
Ejemplo n.º 6
0
 def docs():
     """
     Open documentation
     :raise PackageError
     :return: bool
     """
     docurl = CoreConfig.get('info').get('documentation')
     return helper.openbrowser(docurl)
Ejemplo n.º 7
0
 def docs():
     """
     Open documentation
     :raise PackageError
     :return: bool
     """
     docurl = CoreConfig.get('info').get('documentation')
     return helper.openbrowser(docurl)
Ejemplo n.º 8
0
def exception_log():
    """
    Get exception log path
    :return: string
    """

    exception_filelog = CoreConfig.get('data').get('exceptions_log')
    return filesystem.getabsname(exception_filelog)
Ejemplo n.º 9
0
    def update():
        """
        Check for update
        :raise PackageError
        :return: str
        """

        try:
            if False is sys().is_windows:
                status = process.execute(
                    CoreConfig.get('command').get('cvsupdate'))
                upd_status = tpl.line(status, color='green')
                msg = CoreConfig.get('update').format(status=upd_status)
            else:
                msg = CoreConfig.get('update').format(status=tpl.line(
                    key='upd_win_stat'))
            return msg
        except (AttributeError, CoreSystemError) as error:
            raise PackageError(error)
Ejemplo n.º 10
0
    def __license():
        """
        Get application license
        :raise PackageError
        :return: str
        """

        try:
            license_info = CoreConfig.get('info').get('license')
            return license_info
        except FileSystemError as error:
            raise PackageError(str(error))
Ejemplo n.º 11
0
    def __repo():
        """
        Get application repository url
        :raise PackageError
        :return: str
        """

        try:
            repository = CoreConfig.get('info').get('repository')
            return repository
        except FileSystemError as error:
            raise PackageError(str(error))
Ejemplo n.º 12
0
    def __app_name():
        """
        Get application name
        :raise PackageError
        :return: str
        """

        try:
            name = CoreConfig.get('info').get('name')
            return name
        except FileSystemError as error:
            raise PackageError(str(error))
Ejemplo n.º 13
0
    def local_version():
        """
        Get application local version
        :raise PackageError
        :return: str
        """

        try:
            version = CoreConfig.get('info').get('version')
            return version
        except FileSystemError as error:
            raise PackageError(str(error))
Ejemplo n.º 14
0
    def __init__(self, browser_config):
        """
        Reader constructor
        :param dict browser_config:
        """

        self.__config = CoreConfig.get('data')
        self.__browser_config = browser_config
        self.__useragents = []
        self.__proxies = []
        self.__ignored = []
        self.__counter = 0
Ejemplo n.º 15
0
    def __init__(self, browser_config):
        """
        Reader constructor
        :param dict browser_config:
        """

        self.__config = CoreConfig.get('data')
        self.__browser_config = browser_config
        self.__useragents = []
        self.__proxies = []
        self.__ignored = []
        self.__counter = 0
Ejemplo n.º 16
0
    def __license():
        """
        Get application license
        :raise PackageError
        :return: str
        """

        try:
            license_info = CoreConfig.get('info').get('license')
            return license_info
        except FileSystemError as error:
            raise PackageError(str(error))
Ejemplo n.º 17
0
    def __app_name():
        """
        Get application name
        :raise PackageError
        :return: str
        """

        try:
            name = CoreConfig.get('info').get('name')
            return name
        except FileSystemError as error:
            raise PackageError(str(error))
Ejemplo n.º 18
0
    def __repo():
        """
        Get application repository url
        :raise PackageError
        :return: str
        """

        try:
            repository = CoreConfig.get('info').get('repository')
            return repository
        except FileSystemError as error:
            raise PackageError(str(error))
Ejemplo n.º 19
0
    def local_version():
        """
        Get application local version
        :raise PackageError
        :return: str
        """

        try:
            version = CoreConfig.get('info').get('version')
            return version
        except FileSystemError as error:
            raise PackageError(str(error))
Ejemplo n.º 20
0
class Reporter(object):
    """Reporter class"""

    default = 'std'
    external_directory = None
    config = CoreConfig.get('data')

    @staticmethod
    def is_reported(resource):
        """
        Check if session is already reported
        :param str resource: target report
        :return: bool
        """

        try:
            if None is not Reporter.external_directory:
                if not Reporter.external_directory.endswith(os.path.sep):
                    Reporter.external_directory += os.path.sep
                is_reported = filesystem.is_exist(Reporter.external_directory,
                                                  resource)
            else:
                is_reported = filesystem.is_exist(
                    Reporter.config.get('reports'), resource)
            return is_reported
        except FileSystemError as error:
            raise ReporterError(error)

    @staticmethod
    def load(plugin_name, target, data):
        """
        Load report plugin
        :param str plugin_name: plugin name
        :param str target: target host
        :param dict data: report data
        :raise ReporterError
        :return: src.lib.reporter.plugins.provider.provider.PluginProvider
        """

        try:
            package_module = importlib.import_module(
                'src.lib.reporter.plugins')

            try:
                report = getattr(package_module, plugin_name)
                return report(target, data, Reporter.external_directory)
            except (TypeError, AttributeError, Exception) as error:
                raise ReporterError(
                    'Unable to get reporter `{plugin}`. Reason: {error}'.
                    format(plugin=plugin_name, error=error))
        except ImportError:
            raise ReporterError('Unable to get report\'s plugins`')
Ejemplo n.º 21
0
    def __proxies_count():
        """
        Get number of proxies in basic wordlist
        :raise PackageError
        :return: int
        """

        try:
            filename = CoreConfig.get('data').get('proxies')
            count = filesystem.read(filename).__len__()

            return count

        except FileSystemError as error:
            raise PackageError(str(error))
Ejemplo n.º 22
0
    def __proxies_count():
        """
        Get number of proxies in basic wordlist
        :raise PackageError
        :return: int
        """

        try:
            filename = CoreConfig.get('data').get('proxies')
            count = filesystem.read(filename).__len__()

            return count

        except FileSystemError as error:
            raise PackageError(str(error))
Ejemplo n.º 23
0
    def __init__(self, taget, data, directory=None):
        """
        PluginProvider constructor
        :param str taget: target host
        :param dict data: result set
        :param str directory: custom directory
        """

        PluginProvider.__init__(self, taget, data)

        try:
            if None is directory:
                directory = CoreConfig.get('data').get('reports')
            self.__target_dir = filesystem.makedir("".join((directory, self._target)))
        except FileSystemError as error:
            raise Exception(error)
Ejemplo n.º 24
0
    def version():
        """
        Load application version
        :raise PackageError
        :return: str
        """

        try:

            version = CoreConfig.get('version').format(Package.__app_name(), Package.__current_version(),
                                                       Package.__remote_version(), Package.__repo(),
                                                       Package.__license())
            return version

        except (FileSystemError, CoreSystemError, PackageError) as error:
            raise PackageError(error)
Ejemplo n.º 25
0
    def __init__(self, taget, data, directory=None):
        """
        PluginProvider constructor
        :param str taget: target host
        :param dict data: result set
        :param str directory: custom directory
        """

        PluginProvider.__init__(self, taget, data)

        try:
            if None is directory:
                directory = CoreConfig.get('data').get('reports')
            self.__target_dir = filesystem.makedir("".join(
                (directory, self._target)))
        except FileSystemError as error:
            raise Exception(error)
Ejemplo n.º 26
0
    def version():
        """
        Load application version
        :raise PackageError
        :return: str
        """

        try:

            version = CoreConfig.get('version').format(
                Package.__app_name(), Package.__current_version(),
                Package.__remote_version(), Package.__repo(),
                Package.__license())
            return version

        except (FileSystemError, CoreSystemError, PackageError) as error:
            raise PackageError(error)
Ejemplo n.º 27
0
    def check_interpreter():
        """
        Get interpreter version
        :return: dict or bool
        """

        versions = CoreConfig.get('info').get('required_versions')
        actual_version = sys.version()
        target_compare = (actual_version == versions.get('minor') or actual_version == versions.get('major'))
        relative_compare = (helper.is_less(versions.get('minor'), actual_version) is True or
                            helper.is_more(actual_version, versions.get('major')) is True)

        if target_compare or relative_compare:
            return True
        else:
            return {
                'status': False,
                'actual': actual_version, 'expected': versions.get('minor') + ' -> ' + versions.get('major')
            }
Ejemplo n.º 28
0
    def __remote_version():
        """
        Get application remote version
        :raise PackageError
        :return: str
        """

        if None is Package.remote_version:

            try:
                request_uri = CoreConfig.get('info').get('remote_version')
                result = process.execute('curl -sb GET {uri}'.format(uri=request_uri))
                Package.remote_version = str(result, "utf-8")
                return Package.remote_version

            except (FileSystemError, CoreSystemError) as error:
                raise PackageError(error)
        else:
            return Package.remote_version
Ejemplo n.º 29
0
    def __remote_version():
        """
        Get application remote version
        :raise PackageError
        :return: str
        """

        if None is Package.remote_version:

            try:
                request_uri = CoreConfig.get('info').get('remote_version')
                result = process.execute(
                    'curl -sb GET {uri}'.format(uri=request_uri))
                Package.remote_version = str(result, "utf-8")
                return Package.remote_version

            except (FileSystemError, CoreSystemError) as error:
                raise PackageError(error)
        else:
            return Package.remote_version
Ejemplo n.º 30
0
    def banner():
        """
        Load application banner

        :raise PackageError
        :return: str
        """

        try:

            banner = CoreConfig.get('banner').format(
                tpl.line('Directories: {0}'.format(Package.__directories_count()), color='blue'),
                tpl.line('Subdomains: {0}'.format(Package.__subdomains_count()), color='blue'),
                tpl.line('Browsers: {0}'.format(Package.__browsers_count()), color='blue'),
                tpl.line('Proxies: {0}'.format(Package.__proxies_count()), color='blue'),
                tpl.line(Package.__license(), color='blue'))

            return banner

        except (FileSystemError, CoreSystemError, PackageError) as error:
            raise PackageError(error)
Ejemplo n.º 31
0
    def check_interpreter():
        """
        Get interpreter version
        :return: dict or bool
        """

        versions = CoreConfig.get('info').get('required_versions')
        actual_version = sys.version()
        target_compare = (actual_version == versions.get('minor')
                          or actual_version == versions.get('major'))
        relative_compare = (
            helper.is_less(versions.get('minor'), actual_version) is True
            or helper.is_more(actual_version, versions.get('major')) is True)

        if target_compare or relative_compare:
            return True
        else:
            return {
                'status': False,
                'actual': actual_version,
                'expected':
                versions.get('minor') + ' -> ' + versions.get('major')
            }