-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexploit.go
More file actions
70 lines (66 loc) · 2.34 KB
/
exploit.go
File metadata and controls
70 lines (66 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package pocRegistry
import (
"fmt"
"github.com/12end/pocRegistry/cli"
"github.com/12end/requests"
"net/url"
"strings"
)
func (r Registry) exploit(poc POC, actionName string, target *url.URL, trace bool, args []string) (vulnerable bool, traceInfo []requests.TraceInfo) {
r.Logger.Info(fmt.Sprintf("Exploit %s/%s(%s) for %s,action: %s", poc.ProductName, poc.Name, poc.Alias, target.String(), actionName))
for _, exploit := range poc.Exploit {
params := cli.NewFlagSet(actionName)
for _, flag := range exploit.Flags {
if flag.IsRequired() && args == nil {
// not cli mode
return
}
flag.Apply(params.Set)
}
if exploit.Name == actionName {
err := params.Set.Parse(args)
if err != nil {
fmt.Println(err)
}
vulnerable, traceInfo = exploit.Action(&cli.Context{Trace: trace, Target: target, Logger: r.Logger, Params: params})
if vulnerable {
r.Logger.Warn(fmt.Sprintf("%s has vulnerability for %s/%s!", target.String(), poc.ProductName, poc.Name))
}
return
}
}
r.Logger.Error(fmt.Sprintf("No such action(%s) in poc: %s/%s", actionName, poc.ProductName, poc.Name))
return
}
func (r Registry) ExecuteExploit(target *url.URL, productName string, pocName string, actionName string, args []string) (vulnerable bool) {
productName_ := strings.ToLower(productName)
pocName_ := strings.ToLower(pocName)
if _, ok := r.Pocs[productName_]; ok {
if poc, ok := r.Pocs[productName_][pocName_]; ok {
vulnerable, _ = r.exploit(poc, actionName, target, false, args)
return
} else {
r.Logger.Error(fmt.Sprintf("No such poc(%s) in product: %s", pocName, productName))
return false
}
} else {
r.Logger.Error(fmt.Sprintf("No such product: %s", productName))
return false
}
}
func (r Registry) ExecuteExploitWithTrace(target *url.URL, productName string, pocName string, actionName string, args []string) (vulnerable bool, trace []requests.TraceInfo) {
productName_ := strings.ToLower(productName)
pocName_ := strings.ToLower(pocName)
if _, ok := r.Pocs[productName_]; ok {
if poc, ok := r.Pocs[productName_][pocName_]; ok {
vulnerable, trace = r.exploit(poc, actionName, target, true, args)
return
} else {
r.Logger.Error(fmt.Sprintf("No such poc(%s) in product: %s", pocName, productName))
return false, nil
}
} else {
r.Logger.Error(fmt.Sprintf("No such product: %s", productName))
return false, nil
}
}