forked from bettercap/bettercap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
107 lines (90 loc) · 2.79 KB
/
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
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
package main
import (
"fmt"
"io"
"os"
"github.com/bettercap/bettercap/core"
"github.com/bettercap/bettercap/log"
"github.com/bettercap/bettercap/modules"
"github.com/bettercap/bettercap/session"
)
var sess *session.Session
var err error
// Some modules are enabled by default in order
// to make the interactive session useful.
var autoEnableList = []string{
"events.stream",
"net.recon",
}
func main() {
if sess, err = session.New(); err != nil {
fmt.Println(err)
os.Exit(1)
}
if core.NoColors == true {
fmt.Printf("\n\nWARNING: This terminal does not support colors, view will be very limited.\n\n")
}
appName := fmt.Sprintf("%s v%s", core.Name, core.Version)
fmt.Printf("%s (type '%s' for a list of commands)\n\n", core.Bold(appName), core.Bold("help"))
sess.Register(modules.NewEventsStream(sess))
sess.Register(modules.NewTicker(sess))
sess.Register(modules.NewMacChanger(sess))
sess.Register(modules.NewProber(sess))
sess.Register(modules.NewDiscovery(sess))
sess.Register(modules.NewArpSpoofer(sess))
sess.Register(modules.NewDHCP6Spoofer(sess))
sess.Register(modules.NewDNSSpoofer(sess))
sess.Register(modules.NewSniffer(sess))
sess.Register(modules.NewHttpServer(sess))
sess.Register(modules.NewHttpProxy(sess))
sess.Register(modules.NewHttpsProxy(sess))
sess.Register(modules.NewTcpProxy(sess))
sess.Register(modules.NewRestAPI(sess))
sess.Register(modules.NewWOL(sess))
sess.Register(modules.NewWiFiRecon(sess))
sess.Register(modules.NewBLERecon(sess))
sess.Register(modules.NewSynScanner(sess))
if err = sess.Start(); err != nil {
log.Fatal("%s", err)
}
for _, modName := range autoEnableList {
if err = sess.Run(modName + " on"); err != nil {
log.Fatal("Error while starting module %s: %", modName, err)
}
}
/*
* Commands sent with -eval are used to set specific
* caplet parameters (i.e. arp.spoof.targets) via command
* line, therefore they need to be executed first otherwise
* modules might already be started.
*/
for _, cmd := range session.ParseCommands(*sess.Options.Commands) {
if err = sess.Run(cmd); err != nil {
log.Error("Error while running '%s': %s", core.Bold(cmd), core.Red(err.Error()))
}
}
// Then run the caplet if specified.
if *sess.Options.Caplet != "" {
if err = sess.RunCaplet(*sess.Options.Caplet); err != nil {
log.Error("Error while runnig caplet %s: %s", core.Bold(*sess.Options.Caplet), core.Red(err.Error()))
}
}
// Eventually start the interactive session.
for sess.Active {
line, err := sess.ReadLine()
if err != nil {
if err == io.EOF {
continue
}
log.Fatal("%s", err)
}
for _, cmd := range session.ParseCommands(line) {
if err = sess.Run(cmd); err != nil {
log.Error("%s", err)
}
}
}
sess.Close()
// Windows requires this otherwise the app never exits ...
os.Exit(0)
}