|
| 1 | +package command_line |
| 2 | + |
| 3 | +import ( |
| 4 | + "flag" |
| 5 | + "os" |
| 6 | + |
| 7 | + "github.com/oiweiwei/go-msrpc/config" |
| 8 | +) |
| 9 | + |
| 10 | +func BindFlags(c *config.Config, flagSet *flag.FlagSet) { |
| 11 | + |
| 12 | + flagSet.BoolVar(&c.Debug, "debug", c.Debug, "enable debug output") |
| 13 | + |
| 14 | + flagSet.StringVar(&c.Server, "server", c.Server, "server to connect to") |
| 15 | + flagSet.StringVar(&c.Domain, "domain", c.Domain, "domain to authenticate to") |
| 16 | + flagSet.StringVar(&c.Username, "username", c.Username, "username to authenticate as") |
| 17 | + flagSet.StringVar(&c.Workstation, "workstation", c.Workstation, "workstation to authenticate from") |
| 18 | + |
| 19 | + flagSet.DurationVar(&c.Timeout, "timeout", c.Timeout, "timeout") |
| 20 | + |
| 21 | + flagSet.StringVar(&c.Credential.Password, "password", c.Credential.Password, "password to authenticate with") |
| 22 | + flagSet.StringVar(&c.Credential.NTHash, "nthash", c.Credential.NTHash, "NT hash to authenticate with") |
| 23 | + flagSet.StringVar(&c.Credential.MachineAccountPassword, "machine-account-password", c.Credential.MachineAccountPassword, "machine account password to authenticate with") |
| 24 | + flagSet.StringVar(&c.Credential.MachineAccountNTHash, "machine-account-nthash", c.Credential.MachineAccountNTHash, "machine account NT hash to authenticate with") |
| 25 | + |
| 26 | + flagSet.StringVar(&c.Auth.Level, "auth-level", c.Auth.Level, "authentication level: none, connect, call, pkt, integrity, privacy") |
| 27 | + flagSet.StringVar(&c.Auth.Type, "auth-type", c.Auth.Type, "authentication type: ntlm, krb5") |
| 28 | + flagSet.StringVar(&c.Auth.TargetName, "target-name", c.Auth.TargetName, "target name") |
| 29 | + flagSet.BoolVar(&c.Auth.SPNEGO, "spnego", c.Auth.SPNEGO, "use spnego") |
| 30 | + flagSet.StringVar(&c.Auth.Impersonation, "impersonation", c.Auth.Impersonation, "impersonation level: anonymous, identify, impersonate, delegate") |
| 31 | + flagSet.StringVar(&c.Auth.KRB5.ConfigFile, "krb5-config-file", c.Auth.KRB5.ConfigFile, "path to krb5.conf") |
| 32 | + flagSet.StringVar(&c.Auth.KRB5.KDCServer, "krb5-kdc-server", c.Auth.KRB5.KDCServer, "KDC server to authenticate to") |
| 33 | + flagSet.StringVar(&c.Auth.KRB5.AdminServer, "krb5-admin-server", c.Auth.KRB5.AdminServer, "admin server to authenticate to") |
| 34 | + flagSet.StringVar(&c.Auth.KRB5.Keytab, "krb5-keytab-path", c.Auth.KRB5.Keytab, "path to keytab") |
| 35 | + flagSet.StringVar(&c.Auth.KRB5.CCache, "krb5-ccache-path", c.Auth.KRB5.CCache, "path to ccache") |
| 36 | + flagSet.Var(&c.Auth.KRB5.EncryptionTypes, "krb5-encryption-types", "encryption types to use: aes256-cts-hmac-sha1-96, aes128-cts-hmac-sha1-96, arcfour-hmac-md5") |
| 37 | + flagSet.BoolVar(&c.Auth.KRB5.DCEStyle, "krb5-dce-style", c.Auth.KRB5.DCEStyle, "use DCE style") |
| 38 | + flagSet.BoolVar(&c.Auth.KRB5.DisablePAFXFAST, "krb5-disable-pafx-fast", c.Auth.KRB5.DisablePAFXFAST, "disable PA-FX-FAST") |
| 39 | + flagSet.BoolVar(&c.Auth.KRB5.MutualAuthn, "krb5-mutual-authn", c.Auth.KRB5.MutualAuthn, "use mutual authentication") |
| 40 | + |
| 41 | + flagSet.BoolVar(&c.Auth.NTLM.NTLMv1, "ntlm-v1", c.Auth.NTLM.NTLMv1, "use NTLMv1") |
| 42 | + flagSet.BoolVar(&c.Auth.NTLM.NoESS, "ntlm-no-ess", c.Auth.NTLM.NoESS, "use no extended session security") |
| 43 | + |
| 44 | + flagSet.BoolVar(&c.Verify.Presentation, "verify-presentation", false, "verify presentation") |
| 45 | + flagSet.BoolVar(&c.Verify.Header2, "verify-header2", false, "verify header2") |
| 46 | + flagSet.BoolVar(&c.Verify.BitMask, "verify-bitmask", false, "verify bitmask") |
| 47 | + |
| 48 | + flagSet.IntVar(&c.SMB.Port, "smb-port", 445, "SMB port") |
| 49 | + flagSet.BoolVar(&c.SMB.Sign, "smb-sign", false, "SMB signing") |
| 50 | + flagSet.BoolVar(&c.SMB.Seal, "smb-seal", false, "SMB sealing") |
| 51 | + flagSet.StringVar(&c.SMB.Dialect, "smb-dialect", c.SMB.Dialect, "SMB dialect: 2.0.2 (202), 2.1.0 (210), 3.0.0 (300), 3.0.2 (302), 3.1.1 (311)") |
| 52 | + |
| 53 | + flagSet.BoolVar(&c.EPM.Enabled, "epm", c.EPM.Enabled, "use endpoint mapper") |
| 54 | + flagSet.StringVar(&c.EPM.AuthLevel, "epm-auth-level", c.EPM.AuthLevel, "endpoint mapper authentication level: none, connect, call, pkt, integrity, privacy") |
| 55 | + |
| 56 | + flagSet.StringVar(&c.Protocol, "protocol", c.Protocol, "protocol to use, ncacn_np (smb), ncacn_ip_tcp (tcp)") |
| 57 | +} |
| 58 | + |
| 59 | +func ParseAndValidate(cfg *config.Config, flagSet *flag.FlagSet) error { |
| 60 | + |
| 61 | + flagSet.Parse(os.Args[1:]) |
| 62 | + |
| 63 | + if cfg.Server == "" && flagSet.NArg() > 0 { |
| 64 | + cfg.Server = flagSet.Arg(0) |
| 65 | + flagSet.Parse(flagSet.Args()[1:]) |
| 66 | + } |
| 67 | + |
| 68 | + return cfg.Validate() |
| 69 | +} |
0 commit comments