forked from blackhat-go/bhg
/
main.go
50 lines (43 loc) · 983 Bytes
/
main.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
package main
import (
"fmt"
"io/ioutil"
"log"
"os"
"plugin"
"github.com/bhg/ch-10/plugin-core/scanner"
)
const PluginsDir = "../../plugins/"
func main() {
var (
files []os.FileInfo
err error
p *plugin.Plugin
n plugin.Symbol
check scanner.Checker
res *scanner.Result
)
if files, err = ioutil.ReadDir(PluginsDir); err != nil {
log.Fatalln(err)
}
for idx := range files {
fmt.Println("Found plugin: " + files[idx].Name())
if p, err = plugin.Open(PluginsDir + "/" + files[idx].Name()); err != nil {
log.Fatalln(err)
}
if n, err = p.Lookup("New"); err != nil {
log.Fatalln(err)
}
newFunc, ok := n.(func() scanner.Checker)
if !ok {
log.Fatalln("Plugin entry point is no good. Expecting: func New() scanner.Checker{ ... }")
}
check = newFunc()
res = check.Check("10.0.1.20", 8080)
if res.Vulnerable {
log.Println("Host is vulnerable: " + res.Details)
} else {
log.Println("Host is NOT vulnerable")
}
}
}