network: fix behavior-derived WinHTTP requests missing domain/port - #3263
Merged
Merged
Conversation
- winhttp_finalize_sessions: iterate connects instead of sessions so requests survive when WinHttpOpen was not captured; derive https from WINHTTP_FLAG_SECURE or port 443; handle INTERNET_DEFAULT_PORT (0); emit full url and dport. - _merge_behavior_network: put full URL in uri (network.http template renders only uri, matching PCAP entries), fix dport read from wrong key, emit all requests per host instead of only the first.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Behavior-derived WinHTTP requests showed only the path (e.g.
/eZJDZ5AC?Q=...) in the network HTTP table, without scheme/host, even thoughWinHttpConnecthadServerName/ServerPortlogged.Root causes
_merge_behavior_networkstored only the path inuri. Thenetwork.httptemplate renders onlyrequest.uri; PCAP-derived entries store the full URL there.dportwas read froms0.get("port"), but the event key isdport-> alwaysNone.sessions[0]per host was merged; remaining requests were dropped.winhttp_finalize_sessionsreached connects only viasessions[*].connections. IfWinHttpOpenwas not captured (hooked late / failed), the connect and all its requests were orphaned.port == 443; TLS on non-443 ports was labelled http.Changes
lib/cuckoo/common/network_utils.pyconnectsdirectly; session is looked up only for UA/proxy fields.httpsifWINHTTP_FLAG_SECURE(0x00800000) is set inWinHttpOpenRequestflags or port is 443.INTERNET_DEFAULT_PORT(0) resolved to 80/443; non-default port included in URL.urland a resolveddport.modules/processing/network.pyuri= full URL,path= object name,port/dportpopulated,user_agentadded.Tested in production by reprocessing an affected task: entry now renders as
https://<host>/<object>with thebehaviorbadge.