EXP编写文档
quick start¶
先来看一个最简单的插件示例
package ruijieRCE
import (
"api/types"
"context"
"time"
"fmt"
)
var (
pluginType = "custom"
name = "Ruijie Networks-EWEB Network Management System RCE"
vulType = "rce"
component = "ruijie"
author = "pikpikcu"
description = "test description"
reference = []string {
"https://github.com/yumusb/EgGateWayGetShell_py/blob/main/eg.py",
"https://www.ruijienetworks.com",
}
tags = []string {
"ruijie",
"rce",
"network",
}
)
var opts = types.NewOptions()
func init() {
opts.Int("level", true, "this is a level", 1, func(v interface{}) bool {
vv := v.(int)
return vv >= 1 && vv < 10
})
opts.String("target", true, "目标", "")
}
func exploit(ctx context.Context, params map[string]interface{}) (types.PluginResult) {
l := params["level"].(int)
for i:=0; i<l; i++ {
fmt.Println(i)
time.Sleep(1*time.Second)
}
return types.PluginResult{
Success: true,
}
}
其中:
- pluginType: 插件类型(目前只支持custom),必填
- vulType: 漏洞类型,必填
- component: 漏洞所属组件,必填
- name: 插件名称,必填
- author: 插件作者,选填
- description: 插件描述,选填
- reference: 插件引用资料,选填
- tags: 插件所属标签,选填
var opts = types.NewOptions()
func init() {
opts.Int("level", true, "this is a level", 1, func(v interface{}) bool {
vv := v.(int)
return vv >= 1 && vv < 10
})
opts.String("target", true, "目标", "")
}
先关注插件参数写法,该例子中意味着有
- 一个int类型参数,参数名为
level,是必填的,参数描述为this is a level,最后的为校验函数,校验该参数大于等于1,小于10 - 一个target参数,该参数是插件必要的参数(所有插件都需要有这个参数),类型为String
func exploit(ctx context.Context, params map[string]interface{}) (types.PluginResult) 是插件的入口函数,其中params为用户传入的插件参数,
types.PluginResult 返回插件的结果
可以查看相关的插件示例来学习插件的编写方法
外部库¶
外部库指可以在插件中使用的库
目前引入了两个外部库
- github.com/comwrg/ysoserial
- github.com/tidwall/gjson
智能提示¶
可以克隆仓库 git clone http://git.ah-strategy.online/Akkuman/expgo
然后按照 _example 中的样例来进行插件的编写
本地测试¶
前往 releases 页面下载测试程序进行测试
