Skip to content

Commit 41a02cc

Browse files
committed
Fix URLs containing the hostname in the path.
When the path of a URL contained the hostname, the full URL would not be reconstructed properly. For example: http://example.org/sites/example.org/test
1 parent dac7a1a commit 41a02cc

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

pcap2curl.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ def payload2curl(p):
2020
host_header = re.search("^Host: (.*)", line)
2121
host_name = host_header.group(1)
2222

23-
if host_name not in url:
24-
url = "http://{}/{}".format(host_name, url)
25-
curl = "curl '{}' \\\n -X {} \\\n".format(url, method)
26-
curl += " \\\n".join(headers)
23+
proto_host = 'http://{}/'.format(host_name)
24+
if not url.startswith(proto_host):
25+
url = "{}{}".format(proto_host, url[1:] if url[0] == "/" else url)
26+
curl = "curl '{}' \\\n -X {} \\\n ".format(url, method)
27+
curl += " \\\n ".join(headers)
2728
return curl
2829

2930

0 commit comments

Comments
 (0)