An increasing number of malware families employ SSL/TLS encryption in order to evade detection by
Network Intrusion Detection Systems (NIDS).
In this blog post I’m gonna have a look at Adwind, which is a cross-platform Remote Access Trojan (RAT)
that has been using SSL to conceal it’s traffic for several years. AdwindRAT typically connects SSL sessions
to seemingly random TCP ports on the C2 servers.
Hence, a heuristic that could potentially be used to hunt for Adwind RAT malware is to look for SSL traffic
going to TCP ports that normally don’t use SSL.
However, relying on ONLY that heuristic would generate way too many false positives.
I saw the same certificate information used last week, and it continues this week.
- commonName = assylias
- organizationName = assylias.Inc
- countryName = FR
Currently, this may be the best way to identify Adwind-based post-infection traffic. Look for SSL traffic on a non-standard TCP port using that particular certificate.
Unfortunately, Adwind RAT has evolved to use other CN’s in their new certificates,
so looking for “assylias.Inc” will not cut it anymore.
However, looking for SSL traffic on non-standard TCP ports still holds on the latest Adwind RAT samples that we’ve analyzed.
“We offer one of the ways to detect malicious AdwindRAT software inside
the encrypted traffic. Recently, the detection of this malicious program in
network traffic is significantly reduced due to encryption. As a result of
the research, a stable structure of data fragments was created.”
Not only is it awesome that they were able to detect static patterns in the encrypted data,
they also provided 25 PCAP files containing AdwindRAT traffic.
I loaded these PCAP files into NetworkMiner Professional in order to have a look at the X.509 certificates.
NetworkMiner Professional supports Port-Independent Protocol Identification (PIPI),
which means that it will automatically identify the C2 sessions as SSL, regardless of which port that is used.
It will also automatically extract the X.509 certificates
along with any other parameters that can be extracted from the SSL handshake before the session goes encrypted.
Image: Files extracted from ADT’s PCAP files that mach “Oracle” and “cer”.
In this recent campaign the attackers used X.509 certificates claiming to be from Oracle.
The majory of the extracted certificates were exactly 1237 bytes long, so maybe they’re all identical?
This is what the first extracted X.509 certificate looks like:
The cert claims to be valid for a whopping 100 years!
Self-signed, not trusted.
However, after opening a few of the other certificates it’s clear that each C2 server is using a unique X.509 certificate.
This can be quickly confirmed by opening the parameters tab in NetworkMiner Pro and showing only the Certificate Hash
or Subject Key Identifier values.
Image: Certificate Hash values found in Adwind RAT’s SSL traffic
I also noted that the CN of the certificates isn’t constant either;
these samples use CN’s such as “Oracle America”, “Oracle Tanzania”, “Oracle Arusha Inc.”, “Oracle Leonardo” and “Oracle Heaven”.
The CN field is normally used to specify which domain(s) the certificate is valid for,
together with any additinoal Subject Alternative Name field.
However, Adwind RAT’s certificates don’t contain any domain name in the CN field and they don’t have an Alternative Name record.
This might very well change in future versions of this piece of malware though,
but I don’t expect the malware authors to generate a certificate with a CN matching the domain name used by each C2 server.
I can therefore use this assumption in order to better hunt for Adwind RAT traffic.
But how do I know what public domain name the C2 server has? One solution is to use passive DNS, i.e. to
capture all DNS traffic in order to do passive lookups locally.
Another solution is to leverage the fact that the Adwind RAT clients use the Server Name Indication (SNI)
when connecting to the C2 servers.
Image: TLS Server Name (aka SNI) and Subject CN values don’t match for AdwindRAT
Image: TLS Server Name (SNI) with matching Subject CN from Google.
My conclusion is therefore that Brad’s recommendations from 2015 are still pretty okay,
even for the latest wave of Adwind RAT traffic.
However, instead of looking for a fix CN string I’d prefer to use the following heuristics to hunt for this type of C2 traffic:
- SSL traffic to non-standard SSL port
- Self signed X.509 certificate
- The SNI domain name in the Client Hello message does not match the CN or Subject Alternative Name of the certificate.
These heuristics will match more than just Adwind RAT traffic though.
You’ll find that the exact same heuristics will also help identify other pieces of SSL-enabled malware
as well as Tor traffic.
This is a Security Bloggers Network syndicated blog post authored by Erik Hjelmvik. Read the original post at: NETRESEC Network Security Blog