mirror of https://gitee.com/openkylin/genmai.git
完成简单的漏洞报告功能
This commit is contained in:
parent
c86bb0deed
commit
fe9f46216e
Before Width: | Height: | Size: 101 KiB After Width: | Height: | Size: 101 KiB |
|
@ -1,4 +1,5 @@
|
|||
ConfigFilePrefix: /home/test/桌面/genmai/data/pocs/
|
||||
#ConfigFilePrefix: /home/test/桌面/genmai/data/pocs/
|
||||
ConfigFilePrefix: /home/alpha/Developments/kylinprojects/genmai/data/pocs/
|
||||
ExplorerItems:
|
||||
- Type: kernel
|
||||
ConfigFile: CVE-2021-3156/CVE-2021-3156.yaml
|
||||
|
|
Before Width: | Height: | Size: 56 KiB After Width: | Height: | Size: 56 KiB |
Before Width: | Height: | Size: 95 KiB After Width: | Height: | Size: 95 KiB |
|
@ -32,7 +32,8 @@ import (
|
|||
"github.com/jesseduffield/gocui"
|
||||
)
|
||||
|
||||
type FrameBase interface{
|
||||
type
|
||||
FrameBase interface {
|
||||
Setup()
|
||||
Quit(g *gocui.Gui, v*gocui.View)
|
||||
KeyBinding(g *gocui.Gui)
|
||||
|
|
|
@ -31,7 +31,8 @@ package gconsole
|
|||
import (
|
||||
)
|
||||
|
||||
type FrameMain struct {
|
||||
type
|
||||
FrameMain struct {
|
||||
Title string
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,8 @@ import (
|
|||
)
|
||||
|
||||
// TODO: to make it can config
|
||||
func (fm *FrameMain)KeyBinding(g *gocui.Gui) error {
|
||||
func
|
||||
(fm *FrameMain)KeyBinding(g *gocui.Gui) error {
|
||||
rcs := []error{}
|
||||
|
||||
// Program Command
|
||||
|
@ -99,6 +100,7 @@ func (fm *FrameMain)KeyBinding(g *gocui.Gui) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (fm *FrameMain)Quit(g *gocui.Gui, v*gocui.View) error {
|
||||
func
|
||||
(fm *FrameMain)Quit(g *gocui.Gui, v*gocui.View) error {
|
||||
return gocui.ErrQuit
|
||||
}
|
||||
|
|
|
@ -41,29 +41,37 @@ const (
|
|||
|
||||
///////////////////////////////
|
||||
// navigation
|
||||
func (fm *FrameMain)NextView(g *gocui.Gui, v *gocui.View) error {
|
||||
func
|
||||
(fm *FrameMain)NextView(g *gocui.Gui, v *gocui.View) error {
|
||||
return nil
|
||||
}
|
||||
func (fm *FrameMain)PreView(g *gocui.Gui, v *gocui.View) error {
|
||||
func
|
||||
(fm *FrameMain)PreView(g *gocui.Gui, v *gocui.View) error {
|
||||
return nil
|
||||
}
|
||||
/* */
|
||||
func (fm *FrameMain)NextSummary(g *gocui.Gui, v *gocui.View) error {
|
||||
func
|
||||
(fm *FrameMain)NextSummary(g *gocui.Gui, v *gocui.View) error {
|
||||
return nil
|
||||
}
|
||||
func (fm *FrameMain)PreSummary(g *gocui.Gui, v *gocui.View) error {
|
||||
func
|
||||
(fm *FrameMain)PreSummary(g *gocui.Gui, v *gocui.View) error {
|
||||
return nil
|
||||
}
|
||||
/* */
|
||||
func (fm *FrameMain)CursorDown(g *gocui.Gui, v *gocui.View) error {
|
||||
func
|
||||
(fm *FrameMain)CursorDown(g *gocui.Gui, v *gocui.View) error {
|
||||
return nil
|
||||
}
|
||||
func (fm *FrameMain)CursorUp(g *gocui.Gui, v *gocui.View) error {
|
||||
func
|
||||
(fm *FrameMain)CursorUp(g *gocui.Gui, v *gocui.View) error {
|
||||
return nil
|
||||
}
|
||||
func (fm *FrameMain)CursorPageDown(g *gocui.Gui, v *gocui.View) error {
|
||||
func
|
||||
(fm *FrameMain)CursorPageDown(g *gocui.Gui, v *gocui.View) error {
|
||||
return nil
|
||||
}
|
||||
func (fm *FrameMain)CursorPageUp(g *gocui.Gui, v *gocui.View) error {
|
||||
func
|
||||
(fm *FrameMain)CursorPageUp(g *gocui.Gui, v *gocui.View) error {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -33,30 +33,33 @@ import (
|
|||
"main/genmai"
|
||||
)
|
||||
|
||||
type FrameReport struct {
|
||||
reports []genmai.ReportBase
|
||||
curReport genmai.ReportBase
|
||||
type
|
||||
FrameReport struct {
|
||||
reports []genmai.ReportKernel
|
||||
curReport genmai.ReportKernel
|
||||
vulnInfos []genmai.VulnInfoCommon
|
||||
curVulnInfo int
|
||||
curVulnInfoViewLimitY int
|
||||
curVuln int
|
||||
curVulnViewLimitY int
|
||||
curReportViewLimitY int
|
||||
}
|
||||
|
||||
var G_FrameReport FrameReport
|
||||
|
||||
// TODO: may be should remove this function
|
||||
func (fr *FrameReport)Setup() {
|
||||
fr.reports = append(fr.reports, genmai.GetTemplateReportKernel())
|
||||
fr.reports = append(fr.reports, genmai.GetTemplateReportKernel())
|
||||
func
|
||||
(fr *FrameReport)Setup(rps []genmai.ReportKernel) {
|
||||
// fr.reports = append(fr.reports, genmai.GetTemplateReportKernel())
|
||||
// fr.reports = append(fr.reports, genmai.GetTemplateReportKernel())
|
||||
// /* */
|
||||
// fr.reports = append(fr.reports, genmai.GetTemplateReportDBus())
|
||||
// fr.reports = append(fr.reports, genmai.GetTemplateReportDBus())
|
||||
// /* */
|
||||
// fr.reports = append(fr.reports, genmai.GetTemplateReportSystem())
|
||||
// fr.reports = append(fr.reports, genmai.GetTemplateReportSystem())
|
||||
/* */
|
||||
fr.reports = append(fr.reports, genmai.GetTemplateReportDBus())
|
||||
fr.reports = append(fr.reports, genmai.GetTemplateReportDBus())
|
||||
/* */
|
||||
fr.reports = append(fr.reports, genmai.GetTemplateReportSystem())
|
||||
fr.reports = append(fr.reports, genmai.GetTemplateReportSystem())
|
||||
//fr.curReport =
|
||||
/* */
|
||||
fr.curVulnInfo = 1
|
||||
fr.curVulnInfoViewLimitY = 1
|
||||
fr.reports = rps
|
||||
fr.curReport = rps[0]
|
||||
fr.curVuln = 0
|
||||
fr.curVulnViewLimitY = 1
|
||||
fr.curReportViewLimitY = 1
|
||||
}
|
||||
|
|
|
@ -33,7 +33,8 @@ import (
|
|||
)
|
||||
|
||||
// TODO: to make it can config
|
||||
func (fr *FrameReport)KeyBinding(g *gocui.Gui) error {
|
||||
func
|
||||
(fr *FrameReport)KeyBinding(g *gocui.Gui) error {
|
||||
rcs := []error{}
|
||||
|
||||
// Program Command
|
||||
|
@ -261,6 +262,7 @@ func (fr *FrameReport)KeyBinding(g *gocui.Gui) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (fr *FrameReport)Quit(g *gocui.Gui, v*gocui.View) error {
|
||||
func
|
||||
(fr *FrameReport)Quit(g *gocui.Gui, v*gocui.View) error {
|
||||
return gocui.ErrQuit
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ package gconsole
|
|||
import (
|
||||
"fmt"
|
||||
//"strings"
|
||||
//"errors"
|
||||
"errors"
|
||||
"github.com/jesseduffield/gocui"
|
||||
)
|
||||
|
||||
|
@ -42,7 +42,8 @@ const (
|
|||
FRAMEREPORTVIEW_VIEWNAME_REPORT string = "report"
|
||||
)
|
||||
|
||||
type ViewRact struct {
|
||||
type
|
||||
ViewRact struct {
|
||||
Left int
|
||||
Top int
|
||||
Right int
|
||||
|
@ -51,25 +52,29 @@ type ViewRact struct {
|
|||
|
||||
///////////////////////////////
|
||||
// layout ract
|
||||
func VIEWRACT_TARGET(maxx int, maxy int) ViewRact {
|
||||
func
|
||||
VIEWRACT_TARGET(maxx int, maxy int) ViewRact {
|
||||
return ViewRact{(-1),
|
||||
(-1),
|
||||
32,
|
||||
maxy }
|
||||
}
|
||||
func VIEWRACT_VULN(maxx int, maxy int) ViewRact {
|
||||
func
|
||||
VIEWRACT_VULN(maxx int, maxy int) ViewRact {
|
||||
return ViewRact{32,
|
||||
-1,
|
||||
maxx,
|
||||
int(float64(maxy)*0.3) }
|
||||
}
|
||||
func VIEWRACT_VULNINFO(maxx int, maxy int) ViewRact {
|
||||
func
|
||||
VIEWRACT_VULNINFO(maxx int, maxy int) ViewRact {
|
||||
return ViewRact{32 + (int(float64(maxx - 32)*0.5)),
|
||||
(int(float64(maxy)*0.3)),
|
||||
maxx,
|
||||
maxy }
|
||||
}
|
||||
func VIEWRACT_REPORT(maxx int, maxy int) ViewRact {
|
||||
func
|
||||
VIEWRACT_REPORT(maxx int, maxy int) ViewRact {
|
||||
return ViewRact{32,
|
||||
(int(float64(maxy)*0.3)),
|
||||
32 + (int(float64(maxx - 32)*0.5)),
|
||||
|
@ -78,7 +83,8 @@ func VIEWRACT_REPORT(maxx int, maxy int) ViewRact {
|
|||
// layout ract
|
||||
///////////////////////////////
|
||||
|
||||
func (fr *FrameReport)SetTargetLayout(g *gocui.Gui) error {
|
||||
func
|
||||
(fr *FrameReport)SetTargetLayout(g *gocui.Gui) error {
|
||||
viewract := VIEWRACT_TARGET(g.Size())
|
||||
|
||||
view, rc := g.SetView(FRAMEREPORTVIEW_VIEWNAME_TARGET,
|
||||
|
@ -102,9 +108,17 @@ func (fr *FrameReport)SetTargetLayout(g *gocui.Gui) error {
|
|||
rpt.GetReportCommon().RCExploredIPv6Addrs[0] +
|
||||
":" +
|
||||
rpt.GetReportCommon().RCExploredIPv4Addrs[0] )
|
||||
} // for _, rp ...
|
||||
} // for _, rpt ...
|
||||
|
||||
if ( 0 == len(fr.reports) ) {
|
||||
A_DEBUG_WARNING("No report!")
|
||||
/* */
|
||||
// TODO
|
||||
return errors.New("No report!")
|
||||
}
|
||||
fr.curReport = fr.reports[0]
|
||||
|
||||
|
||||
rc = g.SetCurrentView(FRAMEREPORTVIEW_VIEWNAME_TARGET)
|
||||
/* */
|
||||
if (nil != rc) {
|
||||
|
@ -115,7 +129,8 @@ func (fr *FrameReport)SetTargetLayout(g *gocui.Gui) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (fr *FrameReport)SetVulnLayout(g *gocui.Gui) error {
|
||||
func
|
||||
(fr *FrameReport)SetVulnLayout(g *gocui.Gui) error {
|
||||
viewract := VIEWRACT_VULN(g.Size())
|
||||
|
||||
view, rc := g.SetView(FRAMEREPORTVIEW_VIEWNAME_VULN,
|
||||
|
@ -132,7 +147,7 @@ func (fr *FrameReport)SetVulnLayout(g *gocui.Gui) error {
|
|||
view.Wrap = false
|
||||
|
||||
// TODO: the initial number:0, not that precise
|
||||
for _, vinfo := range fr.reports[0].GetReportCommon().RCExploredVulns {
|
||||
for _, vinfo := range fr.curReport.GetReportCommon().RCExploredVulns {
|
||||
fmt.Fprintln(view, vinfo)
|
||||
} // for _, vinfo ...
|
||||
} // if (nil ...
|
||||
|
@ -140,7 +155,8 @@ func (fr *FrameReport)SetVulnLayout(g *gocui.Gui) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (fr *FrameReport)SetVulnInfoLayout(g *gocui.Gui) error {
|
||||
func
|
||||
(fr *FrameReport)SetVulnInfoLayout(g *gocui.Gui) error {
|
||||
viewract := VIEWRACT_VULNINFO(g.Size())
|
||||
|
||||
view, rc := g.SetView(FRAMEREPORTVIEW_VIEWNAME_VULNINFO,
|
||||
|
@ -153,7 +169,7 @@ func (fr *FrameReport)SetVulnInfoLayout(g *gocui.Gui) error {
|
|||
}
|
||||
|
||||
// TODO: the initial number:0, not that precise
|
||||
fmt.Fprintln(view, fr.reports[0].GetReportCommon().RCExploredVulns[0])
|
||||
fmt.Fprintln(view, fr.curReport.GetReportCommon().RCExploredVulns[fr.curVuln])
|
||||
|
||||
view.Editable = false
|
||||
view.Wrap = false
|
||||
|
@ -162,7 +178,8 @@ func (fr *FrameReport)SetVulnInfoLayout(g *gocui.Gui) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (fr *FrameReport)SetReportLayout(g *gocui.Gui) error {
|
||||
func
|
||||
(fr *FrameReport)SetReportLayout(g *gocui.Gui) error {
|
||||
viewract := VIEWRACT_REPORT(g.Size())
|
||||
|
||||
view, rc := g.SetView(FRAMEREPORTVIEW_VIEWNAME_REPORT,
|
||||
|
@ -176,10 +193,10 @@ func (fr *FrameReport)SetReportLayout(g *gocui.Gui) error {
|
|||
}
|
||||
|
||||
// TODO: the initial number:0, not that precise
|
||||
fmt.Fprintln(view, fr.reports[0].GetReportCommon().RCServerUUID)
|
||||
fmt.Fprintln(view, fr.reports[0].GetReportCommon().RCServerName)
|
||||
fmt.Fprintln(view, fr.reports[0].GetReportCommon().RCFamily)
|
||||
fmt.Fprintln(view, fr.reports[0].GetReportCommon())
|
||||
fmt.Fprintln(view, fr.curReport.GetReportCommon().RCServerUUID)
|
||||
fmt.Fprintln(view, fr.curReport.GetReportCommon().RCServerName)
|
||||
fmt.Fprintln(view, fr.curReport.GetReportCommon().RCFamily)
|
||||
fmt.Fprintln(view, fr.curReport.GetReportCommon())
|
||||
|
||||
view.Editable = false
|
||||
view.Wrap = false
|
||||
|
@ -190,7 +207,8 @@ func (fr *FrameReport)SetReportLayout(g *gocui.Gui) error {
|
|||
|
||||
///////////////////////////////
|
||||
// navigation
|
||||
func (fr *FrameReport)NextView(g *gocui.Gui, v *gocui.View) error {
|
||||
func
|
||||
(fr *FrameReport)NextView(g *gocui.Gui, v *gocui.View) error {
|
||||
var rc error
|
||||
|
||||
if (nil == v) {
|
||||
|
@ -212,7 +230,8 @@ func (fr *FrameReport)NextView(g *gocui.Gui, v *gocui.View) error {
|
|||
|
||||
return rc
|
||||
}
|
||||
func (fr *FrameReport)PreView(g *gocui.Gui, v *gocui.View) error {
|
||||
func
|
||||
(fr *FrameReport)PreView(g *gocui.Gui, v *gocui.View) error {
|
||||
var rc error
|
||||
|
||||
if (nil == v) {
|
||||
|
@ -235,14 +254,17 @@ func (fr *FrameReport)PreView(g *gocui.Gui, v *gocui.View) error {
|
|||
return rc
|
||||
}
|
||||
/* */
|
||||
func (fr *FrameReport)NextVulnItem(g *gocui.Gui, v *gocui.View) error {
|
||||
func
|
||||
(fr *FrameReport)NextVulnItem(g *gocui.Gui, v *gocui.View) error {
|
||||
return nil
|
||||
}
|
||||
func (fr *FrameReport)PreVulnItem(g *gocui.Gui, v *gocui.View) error {
|
||||
func
|
||||
(fr *FrameReport)PreVulnItem(g *gocui.Gui, v *gocui.View) error {
|
||||
return nil
|
||||
}
|
||||
/* */
|
||||
func (fr *FrameReport)CursorDown(g *gocui.Gui, v *gocui.View) error {
|
||||
func
|
||||
(fr *FrameReport)CursorDown(g *gocui.Gui, v *gocui.View) error {
|
||||
if (nil != v) {
|
||||
cx, cy := v.Cursor()
|
||||
ox, oy := v.Origin()
|
||||
|
@ -277,7 +299,8 @@ func (fr *FrameReport)CursorDown(g *gocui.Gui, v *gocui.View) error {
|
|||
|
||||
return nil
|
||||
}
|
||||
func (fr *FrameReport)CursorUp(g *gocui.Gui, v *gocui.View) error {
|
||||
func
|
||||
(fr *FrameReport)CursorUp(g *gocui.Gui, v *gocui.View) error {
|
||||
if (nil != v) {
|
||||
ox, oy := v.Origin()
|
||||
cx, cy := v.Cursor()
|
||||
|
@ -297,17 +320,20 @@ func (fr *FrameReport)CursorUp(g *gocui.Gui, v *gocui.View) error {
|
|||
/* */
|
||||
return nil
|
||||
}
|
||||
func (fr *FrameReport)CursorPageDown(g *gocui.Gui, v *gocui.View) error {
|
||||
func
|
||||
(fr *FrameReport)CursorPageDown(g *gocui.Gui, v *gocui.View) error {
|
||||
return nil
|
||||
}
|
||||
func (fr *FrameReport)CursorPageUp(g *gocui.Gui, v *gocui.View) error {
|
||||
func
|
||||
(fr *FrameReport)CursorPageUp(g *gocui.Gui, v *gocui.View) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////
|
||||
// Utils
|
||||
func (fr *FrameReport)movable(v *gocui.View, nextY int) (ok bool, yLimit int) {
|
||||
func
|
||||
(fr *FrameReport)movable(v *gocui.View, nextY int) (ok bool, yLimit int) {
|
||||
switch ( v.Name() ) {
|
||||
case FRAMEREPORTVIEW_VIEWNAME_TARGET:
|
||||
yLimit = len(fr.reports) - 1
|
||||
|
@ -325,7 +351,7 @@ func (fr *FrameReport)movable(v *gocui.View, nextY int) (ok bool, yLimit int) {
|
|||
/* */
|
||||
return true, yLimit
|
||||
case FRAMEREPORTVIEW_VIEWNAME_VULNINFO:
|
||||
return false, fr.curVulnInfoViewLimitY
|
||||
return false, fr.curVulnViewLimitY
|
||||
case FRAMEREPORTVIEW_VIEWNAME_REPORT:
|
||||
return false, fr.curReportViewLimitY
|
||||
default:
|
||||
|
@ -334,13 +360,29 @@ func (fr *FrameReport)movable(v *gocui.View, nextY int) (ok bool, yLimit int) {
|
|||
}
|
||||
|
||||
// redraw views
|
||||
func (fr *FrameReport)onMovingCursorRedrawView(g *gocui.Gui, v *gocui.View) error {
|
||||
func
|
||||
(fr *FrameReport)onMovingCursorRedrawView(g *gocui.Gui, v *gocui.View) error {
|
||||
switch ( v.Name() ) {
|
||||
case FRAMEREPORTVIEW_VIEWNAME_TARGET:
|
||||
if rc := fr.redrawViewTarget(g, v); (nil != rc) {
|
||||
return rc
|
||||
}
|
||||
case FRAMEREPORTVIEW_VIEWNAME_VULN:
|
||||
// we don't need to redraw
|
||||
// if rc := fr.redrawViewVuln(g, v); (nil != rc) {
|
||||
// return rc
|
||||
// } // if rc := ...
|
||||
// /* */
|
||||
// we just need to chage fr.curVuln
|
||||
_, cy := v.Cursor()
|
||||
_, rc_t := v.Line(cy)
|
||||
rc := rc_t
|
||||
if (nil != rc) {
|
||||
return rc
|
||||
} // if (nil != ...
|
||||
// TODO: 这样不够准确
|
||||
fr.curVuln = cy
|
||||
|
||||
if rc := fr.redrawViewVulnInfo(g); (nil != rc) {
|
||||
return rc
|
||||
} // if rc := ...
|
||||
|
@ -352,7 +394,8 @@ func (fr *FrameReport)onMovingCursorRedrawView(g *gocui.Gui, v *gocui.View) erro
|
|||
return nil
|
||||
}
|
||||
|
||||
func (fr *FrameReport)redrawViewTarget(g *gocui.Gui, v *gocui.View) error {
|
||||
func
|
||||
(fr *FrameReport)redrawViewTarget(g *gocui.Gui, v *gocui.View) error {
|
||||
rc := g.DeleteView(FRAMEREPORTVIEW_VIEWNAME_REPORT)
|
||||
/* */
|
||||
if (nil != rc) {
|
||||
|
@ -405,7 +448,31 @@ func (fr *FrameReport)redrawViewTarget(g *gocui.Gui, v *gocui.View) error {
|
|||
return rc
|
||||
}
|
||||
|
||||
func (fr *FrameReport)redrawViewVulnInfo(g *gocui.Gui) error {
|
||||
func
|
||||
(fr *FrameReport)redrawViewVuln(g *gocui.Gui, v *gocui.View) error {
|
||||
rc := g.DeleteView(FRAMEREPORTVIEW_VIEWNAME_VULN)
|
||||
/* */
|
||||
if (nil != rc) {
|
||||
return rc
|
||||
} // if (nil ...
|
||||
|
||||
_, cy := v.Cursor()
|
||||
_, rc_t := v.Line(cy)
|
||||
rc = rc_t
|
||||
if (nil != rc) {
|
||||
return rc
|
||||
} // if (nil != ...
|
||||
|
||||
//targetname := strings.TrimSpace(l)
|
||||
|
||||
// TODO: 这样不够准确
|
||||
fr.curVuln = cy
|
||||
|
||||
return fr.SetVulnLayout(g)
|
||||
}
|
||||
|
||||
func
|
||||
(fr *FrameReport)redrawViewVulnInfo(g *gocui.Gui) error {
|
||||
rc := g.DeleteView(FRAMEREPORTVIEW_VIEWNAME_VULNINFO)
|
||||
/* */
|
||||
if (nil != rc) {
|
||||
|
@ -415,7 +482,8 @@ func (fr *FrameReport)redrawViewVulnInfo(g *gocui.Gui) error {
|
|||
return fr.SetVulnInfoLayout(g)
|
||||
}
|
||||
|
||||
func (fr *FrameReport)redrawViewReport(g *gocui.Gui) error {
|
||||
func
|
||||
(fr *FrameReport)redrawViewReport(g *gocui.Gui) error {
|
||||
rc := g.DeleteView(FRAMEREPORTVIEW_VIEWNAME_REPORT)
|
||||
/* */
|
||||
if (nil != rc) {
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Filename: Utils.go
|
||||
//
|
||||
// Version: 1.0
|
||||
// Created: 2022年11月08日 21时05分02秒
|
||||
// Revision: none
|
||||
// Compiler: go
|
||||
//
|
||||
// Author: alpha
|
||||
// Organization: alpha
|
||||
// Contacts: chenxinquan@kylinos.com
|
||||
//
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// Log:
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// Todo:
|
||||
//
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
package gconsole
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
// "log"
|
||||
)
|
||||
|
||||
var A_DEBUG_LEVEL int = 0
|
||||
var A_DEBUG_NEED_HEAD bool = true
|
||||
////////////////////////////////////////////////////////////////
|
||||
// ALOG
|
||||
const (
|
||||
A_DEBUG_LEVEL_INFO int = 0
|
||||
A_DEBUG_LEVEL_NOTE int = 1
|
||||
A_DEBUG_LEVEL_WARNING int = 2
|
||||
A_DEBUG_LEVEL_ERROR int = 3
|
||||
|
||||
A_DEBUG_LEVEL_STR_INFO string = "info"
|
||||
A_DEBUG_LEVEL_STR_NOTE string = "note"
|
||||
A_DEBUG_LEVEL_STR_WARNING string = "warning"
|
||||
A_DEBUG_LEVEL_STR_ERROR string = "error"
|
||||
)
|
||||
func A_DEBUG(head string, args ...interface{}) {
|
||||
if (true == A_DEBUG_NEED_HEAD) {
|
||||
fmt.Print(head)
|
||||
}
|
||||
|
||||
fmt.Println(args...)
|
||||
}
|
||||
|
||||
func A_DEBUG_INFO(args ...interface{}) {
|
||||
if (A_DEBUG_LEVEL <= A_DEBUG_LEVEL_INFO) {
|
||||
A_DEBUG(A_DEBUG_LEVEL_STR_INFO + ":", args...)
|
||||
}
|
||||
}
|
||||
func A_DEBUG_NOTE(args ...interface{}) {
|
||||
if (A_DEBUG_LEVEL <= A_DEBUG_LEVEL_NOTE) {
|
||||
A_DEBUG(A_DEBUG_LEVEL_STR_NOTE + ":", args...)
|
||||
}
|
||||
}
|
||||
func A_DEBUG_WARNING(args ...interface{}) {
|
||||
if (A_DEBUG_LEVEL <= A_DEBUG_LEVEL_WARNING) {
|
||||
A_DEBUG(A_DEBUG_LEVEL_STR_WARNING + ":", args...)
|
||||
}
|
||||
}
|
||||
func A_DEBUG_ERROR(args ...interface{}) {
|
||||
if (A_DEBUG_LEVEL <= A_DEBUG_LEVEL_ERROR) {
|
||||
A_DEBUG(A_DEBUG_LEVEL_STR_ERROR + ":", args...)
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// File , Path
|
||||
func GetPrefixPath(path string) string {
|
||||
index := strings.LastIndex(path, string(os.PathSeparator))
|
||||
/* */
|
||||
return path[:index]
|
||||
}
|
||||
|
||||
func GetSubfixPath(path string) string {
|
||||
index := strings.LastIndex(path, string(os.PathSeparator))
|
||||
/* */
|
||||
return path[(index+1):]
|
||||
}
|
||||
|
||||
func GetSubfixFile(path string) string {
|
||||
index := strings.LastIndex(path, ".")
|
||||
/* */
|
||||
return path[index:]
|
||||
}
|
|
@ -33,10 +33,21 @@ import (
|
|||
//"log"
|
||||
|
||||
"github.com/jesseduffield/gocui"
|
||||
"main/genmai"
|
||||
)
|
||||
|
||||
func Draw() (rc error) {
|
||||
G_FrameReport.Setup()
|
||||
func
|
||||
Draw() (rc error) {
|
||||
genmai.DoctorIns().Reset()
|
||||
// genmai.DoctorIns().LoadExplorersListConfig("/home/test/桌面/genmai/data/pocs/pocs.yaml")
|
||||
genmai.DoctorIns().LoadExplorersListConfig("/home/alpha/Developments/kylinprojects/genmai/data/pocs/pocs.yaml")
|
||||
|
||||
var rpks []genmai.ReportKernel
|
||||
A_DEBUG_INFO(">>Genmai>>")
|
||||
rpk := genmai.DoctorIns().Genmai()
|
||||
|
||||
rpks = append(rpks, rpk)
|
||||
G_FrameReport.Setup(rpks)
|
||||
|
||||
g := gocui.NewGui()
|
||||
g.Init()
|
||||
|
@ -58,7 +69,8 @@ func Draw() (rc error) {
|
|||
return rc
|
||||
}
|
||||
|
||||
func layout(g *gocui.Gui) error {
|
||||
func
|
||||
layout(g *gocui.Gui) error {
|
||||
rc := G_FrameReport.SetTargetLayout(g)
|
||||
/* */
|
||||
if (nil != rc) {
|
||||
|
|
|
@ -43,7 +43,8 @@ var (
|
|||
errors.New("The config file is nil")
|
||||
)
|
||||
|
||||
type ConfigParserBase interface {
|
||||
type
|
||||
ConfigParserBase interface {
|
||||
Parse(file string) (rc error)
|
||||
Mashal(file string) (rc error)
|
||||
}
|
||||
|
|
|
@ -47,11 +47,13 @@ import (
|
|||
Center in the future
|
||||
*/
|
||||
// 继承于 ConfigParserBase接口
|
||||
type ConfigParserDefault map[string]interface {}
|
||||
type
|
||||
ConfigParserDefault map[string]interface {}
|
||||
|
||||
///////////////////////////////
|
||||
// override ConfigParserBase functions
|
||||
func (cpd *ConfigParserDefault)Parse(file string) (rc error) {
|
||||
func
|
||||
(cpd *ConfigParserDefault)Parse(file string) (rc error) {
|
||||
configfile, ok := os.Open(file)
|
||||
rc = ok;
|
||||
/* */
|
||||
|
@ -77,7 +79,8 @@ func (cpd *ConfigParserDefault)Parse(file string) (rc error) {
|
|||
return rc
|
||||
}
|
||||
|
||||
func (cpd *ConfigParserDefault)Mashal(file string) (rc error) {
|
||||
func
|
||||
(cpd *ConfigParserDefault)Mashal(file string) (rc error) {
|
||||
if (nil == cpd) {
|
||||
rc = RC_ERR_EMPTY_INTERFACE
|
||||
return
|
||||
|
@ -111,6 +114,7 @@ func (cpd *ConfigParserDefault)Mashal(file string) (rc error) {
|
|||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// others
|
||||
func NewConfig() ConfigParserBase {
|
||||
func
|
||||
NewConfig() ConfigParserBase {
|
||||
return &ConfigParserDefault{}
|
||||
}
|
||||
|
|
|
@ -39,11 +39,13 @@ import (
|
|||
// ConfigParserJSON
|
||||
|
||||
// 继承于 ConfigParserBase接口
|
||||
type ConfigParserJSON map[string]interface {}
|
||||
type
|
||||
ConfigParserJSON map[string]interface {}
|
||||
|
||||
///////////////////////////////
|
||||
// override ConfigParserBase functions
|
||||
func (cpj *ConfigParserJSON)Parse(file string) (rc error) {
|
||||
func
|
||||
(cpj *ConfigParserJSON)Parse(file string) (rc error) {
|
||||
configfile, ok := os.Open(file)
|
||||
rc = ok;
|
||||
/* */
|
||||
|
@ -63,7 +65,8 @@ func (cpj *ConfigParserJSON)Parse(file string) (rc error) {
|
|||
return rc
|
||||
}
|
||||
|
||||
func (cpj *ConfigParserJSON)Mashal(file string) (rc error) {
|
||||
func
|
||||
(cpj *ConfigParserJSON)Mashal(file string) (rc error) {
|
||||
if (nil == cpj) {
|
||||
rc = RC_ERR_EMPTY_INTERFACE
|
||||
return rc
|
||||
|
|
|
@ -39,11 +39,13 @@ import (
|
|||
// ConfigParserYAML
|
||||
|
||||
// 继承于 ConfigParserBase接口
|
||||
type ConfigParserYAML map[string]interface {}
|
||||
type
|
||||
ConfigParserYAML map[string]interface {}
|
||||
|
||||
///////////////////////////////
|
||||
// override ConfigParserBase functions
|
||||
func (cpy *ConfigParserYAML)Parse(file string) (rc error) {
|
||||
func
|
||||
(cpy *ConfigParserYAML)Parse(file string) (rc error) {
|
||||
configfile, ok := os.Open(file)
|
||||
rc = ok;
|
||||
/* */
|
||||
|
@ -70,7 +72,8 @@ func (cpy *ConfigParserYAML)Parse(file string) (rc error) {
|
|||
return rc
|
||||
}
|
||||
|
||||
func (cpy *ConfigParserYAML)Mashal(file string) (rc error) {
|
||||
func
|
||||
(cpy *ConfigParserYAML)Mashal(file string) (rc error) {
|
||||
if (nil == cpy) {
|
||||
rc = RC_ERR_EMPTY_INTERFACE
|
||||
return rc
|
||||
|
|
|
@ -30,6 +30,7 @@ package genmai
|
|||
|
||||
import (
|
||||
"sync"
|
||||
"time"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
|
||||
// TODO:
|
||||
|
@ -47,7 +48,8 @@ const (
|
|||
EXP_TYPE_WEB = "web"
|
||||
)
|
||||
|
||||
type doctor struct {
|
||||
type
|
||||
doctor struct {
|
||||
ExplorersDBus map[string]ExplorerDBus
|
||||
ExplorersKernel map[string]ExplorerKernel
|
||||
ExplorersSystem map[string]ExplorerSystem
|
||||
|
@ -55,12 +57,14 @@ type doctor struct {
|
|||
}
|
||||
|
||||
|
||||
type ExplorerItem struct {
|
||||
type
|
||||
ExplorerItem struct {
|
||||
Type string
|
||||
ConfigFile string
|
||||
|
||||
}
|
||||
type ExplorersListConfig struct {
|
||||
type
|
||||
ExplorersListConfig struct {
|
||||
ConfigFilePrefix string
|
||||
ExplorerItems []ExplorerItem
|
||||
}
|
||||
|
@ -75,7 +79,8 @@ var (
|
|||
once sync.Once
|
||||
)
|
||||
|
||||
func DoctorIns() (*doctor) {
|
||||
func
|
||||
DoctorIns() (*doctor) {
|
||||
once.Do( func() {
|
||||
instance = &doctor{}
|
||||
// go is fuck,
|
||||
|
@ -89,18 +94,71 @@ func DoctorIns() (*doctor) {
|
|||
|
||||
///////////////////////////////
|
||||
// doctor functions
|
||||
func (dtr *doctor)Reset() {
|
||||
func
|
||||
(dtr *doctor)Reset() {
|
||||
// 清空所有map元素
|
||||
dtr.ExplorersKernel = make(map[string]ExplorerKernel)
|
||||
}
|
||||
|
||||
func (dtr *doctor)Genmai() {
|
||||
func
|
||||
(dtr *doctor)Genmai() (rp ReportKernel) {
|
||||
// TODO
|
||||
var expvuls []VulnInfoCommon
|
||||
/* */
|
||||
var expip4addr []string
|
||||
expip4addr = append(expip4addr, "0.0.0.0")
|
||||
var expip6addr []string
|
||||
expip6addr = append(expip6addr, "0.0.0.0")
|
||||
/* */
|
||||
rp.ReportCommon.RCServerUUID = "TBD:so far: " + "alpha"
|
||||
rp.RCServerUUID = "1234-5678-1234-5678"
|
||||
rp.RCServerName = "aServer-Kernel"
|
||||
rp.RCFamily = "RCFamily"
|
||||
rp.RCRelease = "RCRelease"
|
||||
rp.RCContainer = "RCContainer"
|
||||
/* */
|
||||
rp.RCExploredTimeAt = time.Now()
|
||||
rp.RCExploredMode = "RCExploredMode"
|
||||
rp.RCExploredVersion = "RCExploredVersion"
|
||||
rp.RCExploredRevision = "RCExploredRevision"
|
||||
rp.RCExploredBy = "RCExploredBy"
|
||||
rp.RCExploredVia = "RCExploredVia"
|
||||
rp.RCExploredIPv4Addrs = expip4addr
|
||||
rp.RCExploredIPv6Addrs = expip6addr
|
||||
/* */
|
||||
rp.RCReportedAt = time.Now()
|
||||
rp.RCReportedVersion = "RCReportedVersion"
|
||||
rp.RCReportedBy = "RCReportedBy"
|
||||
/* */
|
||||
rp.RCErrors = "RCErrors"
|
||||
rp.RCWarnings = "RCWarnings"
|
||||
|
||||
rp.RCReunningKernelInfo = ReportKernelInfo {
|
||||
"0.0",
|
||||
"0.0",
|
||||
false,
|
||||
}
|
||||
rp.RCPackages = "RCPackages"
|
||||
rp.RCSrcPackages = "RCSrcPackages"
|
||||
rp.RCOptional = "RCOptional"
|
||||
|
||||
for _, v := range dtr.ExplorersKernel {
|
||||
v.Start()
|
||||
expvul, rc := v.Explore()
|
||||
|
||||
// TODO: is append expvul to expvuls according to rc
|
||||
if nil != rc {
|
||||
}
|
||||
expvuls = append(expvuls, expvul)
|
||||
} // for _, v ...
|
||||
|
||||
// TODO: should be type: ConfigCommon..
|
||||
rp.RCExploredVulns = expvuls
|
||||
|
||||
return rp
|
||||
}
|
||||
|
||||
func (dtr *doctor)LoadExplorersListConfig(configf string) (rc error) {
|
||||
func
|
||||
(dtr *doctor)LoadExplorersListConfig(configf string) (rc error) {
|
||||
var parser ConfigParserBase
|
||||
|
||||
filetype := GetSubfixFile(configf)
|
||||
|
@ -147,7 +205,8 @@ func (dtr *doctor)LoadExplorersListConfig(configf string) (rc error) {
|
|||
return rc
|
||||
}
|
||||
|
||||
func (dtr *doctor)PushExplorerDBus(configfile string) error {
|
||||
func
|
||||
(dtr *doctor)PushExplorerDBus(configfile string) error {
|
||||
// // TODO: need to test
|
||||
// ed := ExplorerDBus{}
|
||||
// ed.Setup(&ConfigParserYAML{}, &ExplorerConfigDBus{})
|
||||
|
@ -166,7 +225,8 @@ func (dtr *doctor)PushExplorerDBus(configfile string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (dtr *doctor)PushExplorerKernel(configfile string) error {
|
||||
func
|
||||
(dtr *doctor)PushExplorerKernel(configfile string) error {
|
||||
// TODO: need to test
|
||||
ek := ExplorerKernel{}
|
||||
ek.Setup(&ConfigParserYAML{}, &ExplorerConfigKernel{})
|
||||
|
@ -183,7 +243,8 @@ func (dtr *doctor)PushExplorerKernel(configfile string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (dtr *doctor)PushExplorerSystem(configfile string) error {
|
||||
func
|
||||
(dtr *doctor)PushExplorerSystem(configfile string) error {
|
||||
// // TODO: need to test
|
||||
// es := ExplorerSystem{}
|
||||
// es.Setup(&ConfigParserYAML{}, &ExplorerConfigSystem{})
|
||||
|
@ -202,7 +263,8 @@ func (dtr *doctor)PushExplorerSystem(configfile string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (dtr *doctor)PushExplorerWeb(configfile string) error {
|
||||
func
|
||||
(dtr *doctor)PushExplorerWeb(configfile string) error {
|
||||
// // TODO: need to test
|
||||
// ew := ExplorerWeb{}
|
||||
// ew.Setup(&ConfigParserYAML{}, &ExplorerConfigWeb{})
|
||||
|
|
|
@ -48,19 +48,22 @@ var (
|
|||
)
|
||||
|
||||
// Matchers 解析验证
|
||||
type Matchers struct{
|
||||
type
|
||||
Matchers struct{
|
||||
Type string
|
||||
Condition string
|
||||
MatcherMap map[string]string
|
||||
}
|
||||
|
||||
type ImArray struct {
|
||||
type
|
||||
ImArray struct {
|
||||
Exec string
|
||||
Args string
|
||||
}
|
||||
|
||||
//Implement 解析执行类型
|
||||
type Implement struct {
|
||||
type
|
||||
Implement struct {
|
||||
RawTypes []string
|
||||
Condition string
|
||||
// ImMap map[string]string
|
||||
|
@ -69,14 +72,16 @@ type Implement struct {
|
|||
}
|
||||
|
||||
// SiteRequests 解析请求中的值
|
||||
type SiteRequests struct {
|
||||
type
|
||||
SiteRequests struct {
|
||||
Implement
|
||||
ReqCondition bool
|
||||
Matchers
|
||||
}
|
||||
|
||||
// SiteClassification 解析Info中的信息
|
||||
type SiteClassification struct {
|
||||
type
|
||||
SiteClassification struct {
|
||||
CvssMetrics string
|
||||
CvssScore float32
|
||||
CveId string
|
||||
|
@ -86,7 +91,8 @@ type SiteClassification struct {
|
|||
}
|
||||
|
||||
// Info yaml文件的Info
|
||||
type SiteInfo struct {
|
||||
type
|
||||
SiteInfo struct {
|
||||
Name string
|
||||
Severity string
|
||||
Description string
|
||||
|
@ -99,7 +105,8 @@ type SiteInfo struct {
|
|||
/*
|
||||
Explorer的模板
|
||||
*/
|
||||
type ConfigCommon struct {
|
||||
type
|
||||
ConfigCommon struct {
|
||||
FormatVer int
|
||||
Id string
|
||||
Belong string
|
||||
|
@ -113,7 +120,8 @@ type ConfigCommon struct {
|
|||
|
||||
///////////////////////////////
|
||||
//
|
||||
type ExplorerConfigBase interface {
|
||||
type
|
||||
ExplorerConfigBase interface {
|
||||
// 每个结构体实现,应该完成这个函数以返回具体类型的Config
|
||||
// 由于需要用到具体类型,且因为go语言的限制,需要开发者编
|
||||
// 写具体类型。
|
||||
|
@ -123,7 +131,8 @@ type ExplorerConfigBase interface {
|
|||
// GetExplorerConfig*() (config *Config*, rc error) {
|
||||
}
|
||||
|
||||
type ExplorerCommon struct {
|
||||
type
|
||||
ExplorerCommon struct {
|
||||
EcConfigParser ConfigParserBase
|
||||
EcConfig ExplorerConfigBase
|
||||
EcConfigFilePrefix string
|
||||
|
@ -131,14 +140,17 @@ type ExplorerCommon struct {
|
|||
isSetup bool
|
||||
}
|
||||
|
||||
func (ec *ExplorerCommon)Setup(parser ConfigParserBase, config ExplorerConfigBase) {
|
||||
func
|
||||
(ec *ExplorerCommon)Setup(parser ConfigParserBase,
|
||||
config ExplorerConfigBase) {
|
||||
ec.EcConfigParser = parser
|
||||
ec.EcConfig = config
|
||||
/* */
|
||||
ec.isSetup = true
|
||||
}
|
||||
|
||||
func (ec *ExplorerCommon)LoadConfig(file string) (rc error) {
|
||||
func
|
||||
(ec *ExplorerCommon)LoadConfig(file string) (rc error) {
|
||||
if (true != ec.isSetup) {
|
||||
return ERR_STRUCT_NOTSETUP
|
||||
}
|
||||
|
@ -159,6 +171,11 @@ func (ec *ExplorerCommon)LoadConfig(file string) (rc error) {
|
|||
|
||||
///////////////////////////////
|
||||
// ExplorerBase
|
||||
type ExplorerBase interface {
|
||||
Explore(configfile string) (rp ReportCommon, rc error)
|
||||
type
|
||||
ExplorerBase interface {
|
||||
Explore() (rp ReportBase, rc error)
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////
|
||||
// auxiliary function
|
||||
|
|
|
@ -37,7 +37,8 @@ import (
|
|||
sandbox "main/genmai/Sandbox"
|
||||
)
|
||||
|
||||
type ExplorerConfigDBus struct {
|
||||
type
|
||||
ExplorerConfigDBus struct {
|
||||
FormatVer int
|
||||
Id string
|
||||
Belong string
|
||||
|
@ -48,7 +49,8 @@ type ExplorerConfigDBus struct {
|
|||
}
|
||||
|
||||
|
||||
type ExplorerDBus struct {
|
||||
type
|
||||
ExplorerDBus struct {
|
||||
ExplorerCommon
|
||||
/* */
|
||||
esSandbox sandbox.SandboxBase
|
||||
|
|
|
@ -47,7 +47,8 @@ import (
|
|||
inter "main/genmai/Interpreter"
|
||||
)
|
||||
|
||||
type ExplorerConfigKernel struct {
|
||||
type
|
||||
ExplorerConfigKernel struct {
|
||||
FormatVer int
|
||||
Id string
|
||||
Belong string
|
||||
|
@ -57,7 +58,8 @@ type ExplorerConfigKernel struct {
|
|||
SiteRequests SiteRequests
|
||||
}
|
||||
|
||||
type ExplorerKernel struct {
|
||||
type
|
||||
ExplorerKernel struct {
|
||||
ExplorerCommon
|
||||
/* */
|
||||
//EkConfigParser ConfigParserBase
|
||||
|
@ -71,7 +73,8 @@ type ExplorerKernel struct {
|
|||
|
||||
///////////////////////////////
|
||||
// ExplorerKernel functions
|
||||
func (ek *ExplorerKernel)GetExplorerConfigKernel() (config *ExplorerConfigKernel, rc error) {
|
||||
func
|
||||
(ek *ExplorerKernel)GetExplorerConfigKernel() (config *ExplorerConfigKernel, rc error) {
|
||||
cf, ret := ek.ExplorerCommon.EcConfig.(*ExplorerConfigKernel)
|
||||
/* */
|
||||
if (true == ret) {
|
||||
|
@ -85,17 +88,20 @@ func (ek *ExplorerKernel)GetExplorerConfigKernel() (config *ExplorerConfigKernel
|
|||
return config, rc
|
||||
}
|
||||
|
||||
func (ek *ExplorerKernel)SetupSandbox(sb sandbox.SandboxBase) {
|
||||
func
|
||||
(ek *ExplorerKernel)SetupSandbox(sb sandbox.SandboxBase) {
|
||||
ek.EkSandbox = sb
|
||||
/* */
|
||||
ek.isSetup = true
|
||||
}
|
||||
|
||||
func (ek *ExplorerKernel)startWithPath(execpath string, args ...string) error {
|
||||
func
|
||||
(ek *ExplorerKernel)exploreWithPath(execpath string,
|
||||
args ...string ) error {
|
||||
interio , rc := ek.EkSandbox.Process(execpath, args...)
|
||||
/* */
|
||||
if (nil != rc) {
|
||||
A_DEBUG_ERROR("startWithPath()->Process() error! rc = ", rc)
|
||||
A_DEBUG_ERROR("exploreWithPath()->Process() error! rc = ", rc)
|
||||
/* */
|
||||
return rc
|
||||
}
|
||||
|
@ -103,7 +109,9 @@ func (ek *ExplorerKernel)startWithPath(execpath string, args ...string) error {
|
|||
config, rc1 := ek.GetExplorerConfigKernel()
|
||||
rc = rc1
|
||||
if (nil != rc) {
|
||||
A_DEBUG_ERROR("startWithPath()->GetExplorerConfigKernel() error ! rc = ", rc)
|
||||
A_DEBUG_ERROR("exploreWithPath()-> "+
|
||||
"GetExplorerConfigKernel() error ! rc = ",
|
||||
rc )
|
||||
/* */
|
||||
return rc
|
||||
} // if (nil != ...
|
||||
|
@ -134,13 +142,17 @@ func (ek *ExplorerKernel)startWithPath(execpath string, args ...string) error {
|
|||
ou, _ := interio.Recv( len (itr[icmd_len : ]) )
|
||||
/* */
|
||||
if ( ou == itr[ icmd_len : ] ) {
|
||||
A_DEBUG_INFO("startWithPath():",
|
||||
"\"" + inter.INTERPRETER_CMD_RECV_POC_CHECK + "\":",
|
||||
A_DEBUG_INFO("exploreWithPath():",
|
||||
"\"" +
|
||||
inter.INTERPRETER_CMD_RECV_POC_CHECK +
|
||||
"\":" ,
|
||||
"Check poc successfully!" )
|
||||
/* */
|
||||
return RC_POC_CHECK_SUCCESSFULLY
|
||||
} else {
|
||||
A_DEBUG_INFO("startWithPath():\"<?\":Check poc failed!")
|
||||
A_DEBUG_INFO("exploreWithPath():",
|
||||
inter.INTERPRETER_CMD_RECV_POC_CHECK,
|
||||
"Check poc failed!" )
|
||||
/* */
|
||||
return RC_POC_CHECK_FAILED
|
||||
}
|
||||
|
@ -150,38 +162,49 @@ func (ek *ExplorerKernel)startWithPath(execpath string, args ...string) error {
|
|||
return rc
|
||||
}
|
||||
|
||||
func (ek *ExplorerKernel)Start() (rc error) {
|
||||
//func
|
||||
//(ek *ExplorerKernel)Explore() (rc error) {
|
||||
//}
|
||||
|
||||
///////////////////////////////
|
||||
// override ExplorerBase functions
|
||||
func
|
||||
(ek *ExplorerKernel)Explore() (expvul VulnInfoCommon, rc error) {
|
||||
|
||||
|
||||
config, rc_t := ek.GetExplorerConfigKernel()
|
||||
rc = rc_t
|
||||
if (nil != rc) {
|
||||
A_DEBUG_ERROR("Start()->GetExplorerConfigKernel() error! rc = ", rc)
|
||||
A_DEBUG_ERROR("Explore()->GetExplorerConfigKernel() "+
|
||||
"error! rc = ", rc )
|
||||
/* */
|
||||
return rc
|
||||
return VulnInfoCommon{}, rc
|
||||
}
|
||||
|
||||
///////////////
|
||||
// starting explore
|
||||
|
||||
|
||||
for _, im := range config.SiteRequests.ImArray {
|
||||
rc = ek.startWithPath(ek.ExplorerCommon.EcConfigFilePrefix +
|
||||
rc = ek.exploreWithPath(ek.ExplorerCommon.EcConfigFilePrefix +
|
||||
string(os.PathSeparator) +
|
||||
im.Exec ,
|
||||
im.Args )
|
||||
expvul.VICCveId = config.Id
|
||||
expvul.VICConfidences = Confidence {
|
||||
CScore: config.SiteInfo.SiteClassification.CvssScore,
|
||||
CDetectionMethod: "TBD",
|
||||
SortOrder: 1,
|
||||
}
|
||||
expvul.VICVulnType = config.Belong
|
||||
|
||||
return rc
|
||||
}
|
||||
} // for _, im ...
|
||||
|
||||
///////////////////////////////
|
||||
// override ExplorerBase functions
|
||||
func (ek *ExplorerKernel)Explore(configfile string) (rp ReportCommon, rc error) {
|
||||
ek.Setup(&ConfigParserYAML{}, &ExplorerConfigKernel{})
|
||||
ek.LoadConfig(configfile)
|
||||
|
||||
ek.SetupSandbox(&sandbox.SandboxDefault{})
|
||||
// ending explore
|
||||
///////////////
|
||||
|
||||
ek.Start()
|
||||
|
||||
// TODO:
|
||||
return ReportCommon{}, nil
|
||||
return expvul, nil
|
||||
}
|
||||
|
||||
///////////////////////////////
|
||||
|
|
|
@ -46,7 +46,8 @@ import (
|
|||
inter "main/genmai/Interpreter"
|
||||
)
|
||||
|
||||
type ExplorerConfigSystem struct {
|
||||
type
|
||||
ExplorerConfigSystem struct {
|
||||
FormatVer int
|
||||
Id string
|
||||
Belong string
|
||||
|
@ -56,7 +57,8 @@ type ExplorerConfigSystem struct {
|
|||
SiteRequests SiteRequests
|
||||
}
|
||||
|
||||
type ExplorerSystem struct {
|
||||
type
|
||||
ExplorerSystem struct {
|
||||
ExplorerCommon
|
||||
/* */
|
||||
EsSandbox sandbox.SandboxBase
|
||||
|
@ -65,7 +67,8 @@ type ExplorerSystem struct {
|
|||
|
||||
///////////////////////////////
|
||||
// ExplorerSystem functions
|
||||
func (es *ExplorerSystem)GetExplorerConfigSystem() (config *ExplorerConfigSystem, rc error) {
|
||||
func
|
||||
(es *ExplorerSystem)GetExplorerConfigSystem() (config *ExplorerConfigSystem, rc error) {
|
||||
cf, ret := es.ExplorerCommon.EcConfig.(*ExplorerConfigSystem)
|
||||
/* */
|
||||
if (true == ret) {
|
||||
|
@ -79,13 +82,15 @@ func (es *ExplorerSystem)GetExplorerConfigSystem() (config *ExplorerConfigSystem
|
|||
return config, rc
|
||||
}
|
||||
|
||||
func (es *ExplorerSystem)SetupSandbox(sb sandbox.SandboxBase) {
|
||||
func
|
||||
(es *ExplorerSystem)SetupSandbox(sb sandbox.SandboxBase) {
|
||||
es.EsSandbox = sb
|
||||
/* */
|
||||
es.isSetup = true
|
||||
}
|
||||
|
||||
func (es *ExplorerSystem)startWithPath(execpath string, args ...string) error {
|
||||
func
|
||||
(es *ExplorerSystem)startWithPath(execpath string, args ...string) error {
|
||||
interio , rc := es.EsSandbox.Process(execpath, args...)
|
||||
/* */
|
||||
if (nil != rc) {
|
||||
|
@ -144,7 +149,8 @@ func (es *ExplorerSystem)startWithPath(execpath string, args ...string) error {
|
|||
return rc
|
||||
}
|
||||
|
||||
func (es *ExplorerSystem)Start() (rc error) {
|
||||
func
|
||||
(es *ExplorerSystem)Start() (rc error) {
|
||||
config, rc_t := es.GetExplorerConfigSystem()
|
||||
rc = rc_t
|
||||
if (nil != rc) {
|
||||
|
@ -165,17 +171,18 @@ func (es *ExplorerSystem)Start() (rc error) {
|
|||
|
||||
///////////////////////////////
|
||||
// override ExplorerBase functions
|
||||
func (es *ExplorerSystem)Explore(configfile string) (rp ReportCommon, rc error) {
|
||||
es.Setup(&ConfigParserYAML{}, &ExplorerConfigSystem{})
|
||||
es.LoadConfig(configfile)
|
||||
|
||||
es.SetupSandbox(&sandbox.SandboxDefault{})
|
||||
|
||||
es.Start()
|
||||
|
||||
// TODO:
|
||||
return ReportCommon{}, nil
|
||||
}
|
||||
//func
|
||||
//(es *ExplorerSystem)Explore(configfile string) (rp ReportCommon, rc error) {
|
||||
// es.Setup(&ConfigParserYAML{}, &ExplorerConfigSystem{})
|
||||
// es.LoadConfig(configfile)
|
||||
//
|
||||
// es.SetupSandbox(&sandbox.SandboxDefault{})
|
||||
//
|
||||
// es.Start()
|
||||
//
|
||||
// // TODO:
|
||||
// return ReportCommon{}, nil
|
||||
//}
|
||||
|
||||
|
||||
///////////////////////////////
|
||||
|
|
|
@ -37,7 +37,8 @@ import (
|
|||
sandbox "main/genmai/Sandbox"
|
||||
)
|
||||
|
||||
type ExplorerConfigWeb struct {
|
||||
type
|
||||
ExplorerConfigWeb struct {
|
||||
FormatVer int
|
||||
Id string
|
||||
Belong string
|
||||
|
@ -48,7 +49,8 @@ type ExplorerConfigWeb struct {
|
|||
}
|
||||
|
||||
|
||||
type ExplorerWeb struct {
|
||||
type
|
||||
ExplorerWeb struct {
|
||||
ExplorerCommon
|
||||
/* */
|
||||
esSandbox sandbox.SandboxBase
|
||||
|
|
|
@ -35,28 +35,32 @@ import (
|
|||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// InterIO struct
|
||||
type InterIO struct {
|
||||
type
|
||||
InterIO struct {
|
||||
Reader *bufio.Reader
|
||||
Writer *bufio.Writer
|
||||
}
|
||||
|
||||
///////////////////////////////
|
||||
// InterIO functions
|
||||
func (iio InterIO) Send(str string) (rc error) {
|
||||
func
|
||||
(iio InterIO) Send(str string) (rc error) {
|
||||
_, rc = iio.Writer.WriteString(str)
|
||||
iio.Writer.Flush()
|
||||
/* */
|
||||
return rc
|
||||
}
|
||||
|
||||
func (iio InterIO) Sendline(str string) (rc error) {
|
||||
func
|
||||
(iio InterIO) Sendline(str string) (rc error) {
|
||||
_, rc = iio.Writer.WriteString(str + "\n")
|
||||
iio.Writer.Flush()
|
||||
/* */
|
||||
return rc
|
||||
}
|
||||
|
||||
func (iio InterIO) RecvUntil(delim_s string) (ret string, rc error) {
|
||||
func
|
||||
(iio InterIO) RecvUntil(delim_s string) (ret string, rc error) {
|
||||
output := ""
|
||||
/* */
|
||||
for {
|
||||
|
@ -81,20 +85,23 @@ func (iio InterIO) RecvUntil(delim_s string) (ret string, rc error) {
|
|||
return ret, rc
|
||||
}
|
||||
|
||||
func (iio InterIO) RecvUntilByte(delim_b byte) (string, error) {
|
||||
func
|
||||
(iio InterIO) RecvUntilByte(delim_b byte) (string, error) {
|
||||
recv, rc := iio.Reader.ReadBytes(delim_b)
|
||||
/* */
|
||||
return string(recv), rc
|
||||
}
|
||||
|
||||
func (iio InterIO) RecvLine() (string, bool, error) {
|
||||
func
|
||||
(iio InterIO) RecvLine() (string, bool, error) {
|
||||
|
||||
recv, isPrefix, rc := iio.Reader.ReadLine()
|
||||
|
||||
return string(recv), isPrefix, rc
|
||||
}
|
||||
|
||||
func (iio InterIO) Recv(n int) (string, error) {
|
||||
func
|
||||
(iio InterIO) Recv(n int) (string, error) {
|
||||
var out []byte
|
||||
var rc error
|
||||
for i := 0; i < n ; i++ {
|
||||
|
@ -107,7 +114,8 @@ func (iio InterIO) Recv(n int) (string, error) {
|
|||
return string(out), rc
|
||||
}
|
||||
|
||||
func (iio InterIO) RecvString(delim byte) (line string, rc error) {
|
||||
func
|
||||
(iio InterIO) RecvString(delim byte) (line string, rc error) {
|
||||
line, rc = iio.Reader.ReadString(delim)
|
||||
|
||||
return line, rc
|
||||
|
|
|
@ -43,6 +43,7 @@ const (
|
|||
)
|
||||
////////////////////////////////////////////////////////////////
|
||||
// Interpreter interface
|
||||
type Interpreter interface {
|
||||
type
|
||||
Interpreter interface {
|
||||
Process(execpath string, args...string) (InterIO, error)
|
||||
}
|
||||
|
|
|
@ -56,7 +56,8 @@ const (
|
|||
A_DEBUG_LEVEL_STR_WARNING string = "warning"
|
||||
A_DEBUG_LEVEL_STR_ERROR string = "error"
|
||||
)
|
||||
func A_DEBUG(head string, args ...interface{}) {
|
||||
func
|
||||
A_DEBUG(head string, args ...interface{}) {
|
||||
if (true == A_DEBUG_NEED_HEAD) {
|
||||
fmt.Print(head)
|
||||
}
|
||||
|
@ -64,22 +65,26 @@ func A_DEBUG(head string, args ...interface{}) {
|
|||
fmt.Println(args...)
|
||||
}
|
||||
|
||||
func A_DEBUG_INFO(args ...interface{}) {
|
||||
func
|
||||
A_DEBUG_INFO(args ...interface{}) {
|
||||
if (A_DEBUG_LEVEL <= A_DEBUG_LEVEL_INFO) {
|
||||
A_DEBUG(A_DEBUG_LEVEL_STR_INFO + ":", args...)
|
||||
}
|
||||
}
|
||||
func A_DEBUG_NOTE(args ...interface{}) {
|
||||
func
|
||||
A_DEBUG_NOTE(args ...interface{}) {
|
||||
if (A_DEBUG_LEVEL <= A_DEBUG_LEVEL_NOTE) {
|
||||
A_DEBUG(A_DEBUG_LEVEL_STR_NOTE + ":", args...)
|
||||
}
|
||||
}
|
||||
func A_DEBUG_WARNING(args ...interface{}) {
|
||||
func
|
||||
A_DEBUG_WARNING(args ...interface{}) {
|
||||
if (A_DEBUG_LEVEL <= A_DEBUG_LEVEL_WARNING) {
|
||||
A_DEBUG(A_DEBUG_LEVEL_STR_WARNING + ":", args...)
|
||||
}
|
||||
}
|
||||
func A_DEBUG_ERROR(args ...interface{}) {
|
||||
func
|
||||
A_DEBUG_ERROR(args ...interface{}) {
|
||||
if (A_DEBUG_LEVEL <= A_DEBUG_LEVEL_ERROR) {
|
||||
A_DEBUG(A_DEBUG_LEVEL_STR_ERROR + ":", args...)
|
||||
}
|
||||
|
@ -87,19 +92,22 @@ func A_DEBUG_ERROR(args ...interface{}) {
|
|||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// File , Path
|
||||
func GetPrefixPath(path string) string {
|
||||
func
|
||||
GetPrefixPath(path string) string {
|
||||
index := strings.LastIndex(path, string(os.PathSeparator))
|
||||
/* */
|
||||
return path[:index]
|
||||
}
|
||||
|
||||
func GetSubfixPath(path string) string {
|
||||
func
|
||||
GetSubfixPath(path string) string {
|
||||
index := strings.LastIndex(path, string(os.PathSeparator))
|
||||
/* */
|
||||
return path[(index+1):]
|
||||
}
|
||||
|
||||
func GetSubfixFile(path string) string {
|
||||
func
|
||||
GetSubfixFile(path string) string {
|
||||
index := strings.LastIndex(path, ".")
|
||||
/* */
|
||||
return path[index:]
|
||||
|
|
|
@ -32,7 +32,8 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
type ReportContianer struct {
|
||||
type
|
||||
ReportContianer struct {
|
||||
RCContainerID string
|
||||
RCName string
|
||||
RCImage string
|
||||
|
@ -40,18 +41,21 @@ type ReportContianer struct {
|
|||
RCUUID string
|
||||
}
|
||||
|
||||
type ReportPlatform struct {
|
||||
type
|
||||
ReportPlatform struct {
|
||||
RPName string
|
||||
RPInstanceID string
|
||||
}
|
||||
|
||||
type ReportKernelInfo struct {
|
||||
type
|
||||
ReportKernelInfo struct {
|
||||
RKRelease string
|
||||
RKVersion string
|
||||
RKRebootRequired bool
|
||||
}
|
||||
|
||||
type ReportCommon struct {
|
||||
type
|
||||
ReportCommon struct {
|
||||
RCServerUUID string
|
||||
RCServerName string
|
||||
RCFamily string
|
||||
|
@ -81,7 +85,8 @@ type ReportCommon struct {
|
|||
RCOptional string // TBD: type
|
||||
}
|
||||
|
||||
type ReportBase interface {
|
||||
type
|
||||
ReportBase interface {
|
||||
GetReportCommon() ReportCommon
|
||||
}
|
||||
|
||||
|
@ -96,7 +101,8 @@ type ReportBase interface {
|
|||
//}
|
||||
|
||||
// TODO: to complete
|
||||
type VulnInfoCommon struct {
|
||||
type
|
||||
VulnInfoCommon struct {
|
||||
VICCveId string
|
||||
VICConfidences Confidence
|
||||
VICAffectedPackages []PackageFixStatus
|
||||
|
@ -113,22 +119,26 @@ type VulnInfoCommon struct {
|
|||
// TODO: TBD
|
||||
}
|
||||
|
||||
type Confidence struct {
|
||||
CScore int
|
||||
type
|
||||
Confidence struct {
|
||||
CScore float32
|
||||
CDetectionMethod DetectionMethod
|
||||
SortOrder int
|
||||
}
|
||||
|
||||
type DetectionMethod string
|
||||
type
|
||||
DetectionMethod string
|
||||
|
||||
type PackageFixStatus struct {
|
||||
type
|
||||
PackageFixStatus struct {
|
||||
PFSName string
|
||||
PFSNotFixedYet bool
|
||||
PFSFixState string
|
||||
PFSFixedIn string
|
||||
}
|
||||
|
||||
type DistroAdvisory struct {
|
||||
type
|
||||
DistroAdvisory struct {
|
||||
DAAdvisoryId string
|
||||
DASeverity string
|
||||
DAIssued time.Time
|
||||
|
@ -137,10 +147,12 @@ type DistroAdvisory struct {
|
|||
}
|
||||
|
||||
// TODO:
|
||||
type CveContent struct {
|
||||
type
|
||||
CveContent struct {
|
||||
}
|
||||
|
||||
type ExploitInfo struct {
|
||||
type
|
||||
ExploitInfo struct {
|
||||
EIExploitType string // TODO: TBD
|
||||
EIId string
|
||||
EIURL string
|
||||
|
@ -150,19 +162,22 @@ type ExploitInfo struct {
|
|||
EIBinaryURL []string
|
||||
}
|
||||
|
||||
type MitigationInfo struct {
|
||||
type
|
||||
MitigationInfo struct {
|
||||
// MICveContentType
|
||||
MIMitigationInfo string
|
||||
MIURL string
|
||||
}
|
||||
|
||||
type AlertInfo struct {
|
||||
type
|
||||
AlertInfo struct {
|
||||
AIURL string
|
||||
AITitle string
|
||||
AITeam string
|
||||
}
|
||||
|
||||
type AlerDict struct {
|
||||
type
|
||||
AlerDict struct {
|
||||
ADCISA []AlertInfo
|
||||
ADJPCERT []AlertInfo
|
||||
ADUSCERT []AlertInfo
|
||||
|
|
|
@ -32,15 +32,18 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
type ReportDBus struct {
|
||||
type
|
||||
ReportDBus struct {
|
||||
ReportCommon
|
||||
}
|
||||
|
||||
type VulnInfoDBus struct {
|
||||
type
|
||||
VulnInfoDBus struct {
|
||||
VulnInfoCommon
|
||||
}
|
||||
|
||||
func GetTemplateReportDBus() (*ReportDBus) {
|
||||
func
|
||||
GetTemplateReportDBus() (*ReportDBus) {
|
||||
var expvuls []VulnInfoCommon
|
||||
expvuls = append(expvuls, GetTemplateVulnInfoDBus().VulnInfoCommon)
|
||||
expvuls = append(expvuls, GetTemplateVulnInfoDBus().VulnInfoCommon)
|
||||
|
@ -54,7 +57,7 @@ func GetTemplateReportDBus() (*ReportDBus) {
|
|||
return &ReportDBus{
|
||||
ReportCommon {
|
||||
RCServerUUID: "1234-5678-1234-5678",
|
||||
RCServerName: "aServer",
|
||||
RCServerName: "aServer-DBus",
|
||||
RCFamily: "RCFamily",
|
||||
RCRelease: "RCRelease",
|
||||
RCContainer: "RCContainer",
|
||||
|
@ -88,13 +91,14 @@ func GetTemplateReportDBus() (*ReportDBus) {
|
|||
}
|
||||
}
|
||||
|
||||
func GetTemplateVulnInfoDBus() (*VulnInfoDBus) {
|
||||
func
|
||||
GetTemplateVulnInfoDBus() (*VulnInfoDBus) {
|
||||
return &VulnInfoDBus {
|
||||
VulnInfoCommon {
|
||||
VICCveId: "VICCveId",
|
||||
VICConfidences: Confidence {
|
||||
CScore: 123,
|
||||
CDetectionMethod: "CDetectionMethod",
|
||||
CDetectionMethod: "CDetectionMethod-DBus",
|
||||
SortOrder: 1, },
|
||||
//VICAffectedPackages:
|
||||
// ...
|
||||
|
@ -106,6 +110,7 @@ func GetTemplateVulnInfoDBus() (*VulnInfoDBus) {
|
|||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// ReportBase methods
|
||||
func (rd *ReportDBus)GetReportCommon() ReportCommon {
|
||||
func
|
||||
(rd *ReportDBus)GetReportCommon() ReportCommon {
|
||||
return rd.ReportCommon
|
||||
}
|
||||
|
|
|
@ -32,18 +32,19 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
type ReportKernel struct {
|
||||
type
|
||||
ReportKernel struct {
|
||||
ReportCommon
|
||||
}
|
||||
type VulnInfoKernel struct {
|
||||
type
|
||||
VulnInfoKernel struct {
|
||||
VulnInfoCommon
|
||||
}
|
||||
|
||||
func GetTemplateReportKernel() (*ReportKernel) {
|
||||
func
|
||||
GetTemplateReportKernel() (*ReportKernel) {
|
||||
var expvuls []VulnInfoCommon
|
||||
expvuls = append(expvuls, GetTemplateVulnInfoKernel().VulnInfoCommon)
|
||||
expvuls = append(expvuls, GetTemplateVulnInfoKernel().VulnInfoCommon)
|
||||
expvuls = append(expvuls, GetTemplateVulnInfoKernel().VulnInfoCommon)
|
||||
/* */
|
||||
var expip4addr []string
|
||||
expip4addr = append(expip4addr, "0.0.0.0")
|
||||
|
@ -53,7 +54,7 @@ func GetTemplateReportKernel() (*ReportKernel) {
|
|||
return &ReportKernel {
|
||||
ReportCommon {
|
||||
RCServerUUID: "1234-5678-1234-5678",
|
||||
RCServerName: "aServer",
|
||||
RCServerName: "aServer-Kernel",
|
||||
RCFamily: "RCFamily",
|
||||
RCRelease: "RCRelease",
|
||||
RCContainer: "RCContainer",
|
||||
|
@ -87,7 +88,8 @@ func GetTemplateReportKernel() (*ReportKernel) {
|
|||
}
|
||||
}
|
||||
|
||||
func GetTemplateVulnInfoKernel() VulnInfoKernel {
|
||||
func
|
||||
GetTemplateVulnInfoKernel() VulnInfoKernel {
|
||||
return VulnInfoKernel {
|
||||
VulnInfoCommon {
|
||||
VICCveId: "VICCveId",
|
||||
|
@ -105,6 +107,7 @@ func GetTemplateVulnInfoKernel() VulnInfoKernel {
|
|||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// ReportBase methods
|
||||
func (rk *ReportKernel)GetReportCommon() ReportCommon {
|
||||
func
|
||||
(rk *ReportKernel)GetReportCommon() ReportCommon {
|
||||
return rk.ReportCommon
|
||||
}
|
||||
|
|
|
@ -32,15 +32,18 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
type ReportSystem struct {
|
||||
type
|
||||
ReportSystem struct {
|
||||
ReportCommon
|
||||
}
|
||||
|
||||
type VulnInfoSystem struct {
|
||||
type
|
||||
VulnInfoSystem struct {
|
||||
VulnInfoCommon
|
||||
}
|
||||
|
||||
func GetTemplateReportSystem() (*ReportSystem) {
|
||||
func
|
||||
GetTemplateReportSystem() (*ReportSystem) {
|
||||
var expvuls []VulnInfoCommon
|
||||
expvuls = append(expvuls, GetTemplateVulnInfoSystem().VulnInfoCommon)
|
||||
expvuls = append(expvuls, GetTemplateVulnInfoSystem().VulnInfoCommon)
|
||||
|
@ -54,7 +57,7 @@ func GetTemplateReportSystem() (*ReportSystem) {
|
|||
return &ReportSystem{
|
||||
ReportCommon {
|
||||
RCServerUUID: "1234-5678-1234-5678",
|
||||
RCServerName: "aServer",
|
||||
RCServerName: "aServer-System",
|
||||
RCFamily: "RCFamily",
|
||||
RCRelease: "RCRelease",
|
||||
RCContainer: "RCContainer",
|
||||
|
@ -88,13 +91,14 @@ func GetTemplateReportSystem() (*ReportSystem) {
|
|||
}
|
||||
}
|
||||
|
||||
func GetTemplateVulnInfoSystem() (*VulnInfoSystem) {
|
||||
func
|
||||
GetTemplateVulnInfoSystem() (*VulnInfoSystem) {
|
||||
return &VulnInfoSystem {
|
||||
VulnInfoCommon {
|
||||
VICCveId: "VICCveId",
|
||||
VICConfidences: Confidence {
|
||||
CScore: 123,
|
||||
CDetectionMethod: "CDetectionMethod-Kernel",
|
||||
CDetectionMethod: "CDetectionMethod-System",
|
||||
SortOrder: 1, },
|
||||
//VICAffectedPackages:
|
||||
// ...
|
||||
|
@ -106,6 +110,7 @@ func GetTemplateVulnInfoSystem() (*VulnInfoSystem) {
|
|||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// ReportBase methods
|
||||
func (rs *ReportSystem)GetReportCommon() ReportCommon {
|
||||
func
|
||||
(rs *ReportSystem)GetReportCommon() ReportCommon {
|
||||
return rs.ReportCommon
|
||||
}
|
||||
|
|
|
@ -32,16 +32,19 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
type ReportWeb struct {
|
||||
type
|
||||
ReportWeb struct {
|
||||
ReportCommon
|
||||
}
|
||||
|
||||
type VulnInfoWeb struct {
|
||||
type
|
||||
VulnInfoWeb struct {
|
||||
VulnInfoCommon
|
||||
}
|
||||
|
||||
|
||||
func GetTemplateReportWeb() (*ReportWeb) {
|
||||
func
|
||||
GetTemplateReportWeb() (*ReportWeb) {
|
||||
var expvuls []VulnInfoCommon
|
||||
expvuls = append(expvuls, GetTemplateVulnInfoWeb().VulnInfoCommon)
|
||||
expvuls = append(expvuls, GetTemplateVulnInfoWeb().VulnInfoCommon)
|
||||
|
@ -55,7 +58,7 @@ func GetTemplateReportWeb() (*ReportWeb) {
|
|||
return &ReportWeb{
|
||||
ReportCommon {
|
||||
RCServerUUID: "1234-5678-1234-5678",
|
||||
RCServerName: "aServer",
|
||||
RCServerName: "aServer-Web",
|
||||
RCFamily: "RCFamily",
|
||||
RCRelease: "RCRelease",
|
||||
RCContainer: "RCContainer",
|
||||
|
@ -89,7 +92,8 @@ func GetTemplateReportWeb() (*ReportWeb) {
|
|||
}
|
||||
}
|
||||
|
||||
func GetTemplateVulnInfoWeb() (*VulnInfoWeb) {
|
||||
func
|
||||
GetTemplateVulnInfoWeb() (*VulnInfoWeb) {
|
||||
return &VulnInfoWeb {
|
||||
VulnInfoCommon {
|
||||
VICCveId: "VICCveId",
|
||||
|
@ -107,6 +111,7 @@ func GetTemplateVulnInfoWeb() (*VulnInfoWeb) {
|
|||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// ReportBase methods
|
||||
func (rw *ReportWeb)GetReportCommon() ReportCommon {
|
||||
func
|
||||
(rw *ReportWeb)GetReportCommon() ReportCommon {
|
||||
return rw.ReportCommon
|
||||
}
|
||||
|
|
|
@ -38,7 +38,8 @@ import (
|
|||
)
|
||||
|
||||
// 继承于Interpreter接口
|
||||
type SandboxBase interface {
|
||||
type
|
||||
SandboxBase interface {
|
||||
inter.Interpreter
|
||||
/* */
|
||||
}
|
||||
|
|
|
@ -44,19 +44,22 @@ import (
|
|||
)
|
||||
|
||||
// 继承与SandBoxBase接口
|
||||
type SandboxDefault struct {
|
||||
type
|
||||
SandboxDefault struct {
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////
|
||||
// override functions
|
||||
func (sbd *SandboxDefault)cmdGuard(execpath string) error {
|
||||
func
|
||||
(sbd *SandboxDefault)cmdGuard(execpath string) error {
|
||||
// TODO: Very Important
|
||||
A_DEBUG_ERROR("cmdGuard():NEED TO IMPLEMENT!")
|
||||
|
||||
return nil
|
||||
}
|
||||
func (sbd *SandboxDefault)Process(execpath string, args ...string) (inter.InterIO, error) {
|
||||
func
|
||||
(sbd *SandboxDefault)Process(execpath string, args ...string) (inter.InterIO, error) {
|
||||
// TODO: make ALOG
|
||||
A_DEBUG_INFO("Starting process for : ", GetSubfixPath(execpath), " ...\n")
|
||||
|
||||
|
|
|
@ -56,7 +56,8 @@ const (
|
|||
A_DEBUG_LEVEL_STR_WARNING string = "warning"
|
||||
A_DEBUG_LEVEL_STR_ERROR string = "error"
|
||||
)
|
||||
func A_DEBUG(head string, args ...interface{}) {
|
||||
func
|
||||
A_DEBUG(head string, args ...interface{}) {
|
||||
if (true == A_DEBUG_NEED_HEAD) {
|
||||
fmt.Print(head)
|
||||
}
|
||||
|
@ -64,22 +65,26 @@ func A_DEBUG(head string, args ...interface{}) {
|
|||
fmt.Println(args...)
|
||||
}
|
||||
|
||||
func A_DEBUG_INFO(args ...interface{}) {
|
||||
func
|
||||
A_DEBUG_INFO(args ...interface{}) {
|
||||
if (A_DEBUG_LEVEL <= A_DEBUG_LEVEL_INFO) {
|
||||
A_DEBUG(A_DEBUG_LEVEL_STR_INFO + ":", args...)
|
||||
}
|
||||
}
|
||||
func A_DEBUG_NOTE(args ...interface{}) {
|
||||
func
|
||||
A_DEBUG_NOTE(args ...interface{}) {
|
||||
if (A_DEBUG_LEVEL <= A_DEBUG_LEVEL_NOTE) {
|
||||
A_DEBUG(A_DEBUG_LEVEL_STR_NOTE + ":", args...)
|
||||
}
|
||||
}
|
||||
func A_DEBUG_WARNING(args ...interface{}) {
|
||||
func
|
||||
A_DEBUG_WARNING(args ...interface{}) {
|
||||
if (A_DEBUG_LEVEL <= A_DEBUG_LEVEL_WARNING) {
|
||||
A_DEBUG(A_DEBUG_LEVEL_STR_WARNING + ":", args...)
|
||||
}
|
||||
}
|
||||
func A_DEBUG_ERROR(args ...interface{}) {
|
||||
func
|
||||
A_DEBUG_ERROR(args ...interface{}) {
|
||||
if (A_DEBUG_LEVEL <= A_DEBUG_LEVEL_ERROR) {
|
||||
A_DEBUG(A_DEBUG_LEVEL_STR_ERROR + ":", args...)
|
||||
}
|
||||
|
@ -87,19 +92,22 @@ func A_DEBUG_ERROR(args ...interface{}) {
|
|||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// File , Path
|
||||
func GetPrefixPath(path string) string {
|
||||
func
|
||||
GetPrefixPath(path string) string {
|
||||
index := strings.LastIndex(path, string(os.PathSeparator))
|
||||
/* */
|
||||
return path[:index]
|
||||
}
|
||||
|
||||
func GetSubfixPath(path string) string {
|
||||
func
|
||||
GetSubfixPath(path string) string {
|
||||
index := strings.LastIndex(path, string(os.PathSeparator))
|
||||
/* */
|
||||
return path[(index+1):]
|
||||
}
|
||||
|
||||
func GetSubfixFile(path string) string {
|
||||
func
|
||||
GetSubfixFile(path string) string {
|
||||
index := strings.LastIndex(path, ".")
|
||||
/* */
|
||||
return path[index:]
|
||||
|
|
|
@ -178,7 +178,8 @@ func Test() {
|
|||
|
||||
|
||||
DoctorIns().Reset()
|
||||
DoctorIns().LoadExplorersListConfig("/home/test/桌面/genmai/data/pocs/pocs.yaml")
|
||||
// DoctorIns().LoadExplorersListConfig("/home/test/桌面/genmai/data/pocs/pocs.yaml")
|
||||
DoctorIns().LoadExplorersListConfig("/home/alpha/Developments/kylinprojects/genmai/data/pocs/pocs.yaml")
|
||||
|
||||
A_DEBUG_INFO(">>Genmai>>")
|
||||
DoctorIns().Genmai()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package genmai
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
|
162
src/main.go
162
src/main.go
|
@ -1,162 +0,0 @@
|
|||
|
||||
package main
|
||||
|
||||
import (
|
||||
"main/genmai/ArgParser"
|
||||
"main/genmai/FrameWorkCheck"
|
||||
"fmt"
|
||||
"flag"
|
||||
"log"
|
||||
"strconv"
|
||||
"strings"
|
||||
genmai "main/genmai"
|
||||
gcon "main/gconsole"
|
||||
)
|
||||
type Vul struct{
|
||||
ParserNum int //协程数
|
||||
System string //执行系统漏洞检测
|
||||
Web string //Web漏洞检测
|
||||
Kernel string //内核漏洞检测
|
||||
Fuzz string //Fuzz
|
||||
BaseLine string //基线检测
|
||||
Update string //更新软件
|
||||
Docs string //生成报告
|
||||
PoolStatNum int //启动协程任务数
|
||||
IP string //web 制定IP
|
||||
MD string //生成MD文件
|
||||
RemoteAssessment string //远程检测,所需参数在RAVUL中
|
||||
WKPWD string //弱口令生成,所需参数在WKPWDVUL结构体中
|
||||
SSHBurst string //SSH爆破
|
||||
Nmap string //Nmap模块,端口和IP放在RAVUL中
|
||||
Fofa string //fofa接口调用,需要输入查询命令
|
||||
}
|
||||
|
||||
type FofaCommand struct{
|
||||
FofaCom string
|
||||
}
|
||||
|
||||
type RAVUL struct{
|
||||
Host string //主机IP
|
||||
User string //用户名
|
||||
Password string //密码
|
||||
Port string //端口
|
||||
}
|
||||
|
||||
type WKPWDVUL struct{
|
||||
CompanyName string //公司名
|
||||
Name string //名字
|
||||
Nums string //特殊数字
|
||||
}
|
||||
|
||||
func main(){
|
||||
|
||||
|
||||
var vul Vul //定义vul
|
||||
var RAV RAVUL
|
||||
var WKV WKPWDVUL
|
||||
var FC FofaCommand
|
||||
vul.PoolStatNum =0
|
||||
|
||||
//开始日志打印日志
|
||||
genmai.LogInit()
|
||||
|
||||
//检测系统架构
|
||||
frameWork:=FrameWorkCheck.FwCheck()
|
||||
if len(frameWork) > 0{
|
||||
log.Println("frameWork sure")
|
||||
}else{
|
||||
return
|
||||
}
|
||||
|
||||
Help := flag.Bool("help", false,"")
|
||||
|
||||
//识别参数,执行模块
|
||||
flag.IntVar(&vul.ParserNum, "poolNums", 100, "设置协程的数量,默认数量为0,最大数量为1000")
|
||||
flag.StringVar(&vul.Web, "web", "false", "使用web漏洞的验证模块,可联合其他模块使用")
|
||||
flag.StringVar(&vul.IP, "ip", "false", "设置ip,可设置ip段进行验证")
|
||||
flag.StringVar(&vul.System, "system", "false", "使用系统漏洞的验证模块,可联合其他模块使用")
|
||||
flag.StringVar(&vul.Kernel, "kernel", "false", "使用内核漏洞的验证模块,可联合其他模块使用")
|
||||
flag.StringVar(&vul.BaseLine, "baseline", "false", "使用基线检测模块,可联合其他模块使用")
|
||||
|
||||
//远程模块参数
|
||||
RA := flag.Bool("RA", false, "使用远程检测,只能单独使用模块")
|
||||
flag.StringVar(&RAV.Host, "host", "false", "IP")
|
||||
flag.StringVar(&RAV.Port, "port", "all", "端口")
|
||||
flag.StringVar(&RAV.User, "user", "false", "用户名")
|
||||
flag.StringVar(&RAV.Password, "passwd", "false", "远程登录密码")
|
||||
|
||||
|
||||
|
||||
//弱密码生成模块
|
||||
WK := flag.Bool("WKPWD", false, "使用弱口令生成器模块,选用参数CPN,Name,Nums")
|
||||
flag.StringVar(&WKV.CompanyName, "CPN", "0", "设置特定公司名")
|
||||
flag.StringVar(&WKV.Name, "Name", "0", "设置姓名")
|
||||
flag.StringVar(&WKV.Nums, "Nums", "0", "设置特殊数字(如年份)")
|
||||
|
||||
// SSH爆破模块
|
||||
SSHB:= flag.Bool("SSHBurst", false, "使用SSH爆破,必用参数host,选用参数poolNums")
|
||||
|
||||
// Nmap模块
|
||||
NmapScan:= flag.Bool("Nmap",false,"使用Nmap模块进行扫描,必用参数host,选用参数port")
|
||||
|
||||
// Fofa模块
|
||||
Fofa:=flag.Bool("Fofa",false,"Fofa探测,必用参数FofaCom")
|
||||
flag.StringVar(&FC.FofaCom, "fofaCom", "null", "设置特定公司名")
|
||||
|
||||
//
|
||||
All := flag.Bool("all", false, "只扫描system,kernel的所有poc以及检测baselin模块,不可联合其他参数使用")
|
||||
|
||||
Update := flag.Bool("update", false, "更新程序到最新版本,不可联合其他参数使用")
|
||||
|
||||
//flag解析
|
||||
flag.Parse()
|
||||
|
||||
//将插件模块的值存放到数组中
|
||||
PWDList :=[...]string{WKV.CompanyName,WKV.Name,WKV.Nums}
|
||||
poolNums:=strconv.Itoa(vul.ParserNum)
|
||||
SSHBurstList :=[...]string{RAV.Host,poolNums}
|
||||
NmapScanList :=[...]string{RAV.Host,RAV.Port}
|
||||
|
||||
//初始化bool值
|
||||
sAll :=strconv.FormatBool(*All)
|
||||
vul.Update=strconv.FormatBool(*Update)
|
||||
vul.RemoteAssessment=strconv.FormatBool(*RA)
|
||||
vul.WKPWD=strconv.FormatBool(*WK)
|
||||
help:=strconv.FormatBool(*Help)
|
||||
vul.SSHBurst =strconv.FormatBool(*SSHB)
|
||||
vul.Nmap = strconv.FormatBool(*NmapScan)
|
||||
vul.Fofa = strconv.FormatBool(*Fofa)
|
||||
|
||||
//是否开启远程检测
|
||||
if vul.RemoteAssessment=="true"{
|
||||
checkResult:=ArgParser.RemoteArgParser(RAV.Host,RAV.User,RAV.Password)
|
||||
checkResult=strings.TrimSpace(checkResult)
|
||||
if checkResult=="true"{
|
||||
fmt.Println("不允许登录root/administrator用户进行验证")
|
||||
log.Println("不允许登录root/administrator用户进行验证")
|
||||
}else if checkResult=="false"{
|
||||
ArgParser.ParameterParser(vul.System,vul.Kernel,vul.Web,vul.BaseLine,sAll,vul.PoolStatNum,vul.ParserNum,vul.Update,vul.IP,help)
|
||||
}
|
||||
|
||||
}else{
|
||||
ArgParser.WKPWD(vul.WKPWD,PWDList[:])
|
||||
ArgParser.SSHBurst(vul.SSHBurst,SSHBurstList[:])
|
||||
ArgParser.NmapScan(vul.Nmap, NmapScanList[:])
|
||||
ArgParser.FofaApi(vul.Fofa,FC.FofaCom)
|
||||
return
|
||||
ArgParser.ParameterParser(vul.System,vul.Kernel,vul.Web,vul.BaseLine,sAll,vul.PoolStatNum,vul.ParserNum,vul.Update,vul.IP,help)
|
||||
}
|
||||
return
|
||||
///////////////////////////////
|
||||
// test "main/genmai"
|
||||
genmai.Test()
|
||||
// config := genmai.NewConfig()
|
||||
fmt.Println(">>")
|
||||
//fmt.Println(config["id"])
|
||||
|
||||
///////////////////////////////
|
||||
// test gconsole
|
||||
gcon.Draw()
|
||||
|
||||
return
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
package main
|
||||
import(
|
||||
"main/tools/SSHExplosion"
|
||||
)
|
||||
func main(){
|
||||
SSHExplosion.SshExp()
|
||||
// re:=SSHExplosion.SshConnect("127.0.0.1","song","sbcj1999")
|
||||
}
|
||||
|
Loading…
Reference in New Issue