TAMECAT - Analysis of an Iranian PowerShell-Based Backdoor

A detailed technical analysis of TAMECAT, a PowerShell-based backdoor used by the Iranian state-sponsored APT42 in espionage operations.

TAMECAT - Analysis of an Iranian PowerShell-Based Backdoor
đź’ˇ
Artifacts from our analysis are available on our GitHub.

TAMECAT is a PowerShell-based malware that can execute various commands to collect sensitive information. Reporting from the Israel National Digital Agency dives into the modular nature of the TAMECAT and its functionality. The malware is used by APT42, an Iranian state-sponsored cyber-espionage actor, during its espionage operations. Reporting from Israel indicates that TAMECAT was observed being deployed in espionage campaigns targeting high-value senior defense and government officials. The group leverages social engineering to build rapport with victims over an extended period before gaining access to their environments. This blog will outline TAMECAT’s capabilities and how it exfiltrates data. 

This overview includes:

  • Malware Analysis
  • Recommendations
  • Indicators of Compromise
  • MITRE ATT&CK TTPs

Israel’s National Digital Agency shared a breakdown of the in-memory modules available with TAMECAT. This included the ability to extract data from Microsoft Edge using remote debugging, screen captures, and suspending Chrome for data collection. 

Figure 1: Details Of TAMECAT's capabilities. Source: Israel National Defense Agency

In the analysis, the researchers noted that the malware received commands from a Telegram bot. The malware used messages from the bot to download additional scripts. 

Figure 2: Domains observed by Israel's National Defense Agency. Source: Israel National Defense Agency

Malware Analysis

The intrusion sample that we analyze in this blog starts with a VBScript script that downloads TAMECAT’s first stage. This script checks which antivirus products are running on the system. This check determines whether the script uses conhost and PowerShell or cmd.exe and curl to download the second stage. The sample used in this analysis is available on VirusTotal.

SHA256

5404e39f2f175a0fc993513ee52be3679a64c69c79e32caa656fbb7645965422

SHA1

3fd06c930ddc4b1914151f69454c087a42413a24

MD5

d7bf138d1aa2b70d6204a2f3c3bc72a7

ssdeep

24:W/AnDhKaG2Ds6w8NlrZ5OGPeAbqf+PvENPB3B3CNdHPdYqf+PveBE:YghhG2D68NVfOGPLZvEN9hUhOveE

File Size

1.25 KB

File Type

VBA

Figure 3: VBScript used to download TAMECAT.

When the VBScript file is executed, it uses WMI to retrieve a list of installed antivirus products on the host. The returned list is then used to determine which scripting interpreter is used to download the second stage. If the antivirus list contains “indows”, the VBScript uses conhost to launch PowerShell. The PowerShell script uses wget to download the loader TAMECAT (081419a484bbf99f278ce636d445b9d8). Once the file is downloaded, the script is executed using PowerShell. The script uses an obfuscated command to execute the downloaded PowerShell Script. 

Figure 4: Code used to launch PowerShell and download TAMECAT.
Figure 5: Obfuscated Invoke-Expression command.

This obfuscated command decodes as the following:

Obfuscated Command

Deobfuscated Command

gcm

Get-Command

*e-e?p*

Invoke-Expression

If the antivirus list does not contain Windows, then the VBScript uses cmd.exe and curl to download another piece of malware. At the time of analysis, the link was down, so the payload could not be analyzed.

Figure 6: If the computer does not contain Windows within the AV list, it uses curl to download a secondary payload.

Nconf.txt (TAMECAT PowerShell Loader)

This is the TAMECAT loader that was hosted on tebi[.]io. This script contains several variables containing arrays of values, as well as two functions. The functions are used to decode data and execute additional code. The sample is available on Triage and VirusTotal

SHA256

bd1f0fb085c486e97d82b6e8acb3977497c59c3ac79f973f96c395e7f0ca97f8

SHA1

0ef4f7a8d7b1d34e10faa0bca1dcb76a518dd417

MD5

081419a484bbf99f278ce636d445b9d8

ssdeep

192:ENampkg6c3iKtzYC4+HxeycEUj/Pv9w7EczGRThbD5eROPURDcEaoY62DFRWJCXu:Ia8h3BKDWx2lszGN5DeOPURwvoX2RRY

File Size

10.34 KB

File Type

PowerShell

Figure 7: Code of the nconf.txt.
Figure 8: Functions within nconf.txt PowerShell Script.

The Gorba function defines two parameters called $te12 and $k12ey. The values of these parameters are defined at the end of the script and are shown in the table below.

Figure 9: AES encrypted code within nconf.txt.

Parameter

Value

$te12

v+UDXK47mBGgYqTbOXjXVD6MzhZenTfVf6CKxQFp2+AiPHMvmA2a4IiBz4rOi8ffxWdXFtrPk6UABw1b6oBPsW1VV/HNU0mf8jH7xsoBAHY5Sp6vdYc7WGZ6SYO72KIH/hOyBlS5wc7Y86wJR9naW+0nINCYZV6RyD5t/fDpqEoRYW6dHwoebLECkEck/N5C1jhlFHaoS51QKSfgraHI5iRiT6pfpqUNeJHbYz3VYuo/j2FZ6f5BCJgXoHKPmf4pUSwSZH0qQSa98blmdAH+tG7jc3AUE76IHx4xkzxAldO/4b97duoI6rm+Ucy3rRHHrVnPQ0TvvTvudD/LDBwn3DkNcKSTDvEQDwIgni/MU7BOwklcE1+qQjabXTGr+CrL0c53dNA4OGNYkBAnLokjcoNxKmxbCSK3oSdFEz2+htgPMOjq14IGoPSOWcPX2CVK

$k12ey

T2r0y1M1e1n1o0w1

The value stored in the $k12ey parameters is the same one identified by Volexity in a variant of PowerStar. The Yara rule shared by Volexity closely matches the commands observed in this analysis. 

From there, the script attempts to download the next stage of TAMECAT from a base64-encoded URL. The PowerShell script uses a hardcoded user-agent within the network traffic. The script uses the downstring command to retrieve text from tebi[.]io. The URL is base64-encoded in the script, and before it is decoded, the script drops the first 3 bytes of the encoded string. The file attempts to download text within a file called df32s.txt, which holds base64-encoded content.

Figure 9: The encoded URL stored within the PowerShell file.

User-Agent

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36

Figure 10: Content hosted on the encoded URL.
Figure 11: Data manipulation code used to transform the encoded data.

The script base64-decodes the file's contents and then performs the following actions on each byte:

  • Perform a bitwise not on each bit and convert to base2 
  • Convert to a string and extract 8 characters starting from the 24th character
  • Convert to Byte

Once this manipulation is complete, the script converts the bytes to a UTF-8-Encoded string.

Figure 12: The decoded Borjol function.

The decoded content reveals an additional function that is executed with the value stored in $te12. This function defines an AES decryptor used to decrypt the value stored in $te12 after it is base64-decoded.

AES Settings

Value

Block Size

128

Key Size

256

Key

kNz0CXiP0wEQnhZXYbvraigXvRVYHk1B

IV

0T9r1y1M2e0N0o1w

Figure 13: Decrypted data from Figure 9.

This decoded string is passed to the Borjol function.

Figure 14: Decoded content from Figure 13.

This decrypted data contains functions that manipulate data in the following ways.

Function Name

Description

Borjoly

Decodes base64-encodes data and then decrypts it using AES

Borpos

Encrypts data using AES

x

Converts a base64-encoded character and encodes it into a UTF8-encoded string

xs

Generates a random 16-character string

The PowerShell script uses these functions to manipulate data while attempting to exfiltrate it. The script writes an alphanumeric string, which Google believes to be a victim identifier to %LocalAppData%\config.txt.

Figure 15: Unique identifier being stored within config.txt.

The script then creates a new directory called Chrome in %LocalAppData%. From there, the script defines the SessionUrl, the hostname used for network communication. The value for this parameter is a hxxps://accurate-sprout-porpoise[.]glitch[.]me, which was defined as a global parameter in the function Borjol.

Figure 16: Code used to define the SessionUrl using parameters from the Borjol function.

From there, the script collects details about the operating system, including:

  • OS
  • ComputerName
  • Token (GILNH9LX6TCZ9V8ZZSUF) - the value specified in the $configtxt parameter.

This data is then passed to the Borpos function for encryption before being exfiltrated via a POST request to the domain hxxps://accurate-sprout-porpoise[.]glitch[.]me. The key is the value kNz0CXiP0wEQnhZXYbvraigXvRVYHk1B, while the initialization vector is created using the xs function. The script also adds the header Content-DPR, which stores the IV value.

Figure 17: Code of the Borpos function.

function xs() {

    return  - join ((65..90)  +  (97..122) | Get - Random  - Count 16 | % {

        [char]$_

    }


    )

}

The malware then waits for the C2’s response. If the status code is not 400 and the response is not empty, then the script calls the Borjoly function to decode the response from the C2. The data is separated by ¶ and contains the following four values:

  • language
  • Command
  • ThreadName
  • StartStop
Figure 18: Code of the Borjoly function.

The command is in base64-encoded format. Google identified that the $Language parameter will be used to execute either PowerShell or C# code, and the $StartStop will be used to download additional content, execute, or terminate a command. 

Figure 19: Code that is run based on the response from the C2 server.

Conclusion

TAMECAT is a PowerShell-based malware used by APT42 during its espionage campaigns. It has gone through several iterations, with different variants sharing several similarities. These similarities include the use of Base64-Encoded strings within arrays, the use of array fragments to generate code, and PowerShell string replacement and wildcards. The developers behind TAMECAT have also been observed using platforms such as Discord and Telegram as C2 channels. 

Recommendations

Methods to mitigate the risks posed by malware, such as TAMECAT, include:

  • Deploy EDR/AV solutions: EDR or AV solutions can detect malicious process chains and anomalous activity that may indicate a malware infection.
  • Monitor for wscript launching other scripting interpreters: VBS scripting launching PowerShell or cmd.exe is often suspicious.
  • Expand PowerShell logging: Consider enabling script-block logging to ensure security analysts can see the contents of scripts that were executed.
  • Secure PowerShell in Corporate Environments: Organizations can enforce script execution policies that allow only signed scripts to run. Moreover, PowerShell usage should be restricted to users who need to use it.
  • User Education: Users can help mitigate the risk of phishing emails and targeted social engineering campaigns. Users should also be wary of unsolicited attachments or senders that pressure them to open attachments or download files.
đź’ˇ
The Australian Signals Directorate has released guidance on Securing PowerShell in the enterprise.

Indicators of Compromise

The table below lists TAMECAT network IOCsthat have been identified and added to the Pulsedive platform. This data can be queried in Pulsedive using the Explore query threat=TAMECAT and is available for export in multiple formats (CSV, STIX 2.1, JSON).

TAMECAT  IOCs

hxxps[://]s3[.]tebi[.]io/icestorage/config/nconf[.]txt

hxxps[://]s3[.]tebi[.]io/icestorage/df32s[.]txt

hxxps://accurate-sprout-porpoise[.]glitch[.]me

MITRE ATT&CK TTPs

Technique

Tactic

Command and Control

Application Layer Protocol: Web Protocols (T1071.001)

Data Encoding: Standard Encoding (T1132.001)

Ingress Tool Transfer (T1105)

Encrypted Channel: Symmetric Cryptography (T1573.001)

Defense Evasion

Deobfuscate/Decode Files or Information (T1140)

Obfuscated Files or Information: Encrypted/Encoded (T1027.013)

Discovery

Software Discovery: Security Software Discovery (T1518.001)

System Information Discovery (T1082)

Execution

User Execution: Malicious File (T1204.002)

Windows Management Instrumentation (T1047)

Command and Scripting Interpreter: PowerShell (T1059.001)

Command and Scripting Interpreter: Windows Command Shell (T1059.003)

Command and Scripting Interpreter: Visual Basic (1059.005)

Exfiltration

Exfiltration Over C2 Channel (T1041)

References

https://govextra.gov.il/national-digital-agency/cyber/research/spearspecter/

https://cloud.google.com/blog/topics/threat-intelligence/untangling-iran-apt42-operations 

https://apt.etda.or.th/cgi-bin/listgroups.cgi?t=TAMECAT&n=1 

https://attack.mitre.org/software/S1193/ 

https://www.virustotal.com/gui/file/5404e39f2f175a0fc993513ee52be3679a64c69c79e32caa656fbb7645965422/details 

https://tria.ge/240814-t493jsscke/static1

https://www.virustotal.com/gui/file/bd1f0fb085c486e97d82b6e8acb3977497c59c3ac79f973f96c395e7f0ca97f8/detection

https://github.com/volexity/threat-intel/blob/main/2023/2023-06-28%20POWERSTAR/indicators/rules.yar

https://www.cyber.gov.au/sites/default/files/2025-03/Securing%20PowerShell%20in%20the%20enterprise%20%28October%202021%29.pdf