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)
def exception_log(): """ Get exception log path :return: string """ exception_filelog = CoreConfig.get('data').get('exceptions_log') return filesystem.getabsname(exception_filelog)
def examples(): """ Load examples of usage :return: str """ examples = CoreConfig.get('examples') return examples
def docs(): """ Open documentation :raise PackageError :return: bool """ docurl = CoreConfig.get('info').get('documentation') return helper.openbrowser(docurl)
def docs(): """ Open documentation :raise PackageError :return: bool """ docurl = CoreConfig.get('info').get('documentation') return helper.openbrowser(docurl)
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)
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))
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))
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))
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))
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))
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
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))
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))
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))
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`')
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))
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))
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)
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)
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') }
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
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
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)