In this video I analyze network traffic from a QakBot (QBot) infection in order to identify the Command-and-Control (C2) traffic.
The analyzed PCAP file is from malware-traffic-analysis.net.
Note: This video was recorded in a Windows Sandbox to minimize the risk of infecting the host PC in case of accidental execution of a malicious payload from the network traffic.
As I have previously pointed out, IcedID sends beacons to the C2 server with a 5 minute interval. According to Kai Lu’s blog post A Deep Dive Into IcedID Malware: Part 2, this 5 minute interval is caused by a call to WaitForSingleObject with a millisecond timeout parameter of 0x493e0 (300,000), which is exactly 5 minutes.
UPDATE 2023-03-22
In the research paper
Thawing the permafrost of ICEDID
Elastic Security Labs confirm that IcedID's default polling interval is 5 minutes. They also mention that this interval is configurable:
Once initialized, ICEDID starts its C2 polling thread for retrieving new commands to execute
from one of its C2 domains.
The polling loop checks for a new command every N seconds as defined by the
g_c2_polling_interval_seconds global variable. By default this interval is 5 minutes, but one of
the C2 commands can modify this variable.
The IcedID trojan uses a custom BackConnect protocol in order to interact with victim computers through VNC, a file manager or by establishing a reverse shell.
There was no IcedID BackConnect traffic in this particular PCAP file though, but
severalother IcedID capture files published on malware-traffic-analysis.net do contain IcedID BackConnect traffic.
For more information on this proprietary protocol, please see our blog post IcedID BackConnect Protocol.
Check out our upcoming live network forensics classes for more hands-on network forensic analysis. Our current class material doesn’t include any IcedID traffic though, instead you’ll get to investigate C2 traffic from Cobalt Strike, TrickBot, njRAT, Meterpreter and a few others.
Posted by Erik Hjelmvik on Wednesday, 15 February 2023 10:52:00 (UTC/GMT)
The most important addition in the 1.9.5 release is the new Alerts tab, in which CapLoader warns about malicious network traffic such as command-and-control protocols. The alerts tab also shows information about network anomalies that often are related to malicious traffic, such as periodic connections to a particular service or long running sessions.
Other additions in this new version are:
BPF support for “vlan” keyword, for example “vlan”, “not vlan” or “vlan 121”
Support for nanosecond PCAP files (magic 0xa1b23c4d)
Support for FRITZ!Box PCAP files (magic 0xa1b2cd34)
Decapsulation of CAPWAP protocol, so that flows inside CAPWAP can be viewed and filtered on
Domain names extracted from TLS SNI extensions
Alerts for Malicious Network Traffic
As you can see in the video at the end of this blog post, the Alert tab is a fantastic addition for everyone who wants to detect malicious activity in network traffic. Not only can it alert on over 30 different malicious command-and-control (C2) protocols — including
Cerber,
Gozi ISFB,
IcedID, RedLine Stealer,
njRAT and QakBot — it also alerts on generic behavior that is typically seen in malware traffic.
Examples of such generic behavior are periodic connections to a C2 server or long running TCP connections. This type of behavioral analysis can be used to detect C2 and backdoor traffic even when the protocol is unknown. There are also signatures that detect “normal” protocols, such as HTTP, TLS or SSH running on non-standard ports as well as the reverse, where a standard port like TCP 443 is carrying a protocol that isn’t TLS.
Many of CapLoader’s alert signatures are modeled after threat hunting techniques, which can be used to detect malicious activities that traditional alerting mechanisms like antivirus, EDR’s and IDS’s might have missed. By converting the logic involved in such threat hunting tasks into signatures a great deal of the analysts’ time can be saved. In this sense part of CapLoader’s alerting mechanism is a form of automated threat hunting, which saves several steps in the process of finding malicious network traffic in a packet haystack.
Watch my Hunting for C2 Traffic video for a demonstration on the steps required to perform manual network based threat hunting without CapLoader's alerts tab. In that video I identify TLS traffic to a non-TLS port (TCP 2222) as well as non-TLS traffic to TCP port 443. As of version 1.9.5 CapLoader automatically generates alerts for that type of traffic. More specifically, the alert types will be Protocol-port mismatch (TLS on TCP 2222) and Port-protocol mismatch (non-TLS on TCP 443).
Below is a screenshot of CapLoader’s new Alerts tab after having loaded the capture files analyzed in the Hunting for C2 Traffic video.
Image: Alerts for malicious traffic in CapLoader 1.9.5.
Video Demonstration of CapLoader's Alerts Tab
The best way to explain the power of CapLoader’s Alerts tab is probably by showing it in action. I have therefore recorded the following video demonstration.
This capture file is a small snippet of the network traffic analyzed in one of my old network forensics classes. It contains malicious traffic from njRAT and Kovter mixed with a great deal of legitimate web traffic.
Posted by Erik Hjelmvik on Thursday, 09 February 2023 14:30:00 (UTC/GMT)
In this video I look for C2 traffic by doing something I call Rinse-Repeat Threat Hunting,
which is a method for removing "normal" traffic in order to look closer at what isn't normal.
The video was recorded in a Windows Sandbox in order to avoid accidentally infecting my Windows PC with malware.
This video covers a life cycle of an Emotet infection, including initial infection, command-and-control traffic,
and spambot activity sending emails with malicious spreadsheet attachments to infect new victims.
The video was recorded in a Windows Sandbox in order to avoid accidentally infecting my Windows PC with malware.
Initial Infection
Palo Alto's Unit 42 sent out a
tweet with screenshots and IOCs from an Emotet infection in early March.
A follow-up tweet by Brad Duncan linked to a PCAP file containing
network traffic from the infection on Malware-Traffic-Analysis.net.
Image: Screenshot of original infection email from Unit 42
Attachment MD5: 825e8ea8a9936eb9459344b941df741a
Emotet Download
The PCAP from Malware-Traffic-Analysis.net shows that the Excel spreadsheet attachment caused the download of a DLL file
classified as Emotet.
The victim PC eventually started sending out spam emails.
The spam bot used TLS encryption when possible, either through SMTPS (implicit TLS) or with help of STARTTLS (explicit TLS).
Below is a spam email sent from the victim PC without TLS encryption.
The attached zip file contains a malicious Excel spreadsheet,
which is designed to infect new victims with Emotet.
Image: Spam email extracted from Emotet PCAP with NetworkMiner
My lightning talk from the SEC-T 0x0D conference has now been
published on YouTube.
This 13 minute talk covers tactics and techniques that the SolarWinds hackers used
in order to avoid being detected.
Some of these tactics included using DNS based command-and-control (C2) that mimicked Amazon AWS DNS traffic, blending in with SolarWind’s legitimate source code and handpicking only a small number of targets.
One thing I forgot to mention in my SEC-T talk though, was the speed at which the attackers were working to analyze incoming data from the trojanized installs and selecting organizations to
target for stage two operations.
For example, just during June 2020 the attackers got more than 1300 new organizations that started beaconing in using the DNS-based C2.
The beaconed data only included the organizations’ Active Directory domain name and a list of
installed security applications.
Based on this information the attackers had to decide whether or not they wanted to target the organization.
We have previously estimated that less than 1% of the organizations were targeted, while the malicious backdoor was disabled for all the other 99% who had installed the trojanized SolarWinds Orion update.
The attackers typically decided whether or not to target an organization within one week from when they started beaconing.
This means that the attackers probably had several hundred organizations in queue for a targeting decision on any given week between April and August 2020.
That's a significant workload!
Posted by Erik Hjelmvik on Monday, 18 October 2021 10:30:00 (UTC/GMT)
In this video I demonstrate that text typed into the Windows 10 start menu gets sent to Microsoft and how
that traffic can be intercepted, decrypted and parsed.
What Was Sent?
The XML files shown in the video were sent by Cortana's "SmartSearch" app to https://www.bing.com/threshold/xls.aspx in HTTP/2 POST requests.
As shown in the video, the POST'ed keystrokes can be found inside requestInfo XML tags that have a "RawQuery" key.
The following tcpdump and grep commands can be used to list the RawQuery data sent to Bing in these HTTP/2 requests:
tcpdump -A -r proxy-210927-134557.pcap | grep -a -o 'key="RawQuery" value="[^"]*"'
Running that command on the PolarProxy PCAP file from the video gives the following output:
The same data also gets sent in the query string variable "qry" of GET requests for
https://www.bing.com/AS/API/WindowsCortanaPane/V2/Suggestions, as shown in this NetworkMiner screenshot.
Image: NetworkMiner's Parameters tab with filter "qry" on "Parameter name" column
How to Intercept, Decrypt and Decode HTTPS Traffic
The following section presents the technical details regarding my setup,
so that others can reproduce and verify these findings.
My first step was to install PolarProxy on a Linux machine on the local network.
PolarProxy is a TLS proxy, which can intercept and decrypt TLS traffic.
This TLS proxy is primarily designed to decrypt traffic from malware and hackers,
but can also be used to decrypt legitimate traffic when needed.
PolarProxy was configured to listen for incoming TLS connections on TCP port 443
and output PCAP data with the decrypted traffic as if it had been transmitted over TCP 80.
The decrypted traffic was accessible as a real-time stream through a
PCAP-over-IP service running on port 57012.
Here's the full command that was used to start PolarProxy:
In the video I showed the Windows 10 client's modified hosts file, which included an entry for www.bing.com pointing to the PolarProxy machine.
What was not shown in the video though, is that PolarProxy's own CA certificate had been added to the Win10 machine's list of trusted root CA's,
as explained in the "Trusting the PolarProxy root CA" section of the PolarProxy installation instructions.
With these two changes in place all HTTPS requests for www.bing.com from the Win10 PC got diverted through the PolarProxy TLS inspection service,
which then decrypted and re-encrypted the traffic before forwarding it to Bing.
The decrypted Bing requests could be accessed either locally on the Linux machine,
or remotely using the PCAP-over-IP service on TCP port 57012.
I used NetworkMiner to read the live PCAP stream with decrypted traffic from port 57012 and extract all files being sent and received in real-time.
As part of delivering Windows 10 as a service, updates may be delivered to provide ongoing new features to Bing search, such as new visual layouts, styles and search code.
No query or search usage data is sent to Microsoft, in accordance with the customer's chosen privacy settings.
There are plenty of how-to guides online with instructions on how the Cortana search feature can be disabled.
Most of these guides suggest disabling the AllowCortana setting in group policies or in the registry.
We've tried several of the settings suggested in these how-to guides, but none of them seem to prevent Windows from sending keystrokes to Bing.
If you know how to successfully disable Cortana's Bing searches,
then please feel free to reach out to us so that we can update this blog post.
UPDATE 210928 - How to Actually Disable Cortana Search
Twitter user @GeorgeProfonde3 reached out
to suggest a fix that might prevent the start menu from sending data to Bing.
We have now verified this fix and we're happy to announce that it works (at least for us).
Start regedit.exe
Open the following registry key: HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Search
Ensure that the value for CortanaConsent is set to 0
Create a new DWORD registry entry called "BingSearchEnabled" with value 0
You should no longer see any connections to www.bing.com when interacting with the start menu after implementing this fix.
UPDATE 211015 - Another way to Disable Cortana Search
You may need to use a different method to disable the start meny search, depending on your Windows version and build.
Kimberly (@StopMalvertisin) suggested the following method, which seems to work on Windows 11:
Start regedit.exe
Create a registry key for: HKEY_CURRENT_USER\SOFTWARE\Policies\Microsoft\Windows\Explorer
Create a new DWORD registry entry called "DisableSearchBoxSuggestions" with value 1
Disabling Start Menu Search from Group Policy
There are also a few different methods for disabling start menu searches using GPO.
However, please note that your success will vary depending on your Windows version and build.
GPO Method #1
Start gpedit.msc
Open the following branch: User configuration\Administrative templates\Windows components\File Explorer
Enable the following group policy:
"Turn off display of recent search entries in the File Explorer search box"
GPO Method #2
Start gpedit.msc
Open the following branch: User Configuration\Administrative Templates\Start Menu and Taskbar
Enable the following group policy:
"Do not search communications"
Posted by Erik Hjelmvik on Tuesday, 28 September 2021 08:24:00 (UTC/GMT)
I recently came across a fantastic digital forensics dataset at dfirmadness.com,
which was created by James Smith.
There is a case called The Stolen Szechuan Sauce
on this website that includes forensic artifacts like disk images, memory dumps and a PCAP file (well, pcap-ng actually).
In this video I demonstrate how I analyzed the capture file case001.pcap from this case.
Follow Along in the Analysis
Please feel free to follow along in the analysis performed in the video.
You should be able to use the free trial version of CapLoader
and the free open source version of NetworkMiner
to perform most of the tasks I did in the video.
Here are some of the BPF and Column Criteria filters that I used in the video, so that you can copy/paste them into CapLoader.
net 10.0.0.0/8
Umbrella_Domain =
not ip6 and not net 224.0.0.0/4
host 194.61.24.102 or host 203.78.103.109 or port 3389