Skip to content

Commit

Permalink
Add -raw cli flag (#721)
Browse files Browse the repository at this point in the history
  • Loading branch information
joohoi committed Sep 15, 2023
1 parent 3fdb4e2 commit 02e6a73
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## Changelog
- master
- New
- New cli flag `-raw` to omit urlencoding for URIs
- Integration with `github.com/ffuf/pencode` library, added `-enc` cli flag to do various in-fly encodings for input data
- Changed
- Explicitly allow TLS1.0
Expand Down
1 change: 1 addition & 0 deletions ffufrc.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
ignorebody = false
method = "GET"
proxyurl = "http://127.0.0.1:8080"
raw = false
recursion = false
recursion_depth = 0
recursion_strategy = "default"
Expand Down
2 changes: 1 addition & 1 deletion help.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func Usage() {
Description: "Options controlling the HTTP request and its parts.",
Flags: make([]UsageFlag, 0),
Hidden: false,
ExpectedFlags: []string{"cc", "ck", "H", "X", "b", "d", "r", "u", "recursion", "recursion-depth", "recursion-strategy", "replay-proxy", "timeout", "ignore-body", "x", "sni", "http2"},
ExpectedFlags: []string{"cc", "ck", "H", "X", "b", "d", "r", "u", "raw", "recursion", "recursion-depth", "recursion-strategy", "replay-proxy", "timeout", "ignore-body", "x", "sni", "http2"},
}
u_general := UsageSection{
Name: "GENERAL OPTIONS",
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func ParseFlags(opts *ffuf.ConfigOptions) *ffuf.ConfigOptions {
flag.BoolVar(&opts.General.Verbose, "v", opts.General.Verbose, "Verbose output, printing full URL and redirect location (if any) with the results.")
flag.BoolVar(&opts.HTTP.FollowRedirects, "r", opts.HTTP.FollowRedirects, "Follow redirects")
flag.BoolVar(&opts.HTTP.IgnoreBody, "ignore-body", opts.HTTP.IgnoreBody, "Do not fetch the response content.")
flag.BoolVar(&opts.HTTP.Raw, "raw", opts.HTTP.Raw, "Do not encode URI")
flag.BoolVar(&opts.HTTP.Recursion, "recursion", opts.HTTP.Recursion, "Scan recursively. Only FUZZ keyword is supported, and URL (-u) has to end in it.")
flag.BoolVar(&opts.HTTP.Http2, "http2", opts.HTTP.Http2, "Use HTTP2 protocol")
flag.BoolVar(&opts.Input.DirSearchCompat, "D", opts.Input.DirSearchCompat, "DirSearch wordlist compatibility mode. Used in conjunction with -e flag.")
Expand Down
2 changes: 2 additions & 0 deletions pkg/ffuf/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type Config struct {
ProxyURL string `json:"proxyurl"`
Quiet bool `json:"quiet"`
Rate int64 `json:"rate"`
Raw bool `json:"raw"`
Recursion bool `json:"recursion"`
RecursionDepth int `json:"recursion_depth"`
RecursionStrategy string `json:"recursion_strategy"`
Expand Down Expand Up @@ -108,6 +109,7 @@ func NewConfig(ctx context.Context, cancel context.CancelFunc) Config {
conf.ProxyURL = ""
conf.Quiet = false
conf.Rate = 0
conf.Raw = false
conf.Recursion = false
conf.RecursionDepth = 0
conf.RecursionStrategy = "default"
Expand Down
1 change: 1 addition & 0 deletions pkg/ffuf/configmarshaller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func (c *Config) ToOptions() ConfigOptions {
o.HTTP.IgnoreBody = c.IgnoreBody
o.HTTP.Method = c.Method
o.HTTP.ProxyURL = c.ProxyURL
o.HTTP.Raw = c.Raw
o.HTTP.Recursion = c.Recursion
o.HTTP.RecursionDepth = c.RecursionDepth
o.HTTP.RecursionStrategy = c.RecursionStrategy
Expand Down
3 changes: 3 additions & 0 deletions pkg/ffuf/optionsparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type HTTPOptions struct {
IgnoreBody bool `json:"ignore_body"`
Method string `json:"method"`
ProxyURL string `json:"proxy_url"`
Raw bool `json:"raw"`
Recursion bool `json:"recursion"`
RecursionDepth int `json:"recursion_depth"`
RecursionStrategy string `json:"recursion_strategy"`
Expand Down Expand Up @@ -148,6 +149,7 @@ func NewConfigOptions() *ConfigOptions {
c.HTTP.IgnoreBody = false
c.HTTP.Method = ""
c.HTTP.ProxyURL = ""
c.HTTP.Raw = false
c.HTTP.Recursion = false
c.HTTP.RecursionDepth = 0
c.HTTP.RecursionStrategy = "default"
Expand Down Expand Up @@ -514,6 +516,7 @@ func ConfigFromOptions(parseOpts *ConfigOptions, ctx context.Context, cancel con
conf.StopOnAll = parseOpts.General.StopOnAll
conf.StopOnErrors = parseOpts.General.StopOnErrors
conf.FollowRedirects = parseOpts.HTTP.FollowRedirects
conf.Raw = parseOpts.HTTP.Raw
conf.Recursion = parseOpts.HTTP.Recursion
conf.RecursionDepth = parseOpts.HTTP.RecursionDepth
conf.RecursionStrategy = parseOpts.HTTP.RecursionStrategy
Expand Down
6 changes: 6 additions & 0 deletions pkg/runner/simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,19 @@ func (r *SimpleRunner) Execute(req *ffuf.Request) (ffuf.Response, error) {

req.Host = httpreq.Host
httpreq = httpreq.WithContext(httptrace.WithClientTrace(r.config.Context, trace))

if r.config.Raw {
httpreq.URL.Opaque = req.Url
}

for k, v := range req.Headers {
httpreq.Header.Set(k, v)
}

if len(r.config.OutputDirectory) > 0 {
rawreq, _ = httputil.DumpRequestOut(httpreq, true)
}

httpresp, err := r.client.Do(httpreq)
if err != nil {
return ffuf.Response{}, err
Expand Down

0 comments on commit 02e6a73

Please sign in to comment.