Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sundowndev
GitHub Repository: sundowndev/phoneinfoga
Path: blob/master/cmd/scanners.go
988 views
1
package cmd
2
3
import (
4
"fmt"
5
"github.com/spf13/cobra"
6
"github.com/sundowndev/phoneinfoga/v2/lib/filter"
7
"github.com/sundowndev/phoneinfoga/v2/lib/remote"
8
)
9
10
type ScannersCmdOptions struct {
11
Plugin []string
12
}
13
14
func init() {
15
opts := &ScannersCmdOptions{}
16
scannersCmd := NewScannersCmd(opts)
17
18
fl := scannersCmd.Flags()
19
fl.StringSliceVar(&opts.Plugin, "plugin", []string{}, "Output file")
20
21
rootCmd.AddCommand(scannersCmd)
22
}
23
24
func NewScannersCmd(opts *ScannersCmdOptions) *cobra.Command {
25
cmd := &cobra.Command{
26
Use: "scanners",
27
Example: "phoneinfoga scanners",
28
Short: "Display list of loaded scanners",
29
Run: func(cmd *cobra.Command, args []string) {
30
for _, p := range opts.Plugin {
31
err := remote.OpenPlugin(p)
32
if err != nil {
33
exitWithError(err)
34
}
35
}
36
37
remoteLibrary := remote.NewLibrary(filter.NewEngine())
38
remote.InitScanners(remoteLibrary)
39
40
for i, s := range remoteLibrary.GetAllScanners() {
41
fmt.Printf("%s\n%s\n", s.Name(), s.Description())
42
if i < len(remoteLibrary.GetAllScanners()) {
43
fmt.Printf("\n")
44
}
45
}
46
},
47
}
48
return cmd
49
}
50
51