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文件代码如下:

<table border='1'>

<p style="text-align:center ">功课表</p>

<tr>

<th>战术</th>

<th>技术</th>

<th>能力</th>

<th>描述</th>

<th>命令</th>

<th>结果</th>

<th>系统</th>
</tr>

<tr>

<td>collection</td>

<td>T1005|Data from Local System</td>

<td>Find Git Repositories</td>
<td>此功能将定位作为克隆Git存储库的目录。</td>
<td>1234</td>
<td></td>
<td>Windows/Linux</td>
</tr>

</table>

二、启用插件

1.在caldera/conf/local.yml中的plugin一栏加入- test
在这里插入图片描述

2.在左侧菜单栏的configuration中启用插件在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
最后重启插件便启用成功了在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值