feat: build wahrwelt A/D toolkit
This commit is contained in:
1 parent
303438d206
commit
653924d8c6
564 files changed
+36310
-49998
No files matched your search
@@ -0,0 +1,70 @@
|
||||
package exploit
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/c4t-but-s4d/neo/v2/internal/models"
|
||||
)
|
||||
|
||||
type FarmRequest struct {
|
||||
Flag string `json:"flag"`
|
||||
Exploit string `json:"sploit"`
|
||||
Team string `json:"team"`
|
||||
}
|
||||
|
||||
type FullResult struct {
|
||||
Exploit *models.Exploit
|
||||
Target *models.Target
|
||||
Flag string
|
||||
}
|
||||
|
||||
func NewFullResult(exploit *models.Exploit, target *models.Target, flag string) *FullResult {
|
||||
return &FullResult{
|
||||
Exploit: exploit,
|
||||
Target: target,
|
||||
Flag: flag,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *FullResult) FarmRequest() *FarmRequest {
|
||||
return &FarmRequest{
|
||||
Flag: r.Flag,
|
||||
Exploit: "[neo] " + r.Exploit.ID,
|
||||
Team: r.Target.ID,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *FullResult) MetricLabels() prometheus.Labels {
|
||||
return lo.Assign(r.Exploit.MetricLabels(), r.Target.MetricLabels())
|
||||
}
|
||||
|
||||
type State struct {
|
||||
ID string
|
||||
Version int64
|
||||
Dir string
|
||||
Path string
|
||||
Disabled bool
|
||||
Endless bool
|
||||
RunEvery time.Duration
|
||||
LastRun time.Time
|
||||
ScaledTimeout time.Duration
|
||||
Timeout time.Duration
|
||||
}
|
||||
|
||||
func (s *State) ExploitType() models.ExploitType {
|
||||
if s.Endless {
|
||||
return models.ExploitTypeEndless
|
||||
}
|
||||
return models.ExploitTypeRecurrent
|
||||
}
|
||||
|
||||
func (s *State) ToModel() *models.Exploit {
|
||||
return &models.Exploit{
|
||||
ID: s.ID,
|
||||
Version: s.Version,
|
||||
Type: s.ExploitType(),
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user