feat: init nightly vuls for blackhat

This commit is contained in:
MaineK00n
2022-11-15 11:26:26 +09:00
parent 1d97e91341
commit 3605645ff6
234 changed files with 6172 additions and 54872 deletions

59
pkg/config/config.go Normal file
View 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
View 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"`
}