(c *cli.Context)
| 41 | } |
| 42 | |
| 43 | func ParseBasicHTTPOptions(c *cli.Context) (libgobuster.BasicHTTPOptions, error) { |
| 44 | var opts libgobuster.BasicHTTPOptions |
| 45 | opts.UserAgent = c.String("useragent") |
| 46 | randomUA := c.Bool("random-agent") |
| 47 | if randomUA { |
| 48 | ua, err := libgobuster.GetRandomUserAgent() |
| 49 | if err != nil { |
| 50 | return opts, err |
| 51 | } |
| 52 | opts.UserAgent = ua |
| 53 | } |
| 54 | opts.Proxy = c.String("proxy") |
| 55 | opts.Timeout = c.Duration("timeout") |
| 56 | opts.NoTLSValidation = c.Bool("no-tls-validation") |
| 57 | opts.RetryOnTimeout = c.Bool("retry") |
| 58 | opts.RetryAttempts = c.Int("retry-attempts") |
| 59 | |
| 60 | pemFile := c.String("client-cert-pem") |
| 61 | pemKeyFile := c.String("client-cert-pem-key") |
| 62 | p12File := c.String("client-cert-p12") |
| 63 | p12Pass := c.String("client-cert-p12-password") |
| 64 | |
| 65 | if pemFile != "" && p12File != "" { |
| 66 | return opts, errors.New("please supply either a pem or a p12, not both") |
| 67 | } |
| 68 | |
| 69 | if pemFile != "" { |
| 70 | cert, err := tls.LoadX509KeyPair(pemFile, pemKeyFile) |
| 71 | if err != nil { |
| 72 | return opts, fmt.Errorf("could not load supplied pem key: %w", err) |
| 73 | } |
| 74 | opts.TLSCertificate = &cert |
| 75 | } else if p12File != "" { |
| 76 | p12Content, err := os.ReadFile(p12File) |
| 77 | if err != nil { |
| 78 | return opts, fmt.Errorf("could not read p12 %s: %w", p12File, err) |
| 79 | } |
| 80 | privKey, pubKey, _, err := pkcs12.DecodeChain(p12Content, p12Pass) |
| 81 | if err != nil { |
| 82 | return opts, fmt.Errorf("could not load P12: %w", err) |
| 83 | } |
| 84 | opts.TLSCertificate = &tls.Certificate{ |
| 85 | Certificate: [][]byte{pubKey.Raw}, |
| 86 | PrivateKey: privKey, |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | opts.TLSRenegotiation = c.Bool("tls-renegotiation") |
| 91 | |
| 92 | iface := c.String("interface") |
| 93 | localIP := c.String("local-ip") |
| 94 | if iface != "" && localIP != "" { |
| 95 | return opts, errors.New("can not set both interface and local-ip") |
| 96 | } |
| 97 | |
| 98 | switch { |
| 99 | case iface != "": |
| 100 | a, err := getLocalAddrFromInterface(iface) |
no test coverage detected