New creates a new initialized GobusterDir
(globalopts *libgobuster.Options, opts *OptionsDir, logger *libgobuster.Logger)
| 52 | |
| 53 | // New creates a new initialized GobusterDir |
| 54 | func New(globalopts *libgobuster.Options, opts *OptionsDir, logger *libgobuster.Logger) (*GobusterDir, error) { |
| 55 | if globalopts == nil { |
| 56 | return nil, errors.New("please provide valid global options") |
| 57 | } |
| 58 | |
| 59 | if opts == nil { |
| 60 | return nil, errors.New("please provide valid plugin options") |
| 61 | } |
| 62 | |
| 63 | g := GobusterDir{ |
| 64 | options: opts, |
| 65 | globalopts: globalopts, |
| 66 | } |
| 67 | |
| 68 | basicOptions := libgobuster.BasicHTTPOptions{ |
| 69 | Proxy: opts.Proxy, |
| 70 | Timeout: opts.Timeout, |
| 71 | UserAgent: opts.UserAgent, |
| 72 | NoTLSValidation: opts.NoTLSValidation, |
| 73 | RetryOnTimeout: opts.RetryOnTimeout, |
| 74 | RetryAttempts: opts.RetryAttempts, |
| 75 | TLSCertificate: opts.TLSCertificate, |
| 76 | TLSRenegotiation: opts.TLSRenegotiation, |
| 77 | LocalAddr: opts.LocalAddr, |
| 78 | } |
| 79 | |
| 80 | httpOpts := libgobuster.HTTPOptions{ |
| 81 | BasicHTTPOptions: basicOptions, |
| 82 | FollowRedirect: opts.FollowRedirect, |
| 83 | Username: opts.Username, |
| 84 | Password: opts.Password, |
| 85 | Headers: opts.Headers, |
| 86 | NoCanonicalizeHeaders: opts.NoCanonicalizeHeaders, |
| 87 | Cookies: opts.Cookies, |
| 88 | Method: opts.Method, |
| 89 | } |
| 90 | |
| 91 | h, err := libgobuster.NewHTTPClient(&httpOpts, logger) |
| 92 | if err != nil { |
| 93 | return nil, err |
| 94 | } |
| 95 | g.http = h |
| 96 | |
| 97 | return &g, nil |
| 98 | } |
| 99 | |
| 100 | // Name should return the name of the plugin |
| 101 | func (d *GobusterDir) Name() string { |