栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

CALDERA入门(2)(构建插件入门)

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

CALDERA入门(2)(构建插件入门)

CALDERA入门(2)(构建插件入门) 一、编写插件代码

1.在caldera/plugins文件夹中创建文件夹test

2.在test文件夹中创建hook.py文件,以下是hook.py此次用的代码

from aiohttp_jinja2 import template, web

from app.service.auth_svc import check_authorization

name = 'test'
description = 'A sample plugin for demonstration purposes'
address = '/plugin/abilities/gui'


async def enable(services):
    app = services.get('app_svc').application
    fetcher = AbilityFetcher(services)
    app.router.add_route('*', '/plugin/abilities/gui', fetcher.splash)
    app.router.add_route('GET', '/get/abilities', fetcher.get_abilities)


class AbilityFetcher:
    def __init__(self, services):
        self.services = services
        self.auth_svc = services.get('auth_svc')

    async def get_abilities(self, request):
        abilities = await self.services.get('data_svc').locate('abilities')
        return web.json_response(dict(abilities=[a.display for a in abilities]))

    @check_authorization
    @template('abilities.html')
    async def splash(self, request):
        abilities = await self.services.get('data_svc').locate('abilities')
        return(dict(abilities=[a.display for a in abilities]))

3.在test文件夹中创建templates文件夹,并在templates文件夹中创建test.html文件,此次html文件代码如下:

功课表

战术 技术 能力 描述 命令 结果 系统
collection T1005|Data from Local System Find Git Repositories 此功能将定位作为克隆Git存储库的目录。 1234 Windows/Linux
二、启用插件

1.在caldera/conf/local.yml中的plugin一栏加入- test

2.在左侧菜单栏的configuration中启用插件


最后重启插件便启用成功了

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/926181.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号