-
Notifications
You must be signed in to change notification settings - Fork 46
/
root.go
89 lines (72 loc) · 3.25 KB
/
root.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
package cmd
import (
"fmt"
"os"
"github.com/spf13/cobra"
)
// ToolName controls what this program thinks it is
var ToolName = "flamingo"
// Version is set by goreleaser
var Version = "0.0.0"
type flamingoParameters struct {
Quiet bool
Verbose bool
IgnoreFailures bool
SNMPPorts string
SSHPorts string
SSHHostKey string
LDAPPorts string
LDAPSPorts string
HTTPPorts string
HTTPSPorts string
HTTPBasicRealm string
HTTPAuthMode string
TLSCertFile string
TLSCertData string
TLSKeyFile string
TLSKeyData string
TLSName string
TLSOrgName string
Protocols string
}
var params = &flamingoParameters{}
var rootCmd = &cobra.Command{
Use: ToolName,
Short: fmt.Sprintf("%s captures inbound credentials", ToolName),
Long: fmt.Sprintf(`flamingo v%s`, Version),
Args: cobra.ArbitraryArgs,
Run: func(cmd *cobra.Command, args []string) {
startCapture(cmd, args)
},
}
// Execute is the main entry point for this tool
func Execute() {
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}
func init() {
// General options
rootCmd.PersistentFlags().BoolVarP(¶ms.Verbose, "verbose", "v", false, "Display verbose output")
rootCmd.PersistentFlags().BoolVarP(¶ms.Quiet, "quiet", "q", false, "Hide startup banners and other extraneous output")
rootCmd.PersistentFlags().BoolVarP(¶ms.IgnoreFailures, "ignore", "I", false, "Ignore individual listener failures")
rootCmd.Flags().StringVarP(¶ms.Protocols, "protocols", "", "ssh,snmp,ldap,http", "Specify a comma-separated list of protocols")
// SNMP parameters
rootCmd.Flags().StringVarP(¶ms.SNMPPorts, "snmp-ports", "", "161", "The list of UDP ports to listen on for SNMP")
// SSH parameters
rootCmd.Flags().StringVarP(¶ms.SSHPorts, "ssh-ports", "", "22", "The list of TCP ports to listen on for SSH")
rootCmd.Flags().StringVarP(¶ms.SSHHostKey, "ssh-host-key", "", "", "An optional path to a SSH host key on disk")
// LDAP(S) parameters
rootCmd.Flags().StringVarP(¶ms.LDAPPorts, "ldap-ports", "", "389", "The list of TCP ports to listen on for LDAP")
rootCmd.Flags().StringVarP(¶ms.LDAPSPorts, "ldaps-ports", "", "636", "The list of TCP ports to listen on for LDAPS")
// HTTP(S) parameters
rootCmd.Flags().StringVarP(¶ms.HTTPPorts, "http-ports", "", "80", "The list of TCP ports to listen on for HTTP")
rootCmd.Flags().StringVarP(¶ms.HTTPSPorts, "https-ports", "", "443", "The list of TCP ports to listen on for HTTPS")
rootCmd.Flags().StringVarP(¶ms.HTTPBasicRealm, "http-realm", "", "Administration", "The HTTP basic authentication realm to present")
rootCmd.Flags().StringVarP(¶ms.HTTPAuthMode, "http-auth-mode", "", "ntlm", "The authentication mode for the HTTP listeners (ntlm or basic)")
rootCmd.Flags().StringVarP(¶ms.TLSCertFile, "tls-cert", "", "", "An optional x509 certificate for TLS listeners")
rootCmd.Flags().StringVarP(¶ms.TLSKeyFile, "tls-key", "", "", "An optional x509 key for TLS listeners")
rootCmd.Flags().StringVarP(¶ms.TLSName, "tls-name", "", "localhost", "A server name to use with TLS listeners")
rootCmd.Flags().StringVarP(¶ms.TLSOrgName, "tls-org", "", "Flamingo Feed, Inc.", "An organization to use for self-signed certificates")
}