Skip to content

Commit

Permalink
代码格式化,增加注释
Browse files Browse the repository at this point in the history
  • Loading branch information
ywolf committed Jan 17, 2019
1 parent a4783c3 commit f1f9804
Show file tree
Hide file tree
Showing 40 changed files with 273 additions and 267 deletions.
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ type Meta struct{
PassList []string `json:"passlist"`
}

type TaskInfo struct {
type Task struct {
Type string `json:"type"`
Netloc string `json:"netloc"`
Target string `json:"target"`
Expand Down Expand Up @@ -147,7 +147,7 @@ func main() {
kunpeng.SetConfig(string(configJSONBytes))

// 扫描目标
task := TaskInfo{
task := Task{
Type: "service",
Netloc: "192.168.0.105:3306",
Target: "mysql",
Expand All @@ -158,7 +158,7 @@ func main() {
PassList: []string{"ttest"},
},
}
task2 := TaskInfo{
task2 := Task{
Type: "web",
Netloc: "http://www.google.cn",
Target: "web",
Expand Down Expand Up @@ -252,16 +252,16 @@ import (

// 定义插件结构,info,result需固定存在
type redisWeakPass struct {
info plugin.PluginInfo //插件信息
result []plugin.PluginInfo //漏洞结果集,可返回多个
info plugin.Plugin //插件信息
result []plugin.Plugin //漏洞结果集,可返回多个
}

func init() {
// 注册插件,定义插件目标名称
plugin.Regist("redis", &redisWeakPass{})
}
func (d *redisWeakPass) Init() plugin.PluginInfo{
d.info = plugin.PluginInfo{
func (d *redisWeakPass) Init() plugin.Plugin{
d.info = plugin.Plugin{
Name: "Redis 未授权访问/弱口令", // 插件名称
Remarks: "导致敏感信息泄露,严重可导致服务器直接被入侵控制。", // 漏洞描述
Level: 0, // 漏洞等级 {0:"严重",1:"高危",2:"中危",3:"低危",4:"提示"}
Expand All @@ -275,7 +275,7 @@ func (d *redisWeakPass) Init() plugin.PluginInfo{
return d.info
}

func (d *redisWeakPass) GetResult() []plugin.PluginInfo {
func (d *redisWeakPass) GetResult() []plugin.Plugin {
return d.result
}

Expand Down Expand Up @@ -318,16 +318,16 @@ import (
)

type webDavRCE struct {
info plugin.PluginInfo
result []plugin.PluginInfo
info plugin.Plugin
result []plugin.Plugin
}

func init() {
plugin.Regist("iis", &webDavRCE{})
}

func (d *webDavRCE) Init() plugin.PluginInfo{
d.info = plugin.PluginInfo{
func (d *webDavRCE) Init() plugin.Plugin{
d.info = plugin.Plugin{
Name: "WebDav PROPFIND RCE(理论检测)",
Remarks: "CVE-2017-7269,Windows Server 2003R2版本IIS6.0的WebDAV服务中的ScStoragePathFromUrl函数存在缓存区溢出漏洞",
Level: 1,
Expand All @@ -341,7 +341,7 @@ func (d *webDavRCE) Init() plugin.PluginInfo{
return d.info
}

func (d *webDavRCE) GetResult() []plugin.PluginInfo {
func (d *webDavRCE) GetResult() []plugin.Plugin {
return d.result
}

Expand Down
22 changes: 12 additions & 10 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,27 @@ package config

import "encoding/json"


type config struct{
Timeout int `json:"timeout"`
Aider string `json:"aider"`
HTTPProxy string `json:"httpproxy"`
PassList []string `json:"passlist"`
type config struct {
Timeout int `json:"timeout"`
Aider string `json:"aider"`
HTTPProxy string `json:"httpproxy"`
PassList []string `json:"passlist"`
}

// Config
// Config 全局配置信息
var Config config

func init(){
func init() {
Config.PassList = []string{
"{user}", "{user}123", "admin", "123456", "",
}
Config.Timeout = 15
}

// Set set config
func Set(configJSON string){
// Set 设置配置信息
func Set(configJSON string) {
json.Unmarshal([]byte(configJSON), &Config)
if Config.Timeout == 0 {
Config.Timeout = 15
}
}
51 changes: 24 additions & 27 deletions example/callsoTest.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,33 @@ import "plugin"
import "fmt"
import "encoding/json"


type config struct{
Timeout int `json:"timeout"`
Aider string `json:"aider"`
HTTPProxy string `json:"httpproxy"`
PassList []string `json:"passlist"`
type config struct {
Timeout int `json:"timeout"`
Aider string `json:"aider"`
HTTPProxy string `json:"httpproxy"`
PassList []string `json:"passlist"`
}

type Meta struct{
System string `json:"system"`
type Meta struct {
System string `json:"system"`
PathList []string `json:"pathlist"`
FileList []string `json:"filelist"`
PassList []string `json:"passlist"`
}

type TaskInfo struct {
Type string `json:"type"`
type Task struct {
Type string `json:"type"`
Netloc string `json:"netloc"`
Target string `json:"target"`
Meta Meta `json:"meta"`
Meta Meta `json:"meta"`
}

type Greeter interface {
Check(taskJSON string) ([]map[string]string)
Check(taskJSON string) []map[string]string
GetPlugins() []map[string]string
SetConfig(configJSON string)
}


func main() {
// 加载go plugin
plug, err := plugin.Open("./kunpeng_go.so")
Expand All @@ -56,42 +54,41 @@ func main() {

// 修改配置
c := &config{
Timeout: 15,
Aider: "",
Timeout: 15,
Aider: "",
HTTPProxy: "",
PassList: []string{"ptest"},
PassList: []string{"ptest"},
}
configJSONBytes, _ := json.Marshal(c)
kunpeng.SetConfig(string(configJSONBytes))

// 扫描目标
task := TaskInfo{
Type: "service",
task := Task{
Type: "service",
Netloc: "192.168.0.105:3306",
Target: "mysql",
Meta : Meta{
System : "",
Meta: Meta{
System: "",
PathList: []string{},
FileList: []string{},
PassList: []string{"ttest"},
},
}
task2 := TaskInfo{
Type: "web",
task2 := Task{
Type: "web",
Netloc: "http://www.google.cn",
Target: "web",
Meta : Meta{
System : "",
Meta: Meta{
System: "",
PathList: []string{},
FileList: []string{},
PassList: []string{},
},
}
jsonBytes, _ := json.Marshal(task)
result:= kunpeng.Check(string(jsonBytes))
result := kunpeng.Check(string(jsonBytes))
fmt.Println(result)
jsonBytes, _ = json.Marshal(task2)
result= kunpeng.Check(string(jsonBytes))
result = kunpeng.Check(string(jsonBytes))
fmt.Println(result)
}

4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
type greeting string

func (g greeting) Check(taskJSON string) []map[string]interface{} {
var task plugin.TaskInfo
var task plugin.Task
json.Unmarshal([]byte(taskJSON), &task)
return plugin.Scan(task)
}
Expand All @@ -35,7 +35,7 @@ func StartWebServer() {
//export Check
func Check(task *C.char) *C.char {
fmt.Println(C.GoString(task))
var m plugin.TaskInfo
var m plugin.Task
err := json.Unmarshal([]byte(C.GoString(task)), &m)
if err != nil {
fmt.Println(err.Error())
Expand Down
4 changes: 2 additions & 2 deletions plugin/go.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package plugin

// GoPlugin 插件接口
type GoPlugin interface {
Init() PluginInfo
Init() Plugin
Check(netloc string, meta TaskMeta) bool
GetResult() []PluginInfo
GetResult() []Plugin
}

// Regist 注册插件
Expand Down
10 changes: 5 additions & 5 deletions plugin/go/axisWeakPass.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import (
)

type axisWeakPass struct {
info plugin.PluginInfo
result []plugin.PluginInfo
info plugin.Plugin
result []plugin.Plugin
}

func init() {
plugin.Regist("axis", &axisWeakPass{})
}
func (d *axisWeakPass) Init() plugin.PluginInfo {
d.info = plugin.PluginInfo{
func (d *axisWeakPass) Init() plugin.Plugin {
d.info = plugin.Plugin{
Name: "Axis2控制台 弱口令",
Remarks: "攻击者通过此漏洞可以登陆管理控制台,通过部署功能可直接获取服务器权限。",
Level: 0,
Expand All @@ -30,7 +30,7 @@ func (d *axisWeakPass) Init() plugin.PluginInfo {
}
return d.info
}
func (d *axisWeakPass) GetResult() []plugin.PluginInfo {
func (d *axisWeakPass) GetResult() []plugin.Plugin {
return d.result
}
func (d *axisWeakPass) Check(URL string, meta plugin.TaskMeta) bool {
Expand Down
10 changes: 5 additions & 5 deletions plugin/go/directoryBrowse.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import (
)

type directoryBrowse struct {
info plugin.PluginInfo
result []plugin.PluginInfo
info plugin.Plugin
result []plugin.Plugin
}

func init() {
plugin.Regist("web", &directoryBrowse{})
}
func (d *directoryBrowse) Init() plugin.PluginInfo{
d.info = plugin.PluginInfo{
func (d *directoryBrowse) Init() plugin.Plugin{
d.info = plugin.Plugin{
Name: "web目录遍历",
Remarks: "通过此功能可获取web目录程序结构",
Level: 3,
Expand All @@ -31,7 +31,7 @@ func (d *directoryBrowse) Init() plugin.PluginInfo{
}
return d.info
}
func (d *directoryBrowse) GetResult() []plugin.PluginInfo {
func (d *directoryBrowse) GetResult() []plugin.Plugin {
return d.result
}
func (d *directoryBrowse) Check(URL string, meta plugin.TaskMeta) bool {
Expand Down
10 changes: 5 additions & 5 deletions plugin/go/discuz7xRCE.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import (
)

type discuz7xRCE struct {
info plugin.PluginInfo
result []plugin.PluginInfo
info plugin.Plugin
result []plugin.Plugin
}

func init() {
plugin.Regist("discuz", &discuz7xRCE{})
}
func (d *discuz7xRCE) Init() plugin.PluginInfo{
d.info = plugin.PluginInfo{
func (d *discuz7xRCE) Init() plugin.Plugin{
d.info = plugin.Plugin{
Name: "Discuz! 6.x/7.x 代码执行",
Remarks: "Discuz! 6.x/7.x 全局变量防御绕过导致命令执行",
Level: 0,
Expand All @@ -30,7 +30,7 @@ func (d *discuz7xRCE) Init() plugin.PluginInfo{
}
return d.info
}
func (d *discuz7xRCE) GetResult() []plugin.PluginInfo {
func (d *discuz7xRCE) GetResult() []plugin.Plugin {
return d.result
}
func (d *discuz7xRCE) getTIDList(URL string) (tIDList []string) {
Expand Down
10 changes: 5 additions & 5 deletions plugin/go/ftpWeakPass.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import (
)

type ftpWeakPass struct {
info plugin.PluginInfo
result []plugin.PluginInfo
info plugin.Plugin
result []plugin.Plugin
}

func init() {
plugin.Regist("ftp", &ftpWeakPass{})
}
func (d *ftpWeakPass) Init() plugin.PluginInfo{
d.info = plugin.PluginInfo{
func (d *ftpWeakPass) Init() plugin.Plugin{
d.info = plugin.Plugin{
Name: "FTP 弱口令",
Remarks: "导致敏感信息泄露,严重可导致服务器直接被入侵控制。",
Level: 1,
Expand All @@ -29,7 +29,7 @@ func (d *ftpWeakPass) Init() plugin.PluginInfo{
}
return d.info
}
func (d *ftpWeakPass) GetResult() []plugin.PluginInfo {
func (d *ftpWeakPass) GetResult() []plugin.Plugin {
return d.result
}
func (d *ftpWeakPass) Check(netloc string, meta plugin.TaskMeta) (b bool) {
Expand Down
Loading

0 comments on commit f1f9804

Please sign in to comment.