mirror of
https://github.com/ffuf/ffuf
synced 2025-02-27 12:27:16 +00:00
Fix bug in regex matching when writing responses to file (#150)
* Fix bug in regex matching when writing responses to file * Add changelog entry
This commit is contained in:
parent
875ee38f59
commit
6868aff865
2 changed files with 9 additions and 10 deletions
|
@ -3,6 +3,7 @@
|
|||
- master
|
||||
- New
|
||||
- Changed
|
||||
- Fixed a bug where regex matchers and filters would fail if `-od` was used to store the request & response contents.
|
||||
|
||||
- v1.0
|
||||
- New
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/http/httputil"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
@ -86,7 +87,6 @@ func (r *SimpleRunner) Prepare(input map[string][]byte) (ffuf.Request, error) {
|
|||
func (r *SimpleRunner) Execute(req *ffuf.Request) (ffuf.Response, error) {
|
||||
var httpreq *http.Request
|
||||
var err error
|
||||
var rawreq, rawresp strings.Builder
|
||||
data := bytes.NewReader(req.Data)
|
||||
httpreq, err = http.NewRequest(req.Method, req.Url, data)
|
||||
if err != nil {
|
||||
|
@ -112,15 +112,6 @@ func (r *SimpleRunner) Execute(req *ffuf.Request) (ffuf.Response, error) {
|
|||
resp := ffuf.NewResponse(httpresp, req)
|
||||
defer httpresp.Body.Close()
|
||||
|
||||
if len(r.config.OutputDirectory) > 0 {
|
||||
// store raw request
|
||||
httpreq.Write(&rawreq)
|
||||
resp.Request.Raw = rawreq.String()
|
||||
// store raw response
|
||||
httpresp.Write(&rawresp)
|
||||
resp.Raw = rawresp.String()
|
||||
}
|
||||
|
||||
// Check if we should download the resource or not
|
||||
size, err := strconv.Atoi(httpresp.Header.Get("Content-Length"))
|
||||
if err == nil {
|
||||
|
@ -131,6 +122,13 @@ func (r *SimpleRunner) Execute(req *ffuf.Request) (ffuf.Response, error) {
|
|||
}
|
||||
}
|
||||
|
||||
if len(r.config.OutputDirectory) > 0 {
|
||||
rawreq, _ := httputil.DumpRequestOut(httpreq, true)
|
||||
rawresp, _ := httputil.DumpResponse(httpresp, true)
|
||||
resp.Request.Raw = string(rawreq)
|
||||
resp.Raw = string(rawresp)
|
||||
}
|
||||
|
||||
if respbody, err := ioutil.ReadAll(httpresp.Body); err == nil {
|
||||
resp.ContentLength = int64(utf8.RuneCountInString(string(respbody)))
|
||||
resp.Data = respbody
|
||||
|
|
Loading…
Add table
Reference in a new issue