Operation Wocao: Shining A Light On One of China's Hidden Hacking Groups
Operation Wocao: Shining A Light On One of China's Hidden Hacking Groups
fox-it.com
Executive summary
Operation Wocao (我操, “Wǒ cāo”, used as “shit” or “damn”) is the name that
Fox-IT uses to describe the hacking activities of a Chinese based hacking group.
This report details the profile of a publicly underreported threat actor that Fox‑IT
has dealt with over the past two years. Fox-IT assesses with high confidence
that the actor is a Chinese group and that they are likely working to support the
interests of the Chinese government and are tasked with obtaining information
for espionage purposes. With medium confidence, Fox-IT assesses that the tools,
techniques and procedures are those of the actor referred to within the industry
as APT20. We have identified victims of this actor in 10 countries, in government
entities, managed service providers and across a wide variety of industries,
including Energy, Health Care and High-Tech.
Beyond the technical details, this report should serve to remind us all how focused and result-
oriented high-end threat actors work to achieve their goals, and that there are still threat actors
active that are almost completely unknown to the public. This actor profile reveals that:
• They carry out most of their activities through abusing legitimate access channels. VPN access
is an example of such a channel, and we have even seen this actor abuse 2FA soft tokens.
• For back-up purposes, they keep additional backdoors in place.
• They move through the network, directly singling out workstations of employees with privileged
access (administrators).
• On these systems, the contents of passwords vaults (password managers) are directly targeted
and retrieved.
• As much as is possible, they remove file system based forensic traces of their activities, making it
much harder for investigators to determine what happened after the fact.
• On the basis of the above, an attacker can efficiently achieve their goal of exfiltrating data,
sabotaging systems, maintaining access and jumping to additional targets.
• Overall the actor has been able to stay under the radar even though the tools and techniques
they use for their hacking operations are relatively simple and to the point.
Knowing how high end threat actors work should also remind us that we, the defenders, have to
continually revisit our defensive strategies:
• Zero Trust or Robust segmentation must be one of the guiding principles of any infrastructure,
both for systems and identities. As part of that, leveraging Microsoft’s Enhanced Security
Administrative Environment (ESAE) where applicable will greatly increase your resilience and can
prevent many attacks from succeeding.
• Timely detection of and adequate response to any serious incident depends on a combination of
high-level and low-level telemetry from network and endpoints.
1 Introduction 4
2 Modus operandi 5
2.1 Activity on an average ‘working day’ 6
3 Attribution 7
3.1 Language 7
3.2 Timezone 9
4 Victims 11
5 Custom tooling 12
5.1 File upload webshell 12
5.2 File upload and command execution webshell 12
5.3 Socket tunnel 13
5.4 Reconnaissance script 13
5.5 XServer 14
5.6 Agent 16
5.7 Directory list tool 17
5.8 Process launcher 18
5.9 CheckAdmin 18
5.10 OS scanner 20
5.11 Keylogger 21
In the context of incident response, we support our clients with crisis management, technical
investigations and remediation of the incident. Almost without exception, the most valuable
technical insights for live and historic forensic investigation are gained from the network and
endpoint data. In other words: network and endpoint visibility are crucial for timely detection and
quality response, the most deciding factor in what the impact of an incident will be.
With that in mind, the goal of publishing this report is twofold. The first is to help organizations
and wider cyber defense eco-system defend against the specific actor described in this report.
The second is to help readers understand the tools and techniques that threat actors can use to
compromise an enterprise infrastructure and steal information. This in turn helps them in their role
as incident responder, SOC or threat analyst or even as security officer.
Very little is publicly known or published about the actor that we describe, but rather than giving
this actor an alias of our own, we chose to reach out to industry partners. This collaboration across
the private sector helped us attribute some of the previously unpublished techniques and tools in
this report, with medium confidence, to a Chinese threat actor known within the industry as APT20.
Based on the observed victims of this actor we also assess that this threat actor is likely working in
the interest of the Chinese government.
This report provides the reader with an overview of the techniques known to us that are used by
the actor. It is described in the following five chapters:
• Modus operandi describes, without going into too much technical detail, the actor’s typical
way of working.
• Attribution describes where the actor is most likely operating from.
• Victims describes the countries and sectors in which the victims of this actor reside.
• Custom tooling describes a number of tools, and their functionality, that we believe are
exclusively used by this actor.
• MITRE ATT&CK maps the techniques that the actor uses to the MITRE ATT&CK Matrix1.
This report is accompanied by a parallel publication on GitHub where Snort and YARA signatures
can be found, as well as indicators of compromise.
1. https://attack.mitre.org/wiki/Windows_Technique_Matrix
Initial Access
In several cases the initial access point into a victim network was a vulnerable webserver, often
versions of JBoss. Such vulnerable servers were observed to often already be compromised with
webshells, placed there by other threat actors. The actor actually leverages these other webshells
for reconnaissance and initial lateral movement activity. After this initial reconnaissance the actor
uploads one of its own webshells to the webserver. Access as initially obtained to the compromised
webserver, for example through the uploaded webshell, is kept by the actor as a precaution in the
event of losing the other primary method of persistent access, for example if the credentials for VPN
accounts were to be reset.
Lateral Movement
Once an initial foothold is established, the actor moves laterally through the network using well-
known and well-documented methods, such as dumping credentials from memory and accessing
password managers on compromised systems.
The actor specifically targets systems and people based on their role and associated privilege levels
within the organization. This method enables the actor to persistently and quickly obtain access to
highly privileged accounts, such as enterprise and domain administrators. Once such privileges have
been obtained, the actor directly shifts their means of persistence. Instead of having to rely on their
persistent malicious backdoors as command and control channel – a channel that’s essentially not
supposed to be there and subject to discovery by the victim – the actor uses the stolen credentials to
connect to the victim’s network using the corporate VPN solution.
2FA abuse
In one case, for VPN persistence, the actor did show evidence of using novel techniques. In this
case VPN access to a victim’s network was protected by 2 factor authentication (2FA), which
normally protects an asset from simple credential theft. In this case, however, the actor abused this
implementation of 2FA control with a technique that, as far as Fox-IT could determine, was developed
by the actor themselves. This use of VPN access in combination with 2FA as method of persistence to
a victim’s network is explained in more detailed in paragraph 6.3.2.
Upon compromising a system, before deploying their custom backdoor, the actor sometimes utilizes
a custom reconnaissance script. This script collects, among other things, installed software, running
processes and open connections. Then after deploying the backdoor, the actor manually starts
Another way to look at the previously described modus operandi is through the lens of a typical
“working day”. In this example the actor already has access to a victim’s network and is in the process
of searching for, identifying and collecting information of interest to the actor. During this process an
actor, on a typical day, would:
1. Connect to the victim’s VPN concentrator using stolen credentials and possibly a 2FA token.
2. Move laterally by deploying the custom XServer² backdoor via PowerShell on multiple servers.
3. Identify targets of interest. At this point, the actor usually takes two different paths: one to gain
additional privileges and collect more credentials, or one to identify and collect information and
data of interest.
a. When looking to gain additional privileges, connect to a domain controller using the XServer
backdoor and query the domain controller’s event logs for the usernames of highly privileged
administrators.
b. Otherwise, identify servers or workstations that may contain interesting data.
4. Compromise the identified targets:
a. Run a reconnaissance script to explore the victim’s system, checking for missing Windows
patches and running security software.
b. Execute WMI commands in search of relevant information such as password manager
databases and Office documents.
c. Deploy a keylogger to retrieve the password for the victim’s password manager.
d. Run or deploy other tooling as necessary to complete the goal.
5. Exfiltrate such relevant information from the system, by downloading a single file or by
compressing multiple files into a RAR archive.
6. Securely delete the deployed tools and exfiltrated compressed archives to hinder a forensic
investigation.
In this chapter, we lay the foundation for our hypothesis that the threat actor that we describe
in this paper is, indeed, of Chinese origin.
3.1 Language
However, Fox-IT also unexpectedly observed regular web browsing activity. This may have been
the result of a flawed networking setup on the actor’s side, accidentally tunnelling web traffic from
the actor through a victim’s network. While most of this browsing traffic was encrypted over HTTPS,
Fox-IT also observed the occasional plaintext HTTP request. In all of these leaked HTTP requests,
a Chinese Accept-Language header was seen, indicating that the actor was running a browser with
a Chinese language configuration (see figure 1).
In the webserver logs below, two operators of the group attempt to access the deleted webshells,
executing several Windows commands on one of the webshells, all of which no longer return any
of the expected responses.
Possibly frustrated by the fact of losing access to the webshells, the last seen “command” executed
by the actor is “wocao”. According to a number of native Mandarin speakers in our network, this
could be Chinese slang for “shit” or “damn”, often used by native Chinese speakers.
Table 1 – Registration information used by the actor to rent one of the servers
Field name Value
First Name David
Last Name Walker
Company Name Kiddie City
Email Address DavidVWalker87177@gmx.com (verified)
Address 1 4910 Bridge Avenue
City Lafayette
State/Region 路易斯安那州
Postcode 70506
Country US - United States
Phone Number +44.1302238058
It appears that the actor mostly submitted fake information for the registration of this server, and
possibly forgot to translate the State/Region field from the simplified Chinese 路易斯安那州 to its
English translation: Louisiana.
The phone number used for the registration was set-up using an online SMS service.
3.2 Timezone
In any infrastructure, visibility of network traffic and endpoint behavior are crucial components
to build one’s defenses on and decide how to respond and mitigate. Even more so during incident
response, where time is crucial as the actor can still be in the network. In some of those cases
Fox-IT has the opportunity to monitor an actor, while active in a victim’s infrastructure, primarily
in order to understand what they are doing and to inform proper response. Monitoring of this
actor’s behavior inside a victim network resulted in a comprehensive timeline of the actor’s activity.
With this timeline, an assessment can be made of the most likely time zone that the attack was
carried out from.
Analysis of actor activity shows that the activity is spread across an average of 8 to 10 hours a day,
and that the operators are rarely active during weekends. Based on this, we assume that most of
the activity is conducted in a rhythm of business days and business hours.
CHINA
Based on the multiple described links that already point towards China, and not to any of the other
countries in the same timezone, it is most likely that the time zone that the actor operates out of is
CST (China Standard Time). In other words, the actor likely operates out of China.
3. https://blog.csdn.net/ts__cf/article/details/47659829
UK Germany
France Italy
Portugal Spain China
USA
Mexico
Brazil
The victims include government entities, managed service providers and can be found across
a wide variety of industries including:
• Aviation
• Construction
• Gambling
• Energy
• Finance
• Health care
• Insurance
• Offshore engineering
• Payroll and other HR services
• Physical lock manufacturers
• Software development
• Transportation
The tools below are described in the order in which the actor would typically deploy them, starting
with the webshells used for initial access. It is interesting to mention that Fox-IT has observed the
actor leveraging already existing JexBoss⁴ webshells, placed there by completely different threat
actors, for reconnaissance activity.
A simple password protected file uploader shell. The webshell is merely a form with a path and text
input field. A password is required and given using a URL parameter.
A webshell with more features than the one described above. It supports command execution on
both Unix and Windows hosts. The overall layout and some of the code matches the file upload shell.
For example, a password is required in the same manner.
This and the previous shell were uploaded shortly after each other. Once this shell was deployed,
all interaction with the existing JexBoss shell stopped.
Table 3 – Hashes for the file upload and command execution webshell
Hash type Hash
MD5 14f3514feb74a943b17596ebf0811eb0
SHA1 4b7ba900acd6564afeff44250b91903c0c9ea504
SHA256 2047e464627e36410b3458e23062f23eecbd383e7854b55b497ec8db017c0d5e
4. https://github.com/joaomatosf/jexboss
A modified version of a publicly available socket tunnel⁵. Some print statements were changed and
all comments were removed.
This shell was uploaded not long after the two previously described webshells. All further interaction
with the target system appears to have taken place through this socket tunnel. This was likely done
to easily interact with other systems inside the internal network using more conventional tooling,
such as PsExec and smbexec.
The actor makes use of a reconnaissance script, written in Visual Basic Script (VBS), to retrieve
detailed information from a system that the actor wants to use for lateral movement or to
exfiltrate files from.
The script has support for the following functions, which retrieves:
• Volume drives and the type of drives (Removable disk, network disk, local disk etc.)
• List of accounts that have Administrator rights
• Device information (Manufacturer, Model etc.)
• Overview of installed software
• Recently executed software (MuiCache)
• Running processes
• Internet connectivity check
• Connection to www.bing.com and www.google.com via WMI service winmgmts to check
if a system has a connection to the internet
5. https://github.com/sensepost/reGeorg/blob/master/tunnel.jsp
XServer is a custom backdoor, written in C#, which is executed on a system using PowerShell,
as described in chapter 6.2.2. The backdoor is typically Base64 encoded and zlib compressed.
The backdoor listens for connections on a specific hardcoded local port. Fox-IT observed multiple
variants using port 25667 and port 47000. By default, XServer binds to 0.0.0.0, meaning it could
theoretically be accessible from the internet. Using internet scan data Fox-IT was unable to identify
any internet accessible XServer instances, likely because it is deployed as a backdoor for use in an
internal network.
XServer has two main functions. One is to provide simple backdoor functionality and the other is
to function as a proxy. The proxy functionality has support for proxying through multiple infected
systems. It also has a feature to exit after a specified amount of time. This feature was not enabled
in any of the variants observed by Fox-IT.
When XServer is started, it will wait for incoming connections. Depending on the “command” packet
that is received, it will either act as a proxy for that connection or it will start a backdoor session.
Each of the command packets is described in the table below.
The SOCKS5 proxy functionality of the Xserver backdoor has as a very simple (unauthenticated)
implementation and simply proxies data between the incoming connection and the requested
destination (see figure 5).
When using the proxy chain functionality, the connecting client provides a list of hops as byte
encoded IPs and port numbers. XServer will take one IP and port from the list and transmit the
remainder to this IP and port – the next hop. From there on, any traffic between the incoming
client and next hop is proxied.
When starting a command & control session, the session is upgraded to TLS and XServer will act
as the TLS client, requesting a specific SNI “Root”. After successfully setting up the TLS connection,
XServer replies with the victim type (hardcoded to “WIN”) and the current directory of the backdoor.
After which it’s possible to issue backdoor commands, which are detailed in table 7.
The download command has a few additional features. For example, it supports setting a file transfer
speed. This will limit the amount of data sent at once, as well as sleep intermittently. The XServer
backdoor protocol actually uses DEFLATE to compress most of its communication, but the download
command has the option to omit compression for the file transfer.
Figure 5 – Network stream of XServer traffic, utilizing the proxy chain functionality
First a SOCKS5 proxy is
established to 10.120.3.178
on port 25667.
XServer on 10.120.3.178
replies by upgrading to a
TLS socket and sending a
ClientHello with SNI Root.
The operator side responds
by sending the appropri-
ate ServerHello. The TLS
handshake is finished and all
command & control traffic is
now tunneled over TLS.
The command execution functionality also implements two different methods. The first method
utilizes the ShellExecute Windows API, whereas the other method spawns a new cmd.exe
process for every command executed. The latter method is the only method Fox-IT observed, and
also has a specific way of setting up its arguments. Every cmd.exe spawned will be according to
the following template:
Though this version of the XServer backdoor has been on VirusTotal for more than a year, at the time
of writing only one of the anti-virus engines has marked it as malicious:
The hashes provided in the table below are for the deobfuscated C# code of the XServer backdoor,
as is the version uploaded to VirusTotal.
5.6 Agent
Agent is a custom proxy implementation that has support for multiple hops. It supports two modes:
to backconnect to a hardcoded IP and port or to act as a server and listen for incoming connections.
The only difference is the method used to setup new connections, the rest of the functionality is
similar to the equivalents found in XServer.
The proxy functionality is nearly identical to that of XServer, with a few exceptions. The most
prominent change is that IP addresses for the hops are encrypted using RC4 with a hardcoded RC4
key. Interestingly, the ports of the hops are not encrypted. Another major change is that the final
hop will upgrade the socket to a TLS socket, so that all proxied data is encrypted.
In one of the investigations a Python variant of the Agent proxy was observed, compiled using
py2exe. It appeared to have been minified, as all whitespaces were stripped and some function
names had single character names. Other than being written in Python instead of C#, it is nearly
identical to the C# variant of Agent. It consists of the exact same functionality, including the
hardcoded RC4 key. One notable difference is that this version takes the backconnect IP from an
argument. The argument should be the hex encoding of “<IP>:<PORT>”.
The hashes provided in the table below are for the Python variant of Agent.
This custom tool is used by the actor to create an orderly overview of all files in a given directory,
recursively.
A directory is specified as an argument, which the tool will recursively walk. For each directory,
file information is retrieved, such as timestamps, and stored in a file as specified by an argument.
Maximum recursion depth can also be specified using an argument.
The actor often used a custom process launcher tool, for example to launch a keylogger as a child
process from explorer.exe. It injects code into a selected process that ends up using CreateProcessA
to launch the command as a child process of the selected process.
5.9 CheckAdmin
The actor occasionally uses a custom tool that is capable of enumerating sessions and users on
remote hosts, to identify if privileged users are logged in on a target system. This tool is named
CheckAdmin, according to a help message in an older version. This chapter describes two versions,
a new version which is used most often, and an older version.
C:\Users\user\Desktop>checkadmin.exe
CheckAdmin Usage:
Example:
Below you can find an example of the tool’s output when scanning a host (localhost in this case):
Table 15 – Command line arguments supported by the old version of the CheckAdmin tool
Argument Description
HOSTS IP or path to a file containing IP addresses to check
-kw PATH A list of usernames to look for or a path to a file with usernames
-u USERNAME Username to use
-p PASSWORD Password to use
-s OUTPUT Save output to file
-ht THREADS Number of threads to use
-admin [1] List users in “administra*” or “Remote Desktop*” groups. There
might be some undetermined difference with the default mode (-all)
[2] Default: List users in “administra*” or “Remote Desktop*”
-all
groups.
-dump [3] List all users
[4] NetSessionEnum, list established network sessions (to remote
-active
servers)
Table 17 – Command line argument added to the new version of the CheckAdmin tool
Argument Description
-logon [5] NetWkstaUserEnum, lists currently logged on users
Otherwise, the functionality is the same as the older version. Below is an example of the output
given by this tool, when executed locally in a testing environment:
C:\Users\user\Desktop>checkadmin.exe 127.0.0.1
5.10 OS scanner
The actor sometimes used a custom tool to determine OS versions of systems connected to the
network. It accomplishes this by sending SMB packets to every IP in the specified range and parsing
the response. Like many other tools from this actor, it's a Python script inside a py2exe binary.
The output is written to a file in the following format: IP address, hostname, Windows version. An
example of the output:
5.11 Keylogger
The actor uses a custom keylogger to obtain the password for the victim’s password manager. This is
a relatively simple keylogger written in Python and compiled to an executable using py2exe. It logs
the victim’s keystrokes and clipboard data in plaintext to a specific file. The file location can be given
as an argument, but a default location is hardcoded in the Python code.
• c:\windows\temp\tap.tmp
• c:\windows\temp\mrteeh.tmp
22 | Fox-IT | APT20
Discovery Lateral Movement Collection Exfiltration Command and Control
Account Discovery AppleScript Audio Capture Automated Exfiltration Commonly Used Port
Application Window Application Deployment Automated Collection Data Compressed Communication Through
Discovery Software Clipboard Data Data Encrypted Removable Media
Browser Bookmark Distributed Component Data from Information Data Transfer Size Limits Connection Proxy
Discovery Object Model Repositories Exfiltration Over Custom Command and
Domain Trust Exploitation of Remote Data from Local Alternative Protocol Control Protocol
Discovery Services System Exfiltration Over Custom Cryptographic
File and Directory Logon Scripts Data from Network Command and Control Protocol
Discovery Pass the Hash Shared Drive Channel Data Encoding
Network Service Pass the Ticket Data from Removable Exfiltration Over Other Data Obfuscation
Scanning Remote Desktop Protocol Media Network Medium Domain Fronting
Network Share Remote File Copy Data Staged Exfiltration Over Physical Fallback Channels
Discovery Remote Services Email Collection Medium Multi-hop Proxy
Network Sniffing Replication Through Input Capture Scheduled Transfer Multi-Stage Channels
Password Policy Removable Media Man in the Browser Multiband
Discovery Shared Webroot Screen Capture Communication
Peripheral Device SSH Hijacking Video Capture Multilayer Encryption
Discovery Taint Shared Content Port Knocking
Permission Groups Third-party Software Remote Access Tools
Discovery Windows Admin Remote File Copy
Process Discovery Shares Standard Application
Query Registry Windows Remote Layer Protocol
Remote System Management Standard
Discovery Cryptographic
Security Software Protocol
Discovery Standard Non-Application
System Information Layer Protocol
Discovery Uncommonly Used
System Network Port
Configuration Discovery Web Service
System Network
Connections Discovery
System Owner/User
Discovery
System Service
Discovery
System Time Discovery
6. https://attack.mitre.org/matrices/enterprise/
Fox-IT | APT20 | 23
6.1 Initial Access
6.2 Execution
6.2.2 PowerShell
The actor uses various PowerShell tools which are all open source:
• KeeThief⁸
• KeeThief can be used to recover the plaintext master password and other type of key material
from the running KeePass process, a popular password manager.
• Invoke-BloodHound, executes the BloodHound C# ingestor SharpHound⁹
• BloodHound is an application made to map relationships in the active directory. SharpHound
is a C# ingestor for BloodHound.
• Invoke-Mimikatz¹⁰
• Invoke-Mimikatz leverages Mimikatz 2.0 and Invoke-ReflectivePEInjection to reflectively load
Mimikatz in memory.
• Mimikatz can be used to extract, for example, plaintext passwords and Kerberos tickets from
memory.
PowerShell is also used to execute custom backdoors that are written in C#, such as XServer.
An example of PowerShell code executing the XServer backdoor, using a single byte XOR cipher:
return $tt;}
Add-Type $code;
[agent]::Main($args);
7. https://github.com/joaomatosf/jexboss
8. https://github.com/HarmJ0y/KeeThief
9. https://github.com/BloodHoundAD/BloodHound/wiki/Data-Collector
10. https://github.com/PowerShellMafia/PowerSploit/blob/master/Exfiltration/Invoke-Mimikatz.ps1
[Convert]::FromBase64String($encfile),[IO.Compression.CompressionMode]::Decompress)
$x = [System.Text.Encoding]::Default.GetString($defilebytes)
out-null
Add-Type $x
[xserver]::Main($args);
However, the netsh command adding the firewall rule named powershell, as seen above, is not
executed, as the protocol has to be specified (which should be TCP), resulting in the following error:
Ports can only be specified if the protocol is TCP or UDP. An error the actor likely never saw because
the results of the command are not written to the console.
daily /tr "cmd /c powershell.exe -ep bypass -file c:\s.ps1" /tn win32times /f
After executing the PowerShell code, the scheduled task is removed, to limit traces on the
compromised system:
6.2.4 Scripting
To retrieve more information of systems within the network, the actor deploys a custom VBS script,
described in more detail in chapter 5.4. CScript is used to execute the VBS script:
PowerShell is frequently used to execute custom backdoors that are written in C#, as previously
described in chapter 6.2.2.
.bat files are occasionally used to start services, as described in chapter 6.2.5.
/c cd /d c:\windows\temp & sc \\<IP ADDRESS> create win32times binPath= "cmd /c start c:\
windows\temp\x.bat"
6.3 Persistence
An interesting observation in one of Fox-IT’s incident response cases was that the actor steals a soft-
token for RSA SecurID, which is typically generated on a separate device, such as a hardware token
or mobile phone. In this specific case however, victims using the software could also use a software
based token to generate 2 factor codes on their laptop. This usage scenario opens up multiple
possibilities for an attacker with access to a victim’s laptop to retrieve 2 factor codes used to connect
to a VPN server.
Because Fox-IT was uncertain which method the actor used to obtain valid 2 factor codes from
its victims we analyzed the RSA SecurID software to determine the attack scenario that was most
likely used.
The software token is generated for a specific system, but of course this system specific value could
easily be retrieved by the actor when having access to the system of the victim.
As it turns out, the actor does not actually need to go through the trouble of obtaining the victim’s
system specific value, because this specific value is only checked when importing the SecurID Token
Seed, and has no relation to the seed used to generate actual 2-factor tokens. This means the actor
can actually simply patch the check which verifies if the imported soft token was generated for this
system, and does not need to bother with stealing the system specific value at all.
In short, all the actor has to do to make use of the 2 factor authentication codes is to steal an RSA
SecurID Software Token and to patch 1 instruction, which results in the generation of valid tokens:
ADDRESS>\c$\windows\temp\LMAKSW.ps1 /y
The actor is very consistent in removing its files from a system once they have served its purpose.
Log files and executable files are quickly overwritten and deleted once they are no longer needed.
This makes both forensic and actor tracking efforts more complicated, as only few traces and
executables remain on the system to be investigated.
11. https://github.com/SecureAuthCorp/impacket
wmiexec.py
The variable OUTPUT_FILENAME in this script is set to '__' + str(time.time()) by default.
Note that this variable used for the named pipe is based on the epoch timestamp, this was done
on purpose to avoid any locking issues (https://github.com/SecureAuthCorp/impacket/issues/108).
However Fox-IT observed that the actor changed this variable to the static string __output.
/Q /c wevtutil cl system
/Q /c wevtutil cl security
The actor cleans up running backdoors from systems that are no longer of use to the actor. This is
done by searching for the PID of the process that is listening on the backdoor port, and then killing
that specific process.
WDigest is a protocol used primarily in older versions of Windows for LDAP and web-application
authentication. When enabled it stores the plain-text password of the logged in Windows domain
user in memory, which can then easily be dumped by an actor with access to the system. The key
is located in the following location:
HKLM\SYSTEM\\ControlSet001\\Control\\SecurityProviders\\WDigest
JgAgAHsASQBtAHAAbwByAHQALQBNAG8AZAB1AGwAZQAgAGMAOgBcAHQAZQBtAHAAXABpAGsALgBwAHMAMQA7ACAA
RwBlAHQALQBEAG8AbQBhAGkAbgBVAHMAZQByACAALQBTAFAATgAgAHwAIABHAGUAdAAtAEQAbwBtAGEAaQBuAFMA
rs.txt
[Convert]::FromBase64String
($encfile),[IO.Compression.CompressionMode]::Decompress)
return $tt;}
The actor makes frequent use of Base64 within their PowerShell scripts and command snippets.
Backdoor scripts are usually also compressed using DEFLATE, in addition to being encoded with Base64.
The agent proxy is the only script that adds a layer of single-byte XOR. It is noteworthy that the XOR
operation is in the form of “<charcode> XOR <int> + <int>”, in comparison to “<charcode> XOR <int>”.
Only one case of string obfuscation was observed, and it is not particularly complex. In the custom
tool used to launch processes, as described in chapter 5.8, some of the strings are reversed or stored
partially in the data section. Within the code, these strings would be reversed again or appended
with the remainder of the string.
In one case Fox-IT observed a combination of Base64 and BZIP being used to obfuscate a Python
script compiled with py2exe. The resulting Python code also appeared to be minified, as all
whitespace had been removed and all function names consisted of single characters, in an attempt
to complicate analysis.
For network communication, TLS is mostly used with the occasional use of RC4. This is explained
further in chapters 5.5 and 5.6.
The /accepteula flag ensures the EULA of ProcDump is silently accepted and doesn’t create a
popup. The –ma flag dumps all process memory, not just thread and handle information. This dump
can then be used to recover passwords from a remote system.
savepath = 'c:\\windows\\temp\\tap.tmp'
savepath = 'c:\\windows\\temp\\mrteeh.tmp'
6.6.3 Kerberoasting
To be able to bruteforce the passwords of Windows service accounts , the actor uses PowerSploit’s
Invoke-Kerberoast¹³ module to request encrypted service tickets. The bruteforcing of the passwords
used to encrypt these tickets can be done completely offline, which prevents domain traffic or any
potential account lockouts, making it more difficult to detect this malicious behavior. An example
command:
Hashcat}
12. https://docs.microsoft.com/en-us/sysinternals/downloads/procdump
13. https://powersploit.readthedocs.io/en/latest/Recon/Invoke-Kerberoast/
Using the Mimikatz arguments above, private keys marked as non-exportable can also be exported.
6.7 Discovery
To get a list of all users that have authenticated with a specific domain and have a user profile, the
actor executes the following command on a domain controller:
14. https://github.com/BloodHoundAD/BloodHound
/Q /c type c:\users\<username>\appdata\Roaming\keepass\KeePass.config.xml
The following command is executed to list all files in a specific directory with the kdbx (KeePass
database) extension:
/Q /c dir *.kdbx
Sometimes the actor uses a custom find/walk tool that writes recursive directory listings to a file:
The actor also sometimes uses a custom scanning tool that is capable of enumerating sessions and
users on remote hosts.
The actor executes the following command on a domain controller to retrieve all subnets in the
Active Directory:
dsquery subnet
This information is used by the actor to get a better understanding of the victim’s network.
This same process ID identification is true for the explorer.exe process, which is used by the actor to
inject a keylogger into:
The keylogger (described in chapter 5.11) injected into explorer.exe is primarily used to obtain the
password for the victim’s password manager.
/Q /c dir c:\windows\CarbonBlack\cb.exe
Upon identifying the Carbon Black agents on systems the actor would occasionally halt its activity,
while on other occasions activity would continue as usual.
ipconfig /all
The actor executes the following command on a domain controller to list the records in a zone, likely
to determine the high value targets:
dnscmd.exe /ZonePrint
6.9 Collection
win32clipboard.OpenClipboard()
pasted_value = win32clipboard.GetClipboardData()
win32clipboard.CloseClipboard()
6.10 Exfiltration
Additionally, the XServer backdoor protocol uses DEFLATE to compress most of its communication.
OSINT resulted in some public source code (hereafter referred to as "ProxyTest"), found on a
Chinese blog¹⁵, which shows a significant amount of similarities with the XServer and agent
backdoor. The ProxyTest code provides (authenticated) SOCKS proxy functionality. XServer and
agent provide the same functionality and the code used to achieve this shows a significant amount
of similarities, both in the implementation of actual functionality as well as in the coding style such
as variable and function naming. Some of the functionality similarities are highlighted in the table.
CliSock.Send(new byte[] { 0x05, 0x00 }); No overlap CliSock.Send(new byte[] { 0x05, 0x00 });
ServerSock.Connect(ip, Port);
StartTransData(CliSock, ServerSock);
}
catch
{
CliSock.Shutdown(SocketShutdown.Both);
CliSock.Close();
return;
}
}
}
catch
{
break;
}
}
Commands executed through the webshell were occasionally executed via Tor exit nodes.
15. https://blog.csdn.net/ts__cf/article/details/47659829
Agent
The agent backdoor/proxy uses TLS in a similar way, but for the proxy functionality. It contains a
similar multi-hop functionality as the XServer backdoor, but the final hop in the agent proxy will
upgrade the socket to a TLS socket in the same way as XServer does. Underneath the TLS, the final
hop still behaves like a regular SOCKS5 proxy. The TLS in this case makes sure that the traffic is
encrypted across all hops, whereas it is plaintext with XServer.
The multi-hop functionality also differs slightly. In the agent variant, the individual hop IP addresses
are encrypted using RC4, whereas they are plain in the XServer variant. Port numbers are still in plain,
however.
Fox-IT
Fox-IT prevents, solves and mitigates the most
serious threats caused by cyber attacks, data
leaks or fraud with innovative solutions for
governments, defense agencies, law enforcement,
critical infrastructures and banking and commercial
enterprise clients worldwide. The Fox-IT Red Team
service is part of NCC Group’s Full Spectrum Attack
Services. Fox-IT combines smart ideas with advanced
technology to create solutions that contribute to
a more secure society. We develop products and
custom solutions for our clients to guarantee the
safety of sensitive and critical (government) systems,
to protect industrial networks, to defend online
banking systems and to secure confidential data.
Fox-IT B.V.
Olof Palmestraat 6, Delft T +31 (0)15 284 7999
P.O. Box 638, 2600 AP Delft F +31 (0)15 284 7990
The Netherlands fox@fox-it.com