aboutsummaryrefslogtreecommitdiff
path: root/parsers
diff options
context:
space:
mode:
authorEmiliano Ciavatta2020-10-16 12:16:44 +0000
committerEmiliano Ciavatta2020-10-16 12:16:44 +0000
commitd4bac2d6741f7a291522c29c9ecc87c3e32e21d4 (patch)
treefd48e9b0fa10f0a0c72adcc8f0f9709a5af206ee /parsers
parent2fb8993008752063fa13f253784e9e92552e339d (diff)
Add notification when pcap have been processed
Diffstat (limited to 'parsers')
-rw-r--r--parsers/http_request_parser.go12
1 files changed, 4 insertions, 8 deletions
diff --git a/parsers/http_request_parser.go b/parsers/http_request_parser.go
index bc98f8f..56093c9 100644
--- a/parsers/http_request_parser.go
+++ b/parsers/http_request_parser.go
@@ -82,7 +82,7 @@ func (p HttpRequestParser) TryParse(content []byte) Metadata {
Trailer: JoinArrayMap(request.Trailer),
Reproducers: HttpRequestMetadataReproducers{
CurlCommand: curlCommand(content),
- RequestsCode: requestsCode(request),
+ RequestsCode: requestsCode(request, body),
FetchRequest: fetchRequest(request, body),
},
}
@@ -99,19 +99,15 @@ func curlCommand(content []byte) string {
}
}
-func requestsCode(request *http.Request) string {
+func requestsCode(request *http.Request, body string) string {
var b strings.Builder
- var params string
- if request.Form != nil {
- params = toJson(JoinArrayMap(request.PostForm))
- }
headers := toJson(JoinArrayMap(request.Header))
cookies := toJson(CookiesMap(request.Cookies()))
b.WriteString("import requests\n\nresponse = requests." + strings.ToLower(request.Method) + "(")
b.WriteString("\"" + request.URL.String() + "\"")
- if params != "" {
- b.WriteString(", data = " + params)
+ if body != "" {
+ b.WriteString(", data = \"" + strings.Replace(body, "\"", "\\\"", -1) + "\"")
}
if headers != "" {
b.WriteString(", headers = " + headers)