feat: init nightly vuls for blackhat
This commit is contained in:
59
pkg/config/config.go
Normal file
59
pkg/config/config.go
Normal file
@@ -0,0 +1,59 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func Open(path string) (Config, error) {
|
||||
f, err := os.Open(path)
|
||||
if err != nil {
|
||||
return Config{}, errors.Wrapf(err, "open %s", path)
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
var src Config
|
||||
if err := json.NewDecoder(f).Decode(&src); err != nil {
|
||||
return Config{}, errors.Wrap(err, "decode json")
|
||||
}
|
||||
|
||||
u, err := user.Current()
|
||||
if err != nil {
|
||||
return Config{}, errors.Wrap(err, "get current user")
|
||||
}
|
||||
|
||||
pwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
return Config{}, errors.Wrap(err, "get working directory")
|
||||
}
|
||||
|
||||
config := Config{Server: src.Server, Hosts: map[string]Host{}}
|
||||
for n, h := range src.Hosts {
|
||||
c := Host{
|
||||
Type: h.Type,
|
||||
Host: h.Host,
|
||||
Port: h.Port,
|
||||
User: h.User,
|
||||
SSHConfig: h.SSHConfig,
|
||||
SSHKey: h.SSHKey,
|
||||
Scan: h.Scan,
|
||||
Detect: h.Detect,
|
||||
}
|
||||
if c.User == nil {
|
||||
c.User = &u.Name
|
||||
}
|
||||
if c.Scan.ResultDir == "" {
|
||||
c.Scan.ResultDir = filepath.Join(pwd, "results")
|
||||
}
|
||||
if c.Detect.ResultDir == "" {
|
||||
c.Detect.ResultDir = filepath.Join(pwd, "results")
|
||||
}
|
||||
config.Hosts[n] = c
|
||||
}
|
||||
|
||||
return config, nil
|
||||
}
|
||||
41
pkg/config/types.go
Normal file
41
pkg/config/types.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package config
|
||||
|
||||
type Config struct {
|
||||
Server *Server `json:"server"`
|
||||
Hosts map[string]Host `json:"hosts"`
|
||||
}
|
||||
|
||||
type Scan struct {
|
||||
OSPkg *scanOSPkg `json:"ospkg,omitempty"`
|
||||
CPE []scanCPE `json:"cpe,omitempty"`
|
||||
ResultDir string `json:"result_dir,omitempty"`
|
||||
}
|
||||
|
||||
type scanOSPkg struct {
|
||||
Root bool `json:"root"`
|
||||
}
|
||||
|
||||
type scanCPE struct {
|
||||
CPE string `json:"cpe,omitempty"`
|
||||
RunningOn string `json:"running_on,omitempty"`
|
||||
}
|
||||
|
||||
type Detect struct {
|
||||
Path string `json:"path"`
|
||||
ResultDir string `json:"result_dir"`
|
||||
}
|
||||
|
||||
type Server struct {
|
||||
Listen string `json:"listen"`
|
||||
Path string `json:"path"`
|
||||
}
|
||||
type Host struct {
|
||||
Type string `json:"type"`
|
||||
Host *string `json:"host"`
|
||||
Port *string `json:"port"`
|
||||
User *string `json:"user"`
|
||||
SSHConfig *string `json:"ssh_config"`
|
||||
SSHKey *string `json:"ssh_key"`
|
||||
Scan Scan `json:"scan"`
|
||||
Detect Detect `json:"detect"`
|
||||
}
|
||||
Reference in New Issue
Block a user