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
@ -3,6 +3,7 @@
|
|||||||
- master
|
- master
|
||||||
- New
|
- New
|
||||||
- Changed
|
- Changed
|
||||||
|
- Fixed a bug where regex matchers and filters would fail if `-od` was used to store the request & response contents.
|
||||||
|
|
||||||
- v1.0
|
- v1.0
|
||||||
- New
|
- New
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/http/httputil"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"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) {
|
func (r *SimpleRunner) Execute(req *ffuf.Request) (ffuf.Response, error) {
|
||||||
var httpreq *http.Request
|
var httpreq *http.Request
|
||||||
var err error
|
var err error
|
||||||
var rawreq, rawresp strings.Builder
|
|
||||||
data := bytes.NewReader(req.Data)
|
data := bytes.NewReader(req.Data)
|
||||||
httpreq, err = http.NewRequest(req.Method, req.Url, data)
|
httpreq, err = http.NewRequest(req.Method, req.Url, data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -112,15 +112,6 @@ func (r *SimpleRunner) Execute(req *ffuf.Request) (ffuf.Response, error) {
|
|||||||
resp := ffuf.NewResponse(httpresp, req)
|
resp := ffuf.NewResponse(httpresp, req)
|
||||||
defer httpresp.Body.Close()
|
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
|
// Check if we should download the resource or not
|
||||||
size, err := strconv.Atoi(httpresp.Header.Get("Content-Length"))
|
size, err := strconv.Atoi(httpresp.Header.Get("Content-Length"))
|
||||||
if err == nil {
|
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 {
|
if respbody, err := ioutil.ReadAll(httpresp.Body); err == nil {
|
||||||
resp.ContentLength = int64(utf8.RuneCountInString(string(respbody)))
|
resp.ContentLength = int64(utf8.RuneCountInString(string(respbody)))
|
||||||
resp.Data = respbody
|
resp.Data = respbody
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user