Skip to content
This repository has been archived by the owner on Apr 26, 2021. It is now read-only.

Correctly parsing URIs #3199

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions cuckoo/processing/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,11 +490,16 @@ def _add_http(self, tcpdata, dport):
netloc += ":" + str(entry["port"])

entry["data"] = convert_to_printable(tcpdata)
url = urlparse.urlunparse(("http", netloc, http.uri,
path = http.uri
if netloc and netloc in http.uri:
path = http.uri.split(netloc)[1]
elif entry["host"] and entry["host"] in http.uri:
path = http.uri.split(entry["host"])[1]
url = urlparse.urlunparse(("http", netloc, path,
None, None, None))
entry["uri"] = convert_to_printable(url)
entry["body"] = convert_to_printable(http.body)
entry["path"] = convert_to_printable(http.uri)
entry["path"] = convert_to_printable(path)

if "user-agent" in http.headers:
entry["user-agent"] = \
Expand Down Expand Up @@ -809,13 +814,17 @@ def run(self):
resp_path = os.path.join(self.network_path, resp_sha1)
open(resp_path, "wb").write(recv.body or "")

path = sent.uri
host = sent.headers.get("host", dstip)
if host in path:
path = path.split(host)[1]
results["%s_ex" % protocol].append({
"src": srcip, "sport": srcport,
"dst": dstip, "dport": dstport,
"protocol": protocol,
"method": sent.method,
"host": sent.headers.get("host", dstip),
"uri": sent.uri,
"host": host,
"uri": path,
"status": int(getattr(recv, "status", 0)),

# We'll keep these fields here for now.
Expand Down