Fix HTTP method & data bug when parsing raw request from file (#339)

This commit is contained in:
Joona Hoikkala 2020-10-25 15:47:52 +02:00 committed by GitHub
parent 602c1c79e8
commit 5b00f2b4e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -117,7 +117,7 @@ func NewConfigOptions() *ConfigOptions {
c.HTTP.Data = "" c.HTTP.Data = ""
c.HTTP.FollowRedirects = false c.HTTP.FollowRedirects = false
c.HTTP.IgnoreBody = false c.HTTP.IgnoreBody = false
c.HTTP.Method = "GET" c.HTTP.Method = ""
c.HTTP.ProxyURL = "" c.HTTP.ProxyURL = ""
c.HTTP.Recursion = false c.HTTP.Recursion = false
c.HTTP.RecursionDepth = 0 c.HTTP.RecursionDepth = 0
@ -341,14 +341,33 @@ func ConfigFromOptions(parseOpts *ConfigOptions, ctx context.Context, cancel con
conf.Rate = int64(parseOpts.General.Rate) conf.Rate = int64(parseOpts.General.Rate)
} }
if conf.Method == "" {
if parseOpts.HTTP.Method == "" {
// Only set if defined on command line, because we might be reparsing the CLI after
// populating it through raw request in the first iteration
conf.Method = "GET"
} else {
conf.Method = parseOpts.HTTP.Method
}
} else {
if parseOpts.HTTP.Method != "" {
// Method overridden in CLI
conf.Method = parseOpts.HTTP.Method
}
}
if parseOpts.HTTP.Data != "" {
// Only set if defined on command line, because we might be reparsing the CLI after
// populating it through raw request in the first iteration
conf.Data = parseOpts.HTTP.Data
}
// Common stuff // Common stuff
conf.IgnoreWordlistComments = parseOpts.Input.IgnoreWordlistComments conf.IgnoreWordlistComments = parseOpts.Input.IgnoreWordlistComments
conf.DirSearchCompat = parseOpts.Input.DirSearchCompat conf.DirSearchCompat = parseOpts.Input.DirSearchCompat
conf.Data = parseOpts.HTTP.Data
conf.Colors = parseOpts.General.Colors conf.Colors = parseOpts.General.Colors
conf.InputNum = parseOpts.Input.InputNum conf.InputNum = parseOpts.Input.InputNum
conf.InputMode = parseOpts.Input.InputMode conf.InputMode = parseOpts.Input.InputMode
conf.Method = parseOpts.HTTP.Method
conf.OutputFile = parseOpts.Output.OutputFile conf.OutputFile = parseOpts.Output.OutputFile
conf.OutputDirectory = parseOpts.Output.OutputDirectory conf.OutputDirectory = parseOpts.Output.OutputDirectory
conf.IgnoreBody = parseOpts.HTTP.IgnoreBody conf.IgnoreBody = parseOpts.HTTP.IgnoreBody