| 1 |
package capletsscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/modules/caplets`/ |
| 2 |
|
| 3 |
import ( |
| 4 |
"fmtscip-go gomod github.com/golang/go/src go1.16 fmt/" |
| 5 |
|
| 6 |
"github.com/bettercap/bettercap/capletsscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/caplets`/" |
| 7 |
"github.com/bettercap/bettercap/sessionscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/" |
| 8 |
|
| 9 |
"github.com/dustin/go-humanizescip-go gomod github.com/dustin/go-humanize v1.0.1 `github.com/dustin/go-humanize`/" |
| 10 |
|
| 11 |
"github.com/evilsocket/islazy/tuiscip-go gomod github.com/evilsocket/islazy v1.11.0 `github.com/evilsocket/islazy/tui`/" |
| 12 |
) |
| 13 |
|
| 14 |
type CapletsModulescip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/modules/caplets`/CapletsModule# struct { |
| 15 |
sessionscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/.SessionModulescip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/modules/caplets`/CapletsModule#SessionModule. |
| 16 |
} |
| 17 |
|
| 18 |
func NewCapletsModulescip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/modules/caplets`/NewCapletsModule().(s *sessionscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/.Sessionscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/Session#) *CapletsModulescip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/modules/caplets`/CapletsModule# { |
| 19 |
mod := &CapletsModulescip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/modules/caplets`/CapletsModule#{ |
| 20 |
SessionModulescip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/modules/caplets`/CapletsModule#SessionModule.: sessionscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/.NewSessionModulescip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/NewSessionModule().("caplets", s), |
| 21 |
} |
| 22 |
|
| 23 |
mod.AddHandlerscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/SessionModule#AddHandler().(sessionscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/.NewModuleHandlerscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/NewModuleHandler().("caplets.show", "", |
| 24 |
"Show a list of installed caplets.", |
| 25 |
func(args []string) error { |
| 26 |
return mod.Showscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/modules/caplets`/CapletsModule#Show().() |
| 27 |
})) |
| 28 |
|
| 29 |
mod.AddHandlerscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/SessionModule#AddHandler().(sessionscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/.NewModuleHandlerscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/NewModuleHandler().("caplets.paths", "", |
| 30 |
"Show a list caplet search paths.", |
| 31 |
func(args []string) error { |
| 32 |
return mod.Pathsscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/modules/caplets`/CapletsModule#Paths().() |
| 33 |
})) |
| 34 |
mod.AddHandlerscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/SessionModule#AddHandler().(sessionscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/.NewModuleHandlerscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/NewModuleHandler().("caplets.update", "", |
| •35 |
"Install/updates the caplets.", |
| 36 |
func(args []string) error { |
| 37 |
return mod.Updatescip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/modules/caplets`/CapletsModule#Update().() |
| 38 |
})) |
| 39 |
|
| 40 |
return mod |
| 41 |
} |
| 42 |
|
| 43 |
func (mod *CapletsModulescip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/modules/caplets`/CapletsModule#) Namescip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/modules/caplets`/CapletsModule#Name().() string { |
| 44 |
return "caplets" |
| 45 |
} |
| 46 |
|
| 47 |
func (mod *CapletsModulescip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/modules/caplets`/CapletsModule#) Descriptionscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/modules/caplets`/CapletsModule#Description().() string { |
| •48 |
return "A module to list caplets." |
| 49 |
} |
| 50 |
|
| 51 |
func (mod *CapletsModulescip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/modules/caplets`/CapletsModule#) Authorscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/modules/caplets`/CapletsModule#Author().() string { |
| 52 |
return "Simone Margaritelli <[email protected]>" |
| 53 |
} |
| 54 |
|
| 55 |
func (mod *CapletsModulescip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/modules/caplets`/CapletsModule#) Configurescip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/modules/caplets`/CapletsModule#Configure().() error { |
| 56 |
return nil |
| 57 |
} |
| 58 |
|
| 59 |
func (mod *CapletsModulescip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/modules/caplets`/CapletsModule#) Stopscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/modules/caplets`/CapletsModule#Stop().() error { |
| 60 |
return nil |
| 61 |
} |
| 62 |
|
| 63 |
func (mod *CapletsModulescip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/modules/caplets`/CapletsModule#) Startscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/modules/caplets`/CapletsModule#Start().() error { |
| 64 |
return nil |
| 65 |
} |
| 66 |
|
| 67 |
func (mod *CapletsModulescip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/modules/caplets`/CapletsModule#) Showscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/modules/caplets`/CapletsModule#Show().() error { |
| 68 |
caplets := capletsscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/caplets`/.Listscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/caplets`/List().() |
| 69 |
if len(caplets) == 0 { |
| •70 |
return fmtscip-go gomod github.com/golang/go/src go1.16 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.16 fmt/Errorf().("no installed caplets on this system, in Debian install bettercap-caplets package") |
| 71 |
} |
| 72 |
|
| 73 |
colNames := []string{ |
| 74 |
"Name", |
| 75 |
"Path", |
| 76 |
"Size", |
| 77 |
} |
| 78 |
rows := [][]string{} |
| 79 |
|
| 80 |
for _, caplet := range caplets { |
| 81 |
rows = append(rows, []string{ |
| 82 |
tuiscip-go gomod github.com/evilsocket/islazy v1.11.0 `github.com/evilsocket/islazy/tui`/.Boldscip-go gomod github.com/evilsocket/islazy v1.11.0 `github.com/evilsocket/islazy/tui`/Bold().(caplet.Namescip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/caplets`/Caplet#Name.), |
| 83 |
caplet.Pathscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/caplets`/Script#Path., |
| 84 |
tuiscip-go gomod github.com/evilsocket/islazy v1.11.0 `github.com/evilsocket/islazy/tui`/.Dimscip-go gomod github.com/evilsocket/islazy v1.11.0 `github.com/evilsocket/islazy/tui`/Dim().(humanizescip-go gomod github.com/dustin/go-humanize v1.0.1 `github.com/dustin/go-humanize`/.Bytesscip-go gomod github.com/dustin/go-humanize v1.0.1 `github.com/dustin/go-humanize`/Bytes().(uint64(caplet.Sizescip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/caplets`/Script#Size.))), |
| 85 |
}) |
| 86 |
} |
| 87 |
|
| 88 |
tuiscip-go gomod github.com/evilsocket/islazy v1.11.0 `github.com/evilsocket/islazy/tui`/.Tablescip-go gomod github.com/evilsocket/islazy v1.11.0 `github.com/evilsocket/islazy/tui`/Table().(mod.Sessionscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/SessionModule#Session..Eventsscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/Session#Events..Stdoutscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/EventPool#Stdout., colNames, rows) |
| 89 |
|
| 90 |
return nil |
| 91 |
} |
| 92 |
|
| 93 |
func (mod *CapletsModulescip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/modules/caplets`/CapletsModule#) Pathsscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/modules/caplets`/CapletsModule#Paths().() error { |
| 94 |
colNames := []string{ |
| 95 |
"Path", |
| 96 |
} |
| 97 |
rows := [][]string{} |
| 98 |
|
| 99 |
for _, path := range capletsscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/caplets`/.LoadPathsscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/caplets`/LoadPaths. { |
| 100 |
rows = append(rows, []string{path}) |
| 101 |
} |
| 102 |
|
| 103 |
tuiscip-go gomod github.com/evilsocket/islazy v1.11.0 `github.com/evilsocket/islazy/tui`/.Tablescip-go gomod github.com/evilsocket/islazy v1.11.0 `github.com/evilsocket/islazy/tui`/Table().(mod.Sessionscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/SessionModule#Session..Eventsscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/Session#Events..Stdoutscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/EventPool#Stdout., colNames, rows) |
| 104 |
mod.Printfscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/SessionModule#Printf().("(paths can be customized by defining the %s environment variable)\n", tuiscip-go gomod github.com/evilsocket/islazy v1.11.0 `github.com/evilsocket/islazy/tui`/.Boldscip-go gomod github.com/evilsocket/islazy v1.11.0 `github.com/evilsocket/islazy/tui`/Bold().(capletsscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/caplets`/.EnvVarNamescip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/caplets`/EnvVarName.)) |
| 105 |
|
| 106 |
return nil |
| 107 |
} |
| 108 |
|
| 109 |
func (mod *CapletsModulescip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/modules/caplets`/CapletsModule#) Updatescip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/modules/caplets`/CapletsModule#Update().() error { |
| •110 |
mod.Infoscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/SessionModule#Info().("this command is inactive in Debian. Install the Debian package bettercap-caplets to get the caplets") |
| 111 |
return nil |
| 112 |
} |