Russian APT Groups Adversary Simulation
Russian APT Groups Adversary Simulation
This PDF is a compilation of all Russian APT simulations that target many vital sectors,both
private and governmental. The simulation includes written tools, C2 servers, backdoors,
exploitation techniques, stagers, bootloaders, and many other tools that attackers might have
used in actual attacks. These tools and TTPs (Tactics, Techniques, and Procedures)
are simulated here.
These are all the names of the Russian APT groups, and I simulated one attack for each group.
Energetic Bear................................................................................................................12
This is what many Russian threat actors rely on. They exploit incidents in general for phishing
campaigns, such as the earthquake that happened in Turkey. At that time, all countries of the world
were sending aid to Turkey, and they took advantage of this issue for the sake of launching phishing
campaigns on Diplomatic institutions in Turkey, and on the same issue, took advantage of the war that
Russia was waging against Ukraine at the time. All the people in Ukraine were selling their homes,
property, and valuable things at very cheap prices for the sake of being able to travel and save their
lives, and the same issue is repeated every time in a different way, even at the technical level, that they
are using APIs to hide traffic.
https://unit42.paloaltonetworks.com/cloaked-ursa-phishing/
Of course, this is in addition to their discovery of zero-day vulnerabilities and using them in the attack,
knowing the type of defense machines before the attack and writing down the servers specifically for
this attack. At the same time, the threat actors create software vulnerabilities that are intended to
access sensitive information and at the same time, they also build the C2 server Based on certain
information that the victim has, such as a specific type of product, threat actors attempt to build a
c2 server that exploits API of the same type of product that is already present at the target to avoid the
SOC team by hiding the traffic by product API.
https://thehackernews.com/2024/03/apis-drive-majority-of-internet-traffic.html?m=1
This is in addition to their exploitation of knowledge of the types of products already available to their
targets to create fake software and exploit it to carry out malicious activities, This is just like what
happened at the beginning of the Russian-Ukrainian war, where threat actors used fack update to attack
Ukraine’s CERT.
https://www.socinvestigation.com/ukraines-cert-warns-russian-threat-actors-for-fake-av-updates/
The Russian APT groups use their capabilities to collect information 100%,
which is the main thing on which their attack is built.
Cozy Bear APT29
This is a simulation of attack by the Cozy Bear group (APT-29) targeting diplomatic missions.
The campaign began with an innocuous and legitimate event. In mid-April 2023, a diplomat within the
Polish Ministry of Foreign Affairs emailed his legitimate flyer to various embassies advertising the sale
of a used BMW 5-series sedan located in Kyiv. The file was titled BMW 5 for sale in Kyiv - 2023.docx.
I relied on palo alto to figure out the details to make this simulation: https://unit42.paloaltonetworks.com/cloaked-ursa-phishing/
1. DOCX file: created DOCX file includes a Hyperlink that leads to downloading further HTML
(HTML smuggling file).
2. HTML Smuggling: The attackcers use the of HTML smuggling to obscure the ISO file.
3. LNK files: When the LNK files (shortcut) are executed they run a legitimate EXE and open a PNG file.
However, behind the scenes, encrypted shellcode is read into memory and decrypted.
4. ISO file: The ISO file contains a number of LNK files that are masquerading as images.
These LNK files are used to execute the malicious payload.
5.DLL hijacking: The EXE file loads a malicious DLL via DLL hijacking, which allows the attacker to
execute arbitrary code in the context of the infected process.
6.Shellcode injection: The decrypted shellcode is then injected into a running Windows process,
giving the attacker the ability to execute code with the privileges of the infected process.
7.Payload execution: The shellcode decrypts and loads the final payload inside the current process.
8.Dropbox C2: This payload beacons to Dropbox and Primary/Secondary C2s based on the Microsoft
Graph API.
The first stage (delivery technique)
First the attackers created DOCX file includes a Hyperlink that leads to downloading further HTML
(HTML smuggling file) The advantage of the hyperlink is that it does not appear in texts, and this is
exactly what the attackers wanted to exploit.
HTML Smuggling used to obscure ISO file and the ISO contains a number of LNK files masquerading
as images command line to make payload base64 to then put it in the HTML smuggling file: base64
payload.iso -w 0 and i added a picture of the BMW car along with the text content of the phishing
message in the HTML file.
Note: This iso file is the one to which i will make base64 for this iso file and put in the html
smuggling file before make hyperlink and place it in the docx file.
After that, I will go to the settings menu to generate the access token for the Dropbox account,
and this is what I will use in Dropbox C2.
This script integrates Dropbox API functionality to facilitate communication between the
compromised system and the attacker-controlled server, thereby hiding the traffic within legitimate
Dropbox communication, and take the access token as input prompts the user to enter an
AES key (which must be 16, 24, or 32 bytes long) and encrypts the token using AES encryption
in ECB mode. It then base64 encodes the encrypted token and returns it.
I used payload written by Python only to test C2 (testing payload.py), if there were any problems
with the connection (just for test connection) before writing the actual payload.
The fifth stage (payload with DLL hijacking) and injected Shellcode
This payload uses the Dropbox API to upload data, including command output to Dropbox.
By leveraging the Dropbox API and providing an access token the payload hides its traffic within
the legitimate traffic of the Dropbox servic and If the malicious DLL fails to load, it prints a warning
message but continues executing without it.
1.DLL Injection: The payload utilizes DLL hijacking to load a malicious DLL into the address
space of a target process.
2.Shellcode Execution: Upon successful injection, the malicious DLL executes shellcode stored
within its DllMain function.
3.Memory Allocation: The VirtualAlloc function is employed to allocate memory within the target
process, where the shellcode will be injected.
4.Shellcode Injection: The shellcode is copied into the allocated memory region using memcpy,
effectively injecting it into the process
5.Privilege Escalation: If the compromised process runs with elevated privileges, the injected shellcode
inherits those privileges, allowing the attacker to perform privileged operations.
Final result: payload connect to Dropbox C2 server
the final step in this process involves the execution of the final payload. After being decrypted
and loaded into the current process, the final payload is designed to beacon out to both Dropbox
API-based C2 server.
Energetic Bear
This is a simulation of attack by (Energetic Bear) APT group targeting “eWon” is a Belgian producer
of SCADA and industrial network equipmen, the attack campaign was active from January 2014,
The attack chain starts with malicious XDP file containing the PDF/SWF exploit (CVE-2011-0611)
and was used in spear-phishing attack. This exploit drops the loader DLL which is stored in an
encrypted form in the XDP file, The exploit is delivered as an XDP (XML Data Package) file which
is actually a PDF file packaged within an XML container. I relied on Kaspersky tofigure out the details
to make this simulation: https://media.kasperskycontenthub.com/wp-content/uploads/sites/43/2018/03/08080817/EB-YetiJuly2014-Public.pdf
This attack included several stages including exploitation of the (CVE-2011-0611) vulnerability
which allows attackers to overwrite a pointer in memory by embedding a specially crafted .swf,
The XDP file contains a SWF exploit CVE-2011-0611 and two files encrypted with XOR stored in the
XDP file One of the files is malicious DLL the other is a JAR file which is used to copy and run the
DLL by executing the Cmd command line
1. CVE-2011-0611: this module exploits a memory corruption vulnerability in Adobe Flash Player
versions 10.2.153.1 and earlier, i maked Modified version of the exploit based on Windows 10.
2. CVE-2012-1723: this exploit allows for sandbox escape and remote code execution on any target
with a vulnerable JRE (Java IE 8).
3. XDP file: this XDP file contains a malicious XML Data Package (XDP) with a SWF exploit
(CVE-2011-0611), It also includes functionality to download additional files via HTML-Smuggling
by apache host.
4. HTML Smuggling: the html-smuggling file is used after uploading it to the apache server to
download other files, One of the files is DLL payload the other is a small JAR file.
5. JAR file: this jar file used to copy and run the DLL by executing the cmd command.
6. DLL payload: the attackers used havex trojan, havex scanned the infected system to locate any
supervisory control and data acquisition SCADA.
7. Encrypted with XOR: the XDP file contains a SWF exploit and two files encrypted with XOR.
8. PHP backend C2-Server: the attckers used hacked websites as simple PHP C2 Server backend.
9.Final result: make remote communication by utilizes XOR encryption for secure data transmission
between the attacker server and the target.
The first stage (exploit Adobe SWF Memory Corruption Vulnerability CVE-2011-0611)
This module exploits a memory corruption vulnerability (CVE-2011-0611) in Adobe Flash Player versions
10.2.153.1 and earlier. The vulnerability allows for arbitrary code execution by exploiting a flaw in how
Adobe Flash Player handles certain crafted .swf files. By leveraging this vulnerability, an attacker can
execute arbitrary code on the victim's system.
sudo updatedb
The Second stage (CVE-2012-1723 Oracle Java Applet Field Bytecode Verifier Cache RCE)
This vulnerability in the Java Runtime Environment (JRE) component in Oracle Java SE 7 update
4 and earlier, 6 update 32 and earlier, 5 update 35 and earlier, and 1.4.2_37 and earlier allows remote
attackers to affect confidentiality, integrity, and availability via unknown vectors related to Hotspot.
if you need know more about CVE-2012-1723:
https://www.microsoft.com/en-us/wdsi/threats/malware-encyclopedia-description?Name=Exploit:Java/CVE-2012-1723!generic&threatId=-2147302241
use exploit/multi/browser/java_verifier_field_access
The attackers actively compromises legitimate websites for watering hole attacks. These hacked
websites in turn redirect victims to malicious JAR or HTML files hosted on other sites maintained
by the group (exploiting CVE-2013-2465, CVE-2013-1347, and CVE-2012-1723 in Java 6, Java 7, IE 7
and IE 8), These hacked websites will be using a simple PHP C2 Server backend.
The third stage (XML Data Package XDP with a SWF exploit)
The exploit is delivered as an XDP (XML Data Package) file which is actually a PDF file packaged
within an XML container. This is a known the PDF obfuscation method and serves as an additional
anti-detection layer. if you need know more about XDP file: https://filext.com/file-extension/XDP
The XDP file contains a SWF exploit (CVE-2011-0611) and two files (encrypted with XOR) stored in the
PDF file, It also includes functionality to download additional files via HTML-Smuggling by apache host.
The fourth stage (HTML-Smuggling with DLL payload & JAR file)
The HTML smuggling file is used after uploading it to the apache server to download other files, One
of the files is DLL payload the other is a small JAR file which is used to copy and run the DLL,
the command line to make payload base64 to then put it in the HTML smuggling file: base64
payload.dll -w 0 and the same command but with jar file.
The fifth stage (Copy DLL by JAR file)
This jar file used to copy and run the DLL by executing the following command: cmd /c copy
payload.dll %TEMP%\\payload.dll /y & rundll32.exe %TEMP%\\payload.dll,RunDllEntry
The attackers gained access to eWon’s FTP site and replaced the legitimate file with one that is bound
with the Havex dropper several times.
The main functionality of this component is to download and load additional DLL modules into the
memory. These are stored on compromised websites that act as C&C servers. In order to do that,
the malware injects itself into the EXPLORER.EXE process, sends a GET/POST request to the PHP
script on the compromised website, then reads the HTML document returned by the script, looking
for a base64 encrypted data between the two “havex” strings in the comment tag <!--havexhavex-->
and writes this data to a %TEMP%<tmp>.xmd file (the filename is generated by GetTempFilename
function).
Full Disclosure of Havex Trojans: https://www.netresec.com/?page=Blog&month=2014-10&post=Full-Disclosure-of-Havex-Trojans
If you need know more about Havex trojan: https://malpedia.caad.fkie.fraunhofer.de/details/win.havex_rat
In this simulation i used a simple payload with XOR encryption to secure the connection between the
C2 Server and the Target Machine, this payload uses Winsock for establishing a tcp connection
between the target machine and the attacker machine, in an infinite loop the payload receives
commands from the attacker c2 decrypts them using (XOR) encryption executes them using system
and then sleeps for 10 seconds before repeating the loop.
xor_encrypt($data, $key) This function takes two parameters: the data to be encrypted ($data) and
the encryption key ($key) it iterates over each character in the data and performs an XOR operation
between the character and the corresponding character in the key (using modulo to repeat the key
if it's shorter than the data), the result is concatenated to form the encrypted output which is returned.
send_to_payload($socket, $data, $encryption_key) This function sends encrypted data to the target
system (payload) over a socket connection it first encrypts the data using the xor_encrypt function
with the provided encryption key then it writes the encrypted data to the socket using socket_write.
if you chose (command or URL) is encrypted using XOR encryption with a user-defined key before
being sent to the target.
1.Set up a web server or any HTTP server that can serve text content.
2.Upload a text file containing the commands you want the compromised system to execute.
3.Make sure the text file is accessible via HTTP and note down the URL.
4.When prompted by the script, enter the URL you obtained in step.
NOTE: If you choose to fetch commands from a URL it will prompt you to enter the URL,
If you choose to enter commands directly it will prompt you to Enter a command to execute
Berserk Bear
This is a simulation of attack by (Berserk Bear) APT group targeting critical infrastructure and
energy companies around the world, primarily in Europe and the United States,
The attack campaign was active from least May 2017. This attack target both the critical
infrastructure providers and the vendors those providers use to deliver critical services,
the attack chain starts with malicious (XML container) Injected into DOCX file connected to
external server over (SMB) used to silently harvest users credentials and was used in
spear-phishing attack. I relied on Cisco Talos Intelligence Group tofigure out the details to
make this simulation: https://blog.talosintelligence.com/template-injection/
If you need to know more about Berserk Bear APT group attacks:
https://apt.etda.or.th/cgi-bin/showcard.cgi?g=Berserk%20Bear%2C%20Dragonfly%202%2E0&n=1
This attack included several stages including Injecting a DOCX file and using a malicious XML
container that creates a specific alert to obtain credentials and is transferred to the attackers’
server, which in turn is used by them to obtain data for the organizations that were targeted by
the spear-phishing attack. The DOCX file was a CV that was Presented to a person with ten years
of experience in software development and SCADA control systems.
1.Create CV DOCX file which will be injected and sent spear phishing.
2.Make injections into DOCX file to obtain credentials using the phishery tool.
3.Credential Phishing is when the target opens the target Word file and enters credentials into
the notification that will be shown to them.
The first stage (delivery technique)
Since the attackers here wanted to target institutions related to energy and energy management
systems such as SCADA, the attackers created a DOCX file in the form of a CV to apply for a job.
It seems that there was a hiring open to work for such a position, and the attackers sent the CV
that contained the malicious XML container, here i created a CV identical to the one they used
in the actual attack.
phishery
Now the malicious CV will be sent to the target and wait for the Credentials.
This attack included several stages including exploitation of the CVE-2021-40444 vulnerability
through which remote access execution can be accessed through word file this is done by injecting
the DLL into Word file through this exploit, Also use OneDrive c2 Server to get command and
control and this is to data exfiltration with hide malicious activities among the legitimate traffic
to OneDrive.
1. Create dll downloads files through base64, This is to download two files the first is (dfsvc.dll)
the second is (Stager.dll).
2. Exploiting the zero-day vulnerability to inject the DLL file into Word File and create an execution
for DLL by opening Word File.
3. Word File is running and the actual payload is downloaded through DLLDownloader.dll and I
have two files Stager.dll and dfsvc.dll.
4. The Stager decrypts the actual payload and runs it which in turn is responsible for command
and control.
5. Data exfiltration over OneDrive API C2 Channe, This integrates OneDrive API functionality to
facilitate communication between the compromised system and the attacker-controlled server
thereby potentially hiding the traffic within legitimate OneDrive communication.
6. Get Command and Control through payload uses the OneDrive API to upload data including
command output to OneDrive, the payload calculates the CRC32 checksum of the MachineGuid
and includes it in the communication with the server for identification purposes.
The first stage (delivery technique)
First the attackers created DLL executable (DLLDownloader.dll) this DLL it can download two
payloads by command line to make payload base64 base64 dfsvc.dll -w 0 and base64 Stager.dll
-w 0 the first is (dfsvc.dll) the second is (Stager.dll), This DLL will be used in the next stage by
injecting it into a Word file via the Zero-day vulnerability.
The Second stage (implanting technique)
When a victim opens the malicious Office document using Microsoft Office, the application parses
the document's content, including the embedded objects. The flaw in the MSHTML component is
triggered during this parsing process, allowing the attacker's malicious code to be executed within
the context of the Office application.
The third stage (execution technique)
Now i have a Word file when i open it performs an execution for the DLL Downloader and thus
downloads the two files (dfsvc.dll) and (Stager.dll) this is through the vulnerability CVE-2021-40444.
After that the stager decrypts the payload using the Decrypt-Payload function
(you need to implement the decryption algorithm) and then executes the payload using the
Execute-Payload function, In this simulation i made the build perform an execution directly
without the need for the stager script, and it can be modified to suit the stager making an
execution for the actual payload.
The fourth stage (Data Exfiltration) over OneDrive API C2 Channe
The attackers used the OneDrive C2 (Command and Control) API as a means to establish a
communication channel between their payload and the attacker's server, By using OneDrive as a
C2 server, attackers can hide their malicious activities among the legitimate traffic to OneDrive,
making it harder for security teams to detect the threat. First, I need to create a Microsoft Azure
account and activate its permissions, as shown in the following figure.
I will use the Application (client) ID for the inputs needed by the C2 server
After that, I will go to the Certificates & secrets menu to generate the Secret ID for the Microsoft
Azure account, and this is what i will use in OneDrive C2.
To make simulation of this attack at the present time i did not use the PowerShell Empire to avoid
detection and i make customization of the OneDrive C2 server, This script integrates OneDrive
API functionality to facilitate communication between the compromised system and the attacker
controlled server, thereby potentially hiding the traffic within legitimate OneDrive communication
and i used AES Encryption to secure the connection just like the PowerShell Empire server that
the attackers used in the actual attack, The customization OneDrive C2 Server inspired by
PowerShell Empire.
2.Identification mechanism: It retrieves the MachineGuid from the Windows registry and calculates
its CRC32 checksum.
3.Command execution: The payload enters a loop to receive commands from the remote server
or OneDrive.
4.Data exfiltration: After execution it captures output and sends it back to the server or uploads it to
OneDrive.
5.Stealthy communication: Utilizing OneDrive API it blends network traffic with legitimate OneDrive
traffic.
This attack included several stages including creating a PDF file and placing a hyperlink inside it.
The PDF file will be unreadable, with a prominent button intended to enable reading the content,
Pressing the button in the PDF file causes the default browser to open a link to a fake page that
steals the target's Credential, From the same PDF I also made it possible for me to get Command and
Control.
1. PDF file: created PDF file includes a Hyperlink that leads to a fake page that steals Credential.
2. HTML Smuggling: it was used to open the URL of the credentials phishing page and also to install
the payload.
3. Now when you click the prominent button in the PDF file it launches the html smuggling file on
the apache server which contains payload in base64 encod and the phishing link.
4. Data exfiltration: over GoogleDrive API C2 Channe, This integrates GoogleDrive API functionality
to facilitate communication between the compromised system and the attacker-controlled server thereb
5. Make simple reverse shell payload to creates a TCP connection to a command and control (C2)
server and listens for commands to execute on the target machine.
6. The final step in this process involves the execution of the final payload, After it was downloaded
through an obfuscated HTML file with base64 encoding and a phishing link was opened.
The first stage (delivery technique)
First the attackers created PDF file includes a Hyperlink that leads to a fake page that steals
Credential, The advantage of the hyperlink is that it does not appear in texts, and this is exactly what
the attackers wanted to exploit.
HTML Smuggling it was used to open the URL of the credentials phishing page and also to create
an install for payload to get Command and Control, After that i will place the HTML file in the apache
server, take the localhost and place it as a hyperlink in the prominent button in the PDF file.
HTML Smuggling it was used to open the URL of the credentials phishing page and also to create
an install for payload to get Command and Control, After that i will place the HTML file in the apache
server, take the localhost and place it as a hyperlink in the prominent button in the PDF file.
PyPhisher: https://github.com/KasRoudra2/PyPhisher.git
base64 payload.exe
After that i will obfuscate the html file after putting the phishing link and the payload inside it before
putting it in the apache server
In the actual attack, the attackers did not use an actual c2 server or payload and limited themselves
to spear phishing, but here I wanted to exploit the presence of a larger HTML file to download the
payload and open malicious url.
First i need to create a google Drive account, as shown in the following figure
I used the GoogleDrive C2 (Command and Control) API as a means to establish a communication
channel between the payload and the attacker's server, By using GoogleDrive as a C2 server,
i can hide the malicious activities among the legitimate traffic to GoogleDrive, making it harder for
security teams to detect the threat.
The fifth stage (payload with reverse shell)
This payload is a simple reverse shell written in Rust it creates a TCP connection to a command
and control (C2) server and listens for commands to execute on the infected machine, the payload
first sets up the IP address and port number of the C2 server.
When a command is received, it is executed using the cmd command in Windows. The output of
the command is captured and sent back to the C2 server, the loop continues until the connection
is closed by the C2 server or an error occurs while receiving data from the server.
The attackers uses a .BAT file that resembles the Microsoft Windows Time Service, to install the
backdoor. The backdoor comes in the form of a service dynamic link library (DLL) called w64time.dll.
The description and filename make it look like a valid Microsoft DLL. Once up and running, it allows
the attackers to exfiltrate files or upload and execute them, thus functioning as a second-stage postern
when needed.
1. BAT file: The attackers used a .bat file similar to the one below to install the backdoor as a harmless
-looking fake Microsoft Windows Time service.
2. DLL backdoor: I have developed a simulation of the backdoor that the attackers used in the actual
attack.
3. Backdoor Listener: I was here developed a simple listener script that waits for the incoming
connection from the backdoor when it is executed on the target machine.
According to what the Cisco team said, they were not able to identify the method by which this
backdoor was installed on the victims’ systems.
The first stage (.BAT file)
The attackers used a .bat file similar to the one below to install the backdoor as a harmless-looking
fake Microsoft Windows Time service, the .bat file is also setting the configuration parameters in
the registry the backdoor is using.
I wrote a .bat file identical to the one the attackers used to the one below to install the backdoor
as a fake Microsoft Windows Time service.
These commands add various configuration parameters for the W64Time service to the registry.
Hosts: Sets the hosts and port (values removed for security).
"Here, I have developed a simulation of the backdoor that the attackers used in the actual attack."
First, the backdoor reads its configuration from the registry and saves it in the "result" structure,
which is later on assigned to the "sConfig" structure.
This backdoor includes the following components:
1.Service Control Handler: Registers a service control handler to manage the service's state.
2.Main Malware Function: Placeholder for the main logic of the backdoor.
3.Configuration Reading: Initializes the configuration with placeholders for actual values.
4.C2 Command Retrieval: Simulates retrieving commands from a Command and Control (C2) server.
6.Service Loop: Continuously connects to the C2 server and processes commands, with error
handling and cleanup.
Adjust the placeholder values and add the actual logic for backdoor operations and C2 command
processing as per your requirements.
The third stage (Backdoor Listener)
I was here developed a simple listener script that waits for the incoming connection from the
backdoor when it is executed on the target machine.
Accepts incoming connections: When a client connects, it prints the client's IP address and port.
Sends the command: Encodes the command as bytes and sends it over the socket.
Prompts for a command: Asks the user to enter a command to send to the connected client.
Receives output from the client: Reads data in chunks of 4096 bytes.
This is a simulation of attack by (Ember Bear) APT group targeting energy Organizations in Ukraine
the attack campaign was active on April 2021, The attack chain starts wit spear phishing email sent
to an employee of the organization, which used a social engineering theme that suggested the
individual had committed a crime. The email had a Word document attached that contained a
malicious JavaScript file that would download and install a payload known as SaintBot
(a downloader) and OutSteel (a document stealer). The OutSteel tool is a simple document stealer.
It searches for potentially sensitive documents based on their file type and uploads the files to a
remote server. The use of OutSteel may suggest that this threat group’s primary goals involve data
collection on government organizations and companies involved with critical infrastructure.
The SaintBot tool is a downloader that allows the threat actors to download and run additional tools
on the infected system. SaintBot provides the actors persistent access to the system while granting
the ability to further their capabilities. I relied on palo alto to figure out the details to make this
simulation: https://unit42.paloaltonetworks.com/ukraine-targeted-outsteel-saintbot/
This attack included several stages including links to Zip archives that contain malicious shortcuts
(LNK) within the spear phishing emails, as well as attachments in the form of PDF documents,
Word documents, JavaScript files and Control Panel File (CPL) executables. Even the Word
documents attached to emails have used a variety of techniques, including malicious macros,
embedded JavaScript and the exploitation of CVE-2017-11882 to install payloads onto the system.
With the exception of the CPL executables, most of the delivery mechanisms rely on PowerShell
scripts to download and execute code from remote servers.
1. Create the Word Document: Write a Word document (.docx) containing the exploitation of
CVE-2017-11882 to install payloads onto the system.
2. CVE-2017-11882: this exploit allow an attacker to run arbitrary code in the context of the current
user by failing to properly handle objects in memory.
3. Data exfiltration: over Discord API C2 Channe, This integrates Discord API functionality to facilitate
communication between the compromised system and the attacker-controlled server thereby
potentially hiding the traffic within legitimate Discord communication.
5. The attackers used .BAT file to disable Windows Defender functionality, It accomplishes this by
executing multiple commands via CMD that modify registry keys and disabling Windows Defender
scheduled tasks.
6. OutSteel: is a file uploader and document stealer developed with the scripting language.
Some examples of the PDF and docx files that was used in this attack.
In the beginning, I will create a Word file that I will use to injections for a vulnerability that
attackers used in the actual attack to install payloads on the system.
April 2021: Bitcoin-themed spear phishing emails targeting Ukrainian government organizations.
The second stage (exploit Microsoft Office Memory Corruption Vulnerability
CVE-2017-11882)
This vulnerability allow an attacker to run arbitrary code in the context of the current user by failing
to properly handle objects in memory, I then placed a Word file in the phishing email, including
links to Zip files containing malicious shortcuts (LNK).
sudo updatedb
The attackers used the Discord C2 (Command and Control) API as a means to establish a
communication channel between their payload and the attacker's server. By using Discord as a
C2 server, attackers can hide their malicious activities among the legitimate traffic to Discord,
making it harder for security teams to detect the threat.
First, i need to create a Discord account and activate its permissions, as shown in the following figure
3. Go to "Bot", find "Privileged Gateway Intents", turn on all three "Intents", and save.
This script integrates Discord API functionality to facilitate communication between the
compromised system and the attacker-controlled server, thereby potentially hiding the traffic within
legitimate Discord communication and checks if the Discord bot token and channel ID are provided.
If they are, it starts the Discord bot functionalities; otherwise, it proceeds with just the IP and port.
This way, the script can continue the connection without the Discord details if they are not entered.
1.Locale Check: The IsSupportedLocale function checks if the system's locale matches specific
locales.
2.Downloading Payload: The DownloadPayload function downloads a file from a specified URL
and saves it to a specified filepath.
3.Injecting into a Process: The InjectIntoProcess function injects a DLL into a running process by
its name.
4.Self-Deleting: The SelfDelete function deletes the executable after its execution.
The fifth stage (disable windows defender)
This batch file is used to disable Windows Defender functionality. It accomplishes this by executing
multiple commands via CMD that modify registry keys and disabling Windows Defender scheduled
tasks.
This is a simulation of attack by (Primitive Bear) APT group targeting the State Migration Service of
Ukraine the attack campaign was active from first of December to June 2021, The attack chain starts
with Word document sent to the victim via email then VBS payload is used to obtain the command
and control, before placing the payload or injecting it into the Word file an obfuscation of the payload
is done to create an evasion of the detection then it is injected through the macro into the Word
document, Then i create an SFX archive and put the payload Word file inside it to get command and
control and use this SFX archive to perform a spear phishing attack then i get command and control
by opening the Word file. I relied on palo alto networks to figure out the details to make this
simulation: https://unit42.paloaltonetworks.com/gamaredon-primitive-bear-ukraine-update-2021/
This attack included several stages including Create an SFX file with Word File inside it. This Word
File contains VBS script which is responsible for command and control and make obfuscation VBS
script payload before putting it inside the word file this sent through spear phishing attack and make
remote communication by utilizes DES encryption for secure data transmission between the attacker
server and the target.
1. Create the Word Document: Write a Word document (.doc or .docx) containing the macro with the
obfuscated VBS payload. The macro should be designed to execute the payload when the
document is opened.
2. Create a VBScript payload designed to establish a reverse connection to the Command and
Control (C2) server.
3. Obfuscate the VBS Payload: Obfuscate the VBS payload to make it more difficult to detect
by antivirus software or security solutions.
4. Create a Self-Extracting Archive with WinRAR: Use WinRAR to create a self-extracting (SFX)
archive. Add the Word document containing the macro and the obfuscated VBS payload to the
archive.
5. Place the obfuscated VBS payload and word file inside the SFX archive to send to the target.
6. Final result make remote communication by utilizes DES encryption for secure data transmission
between the attacker server and the target.
The first stage (delivery technique)
I began by drafting the phishing email in a Word document for the upcoming attack. Subsequently,
prior to crafting the payload, which will consist of a VBS Script injected into macros, I will encapsulate
them within an SFX file. The assault targeted the Ukrainian Immigration Department, with the phishing
correspondence purporting to offer financial assistance totaling 2 billion dollars.
This word file will be used to place the VBS script payload into it after obfuscation here will help make
detection more difficult when placing this VBS script inside the macro in word file.
The Second stage (VBScript payload)
First i will create a VBS payload which is a simple VBS script designed to establish a reverse
connection to the C2 server then open a Word file enable macros and insert the payload into the
macro finally i will save the document.
Save the Word file with the obfuscated VBScript payload embedded in the macro, thus i will be able
to execute for the payload file when opening word file.
The fifth stage (make SFX archive)
Now i will create SFX Archive using WinRAR and take the SFX file that contains the Word Document
inside it with obfuscated VBS payload via the macro and send it in a spear phishing.
3.In the "Archive name and parameters" window, select "SFX" as the archive format.
4.Configure the SFX options as desired, including the extraction path and execution parameters.
get_attacker_info and get_port: Prompts for the IP address and port number.
main: Sets up a TCP server, accepts connections, executes commands, encrypts results, and sends
Kapeka, which means “little stork” in Russian, is a flexible backdoor written in C++. It allows the
threat actors to use it as an early stage toolkit, while also providing long term persistence to the
victim network. Kapeka’s dropper is a 32-bit Windows executable that drops and launches the
backdoor on a victim machine. The dropper also sets up persistence by creating a scheduled task or
autorun registry. Finally, the dropper removes itself from the system. If you need to know more about
Kapeka backdoor for Voodoo Bear APT group:
https://blog.polyswarm.io/voodoo-bears-kapeka-backdoor-targets-critical-infrastructure
2. Testing payload : I used payload written by Python only to test C2 (testing payload.py), if there
were any problems with the connection (just for test connection) before writing the actual payload.
3. DLL backdoor: I have developed a simulation of the kapeka backdoor that the attackers used
in the actual attack.
The first stage (RSA C2-Server)
This PHP C2 server script enable to make remote communication by utilizes RSA encryption for
secure data transmission between the attacker server and the target.
rsa_encrypt($data, $public_key):
Purpose: Encrypts data using the RSA public key. Process: The function takes the data and the
public key as input, then uses openssl_public_encrypt to encrypt the data with the provided public
key. Output: Returns the encrypted data.
rsa_decrypt($data, $private_key):
Purpose: Decrypts data using the RSA private key. Process: The function takes the encrypted
data and the private key as input, then uses openssl_private_decrypt to decrypt the data with the
provided private key. Output: Returns the decrypted data.
The Second stage (Testing payload)
I used payload written by Python only to test C2 (testing payload.py), if there were any problems
with the connection (just for test connection) before writing the actual payload.
RSA and PKCS1_OAEP from pycryptodome: For encryption and decryption using RSA.
rsa_decrypt(data, private_key): Decrypts data using the provided private key (not used in this script).
Note: Ensure that the server is correctly sending RSA-encrypted commands and handling the
responses appropriately. The script requires the pycryptodome library for RSA encryption and
decryption:
I have developed a simulation of the kapeka backdoor that the attackers used in the
actual attack.
• First thread: This is the primary thread which performs the initialization and exit
routine, as well as C2 polling to receive tasks or an updated C2 configuration.
• Second thread: Monitors for Windows log off events, signaling the primary thread to
perform the backdoor’s graceful exit routine upon log off.
• Third thread: Monitors for incoming tasks to be processed. This thread launches subsequent
threads to execute each received task.
• Fourth thread: Monitors for completion of tasks to send back the processed task results to the C2.
LinkedIn: /in/abdulrehman-a-4472a3243/
Github:/S3N4T0R-0X0
To be continued...