forked from gaulliath/operative-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
searchsploit.go
127 lines (107 loc) · 2.87 KB
/
searchsploit.go
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
package searchsploit
import (
"encoding/json"
"os"
"os/exec"
"github.com/jedib0t/go-pretty/table"
"github.com/Oni-kuki/operative-framework/session"
)
type SearchSploitModule struct {
session.SessionModule
sess *session.Session `json:"-"`
Stream *session.Stream `json:"-"`
}
type Exploit struct {
SEARCH string `json:"SEARCH"`
DBPATHEXPLOIT string `json:"DB_PATH_EXPLOIT"`
RESULTSEXPLOIT []struct {
Title string `json:"Title"`
URL string `json:"URL"`
} `json:"RESULTS_EXPLOIT"`
DBPATHSHELLCODE string `json:"DB_PATH_SHELLCODE"`
RESULTSSHELLCODE []interface{} `json:"RESULTS_SHELLCODE"`
DBPATHPAPER string `json:"DB_PATH_PAPER"`
RESULTSPAPER []struct {
Title string `json:"Title"`
URL string `json:"URL"`
} `json:"RESULTS_PAPER"`
}
func PushSearchSploitModule(s *session.Session) *SearchSploitModule {
mod := SearchSploitModule{
sess: s,
Stream: &s.Stream,
}
mod.WithProgram("searchsploit")
mod.CreateNewParam("TARGET", "Name of software", "", true, session.STRING)
return &mod
}
func (module *SearchSploitModule) Name() string {
return "search_exploit"
}
func (module *SearchSploitModule) Description() string {
return "Search exploit for specific software"
}
func (module *SearchSploitModule) Author() string {
return "Tristan Granier"
}
func (module *SearchSploitModule) GetType() []string {
return []string{
session.T_TARGET_SOFTWARE,
}
}
func (module *SearchSploitModule) GetInformation() session.ModuleInformation {
information := session.ModuleInformation{
Name: module.Name(),
Description: module.Description(),
Author: module.Author(),
Type: module.GetType(),
Parameters: module.Parameters,
}
return information
}
func (module *SearchSploitModule) Start() {
trg, err := module.GetParameter("TARGET")
if err != nil {
module.sess.Stream.Error(err.Error())
return
}
target, err := module.sess.GetTarget(trg.Value)
if err != nil {
module.sess.Stream.Error(err.Error())
return
}
output, err := exec.Command("searchsploit", "-w", "-o", "-j", target.GetName()).CombinedOutput()
if err != nil {
module.sess.Stream.Error(err.Error())
return
}
var exploits Exploit
err = json.Unmarshal(output, &exploits)
if err != nil {
module.sess.Stream.Error("No result found.")
return
}
if len(exploits.RESULTSEXPLOIT) < 1 {
module.sess.Stream.Error("No result found.")
return
}
t := module.sess.Stream.GenerateTable()
t.SetOutputMirror(os.Stdout)
t.SetAllowedColumnLengths([]int{50, 30})
t.AppendHeader(table.Row{
"TITLE",
"URL",
})
for _, exploit := range exploits.RESULTSEXPLOIT {
t.AppendRow(table.Row{
exploit.Title,
exploit.URL,
})
result := target.NewResult()
result.Set("TITLE", exploit.Title)
result.Set("URL", exploit.URL)
result.Save(module, target)
module.Results = append(module.Results, exploit.Title)
}
module.sess.Stream.Render(t)
}