* Takes the User-Agent header from a list. * typo * base * Make defining User-agent header case insensitive #171 * -whitespaces * Make canonical http headers and set default User-Agent only once. * clean-up * formatting, canonical customer headers, docs updated * cleanup * fmt * Checking userdefined headers for excluding in canonicalization. * resolving one conflict * moved logic back and less resolve conflicts Co-authored-by: Joona Hoikkala <joohoi@users.noreply.github.com>
This commit is contained in:
parent
b58c30625e
commit
5f0d0faeb7
@ -4,7 +4,8 @@
|
|||||||
- New
|
- New
|
||||||
|
|
||||||
- Changed
|
- Changed
|
||||||
- Write POST request data properly to file when ran with `-od`
|
- Write POST request data properly to file when ran with `-od`.
|
||||||
|
- Fixed a bug by using header canonicaliztion related to HTTP headers being case insensitive.
|
||||||
- Properly handle relative redirect urls with `-recursion`
|
- Properly handle relative redirect urls with `-recursion`
|
||||||
- Calculate req/sec correctly for when using recursion
|
- Calculate req/sec correctly for when using recursion
|
||||||
- When `-request` is used, allow the user to override URL using `-u`
|
- When `-request` is used, allow the user to override URL using `-u`
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
# Contributors
|
# Contributors
|
||||||
|
|
||||||
|
* [bjhulst](https://github.com/bjhulst)
|
||||||
* [ccsplit](https://github.com/ccsplit)
|
* [ccsplit](https://github.com/ccsplit)
|
||||||
* [codingo](https://github.com/codingo)
|
* [codingo](https://github.com/codingo)
|
||||||
* [delic](https://github.com/delic)
|
* [delic](https://github.com/delic)
|
||||||
|
|||||||
25
main.go
25
main.go
@ -7,6 +7,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
|
"net/textproto"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -341,15 +342,37 @@ func prepareConfig(parseOpts *cliOptions, conf *ffuf.Config) error {
|
|||||||
conf.Url = parseOpts.URL
|
conf.Url = parseOpts.URL
|
||||||
}
|
}
|
||||||
|
|
||||||
//Prepare headers
|
//Prepare headers and make canonical
|
||||||
for _, v := range parseOpts.headers {
|
for _, v := range parseOpts.headers {
|
||||||
hs := strings.SplitN(v, ":", 2)
|
hs := strings.SplitN(v, ":", 2)
|
||||||
if len(hs) == 2 {
|
if len(hs) == 2 {
|
||||||
|
// trim and make canonical
|
||||||
|
// except if used in custom defined header
|
||||||
|
var CanonicalNeeded bool = true
|
||||||
|
for _, a := range conf.CommandKeywords {
|
||||||
|
if a == hs[0] {
|
||||||
|
CanonicalNeeded = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// check if part of InputProviders
|
||||||
|
if CanonicalNeeded {
|
||||||
|
for _, b := range conf.InputProviders {
|
||||||
|
if b.Keyword == hs[0] {
|
||||||
|
CanonicalNeeded = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if CanonicalNeeded {
|
||||||
|
var CanonicalHeader string = textproto.CanonicalMIMEHeaderKey(strings.TrimSpace(hs[0]))
|
||||||
|
conf.Headers[CanonicalHeader] = strings.TrimSpace(hs[1])
|
||||||
|
} else {
|
||||||
conf.Headers[strings.TrimSpace(hs[0])] = strings.TrimSpace(hs[1])
|
conf.Headers[strings.TrimSpace(hs[0])] = strings.TrimSpace(hs[1])
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
errs.Add(fmt.Errorf("Header defined by -H needs to have a value. \":\" should be used as a separator"))
|
errs.Add(fmt.Errorf("Header defined by -H needs to have a value. \":\" should be used as a separator"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Prepare delay
|
//Prepare delay
|
||||||
d := strings.Split(parseOpts.delay, "-")
|
d := strings.Split(parseOpts.delay, "-")
|
||||||
if len(d) > 2 {
|
if len(d) > 2 {
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httputil"
|
"net/http/httputil"
|
||||||
|
"net/textproto"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -73,7 +74,8 @@ func (r *SimpleRunner) Prepare(input map[string][]byte) (ffuf.Request, error) {
|
|||||||
req.Method = strings.Replace(req.Method, keyword, string(inputitem), -1)
|
req.Method = strings.Replace(req.Method, keyword, string(inputitem), -1)
|
||||||
headers := make(map[string]string, 0)
|
headers := make(map[string]string, 0)
|
||||||
for h, v := range req.Headers {
|
for h, v := range req.Headers {
|
||||||
headers[strings.Replace(h, keyword, string(inputitem), -1)] = strings.Replace(v, keyword, string(inputitem), -1)
|
var CanonicalHeader string = textproto.CanonicalMIMEHeaderKey(strings.Replace(h, keyword, string(inputitem), -1))
|
||||||
|
headers[CanonicalHeader] = strings.Replace(v, keyword, string(inputitem), -1)
|
||||||
}
|
}
|
||||||
req.Headers = headers
|
req.Headers = headers
|
||||||
req.Url = strings.Replace(req.Url, keyword, string(inputitem), -1)
|
req.Url = strings.Replace(req.Url, keyword, string(inputitem), -1)
|
||||||
@ -93,10 +95,12 @@ func (r *SimpleRunner) Execute(req *ffuf.Request) (ffuf.Response, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return ffuf.Response{}, err
|
return ffuf.Response{}, err
|
||||||
}
|
}
|
||||||
// Add user agent string if not defined
|
|
||||||
|
// set default User-Agent header if not present
|
||||||
if _, ok := req.Headers["User-Agent"]; !ok {
|
if _, ok := req.Headers["User-Agent"]; !ok {
|
||||||
req.Headers["User-Agent"] = fmt.Sprintf("%s v%s", "Fuzz Faster U Fool", ffuf.VERSION)
|
req.Headers["User-Agent"] = fmt.Sprintf("%s v%s", "Fuzz Faster U Fool", ffuf.VERSION)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle Go http.Request special cases
|
// Handle Go http.Request special cases
|
||||||
if _, ok := req.Headers["Host"]; ok {
|
if _, ok := req.Headers["Host"]; ok {
|
||||||
httpreq.Host = req.Headers["Host"]
|
httpreq.Host = req.Headers["Host"]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user